Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Passing a namelist to a read

  1. May 27, 2012 #1
    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?
     
  2. jcsd
  3. May 28, 2012 #2

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook