Skip to content

Commit 73304eb

Browse files
committed
Eliminated mpp calls from coupled_driver
Channel all infrastructure calls from coupled_driver via the MOM6 framework code. This includes changing the type of one of the arguments and eliminating another argument to initialize_ocean_public_type to pass a MOM_domain_type, and using clone_MOM_domain to create the domain2D element of the Ocean_sfc type. All answers are bitwise identical.
1 parent 9ad5dcb commit 73304eb

File tree

2 files changed

+33
-60
lines changed

2 files changed

+33
-60
lines changed

config_src/coupled_driver/MOM_surface_forcing_gfdl.F90

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ module MOM_surface_forcing_gfdl
77
!#CTRL# use MOM_controlled_forcing, only : ctrl_forcing_CS
88
use MOM_coms, only : reproducing_sum, field_chksum
99
use MOM_constants, only : hlv, hlf
10+
use MOM_coupler_types, only : coupler_2d_bc_type, coupler_type_write_chksums
11+
use MOM_coupler_types, only : coupler_type_initialized, coupler_type_spawn
12+
use MOM_coupler_types, only : coupler_type_copy_data
1013
use MOM_cpu_clock, only : cpu_clock_id, cpu_clock_begin, cpu_clock_end
1114
use MOM_cpu_clock, only : CLOCK_SUBCOMPONENT
1215
use MOM_diag_mediator, only : diag_ctrl, safe_alloc_ptr, time_type
@@ -23,7 +26,7 @@ module MOM_surface_forcing_gfdl
2326
use MOM_grid, only : ocean_grid_type
2427
use MOM_interpolate, only : init_external_field, time_interp_external
2528
use MOM_interpolate, only : time_interp_external_init
26-
use MOM_io, only : slasher, write_version_number, MOM_read_data
29+
use MOM_io, only : slasher, write_version_number, MOM_read_data, stdout
2730
use MOM_restart, only : register_restart_field, restart_init, MOM_restart_CS
2831
use MOM_restart, only : restart_init_end, save_restart, restore_state
2932
use MOM_string_functions, only : uppercase
@@ -33,11 +36,7 @@ module MOM_surface_forcing_gfdl
3336
use user_revise_forcing, only : user_alter_forcing, user_revise_forcing_init
3437
use user_revise_forcing, only : user_revise_forcing_CS
3538

36-
use coupler_types_mod, only : coupler_2d_bc_type, coupler_type_write_chksums
37-
use coupler_types_mod, only : coupler_type_initialized, coupler_type_spawn
38-
use coupler_types_mod, only : coupler_type_copy_data
3939
use data_override_mod, only : data_override_init, data_override
40-
use fms_mod, only : stdout
4140

4241
implicit none ; private
4342

@@ -318,8 +317,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,
318317

319318
if ((.not.coupler_type_initialized(fluxes%tr_fluxes)) .and. &
320319
coupler_type_initialized(IOB%fluxes)) &
321-
call coupler_type_spawn(IOB%fluxes, fluxes%tr_fluxes, &
322-
(/is,is,ie,ie/), (/js,js,je,je/))
320+
call coupler_type_spawn(IOB%fluxes, fluxes%tr_fluxes, (/is,is,ie,ie/), (/js,js,je,je/))
323321
! It might prove valuable to use the same array extents as the rest of the
324322
! ocean model, rather than using haloless arrays, in which case the last line
325323
! would be: ( (/isd,is,ie,ied/), (/jsd,js,je,jed/))
@@ -1628,7 +1626,7 @@ subroutine ice_ocn_bnd_type_chksum(id, timestep, iobt)
16281626
!! ocean in a coupled model whose checksums are reported
16291627
integer :: n,m, outunit
16301628

1631-
outunit = stdout()
1629+
outunit = stdout
16321630

16331631
write(outunit,*) "BEGIN CHECKSUM(ice_ocean_boundary_type):: ", id, timestep
16341632
write(outunit,100) 'iobt%u_flux ', field_chksum( iobt%u_flux )

config_src/coupled_driver/ocean_model_MOM.F90

Lines changed: 27 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ module ocean_model_mod
1717
use MOM, only : get_ocean_stocks, step_offline
1818
use MOM_coms, only : field_chksum
1919
use MOM_constants, only : CELSIUS_KELVIN_OFFSET, hlf
20+
use MOM_coupler_types, only : coupler_1d_bc_type, coupler_2d_bc_type
21+
use MOM_coupler_types, only : coupler_type_spawn, coupler_type_write_chksums
22+
use MOM_coupler_types, only : coupler_type_initialized, coupler_type_copy_data
23+
use MOM_coupler_types, only : coupler_type_set_diags, coupler_type_send_data
2024
use MOM_diag_mediator, only : diag_ctrl, enable_averaging, disable_averaging
2125
use MOM_diag_mediator, only : diag_mediator_close_registration, diag_mediator_end
22-
use MOM_domains, only : pass_var, pass_vector, AGRID, BGRID_NE, CGRID_NE
23-
use MOM_domains, only : TO_ALL, Omit_Corners
26+
use MOM_domains, only : MOM_domain_type, domain2d, clone_MOM_domain, get_domain_extent
27+
use MOM_domains, only : pass_var, pass_vector, AGRID, BGRID_NE, CGRID_NE, TO_ALL, Omit_Corners
2428
use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL, WARNING, is_root_pe
2529
use MOM_error_handler, only : callTree_enter, callTree_leave
2630
use MOM_EOS, only : gsw_sp_from_sr, gsw_pt_from_ct
@@ -31,7 +35,7 @@ module ocean_model_mod
3135
use MOM_forcing_type, only : forcing_diagnostics, mech_forcing_diags
3236
use MOM_get_input, only : Get_MOM_Input, directories
3337
use MOM_grid, only : ocean_grid_type
34-
use MOM_io, only : close_file, file_exists, read_data, write_version_number
38+
use MOM_io, only : close_file, file_exists, read_data, write_version_number, stdout
3539
use MOM_marine_ice, only : iceberg_forces, iceberg_fluxes, marine_ice_init, marine_ice_CS
3640
use MOM_restart, only : MOM_restart_CS, save_restart
3741
use MOM_string_functions, only : uppercase
@@ -52,14 +56,6 @@ module ocean_model_mod
5256
use MOM_ice_shelf, only : add_shelf_forces, ice_shelf_end, ice_shelf_save_restart
5357
use MOM_wave_interface, only: wave_parameters_CS, MOM_wave_interface_init
5458
use MOM_wave_interface, only: MOM_wave_interface_init_lite, Update_Surface_Waves
55-
use coupler_types_mod, only : coupler_1d_bc_type, coupler_2d_bc_type
56-
use coupler_types_mod, only : coupler_type_spawn, coupler_type_write_chksums
57-
use coupler_types_mod, only : coupler_type_initialized, coupler_type_copy_data
58-
use coupler_types_mod, only : coupler_type_set_diags, coupler_type_send_data
59-
use mpp_domains_mod, only : domain2d, mpp_get_layout, mpp_get_global_domain
60-
use mpp_domains_mod, only : mpp_define_domains, mpp_get_compute_domain, mpp_get_data_domain
61-
use atmos_ocean_fluxes_mod, only : aof_set_coupler_flux
62-
use fms_mod, only : stdout
6359

6460
#include <MOM_memory.h>
6561

@@ -107,7 +103,7 @@ module ocean_model_mod
107103
!! points of the two velocity components. Valid entries
108104
!! include AGRID, BGRID_NE, CGRID_NE, BGRID_SW, and CGRID_SW,
109105
!! corresponding to the community-standard Arakawa notation.
110-
!! (These are named integers taken from mpp_parameter_mod.)
106+
!! (These are named integers taken from the MOM_domains module.)
111107
!! Following MOM5, stagger is BGRID_NE by default when the
112108
!! ocean is initialized, but here it is set to -999 so that
113109
!! a global max across ocean and non-ocean processors can be
@@ -391,14 +387,8 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, wind_stagger, gas
391387
call MOM_wave_interface_init_lite(param_file)
392388
endif
393389

394-
if (associated(OS%grid%Domain%maskmap)) then
395-
call initialize_ocean_public_type(OS%grid%Domain%mpp_domain, Ocean_sfc, &
396-
OS%diag, maskmap=OS%grid%Domain%maskmap, &
397-
gas_fields_ocn=gas_fields_ocn)
398-
else
399-
call initialize_ocean_public_type(OS%grid%Domain%mpp_domain, Ocean_sfc, &
400-
OS%diag, gas_fields_ocn=gas_fields_ocn)
401-
endif
390+
call initialize_ocean_public_type(OS%grid%Domain, Ocean_sfc, OS%diag, &
391+
gas_fields_ocn=gas_fields_ocn)
402392

403393
! This call can only occur here if the coupler_bc_type variables have been
404394
! initialized already using the information from gas_fields_ocn.
@@ -513,8 +503,7 @@ subroutine update_ocean_model(Ice_ocean_boundary, OS, Ocean_sfc, time_start_upda
513503
(/is,is,ie,ie/), (/js,js,je,je/), as_needed=.true.)
514504

515505
! Translate Ice_ocean_boundary into fluxes and forces.
516-
call mpp_get_compute_domain(Ocean_sfc%Domain, index_bnds(1), index_bnds(2), &
517-
index_bnds(3), index_bnds(4))
506+
call get_domain_extent(Ocean_sfc%Domain, index_bnds(1), index_bnds(2), index_bnds(3), index_bnds(4))
518507

519508
if (do_dyn) then
520509
call convert_IOB_to_forces(Ice_ocean_boundary, OS%forces, index_bnds, OS%Time_dyn, OS%grid, OS%US, &
@@ -733,7 +722,7 @@ end subroutine ocean_model_end
733722
subroutine ocean_model_save_restart(OS, Time, directory, filename_suffix)
734723
type(ocean_state_type), pointer :: OS !< A pointer to the structure containing the
735724
!! internal ocean state (in).
736-
type(time_type), intent(in) :: Time !< The model time at this call, needed for mpp_write calls.
725+
type(time_type), intent(in) :: Time !< The model time at this call, needed for writing files.
737726
character(len=*), optional, intent(in) :: directory !< An optional directory into which to
738727
!! write these restart files.
739728
character(len=*), optional, intent(in) :: filename_suffix !< An optional suffix (e.g., a time-stamp)
@@ -765,16 +754,12 @@ subroutine ocean_model_save_restart(OS, Time, directory, filename_suffix)
765754
end subroutine ocean_model_save_restart
766755

767756
!> Initialize the public ocean type
768-
subroutine initialize_ocean_public_type(input_domain, Ocean_sfc, diag, maskmap, &
769-
gas_fields_ocn)
770-
type(domain2D), intent(in) :: input_domain !< The ocean model domain description
757+
subroutine initialize_ocean_public_type(input_domain, Ocean_sfc, diag, gas_fields_ocn)
758+
type(MOM_domain_type), intent(in) :: input_domain !< The ocean model domain description
771759
type(ocean_public_type), intent(inout) :: Ocean_sfc !< A structure containing various publicly
772-
!! visible ocean surface properties after initialization, whose
773-
!! elements are allocated here.
774-
type(diag_ctrl), intent(in) :: diag !< A structure that regulates diagnsotic output
775-
logical, dimension(:,:), &
776-
optional, intent(in) :: maskmap !< A mask indicating which virtual processors
777-
!! are actually in use. If missing, all are used.
760+
!! visible ocean surface properties after
761+
!! initialization, whose elements are allocated here.
762+
type(diag_ctrl), intent(in) :: diag !< A structure that regulates diagnostic output
778763
type(coupler_1d_bc_type), &
779764
optional, intent(in) :: gas_fields_ocn !< If present, this type describes the
780765
!! ocean and surface-ice fields that will participate
@@ -786,14 +771,9 @@ subroutine initialize_ocean_public_type(input_domain, Ocean_sfc, diag, maskmap,
786771
! and have no halos.
787772
integer :: isc, iec, jsc, jec
788773

789-
call mpp_get_layout(input_domain,layout)
790-
call mpp_get_global_domain(input_domain, xsize=xsz, ysize=ysz)
791-
if (PRESENT(maskmap)) then
792-
call mpp_define_domains((/1,xsz,1,ysz/),layout,Ocean_sfc%Domain, maskmap=maskmap)
793-
else
794-
call mpp_define_domains((/1,xsz,1,ysz/),layout,Ocean_sfc%Domain)
795-
endif
796-
call mpp_get_compute_domain(Ocean_sfc%Domain, isc, iec, jsc, jec)
774+
call clone_MOM_domain(input_domain, Ocean_sfc%Domain, halo_size=0, symmetric=.false.)
775+
776+
call get_domain_extent(Ocean_sfc%Domain, isc, iec, jsc, jec)
797777

798778
allocate ( Ocean_sfc%t_surf (isc:iec,jsc:jec), &
799779
Ocean_sfc%s_surf (isc:iec,jsc:jec), &
@@ -849,8 +829,7 @@ subroutine convert_state_to_ocean_type(sfc_state, Ocean_sfc, G, US, patm, press_
849829
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec
850830
call pass_vector(sfc_state%u, sfc_state%v, G%Domain)
851831

852-
call mpp_get_compute_domain(Ocean_sfc%Domain, isc_bnd, iec_bnd, &
853-
jsc_bnd, jec_bnd)
832+
call get_domain_extent(Ocean_sfc%Domain, isc_bnd, iec_bnd, jsc_bnd, jec_bnd)
854833
if (present(patm)) then
855834
! Check that the inidicies in patm are (isc_bnd:iec_bnd,jsc_bnd:jec_bnd).
856835
if (.not.present(press_to_z)) call MOM_error(FATAL, &
@@ -1044,20 +1023,17 @@ subroutine ocean_model_data2D_get(OS, Ocean, name, array2D, isc, jsc)
10441023
integer , intent(in) :: isc !< The starting i-index of array2D
10451024
integer , intent(in) :: jsc !< The starting j-index of array2D
10461025

1047-
integer :: g_isc, g_iec, g_jsc, g_jec,g_isd, g_ied, g_jsd, g_jed, i, j
1026+
integer :: g_isc, g_iec, g_jsc, g_jec, g_isd, g_ied, g_jsd, g_jed, i, j
10481027

10491028
if (.not.associated(OS)) return
10501029
if (.not.OS%is_ocean_pe) return
10511030

1052-
! The problem is %areaT is on MOM domain but Ice_Ocean_Boundary%... is on mpp domain.
1053-
! We want to return the MOM data on the mpp (compute) domain
1054-
! Get MOM domain extents
1055-
call mpp_get_compute_domain(OS%grid%Domain%mpp_domain, g_isc, g_iec, g_jsc, g_jec)
1056-
call mpp_get_data_domain (OS%grid%Domain%mpp_domain, g_isd, g_ied, g_jsd, g_jed)
1031+
! The problem is that %areaT is on MOM domain but Ice_Ocean_Boundary%... is on a haloless domain.
1032+
! We want to return the MOM data on the haloless (compute) domain
1033+
call get_domain_extent(OS%grid%Domain, g_isc, g_iec, g_jsc, g_jec, g_isd, g_ied, g_jsd, g_jed)
10571034

10581035
g_isc = g_isc-g_isd+1 ; g_iec = g_iec-g_isd+1 ; g_jsc = g_jsc-g_jsd+1 ; g_jec = g_jec-g_jsd+1
10591036

1060-
10611037
select case(name)
10621038
case('area')
10631039
array2D(isc:,jsc:) = OS%US%L_to_m**2*OS%grid%areaT(g_isc:g_iec,g_jsc:g_jec)
@@ -1127,7 +1103,7 @@ subroutine ocean_public_type_chksum(id, timestep, ocn)
11271103
!! visible ocean surface fields.
11281104
integer :: n, m, outunit
11291105

1130-
outunit = stdout()
1106+
outunit = stdout
11311107

11321108
write(outunit,*) "BEGIN CHECKSUM(ocean_type):: ", id, timestep
11331109
write(outunit,100) 'ocean%t_surf ', field_chksum(ocn%t_surf )
@@ -1180,8 +1156,7 @@ subroutine ocean_model_get_UV_surf(OS, Ocean, name, array2D, isc, jsc)
11801156
G => OS%grid
11811157
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec
11821158

1183-
call mpp_get_compute_domain(Ocean%Domain, isc_bnd, iec_bnd, &
1184-
jsc_bnd, jec_bnd)
1159+
call get_domain_extent(Ocean%Domain, isc_bnd, iec_bnd, jsc_bnd, jec_bnd)
11851160

11861161
i0 = is - isc_bnd ; j0 = js - jsc_bnd
11871162

0 commit comments

Comments
 (0)