Skip to content

Commit

Permalink
Merge branch 'dev/gfdl' into bugfix/sanAkel/output-b-grid-currents
Browse files Browse the repository at this point in the history
  • Loading branch information
sanAkel authored Mar 27, 2021
2 parents fad7e0d + 67b03e3 commit 6c2b944
Show file tree
Hide file tree
Showing 27 changed files with 7,783 additions and 282 deletions.
56 changes: 32 additions & 24 deletions config_src/drivers/FMS_cap/MOM_surface_forcing_gfdl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module MOM_surface_forcing_gfdl
use MOM_variables, only : surface
use user_revise_forcing, only : user_alter_forcing, user_revise_forcing_init
use user_revise_forcing, only : user_revise_forcing_CS
use iso_fortran_env, only : int64

implicit none ; private

Expand Down Expand Up @@ -1622,32 +1623,39 @@ subroutine ice_ocn_bnd_type_chksum(id, timestep, iobt)
type(ice_ocean_boundary_type), &
intent(in) :: iobt !< An ice-ocean boundary type with fluxes to drive the
!! ocean in a coupled model whose checksums are reported
integer :: n,m, outunit
! Local variables
integer(kind=int64) :: chks ! A checksum for the field
logical :: root ! True only on the root PE
integer :: outunit ! The output unit to write to

outunit = stdout

write(outunit,*) "BEGIN CHECKSUM(ice_ocean_boundary_type):: ", id, timestep
write(outunit,100) 'iobt%u_flux ', field_chksum( iobt%u_flux )
write(outunit,100) 'iobt%v_flux ', field_chksum( iobt%v_flux )
write(outunit,100) 'iobt%t_flux ', field_chksum( iobt%t_flux )
write(outunit,100) 'iobt%q_flux ', field_chksum( iobt%q_flux )
write(outunit,100) 'iobt%salt_flux ', field_chksum( iobt%salt_flux )
write(outunit,100) 'iobt%lw_flux ', field_chksum( iobt%lw_flux )
write(outunit,100) 'iobt%sw_flux_vis_dir', field_chksum( iobt%sw_flux_vis_dir)
write(outunit,100) 'iobt%sw_flux_vis_dif', field_chksum( iobt%sw_flux_vis_dif)
write(outunit,100) 'iobt%sw_flux_nir_dir', field_chksum( iobt%sw_flux_nir_dir)
write(outunit,100) 'iobt%sw_flux_nir_dif', field_chksum( iobt%sw_flux_nir_dif)
write(outunit,100) 'iobt%lprec ', field_chksum( iobt%lprec )
write(outunit,100) 'iobt%fprec ', field_chksum( iobt%fprec )
write(outunit,100) 'iobt%runoff ', field_chksum( iobt%runoff )
write(outunit,100) 'iobt%calving ', field_chksum( iobt%calving )
write(outunit,100) 'iobt%p ', field_chksum( iobt%p )
if (associated(iobt%ustar_berg)) &
write(outunit,100) 'iobt%ustar_berg ', field_chksum( iobt%ustar_berg )
if (associated(iobt%area_berg)) &
write(outunit,100) 'iobt%area_berg ', field_chksum( iobt%area_berg )
if (associated(iobt%mass_berg)) &
write(outunit,100) 'iobt%mass_berg ', field_chksum( iobt%mass_berg )
root = is_root_pe()

if (root) write(outunit,*) "BEGIN CHECKSUM(ice_ocean_boundary_type):: ", id, timestep
chks = field_chksum( iobt%u_flux ) ; if (root) write(outunit,100) 'iobt%u_flux ', chks
chks = field_chksum( iobt%v_flux ) ; if (root) write(outunit,100) 'iobt%v_flux ', chks
chks = field_chksum( iobt%t_flux ) ; if (root) write(outunit,100) 'iobt%t_flux ', chks
chks = field_chksum( iobt%q_flux ) ; if (root) write(outunit,100) 'iobt%q_flux ', chks
chks = field_chksum( iobt%salt_flux ) ; if (root) write(outunit,100) 'iobt%salt_flux ', chks
chks = field_chksum( iobt%lw_flux ) ; if (root) write(outunit,100) 'iobt%lw_flux ', chks
chks = field_chksum( iobt%sw_flux_vis_dir) ; if (root) write(outunit,100) 'iobt%sw_flux_vis_dir', chks
chks = field_chksum( iobt%sw_flux_vis_dif) ; if (root) write(outunit,100) 'iobt%sw_flux_vis_dif', chks
chks = field_chksum( iobt%sw_flux_nir_dir) ; if (root) write(outunit,100) 'iobt%sw_flux_nir_dir', chks
chks = field_chksum( iobt%sw_flux_nir_dif) ; if (root) write(outunit,100) 'iobt%sw_flux_nir_dif', chks
chks = field_chksum( iobt%lprec ) ; if (root) write(outunit,100) 'iobt%lprec ', chks
chks = field_chksum( iobt%fprec ) ; if (root) write(outunit,100) 'iobt%fprec ', chks
chks = field_chksum( iobt%runoff ) ; if (root) write(outunit,100) 'iobt%runoff ', chks
chks = field_chksum( iobt%calving ) ; if (root) write(outunit,100) 'iobt%calving ', chks
chks = field_chksum( iobt%p ) ; if (root) write(outunit,100) 'iobt%p ', chks
if (associated(iobt%ustar_berg)) then
chks = field_chksum( iobt%ustar_berg ) ; if (root) write(outunit,100) 'iobt%ustar_berg ', chks
endif
if (associated(iobt%area_berg)) then
chks = field_chksum( iobt%area_berg ) ; if (root) write(outunit,100) 'iobt%area_berg ', chks
endif
if (associated(iobt%mass_berg)) then
chks = field_chksum( iobt%mass_berg ) ; if (root) write(outunit,100) 'iobt%mass_berg ', chks
endif
100 FORMAT(" CHECKSUM::",A20," = ",Z20)

call coupler_type_write_chksums(iobt%fluxes, outunit, 'iobt%')
Expand Down
27 changes: 16 additions & 11 deletions config_src/drivers/FMS_cap/ocean_model_MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module ocean_model_mod
use MOM_ice_shelf, only : add_shelf_forces, ice_shelf_end, ice_shelf_save_restart
use MOM_wave_interface, only: wave_parameters_CS, MOM_wave_interface_init
use MOM_wave_interface, only: MOM_wave_interface_init_lite, Update_Surface_Waves
use iso_fortran_env, only : int64

#include <MOM_memory.h>

Expand Down Expand Up @@ -1094,25 +1095,29 @@ subroutine ocean_model_data1D_get(OS, Ocean, name, value)

end subroutine ocean_model_data1D_get

!> Write out FMS-format checsums on fields from the ocean surface state
!> Write out checksums for fields from the ocean surface state
subroutine ocean_public_type_chksum(id, timestep, ocn)

character(len=*), intent(in) :: id !< An identifying string for this call
integer, intent(in) :: timestep !< The number of elapsed timesteps
type(ocean_public_type), intent(in) :: ocn !< A structure containing various publicly
!! visible ocean surface fields.
integer :: n, m, outunit
! Local variables
integer(kind=int64) :: chks ! A checksum for the field
logical :: root ! True only on the root PE
integer :: outunit ! The output unit to write to

outunit = stdout

write(outunit,*) "BEGIN CHECKSUM(ocean_type):: ", id, timestep
write(outunit,100) 'ocean%t_surf ', field_chksum(ocn%t_surf )
write(outunit,100) 'ocean%s_surf ', field_chksum(ocn%s_surf )
write(outunit,100) 'ocean%u_surf ', field_chksum(ocn%u_surf )
write(outunit,100) 'ocean%v_surf ', field_chksum(ocn%v_surf )
write(outunit,100) 'ocean%sea_lev ', field_chksum(ocn%sea_lev)
write(outunit,100) 'ocean%frazil ', field_chksum(ocn%frazil )
write(outunit,100) 'ocean%melt_potential ', field_chksum(ocn%melt_potential)
root = is_root_pe()

if (root) write(outunit,*) "BEGIN CHECKSUM(ocean_type):: ", id, timestep
chks = field_chksum(ocn%t_surf ) ; if (root) write(outunit,100) 'ocean%t_surf ', chks
chks = field_chksum(ocn%s_surf ) ; if (root) write(outunit,100) 'ocean%s_surf ', chks
chks = field_chksum(ocn%u_surf ) ; if (root) write(outunit,100) 'ocean%u_surf ', chks
chks = field_chksum(ocn%v_surf ) ; if (root) write(outunit,100) 'ocean%v_surf ', chks
chks = field_chksum(ocn%sea_lev) ; if (root) write(outunit,100) 'ocean%sea_lev ', chks
chks = field_chksum(ocn%frazil ) ; if (root) write(outunit,100) 'ocean%frazil ', chks
chks = field_chksum(ocn%melt_potential) ; if (root) write(outunit,100) 'ocean%melt_potential ', chks
call coupler_type_write_chksums(ocn%fields, outunit, 'ocean%')
100 FORMAT(" CHECKSUM::",A20," = ",Z20)

Expand Down
28 changes: 16 additions & 12 deletions config_src/drivers/mct_cap/mom_ocean_model_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module MOM_ocean_model_mct
use MOM, only : extract_surface_state, allocate_surface_state, finish_MOM_initialization
use MOM, only : get_MOM_state_elements, MOM_state_is_synchronized
use MOM, only : get_ocean_stocks, step_offline
use MOM_coms, only : field_chksum
use MOM_constants, only : CELSIUS_KELVIN_OFFSET, hlf
use MOM_diag_mediator, only : diag_ctrl, enable_averaging, disable_averaging
use MOM_diag_mediator, only : diag_mediator_close_registration, diag_mediator_end
Expand Down Expand Up @@ -65,6 +66,7 @@ module MOM_ocean_model_mct

! MCT specfic routines
use MOM_domains, only : MOM_infra_end
use iso_fortran_env, only : int64

#include <MOM_memory.h>

Expand Down Expand Up @@ -1042,24 +1044,26 @@ subroutine Ocean_stock_pe(OS, index, value, time_index)

end subroutine Ocean_stock_pe

!> Write out FMS-format checsums on fields from the ocean surface state
!> Write out checksums for fields from the ocean surface state
subroutine ocean_public_type_chksum(id, timestep, ocn)

character(len=*), intent(in) :: id !< An identifying string for this call
integer, intent(in) :: timestep !< The number of elapsed timesteps
type(ocean_public_type), intent(in) :: ocn !< A structure containing various publicly
!! visible ocean surface fields.
integer :: n, m

write(stdout,*) "BEGIN CHECKSUM(ocean_type):: ", id, timestep
write(stdout,100) 'ocean%t_surf ',mpp_chksum(ocn%t_surf )
write(stdout,100) 'ocean%s_surf ',mpp_chksum(ocn%s_surf )
write(stdout,100) 'ocean%u_surf ',mpp_chksum(ocn%u_surf )
write(stdout,100) 'ocean%v_surf ',mpp_chksum(ocn%v_surf )
write(stdout,100) 'ocean%sea_lev ',mpp_chksum(ocn%sea_lev)
write(stdout,100) 'ocean%frazil ',mpp_chksum(ocn%frazil )
write(stdout,100) 'ocean%melt_potential ',mpp_chksum(ocn%melt_potential)

! Local variables
integer(kind=int64) :: chks ! A checksum for the field
logical :: root ! True only on the root PE
integer :: outunit ! The output unit to write to

if (root) write(outunit,*) "BEGIN CHECKSUM(ocean_type):: ", id, timestep
chks = field_chksum(ocn%t_surf ) ; if (root) write(outunit,100) 'ocean%t_surf ', chks
chks = field_chksum(ocn%s_surf ) ; if (root) write(outunit,100) 'ocean%s_surf ', chks
chks = field_chksum(ocn%u_surf ) ; if (root) write(outunit,100) 'ocean%u_surf ', chks
chks = field_chksum(ocn%v_surf ) ; if (root) write(outunit,100) 'ocean%v_surf ', chks
chks = field_chksum(ocn%sea_lev) ; if (root) write(outunit,100) 'ocean%sea_lev ', chks
chks = field_chksum(ocn%frazil ) ; if (root) write(outunit,100) 'ocean%frazil ', chks
chks = field_chksum(ocn%melt_potential) ; if (root) write(outunit,100) 'ocean%melt_potential ', chks
call coupler_type_write_chksums(ocn%fields, stdout, 'ocean%')
100 FORMAT(" CHECKSUM::",A20," = ",Z20)

Expand Down
78 changes: 44 additions & 34 deletions config_src/drivers/mct_cap/mom_surface_forcing_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module MOM_surface_forcing_mct

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

use MOM_coms, only : reproducing_sum
use MOM_coms, only : reproducing_sum, field_chksum
use MOM_constants, only : hlv, hlf
use MOM_cpu_clock, only : cpu_clock_id, cpu_clock_begin, cpu_clock_end
use MOM_cpu_clock, only : CLOCK_SUBCOMPONENT
Expand Down Expand Up @@ -37,7 +37,8 @@ module MOM_surface_forcing_mct
use mpp_mod, only : mpp_chksum
use time_interp_external_mod, only : init_external_field, time_interp_external
use time_interp_external_mod, only : time_interp_external_init
use MOM_io, only: stdout
use MOM_io, only : stdout
use iso_fortran_env, only : int64

implicit none ; private

Expand Down Expand Up @@ -486,17 +487,18 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

! latent heat flux (W/m^2)
fluxes%latent(i,j) = 0.0
! contribution from frozen ppt
! contribution from frozen ppt (notice minus sign since fprec is positive into the ocean)
if (associated(IOB%fprec)) then
fluxes%latent(i,j) = fluxes%latent(i,j) + &
fluxes%latent(i,j) = fluxes%latent(i,j) - &
IOB%fprec(i-i0,j-j0)*US%W_m2_to_QRZ_T*CS%latent_heat_fusion
fluxes%latent_fprec_diag(i,j) = G%mask2dT(i,j) * IOB%fprec(i-i0,j-j0)*US%W_m2_to_QRZ_T*CS%latent_heat_fusion
fluxes%latent_fprec_diag(i,j) = - G%mask2dT(i,j) * IOB%fprec(i-i0,j-j0)*US%W_m2_to_QRZ_T*CS%latent_heat_fusion
endif
! contribution from frozen runoff
! contribution from frozen runoff (notice minus sign since rofi_flux is positive into the ocean)
if (associated(fluxes%frunoff)) then
fluxes%latent(i,j) = fluxes%latent(i,j) + &
fluxes%latent(i,j) = fluxes%latent(i,j) - &
IOB%rofi_flux(i-i0,j-j0)*US%W_m2_to_QRZ_T*CS%latent_heat_fusion
fluxes%latent_frunoff_diag(i,j) = G%mask2dT(i,j) * IOB%rofi_flux(i-i0,j-j0)*US%W_m2_to_QRZ_T*CS%latent_heat_fusion
fluxes%latent_frunoff_diag(i,j) = -G%mask2dT(i,j) &
* IOB%rofi_flux(i-i0,j-j0)*US%W_m2_to_QRZ_T*CS%latent_heat_fusion
endif
! contribution from evaporation
if (associated(IOB%q_flux)) then
Expand Down Expand Up @@ -1361,32 +1363,40 @@ subroutine ice_ocn_bnd_type_chksum(id, timestep, iobt)
!! ocean in a coupled model whose checksums are reported

! local variables
integer :: n,m

write(stdout,*) "BEGIN CHECKSUM(ice_ocean_boundary_type):: ", id, timestep
write(stdout,100) 'iobt%u_flux ' , mpp_chksum( iobt%u_flux )
write(stdout,100) 'iobt%v_flux ' , mpp_chksum( iobt%v_flux )
write(stdout,100) 'iobt%t_flux ' , mpp_chksum( iobt%t_flux )
write(stdout,100) 'iobt%q_flux ' , mpp_chksum( iobt%q_flux )
write(stdout,100) 'iobt%salt_flux ' , mpp_chksum( iobt%salt_flux )
write(stdout,100) 'iobt%seaice_melt_heat' , mpp_chksum( iobt%seaice_melt_heat)
write(stdout,100) 'iobt%seaice_melt ' , mpp_chksum( iobt%seaice_melt )
write(stdout,100) 'iobt%lw_flux ' , mpp_chksum( iobt%lw_flux )
write(stdout,100) 'iobt%sw_flux_vis_dir' , mpp_chksum( iobt%sw_flux_vis_dir)
write(stdout,100) 'iobt%sw_flux_vis_dif' , mpp_chksum( iobt%sw_flux_vis_dif)
write(stdout,100) 'iobt%sw_flux_nir_dir' , mpp_chksum( iobt%sw_flux_nir_dir)
write(stdout,100) 'iobt%sw_flux_nir_dif' , mpp_chksum( iobt%sw_flux_nir_dif)
write(stdout,100) 'iobt%lprec ' , mpp_chksum( iobt%lprec )
write(stdout,100) 'iobt%fprec ' , mpp_chksum( iobt%fprec )
write(stdout,100) 'iobt%runoff ' , mpp_chksum( iobt%runoff )
write(stdout,100) 'iobt%calving ' , mpp_chksum( iobt%calving )
write(stdout,100) 'iobt%p ' , mpp_chksum( iobt%p )
if (associated(iobt%ustar_berg)) &
write(stdout,100) 'iobt%ustar_berg ' , mpp_chksum( iobt%ustar_berg )
if (associated(iobt%area_berg)) &
write(stdout,100) 'iobt%area_berg ' , mpp_chksum( iobt%area_berg )
if (associated(iobt%mass_berg)) &
write(stdout,100) 'iobt%mass_berg ' , mpp_chksum( iobt%mass_berg )
integer(kind=int64) :: chks ! A checksum for the field
logical :: root ! True only on the root PE
integer :: outunit ! The output unit to write to

outunit = stdout
root = is_root_pe()

if (root) write(outunit,*) "BEGIN CHECKSUM(ice_ocean_boundary_type):: ", id, timestep
chks = field_chksum( iobt%u_flux ) ; if (root) write(outunit,100) 'iobt%u_flux ', chks
chks = field_chksum( iobt%v_flux ) ; if (root) write(outunit,100) 'iobt%v_flux ', chks
chks = field_chksum( iobt%t_flux ) ; if (root) write(outunit,100) 'iobt%t_flux ', chks
chks = field_chksum( iobt%q_flux ) ; if (root) write(outunit,100) 'iobt%q_flux ', chks
chks = field_chksum( iobt%seaice_melt_heat); if (root) write(outunit,100) 'iobt%seaice_melt_heat', chks
chks = field_chksum( iobt%seaice_melt) ; if (root) write(outunit,100) 'iobt%seaice_melt ', chks
chks = field_chksum( iobt%salt_flux ) ; if (root) write(outunit,100) 'iobt%salt_flux ', chks
chks = field_chksum( iobt%lw_flux ) ; if (root) write(outunit,100) 'iobt%lw_flux ', chks
chks = field_chksum( iobt%sw_flux_vis_dir) ; if (root) write(outunit,100) 'iobt%sw_flux_vis_dir', chks
chks = field_chksum( iobt%sw_flux_vis_dif) ; if (root) write(outunit,100) 'iobt%sw_flux_vis_dif', chks
chks = field_chksum( iobt%sw_flux_nir_dir) ; if (root) write(outunit,100) 'iobt%sw_flux_nir_dir', chks
chks = field_chksum( iobt%sw_flux_nir_dif) ; if (root) write(outunit,100) 'iobt%sw_flux_nir_dif', chks
chks = field_chksum( iobt%lprec ) ; if (root) write(outunit,100) 'iobt%lprec ', chks
chks = field_chksum( iobt%fprec ) ; if (root) write(outunit,100) 'iobt%fprec ', chks
chks = field_chksum( iobt%rofl_flux ) ; if (root) write(outunit,100) 'rofl_flux ', chks
chks = field_chksum( iobt%rofi_flux ) ; if (root) write(outunit,100) 'rofi_flux ', chks
chks = field_chksum( iobt%p ) ; if (root) write(outunit,100) 'iobt%p ', chks
if (associated(iobt%ustar_berg)) then
chks = field_chksum( iobt%ustar_berg ) ; if (root) write(outunit,100) 'iobt%ustar_berg ', chks
endif
if (associated(iobt%area_berg)) then
chks = field_chksum( iobt%area_berg ) ; if (root) write(outunit,100) 'iobt%area_berg ', chks
endif
if (associated(iobt%mass_berg)) then
chks = field_chksum( iobt%mass_berg ) ; if (root) write(outunit,100) 'iobt%mass_berg ', chks
endif
100 FORMAT(" CHECKSUM::",A20," = ",Z20)

call coupler_type_write_chksums(iobt%fluxes, stdout, 'iobt%')
Expand Down
23 changes: 22 additions & 1 deletion config_src/drivers/nuopc_cap/mom_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ module MOM_cap_mod
use ESMF, only: ESMF_AlarmCreate, ESMF_ClockGetAlarmList, ESMF_AlarmList_Flag
use ESMF, only: ESMF_AlarmGet, ESMF_AlarmIsCreated, ESMF_ALARMLIST_ALL, ESMF_AlarmIsEnabled
use ESMF, only: ESMF_STATEITEM_NOTFOUND, ESMF_FieldWrite
use ESMF, only: ESMF_END_ABORT, ESMF_Finalize
use ESMF, only: operator(==), operator(/=), operator(+), operator(-)

! TODO ESMF_GridCompGetInternalState does not have an explicit Fortran interface.
Expand Down Expand Up @@ -135,6 +136,7 @@ module MOM_cap_mod
logical :: profile_memory = .true.
logical :: grid_attach_area = .false.
logical :: use_coldstart = .true.
logical :: use_mommesh = .false.
character(len=128) :: scalar_field_name = ''
integer :: scalar_field_count = 0
integer :: scalar_field_idx_grid_nx = 0
Expand All @@ -147,7 +149,7 @@ module MOM_cap_mod
type(ESMF_GeomType_Flag) :: geomtype = ESMF_GEOMTYPE_MESH
#else
logical :: cesm_coupled = .false.
type(ESMF_GeomType_Flag) :: geomtype = ESMF_GEOMTYPE_GRID
type(ESMF_GeomType_Flag) :: geomtype
#endif
character(len=8) :: restart_mode = 'alarms'

Expand Down Expand Up @@ -347,6 +349,25 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
write(logmsg,*) use_coldstart
call ESMF_LogWrite('MOM_cap:use_coldstart = '//trim(logmsg), ESMF_LOGMSG_INFO)

use_mommesh = .false.
call NUOPC_CompAttributeGet(gcomp, name="use_mommesh", value=value, &
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) use_mommesh=(trim(value)=="true")
write(logmsg,*) use_mommesh
call ESMF_LogWrite('MOM_cap:use_mommesh = '//trim(logmsg), ESMF_LOGMSG_INFO)

if(use_mommesh)then
geomtype = ESMF_GEOMTYPE_MESH
call NUOPC_CompAttributeGet(gcomp, name='mesh_ocn', isPresent=isPresent, isSet=isSet, rc=rc)
if (.not. isPresent .and. .not. isSet) then
call ESMF_LogWrite('geomtype set to mesh but mesh_ocn is not specified', ESMF_LOGMSG_INFO)
call ESMF_Finalize(endflag=ESMF_END_ABORT)
endif
else
geomtype = ESMF_GEOMTYPE_GRID
endif

end subroutine

!> Called by NUOPC to advertise import and export fields. "Advertise"
Expand Down
Loading

0 comments on commit 6c2b944

Please sign in to comment.