13 use mom_io,
only : open_namelist_file, check_nml_error
15 implicit none ;
private
21 character(len=240) :: &
22 restart_input_dir =
' ',& !< The directory to read restart and input files.
23 restart_output_dir =
' ',&
24 output_directory =
' ', &
33 subroutine get_mom_input(param_file, dirs, check_params, default_input_filename, ensemble_num)
36 logical,
optional,
intent(in) :: check_params
38 character(len=*),
optional,
intent(in) :: default_input_filename
41 integer,
optional,
intent(in) :: ensemble_num
43 integer,
parameter :: npf = 5
45 character(len=240) :: &
46 parameter_filename(npf), &
52 character(len=240) :: output_dir
53 integer :: unit, io, ierr, valid_param_files
55 namelist /mom_input_nml/ output_directory, input_filename, parameter_filename, &
56 restart_input_dir, restart_output_dir
59 parameter_filename(:) =
' '
60 output_directory =
' '
61 restart_input_dir =
' '
62 restart_output_dir =
' '
64 if (
present(default_input_filename)) input_filename = trim(default_input_filename)
68 unit = open_namelist_file(file=
'input.nml')
70 call mom_error(fatal,
'Required namelist file input.nml does not exist.')
74 ierr=1 ;
do while (ierr /= 0)
75 read(unit, nml=mom_input_nml, iostat=io,
end=10)
76 ierr = check_nml_error(io,
'MOM_input_nml')
78 10
call close_file(unit)
81 if (
present(dirs))
then
82 if (
present(ensemble_num))
then
83 dirs%output_directory = slasher(ensembler(output_directory,ensemble_num))
84 dirs%restart_output_dir = slasher(ensembler(restart_output_dir,ensemble_num))
85 dirs%restart_input_dir = slasher(ensembler(restart_input_dir,ensemble_num))
86 dirs%input_filename = ensembler(input_filename,ensemble_num)
88 dirs%output_directory = slasher(ensembler(output_directory))
89 dirs%restart_output_dir = slasher(ensembler(restart_output_dir))
90 dirs%restart_input_dir = slasher(ensembler(restart_input_dir))
91 dirs%input_filename = ensembler(input_filename)
96 if (
present(param_file))
then
97 output_dir = slasher(ensembler(output_directory))
100 if (len_trim(trim(parameter_filename(io))) > 0)
then
101 if (
present(ensemble_num))
then
102 call open_param_file(ensembler(parameter_filename(io),ensemble_num), param_file, &
103 check_params, doc_file_dir=output_dir)
106 check_params, doc_file_dir=output_dir)
108 valid_param_files = valid_param_files + 1
111 if (valid_param_files == 0)
call mom_error(fatal,
"There must be at "//&
112 "least 1 valid entry in input_filename in MOM_input_nml in input.nml.")