Skip to content

Commit

Permalink
+Always call initialization routines to get_params
Browse files Browse the repository at this point in the history
  Modified MOM_state_initialization and all of the thickness, temperature, and
velocity initialization routines it calls so that the relevant routines are
always called, regardless of whether this run segment is for a new run or
started from a restart file, so that all valid parameters are read.  This will
enable detection of misspelled or invalid runtime parameters without requiring
that the MOM input files be changed between run segments. Several
MOM_parameter_doc files have been changed by the addition of missing log_version
calls for some initialization routines. All answers are bitwise identical, but
there are new optional arguments to numerous intialization routines.
This commit addresses and should close NOAA-GFDL/MOM6-examples Issue #135.
  • Loading branch information
Hallberg-NOAA committed Jun 29, 2017
1 parent 0c4f909 commit e6b7df2
Show file tree
Hide file tree
Showing 18 changed files with 1,115 additions and 705 deletions.
875 changes: 511 additions & 364 deletions src/initialization/MOM_state_initialization.F90

Large diffs are not rendered by default.

61 changes: 44 additions & 17 deletions src/user/DOME2d_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module DOME2d_initialization
public DOME2d_initialize_temperature_salinity
public DOME2d_initialize_sponges

character(len=40) :: mod = "DOEM2D_initialization" !< This module's name.
character(len=40) :: mod = "DOME2D_initialization" !< This module's name.

contains

Expand All @@ -43,7 +43,10 @@ subroutine DOME2d_initialize_topography ( D, G, param_file, max_depth )
integer :: i, j
real :: x, bay_depth, l1, l2
real :: dome2d_width_bay, dome2d_width_bottom, dome2d_depth_bay
! This include declares and sets the variable "version".
#include "version_variable.h"

call log_version(param_file, mod, version, "")
call get_param(param_file, mod, "DOME2D_SHELF_WIDTH", dome2d_width_bay, &
'Width of shelf, as fraction of domain, in 2d DOME configuration.', &
units='nondim',default=0.1)
Expand Down Expand Up @@ -82,26 +85,35 @@ subroutine DOME2d_initialize_topography ( D, G, param_file, max_depth )
end subroutine DOME2d_initialize_topography

!> Initialize thicknesses according to coordinate mode
subroutine DOME2d_initialize_thickness ( h, G, GV, param_file )
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
type(verticalGrid_type), intent(in) :: GV !< Vertical grid structure
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(out) :: h !< Layer thicknesses
type(param_file_type), intent(in) :: param_file !< Parameter file structure
subroutine DOME2d_initialize_thickness ( h, G, GV, param_file, just_read_params )
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
type(verticalGrid_type), intent(in) :: GV !< Vertical grid structure
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
intent(out) :: h !< The thickness that is being initialized, in m.
type(param_file_type), intent(in) :: param_file !< A structure indicating the open file
!! to parse for model parameter values.
logical, optional, intent(in) :: just_read_params !< If present and true, this call will
!! only read parameters without changing h.

! Local variables
real :: e0(SZK_(G)) ! The resting interface heights, in m, usually !
! negative because it is positive upward. !
real :: eta1D(SZK_(G)+1)! Interface height relative to the sea surface !
! positive upward, in m. !
real :: e0(SZK_(GV)) ! The resting interface heights, in m, usually !
! negative because it is positive upward. !
real :: eta1D(SZK_(GV)+1)! Interface height relative to the sea surface !
! positive upward, in m. !
integer :: i, j, k, is, ie, js, je, nz
real :: x
real :: delta_h
real :: min_thickness
character(len=40) :: verticalCoordinate
real :: dome2d_width_bay, dome2d_width_bottom, dome2d_depth_bay
logical :: just_read ! If true, just read parameters but set nothing.
character(len=40) :: verticalCoordinate

is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = G%ke

call MOM_mesg("MOM_initialization.F90, DOME2d_initialize_thickness: setting thickness")
just_read = .false. ; if (present(just_read_params)) just_read = just_read_params

if (.not.just_read) &
call MOM_mesg("MOM_initialization.F90, DOME2d_initialize_thickness: setting thickness")

call get_param(param_file,mod,"MIN_THICKNESS",min_thickness, &
default=1.e-3, do_not_log=.true.)
Expand All @@ -114,6 +126,8 @@ subroutine DOME2d_initialize_thickness ( h, G, GV, param_file )
call get_param(param_file, mod, "DOME2D_SHELF_DEPTH", dome2d_depth_bay, &
default=0.2, do_not_log=.true.)

if (just_read) return ! All run-time parameters have been read, so return.

! WARNING: this routine specifies the interface heights so that the last layer
! is vanished, even at maximum depth. In order to have a uniform
! layer distribution, use this line of code within the loop:
Expand Down Expand Up @@ -202,13 +216,17 @@ end subroutine DOME2d_initialize_thickness


!> Initialize temperature and salinity in the 2d DOME configuration
subroutine DOME2d_initialize_temperature_salinity ( T, S, h, G, param_file, eqn_of_state)
subroutine DOME2d_initialize_temperature_salinity ( T, S, h, G, param_file, &
eqn_of_state, just_read_params)
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
real, dimension(SZI_(G),SZJ_(G), SZK_(G)), intent(out) :: T !< Potential temperature (degC)
real, dimension(SZI_(G),SZJ_(G), SZK_(G)), intent(out) :: S !< Salinity (ppt)
real, dimension(SZI_(G),SZJ_(G), SZK_(G)), intent(in) :: h !< Layer thickness (m or Pa)
type(param_file_type), intent(in) :: param_file !< Parameter file structure
type(EOS_type), pointer :: eqn_of_state !< Equation of state structure
logical, optional, intent(in) :: just_read_params !< If present and true, this call will
!! only read parameters without changing h.

! Local variables
integer :: i, j, k, is, ie, js, je, nz
real :: x;
Expand All @@ -217,11 +235,14 @@ subroutine DOME2d_initialize_temperature_salinity ( T, S, h, G, param_file, eqn_
real :: S_ref, T_ref; ! Reference salinity and temperature within surface layer
real :: S_range, T_range; ! Range of salinities and temperatures over the vertical
real :: xi0, xi1;
logical :: just_read ! If true, just read parameters but set nothing.
character(len=40) :: verticalCoordinate
real :: dome2d_width_bay, dome2d_width_bottom, dome2d_depth_bay

is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = G%ke

just_read = .false. ; if (present(just_read_params)) just_read = just_read_params

call get_param(param_file,mod,"REGRIDDING_COORDINATE_MODE", verticalCoordinate, &
default=DEFAULT_COORDINATE_MODE, do_not_log=.true.)
call get_param(param_file, mod, "DOME2D_SHELF_WIDTH", dome2d_width_bay, &
Expand All @@ -230,10 +251,16 @@ subroutine DOME2d_initialize_temperature_salinity ( T, S, h, G, param_file, eqn_
default=0.3, do_not_log=.true.)
call get_param(param_file, mod, "DOME2D_SHELF_DEPTH", dome2d_depth_bay, &
default=0.2, do_not_log=.true.)
call get_param(param_file,mod,"S_REF",S_ref,'Reference salinity',units='1e-3',fail_if_missing=.true.)
call get_param(param_file,mod,"T_REF",T_ref,'Refernce temperature',units='C',fail_if_missing=.true.)
call get_param(param_file,mod,"S_RANGE",S_range,'Initial salinity range',units='1e-3',default=2.0)
call get_param(param_file,mod,"T_RANGE",T_range,'Initial temperature range',units='1e-3',default=0.0)
call get_param(param_file,mod,"S_REF",S_ref,'Reference salinity',units='1e-3', &
fail_if_missing=.not.just_read, do_not_log=just_read)
call get_param(param_file,mod,"T_REF",T_ref,'Refernce temperature',units='C', &
fail_if_missing=.not.just_read, do_not_log=just_read)
call get_param(param_file,mod,"S_RANGE",S_range,'Initial salinity range', &
units='1e-3', default=2.0, do_not_log=just_read)
call get_param(param_file,mod,"T_RANGE",T_range,'Initial temperature range', &
units='1e-3', default=0.0, do_not_log=just_read)

if (just_read) return ! All run-time parameters have been read, so return.

T(:,:,:) = 0.0
S(:,:,:) = 0.0
Expand Down
26 changes: 17 additions & 9 deletions src/user/DOME_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,30 @@ end subroutine DOME_initialize_topography

! -----------------------------------------------------------------------------
!> This subroutine initializes layer thicknesses for the DOME experiment
subroutine DOME_initialize_thickness(h, G, GV, param_file)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure.
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure.
real, intent(out), dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: h !< The thickness that is being initialized.
type(param_file_type), intent(in) :: param_file !< A structure indicating the open file
!! to parse for model parameter values.

real :: e0(SZK_(G)+1) ! The resting interface heights, in m, usually !
subroutine DOME_initialize_thickness(h, G, GV, param_file, just_read_params)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure.
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure.
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
intent(out) :: h !< The thickness that is being initialized, in m.
type(param_file_type), intent(in) :: param_file !< A structure indicating the open file
!! to parse for model parameter values.
logical, optional, intent(in) :: just_read_params !< If present and true, this call will
!! only read parameters without changing h.

real :: e0(SZK_(GV)+1) ! The resting interface heights, in m, usually !
! negative because it is positive upward. !
real :: eta1D(SZK_(G)+1) ! Interface height relative to the sea surface !
real :: eta1D(SZK_(GV)+1) ! Interface height relative to the sea surface !
! positive upward, in m. !
logical :: just_read ! If true, just read parameters but set nothing.
character(len=40) :: mod = "DOME_initialize_thickness" ! This subroutine's name.
integer :: i, j, k, is, ie, js, je, nz

is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = G%ke

just_read = .false. ; if (present(just_read_params)) just_read = just_read_params

if (just_read) return ! This subroutine has no run-time parameters.

call MOM_mesg(" DOME_initialization.F90, DOME_initialize_thickness: setting thickness", 5)

e0(1)=0.0
Expand Down
Loading

0 comments on commit e6b7df2

Please sign in to comment.