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, &
150 use platform_mod,
only: r4_kind, r8_kind
152 use,
intrinsic :: iso_c_binding
166 public :: lowercase, uppercase, &
170 public ::
mpp_error, note, warning, fatal, &
175 public :: input_nml_file
177 public :: mpp_clock_sync, mpp_clock_detailed
178 public :: clock_component, clock_subcomponent, &
179 clock_module_driver, clock_module, &
180 clock_routine, clock_loop, clock_infra
186 module procedure :: monotonic_array_r4, monotonic_array_r8
192 integer,
public :: clock_flag_default
197 INTEGER :: multipleNMLSinFile
200 INTEGER :: missingVar
203 TYPE(nml_errors_type),
SAVE :: nml_errors
250 integer,
private :: num_nml_error_codes, nml_error_codes(20)
251 logical,
private :: do_nml_error_init = .true.
258 #include<file_version.h>
260 logical :: module_is_initialized = .false.
286 subroutine fms_init (localcomm, alt_input_nml_path)
289 use constants_mod,
only: constants_version=>version
291 subroutine maximize_system_stacksize_limit()
bind(C)
295 integer,
intent(in),
optional :: localcomm
296 character(len=*),
intent(in),
optional :: alt_input_nml_path
298 integer :: logunitnum
299 integer :: stdout_unit
301 if (module_is_initialized)
return
302 module_is_initialized = .true.
305 call maximize_system_stacksize_limit
308 if(
present(localcomm))
then
309 if(
present(alt_input_nml_path))
then
310 call mpp_init(localcomm=localcomm, alt_input_nml_path=alt_input_nml_path)
315 if(
present(alt_input_nml_path))
then
316 call mpp_init(alt_input_nml_path=alt_input_nml_path)
323 #ifdef use_deprecated_io
324 call mpp_error(note,
"fms_io_init: fms_io HAS BEEN DEPRECATED! "//&
325 "PLEASE REMOVE -Duse_deprecated_io FROM YOUR COMPILE FLAGS "// &
326 "AND MOVE TO FMS2_IO. CONTACT YOUR MODEL LIASISON IF YOU NEED "// &
334 read (input_nml_file, fms_nml, iostat=io)
346 call mpp_set_warn_level ( fatal )
348 call mpp_set_warn_level ( warning )
351 'invalid entry for namelist variable warning_level', fatal )
361 case(
'SUBCOMPONENT' )
363 case(
'MODULE_DRIVER' )
375 'invalid entry for namelist variable clock_grain', fatal )
380 clock_flag_default = 0
382 clock_flag_default = mpp_clock_sync
384 clock_flag_default = mpp_clock_detailed
387 'invalid entry for namelist variable clock_flags', fatal )
393 if (
mpp_pe() == mpp_root_pe())
then
395 write (stdout_unit, nml=fms_nml)
396 write (stdout_unit,*)
'nml_error_codes=', nml_error_codes(1:num_nml_error_codes)
417 if (.not.module_is_initialized)
return
422 module_is_initialized =.false.
442 character(len=*),
intent(in) :: routine
443 character(len=*),
intent(in) :: message
444 integer,
intent(in) :: level
452 if (.not.module_is_initialized)
call fms_init ( )
453 call mpp_error ( routine, message, level )
471 character(len=*),
intent(in) :: routine
472 character(len=*),
intent(in) :: message
473 character(len=*),
intent(out),
optional :: err_msg
476 if(
present(err_msg))
then
480 call mpp_error(trim(routine),trim(message),fatal)
524 INTEGER,
INTENT(in) :: iostat
525 CHARACTER(len=*),
INTENT(in) :: nml_name
528 CHARACTER(len=256) :: err_str
530 IF ( .NOT.module_is_initialized)
CALL fms_init()
535 IF ( iostat <= 0 .OR.&
536 & iostat == nml_errors%multipleNMLSinFile .OR.&
537 & iostat == nml_errors%NotInFile)
RETURN
540 IF ( (iostat == nml_errors%badType1 .OR. iostat == nml_errors%badType2) .OR. iostat == nml_errors%missingVar )
THEN
541 WRITE (err_str,*)
'Unknown namelist, or mistyped namelist variable in namelist ',trim(nml_name),
', &
542 & (IOSTAT = ',iostat,
')'
543 CALL error_mesg (
'check_nml_error in fms_mod', err_str, fatal)
546 WRITE (err_str,*)
'Unknown error while reading namelist ',trim(nml_name),
', (IOSTAT = ',iostat,
')'
547 CALL error_mesg (
'check_nml_error in fms_mod', err_str, fatal)
562 INTEGER,
PARAMETER :: unit_begin = 20, unit_end = 1024
563 INTEGER :: fileunit, io_stat
564 INTEGER,
DIMENSION(5) :: nml_iostats
572 namelist /a_nml/ i1, r1
573 namelist /b_nml/ i2, r2, l1
574 namelist /badtype1_nml/ i1, r1
575 namelist /badtype2_nml/ i1, r1
576 namelist /missingvar_nml/ i2, r2
577 namelist /not_in_file_nml/ i2, r2
587 IF (
mpp_pe() == mpp_root_pe() )
THEN
589 file_opened:
DO fileunit = unit_begin, unit_end
590 INQUIRE(unit=fileunit, opened=opened)
591 IF ( .NOT.opened )
EXIT file_opened
594 #if defined(__PGI) || defined(_CRAYFTN)
595 OPEN (unit=fileunit, file=
'_read_error.nml', iostat=io_stat)
597 OPEN (unit=fileunit, status=
'SCRATCH', iostat=io_stat)
601 WRITE (unit=fileunit, nml=a_nml, iostat=io_stat)
602 WRITE (unit=fileunit, nml=b_nml, iostat=io_stat)
603 WRITE (unit=fileunit, iostat=io_stat, fmt=
'(/,"&badType1_nml i1=1, r1=''bad'' /",/)')
604 WRITE (unit=fileunit, iostat=io_stat, fmt=
'(/,"&badType2_nml i1=1, r1=.true. /",/)')
605 WRITE (unit=fileunit, iostat=io_stat, fmt=
'(/,"&missingVar_nml i2=1, r2=1.0e0, l1=.true. /",/)')
608 rewind(unit=fileunit)
611 READ (unit=fileunit, nml=b_nml, iostat=nml_iostats(1))
612 rewind(unit=fileunit)
615 READ (unit=fileunit, nml=badtype1_nml, iostat=nml_iostats(2))
616 rewind(unit=fileunit)
619 READ (unit=fileunit, nml=badtype2_nml, iostat=nml_iostats(3))
620 rewind(unit=fileunit)
623 READ (unit=fileunit, nml=missingvar_nml, iostat=nml_iostats(4))
624 rewind(unit=fileunit)
627 READ (unit=fileunit, nml=not_in_file_nml, iostat=nml_iostats(5))
630 CLOSE (unit=fileunit)
633 IF ( nml_iostats(2) * nml_iostats(3) .EQ. 0 )
THEN
634 IF ( nml_iostats(2) .NE. 0 .AND. nml_iostats(3) .EQ. 0 )
THEN
635 nml_iostats(3) = nml_iostats(2)
636 ELSE IF ( nml_iostats(2) .EQ. 0 .AND. nml_iostats(3) .NE.0 )
THEN
637 nml_iostats(2) = nml_iostats(3)
639 nml_iostats(2) = nml_iostats(4)
640 nml_iostats(2) = nml_iostats(4)
647 nml_errors%multipleNMLSinFile = nml_iostats(1)
648 nml_errors%badType1 = nml_iostats(2)
649 nml_errors%badType2 = nml_iostats(3)
650 nml_errors%missingVar = nml_iostats(4)
651 nml_errors%NotInFile = nml_iostats(5)
653 do_nml_error_init = .false.
674 character(len=*),
intent(in) ::
string
675 character(len=*),
intent(in) :: string_array(:)
676 integer,
optional,
intent(out) :: index
685 if (
present(index)) index = 0
687 do i = 1,
size(string_array(:))
689 if ( trim(
string) == trim(string_array(i)) )
then
691 if (
present(index)) index = i
702 character(len=*),
intent(in) :: version
703 character(len=*),
intent(in),
optional :: tag
704 integer,
intent(in),
optional :: unit
708 if (.not.module_is_initialized)
call fms_init ( )
712 if (
present(unit))
then
716 if (
mpp_pe() /= mpp_root_pe() )
return
719 if (
present(tag))
then
720 write (logunit,
'(/,80("="),/(a))') trim(version), trim(tag)
722 write (logunit,
'(/,80("="),/(a))') trim(version)
subroutine, public fms2_io_init()
Reads the fms2_io_nml.
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...
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