Skip to content

Commit

Permalink
Doxygenized MOM_get_input.F90
Browse files Browse the repository at this point in the history
- Completed doxygenization of MOM_get_input.F90
- No answer changes.
  • Loading branch information
adcroft committed Aug 24, 2017
1 parent 2c0667f commit a96c4dd
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions src/framework/MOM_get_input.F90
Original file line number Diff line number Diff line change
@@ -1,48 +1,41 @@
!> \brief Reads the only Fortran name list needed to boot-strap the model.
!!
!! The name list parameters indicate which directories to use for
!! certain types of input and output, and which files to look in for
!! the full parsable input parameter file(s).
module MOM_get_input

! This file is part of MOM6. See LICENSE.md for the license.

!********+*********+*********+*********+*********+*********+*********+**
!* *
!* By Robert Hallberg, April 2013 *
!* *
!* The subroutine in this file reads the MOM6 namelist input, which *
!* indicates which directories to use for certain types of input and *
!* output, and where to look for the full parsable input file(s). *
!* *
!********+*********+*********+*********+*********+*********+*********+**

use MOM_error_handler, only : MOM_mesg, MOM_error, FATAL, WARNING, is_root_pe
use MOM_file_parser, only : open_param_file, param_file_type
use MOM_io, only : file_exists, close_file, slasher, ensembler
use MOM_io, only : open_namelist_file, check_nml_error

implicit none ; private

public Get_MOM_Input

! This structure is to simplify communication with the calling code.
public get_MOM_input

!> Container for paths and parameter file names.
type, public :: directories
character(len=240) :: &
restart_input_dir = ' ',& ! The directory to read restart and input files.
restart_output_dir = ' ',&! The directory into which to write restart files.
output_directory = ' ', & ! The directory to use to write the model output.
input_filename = ' ' ! A string that indicates the input files or how
! the run segment should be started.
restart_input_dir = ' ',& !< The directory to read restart and input files.
restart_output_dir = ' ',&!< The directory into which to write restart files.
output_directory = ' ', & !< The directory to use to write the model output.
input_filename = ' ' !< A string that indicates the input files or how
!! the run segment should be started.
end type directories

contains

subroutine Get_MOM_Input(param_file, dirs, check_params)
type(param_file_type), optional, intent(out) :: param_file !< A structure to parse for run-time parameters
type(directories), optional, intent(out) :: dirs
logical, optional, intent(in) :: check_params

! See if the run is to be started from saved conditions, and get !
! the names of the I/O directories and initialization file. This !
! subroutine also calls the subroutine that allows run-time changes !
! in parameters. !
!> Get the names of the I/O directories and initialization file.
!! Also calls the subroutine that opens run-time parameter files.
subroutine get_MOM_input(param_file, dirs, check_params)
type(param_file_type), optional, intent(out) :: param_file !< A structure to parse for run-time parameters.
type(directories), optional, intent(out) :: dirs !< Container for paths and parameter file names.
logical, optional, intent(in) :: check_params !< If present and False will stop error checking for
!! run-time parameters.
! Local variables
integer, parameter :: npf = 5 ! Maximum number of parameter files
character(len=240) :: &
parameter_filename(npf) = ' ', & ! List of files containing parameters.
Expand All @@ -57,25 +50,29 @@ subroutine Get_MOM_Input(param_file, dirs, check_params)
namelist /MOM_input_nml/ output_directory, input_filename, parameter_filename, &
restart_input_dir, restart_output_dir

! Open namelist
if (file_exists('input.nml')) then
unit = open_namelist_file(file='input.nml')
else
call MOM_error(FATAL,'Required namelist file input.nml does not exist.')
endif

! Read namelist parameters
ierr=1 ; do while (ierr /= 0)
read(unit, nml=MOM_input_nml, iostat=io, end=10)
ierr = check_nml_error(io, 'MOM_input_nml')
enddo
10 call close_file(unit)

! Store parameters in container
if (present(dirs)) then
dirs%output_directory = slasher(ensembler(output_directory))
dirs%restart_output_dir = slasher(ensembler(restart_output_dir))
dirs%restart_input_dir = slasher(ensembler(restart_input_dir))
dirs%input_filename = ensembler(input_filename)
endif

! Open run-time parameter file(s)
if (present(param_file)) then
output_dir = slasher(ensembler(output_directory))
valid_param_files = 0
Expand All @@ -90,6 +87,6 @@ subroutine Get_MOM_Input(param_file, dirs, check_params)
"least 1 valid entry in input_filename in MOM_input_nml in input.nml.")
endif

end subroutine Get_MOM_Input
end subroutine get_MOM_input

end module MOM_get_input

0 comments on commit a96c4dd

Please sign in to comment.