Can a Fortran read statement handle a namelist as input?

  • Thread starter Thread starter solarblast
  • Start date Start date
AI Thread Summary
The discussion centers on the use of the Fortran `read` statement with an integer unit number and a namelist. The original code snippet uses `read ( u_in, instrument, iostat=i )`, which raises questions about its correctness since the expected format is `read ( u_in, nml=instrument, iostat=i )`. The participants note that while the first two items in the I/O control list can be the unit number and format or namelist, subsequent items must follow the "name=value" format. The flexibility of the `read` statement allows for options to be specified in any order, such as `read(end=100, iostat=i, unit=u, err=200, nml=n)`, emphasizing the importance of understanding the structure of I/O control in Fortran.
solarblast
Messages
146
Reaction score
2
I'm looking at someone else''s f90 code, and see:

read ( u_in, instrument, iostat=i )

u_in is an integer, and instrument is a namelist.

Apparently, the read does handle the namelist OK, but I would have expected:
read ( u_in, nml=instrument, iostat=i)

The partial namelist is above as:
! Instrument data
namelist / Instrument / &
Bn, & ! Closures per revolution
Fl, & ! Focal length, mm
...

Comments?
 
Technology news on Phys.org
Both are standard fortran. If the first two items in the I/O control list are just "value" not "name=value", the first item is the unit number and the second is the format or namelist.

All the other items must use the "name=value" format. Unit = and fmt= or nml= are required if those items are not first and second in the list. You can put the options in "random order" like
read(end=100, iostat=i, unit=u, err=200, nml=n)
if you want.
 
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.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Replies
12
Views
3K
Replies
6
Views
2K
Replies
6
Views
2K
Replies
5
Views
4K
Replies
4
Views
9K
Replies
5
Views
5K
Replies
6
Views
3K
Replies
3
Views
3K
Replies
16
Views
2K
Back
Top