SUBROUTINE EBCASC (NC,ND,NUM) C Convert NUM characters from EBCDIC to ASCII, NC is EBCDIC input string C and ND is ASCII output string, NC and ND may be the same string. C C The conversion table corresponds to the NCAR import/export conversion C and should give the same results. C C HISTORY: C 1994 Dec: last modified by Dennis Joseph, probably a modification C of the Cray version C 2002 Nov: Ported to IBM AIX where 8-bit values are treated as signed C integers (Barnes). This version has been tested on SunOS C and AIX CHARACTER NC*(*),ND*(*) DIMENSION NTAB(256) SAVE NTAB 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,091,046,060,040,043,033, f 038,169,170,171,172,173,174,175,176,177,093,036,042,041,059,094, g 045,047,178,179,180,181,182,183,184,185,124,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/ C Discrepancies are: element was is Graphic C 74 213 91 [ C 79 124 33 ! C 90 33 93 ] C 106 229 124 | C e 032,160,161,162,163,164,165,166,167,168,213,046,060,040,043,124, C f 038,169,170,171,172,173,174,175,176,177,033,036,042,041,059,094, C g 045,047,178,179,180,181,182,183,184,185,229,044,037,095,062,063, DO 20 I=1,NUM C ND(I:I)=CHAR(NTAB(ICHAR(NC(I:I))+1)) 1994 version IINT = ICHAR (NC(I:I)) IF (IINT .LT. 0) IINT = IINT + 256 ND(I:I) = CHAR (NTAB(IINT+1)) 20 CONTINUE RETURN END C Dennis Joseph's 1994 version commented out: C subroutine ebcasc(nc,nd,num) Cc Cc convert num characters from ebcdic to ascii, nc is ebcdic input string Cc and nd is ascii output string, nc and nd may be the same string. Cc Cc the conversion table corresponds to the NCAR import/export conversion Cc and should give the same results. Cc C character nc*(*),nd*(*) C dimension ntab(256) C data ntab/ C a 000,001,002,003,156,009,134,127,151,141,142,011,012,013,014,015, C b 016,017,018,019,157,133,008,135,024,025,146,143,028,029,030,031, C c 128,129,130,131,132,010,023,027,136,137,138,139,140,005,006,007, C d 144,145,022,147,148,149,150,004,152,153,154,155,020,021,158,026, C e 032,160,161,162,163,164,165,166,167,168,213,046,060,040,043,124, C f 038,169,170,171,172,173,174,175,176,177,033,036,042,041,059,094, C g 045,047,178,179,180,181,182,183,184,185,229,044,037,095,062,063, C h 186,187,188,189,190,191,192,193,194,096,058,035,064,039,061,034, C i 195,097,098,099,100,101,102,103,104,105,196,197,198,199,200,201, C j 202,106,107,108,109,110,111,112,113,114,203,204,205,206,207,208, C k 209,126,115,116,117,118,119,120,121,122,210,211,212,091,214,215, C l 216,217,218,219,220,221,222,223,224,225,226,227,228,093,230,231, C m 123,065,066,067,068,069,070,071,072,073,232,233,234,235,236,237, C n 125,074,075,076,077,078,079,080,081,082,238,239,240,241,242,243, C o 092,159,083,084,085,086,087,088,089,090,244,245,246,247,248,249, C p 048,049,050,051,052,053,054,055,056,057,250,251,252,253,254,255/ C do 20 i=1,num C nd(i:i)=char(ntab(ichar(nc(i:i))+1)) C 20 continue C return C end