MOM6
mom_get_input Module Reference

Data Types

type  directories
 

Functions/Subroutines

subroutine, public get_mom_input (param_file, dirs, check_params)
 

Function/Subroutine Documentation

◆ get_mom_input()

subroutine, public mom_get_input::get_mom_input ( type(param_file_type), intent(out), optional  param_file,
type(directories), intent(out), optional  dirs,
logical, intent(in), optional  check_params 
)
Parameters
[out]param_fileA structure to parse for run-time parameters

Definition at line 55 of file MOM_get_input.F90.

References mom_error_handler::mom_error(), and mom_file_parser::open_param_file().

Referenced by mom::initialize_mom(), and ocean_model_mod::ocean_model_flux_init().

55  type(param_file_type), optional, intent(out) :: param_file !< A structure to parse for run-time parameters
56  type(directories), optional, intent(out) :: dirs
57  logical, optional, intent(in) :: check_params
58 
59 ! See if the run is to be started from saved conditions, and get !
60 ! the names of the I/O directories and initialization file. This !
61 ! subroutine also calls the subroutine that allows run-time changes !
62 ! in parameters. !
63  integer, parameter :: npf = 5 ! Maximum number of parameter files
64  character(len=240) :: &
65  parameter_filename(npf) = ' ', & ! List of files containing parameters.
66  output_directory = ' ', & ! Directory to use to write the model output.
67  restart_input_dir = ' ', & ! Directory for reading restart and input files.
68  restart_output_dir = ' ', & ! Directory into which to write restart files.
69  input_filename = ' ' ! A string that indicates the input files or how
70  ! the run segment should be started.
71  character(len=240) :: output_dir
72  integer :: unit, io, ierr, valid_param_files
73 
74  namelist /mom_input_nml/ output_directory, input_filename, parameter_filename, &
75  restart_input_dir, restart_output_dir
76 
77  if (file_exists('input.nml')) then
78  unit = open_namelist_file(file='input.nml')
79  else
80  call mom_error(fatal,'Required namelist file input.nml does not exist.')
81  endif
82 
83  ierr=1 ; do while (ierr /= 0)
84  read(unit, nml=mom_input_nml, iostat=io, end=10)
85  ierr = check_nml_error(io, 'MOM_input_nml')
86  enddo
87 10 call close_file(unit)
88 
89  if (present(dirs)) then
90  dirs%output_directory = slasher(ensembler(output_directory))
91  dirs%restart_output_dir = slasher(ensembler(restart_output_dir))
92  dirs%restart_input_dir = slasher(ensembler(restart_input_dir))
93  dirs%input_filename = ensembler(input_filename)
94  endif
95 
96  if (present(param_file)) then
97  output_dir = slasher(ensembler(output_directory))
98  valid_param_files = 0
99  do io = 1, npf
100  if (len_trim(trim(parameter_filename(io))) > 0) then
101  call open_param_file(ensembler(parameter_filename(io)), param_file, &
102  check_params, doc_file_dir=output_dir)
103  valid_param_files = valid_param_files + 1
104  endif
105  enddo
106  if (valid_param_files == 0) call mom_error(fatal, "There must be at "//&
107  "least 1 valid entry in input_filename in MOM_input_nml in input.nml.")
108  endif
109 
Here is the call graph for this function:
Here is the caller graph for this function: