121 use mpp_mod,
only:
mpp_error, note, warning, fatal, &
122 mpp_set_warn_level, &
126 mpp_clock_begin, mpp_clock_end, &
128 mpp_clock_sync, mpp_clock_detailed, &
129 clock_component, clock_subcomponent,&
130 clock_module_driver, clock_module, &
131 clock_routine, clock_loop, &
135 mpp_error_state, lowercase, &
146 #ifdef use_deprecated_io
147 use mpp_io_mod,
only: mpp_io_init, mpp_open, mpp_close, &
148 mpp_ascii, mpp_native, mpp_ieee32, mpp_netcdf, &
149 mpp_rdonly, mpp_wronly, mpp_append, mpp_overwr, &
150 mpp_sequential, mpp_direct, &
151 mpp_single, mpp_multi, mpp_delete, mpp_io_exit, &
155 use fms_io_mod,
only : fms_io_init, fms_io_exit, field_size, &
156 read_data, write_data, read_compressed, read_distributed, &
157 open_namelist_file, open_restart_file, open_ieee32_file, close_file, &
159 open_file, open_direct_file, get_mosaic_tile_grid, &
160 get_mosaic_tile_file, get_global_att_value, file_exist, field_exist, &
161 set_domain, nullify_domain
167 use platform_mod,
only: r4_kind, r8_kind
169 use,
intrinsic :: iso_c_binding
178 #ifdef use_deprecated_io
179 public :: open_namelist_file, open_restart_file, &
185 public :: get_domain_decomp, field_size
186 public :: get_global_att_value
189 public :: get_mosaic_tile_grid, get_mosaic_tile_file
192 public :: file_exist, field_exist
200 public :: lowercase, uppercase, &
202 #ifdef use_deprecated_io
203 public :: set_domain, nullify_domain
207 public ::
mpp_error, note, warning, fatal, &
212 public :: input_nml_file
214 public :: mpp_clock_sync, mpp_clock_detailed
215 public :: clock_component, clock_subcomponent, &
216 clock_module_driver, clock_module, &
217 clock_routine, clock_loop, clock_infra
223 #ifdef use_deprecated_io
224 public :: do_cf_compliance
228 module procedure :: monotonic_array_r4, monotonic_array_r8
234 integer,
public :: clock_flag_default
239 INTEGER :: multipleNMLSinFile
242 INTEGER :: missingVar
245 TYPE(nml_errors_type),
SAVE :: nml_errors
292 integer,
private :: num_nml_error_codes, nml_error_codes(20)
293 logical,
private :: do_nml_error_init = .true.
300 #include<file_version.h>
302 logical :: module_is_initialized = .false.
304 logical,
private :: fms_io_initialized = .false.
331 subroutine fms_init (localcomm, alt_input_nml_path)
334 use constants_mod,
only: constants_version=>version
335 #ifdef use_deprecated_io
336 use fms_io_mod,
only: fms_io_version
340 subroutine maximize_system_stacksize_limit()
bind(C)
344 integer,
intent(in),
optional :: localcomm
345 character(len=*),
intent(in),
optional :: alt_input_nml_path
347 integer :: logunitnum
348 integer :: stdout_unit
350 if (module_is_initialized)
return
351 module_is_initialized = .true.
354 call maximize_system_stacksize_limit
357 if(
present(localcomm))
then
358 if(
present(alt_input_nml_path))
then
359 call mpp_init(localcomm=localcomm, alt_input_nml_path=alt_input_nml_path)
364 if(
present(alt_input_nml_path))
then
365 call mpp_init(alt_input_nml_path=alt_input_nml_path)
371 #ifdef use_deprecated_io
375 if(.not.fms_io_initialized)
then
376 #ifdef use_deprecated_io
379 fms_io_initialized = .true.
387 read (input_nml_file, fms_nml, iostat=io)
399 call mpp_set_warn_level ( fatal )
401 call mpp_set_warn_level ( warning )
404 'invalid entry for namelist variable warning_level', fatal )
414 case(
'SUBCOMPONENT' )
416 case(
'MODULE_DRIVER' )
428 'invalid entry for namelist variable clock_grain', fatal )
433 clock_flag_default = 0
435 clock_flag_default = mpp_clock_sync
437 clock_flag_default = mpp_clock_detailed
440 'invalid entry for namelist variable clock_flags', fatal )
446 if (
mpp_pe() == mpp_root_pe())
then
448 write (stdout_unit, nml=fms_nml)
449 write (stdout_unit,*)
'nml_error_codes=', nml_error_codes(1:num_nml_error_codes)
470 if (.not.module_is_initialized)
return
473 #ifdef use_deprecated_io
478 module_is_initialized =.false.
498 character(len=*),
intent(in) :: routine
499 character(len=*),
intent(in) :: message
500 integer,
intent(in) :: level
508 if (.not.module_is_initialized)
call fms_init ( )
509 call mpp_error ( routine, message, level )
527 character(len=*),
intent(in) :: routine
528 character(len=*),
intent(in) :: message
529 character(len=*),
intent(out),
optional :: err_msg
532 if(
present(err_msg))
then
536 call mpp_error(trim(routine),trim(message),fatal)
580 INTEGER,
INTENT(in) :: iostat
581 CHARACTER(len=*),
INTENT(in) :: nml_name
584 CHARACTER(len=256) :: err_str
586 IF ( .NOT.module_is_initialized)
CALL fms_init()
591 IF ( iostat <= 0 .OR.&
592 & iostat == nml_errors%multipleNMLSinFile .OR.&
593 & iostat == nml_errors%NotInFile)
RETURN
596 IF ( (iostat == nml_errors%badType1 .OR. iostat == nml_errors%badType2) .OR. iostat == nml_errors%missingVar )
THEN
597 WRITE (err_str,*)
'Unknown namelist, or mistyped namelist variable in namelist ',trim(nml_name),
', &
598 & (IOSTAT = ',iostat,
')'
599 CALL error_mesg (
'check_nml_error in fms_mod', err_str, fatal)
602 WRITE (err_str,*)
'Unknown error while reading namelist ',trim(nml_name),
', (IOSTAT = ',iostat,
')'
603 CALL error_mesg (
'check_nml_error in fms_mod', err_str, fatal)
618 INTEGER,
PARAMETER :: unit_begin = 20, unit_end = 1024
619 INTEGER :: fileunit, io_stat
620 INTEGER,
DIMENSION(5) :: nml_iostats
628 namelist /a_nml/ i1, r1
629 namelist /b_nml/ i2, r2, l1
630 namelist /badtype1_nml/ i1, r1
631 namelist /badtype2_nml/ i1, r1
632 namelist /missingvar_nml/ i2, r2
633 namelist /not_in_file_nml/ i2, r2
643 IF (
mpp_pe() == mpp_root_pe() )
THEN
645 file_opened:
DO fileunit = unit_begin, unit_end
646 INQUIRE(unit=fileunit, opened=opened)
647 IF ( .NOT.opened )
EXIT file_opened
650 #if defined(__PGI) || defined(_CRAYFTN)
651 OPEN (unit=fileunit, file=
'_read_error.nml', iostat=io_stat)
653 OPEN (unit=fileunit, status=
'SCRATCH', iostat=io_stat)
657 WRITE (unit=fileunit, nml=a_nml, iostat=io_stat)
658 WRITE (unit=fileunit, nml=b_nml, iostat=io_stat)
659 WRITE (unit=fileunit, iostat=io_stat, fmt=
'(/,"&badType1_nml i1=1, r1=''bad'' /",/)')
660 WRITE (unit=fileunit, iostat=io_stat, fmt=
'(/,"&badType2_nml i1=1, r1=.true. /",/)')
661 WRITE (unit=fileunit, iostat=io_stat, fmt=
'(/,"&missingVar_nml i2=1, r2=1.0e0, l1=.true. /",/)')
664 rewind(unit=fileunit)
667 READ (unit=fileunit, nml=b_nml, iostat=nml_iostats(1))
668 rewind(unit=fileunit)
671 READ (unit=fileunit, nml=badtype1_nml, iostat=nml_iostats(2))
672 rewind(unit=fileunit)
675 READ (unit=fileunit, nml=badtype2_nml, iostat=nml_iostats(3))
676 rewind(unit=fileunit)
679 READ (unit=fileunit, nml=missingvar_nml, iostat=nml_iostats(4))
680 rewind(unit=fileunit)
683 READ (unit=fileunit, nml=not_in_file_nml, iostat=nml_iostats(5))
686 CLOSE (unit=fileunit)
689 IF ( nml_iostats(2) * nml_iostats(3) .EQ. 0 )
THEN
690 IF ( nml_iostats(2) .NE. 0 .AND. nml_iostats(3) .EQ. 0 )
THEN
691 nml_iostats(3) = nml_iostats(2)
692 ELSE IF ( nml_iostats(2) .EQ. 0 .AND. nml_iostats(3) .NE.0 )
THEN
693 nml_iostats(2) = nml_iostats(3)
695 nml_iostats(2) = nml_iostats(4)
696 nml_iostats(2) = nml_iostats(4)
703 nml_errors%multipleNMLSinFile = nml_iostats(1)
704 nml_errors%badType1 = nml_iostats(2)
705 nml_errors%badType2 = nml_iostats(3)
706 nml_errors%missingVar = nml_iostats(4)
707 nml_errors%NotInFile = nml_iostats(5)
709 do_nml_error_init = .false.
730 character(len=*),
intent(in) ::
string
731 character(len=*),
intent(in) :: string_array(:)
732 integer,
optional,
intent(out) :: index
741 if (
present(index)) index = 0
743 do i = 1,
size(string_array(:))
745 if ( trim(
string) == trim(string_array(i)) )
then
747 if (
present(index)) index = i
758 character(len=*),
intent(in) :: version
759 character(len=*),
intent(in),
optional :: tag
760 integer,
intent(in),
optional :: unit
764 if (.not.module_is_initialized)
call fms_init ( )
768 if (
present(unit))
then
772 if (
mpp_pe() /= mpp_root_pe() )
return
775 if (
present(tag))
then
776 write (logunit,
'(/,80("="),/(a))') trim(version), trim(tag)
778 write (logunit,
'(/,80("="),/(a))') trim(version)
subroutine, public fms2_io_init()
Reads the fms2_io_nml.
Close a netcdf or domain file opened with open_file or open_virtual_file.
Opens a given netcdf or domain file.
Read data from a defined field in a file.
Write data to a defined field within a file Example usage:
integer function, public check_nml_error(IOSTAT, NML_NAME)
Checks the iostat argument that is returned after reading a namelist and determines if the error code...
subroutine, public write_version_number(version, tag, unit)
Prints to the log file (or a specified unit) the version id string and tag name.
subroutine, private nml_error_init
Determines the IOSTAT error value for some common Namelist errors. Also checks if the compiler return...
character(len=8) warning_level
Sets the termination condition for the WARNING flag to interfaces error_mesg/mpp_error....
logical function, public string_array_index(string, string_array, index)
match the input character string to a string in an array/list of character strings
logical read_all_pe
Read global data on all processors extracting local part needed (TRUE) or read global data on PE0 and...
subroutine, public fms_end()
Calls the termination routines for all modules in the MPP package.
character(len=16) clock_grain
The level of clock granularity used for performance timing sections of code. Possible values in order...
logical function, public fms_error_handler(routine, message, err_msg)
Facilitates the control of fatal error conditions.
integer domains_stack_size
The size in words of the MPP_DOMAINS user stack. If domains_stack_size > 0, the following MPP_DOMAINS...
subroutine, public fms_init(localcomm, alt_input_nml_path)
Initializes the FMS module and also calls the initialization routines for all modules in the MPP pack...
logical, public print_memory_usage
If set to .TRUE., memory usage statistics will be printed at various points in the code....
character(len=16) clock_flags
Possible values are 'NONE', 'SYNC', or 'DETAILED'. SYNC will give accurate information on load balanc...
subroutine, public error_mesg(routine, message, level)
Print notes, warnings and error messages; terminates program for warning and error messages....
integer stack_size
The size in words of the MPP user stack. If stack_size > 0, the following MPP routine is called: call...
Converts a C string to a Fortran string.
Namelist read error values.
character(:) function, allocatable, public string(v, fmt)
Converts a number or a Boolean value to a string.
subroutine, public grid_end
Shutdown the grid2 module.
subroutine, public grid_init
Initialize the grid2 module.
subroutine, public memutils_init(print_flag)
Initialize the memutils module.
subroutine, public print_memuse_stats(text, unit, always)
Print memory usage stats to stdout, or a particular file.
subroutine mpp_domains_init(flags)
Initialize domain decomp package.
subroutine mpp_domains_exit()
Exit mpp_domains_mod. Serves no particular purpose, but is provided should you require to re-initiali...
subroutine mpp_domains_set_stack_size(n)
Set user stack size.
Set up a domain decomposition.
These routines retrieve the axis specifications associated with the compute domains....
These routines retrieve the axis specifications associated with the data domains. The domain is a der...
These routines retrieve the axis specifications associated with the global domains....
Fill in a global array from domain-decomposed arrays.
Performs halo updates for a given domain.
The domain2D type contains all the necessary information to define the global, compute and data domai...
subroutine mpp_get_info(unit, ndim, nvar, natt, ntime)
Get some general information about a file.
subroutine mpp_get_fields(unit, variables)
Copy variable information from file (excluding data)
Get file global metadata.
integer function stdout()
This function returns the current standard fortran unit numbers for output.
subroutine mpp_init(flags, localcomm, test_level, alt_input_nml_path)
Initialize the mpp_mod module. Must be called before any usage.
integer function stderr()
This function returns the current standard fortran unit numbers for error messages.
subroutine read_input_nml(pelist_name_in, alt_input_nml_path)
Reads an existing input nml file into a character array and broadcasts it to the non-root mpi-tasks....
subroutine mpp_clock_set_grain(grain)
Set the level of granularity of timing measurements.
subroutine mpp_exit()
Finalizes process termination. To be called at the end of a run. Certain mpi implementations(openmpi)...
integer function stdlog()
This function returns the current standard fortran unit numbers for log messages. Log messages,...
integer function mpp_npes()
Returns processor count for current pelist.
subroutine mpp_set_stack_size(n)
Set the mpp_stack variable to be at least n LONG words long.
integer function mpp_pe()
Returns processor ID.
subroutine mpp_sync(pelist, do_self)
Synchronize PEs in list.
integer function mpp_clock_id(name, flags, grain)
Return an ID for a new or existing clock.
integer function stdin()
This function returns the current standard fortran unit numbers for input.
Perform parallel broadcasts.
Calculate parallel checksums.
Basic message-passing call.
converts a kind=c_char to type c_ptr