PDA

View Full Version : Please help !! FORTRAN ..


Arokiamary
Feb13-12, 12:55 AM
SUBROUTINE PRGTAC
COMMON IA(2),IB(2),J,JSUM,IFL
NR=4000-JSUM
IF(NR-51) 200,100,100
100 JSUM=0
RETURN
200 IF(NR.EQ.6 .OR. NR.EQ.7) PRINT 1
1 FORMAT(1H1)



In the above given lines from a program.. What does the 4th line intepret ? (200,100,100)
and what does 1H1 in the format mean ? .. Thank you :)

Well_InTheory
Feb13-12, 01:38 AM
http://en.wikipedia.org/wiki/Arithmetic_IF

IF (expression) negative,zero,positive

rcgldr
Feb13-12, 02:59 AM
In the above program.. what does (200,100,100) in the 4th line mean?It's an arithmetic if statement, which goes to the first statement number (in this case 200) if the result is negative, second statement number if the result is zero (in this case 100), and the third statement number if the result is positive (in this case also 100). The GOTO(...)IFL is a computed goto statement, where IFL indexes the list of statement numbers in (...).

Can someone help me with the format explanation too ?The 1H1 means one "Hollerith" character, in this case '1'. It's an old method for specifying characters, you could probably use '1' instead. My guess is that on the machine this code was written for, a '1' as the first character of output on a line cause a page eject. '+' would cause an overwrite. '0' would double space, and a space (' ') would produce a normal line. '/', is probably 'end of record' so '//' should should cause a double space.

This must be really old code.

NascentOxygen
Feb13-12, 04:05 AM
In the above program.. what does (200,100,100) in the 4th line mean ? Can someone help me with the format explanation too ?
Welcome to PF. You should post your question to only one thread, and wait for an answer there. It is better to start a new thread for your question, since it is not on the specific tpoic of the post where you have piggybacked it.

I see you already got your answer to the computed IF statement in another thread. For help with other FORTRAN statements I suggest you do a google search. As for the H in the FORMAT statement, I recall that H stands for Hollerith. Here is more detail: gcc.gnu.org/onlinedocs/.../gfortran/Hollerith-constants-support.html

Good luck. When experimenting, never hesitate to modify a line of code to investigate how your change causes it to run differently. You'll learn a lot through trial and error; and even better, you'll remember it! :smile:

jtbell
Feb13-12, 06:08 AM
I've merged multiple replies from different threads, into a single thread.

AlephZero
Feb14-12, 12:52 PM
The 1H1 means one "Hollerith" character, in this case '1'.
...
This must be really old code.

Maybe, but unix still understands this stuff - for example the -f option on the lpr command.