Contact: | Jeff Anderson |
Reviewers: | |
Revision: | $Revision: 1.2 $ |
Release Name: | $Name: pre_hawaii $ |
Change Date: | $Date: 2004/12/22 20:48:13 $ |
Change history: | see CVS log |
Provides a number of tools used by most DART modules including tools for file IO, diagnostic tools for registering modules and recording namelist arguments, and and error handler.
types_mod
Optional namelist interface &utilities_nml may be read from file input.nml.
logical :: file_exist character(len=*), intent(in) :: file_name
Returns true if file_name exists in the working directory, else false.
file_exist | True if file_name exists in working directory. |
file_name | Name of file to look for. |
integer :: get_unit
Returns an unused unit number for IO.
get_unit | An unused unit number. |
integer :: check_nml_error integer, intent(in) :: iostat character(len=*), intent(in) :: nml_name
Given the iostat variable from a namelist read and the name of the namelist, makes sure that the iostat is an acceptable value. If not, generates a call to the error handler.
check_nml_error | Returned error code (same as iostat input). |
iostat | Input error code from a namelist read. |
nml_name | Name of the namelist that was read. |
integer :: open_file character(len=*), intent(in) :: fname character(len=*), optional, intent(in) :: form character(len=*), optional, intent(in) :: action
Returns a unit number that is opened to the file fname. If form is not present or if form is "formatted" or "FORMATTED", file is opened for formatted IO. Otherwise, it is unformatted. The action string is the standard action string for Fortran IO (see F90 language description).
open_file | Unit number opened to file fname. |
fname | Name of file to be opened. |
form | Format: 'formatted' or 'FORMATTED' give formatted, anything else is unformatted. Default is formatted. |
action | Standard fortran string description of requested file open action. |
character(len=*), optional, intent(in) :: string1 character(len=*), optional, intent(in) :: string2 character(len=*), optional, intent(in) :: string3 character(len=*), intent(in) :: pos
Prints the message 'Time is YYYY MM DD HH MM SS' to the logfile along with three optional message strings. If the pos argument is 'end', the message printed is 'Finished... at YYYY MM DD HH MM SS' and the logfile is closed.
string1 | An optional message to be printed. |
string2 | An optional message to be printed. |
string3 | An optional message to be printed. |
pos | If 'end' terminates log_file output. |
integer, intent(in) :: iunit
Closes the given unit number. If the unit is not open, nothing happens.
iunit | File unit to be closed. |
character(len=*), intent(in) :: src character(len=*), intent(in) :: rev character(len=*), intent(in) :: rdate
Writes the source name, revision number and revision date to both the logfileunit and to standard out. All dart modules are supposed to register when first called.
src | CVS source file name. |
rev | Revision number of source. |
rdate | Date of revision. |
integer, intent(in) :: level character(len=*), intent(in) :: routine character(len=*), intent(in) :: text character(len=*), intent(in) :: src character(len=*), intent(in) :: rev character(len=*), intent(in) :: rdate character(len=*), optional, intent(in) :: aut
Prints an error message to standard out and to the logfileunit. The message contains the routine name, an error message, the CVS source file, revision and revision date, and optionally the author. The level of severity is message, debug, warning, or error. If the level is greater than or equal to the TERMLEVEL (set in the namelist), execution is terminated. The default TERMLEVEL only stops for ERRORS.
level | Error severity (message, debug, warning, error). See below for specific ations. |
routine | Name of routine generating error. |
text | Error message. |
src | Source file containing routine generating message. |
rev | Revision number of source file. |
rdate | Revision date of source file. |
aut | Author of routine. |
Severity levels to be passed to error handler. Levels are debug, message, warning and fatal. The namelist parameter TERMLEVEL can be used to control at which level program termination should occur. |
logfileunit | Unit opened to file for diagnostic output. |
Reads the namelist and opens the logfile. Records the values of the namelist and registers this module.
Closes the logfile; using utilities after this call is a bad idea.
integer, intent(in) :: iunit
Writes all information about the status of the IO unit to the error handler with error level message.
iunit | Unit about which information is requested. |
Severity levels to be passed to error handler. Levels are debug, message, warning and fatal. The namelist parameter TERMLEVEL can be used to control at which level program termination should occur. |
We adhere to the F90 standard of starting a namelist with an ampersand '&' and terminating with a slash '/'.
namelist / utilities_nml / TERMLEVEL, logfilename
The namelist controls the way in which the error handler acts. In the default case, only calls with level E_ERR lead to program termination. If TERMLEVEL is set to E_WARN, then warnings or errors lead to termination. If TERMLEVEL is set to E_ERR + 1, then even errors don't lead to termination (be careful doing this).
This namelist is read in a file called input.nml
Contents | Type | Description |
---|---|---|
TERMLEVEL | integer | Level at which calls to error manager terminate program. Default: E_ERR |
logfilename | character(len=129) | File to which the logfile is written. Default: dart_log.out |
Routine | Message | Comment |
---|---|---|
get_unit | No available units | Unable to open enough IO channels |
check_nml_error | while reading namelist _____ | Fatal error reading namelist. This could be caused by having an entry in the namelist input file that is not in the namelist, by having illegal values for namelist variables, or by a variety of other compiler dependent problems. |