Skip to content

Commit

Permalink
Merge branch 'dev/gfdl' into logged_param_units
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallward authored Dec 12, 2022
2 parents 1edf11f + 3327037 commit 9982d44
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 262 deletions.
4 changes: 2 additions & 2 deletions .github/actions/ubuntu-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
sudo apt-get install netcdf-bin
sudo apt-get install libnetcdf-dev
sudo apt-get install libnetcdff-dev
sudo apt-get install mpich
sudo apt-get install libmpich-dev
sudo apt-get install openmpi-bin
sudo apt-get install libopenmpi-dev
sudo apt-get install linux-tools-common
echo "::endgroup::"
258 changes: 151 additions & 107 deletions ac/makedep

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/core/MOM_barotropic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4614,15 +4614,17 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, US, param_file, diag, CS,
"gravity waves) to 1 (for a backward Euler treatment). "//&
"In practice, BEBT must be greater than about 0.05.", &
units="nondim", default=0.1)
! Note that dtbt_input is not rescaled because it has different units for
! positive [s] and negative [nondim] values.
call get_param(param_file, mdl, "DTBT", dtbt_input, &
"The barotropic time step, in s. DTBT is only used with "//&
"the split explicit time stepping. To set the time step "//&
"automatically based the maximum stable value use 0, or "//&
"a negative value gives the fraction of the stable value. "//&
"Setting DTBT to 0 is the same as setting it to -0.98. "//&
"The value of DTBT that will actually be used is an "//&
"integer fraction of DT, rounding down.", units="s or nondim",&
default = -0.98)
"integer fraction of DT, rounding down.", &
units="s or nondim", default=-0.98)
call get_param(param_file, mdl, "BT_USE_OLD_CORIOLIS_BRACKET_BUG", &
CS%use_old_coriolis_bracket_bug , &
"If True, use an order of operations that is not bitwise "//&
Expand Down
71 changes: 36 additions & 35 deletions src/diagnostics/MOM_sum_output.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module MOM_sum_output
! This file is part of MOM6. See LICENSE.md for the license.

use iso_fortran_env, only : int64
use MOM_checksums, only : is_NaN
use MOM_coms, only : sum_across_PEs, PE_here, root_PE, num_PEs, max_across_PEs, field_chksum
use MOM_coms, only : reproducing_sum, reproducing_sum_EFP, EFP_to_real, real_to_EFP
use MOM_coms, only : EFP_type, operator(+), operator(-), assignment(=), EFP_sum_across_PEs
Expand Down Expand Up @@ -108,14 +109,16 @@ module MOM_sum_output
!! of calls to write_energy and revert to the standard
!! energysavedays interval

real :: timeunit !< The length of the units for the time axis [s].
real :: timeunit !< The length of the units for the time axis and certain input parameters
!! including ENERGYSAVEDAYS [s].

logical :: date_stamped_output !< If true, use dates (not times) in messages to stdout.
type(time_type) :: Start_time !< The start time of the simulation.
! Start_time is set in MOM_initialization.F90
integer, pointer :: ntrunc => NULL() !< The number of times the velocity has been
!! truncated since the last call to write_energy.
real :: max_Energy !< The maximum permitted energy per unit mass. If there is
!! more energy than this, the model should stop [m2 s-2].
!! more energy than this, the model should stop [L2 T-2 ~> m2 s-2].
integer :: maxtrunc !< The number of truncations per energy save
!! interval at which the run is stopped.
logical :: write_stocks !< If true, write the integrated tracer amounts
Expand Down Expand Up @@ -147,13 +150,12 @@ subroutine MOM_sum_output_init(G, GV, US, param_file, directory, ntrnc, &
type(Sum_output_CS), pointer :: CS !< A pointer that is set to point to the
!! control structure for this module.
! Local variables
real :: Time_unit ! The time unit in seconds for ENERGYSAVEDAYS [s]
real :: maxvel ! The maximum permitted velocity [m s-1]
real :: maxvel ! The maximum permitted velocity [L T-1 ~> m s-1]
! This include declares and sets the variable "version".
# include "version_variable.h"
character(len=40) :: mdl = "MOM_sum_output" ! This module's name.
character(len=200) :: energyfile ! The name of the energy file.
character(len=32) :: filename_appendix = '' !fms appendix to filename for ensemble runs
character(len=32) :: filename_appendix = '' ! FMS appendix to filename for ensemble runs

if (associated(CS)) then
call MOM_error(WARNING, "MOM_sum_output_init called with associated control structure.")
Expand Down Expand Up @@ -190,13 +192,13 @@ subroutine MOM_sum_output_init(G, GV, US, param_file, directory, ntrnc, &
"The maximum permitted average energy per unit mass; the "//&
"model will be stopped if there is more energy than "//&
"this. If zero or negative, this is set to 10*MAXVEL^2.", &
units="m2 s-2", default=0.0)
units="m2 s-2", default=0.0, scale=US%m_s_to_L_T**2)
if (CS%max_Energy <= 0.0) then
call get_param(param_file, mdl, "MAXVEL", maxvel, &
"The maximum velocity allowed before the velocity "//&
"components are truncated.", units="m s-1", default=3.0e8)
"components are truncated.", units="m s-1", default=3.0e8, scale=US%m_s_to_L_T)
CS%max_Energy = 10.0 * maxvel**2
call log_param(param_file, mdl, "MAX_ENERGY as used", CS%max_Energy)
call log_param(param_file, mdl, "MAX_ENERGY as used", US%L_T_to_m_s**2*CS%max_Energy, units="m2 s-2")
endif

call get_param(param_file, mdl, "ENERGYFILE", energyfile, &
Expand All @@ -218,13 +220,12 @@ subroutine MOM_sum_output_init(G, GV, US, param_file, directory, ntrnc, &
call get_param(param_file, mdl, "DATE_STAMPED_STDOUT", CS%date_stamped_output, &
"If true, use dates (not times) in messages to stdout", &
default=.true.)
! Note that the units of CS%Timeunit are the MKS units of [s].
call get_param(param_file, mdl, "TIMEUNIT", CS%Timeunit, &
"The time unit in seconds a number of input fields", &
units="s", default=86400.0)
if (CS%Timeunit < 0.0) CS%Timeunit = 86400.0



if (CS%do_APE_calc) then
call get_param(param_file, mdl, "READ_DEPTH_LIST", CS%read_depth_list, &
"Read the depth list from a file if it exists or "//&
Expand Down Expand Up @@ -257,18 +258,15 @@ subroutine MOM_sum_output_init(G, GV, US, param_file, directory, ntrnc, &
CS%DL%listsize = 1
endif

call get_param(param_file, mdl, "TIMEUNIT", Time_unit, &
"The time unit for ENERGYSAVEDAYS.", &
units="s", default=86400.0)
call get_param(param_file, mdl, "ENERGYSAVEDAYS",CS%energysavedays, &
"The interval in units of TIMEUNIT between saves of the "//&
"energies of the run and other globally summed diagnostics.",&
default=set_time(0,days=1), timeunit=Time_unit)
default=set_time(0,days=1), timeunit=CS%Timeunit)
call get_param(param_file, mdl, "ENERGYSAVEDAYS_GEOMETRIC",CS%energysavedays_geometric, &
"The starting interval in units of TIMEUNIT for the first call "//&
"to save the energies of the run and other globally summed diagnostics. "//&
"The interval increases by a factor of 2. after each call to write_energy.",&
default=set_time(seconds=0), timeunit=Time_unit)
default=set_time(seconds=0), timeunit=CS%Timeunit)

if ((time_type_to_real(CS%energysavedays_geometric) > 0.) .and. &
(CS%energysavedays_geometric < CS%energysavedays)) then
Expand Down Expand Up @@ -328,7 +326,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
real :: PE_tot ! The total available potential energy [J].
real :: Z_0APE(SZK_(GV)+1) ! The uniform depth which overlies the same
! volume as is below an interface [Z ~> m].
real :: H_0APE(SZK_(GV)+1) ! A version of Z_0APE, converted to m, usually positive.
real :: H_0APE(SZK_(GV)+1) ! A version of Z_0APE, converted to m, usually positive [m].
real :: toten ! The total kinetic & potential energies of
! all layers [J] (i.e. kg m2 s-2).
real :: En_mass ! The total kinetic and potential energies divided by
Expand Down Expand Up @@ -381,7 +379,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
real :: CFL_lin ! A simpler definition of the CFL number [nondim].
real :: max_CFL(2) ! The maxima of the CFL numbers [nondim].
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: &
tmp1 ! A temporary array
tmp1 ! A temporary array used in reproducing sums [various]
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: &
PE_pt ! The potential energy at each point [J].
real, dimension(SZI_(G),SZJ_(G)) :: &
Expand All @@ -398,21 +396,26 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
! lbelow & labove are lower & upper limits for li
! in the search for the entry in lH to use.
integer :: start_of_day, num_days
real :: reday, var
real :: reday ! Time in units given by CS%Timeunit, but often [days]
character(len=240) :: energypath_nc
character(len=200) :: mesg
character(len=32) :: mesg_intro, time_units, day_str, n_str, date_str
logical :: date_stamped
type(time_type) :: dt_force ! A time_type version of the forcing timestep.
real :: Tr_stocks(MAX_FIELDS_) ! The total amounts of each of the registered tracers
real :: Tr_min(MAX_FIELDS_) ! The global minimum unmasked value of the tracers
real :: Tr_max(MAX_FIELDS_) ! The global maximum unmasked value of the tracers
! The units of the tracer stock vary between tracers, with [conc] given explicitly by Tr_units.
real :: Tr_stocks(MAX_FIELDS_) ! The total amounts of each of the registered tracers [kg conc]
real :: Tr_min(MAX_FIELDS_) ! The global minimum unmasked value of the tracers [conc]
real :: Tr_max(MAX_FIELDS_) ! The global maximum unmasked value of the tracers [conc]
real :: Tr_min_x(MAX_FIELDS_) ! The x-positions of the global tracer minima
! in the units of G%geoLonT, often [degrees_E] or [km]
real :: Tr_min_y(MAX_FIELDS_) ! The y-positions of the global tracer minima
real :: Tr_min_z(MAX_FIELDS_) ! The z-positions of the global tracer minima
! in the units of G%geoLatT, often [degrees_N] or [km]
real :: Tr_min_z(MAX_FIELDS_) ! The z-positions of the global tracer minima [layer]
real :: Tr_max_x(MAX_FIELDS_) ! The x-positions of the global tracer maxima
! in the units of G%geoLonT, often [degrees_E] or [km]
real :: Tr_max_y(MAX_FIELDS_) ! The y-positions of the global tracer maxima
real :: Tr_max_z(MAX_FIELDS_) ! The z-positions of the global tracer maxima
! in the units of G%geoLatT, often [degrees_N] or [km]
real :: Tr_max_z(MAX_FIELDS_) ! The z-positions of the global tracer maxima [layer]
logical :: Tr_minmax_avail(MAX_FIELDS_) ! A flag indicating whether the global minimum and
! maximum information are available for each of the tracers
character(len=40), dimension(MAX_FIELDS_) :: &
Expand Down Expand Up @@ -860,8 +863,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
endif
endif

var = real(CS%ntrunc)
call write_field(CS%fileenergy_nc, CS%fields(1), var, reday)
call write_field(CS%fileenergy_nc, CS%fields(1), real(CS%ntrunc), reday)
call write_field(CS%fileenergy_nc, CS%fields(2), toten, reday)
call write_field(CS%fileenergy_nc, CS%fields(3), PE, reday)
call write_field(CS%fileenergy_nc, CS%fields(4), KE, reday)
Expand Down Expand Up @@ -891,13 +893,12 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci

call flush_file(CS%fileenergy_nc)

! The second (impossible-looking) test looks for a NaN in En_mass.
if ((En_mass>CS%max_Energy) .or. &
((En_mass>CS%max_Energy) .and. (En_mass<CS%max_Energy))) then
if (is_NaN(En_mass)) then
call MOM_error(FATAL, "write_energy : NaNs in total model energy forced model termination.")
elseif (En_mass > US%L_T_to_m_s**2*CS%max_Energy) then
write(mesg,'("Energy per unit mass of ",ES11.4," exceeds ",ES11.4)') &
En_mass, CS%max_Energy
call MOM_error(FATAL, &
"write_energy : Excessive energy per unit mass or NaNs forced model termination.")
En_mass, US%L_T_to_m_s**2*CS%max_Energy
call MOM_error(FATAL, "write_energy : Excessive energy per unit mass forced model termination.")
endif
if (CS%ntrunc>CS%maxtrunc) then
call MOM_error(FATAL, "write_energy : Ocean velocity has been truncated too many times.")
Expand All @@ -913,7 +914,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci

end subroutine write_energy

!> This subroutine accumates the net input of volume, salt and heat, through
!> This subroutine accumulates the net input of volume, salt and heat, through
!! the ocean surface for use in diagnosing conservation.
subroutine accumulate_net_input(fluxes, sfc_state, tv, dt, G, US, CS)
type(forcing), intent(in) :: fluxes !< A structure containing pointers to any possible
Expand Down Expand Up @@ -1100,7 +1101,7 @@ end subroutine depth_list_setup
subroutine create_depth_list(G, DL, min_depth_inc)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure.
type(Depth_List), intent(inout) :: DL !< The list of depths, areas and volumes to create
real, intent(in) :: min_depth_inc !< The minimum increment bewteen depths in the list [Z ~> m]
real, intent(in) :: min_depth_inc !< The minimum increment between depths in the list [Z ~> m]

! Local variables
real, dimension(G%Domain%niglobal*G%Domain%njglobal + 1) :: &
Expand All @@ -1110,7 +1111,7 @@ subroutine create_depth_list(G, DL, min_depth_inc)
indx2 !< The position of an element in the original unsorted list.
real :: Dnow !< The depth now being considered for sorting [Z ~> m].
real :: Dprev !< The most recent depth that was considered [Z ~> m].
real :: vol !< The running sum of open volume below a deptn [Z L2 ~> m3].
real :: vol !< The running sum of open volume below a depth [Z L2 ~> m3].
real :: area !< The open area at the current depth [L2 ~> m2].
real :: D_list_prev !< The most recent depth added to the list [Z ~> m].
logical :: add_to_list !< This depth should be included as an entry on the list.
Expand Down Expand Up @@ -1360,7 +1361,7 @@ subroutine get_depth_list_checksums(G, US, depth_chksum, area_chksum)
character(len=16), intent(out) :: area_chksum !< Area checksum hexstring

integer :: i, j
real, allocatable :: field(:,:)
real, allocatable :: field(:,:) ! A temporary array for output converted to MKS units [m] or [m2]

allocate(field(G%isc:G%iec, G%jsc:G%jec))

Expand Down
27 changes: 14 additions & 13 deletions src/framework/MOM_write_cputime.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ module MOM_write_cputime
!> A control structure that regulates the writing of CPU time
type, public :: write_cputime_CS ; private
logical :: initialized = .false. !< True if this control structure has been initialized.
real :: maxcpu !< The maximum amount of cpu time per processor
real :: maxcpu !< The maximum amount of CPU time per processor
!! for which MOM should run before saving a restart
!! file and quiting with a return value that
!! file and quitting with a return value that
!! indicates that further execution is required to
!! complete the simulation, in wall-clock seconds.
!! complete the simulation [wall-clock seconds].
type(time_type) :: Start_time !< The start time of the simulation.
!! Start_time is set in MOM_initialization.F90
real :: startup_cputime !< The CPU time used in the startup phase of the model.
real :: prev_cputime = 0.0 !< The last measured CPU time.
real :: dn_dcpu_min = -1.0 !< The minimum derivative of timestep with CPU time.
real :: cputime2 = 0.0 !< The accumulated cpu time.
real :: startup_cputime !< The CPU time used in the startup phase of the model [clock_cycles].
real :: prev_cputime = 0.0 !< The last measured CPU time [clock_cycles].
real :: dn_dcpu_min = -1.0 !< The minimum derivative of timestep with CPU time [steps clock_cycles-1].
real :: cputime2 = 0.0 !< The accumulated CPU time [clock_cycles].
integer :: previous_calls = 0 !< The number of times write_CPUtime has been called.
integer :: prev_n = 0 !< The value of n from the last call.
integer :: fileCPU_ascii= -1 !< The unit number of the CPU time file.
Expand Down Expand Up @@ -76,8 +76,8 @@ subroutine MOM_write_cputime_init(param_file, directory, Input_start_time, CS)

! Read all relevant parameters and write them to the model log.

! Determine whether all paramters are set to their default values.
call get_param(param_file, mdl, "MAXCPU", CS%maxcpu, default=-1.0, do_not_log=.true.)
! Determine whether all parameters are set to their default values.
call get_param(param_file, mdl, "MAXCPU", CS%maxcpu, units="wall-clock seconds", default=-1.0, do_not_log=.true.)
call get_param(param_file, mdl, "CPU_TIME_FILE", CS%CPUfile, default="CPU_stats", do_not_log=.true.)
all_default = (CS%maxcpu == -1.0) .and. (trim(CS%CPUfile) == trim("CPU_stats"))

Expand Down Expand Up @@ -135,10 +135,11 @@ subroutine write_cputime(day, n, CS, nmax, call_end)

! Local variables
real :: d_cputime ! The change in CPU time since the last call
! this subroutine.
integer :: new_cputime ! The CPU time returned by SYSTEM_CLOCK
real :: reday ! A real version of day.
integer :: start_of_day, num_days
! this subroutine [clock_cycles]
integer :: new_cputime ! The CPU time returned by SYSTEM_CLOCK [clock_cycles]
real :: reday ! The time in days, including fractional days [days]
integer :: start_of_day ! The number of seconds since the start of the day
integer :: num_days ! The number of days in the time

if (.not.associated(CS)) call MOM_error(FATAL, &
"write_energy: Module must be initialized before it is used.")
Expand Down
Loading

0 comments on commit 9982d44

Please sign in to comment.