Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange expression (needs explaining)...

Status
Not open for further replies.

juliak66ussd

Programmer
Feb 25, 2004
5
CA
Hi,

I port one old FORTRAN-IV code and I see this:

TRIP=TRIP-"60

what exactly can it be?
I mean this "60 - is that like hexadecimal notation?
I assume that this is a character code, but not sure.

There is also "140 somewhere in that code - can it be a character?

It does not look like a string, because there is no enclosing double quote.

AND IT COMPILES! by G77... weird.

I appreciate any help.
 
Just tried it on g77 V0.5.25. Doesn't even compile. Which version of g77 are you using?
 
Hi both

I tried this on me old F77 compiler from Microsoft, and it did NOT compile (got error). I have the following suggestions:

1) It was an error originally, but slipped through the old compiler that was used. This in unlikely, if "140 also in the program.

2) It could mean 60 seconds (= one minute) or 60 minutes (= one hour). The name TRIP could indicate that the program is calculating some kind of time (traveltime or duration of something).

3) If the program was translated from some other character set than ASCII, the character " could stand for something else. I find that very unlike though. [What was the punch code for this character on the punch-cards in the old days?]

4) Something quite different, that nobody remembers anymore ... ...
 
My bad!
It does not compile by my G77.
It says "expression has no closing quote".
It is definitely a numerical notation, because I see code like:

IF(KHAR .GE. "140) KHAR=KHAR-"40

 
Hi both

IF(KHAR .GE. "140) KHAR=KHAR-"40

This sounds like the program is trying to change lower case characters to upper case characters. If it is so, this "40 and "140 are octal numbers. Octal 40 is decimal 32, exactly the difference between the numerical code for the same character in upper and lower case. Octal 140 is also the last character before the the lower case "a" (which is decimal 97 = octal 141). The name KHAR also suggest that.
 
... and more about octal representation from
Allowed representations of the octal number 1357 are shown here:
Code:
Fortran 77   Not available.  
Fortran 90   O'1357' or O"1357" only in data statements.  
IBM XLF      O'1357' or O"1357" or '1357'O or "1357"O (either upper or lower case O; up to 64 bits).  
CIVIC        1357B  
CF77         1357B or O'1357' or O"1357" treated as integers.  
CF90         1357B or O'1357' or O"1357" treated as typeless.  
DEC F77      O'1357' or O"1357" or '1357'O or "1357"O (which are typeless) or "1357 (which is typed integer)  
DEC F90      O'1357' or O"1357" or '1357'O or "1357"O  
PGF77        o'1357' or '1357'O (either upper or lower case O; single quotes only; up to 64 bits).  
Sun F77      o'1357' or '1357'O 
             "1357 is octal representation of integer.  
Sun F90      1357B or O'1357' or O"1357" treated as typeless. Up to 11 octal digits are allowed.
 
To compile the source with octal constants use the option -fvxt of g77:

octal.for
Code:
[COLOR=#0000ff]C     to use octal numbers in g77: compile with the option -fvxt[/color]
      IOCTAL [COLOR=#804040][b]=[/b][/color] [COLOR=#ff00ff]"30 + "[/color][COLOR=#ff00ff]32[/color] 
      [COLOR=#804040][b]WRITE[/b][/color]([COLOR=#804040][b]*[/b][/color],[COLOR=#804040][b]*[/b][/color]) [COLOR=#ff00ff]'IOCTAL = '[/color], IOCTAL
      [COLOR=#a020f0]END[/color]
Code:
$ g77 -fvxt octal.for -o octal

$ octal
 IOCTAL =  50
 
Thanks everyone!
Great help!

The routine in question is converting from string, like "-66.62738" into a REAL, so "xx must be octal character values for sure.

I will be converting these into ASCII, because I think this program used EBCDIC encoding - it was written in 1979.

Cheers!
 
I doubt if it's in EBCDIC, because -fvxt is option for the VAX FORTRAN dialect -see:
And IMO VAX was the ASCII machine.

If it was in EBCDIC then the calculations like
IF(KHAR .GE. "140) KHAR=KHAR-"40
to translate lowercase into uppercase could not be applied, because in EBCDIC the lowercase and uppercase characters are not continuos: There are holes between lowercase characters a-i, j-r and s-z as like between uppercase characters A-I, J-R and S-Z.
..and the difference between 'A' and 'a' isn't in EBCDIC 32(dec)=40(oct) like in ASCII, but 64(dec)=100(oct)
-see:
 
It is probably for converting something like 1.23e9 to 1.23E9
 
Octal 60 is ascii code of '0' digit.
So TRIP-"60 expression yields correspondent digit value.

It's a common program case in Fortan IV era...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top