What does the Fortran 77 command 'write' do and how is it used?

  • Context: Fortran 
  • Thread starter Thread starter Triscas
  • Start date Start date
  • Tags Tags
    Fortran
Click For Summary

Discussion Overview

The discussion revolves around the Fortran 77 command 'write', specifically its usage and the meaning of the unit number in the context of output formatting. Participants are exploring how the command operates in a program, particularly in relation to formatting statements and output devices.

Discussion Character

  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Some participants explain that the command 'write (4,*)' outputs a single space to unit 4 using a default format.
  • It is noted that 'write (4,310)' and 'write (4,311)' print formatted strings defined in format statements 310 and 311, which appear to serve as headers.
  • There is a question about the meaning of unit 4, with one participant suggesting it indicates the output device, likely a disk file associated with an OPEN statement.
  • Another participant queries whether the values will have a length of 4 characters, but this is not directly addressed.

Areas of Agreement / Disagreement

Participants generally agree on the function of the 'write' command and its formatting, but there is some uncertainty regarding the specifics of unit 4 and its implications.

Contextual Notes

There is a lack of clarity regarding the specific nature of unit 4 and whether it is strictly related to character length or output device assignment.

Triscas
Messages
9
Reaction score
0
Hello,

I'm new using fortran and I don't know what does it mean:

write (4,*) ' '
write (4,310)
write (4,311)

this lines go consecutive in the programm I have to understand.

- might say that 4 is not a reference to a line of the code.
- 310,311 are references about how the format should be

i.e:
310 format('Distance C Elec C Sol Surf Liq Pot Solid Pot ',
&'Liq Cur j main j side 1 j side 2 j side 3')
311 format('(microns) (mol/m3) x or y (V) (V) ',
1' (A/m2) (A/m2) (A/m2) (A/m2) (A/m2)')



I hope someone can help. Thanks
 
Technology news on Phys.org
Triscas said:
Hello,

I'm new using fortran and I don't know what does it mean:

write (4,*) ' '
write (4,310)
write (4,311)

this lines go consecutive in the programm I have to understand.

- might say that 4 is not a reference to a line of the code.
- 310,311 are references about how the format should be

i.e:
310 format('Distance C Elec C Sol Surf Liq Pot Solid Pot ',
&'Liq Cur j main j side 1 j side 2 j side 3')
311 format('(microns) (mol/m3) x or y (V) (V) ',
1' (A/m2) (A/m2) (A/m2) (A/m2) (A/m2)')
All of your write statements send output to unit 4, the first number in the parentheses.
write (4,*) ' ' -- prints a single space (' ') on unit 4, using a default format.
write (4,310) -- prints the string in the format statement in line 310, on unit 4. This string appears to be a header of some sort.
write (4,311) -- prints the string in the format statement in line 311, on unit 4. This string also appears to be some sort of header.
 
Mark44 said:
All of your write statements send output to unit 4, the first number in the parentheses.
write (4,*) ' ' -- prints a single space (' ') on unit 4, using a default format.
write (4,310) -- prints the string in the format statement in line 310, on unit 4. This string appears to be a header of some sort.
write (4,311) -- prints the string in the format statement in line 311, on unit 4. This string also appears to be some sort of header.
what does unit 4 mean? The values will have a length of 4 characters?

yes, i also understood they're a header the other outputs. The second might be the units of the first
 
Triscas said:
what does unit 4 mean?
The unit number indicates which device you want to write to. In this case it would probably be a disk file that was assigned a unit number with an OPEN statement.
Triscas said:
The values will have a length of 4 characters?

yes, i also understood they're a header the other outputs. The second might be the units of the first
 
Mark44 said:
The unit number indicates which device you want to write to. In this case it would probably be a disk file that was assigned a unit number with an OPEN statement.

Thanks for the answer, Mark.
 

Similar threads

Replies
6
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
19K