Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Fortran to ANSI C 2

Status
Not open for further replies.

madmaxdev

New member
Aug 8, 2010
2
Hi,
I'm "translating" some Fortran code into ANSI C code and I'm not a Fortran developer!

Now I'm in a deadline. I've found some without meaning (for me!!!) code.

What does it means? How can I translate in ANSI C?

IF(X-TAB(NXP)) 70002, 4 ,70004
70002 NXP = NXP - 1
IF(X-TAB(NXP)) 70002, 4 ,70001
70004 IF(X-TAB(NXP+1)) 70001,70005,70006
70006 NXP = NXP + 1
4 I1 = NXP + NX

Thanks in advance.

Max
 
Replies continue below

Recommended for you

It is an arithmetic if

1st label if it the expression is less than zero
2nd label if it is equal to zero
3rd label if it is greater than zero

Using gotos

IF(X-TAB(NXP)) 70002, 4 ,70004

would be

if (X - TAB[NXP] < 0) goto L70002
if (X - TAB[NXP] == 0) goto L4
goto L70004

Three way jumps were invented in the days when 3 way jumps were common in assembler.
 
Thaks johnhors and xwb,
this code is really old (1997).
This is not the "worst" part of this "spaghetti code"!!!

I've inherit this code...It's not mine :)

Bye

Max
 
No, I wouldn't own up to it either!

I think this code is much much older than 1997. This statement was obsolete before fortran 77 came out, its probably 40 years or more old !

To be fair to the original programmer, at the time it could have been the only logic option available, fortran pre-dates all other languages so there was no choice.


 
It may have been written for compatibility with Fortran II. I worked on several projects where the code had to compile on Fortran II, Fortran IV and Fortran 77 and the only option was to use arithmetic ifs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor