×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Fortran to ANSI C2

## Fortran to ANSI C

(OP)
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

Max

### RE: Fortran to ANSI C

This is very old Fortran (not sure what standard, IV and earlier ?), it is an "Arithmetic IF" statement, see

http://en.wikipedia.org/wiki/Conditional_(programming)

about half way down the page.

Unfortunately you have "spaghetti" code which can be very confusing to unravel !

### RE: Fortran to ANSI C

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.

### RE: Fortran to ANSI C

(OP)
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

### RE: Fortran to ANSI C

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.

### RE: Fortran to ANSI C

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.

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!