Simple Fortran Question (hopefully)?

Ynog

Golden Member
Oct 9, 2002
1,782
1
0
I am looking at Fortran code and while I can understand most of it.

I am dealing with a section of code.

Now there are some

OPEN(UNIT=60,FILE,STATUS)
OPEN(UNIT=61,FILE,STATUS)
OPEN(UNIT=62,FILE,STATUS)


But further down there is a

WRITE(6,110)
WRITE(6,120)
WRITE(6,130)

Now I want to know if I am getting this right.

Does this print out print statements made later in the file, to the screen.

Example:

110 FORMAT(' LINE 110 ')
120 FORMAT(' LINE 120 ')

I appreicate any help from anyone that knows fortran.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Originally posted by: Ynog
I am looking at Fortran code and while I can understand most of it.

I am dealing with a section of code.

Now there are some

OPEN(UNIT=60,FILE,STATUS)
OPEN(UNIT=61,FILE,STATUS)
OPEN(UNIT=62,FILE,STATUS)


But further down there is a

WRITE(6,110)
WRITE(6,120)
WRITE(6,130)

Now I want to know if I am getting this right.

Does this print out print statements made later in the file, to the screen.

Example:

110 FORMAT(' LINE 110 ')
120 FORMAT(' LINE 120 ')

I appreicate any help from anyone that knows fortran.

One, the write statments must refer to the proper device.

WRITE(device,format statement) parameters

The compiler will use the format statement just like a printf statement in C
The format statment contains formatting information which setups the output to the device for paremters being used by the write statement.



 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
File descriptor 0 is stdin, 1 is stdout, and 2 is stderr. Any fds past that are things you (or libraries, etc) have opened.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Originally posted by: Ynog
Ok so is 6, STDOUT

In the older Fortrans, 5 was by default the equivalent to STDIN and 6 was equivalent to STDOUT.

 

Ynog

Golden Member
Oct 9, 2002
1,782
1
0
Originally posted by: EagleKeeper
Originally posted by: Ynog
Ok so is 6, STDOUT

In the older Fortrans, 5 was by default the equivalent to STDIN and 6 was equivalent to STDOUT.

Thanks, that is what I figured, because I saw, some READs using 5 and WRITE using 6 but wanted to
double check.
 

bootoo

Senior member
Apr 13, 2002
671
0
0
LOL, no help from here but I'm very impressed; I took fortran back when you used punch cards and it was the only course I got a C in - endless endless problems. Good job guys; it made me so scared of computers I waited till the late '90's to buy a pc.

Guess it is a good program if it's still being used.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Originally posted by: bootoo
LOL, no help from here but I'm very impressed; I took fortran back when you used punch cards and it was the only course I got a C in - endless endless problems. Good job guys; it made me so scared of computers I waited till the late '90's to buy a pc.

Guess it is a good program if it's still being used.

still used quite abit within high speed number crunching applications.

Alot depends on the OS that it is running on.


Punch cards were a step up. Started learning using toggle switches. :eek:
 

Ynog

Golden Member
Oct 9, 2002
1,782
1
0
While I did get out of using punch cards, like Eagle Keeper said, Fortran still has a
following with mathmatical algorithms types who want to run programs with alot
of mathmatical computation.