C=============================================================================C C Comprehensive Ocean-Atmosphere Data Set (COADS): Fortran 77 Library C C Filename:level: ebcasc.f:01A 13 March 1998 C C Function: Convert: From/To ebcdic/ascii Author: D.Joseph et al. C C=============================================================================C C Software documentation for the (invariant) user-interface routines {ebcasc, C ascebc,iasc,iebc}: C C Functionality: These routines provide a complete, reversible mapping of all C 8-bit character patterns from ebcdic to ascii, and vice versa. {ebcasc} C converts num ebcdic characters from character string ebc into asc (which may C be the same string), and {ascebc} reverses the conversion (ebc and asc must C be of length num or greater; if called with an array element as an argument C the length of ebc or asc is the length of that one element of the array). C {ebcasc} and {ascebc} call {iasc} and {iebc} (which also may be called C directly) to implement the actual mapping in terms of integers. C C Machine dependencies: None known. Intrinsic Fortran 77 functions ICHAR and C CHAR are used, which produce results "based on the position of the character C in the processor collating sequence" (according to the ANSI standard). C For more information: See and (electronic documents). C=============================================================================C C WARNING: Code beyond this point should not require any modification. C C=============================================================================C c-----------------------------------------------------------------------3456789 subroutine ebcasc(ebc,asc,num) c c convert num characters from ebcdic to ascii, ebc is ebcdic input string c and asc is ascii output string, ebc and asc may be the same string. c character ebc*(*),asc*(*) do 20 i=1,num asc(i:i)=char(iasc(ichar(ebc(i:i)))) 20 continue return end c-----------------------------------------------------------------------3456789 subroutine ascebc(asc,ebc,num) c c convert num characters from ascii to ebcdic, asc is ascii input string c and ebc is ebcdic output string, asc and ebc may be the same string. c character asc*(*),ebc*(*) do 20 i=1,num ebc(i:i)=char(iebc(ichar(asc(i:i)))) 20 continue return end c-----------------------------------------------------------------------3456789 function iasc(iebc) c c convert the ichar of a character from ebcdic to ascii c c the conversion table corresponds to the NCAR import/export conversion c and should give the same results. c dimension ntab(256) data ntab/ a 000,001,002,003,156,009,134,127,151,141,142,011,012,013,014,015, b 016,017,018,019,157,133,008,135,024,025,146,143,028,029,030,031, c 128,129,130,131,132,010,023,027,136,137,138,139,140,005,006,007, d 144,145,022,147,148,149,150,004,152,153,154,155,020,021,158,026, e 032,160,161,162,163,164,165,166,167,168,213,046,060,040,043,124, f 038,169,170,171,172,173,174,175,176,177,033,036,042,041,059,094, g 045,047,178,179,180,181,182,183,184,185,229,044,037,095,062,063, h 186,187,188,189,190,191,192,193,194,096,058,035,064,039,061,034, i 195,097,098,099,100,101,102,103,104,105,196,197,198,199,200,201, j 202,106,107,108,109,110,111,112,113,114,203,204,205,206,207,208, k 209,126,115,116,117,118,119,120,121,122,210,211,212,091,214,215, l 216,217,218,219,220,221,222,223,224,225,226,227,228,093,230,231, m 123,065,066,067,068,069,070,071,072,073,232,233,234,235,236,237, n 125,074,075,076,077,078,079,080,081,082,238,239,240,241,242,243, o 092,159,083,084,085,086,087,088,089,090,244,245,246,247,248,249, p 048,049,050,051,052,053,054,055,056,057,250,251,252,253,254,255/ iasc=ntab(iebc+1) return end c-----------------------------------------------------------------------3456789 function iebc(iasc) c c convert the ichar of a character from ascii to ebcdic c c the conversion table corresponds to the NCAR import/export conversion c and should give the same results. c dimension ntab(256) data ntab/ a 000,001,002,003,055,045,046,047,022,005,037,011,012,013,014,015, b 016,017,018,019,060,061,050,038,024,025,063,039,028,029,030,031, c 064,090,127,123,091,108,080,125,077,093,092,078,107,096,075,097, d 240,241,242,243,244,245,246,247,248,249,122,094,076,126,110,111, e 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, f 215,216,217,226,227,228,229,230,231,232,233,173,224,189,095,109, g 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, h 151,152,153,162,163,164,165,166,167,168,169,192,079,208,161,007, i 032,033,034,035,036,021,006,023,040,041,042,043,044,009,010,027, j 048,049,026,051,052,053,054,008,056,057,058,059,004,020,062,225, k 065,066,067,068,069,070,071,072,073,081,082,083,084,085,086,087, l 088,089,098,099,100,101,102,103,104,105,112,113,114,115,116,117, m 118,119,120,128,138,139,140,141,142,143,144,154,155,156,157,158, n 159,160,170,171,172,074,174,175,176,177,178,179,180,181,182,183, o 184,185,186,187,188,106,190,191,202,203,204,205,206,207,218,219, p 220,221,222,223,234,235,236,237,238,239,250,251,252,253,254,255/ iebc=ntab(iasc+1) return end