Skip to content

Commit

Permalink
Merge branch 'NCAR-dev/ncar' into dev/master
Browse files Browse the repository at this point in the history
  • Loading branch information
adcroft committed Oct 23, 2017
2 parents 2c0667f + 398bf5c commit b85463d
Show file tree
Hide file tree
Showing 7 changed files with 2,057 additions and 347 deletions.
14 changes: 1 addition & 13 deletions config_src/coupled_driver/ocean_model_MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module ocean_model_mod
use MOM_error_handler, only : callTree_enter, callTree_leave
use MOM_file_parser, only : get_param, log_version, close_param_file, param_file_type
use MOM_forcing_type, only : forcing, forcing_diagnostics, mech_forcing_diags, forcing_accumulate
use MOM_get_input, only : Get_MOM_Input, directories
use MOM_get_input, only : directories
use MOM_grid, only : ocean_grid_type
use MOM_io, only : close_file, file_exists, read_data, write_version_number
use MOM_restart, only : save_restart
Expand Down Expand Up @@ -76,7 +76,6 @@ module ocean_model_mod
public ice_ocn_bnd_type_chksum
public ocean_public_type_chksum
public ocean_model_data_get
public get_state_pointers

interface ocean_model_data_get
module procedure ocean_model_data1D_get
Expand Down Expand Up @@ -1079,15 +1078,4 @@ subroutine ocean_public_type_chksum(id, timestep, ocn)

end subroutine ocean_public_type_chksum

!> Returns pointers to objects within ocean_state_type
subroutine get_state_pointers(OS, grid, surf)
type(ocean_state_type), pointer :: OS !< Ocean state type
type(ocean_grid_type), optional, pointer :: grid !< Ocean grid
type(surface), optional, pointer :: surf !< Ocean surface state

if (present(grid)) grid => OS%grid
if (present(surf)) surf=> OS%state

end subroutine get_state_pointers

end module ocean_model_mod
2,289 changes: 2,000 additions & 289 deletions config_src/mct_driver/ocn_comp_mct.F90

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1475,14 +1475,15 @@ subroutine step_offline(fluxes, state, Time_start, time_interval, CS)
end subroutine step_offline

!> This subroutine initializes MOM.
subroutine initialize_MOM(Time, param_file, dirs, CS, Time_in, offline_tracer_mode)
subroutine initialize_MOM(Time, param_file, dirs, CS, Time_in, offline_tracer_mode, input_restart_file)
type(time_type), target, intent(inout) :: Time !< model time, set in this routine
type(param_file_type), intent(out) :: param_file !< structure indicating paramater file to parse
type(directories), intent(out) :: dirs !< structure with directory paths
type(MOM_control_struct), pointer :: CS !< pointer set in this routine to MOM control structure
type(time_type), optional, intent(in) :: Time_in !< time passed to MOM_initialize_state when
!! model is not being started from a restart file
logical, optional, intent(out) :: offline_tracer_mode !< True if tracers are being run offline
character(len=*),optional, intent(in) :: input_restart_file !< If present, name of restart file to read

! local
type(ocean_grid_type), pointer :: G => NULL() ! A pointer to a structure with metrics and related
Expand Down Expand Up @@ -1552,7 +1553,9 @@ subroutine initialize_MOM(Time, param_file, dirs, CS, Time_in, offline_tracer_mo

Start_time = Time ; if (present(Time_in)) Start_time = Time_in

call Get_MOM_Input(param_file, dirs)
! Read paths and filenames from namelist and store in "dirs".
! Also open the parsed input parameter file(s) and setup param_file.
call get_MOM_input(param_file, dirs, default_input_filename=input_restart_file)

verbosity = 2 ; call read_param(param_file, "VERBOSITY", verbosity)
call MOM_set_verbosity(verbosity)
Expand Down
4 changes: 2 additions & 2 deletions src/equation_of_state/MOM_EOS.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1393,12 +1393,12 @@ subroutine find_depth_of_pressure_in_cell(T_t, T_b, S_t, S_b, z_t, z_b, P_t, P_t

P_b = P_t + dp ! Anomalous pressure at bottom of cell

if (P_tgt < P_t ) then
if (P_tgt <= P_t ) then
z_out = z_t
return
endif

if (P_tgt > P_b) then
if (P_tgt >= P_b) then
z_out = z_b
return
endif
Expand Down
76 changes: 42 additions & 34 deletions src/framework/MOM_get_input.F90
Original file line number Diff line number Diff line change
@@ -1,81 +1,89 @@
!> \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, default_input_filename)
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.
character(len=*), optional, intent(in) :: default_input_filename !< If present, is the value assumed for
!! input_filename if input_filename is not listed
!! in the namelist MOM_input_nml.
! Local variables
integer, parameter :: npf = 5 ! Maximum number of parameter files
character(len=240) :: &
parameter_filename(npf) = ' ', & ! List of files containing parameters.
output_directory = ' ', & ! Directory to use to write the model output.
restart_input_dir = ' ', & ! Directory for reading restart and input files.
restart_output_dir = ' ', & ! Directory into which to write restart files.
input_filename = ' ' ! A string that indicates the input files or how
! the run segment should be started.
parameter_filename(npf), & ! List of files containing parameters.
output_directory, & ! Directory to use to write the model output.
restart_input_dir, & ! Directory for reading restart and input files.
restart_output_dir, & ! Directory into which to write restart files.
input_filename ! A string that indicates the input files or how
! the run segment should be started.
character(len=240) :: output_dir
integer :: unit, io, ierr, valid_param_files

namelist /MOM_input_nml/ output_directory, input_filename, parameter_filename, &
restart_input_dir, restart_output_dir

! Default values in case parameter is not set in file input.nml
parameter_filename(:) = ' '
output_directory = ' '
restart_input_dir = ' '
restart_output_dir = ' '
input_filename = ' '
if (present(default_input_filename)) input_filename = trim(default_input_filename)

! 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 +98,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
2 changes: 1 addition & 1 deletion src/framework/MOM_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ subroutine restore_state(filename, directory, day, G, CS)
! restart_init.

character(len=200) :: filepath ! The path (dir/file) to the file being opened.
character(len=80) :: fname ! The name of the current file.
character(len=80) :: fname ! The name of the current file.
character(len=8) :: suffix ! A suffix (like "_2") that is added to any
! additional restart files.
character(len=256) :: mesg ! A message for warnings.
Expand Down
12 changes: 6 additions & 6 deletions src/ice_shelf/MOM_ice_shelf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1905,9 +1905,9 @@ subroutine initialize_ice_shelf(param_file, ocn_grid, Time, CS, diag, fluxes, Ti
'salinity in the boundary layer minus salinity at the ice-ocean interface.', 'PPT')
CS%id_Sbdry = register_diag_field('ocean_model', 'sbdry', CS%diag%axesT1, CS%Time, &
'salinity at the ice-ocean interface.', 'PPT')
CS%id_u_ml = register_diag_field('ocean_model', 'u_ml', CS%diag%axesT1, CS%Time, &
CS%id_u_ml = register_diag_field('ocean_model', 'u_ml', CS%diag%axesCu1, CS%Time, &
'Eastward vel. in the boundary layer (used to compute ustar)', 'meter second-1')
CS%id_v_ml = register_diag_field('ocean_model', 'v_ml', CS%diag%axesT1, CS%Time, &
CS%id_v_ml = register_diag_field('ocean_model', 'v_ml', CS%diag%axesCv1, CS%Time, &
'Northward vel. in the boundary layer (used to compute ustar)', 'meter second-1')
CS%id_exch_vel_s = register_diag_field('ocean_model', 'exch_vel_s', CS%diag%axesT1, CS%Time, &
'Sub-shelf salinity exchange velocity', 'meter second-1')
Expand All @@ -1921,13 +1921,13 @@ subroutine initialize_ice_shelf(param_file, ocn_grid, Time, CS, diag, fluxes, Ti
'Fric vel under shelf', 'm/s')

if (CS%shelf_mass_is_dynamic .and. .not.CS%override_shelf_movement) then
CS%id_u_shelf = register_diag_field('ocean_model','u_shelf',CS%diag%axesB1,CS%Time, &
CS%id_u_shelf = register_diag_field('ocean_model','u_shelf',CS%diag%axesCu1,CS%Time, &
'x-velocity of ice', 'm year')
CS%id_v_shelf = register_diag_field('ocean_model','v_shelf',CS%diag%axesB1,CS%Time, &
CS%id_v_shelf = register_diag_field('ocean_model','v_shelf',CS%diag%axesCv1,CS%Time, &
'y-velocity of ice', 'm year')
CS%id_u_mask = register_diag_field('ocean_model','u_mask',CS%diag%axesB1,CS%Time, &
CS%id_u_mask = register_diag_field('ocean_model','u_mask',CS%diag%axesCu1,CS%Time, &
'mask for u-nodes', 'none')
CS%id_v_mask = register_diag_field('ocean_model','v_mask',CS%diag%axesB1,CS%Time, &
CS%id_v_mask = register_diag_field('ocean_model','v_mask',CS%diag%axesCv1,CS%Time, &
'mask for v-nodes', 'none')
CS%id_h_mask = register_diag_field('ocean_model','h_mask',CS%diag%axesT1,CS%Time, &
'ice shelf thickness', 'none')
Expand Down

0 comments on commit b85463d

Please sign in to comment.