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

  • Thread starter Thread starter Triscas
  • Start date Start date
  • Tags Tags
    Fortran
AI Thread Summary
In Fortran, the statements `write (4,*) ' '`, `write (4,310)`, and `write (4,311)` are used for outputting data to a specified unit, which is indicated by the number 4. This unit typically refers to a file or output device that has been assigned with an OPEN statement. The first statement outputs a single space using default formatting, while the subsequent statements utilize format specifications defined in lines 310 and 311. These format lines define headers for the output, with line 310 containing descriptive labels and line 311 specifying units for the data. The discussion clarifies that the unit number does not relate to character length but rather to the output destination.
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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Back
Top