Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+More MOM6 framework code restructuring #1289

Merged
merged 10 commits into from
Jan 19, 2021
49 changes: 24 additions & 25 deletions config_src/coupled_driver/MOM_surface_forcing_gfdl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module MOM_surface_forcing_gfdl
!#CTRL# use MOM_controlled_forcing, only : apply_ctrl_forcing, register_ctrl_forcing_restarts
!#CTRL# use MOM_controlled_forcing, only : controlled_forcing_init, controlled_forcing_end
!#CTRL# use MOM_controlled_forcing, only : ctrl_forcing_CS
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 All @@ -21,6 +21,8 @@ module MOM_surface_forcing_gfdl
use MOM_forcing_type, only : allocate_mech_forcing, deallocate_mech_forcing
use MOM_get_input, only : Get_MOM_Input, directories
use MOM_grid, only : ocean_grid_type
use MOM_interpolate, only : init_external_field, time_interp_extern
use MOM_interpolate, only : time_interp_external_init
use MOM_io, only : slasher, write_version_number, MOM_read_data
use MOM_restart, only : register_restart_field, restart_init, MOM_restart_CS
use MOM_restart, only : restart_init_end, save_restart, restore_state
Expand All @@ -36,9 +38,6 @@ module MOM_surface_forcing_gfdl
use coupler_types_mod, only : coupler_type_copy_data
use data_override_mod, only : data_override_init, data_override
use fms_mod, only : stdout
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

implicit none ; private

Expand Down Expand Up @@ -350,7 +349,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

! Salinity restoring logic
if (CS%restore_salt) then
call time_interp_external(CS%id_srestore,Time,data_restore)
call time_interp_extern(CS%id_srestore, Time, data_restore)
! open_ocn_mask indicates where to restore salinity (1 means restore, 0 does not)
open_ocn_mask(:,:) = 1.0
if (CS%mask_srestore_under_ice) then ! Do not restore under sea-ice
Expand Down Expand Up @@ -407,7 +406,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

! SST restoring logic
if (CS%restore_temp) then
call time_interp_external(CS%id_trestore,Time,data_restore)
call time_interp_extern(CS%id_trestore, Time, data_restore)
do j=js,je ; do i=is,ie
delta_sst = data_restore(i,j)- sfc_state%SST(i,j)
delta_sst = sign(1.0,delta_sst)*min(abs(delta_sst),CS%max_delta_trestore)
Expand Down Expand Up @@ -1486,7 +1485,7 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, wind_stagger)
enddo ; enddo
endif

call time_interp_external_init
call time_interp_external_init()

! Optionally read a x-y gustiness field in place of a global constant.
call get_param(param_file, mdl, "READ_GUST_2D", CS%read_gust_2d, &
Expand Down Expand Up @@ -1632,27 +1631,27 @@ subroutine ice_ocn_bnd_type_chksum(id, timestep, iobt)
outunit = stdout()

write(outunit,*) "BEGIN CHECKSUM(ice_ocean_boundary_type):: ", id, timestep
write(outunit,100) 'iobt%u_flux ', mpp_chksum( iobt%u_flux )
write(outunit,100) 'iobt%v_flux ', mpp_chksum( iobt%v_flux )
write(outunit,100) 'iobt%t_flux ', mpp_chksum( iobt%t_flux )
write(outunit,100) 'iobt%q_flux ', mpp_chksum( iobt%q_flux )
write(outunit,100) 'iobt%salt_flux ', mpp_chksum( iobt%salt_flux )
write(outunit,100) 'iobt%lw_flux ', mpp_chksum( iobt%lw_flux )
write(outunit,100) 'iobt%sw_flux_vis_dir', mpp_chksum( iobt%sw_flux_vis_dir)
write(outunit,100) 'iobt%sw_flux_vis_dif', mpp_chksum( iobt%sw_flux_vis_dif)
write(outunit,100) 'iobt%sw_flux_nir_dir', mpp_chksum( iobt%sw_flux_nir_dir)
write(outunit,100) 'iobt%sw_flux_nir_dif', mpp_chksum( iobt%sw_flux_nir_dif)
write(outunit,100) 'iobt%lprec ', mpp_chksum( iobt%lprec )
write(outunit,100) 'iobt%fprec ', mpp_chksum( iobt%fprec )
write(outunit,100) 'iobt%runoff ', mpp_chksum( iobt%runoff )
write(outunit,100) 'iobt%calving ', mpp_chksum( iobt%calving )
write(outunit,100) 'iobt%p ', mpp_chksum( iobt%p )
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 ', mpp_chksum( 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 ', mpp_chksum( 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 ', mpp_chksum( iobt%mass_berg )
write(outunit,100) 'iobt%mass_berg ', field_chksum( iobt%mass_berg )
100 FORMAT(" CHECKSUM::",A20," = ",Z20)

call coupler_type_write_chksums(iobt%fluxes, outunit, 'iobt%')
Expand Down
22 changes: 11 additions & 11 deletions config_src/coupled_driver/ocean_model_MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ module ocean_model_mod
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
use MOM_domains, only : pass_var, pass_vector, AGRID, BGRID_NE, CGRID_NE
use MOM_domains, only : TO_ALL, Omit_Corners
use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL, WARNING, is_root_pe
use MOM_error_handler, only : callTree_enter, callTree_leave
use MOM_EOS, only : gsw_sp_from_sr, gsw_pt_from_ct
use MOM_file_parser, only : get_param, log_version, close_param_file, param_file_type
use MOM_forcing_type, only : forcing, mech_forcing, allocate_forcing_type
use MOM_forcing_type, only : fluxes_accumulate, get_net_mass_forcing
Expand All @@ -48,6 +50,8 @@ module ocean_model_mod
use MOM_verticalGrid, only : verticalGrid_type
use MOM_ice_shelf, only : initialize_ice_shelf, shelf_calc_flux, ice_shelf_CS
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 coupler_types_mod, only : coupler_1d_bc_type, coupler_2d_bc_type
use coupler_types_mod, only : coupler_type_spawn, coupler_type_write_chksums
use coupler_types_mod, only : coupler_type_initialized, coupler_type_copy_data
Expand All @@ -56,10 +60,6 @@ module ocean_model_mod
use mpp_domains_mod, only : mpp_define_domains, mpp_get_compute_domain, mpp_get_data_domain
use atmos_ocean_fluxes_mod, only : aof_set_coupler_flux
use fms_mod, only : stdout
use mpp_mod, only : mpp_chksum
use MOM_EOS, only : gsw_sp_from_sr, gsw_pt_from_ct
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

#include <MOM_memory.h>

Expand Down Expand Up @@ -1130,13 +1130,13 @@ subroutine ocean_public_type_chksum(id, timestep, ocn)
outunit = stdout()

write(outunit,*) "BEGIN CHECKSUM(ocean_type):: ", id, timestep
write(outunit,100) 'ocean%t_surf ',mpp_chksum(ocn%t_surf )
write(outunit,100) 'ocean%s_surf ',mpp_chksum(ocn%s_surf )
write(outunit,100) 'ocean%u_surf ',mpp_chksum(ocn%u_surf )
write(outunit,100) 'ocean%v_surf ',mpp_chksum(ocn%v_surf )
write(outunit,100) 'ocean%sea_lev ',mpp_chksum(ocn%sea_lev)
write(outunit,100) 'ocean%frazil ',mpp_chksum(ocn%frazil )
write(outunit,100) 'ocean%melt_potential ',mpp_chksum(ocn%melt_potential)
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)
call coupler_type_write_chksums(ocn%fields, outunit, 'ocean%')
100 FORMAT(" CHECKSUM::",A20," = ",Z20)

Expand Down
14 changes: 7 additions & 7 deletions config_src/solo_driver/MOM_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ program MOM_main
use MOM, only : extract_surface_state, finish_MOM_initialization
use MOM, only : get_MOM_state_elements, MOM_state_is_synchronized
use MOM, only : step_offline
use MOM_coms, only : Set_PElist
use MOM_domains, only : MOM_infra_init, MOM_infra_end
use MOM_error_handler, only : MOM_error, MOM_mesg, WARNING, FATAL, is_root_pe
use MOM_error_handler, only : callTree_enter, callTree_leave, callTree_waypoint
Expand All @@ -41,6 +42,7 @@ program MOM_main
use MOM_forcing_type, only : mech_forcing_diags, MOM_forcing_chksum, MOM_mech_forcing_chksum
use MOM_get_input, only : directories
use MOM_grid, only : ocean_grid_type
use MOM_interpolate, only : time_interp_external_init
use MOM_io, only : file_exists, open_file, close_file
use MOM_io, only : check_nml_error, io_infra_init, io_infra_end
use MOM_io, only : APPEND_FILE, ASCII_FILE, READONLY_FILE, SINGLE_FILE
Expand All @@ -64,8 +66,6 @@ program MOM_main
use MOM_get_input, only : get_MOM_input
use ensemble_manager_mod, only : ensemble_manager_init, get_ensemble_size
use ensemble_manager_mod, only : ensemble_pelist_setup
use mpp_mod, only : set_current_pelist => mpp_set_current_pelist
use time_interp_external_mod, only : time_interp_external_init
use fms_affinity_mod, only : fms_affinity_init, fms_affinity_set,fms_affinity_get

use MOM_ice_shelf, only : initialize_ice_shelf, ice_shelf_end, ice_shelf_CS
Expand Down Expand Up @@ -229,7 +229,7 @@ program MOM_main
allocate(ocean_pelist(nPEs_per))
call ensemble_pelist_setup(.true., 0, nPEs_per, 0, 0, atm_pelist, ocean_pelist, &
land_pelist, ice_pelist)
call set_current_pelist(ocean_pelist)
call Set_PElist(ocean_pelist)
deallocate(ocean_pelist)
endif

Expand Down Expand Up @@ -286,17 +286,17 @@ program MOM_main


if (sum(date_init) > 0) then
Start_time = set_date(date_init(1),date_init(2), date_init(3), &
date_init(4),date_init(5),date_init(6))
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 = real_to_time(0.0)
endif

call time_interp_external_init
call time_interp_external_init()

if (sum(date) >= 0) then
! In this case, the segment starts at a time fixed by ocean_solo.res
segment_start_time = set_date(date(1),date(2),date(3),date(4),date(5),date(6))
segment_start_time = set_date(date(1), date(2), date(3), date(4), date(5), date(6))
Time = segment_start_time
else
! In this case, the segment starts at a time read from the MOM restart file
Expand Down
9 changes: 4 additions & 5 deletions src/core/MOM_open_boundary.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ module MOM_open_boundary
use MOM_tidal_forcing, only : astro_longitudes, astro_longitudes_init, eq_phase, nodal_fu, tidal_frequency
use MOM_time_manager, only : set_date, time_type, time_type_to_real, operator(-)
use MOM_tracer_registry, only : tracer_type, tracer_registry_type, tracer_name_lookup
use time_interp_external_mod, only : init_external_field, time_interp_external
use time_interp_external_mod, only : time_interp_external_init
use MOM_interpolate, only : init_external_field, time_interp_extern, time_interp_external_init
use MOM_remapping, only : remappingSchemesDoc, remappingDefaultScheme, remapping_CS
use MOM_remapping, only : initialize_remapping, remapping_core_h, end_remapping
use MOM_regridding, only : regridding_CS
Expand Down Expand Up @@ -3897,7 +3896,7 @@ subroutine update_OBC_segment_data(G, GV, US, OBC, tv, h, Time)

! TODO: Since we conditionally rotate a subset of tmp_buffer_in after
! reading the value, it is currently not possible to use the rotated
! implementation of time_interp_external.
! implementation of time_interp_extern.
! For now, we must explicitly allocate and rotate this array.
if (turns /= 0) then
if (modulo(turns, 2) /= 0) then
Expand All @@ -3909,7 +3908,7 @@ subroutine update_OBC_segment_data(G, GV, US, OBC, tv, h, Time)
tmp_buffer_in => tmp_buffer
endif

call time_interp_external(segment%field(m)%fid,Time, tmp_buffer_in)
call time_interp_extern(segment%field(m)%fid,Time, tmp_buffer_in)
! NOTE: Rotation of face-points require that we skip the final value
if (turns /= 0) then
! TODO: This is hardcoded for 90 degrees, and needs to be generalized.
Expand Down Expand Up @@ -3976,7 +3975,7 @@ subroutine update_OBC_segment_data(G, GV, US, OBC, tv, h, Time)
! no dz for tidal variables
if (segment%field(m)%nk_src > 1 .and.&
(index(segment%field(m)%name, 'phase') .le. 0 .and. index(segment%field(m)%name, 'amp') .le. 0)) then
call time_interp_external(segment%field(m)%fid_dz,Time, tmp_buffer_in)
call time_interp_extern(segment%field(m)%fid_dz,Time, tmp_buffer_in)
if (turns /= 0) then
! TODO: This is hardcoded for 90 degrees, and needs to be generalized.
if (segment%is_E_or_W &
Expand Down
4 changes: 2 additions & 2 deletions src/diagnostics/MOM_obsolete_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module MOM_obsolete_diagnostics

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

use MOM_diag_manager, only : register_static_field_fms
use MOM_diag_mediator, only : diag_ctrl
use MOM_error_handler, only : MOM_error, FATAL, WARNING, is_root_pe
use MOM_file_parser, only : param_file_type, log_version, get_param
use MOM_diag_mediator, only : diag_ctrl
use diag_manager_mod, only : register_static_field_fms=>register_static_field

implicit none ; private

Expand Down
19 changes: 4 additions & 15 deletions src/framework/MOM_coms.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@ module MOM_coms
! This file is part of MOM6. See LICENSE.md for the license.

use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL, WARNING
use fms_mod, only : fms_end, MOM_infra_init => fms_init
use memutils_mod, only : print_memuse_stats
use mpp_mod, only : PE_here => mpp_pe, root_PE => mpp_root_pe, num_PEs => mpp_npes
use mpp_mod, only : Set_PElist => mpp_set_current_pelist, Get_PElist => mpp_get_current_pelist
use mpp_mod, only : broadcast => mpp_broadcast, field_chksum => mpp_chksum
use mpp_mod, only : sum_across_PEs => mpp_sum, max_across_PEs => mpp_max, min_across_PEs => mpp_min
use MOM_coms_wrapper, only : PE_here, root_PE, num_PEs, Set_PElist, Get_PElist
use MOM_coms_wrapper, only : broadcast, field_chksum, MOM_infra_init, MOM_infra_end
use MOM_coms_wrapper, only : sum_across_PEs, max_across_PEs, min_across_PEs

implicit none ; private

public :: PE_here, root_PE, num_PEs, MOM_infra_init, MOM_infra_end
public :: broadcast, sum_across_PEs, min_across_PEs, max_across_PEs, field_chksum
public :: Set_PElist, Get_PElist
public :: reproducing_sum, reproducing_sum_EFP, EFP_sum_across_PEs, EFP_list_sum_across_PEs
public :: EFP_plus, EFP_minus, EFP_to_real, real_to_EFP, EFP_real_diff
public :: operator(+), operator(-), assignment(=)
public :: query_EFP_overflow_error, reset_EFP_overflow_error
public :: Set_PElist, Get_PElist

! This module provides interfaces to the non-domain-oriented communication subroutines.

Expand Down Expand Up @@ -880,12 +877,4 @@ subroutine EFP_val_sum_across_PEs(EFP, error)

end subroutine EFP_val_sum_across_PEs


!> This subroutine carries out all of the calls required to close out the infrastructure cleanly.
!! This should only be called in ocean-only runs, as the coupler takes care of this in coupled runs.
subroutine MOM_infra_end
call print_memuse_stats( 'Memory HiWaterMark', always=.TRUE. )
call fms_end
end subroutine MOM_infra_end

end module MOM_coms
Loading