Skip to content

Commit

Permalink
Merge pull request #2 from NOAA-GFDL/dev/gfdl
Browse files Browse the repository at this point in the history
Latest changes from MOM dev/gfdl
  • Loading branch information
wrongkindofdoctor authored Aug 28, 2018
2 parents 171e0c8 + 50c4f60 commit b0f1236
Show file tree
Hide file tree
Showing 59 changed files with 1,406 additions and 996 deletions.
700 changes: 431 additions & 269 deletions config_src/coupled_driver/MOM_surface_forcing.F90

Large diffs are not rendered by default.

292 changes: 140 additions & 152 deletions config_src/coupled_driver/ocean_model_MOM.F90

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions config_src/mct_driver/ocn_comp_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1790,8 +1790,7 @@ subroutine update_ocean_model(OS, Ocean_sfc, time_start_update, &
OS%nstep = OS%nstep + 1

call enable_averaging(time_step, OS%Time, OS%diag)
call mech_forcing_diags(OS%forces, OS%fluxes, time_step, OS%grid, &
OS%diag, OS%forcing_CSp%handles)
call mech_forcing_diags(OS%forces, time_step, OS%grid, OS%diag, OS%forcing_CSp%handles)
call disable_averaging(OS%diag)

if (OS%fluxes%fluxes_used) then
Expand Down
95 changes: 2 additions & 93 deletions config_src/solo_driver/MESO_surface_forcing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ module MESO_surface_forcing
use MOM_forcing_type, only : allocate_forcing_type, allocate_mech_forcing
use MOM_grid, only : ocean_grid_type
use MOM_io, only : file_exists, MOM_read_data, slasher
use MOM_time_manager, only : time_type, operator(+), operator(/), get_time
use MOM_time_manager, only : time_type, operator(+), operator(/)
use MOM_tracer_flow_control, only : call_tracer_set_forcing
use MOM_tracer_flow_control, only : tracer_flow_control_CS
use MOM_variables, only : surface

implicit none ; private

public MESO_wind_forcing, MESO_buoyancy_forcing, MESO_surface_forcing_init
public MESO_buoyancy_forcing, MESO_surface_forcing_init

!> This control structure is used to store parameters associated with the MESO forcing.
type, public :: MESO_surface_forcing_CS ; private
Expand Down Expand Up @@ -52,71 +52,6 @@ module MESO_surface_forcing

contains

!### This subroutine sets zero surface wind stresses, but it is not even
!### used by the MESO experimeents. This subroutine can be deleted. -RWH
subroutine MESO_wind_forcing(sfc_state, forces, day, G, CS)
type(surface), intent(inout) :: sfc_state !< A structure containing fields that
!! describe the surface state of the ocean.
type(mech_forcing), intent(inout) :: forces !< A structure with the driving mechanical forces
type(time_type), intent(in) :: day !< The time of the fluxes
type(ocean_grid_type), intent(inout) :: G !< The ocean's grid structure
type(MESO_surface_forcing_CS), pointer :: CS !< A pointer to the control structure returned by a previous
!! call to MESO_surface_forcing_init

! This subroutine sets the surface wind stresses, forces%taux and forces%tauy.
! These are the stresses in the direction of the model grid (i.e. the same
! direction as the u- and v- velocities.) They are both in Pa.
! In addition, this subroutine can be used to set the surface friction
! velocity, forces%ustar, in m s-1. This is needed with a bulk mixed layer.
!
! Arguments: state - A structure containing fields that describe the
! surface state of the ocean.
! (out) fluxes - A structure containing pointers to any possible
! forcing fields. Unused fields have NULL ptrs.
! (in) day - Time of the fluxes.
! (in) G - The ocean's grid structure.
! (in) CS - A pointer to the control structure returned by a previous
! call to MESO_surface_forcing_init

integer :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq
integer :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB

! When modifying the code, comment out this error message. It is here
! so that the original (unmodified) version is not accidentally used.
call MOM_error(FATAL, "MESO_wind_surface_forcing: " // &
"User forcing routine called without modification." )

is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec
Isq = G%IscB ; Ieq = G%IecB ; Jsq = G%JscB ; Jeq = G%JecB
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB

! Allocate the forcing arrays, if necessary.
call allocate_mech_forcing(G, forces, stress=.true., ustar=.true.)

! Set the surface wind stresses, in units of Pa. A positive taux
! accelerates the ocean to the (pseudo-)east.

! The i-loop extends to is-1 so that taux can be used later in the
! calculation of ustar - otherwise the lower bound would be Isq.
do j=js,je ; do I=is-1,Ieq
forces%taux(I,j) = G%mask2dCu(I,j) * 0.0 ! Change this to the desired expression.
enddo ; enddo
do J=js-1,Jeq ; do i=is,ie
forces%tauy(i,J) = G%mask2dCv(i,J) * 0.0 ! Change this to the desired expression.
enddo ; enddo

! Set the surface friction velocity, in units of m s-1. ustar
! is always positive.
if (associated(forces%ustar)) then ; do j=js,je ; do i=is,ie
! This expression can be changed if desired, but need not be.
forces%ustar(i,j) = G%mask2dT(i,j) * sqrt(CS%gust_const/CS%Rho0 + &
sqrt(0.5*(forces%taux(I-1,j)**2 + forces%taux(I,j)**2) + &
0.5*(forces%tauy(i,J-1)**2 + forces%tauy(i,J)**2))/CS%Rho0)
enddo ; enddo ; endif

end subroutine MESO_wind_forcing

!> This subroutine sets up the MESO buoyancy forcing, which uses control-theory style
!! specification restorative buoyancy fluxes at large scales.
subroutine MESO_buoyancy_forcing(sfc_state, fluxes, day, dt, G, CS)
Expand All @@ -130,10 +65,6 @@ subroutine MESO_buoyancy_forcing(sfc_state, fluxes, day, dt, G, CS)
type(MESO_surface_forcing_CS), pointer :: CS !< A pointer to the control structure returned by
!! a previous call to MESO_surface_forcing_init

! This subroutine specifies the current surface fluxes of buoyancy or
! temperature and fresh water. It may also be modified to add
! surface fluxes of user provided tracers.

! When temperature is used, there are long list of fluxes that need to be
! set - essentially the same as for a full coupled model, but most of these
! can be simply set to zero. The net fresh water flux should probably be
Expand All @@ -144,17 +75,6 @@ subroutine MESO_buoyancy_forcing(sfc_state, fluxes, day, dt, G, CS)
! are in W m-2 and positive for heat going into the ocean. All fresh water
! fluxes are in kg m-2 s-1 and positive for water moving into the ocean.

! Arguments: state - A structure containing fields that describe the
! surface state of the ocean.
! (out) fluxes - A structure containing pointers to any possible
! forcing fields. Unused fields have NULL ptrs.
! (in) day_start - Start time of the fluxes.
! (in) day_interval - Length of time over which these fluxes
! will be applied.
! (in) G - The ocean's grid structure.
! (in) CS - A pointer to the control structure returned by a previous
! call to MESO_surface_forcing_init

real :: Temp_restore ! The temperature that is being restored toward, in C.
real :: Salin_restore ! The salinity that is being restored toward, in PSU.
real :: density_restore ! The potential density that is being restored
Expand Down Expand Up @@ -293,14 +213,6 @@ subroutine MESO_surface_forcing_init(Time, G, param_file, diag, CS)
type(MESO_surface_forcing_CS), pointer :: CS !< A pointer that is set to point to the
!! control structure for this module

! Arguments: Time - The current model time.
! (in) G - The ocean's grid structure.
! (in) param_file - A structure indicating the open file to parse for
! model parameter values.
! (in) diag - A structure that is used to regulate diagnostic output.
! (in/out) CS - A pointer that is set to point to the control structure
! for this module

! This include declares and sets the variable "version".
#include "version_variable.h"
character(len=40) :: mdl = "MESO_surface_forcing" ! This module's name.
Expand Down Expand Up @@ -383,9 +295,6 @@ end subroutine MESO_surface_forcing_init
!! it is probably a good idea to read the forcing from input files
!! using "file" for WIND_CONFIG and BUOY_CONFIG.
!!
!! MESO_wind_forcing should set the surface wind stresses (taux and
!! tauy) perhaps along with the surface friction velocity (ustar).
!!
!! MESO_buoyancy forcing is used to set the surface buoyancy
!! forcing, which may include a number of fresh water flux fields
!! (evap, liq_precip, froz_precip, liq_runoff, froz_runoff, and
Expand Down
38 changes: 19 additions & 19 deletions config_src/solo_driver/MOM_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ program MOM_main
use MOM_string_functions,only : uppercase
use MOM_surface_forcing, only : set_forcing, forcing_save_restart
use MOM_surface_forcing, only : surface_forcing_init, surface_forcing_CS
use MOM_time_manager, only : time_type, set_date, set_time, get_date, time_type_to_real
use MOM_time_manager, only : time_type, set_date, get_date
use MOM_time_manager, only : real_to_time, time_type_to_real
use MOM_time_manager, only : operator(+), operator(-), operator(*), operator(/)
use MOM_time_manager, only : operator(>), operator(<), operator(>=)
use MOM_time_manager, only : increment_date, set_calendar_type, month_name
Expand Down Expand Up @@ -137,7 +138,7 @@ program MOM_main
real :: dt_dyn, dtdia, t_elapsed_seg
integer :: n, n_max, nts, n_last_thermo
logical :: diabatic_first, single_step_call
type(time_type) :: Time2
type(time_type) :: Time2, time_chg

integer :: Restart_control ! An integer that is bit-tested to determine whether
! incremental restart files are saved and whether they
Expand Down Expand Up @@ -290,7 +291,7 @@ program MOM_main
Start_time = set_date(date_init(1),date_init(2), date_init(3), &
date_init(4),date_init(5),date_init(6))
else
Start_time = set_time(0,days=0)
Start_time = real_to_time(0.0)
endif

call time_interp_external_init
Expand Down Expand Up @@ -356,7 +357,7 @@ program MOM_main
endif
ntstep = MAX(1,ceiling(dt_forcing/dt - 0.001))

Time_step_ocean = set_time(int(floor(dt_forcing+0.5)))
Time_step_ocean = real_to_time(dt_forcing)
elapsed_time_master = (abs(dt_forcing - time_type_to_real(Time_step_ocean)) > 1.0e-12*dt_forcing)
if (elapsed_time_master) &
call MOM_mesg("Using real elapsed time for the master clock.", 2)
Expand Down Expand Up @@ -415,7 +416,7 @@ program MOM_main
call get_param(param_file, mod_name, "RESTINT", restint, &
"The interval between saves of the restart file in units \n"//&
"of TIMEUNIT. Use 0 (the default) to not save \n"//&
"incremental restart files at all.", default=set_time(0), &
"incremental restart files at all.", default=real_to_time(0.0), &
timeunit=Time_unit)
call get_param(param_file, mod_name, "WRITE_CPU_STEPS", cpu_steps, &
"The number of coupled timesteps between writing the cpu \n"//&
Expand Down Expand Up @@ -454,7 +455,7 @@ program MOM_main
if (((.not.BTEST(Restart_control,1)) .and. (.not.BTEST(Restart_control,0))) &
.or. (Restart_control < 0)) permit_incr_restart = .false.

if (restint > set_time(0)) then
if (restint > real_to_time(0.0)) then
! restart_time is the next integral multiple of restint.
restart_time = Start_time + restint * &
(1 + ((Time + Time_step_ocean) - Start_time) / restint)
Expand Down Expand Up @@ -532,7 +533,7 @@ program MOM_main
dtdia = dt_dyn*(n - n_last_thermo)
! Back up Time2 to the start of the thermodynamic segment.
if (n > n_last_thermo+1) &
Time2 = Time2 - set_time(int(floor((dtdia - dt_dyn) + 0.5)))
Time2 = Time2 - real_to_time(dtdia - dt_dyn)
call step_MOM(forces, fluxes, sfc_state, Time2, dtdia, MOM_CSp, &
do_dynamics=.false., do_thermodynamics=.true., &
start_cycle=.false., end_cycle=(n==n_max), cycle_length=dt_forcing)
Expand All @@ -541,25 +542,25 @@ program MOM_main
endif

t_elapsed_seg = t_elapsed_seg + dt_dyn
Time2 = Time1 + set_time(int(floor(t_elapsed_seg + 0.5)))
Time2 = Time1 + real_to_time(t_elapsed_seg)
enddo
endif

! Time = Time + Time_step_ocean
! This is here to enable fractional-second time steps.
elapsed_time = elapsed_time + dt_forcing
if (elapsed_time > 2e9) then
! This is here to ensure that the conversion from a real to an integer
! can be accurately represented in long runs (longer than ~63 years).
! It will also ensure that elapsed time does not lose resolution of order
! the timetype's resolution, provided that the timestep and tick are
! larger than 10-5 seconds. If a clock with a finer resolution is used,
! a smaller value would be required.
segment_start_time = segment_start_time + set_time(int(floor(elapsed_time)))
elapsed_time = elapsed_time - floor(elapsed_time)
! This is here to ensure that the conversion from a real to an integer can be accurately
! represented in long runs (longer than ~63 years). It will also ensure that elapsed time
! does not lose resolution of order the timetype's resolution, provided that the timestep and
! tick are larger than 10-5 seconds. If a clock with a finer resolution is used, a smaller
! value would be required.
time_chg = real_to_time(elapsed_time)
segment_start_time = segment_start_time + time_chg
elapsed_time = elapsed_time - time_type_to_real(time_chg)
endif
if (elapsed_time_master) then
Master_Time = segment_start_time + set_time(int(floor(elapsed_time+0.5)))
Master_Time = segment_start_time + real_to_time(elapsed_time)
else
Master_Time = Master_Time + Time_step_ocean
endif
Expand All @@ -570,8 +571,7 @@ program MOM_main
endif ; endif

call enable_averaging(dt_forcing, Time, diag)
call mech_forcing_diags(forces, fluxes, dt_forcing, grid, diag, &
surface_forcing_CSp%handles)
call mech_forcing_diags(forces, dt_forcing, grid, diag, surface_forcing_CSp%handles)
call disable_averaging(diag)

if (.not. offline_tracer_mode) then
Expand Down
Loading

0 comments on commit b0f1236

Please sign in to comment.