Can a Fortran read statement handle a namelist as input?

  • Context: Fortran 
  • Thread starter Thread starter solarblast
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
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?
 
Physics 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.