From d451bc6cf40c80e32bbaa8094bf2c4eaba26cf71 Mon Sep 17 00:00:00 2001 From: Robert Hallberg Date: Sat, 3 Apr 2021 12:20:36 -0400 Subject: [PATCH 1/6] SIS_diag_mediator goes via MOM_diag_manager_infra Channel the infrastructure calls from SIS_diag_mediator to go through MOM_diag_manager_infra, thereby permitting the evolution of the underlying infrastructure without requiring changes to SIS2. A number of calls needed different arguments for this to work, but all answers are bitwise identical. --- src/SIS_diag_mediator.F90 | 118 +++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 64 deletions(-) diff --git a/src/SIS_diag_mediator.F90 b/src/SIS_diag_mediator.F90 index dc979107..d9b3665b 100644 --- a/src/SIS_diag_mediator.F90 +++ b/src/SIS_diag_mediator.F90 @@ -3,20 +3,17 @@ module SIS_diag_mediator ! This file is a part of SIS2. See LICENSE.md for the license. -use SIS_hor_grid, only : SIS_hor_grid_type -use ice_grid, only : ice_grid_type - -use MOM_coms, only : PE_here -use MOM_error_handler, only : SIS_error=>MOM_error, FATAL, is_root_pe -use MOM_file_parser, only : get_param, log_param, log_version, param_file_type -use MOM_safe_alloc, only : safe_alloc_ptr, safe_alloc_alloc -use MOM_string_functions, only : lowercase, uppercase, slasher -use MOM_time_manager, only : time_type - -use diag_manager_mod, only : diag_manager_init, send_data, diag_axis_init -use diag_manager_mod, only : register_diag_field_fms=>register_diag_field -use diag_manager_mod, only : register_static_field_fms=>register_static_field -use SIS_framework, only : EAST, NORTH +use ice_grid, only : ice_grid_type +use MOM_coms, only : PE_here +use MOM_diag_manager_infra, only : diag_manager_init=>MOM_diag_manager_init +use MOM_diag_manager_infra, only : register_diag_field_infra, register_static_field_infra +use MOM_diag_manager_infra, only : send_data_infra, diag_axis_init=>MOM_diag_axis_init, EAST, NORTH +use MOM_error_handler, only : SIS_error=>MOM_error, FATAL, is_root_pe +use MOM_file_parser, only : get_param, log_param, log_version, param_file_type +use MOM_safe_alloc, only : safe_alloc_ptr, safe_alloc_alloc +use MOM_string_functions, only : lowercase, uppercase, slasher +use MOM_time_manager, only : time_type +use SIS_hor_grid, only : SIS_hor_grid_type implicit none ; private @@ -174,30 +171,23 @@ subroutine set_SIS_axes_info(G, IG, param_file, diag_cs, set_vertical, axes_set_ endif id_xq = diag_axis_init('xB', G%gridLonB(G%isgB:G%iegB), G%x_axis_units, 'x', & - 'Boundary point nominal longitude',set_name=set_name, & - Domain2=G%Domain%mpp_domain, domain_position=EAST) + 'Boundary point nominal longitude', G%Domain, set_name=set_name, position=EAST) id_yq = diag_axis_init('yB', G%gridLatB(G%jsgB:G%jegB), G%y_axis_units, 'y', & - 'Boundary point nominal latitude', set_name=set_name, & - Domain2=G%Domain%mpp_domain, domain_position=NORTH) + 'Boundary point nominal latitude', G%Domain, set_name=set_name, position=NORTH) id_xhe = diag_axis_init('xTe', G%gridLonB(G%isg-1:G%ieg), G%x_axis_units, 'x', & - 'T-cell edge nominal longitude', set_name=set_name, & - Domain2=G%Domain%mpp_domain, domain_position=EAST) + 'T-cell edge nominal longitude', G%Domain, set_name=set_name, position=EAST) id_yhe = diag_axis_init('yTe', G%gridLatB(G%jsg-1:G%jeg), G%y_axis_units, 'y', & - 'T-cell edge nominal latitude', set_name=set_name, & - Domain2=G%Domain%mpp_domain, domain_position=NORTH) + 'T-cell edge nominal latitude', G%Domain, set_name=set_name, position=NORTH) id_xh = diag_axis_init('xT', G%gridLonT(G%isg:G%ieg), G%x_axis_units, 'x', & - 'T point nominal longitude', set_name=set_name, edges=id_xhe, & - Domain2=G%Domain%mpp_domain) + 'T point nominal longitude', G%Domain, set_name=set_name, edges=id_xhe) id_yh = diag_axis_init('yT', G%gridLatT(G%jsg:G%jeg), G%y_axis_units, 'y', & - 'T point nominal latitude', set_name=set_name, edges=id_yhe, & - Domain2=G%Domain%mpp_domain) + 'T point nominal latitude', G%Domain, set_name=set_name, edges=id_yhe) if (set_vert) then do k=1,IG%NkIce+1 ; zinter_ice(k) = real(k-1) / real(IG%NkIce) ; enddo do k=1,IG%NkIce ; zlev_ice(k) = (k-0.5) / real(IG%NkIce) ; enddo - id_zl = diag_axis_init('zl', zlev_ice, 'layer', 'z', 'Cell depth', & - set_name=set_name) + id_zl = diag_axis_init('zl', zlev_ice, 'layer', 'z', 'Cell depth', set_name=set_name) id_zi = diag_axis_init('zi', zinter_ice, 'interface', 'z', & 'Cell interface depth', set_name=set_name) else @@ -281,7 +271,7 @@ end subroutine set_SIS_diag_mediator_grid !> Offer a 2d diagnostic field for output or averaging subroutine post_data_2d(diag_field_id, field, diag_cs, is_static, mask) integer, intent(in) :: diag_field_id !< the id for an output variable returned by a - !! previous call to register_diag_field. + !! previous call to register_SIS_diag_field. real, target, intent(in) :: field(:,:) !< The 2-d array being offered for output or averaging. type(SIS_diag_ctrl), target, & intent(in) :: diag_cs !< A structure that is used to regulate diagnostic output @@ -366,35 +356,35 @@ subroutine post_data_2d(diag_field_id, field, diag_cs, is_static, mask) if (is_stat) then if (present(mask)) then - used = send_data(fms_diag_id, locfield, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, mask=mask) elseif(i_data .and. associated(diag%mask2d)) then - used = send_data(fms_diag_id, locfield, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, rmask=diag%mask2d) elseif((.not.i_data) .and. associated(diag%mask2d_comp)) then - used = send_data(fms_diag_id, locfield, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, rmask=diag%mask2d_comp) else - used = send_data(fms_diag_id, locfield, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev) endif elseif (diag_cs%ave_enabled) then if (present(mask)) then - used = send_data(fms_diag_id, locfield, diag_cs%time_end, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, & - weight=diag_cs%time_int, mask=mask) + time=diag_cs%time_end, weight=diag_cs%time_int, mask=mask) elseif(i_data .and. associated(diag%mask2d)) then - used = send_data(fms_diag_id, locfield, diag_cs%time_end, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, & - weight=diag_cs%time_int, rmask=diag%mask2d) + time=diag_cs%time_end, weight=diag_cs%time_int, rmask=diag%mask2d) elseif((.not.i_data) .and. associated(diag%mask2d_comp)) then - used = send_data(fms_diag_id, locfield, diag_cs%time_end, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, & - weight=diag_cs%time_int, rmask=diag%mask2d_comp) + time=diag_cs%time_end, weight=diag_cs%time_int, rmask=diag%mask2d_comp) else - used = send_data(fms_diag_id, locfield, diag_cs%time_end, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, & - weight=diag_cs%time_int) + time=diag_cs%time_end, weight=diag_cs%time_int) endif endif @@ -405,7 +395,7 @@ end subroutine post_data_2d !> Offer a 3d diagnostic field for output or averaging subroutine post_data_3d(diag_field_id, field, diag_cs, is_static, mask) integer, intent(in) :: diag_field_id !< the id for an output variable returned by a - !! previous call to register_diag_field. + !! previous call to register_SIS_diag_field. real, target, intent(in) :: field(:,:,:) !< The 3-d array being offered for output or averaging. type(SIS_diag_ctrl), target, & intent(in) :: diag_cs !< A structure that is used to regulate diagnostic output @@ -483,28 +473,28 @@ subroutine post_data_3d(diag_field_id, field, diag_cs, is_static, mask) if (is_stat) then if (present(mask)) then - used = send_data(fms_diag_id, locfield, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, mask=mask) elseif(associated(diag%mask3d)) then - used = send_data(fms_diag_id, locfield, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, rmask=diag%mask3d) else - used = send_data(fms_diag_id, locfield, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev) endif elseif (diag_cs%ave_enabled) then if (present(mask)) then - used = send_data(fms_diag_id, locfield, diag_cs%time_end, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, & - weight=diag_cs%time_int, mask=mask) + time=diag_cs%time_end, weight=diag_cs%time_int, mask=mask) elseif(associated(diag%mask3d)) then - used = send_data(fms_diag_id, locfield, diag_cs%time_end, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, & - weight=diag_cs%time_int, rmask=diag%mask3d) + time=diag_cs%time_end, weight=diag_cs%time_int, rmask=diag%mask3d) else - used = send_data(fms_diag_id, locfield, diag_cs%time_end, & + used = send_data_infra(fms_diag_id, locfield, & is_in=isv, js_in=jsv, ie_in=iev, je_in=jev, & - weight=diag_cs%time_int) + time=diag_cs%time_end, weight=diag_cs%time_int) endif endif @@ -585,20 +575,20 @@ function register_SIS_diag_field(module_name, field_name, axes, init_time, & ! Local variables character(len=240) :: mesg - real :: MOM_missing_value + real :: SIS_missing_value integer :: primary_id, fms_id type(SIS_diag_ctrl), pointer :: diag_cs => NULL() ! A structure that is used ! to regulate diagnostic output type(diag_type), pointer :: diag => NULL() - MOM_missing_value = axes%diag_cs%missing_value - if(present(missing_value)) MOM_missing_value = missing_value + SIS_missing_value = axes%diag_cs%missing_value + if(present(missing_value)) SIS_missing_value = missing_value diag_cs => axes%diag_cs primary_id = -1 - fms_id = register_diag_field_fms(module_name, field_name, axes%handles, & - init_time, long_name=long_name, units=units, missing_value=MOM_missing_value, & + fms_id = register_diag_field_infra(module_name, field_name, axes%handles, & + init_time, long_name=long_name, units=units, missing_value=SIS_missing_value, & range=range, mask_variant=mask_variant, standard_name=standard_name, & verbose=verbose, do_not_log=do_not_log, err_msg=err_msg, & interp_method=interp_method, tile_count=tile_count) @@ -664,7 +654,7 @@ function register_SIS_diag_field(module_name, field_name, axes, init_time, & elseif (axes%id == diag_cs%axesCvc0%id) then diag%mask3d => diag_cs%mask3dCvC(:,:,0:) ! else - ! call SIS_error(FATAL, "SIS_diag_mediator:register_diag_field: " // & + ! call SIS_error(FATAL, "SIS_diag_mediator:register_SIS_diag_field: " // & ! "unknown axes for diagnostic variable "//trim(field_name)) endif !2d masks @@ -680,11 +670,11 @@ function register_SIS_diag_field(module_name, field_name, axes, init_time, & elseif (axes%id == diag_cs%axesCv1%id) then diag%mask2d => diag_cs%mask2dCv ! else - ! call SIS_error(FATAL, "SIS_diag_mediator:register_diag_field: " // & + ! call SIS_error(FATAL, "SIS_diag_mediator:register_SIS_diag_field: " // & ! "unknown axes for diagnostic variable "//trim(field_name)) endif else - call SIS_error(FATAL, "SIS_diag_mediator:register_diag_field: " // & + call SIS_error(FATAL, "SIS_diag_mediator:register_SIS_diag_field: " // & "unknown axes for diagnostic variable "//trim(field_name)) endif endif ! if (primary_id>-1) @@ -715,18 +705,18 @@ function register_static_field(module_name, field_name, axes, & ! Local variables character(len=240) :: mesg - real :: MOM_missing_value + real :: SIS_missing_value integer :: primary_id, fms_id type(SIS_diag_ctrl), pointer :: diag_cs !< A structure that is used to regulate diagnostic output - MOM_missing_value = axes%diag_cs%missing_value - if(present(missing_value)) MOM_missing_value = missing_value + SIS_missing_value = axes%diag_cs%missing_value + if(present(missing_value)) SIS_missing_value = missing_value diag_cs => axes%diag_cs primary_id = -1 - fms_id = register_static_field_fms(module_name, field_name, axes%handles, & - long_name=long_name, units=units, missing_value=MOM_missing_value, & + fms_id = register_static_field_infra(module_name, field_name, axes%handles, & + long_name=long_name, units=units, missing_value=SIS_missing_value, & range=range, mask_variant=mask_variant, standard_name=standard_name, & do_not_log=do_not_log, & interp_method=interp_method, tile_count=tile_count) From 783f937d31ab268b168763d5be6003887502e790 Mon Sep 17 00:00:00 2001 From: Robert Hallberg Date: Sat, 3 Apr 2021 12:22:14 -0400 Subject: [PATCH 2/6] +Use same_domain from MOM_domain_infra Use same_domain from MOM_domain_infra in combined_ice_ocean_driver.F90, rather than having an infrastructure-dependent implementation in this module. All answers are bitwise identical. --- src/combined_ice_ocean_driver.F90 | 32 ++++--------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/combined_ice_ocean_driver.F90 b/src/combined_ice_ocean_driver.F90 index 507e57de..a9f04615 100644 --- a/src/combined_ice_ocean_driver.F90 +++ b/src/combined_ice_ocean_driver.F90 @@ -9,7 +9,11 @@ module combined_ice_ocean_driver ! This module provides a common interface for jointly stepping SIS2 and MOM6, and ! will evolve as a platform for tightly integrating the ocean and sea ice models. +use MOM_coupler_types, only : coupler_type_copy_data, coupler_type_data_override +use MOM_coupler_types, only : coupler_type_send_data use MOM_cpu_clock, only : cpu_clock_id, cpu_clock_begin, cpu_clock_end, CLOCK_COMPONENT +use MOM_data_override, only : data_override +use MOM_domains, only : domain2D, same_domain use MOM_error_handler, only : MOM_error, FATAL, WARNING, callTree_enter, callTree_leave use MOM_file_parser, only : param_file_type, open_param_file, close_param_file use MOM_file_parser, only : read_param, get_param, log_param, log_version @@ -17,17 +21,12 @@ module combined_ice_ocean_driver use MOM_io, only : open_namelist_file, check_nml_error use MOM_time_manager, only : time_type, time_type_to_real, real_to_time_type use MOM_time_manager, only : operator(+), operator(-), operator(>) -use SIS_framework, only : domain2D, get_layout, get_compute_domain use ice_model_mod, only : ice_data_type, ice_model_end use ice_model_mod, only : update_ice_slow_thermo, update_ice_dynamics_trans use ocean_model_mod, only : update_ocean_model, ocean_model_end use ocean_model_mod, only : ocean_public_type, ocean_state_type, ice_ocean_boundary_type -use coupler_types_mod, only : coupler_type_send_data, coupler_type_data_override -use coupler_types_mod, only : coupler_type_copy_data -use data_override_mod, only : data_override - implicit none ; private public :: update_slow_ice_and_ocean, ice_ocean_driver_init, ice_ocean_driver_end @@ -242,29 +241,6 @@ subroutine update_slow_ice_and_ocean(CS, Ice, Ocn, Ocean_sfc, IOB, & call callTree_leave("update_ice_and_ocean()") end subroutine update_slow_ice_and_ocean -!> same_domain returns true if two domains use the same list of PEs and have -!! the same size computational domains. -function same_domain(a, b) - type(domain2D), intent(in) :: a !< The first domain in the comparison - type(domain2D), intent(in) :: b !< The second domain in the comparison - integer :: isize_a, jsize_a, isize_b, jsize_b - integer :: layout_a(2), layout_b(2) - logical :: same_domain - - ! This does a limited number of checks for consistent domain sizes. - - call get_layout(a, layout_a) - call get_layout(b, layout_b) - same_domain = ((layout_a(1) == layout_b(1)) .and. (layout_a(2) == layout_b(2))) - - call get_compute_domain(a, xsize=isize_a, ysize=jsize_a) - call get_compute_domain(b, xsize=isize_b, ysize=jsize_b) - - same_domain = same_domain .and. ((layout_a(1) == layout_b(1)) .and. & - (layout_a(2) == layout_b(2))) - -end function same_domain - !> This subroutine does a direct copy of the fluxes from the ice data type into !! a ice-ocean boundary type on the same grid. subroutine direct_flux_ice_to_IOB(Time, Ice, IOB, do_thermo) From 6b2405479ddee073a81a52560dfe6fe49b1f096d Mon Sep 17 00:00:00 2001 From: Robert Hallberg Date: Sat, 3 Apr 2021 12:23:02 -0400 Subject: [PATCH 3/6] Call data_override via MOM_data_override Use MOM_data_override instead of calling the FMS module data_override_mod directly, thereby permitting the evolution of the underlying infrastructure without requiring changes to SIS2. All answers are bitwise identical. --- src/SIS_slow_thermo.F90 | 2 +- src/SIS_state_initialization.F90 | 2 +- src/ice_spec.F90 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SIS_slow_thermo.F90 b/src/SIS_slow_thermo.F90 index bd23b061..b2b2de72 100644 --- a/src/SIS_slow_thermo.F90 +++ b/src/SIS_slow_thermo.F90 @@ -21,13 +21,13 @@ module SIS_slow_thermo !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~! -use data_override_mod, only : data_override use ice_grid, only : ice_grid_type use ice_spec_mod, only : get_sea_surface use MOM_cpu_clock, only : cpu_clock_id, cpu_clock_begin, cpu_clock_end use MOM_cpu_clock, only : CLOCK_COMPONENT, CLOCK_LOOP, CLOCK_ROUTINE +use MOM_data_override, only : data_override use MOM_EOS, only : EOS_type, calculate_density_derivs use MOM_error_handler, only : SIS_error=>MOM_error, FATAL, WARNING, SIS_mesg=>MOM_mesg use MOM_error_handler, only : callTree_enter, callTree_leave, callTree_waypoint diff --git a/src/SIS_state_initialization.F90 b/src/SIS_state_initialization.F90 index 2f9cf432..b95f9ee4 100644 --- a/src/SIS_state_initialization.F90 +++ b/src/SIS_state_initialization.F90 @@ -9,10 +9,10 @@ module SIS_state_initialization ! routines have options that just read and log their input parameters. ! !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~! -use data_override_mod, only : data_override, data_override_init, data_override_unset_domains use ice_grid, only : ice_grid_type use ice_type_mod, only : ice_data_type, dealloc_ice_arrays use ice_type_mod, only : ice_type_slow_reg_restarts +use MOM_data_override, only : data_override, data_override_init, data_override_unset_domains use MOM_domains, only : MOM_domain_type use MOM_error_handler, only : SIS_error=>MOM_error, FATAL, WARNING, SIS_mesg=>MOM_mesg use MOM_error_handler, only : callTree_enter, callTree_leave, callTree_waypoint diff --git a/src/ice_spec.F90 b/src/ice_spec.F90 index 242b0158..5d33f722 100644 --- a/src/ice_spec.F90 +++ b/src/ice_spec.F90 @@ -1,10 +1,10 @@ !> sea ice and SST specified from data as per GFDL climate group module ice_spec_mod -use data_override_mod, only : data_override, data_override_init, data_override_unset_domains use fms_mod, only : write_version_number use mpp_mod, only : input_nml_file +use MOM_data_override, only : data_override, data_override_init, data_override_unset_domains use MOM_error_handler, only : stdlog, stdout use MOM_hor_index, only : hor_index_type use MOM_io, only : open_namelist_file, check_nml_error, close_file From 3e342e903f467671c7f0eecc7ca2ec4620a75d20 Mon Sep 17 00:00:00 2001 From: Robert Hallberg Date: Sat, 3 Apr 2021 12:23:49 -0400 Subject: [PATCH 4/6] Use MOM6/config_src/infra in SIS_framework.F90 Changed module use statements in SIS_framework.F90 to go via MOM_domain_infra MOM_coms_infra or MOM_coupler_types instead of directly accessing FMS infrastructure modules, thereby permitting the evolution of the underlying infrastructure without requiring changes to SIS2. In addition, both the variables EAST and EAST_FACE are now available through this module, facilitating an orderly migration to the more self-explanatory variables that are used by MOM6. --- src/SIS_framework.F90 | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/SIS_framework.F90 b/src/SIS_framework.F90 index 1428a867..67480a75 100644 --- a/src/SIS_framework.F90 +++ b/src/SIS_framework.F90 @@ -4,25 +4,24 @@ module SIS_framework ! This file is part of SIS2. See LICENSE.md for the license. -use coupler_types_mod, only : coupler_1d_bc_type, coupler_2d_bc_type, coupler_3d_bc_type -use coupler_types_mod, only : coupler_type_spawn, coupler_type_initialized, coupler_type_send_data -use coupler_types_mod, only : coupler_type_redistribute_data, coupler_type_copy_data -use coupler_types_mod, only : coupler_type_increment_data, coupler_type_rescale_data use coupler_types_mod, only : coupler_type_register_restarts -use coupler_types_mod, only : coupler_type_set_diags, coupler_type_write_chksums use fms_io_mod, only : set_domain, nullify_domain + use fms_io_mod, only : restart_file_type, FMS1_register_restart=>register_restart_field use fms_io_mod, only : save_restart_FMS1=>save_restart, FMS1_restore_state=>restore_state use fms_io_mod, only : FMS1_query_initialized=>query_initialized ! use fms2_io_mod, only : query_initialized=>is_registered_to_restart -use mpp_mod, only : SIS_chksum=>mpp_chksum -use mpp_domains_mod, only : domain2D, CENTER, CORNER, EAST, NORTH -use mpp_domains_mod, only : get_layout=>mpp_get_layout, get_compute_domain=>mpp_get_compute_domain -use mpp_domains_mod, only : redistribute_data=>mpp_redistribute -use mpp_domains_mod, only : broadcast_domain=>mpp_broadcast_domain -use MOM_domains, only : MOM_domain_type +use MOM_coms_infra, only : SIS_chksum=>field_chksum +use MOM_coupler_types, only : coupler_1d_bc_type, coupler_2d_bc_type, coupler_3d_bc_type +use MOM_coupler_types, only : coupler_type_spawn, coupler_type_initialized, coupler_type_send_data +use MOM_coupler_types, only : coupler_type_copy_data, coupler_type_redistribute_data +use MOM_coupler_types, only : coupler_type_increment_data, coupler_type_rescale_data +use MOM_coupler_types, only : coupler_type_set_diags, coupler_type_write_chksums +use MOM_domain_infra, only : MOM_domain_type, domain2D, get_domain_extent +use MOM_domain_infra, only : global_field, redistribute_data=>redistribute_array, broadcast_domain +use MOM_domain_infra, only : CENTER, CORNER, EAST=>EAST_FACE, NORTH=>NORTH_FACE, EAST_FACE, NORTH_FACE use MOM_error_handler, only : callTree_enter, callTree_leave, callTree_waypoint use MOM_error_handler, only : SIS_error=>MOM_error, FATAL, WARNING, NOTE use MOM_safe_alloc, only : safe_alloc=>safe_alloc_alloc, safe_alloc_ptr @@ -31,8 +30,8 @@ module SIS_framework implicit none ; private -public :: SIS_chksum, redistribute_data, domain2D, CENTER, CORNER, EAST, NORTH, axis_names_from_pos -public :: set_domain, nullify_domain, get_layout, get_compute_domain, broadcast_domain +public :: SIS_chksum, redistribute_data, domain2D, axis_names_from_pos +public :: set_domain, nullify_domain, get_domain_extent, broadcast_domain public :: restart_file_type, restore_SIS_state, register_restart_field, save_restart, query_inited public :: coupler_1d_bc_type, coupler_2d_bc_type, coupler_3d_bc_type public :: coupler_type_spawn, coupler_type_initialized, coupler_type_send_data @@ -40,6 +39,9 @@ module SIS_framework public :: coupler_type_increment_data, coupler_type_write_chksums, coupler_type_set_diags public :: query_initialized, SIS_restart_init, SIS_restart_end, only_read_from_restarts public :: SIS_initialize_framework, safe_alloc, safe_alloc_ptr +! These encoding constants are used to indicate the discretization position of a variable +public :: CENTER, CORNER, EAST, NORTH, EAST_FACE, NORTH_FACE + !> A restart registry and the control structure for restarts type, public :: SIS_restart_CS ; private @@ -594,9 +596,9 @@ subroutine axis_names_from_pos(dim_names, position, varname) dim_names(1:2) = (/ "ih", "jh" /) elseif (position == CORNER) then dim_names(1:2) = (/ "iq", "jq" /) - elseif (position == NORTH) then + elseif (position == NORTH_FACE) then dim_names(1:2) = (/ "iq", "jq" /) - elseif (position == EAST) then + elseif (position == EAST_FACE) then dim_names(1:2) = (/ "iq", "jq" /) elseif (present(varname)) then call SIS_error(FATAL, "set_axis_names_from_pos: Unrecognized position setting for "//trim(varname)) From 27d462a4b00e65762e2cf92b52fe0f1fabcb6ea0 Mon Sep 17 00:00:00 2001 From: Robert Hallberg Date: Sat, 3 Apr 2021 12:25:26 -0400 Subject: [PATCH 5/6] Eliminate unused module use entries Eliminated unused module use statements for some variables from SIS_framework in SIS_ctrl_types.F90 and ice_type.F90. Also replaced two calls to get_compute_domain with the more widely used get_domain_extent. All answers are bitwise identical. --- src/SIS_ctrl_types.F90 | 3 +-- src/ice_type.F90 | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/SIS_ctrl_types.F90 b/src/SIS_ctrl_types.F90 index d18da448..b2546af6 100644 --- a/src/SIS_ctrl_types.F90 +++ b/src/SIS_ctrl_types.F90 @@ -12,8 +12,7 @@ module SIS_ctrl_types use SIS_diag_mediator, only : register_SIS_diag_field, register_static_field use SIS_dyn_trans, only : dyn_trans_CS use SIS_fast_thermo, only : fast_thermo_CS -use SIS_framework, only : domain2D, CORNER, EAST, NORTH -use SIS_framework, only : coupler_2d_bc_type, coupler_3d_bc_type +use SIS_framework, only : domain2D, coupler_2d_bc_type, coupler_3d_bc_type use SIS_framework, only : coupler_type_initialized, coupler_type_set_diags use SIS_hor_grid, only : SIS_hor_grid_type use SIS_optics, only : SIS_optics_CS diff --git a/src/ice_type.F90 b/src/ice_type.F90 index 821efb57..a49d11e8 100644 --- a/src/ice_type.F90 +++ b/src/ice_type.F90 @@ -13,11 +13,9 @@ module ice_type_mod use MOM_unit_scaling, only : unit_scale_type use SIS_ctrl_types, only : SIS_fast_CS, SIS_slow_CS use SIS_debugging, only : chksum -use SIS_diag_mediator, only : SIS_diag_ctrl, post_data=>post_SIS_data -use SIS_diag_mediator, only : register_SIS_diag_field -use SIS_framework, only : domain2D, CORNER, EAST, NORTH, SIS_chksum, get_compute_domain -use SIS_framework, only : register_restart_field, SIS_restart_CS -use SIS_framework, only : save_restart, query_initialized, safe_alloc, safe_alloc_ptr +use SIS_diag_mediator, only : SIS_diag_ctrl, post_data=>post_SIS_data, register_SIS_diag_field +use SIS_framework, only : domain2D, SIS_chksum, get_domain_extent, safe_alloc, safe_alloc_ptr +use SIS_framework, only : register_restart_field, save_restart, SIS_restart_CS, query_initialized use SIS_framework, only : coupler_1d_bc_type, coupler_2d_bc_type, coupler_3d_bc_type use SIS_framework, only : coupler_type_spawn, coupler_type_write_chksums use SIS_hor_grid, only : SIS_hor_grid_type @@ -179,7 +177,7 @@ subroutine ice_type_slow_reg_restarts(domain, CatIce, param_file, Ice, & ! registers the appopriate ones for inclusion in the restart file. integer :: isc, iec, jsc, jec, km, idr - call get_compute_domain(domain, isc, iec, jsc, jec ) + call get_domain_extent(domain, isc, iec, jsc, jec ) km = CatIce + 1 ! The fields t_surf, s_surf, and part_size are only available on fast PEs. @@ -271,7 +269,7 @@ subroutine ice_type_fast_reg_restarts(domain, CatIce, param_file, Ice, & ! registers the appopriate ones for inclusion in the restart file. integer :: isc, iec, jsc, jec, km, idr - call get_compute_domain(domain, isc, iec, jsc, jec ) + call get_domain_extent(domain, isc, iec, jsc, jec ) km = CatIce + 1 call safe_alloc_ptr(Ice%t_surf, isc, iec, jsc, jec, km) From b10799c795e57d8f1c540c4e458b2c0b80dd9b53 Mon Sep 17 00:00:00 2001 From: Robert Hallberg Date: Sat, 3 Apr 2021 12:26:05 -0400 Subject: [PATCH 6/6] Use EAST_FACE instead of EAST to denote positions Replaced the variable EAST with EAST_FACE and NORTH with NORTH_FACE to indicate the positions where some variables are discretized, both coming via SIS_framework, for greater clarity and to conform with the variable names used elsewhere in the MOM6_code. --- src/SIS_types.F90 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/SIS_types.F90 b/src/SIS_types.F90 index 1e605cff..34e2453c 100644 --- a/src/SIS_types.F90 +++ b/src/SIS_types.F90 @@ -16,7 +16,7 @@ module SIS_types use SIS_diag_mediator, only : register_SIS_diag_field, register_static_field use SIS_debugging, only : chksum, Bchksum, Bchksum_pair, hchksum, uvchksum use SIS_debugging, only : check_redundant_B, check_redundant_C -use SIS_framework, only : domain2D, CORNER, EAST, NORTH, redistribute_data +use SIS_framework, only : domain2D, CORNER, EAST_FACE, NORTH_FACE, redistribute_data use SIS_framework, only : register_restart_field, SIS_restart_CS, restore_SIS_state use SIS_framework, only : query_initialized=>query_inited, only_read_from_restarts use SIS_framework, only : safe_alloc, safe_alloc_ptr @@ -517,14 +517,14 @@ subroutine ice_state_register_restarts(IST, G, IG, Ice_restart) if (IST%Cgrid_dyn) then if (G%symmetric) then call register_restart_field(Ice_restart, 'sym_u_ice_C', IST%u_ice_C, & - position=EAST, mandatory=.false.) + position=EAST_FACE, mandatory=.false.) call register_restart_field(Ice_restart, 'sym_v_ice_C', IST%v_ice_C, & - position=NORTH, mandatory=.false.) + position=NORTH_FACE, mandatory=.false.) else call register_restart_field(Ice_restart, 'u_ice_C', IST%u_ice_C, & - position=EAST, mandatory=.false.) + position=EAST_FACE, mandatory=.false.) call register_restart_field(Ice_restart, 'v_ice_C', IST%v_ice_C, & - position=NORTH, mandatory=.false.) + position=NORTH_FACE, mandatory=.false.) endif else if (G%symmetric) then @@ -604,9 +604,9 @@ subroutine ice_state_read_alt_restarts(IST, G, IG, Ice_restart, restart_dir) if (IST%Cgrid_dyn .and. (.not.u_set)) then call safe_alloc(u_tmp, G%isd, G%ied, G%jsd, G%jed) call safe_alloc(v_tmp, G%isd, G%ied, G%jsd, G%jed) - call only_read_from_restarts(Ice_restart, 'u_ice_C', u_tmp, position=EAST, & + call only_read_from_restarts(Ice_restart, 'u_ice_C', u_tmp, position=EAST_FACE, & directory=restart_dir, domain=domain_tmp, success=read_u) - call only_read_from_restarts(Ice_restart, 'v_ice_C', v_tmp, position=NORTH, & + call only_read_from_restarts(Ice_restart, 'v_ice_C', v_tmp, position=NORTH_FACE, & directory=restart_dir, domain=domain_tmp, success=read_v) if (read_u .and. read_v) then ! The non-symmetric variant of this vector has been successfully read. @@ -655,9 +655,9 @@ subroutine ice_state_read_alt_restarts(IST, G, IG, Ice_restart, restart_dir) if (IST%Cgrid_dyn .and. (.not.u_set)) then call safe_alloc(u_tmp, G%isd-1, G%ied, G%jsd, G%jed) call safe_alloc(v_tmp, G%isd, G%ied, G%jsd-1, G%jed) - call only_read_from_restarts(Ice_restart, 'sym_u_ice_C', u_tmp, position=EAST, & + call only_read_from_restarts(Ice_restart, 'sym_u_ice_C', u_tmp, position=EAST_FACE, & directory=restart_dir, domain=domain_tmp, success=read_u) - call only_read_from_restarts(Ice_restart, 'sym_v_ice_C', v_tmp, position=NORTH, & + call only_read_from_restarts(Ice_restart, 'sym_v_ice_C', v_tmp, position=NORTH_FACE, & directory=restart_dir, domain=domain_tmp, success=read_v) if (read_u .and. read_v) then ! The symmetric variant of this vector has been successfully read.