0.6.2-dev0
FORCES
FORtran lib for Comp. Env. Sys.
Loading...
Searching...
No Matches
mo_nml Module Reference

Deal with namelist files. More...

Functions/Subroutines

subroutine, public open_nml (file, unit, quiet)
 Open a namelist file.
 
subroutine, public close_nml (unit)
 Close a namelist file.
 
subroutine, public position_nml (name, unit, status, first)
 Position a namlist file.
 

Variables

integer(i4), parameter, public positioned = 0
 Information: file pointer set to namelist group.
 
integer(i4), parameter, public missing = 1
 Error: namelist group is missing.
 
integer(i4), parameter, public length_error = 2
 Error: namelist group name too long.
 
integer(i4), parameter, public read_error = 3
 Error occured during read of namelist file.
 
integer, save, public nunitnml = -1
 default namelist unit
 

Detailed Description

Deal with namelist files.

This module provides routines to open, close and position namelist files.

  • Adapted from Echam5, (C) MPI-MET, Hamburg, Germany
    Author
    L. Kornblueh, MPI, March 2001, original source
    Changelog
  • Jan 2011, Matthias Cuntz
    • compatible with gfortran <= version 4.3
    • all integer(i4)
    • quiet
  • Jan 2013, Matthias Cuntz
    • close_nml with unit, open_nml quiet=.true. default position_nml swap first and status
      Authors
      Matthias Cuntz
      Date
      Jan 2011

Function/Subroutine Documentation

◆ close_nml()

subroutine, public mo_nml::close_nml ( integer, intent(in), optional  unit)

Close a namelist file.

Close a namelist file.

Example

call close_nml()
! or
call close_nml(unml)

See also example in test directory

Parameters
[in]integer, optional :: unitnamelist unit
Note
open_nml remembers the namelist unit in the public, save variable nunitnml.
close_nml uses nunitnml if unit is not given.
Author
Matthias Cuntz
Date
Dec 2011
  • modified from Echam5, (C) MPI-MET, Hamburg, Germany
Jan 2013
  • unit

Definition at line 130 of file mo_nml.f90.

References mo_message::error_message(), and nunitnml.

Here is the call graph for this function:

◆ open_nml()

subroutine, public mo_nml::open_nml ( character(len = *), intent(in)  file,
integer, intent(in)  unit,
logical, intent(in), optional  quiet 
)

Open a namelist file.

Open a namelist file.

Example

call open_nml('namelist.txt',nnml)

See also example in test directory

Parameters
[in]character(len=*) :: filenamelist filename
[in]integer :: unitnamelist unit
[in]logical, optional :: quietBe verbose or not (default: .true.)
.true.: no messages
.false.: write out messages
Author
Matthias Cuntz
Date
Dec 2011
  • modified from Echam5, (C) MPI-MET, Hamburg, Germany
Jan 2013
  • quiet=.true. default
Author
Luis Samaniego
Date
Nov 2013
  • comparison statements == -> .eq., etc

Definition at line 81 of file mo_nml.f90.

References mo_message::error_message(), mo_message::message(), and nunitnml.

Here is the call graph for this function:

◆ position_nml()

subroutine, public mo_nml::position_nml ( character(len = *), intent(in)  name,
integer, intent(in), optional  unit,
integer(i4), intent(out), optional  status,
logical, intent(in), optional  first 
)

Position a namlist file.

Position namelist file pointer for reading a new namelist next.
It positions the namelist file at the correct place for reading
namelist /name/ (case independent).

Example

call position_nml('myname',nnml)
Parameters
[in]character(len=*) :: namenamelist name (case independent)
[in]integer, optional :: unitnamelist unit (default: nunitnml)
[in]logical, optional :: firststart search at beginning, i.e. rewind the namelist first (default: .true.)
.true.: rewind
.false.: continue search from current file pointer
[out]integer(i4), optional :: statusSet on output to either of
POSITIONED (0) - correct
MISSING (1) - name not found
LENGTH_ERROR (2) - namelist length longer then 256 characters
READ_ERROR (3) - error while reading namelist file
Author
Matthias Cuntz
Date
Dec 2011
  • modified from Echam5, (C) MPI-MET, Hamburg, Germany
Jan 2013
  • swap first and status in call list

Definition at line 182 of file mo_nml.f90.

References mo_message::error_message(), length_error, missing, nunitnml, positioned, read_error, and mo_string_utils::tolower().

Here is the call graph for this function:

Variable Documentation

◆ length_error

integer(i4), parameter, public mo_nml::length_error = 2

Error: namelist group name too long.

Definition at line 42 of file mo_nml.f90.

Referenced by position_nml().

◆ missing

integer(i4), parameter, public mo_nml::missing = 1

Error: namelist group is missing.

Definition at line 40 of file mo_nml.f90.

Referenced by position_nml().

◆ nunitnml

integer, save, public mo_nml::nunitnml = -1

default namelist unit

Definition at line 47 of file mo_nml.f90.

Referenced by close_nml(), open_nml(), and position_nml().

◆ positioned

integer(i4), parameter, public mo_nml::positioned = 0

Information: file pointer set to namelist group.

Definition at line 38 of file mo_nml.f90.

Referenced by position_nml().

◆ read_error

integer(i4), parameter, public mo_nml::read_error = 3

Error occured during read of namelist file.

Definition at line 44 of file mo_nml.f90.

Referenced by position_nml().