From 33c0425c6fcfea7a6622d61902a01f5fb5784c31 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Fri, 8 Mar 2024 09:32:02 -0500 Subject: [PATCH 01/19] add public --- full/coupler_main.F90 | 2 +- ...upler_wrapper.F90 => full_coupler_mod.F90} | 240 +++++++++++------- 2 files changed, 148 insertions(+), 94 deletions(-) rename full/{coupler_wrapper.F90 => full_coupler_mod.F90} (86%) diff --git a/full/coupler_main.F90 b/full/coupler_main.F90 index 5dd93a4f..8045eec7 100644 --- a/full/coupler_main.F90 +++ b/full/coupler_main.F90 @@ -333,7 +333,7 @@ program coupler_main !--- F90 module for OpenMP use omp_lib - use coupler_wrapper_mod + use full_coupler_mod call fms_mpp_init() !these clocks are on the global pelist diff --git a/full/coupler_wrapper.F90 b/full/full_coupler_mod.F90 similarity index 86% rename from full/coupler_wrapper.F90 rename to full/full_coupler_mod.F90 index f42207f8..6e0338f8 100644 --- a/full/coupler_wrapper.F90 +++ b/full/full_coupler_mod.F90 @@ -17,7 +17,7 @@ !* License along with FMS Coupler. !* If not, see . !*********************************************************************** -module coupler_wrapper_mod +module full_coupler_mod use FMS !, status_fms=>status use FMSconstants, only: fmsconstants_init @@ -86,6 +86,38 @@ module coupler_wrapper_mod use iso_fortran_env implicit none + private + + public :: FMS, fmsconstants_init + public :: update_atmos_model_dynamics, update_atmos_model_down, update_atmos_model_up + public :: update_atmos_model_radiation, update_atmos_model_state + public :: update_land_model_fast, update_land_model_slow + public :: update_ice_model_fast, set_ice_surface_fields + public :: unpack_ocean_ice_boundary, exchange_slow_to_fast_ice + public :: ice_model_fast_cleanup, unpack_land_ice_boundary + public :: exchange_fast_to_slow_ice, update_ice_model_slow + public :: update_ocean_model, update_slow_ice_and_ocean + public :: sfc_boundary_layer, generate_sfc_xgrid, send_ice_mask_sic + public :: flux_down_from_atmos, flux_up_to_atmos + public :: flux_land_to_ice, flux_ice_to_ocean, flux_ocean_to_ice + public :: flux_ice_to_ocean_finish, flux_ocean_to_ice_finish + public :: flux_check_stocks, flux_init_stocks + public :: flux_ocean_from_ice_stocks, flux_ice_to_ocean_stocks + public :: flux_atmos_to_ocean, flux_ex_arrays_dealloc + public :: atmos_tracer_driver_gather_data + + public :: atmos_model_restart, land_model_restart, ice_model_restart, ocean_model_restart + + public :: atmos_data_type_chksum, lnd_ice_atm_bnd_type_chksum + public :: lnd_atm_bnd_type_chksum, ice_atm_bnd_type_chksum + public :: atm_lnd_bnd_type_chksum, land_data_type_chksum + public :: ice_data_type_chksum, ocn_ice_bnd_type_chksum + public :: atm_ice_bnd_type_chksum, lnd_ice_bnd_type_chksum + public :: ocean_ice_boundary_type, atmos_ice_boundary_type + public :: ocean_public_type_chksum, ice_ocn_bnd_type_chksum + + public :: coupler_init, coupler_end, coupler_restart + public :: coupler_chksum, atmos_ice_land_chksum, slow_ice_chksum !----------------------------------------------------------------------- @@ -95,38 +127,38 @@ module coupler_wrapper_mod !----------------------------------------------------------------------- !---- model defined-types ---- - type (atmos_data_type) :: Atm - type (land_data_type) :: Land - type (ice_data_type) :: Ice + type (atmos_data_type), public :: Atm + type (land_data_type), public :: Land + type (ice_data_type), public :: Ice ! allow members of ocean type to be aliased (ap) - type (ocean_public_type), target :: Ocean - type (ocean_state_type), pointer :: Ocean_state => NULL() + type (ocean_public_type), target, public :: Ocean + type (ocean_state_type), pointer, public :: Ocean_state => NULL() - type(atmos_land_boundary_type) :: Atmos_land_boundary - type(atmos_ice_boundary_type) :: Atmos_ice_boundary - type(land_ice_atmos_boundary_type) :: Land_ice_atmos_boundary - type(land_ice_boundary_type) :: Land_ice_boundary - type(ice_ocean_boundary_type) :: Ice_ocean_boundary - type(ocean_ice_boundary_type) :: Ocean_ice_boundary - type(ice_ocean_driver_type), pointer :: ice_ocean_driver_CS => NULL() + type(atmos_land_boundary_type), public :: Atmos_land_boundary + type(atmos_ice_boundary_type), public :: Atmos_ice_boundary + type(land_ice_atmos_boundary_type), public :: Land_ice_atmos_boundary + type(land_ice_boundary_type), public :: Land_ice_boundary + type(ice_ocean_boundary_type), public :: Ice_ocean_boundary + type(ocean_ice_boundary_type), public :: Ocean_ice_boundary + type(ice_ocean_driver_type), pointer, public :: ice_ocean_driver_CS => NULL() !----------------------------------------------------------------------- ! ----- coupled model time ----- - type (FmsTime_type) :: Time, Time_init, Time_end, & - Time_step_atmos, Time_step_cpld - type(FmsTime_type) :: Time_atmos, Time_ocean - type(FmsTime_type) :: Time_flux_ice_to_ocean, Time_flux_ocean_to_ice + type (FmsTime_type), public :: Time, Time_init, Time_end + type(FmsTime_type), public :: Time_step_atmos, Time_step_cpld + type(FmsTime_type), public :: Time_atmos, Time_ocean + type(FmsTime_type), public :: Time_flux_ice_to_ocean, Time_flux_ocean_to_ice - integer :: num_atmos_calls, na - integer :: num_cpld_calls, nc + integer, public :: num_atmos_calls, na + integer, public :: num_cpld_calls, nc - type(FmsNetcdfDomainFile_t), dimension(:), pointer :: Ice_bc_restart => NULL() - type(FmsNetcdfDomainFile_t), dimension(:), pointer :: Ocn_bc_restart => NULL() + type(FmsNetcdfDomainFile_t), dimension(:), pointer, public :: Ice_bc_restart => NULL() + type(FmsNetcdfDomainFile_t), dimension(:), pointer, public :: Ocn_bc_restart => NULL() - integer :: num_ice_bc_restart=0, num_ocn_bc_restart=0 - type(FmsTime_type) :: Time_restart, Time_restart_current, Time_start - character(len=32) :: timestamp + integer, public :: num_ice_bc_restart=0, num_ocn_bc_restart=0 + type(FmsTime_type), public :: Time_restart, Time_restart_current, Time_start + character(len=32), public :: timestamp ! ----- coupled model initial date ----- @@ -136,67 +168,89 @@ module coupler_wrapper_mod !----------------------------------------------------------------------- !------ namelist interface ------- - integer, dimension(6) :: restart_interval = (/ 0, 0, 0, 0, 0, 0/) !< The time interval that write out intermediate restart file. - !! The format is (yr,mo,day,hr,min,sec). When restart_interval - !! is all zero, no intermediate restart file will be written out - integer, dimension(6) :: current_date = (/ 0, 0, 0, 0, 0, 0 /) !< The date that the current integration starts with. (See - !! force_date_from_namelist.) - character(len=17) :: calendar = ' ' !< The calendar type used by the current integration. Valid values are - !! consistent with the time_manager module: 'gregorian', 'julian', 'noleap', or 'thirty_day'. - !! The value 'no_calendar' cannot be used because the time_manager's date - !! functions are used. All values must be lower case. - logical :: force_date_from_namelist = .false. !< Flag that determines whether the namelist variable current_date should override - !! the date in the restart file `INPUT/coupler.res`. If the restart file does not - !! exist then force_date_from_namelist has no effect, the value of current_date - !! will be used. + !> The time interval that write out intermediate restart file. + !! The format is (yr,mo,day,hr,min,sec). When restart_interval + !! is all zero, no intermediate restart file will be written out + integer, dimension(6), public :: restart_interval = (/ 0, 0, 0, 0, 0, 0/) + + !> The date that the current integration starts with. (See + !! force_date_from_namelist.) + integer, dimension(6) :: current_date = (/ 0, 0, 0, 0, 0, 0 /) + + !< The calendar type used by the current integration. Valid values are + !! consistent with the time_manager module: 'gregorian', 'julian', 'noleap', or 'thirty_day'. + !! The value 'no_calendar' cannot be used because the time_manager's date + !! functions are used. All values must be lower case. + character(len=17) :: calendar = ' ' + + !> Flag that determines whether the namelist variable current_date should override + !! the date in the restart file `INPUT/coupler.res`. If the restart file does not + !! exist then force_date_from_namelist has no effect, the value of current_date + !! will be used. + logical :: force_date_from_namelist = .false. + integer :: months=0 !< Number of months the current integration will be run integer :: days=0 !< Number of days the current integration will be run integer :: hours=0 !< Number of hours the current integration will be run integer :: minutes=0 !< Number of minutes the current integration will be run integer :: seconds=0 !< Number of seconds the current integration will be run - integer :: dt_atmos = 0 !< Atmospheric model time step in seconds, including the fat coupling with land and sea ice - integer :: dt_cpld = 0 !< Time step in seconds for coupling between ocean and atmospheric models. This must be an - !! integral multiple of dt_atmos and dt_ocean. This is the "slow" timestep. - integer :: atmos_npes=0 !< The number of MPI tasks to use for the atmosphere - integer :: ocean_npes=0 !< The number of MPI tasks to use for the ocean - integer :: ice_npes=0 !< The number of MPI tasks to use for the ice - integer :: land_npes=0 !< The number of MPI tasks to use for the land - integer :: atmos_nthreads=1 !< Number of OpenMP threads to use in the atmosphere - integer :: ocean_nthreads=1 !< Number of OpenMP threads to use in the ocean - integer :: radiation_nthreads=1 !< Number of threads to use for the radiation. - logical :: do_atmos =.true. !< Indicates if this component should be executed. If .FALSE., then execution is skipped. - !! This is used when ALL the output fields sent by this component to the coupler have been - !! overridden using the data_override feature. This is for advanced users only. - logical :: do_land =.true. !< See do_atmos - logical :: do_ice =.true. !< See do_atmos - logical :: do_ocean=.true. !< See do_atmos - logical :: do_flux =.true. !< See do_atmos - logical :: concurrent=.FALSE. !< If .TRUE., the ocean executes concurrently with the atmosphere-land-ice on a separate - !! set of PEs. Concurrent should be .TRUE. if concurrent_ice is .TRUE. - !! If .FALSE., the execution is serial: call atmos... followed by call ocean... - logical :: do_concurrent_radiation=.FALSE. !< If .TRUE. then radiation is done concurrently - logical :: use_lag_fluxes=.TRUE. !< If .TRUE., the ocean is forced with SBCs from one coupling timestep ago. - !! If .FALSE., the ocean is forced with most recent SBCs. For an old leapfrog - !! MOM4 coupling with dt_cpld=dt_ocean, lag fluxes can be shown to be stable - !! and current fluxes to be unconditionally unstable. For dt_cpld>dt_ocean there - !! is probably sufficient damping for MOM4. For more modern ocean models (such as - !! MOM5, GOLD or MOM6) that do not use leapfrog timestepping, use_lag_fluxes=.False. - !! should be much more stable. - logical :: concurrent_ice=.FALSE. !< If .TRUE., the slow sea-ice is forced with the fluxes that were used for the - !! fast ice processes one timestep before. When used in conjuction with setting - !! slow_ice_with_ocean=.TRUE., this approach allows the atmosphere and - !! ocean to run concurrently even if use_lag_fluxes=.FALSE., and it can - !! be shown to ameliorate or eliminate several ice-ocean coupled instabilities. - logical :: slow_ice_with_ocean=.FALSE. !< If true, the slow sea-ice is advanced on the ocean processors. Otherwise - !! the slow sea-ice processes are on the same PEs as the fast sea-ice. - logical :: combined_ice_and_ocean=.FALSE. !< If true, there is a single call from the coupler to advance - !! both the slow sea-ice and the ocean. slow_ice_with_ocean and - !! concurrent_ice must both be true if combined_ice_and_ocean is true. - logical :: do_chksum=.FALSE. !! If .TRUE., do multiple checksums throughout the execution of the model. - logical :: do_endpoint_chksum=.TRUE. !< If .TRUE., do checksums of the initial and final states. - logical :: do_debug=.FALSE. !< If .TRUE. print additional debugging messages. - integer :: check_stocks = 0 ! -1: never 0: at end of run only n>0: every n coupled steps - logical :: use_hyper_thread = .false. + integer, public :: dt_atmos = 0 !< Atmospheric model time step in seconds, including the fast + !! coupling with land and sea ice + integer, public :: dt_cpld = 0 !< Time step in seconds for coupling between ocean and atmospheric models. This must + !! be an integral multiple of dt_atmos and dt_ocean. This is the "slow" timestep. + integer, public :: atmos_npes=0 !< The number of MPI tasks to use for the atmosphere + integer, public :: ocean_npes=0 !< The number of MPI tasks to use for the ocean + integer, public :: ice_npes=0 !< The number of MPI tasks to use for the ice + integer, public :: land_npes=0 !< The number of MPI tasks to use for the land + integer, public :: atmos_nthreads=1 !< Number of OpenMP threads to use in the atmosphere + integer, public :: ocean_nthreads=1 !< Number of OpenMP threads to use in the ocean + integer, public :: radiation_nthreads=1 !< Number of threads to use for the radiation. + + !> Indicates if this component should be executed. If .FALSE., then execution is skipped. + !! This is used when ALL the output fields sent by this component to the coupler have been + !! overridden using the data_override feature. This is for advanced users only. + logical, public :: do_atmos =.true. + logical, public :: do_land =.true. !< See do_atmos + logical, public :: do_ice =.true. !< See do_atmos + logical, public :: do_ocean=.true. !< See do_atmos + logical, public :: do_flux =.true. !< See do_atmos + + !> If .TRUE., the ocean executes concurrently with the atmosphere-land-ice on a separate + !! set of PEs. Concurrent should be .TRUE. if concurrent_ice is .TRUE. + !! If .FALSE., the execution is serial: call atmos... followed by call ocean... + logical, public :: concurrent=.FALSE. + logical, public :: do_concurrent_radiation=.FALSE. !< If .TRUE. then radiation is done concurrently + + !> If .TRUE., the ocean is forced with SBCs from one coupling timestep ago. + !! If .FALSE., the ocean is forced with most recent SBCs. For an old leapfrog + !! MOM4 coupling with dt_cpld=dt_ocean, lag fluxes can be shown to be stable + !! and current fluxes to be unconditionally unstable. For dt_cpld>dt_ocean there + !! is probably sufficient damping for MOM4. For more modern ocean models (such as + !! MOM5, GOLD or MOM6) that do not use leapfrog timestepping, use_lag_fluxes=.False. + !! should be much more stable. + logical, public :: use_lag_fluxes=.TRUE. + + !> If .TRUE., the slow sea-ice is forced with the fluxes that were used for the + !! fast ice processes one timestep before. When used in conjuction with setting + !! slow_ice_with_ocean=.TRUE., this approach allows the atmosphere and + !! ocean to run concurrently even if use_lag_fluxes=.FALSE., and it can + !! be shown to ameliorate or eliminate several ice-ocean coupled instabilities. + logical, public :: concurrent_ice=.FALSE. + + !> If true, the slow sea-ice is advanced on the ocean processors. Otherwise + !! the slow sea-ice processes are on the same PEs as the fast sea-ice. + logical, public :: slow_ice_with_ocean=.FALSE. + + !< If true, there is a single call from the coupler to advance + !! both the slow sea-ice and the ocean. slow_ice_with_ocean and + !! concurrent_ice must both be true if combined_ice_and_ocean is true. + logical, public :: combined_ice_and_ocean=.FALSE. + + logical, public :: do_chksum=.FALSE. !< If .TRUE., do multiple checksums throughout the execution of the model + logical, public :: do_endpoint_chksum=.TRUE. !< If .TRUE., do checksums of the initial and final states. + logical, public :: do_debug=.FALSE.!< If .TRUE. print additional debugging messages. + integer, public :: check_stocks = 0 !< -1: never 0: at end of run only n>0: every n coupled steps + logical, public :: use_hyper_thread = .false. namelist /coupler_nml/ current_date, calendar, force_date_from_namelist, & months, days, hours, minutes, seconds, dt_cpld, dt_atmos, & @@ -208,26 +262,26 @@ module coupler_wrapper_mod use_hyper_thread, concurrent_ice, slow_ice_with_ocean, & do_endpoint_chksum, combined_ice_and_ocean - integer :: initClock, mainClock, termClock + integer, public :: initClock, mainClock, termClock - integer :: newClock0, newClock1, newClock2, newClock3, newClock4, newClock5, newClock7 - integer :: newClock6f, newClock6s, newClock6e, newClock10f, newClock10s, newClock10e - integer :: newClock8, newClock9, newClock11, newClock12, newClock13, newClock14, newClocka - integer :: newClockb, newClockc, newClockd, newClocke, newClockf, newClockg, newClockh, newClocki - integer :: newClockj, newClockk, newClockl + integer, public :: newClock0, newClock1, newClock2, newClock3, newClock4, newClock5, newClock7 + integer, public :: newClock6f, newClock6s, newClock6e, newClock10f, newClock10s, newClock10e + integer, public :: newClock8, newClock9, newClock11, newClock12, newClock13, newClock14, newClocka + integer, public :: newClockb, newClockc, newClockd, newClocke, newClockf, newClockg, newClockh, newClocki + integer, public :: newClockj, newClockk, newClockl - integer :: id_atmos_model_init, id_land_model_init, id_ice_model_init - integer :: id_ocean_model_init, id_flux_exchange_init + integer, public :: id_atmos_model_init, id_land_model_init, id_ice_model_init + integer, public :: id_ocean_model_init, id_flux_exchange_init character(len=80) :: text character(len=48), parameter :: mod_name = 'coupler_main_mod' - integer :: outunit + integer, public :: outunit integer :: ensemble_id = 1 - integer, allocatable :: ensemble_pelist(:, :) - integer, allocatable :: slow_ice_ocean_pelist(:) - integer :: conc_nthreads = 1 - real :: dsec, omp_sec(2)=0.0, imb_sec(2)=0.0 + integer, allocatable, public :: ensemble_pelist(:, :) + integer, allocatable, public :: slow_ice_ocean_pelist(:) + integer, public :: conc_nthreads = 1 + real, public :: dsec, omp_sec(2)=0.0, imb_sec(2)=0.0 contains From ac25fd8eafe6cb867ba1734ec78634ed33da0dab Mon Sep 17 00:00:00 2001 From: mlee03 Date: Fri, 8 Mar 2024 09:36:02 -0500 Subject: [PATCH 02/19] fix end module --- full/full_coupler_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 6e0338f8..31e6d910 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -1475,4 +1475,4 @@ subroutine ocean_chksum(id, timestep, Ocean, Ice_ocean_boundary) end subroutine ocean_chksum -end module coupler_wrapper_mod +end module full_coupler_mod From cb0b7cf3aa126f2daee741da9ca43f0a2b4200fd Mon Sep 17 00:00:00 2001 From: mlee03 Date: Fri, 8 Mar 2024 09:49:53 -0500 Subject: [PATCH 03/19] fix spacing --- full/full_coupler_mod.F90 | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 31e6d910..9bfa8a52 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -19,6 +19,7 @@ !*********************************************************************** module full_coupler_mod + use omp_lib !< F90 module for OpenMP use FMS !, status_fms=>status use FMSconstants, only: fmsconstants_init @@ -88,7 +89,7 @@ module full_coupler_mod implicit none private - public :: FMS, fmsconstants_init + public :: FMS, fmsconstants_init public :: update_atmos_model_dynamics, update_atmos_model_down, update_atmos_model_up public :: update_atmos_model_radiation, update_atmos_model_state public :: update_land_model_fast, update_land_model_slow @@ -121,8 +122,8 @@ module full_coupler_mod !----------------------------------------------------------------------- - character(len=128) :: version = '$Id$' - character(len=128) :: tag = '$Name$' + character(len=128), public :: version = '$Id$' + character(len=128), public :: tag = '$Name$' !----------------------------------------------------------------------- !---- model defined-types ---- @@ -134,21 +135,21 @@ module full_coupler_mod type (ocean_public_type), target, public :: Ocean type (ocean_state_type), pointer, public :: Ocean_state => NULL() - type(atmos_land_boundary_type), public :: Atmos_land_boundary - type(atmos_ice_boundary_type), public :: Atmos_ice_boundary + type(atmos_land_boundary_type), public :: Atmos_land_boundary + type(atmos_ice_boundary_type), public :: Atmos_ice_boundary type(land_ice_atmos_boundary_type), public :: Land_ice_atmos_boundary - type(land_ice_boundary_type), public :: Land_ice_boundary - type(ice_ocean_boundary_type), public :: Ice_ocean_boundary - type(ocean_ice_boundary_type), public :: Ocean_ice_boundary + type(land_ice_boundary_type), public :: Land_ice_boundary + type(ice_ocean_boundary_type), public :: Ice_ocean_boundary + type(ocean_ice_boundary_type), public :: Ocean_ice_boundary type(ice_ocean_driver_type), pointer, public :: ice_ocean_driver_CS => NULL() !----------------------------------------------------------------------- ! ----- coupled model time ----- - type (FmsTime_type), public :: Time, Time_init, Time_end - type(FmsTime_type), public :: Time_step_atmos, Time_step_cpld - type(FmsTime_type), public :: Time_atmos, Time_ocean - type(FmsTime_type), public :: Time_flux_ice_to_ocean, Time_flux_ocean_to_ice + type(FmsTime_type), public :: Time, Time_init, Time_end + type(FmsTime_type), public :: Time_step_atmos, Time_step_cpld + type(FmsTime_type), public :: Time_atmos, Time_ocean + type(FmsTime_type), public :: Time_flux_ice_to_ocean, Time_flux_ocean_to_ice integer, public :: num_atmos_calls, na integer, public :: num_cpld_calls, nc From 5a3187a739ce235cede663e43faca6c710cdb71d Mon Sep 17 00:00:00 2001 From: mlee03 Date: Fri, 8 Mar 2024 10:30:17 -0500 Subject: [PATCH 04/19] make text public --- full/full_coupler_mod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 9bfa8a52..3fbe88d5 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -274,7 +274,7 @@ module full_coupler_mod integer, public :: id_atmos_model_init, id_land_model_init, id_ice_model_init integer, public :: id_ocean_model_init, id_flux_exchange_init - character(len=80) :: text + character(len=80), public :: text character(len=48), parameter :: mod_name = 'coupler_main_mod' integer, public :: outunit From 1bb5298694af4fda6d60d33c1019331264bbf2c3 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Fri, 8 Mar 2024 10:54:55 -0500 Subject: [PATCH 05/19] add ocean_chksum to public --- full/full_coupler_mod.F90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 3fbe88d5..826ea1e3 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -20,6 +20,7 @@ module full_coupler_mod use omp_lib !< F90 module for OpenMP + use FMS !, status_fms=>status use FMSconstants, only: fmsconstants_init @@ -118,7 +119,7 @@ module full_coupler_mod public :: ocean_public_type_chksum, ice_ocn_bnd_type_chksum public :: coupler_init, coupler_end, coupler_restart - public :: coupler_chksum, atmos_ice_land_chksum, slow_ice_chksum + public :: coupler_chksum, atmos_ice_land_chksum, slow_ice_chksum, ocean_chksum !----------------------------------------------------------------------- From cdd38b140ce483eeba0334a99ba19ada5fedaf34 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Fri, 8 Mar 2024 11:12:55 -0500 Subject: [PATCH 06/19] use fms in coupler_main --- full/coupler_main.F90 | 1 + full/full_coupler_mod.F90 | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/full/coupler_main.F90 b/full/coupler_main.F90 index 8045eec7..aeeed69a 100644 --- a/full/coupler_main.F90 +++ b/full/coupler_main.F90 @@ -333,6 +333,7 @@ program coupler_main !--- F90 module for OpenMP use omp_lib + use FMS use full_coupler_mod call fms_mpp_init() diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 826ea1e3..dad8661a 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -90,7 +90,7 @@ module full_coupler_mod implicit none private - public :: FMS, fmsconstants_init + public :: fmsconstants_init public :: update_atmos_model_dynamics, update_atmos_model_down, update_atmos_model_up public :: update_atmos_model_radiation, update_atmos_model_state public :: update_land_model_fast, update_land_model_slow From 06bd2143d98482dc722fefb684af253dc57634d9 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Tue, 19 Mar 2024 18:18:07 -0400 Subject: [PATCH 07/19] implicit none --- full/coupler_main.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/full/coupler_main.F90 b/full/coupler_main.F90 index b2a0ba7e..e5bb0c60 100644 --- a/full/coupler_main.F90 +++ b/full/coupler_main.F90 @@ -335,6 +335,9 @@ program coupler_main use omp_lib use FMS use full_coupler_mod + + use iso_fortran_env + implicit none call fms_mpp_init() !these clocks are on the global pelist From ba3065f7a1fad924741d54d2b3bde8f892e598cd Mon Sep 17 00:00:00 2001 From: mlee03 Date: Tue, 26 Mar 2024 08:55:24 -0400 Subject: [PATCH 08/19] add fredb_id back --- full/coupler_main.F90 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/full/coupler_main.F90 b/full/coupler_main.F90 index e5bb0c60..51bd64f0 100644 --- a/full/coupler_main.F90 +++ b/full/coupler_main.F90 @@ -338,6 +338,40 @@ program coupler_main use iso_fortran_env implicit none + + + INTEGER :: i, status, arg_count + CHARACTER(len=256) :: executable_name, arg, fredb_id + +#ifdef FREDB_ID +#define xstr(s) str(s) +#define str(s) #s + fredb_id = xstr(FREDB_ID) +#else +#warning "FREDB_ID not defined. Continuing as normal." + fredb_id = 'FREDB_ID was not defined (e.g. -DFREDB_ID=...) during preprocessing' +#endif + + arg_count = command_argument_count() + DO i=0, arg_count + CALL get_command_argument(i, arg, status=status) + if (status .ne. 0) then + write (error_unit,*) 'get_command_argument failed: status = ', status, ' arg = ', i + stop 1 + end if + + if (i .eq. 0) then + executable_name = arg + else if (arg == '--fredb_id') then + write (output_unit,*) TRIM(fredb_id) + stop + end if + END DO + + if (arg_count .ge. 1) then + write (error_unit,*) 'Usage: '//TRIM(executable_name)//' [--fredb_id]' + stop 1 + end if call fms_mpp_init() !these clocks are on the global pelist From 04e06ab2a08527fdfc37b4a396b3b72c1887084b Mon Sep 17 00:00:00 2001 From: mlee03 Date: Tue, 26 Mar 2024 08:58:21 -0400 Subject: [PATCH 09/19] lint? --- full/coupler_main.F90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/full/coupler_main.F90 b/full/coupler_main.F90 index 51bd64f0..826e4970 100644 --- a/full/coupler_main.F90 +++ b/full/coupler_main.F90 @@ -351,7 +351,7 @@ program coupler_main #warning "FREDB_ID not defined. Continuing as normal." fredb_id = 'FREDB_ID was not defined (e.g. -DFREDB_ID=...) during preprocessing' #endif - + arg_count = command_argument_count() DO i=0, arg_count CALL get_command_argument(i, arg, status=status) @@ -359,7 +359,7 @@ program coupler_main write (error_unit,*) 'get_command_argument failed: status = ', status, ' arg = ', i stop 1 end if - + if (i .eq. 0) then executable_name = arg else if (arg == '--fredb_id') then @@ -367,12 +367,12 @@ program coupler_main stop end if END DO - + if (arg_count .ge. 1) then write (error_unit,*) 'Usage: '//TRIM(executable_name)//' [--fredb_id]' stop 1 end if - + call fms_mpp_init() !these clocks are on the global pelist initClock = fms_mpp_clock_id( 'Initialization' ) From 446673f371c21a370076ba77b1020bcb5981f638 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Fri, 19 Apr 2024 11:00:13 -0400 Subject: [PATCH 10/19] make variables program variables inwork gaea might go down --- full/coupler_main.F90 | 61 +++++++++++++++++++++++++-- full/full_coupler_mod.F90 | 88 +++++++-------------------------------- 2 files changed, 73 insertions(+), 76 deletions(-) diff --git a/full/coupler_main.F90 b/full/coupler_main.F90 index 826e4970..0b2c8af5 100644 --- a/full/coupler_main.F90 +++ b/full/coupler_main.F90 @@ -339,7 +339,58 @@ program coupler_main use iso_fortran_env implicit none - + !> model defined types + type (atmos_data_type) :: Atm + type (land_data_type) :: Land + type (ice_data_type) :: Ice + ! allow members of ocean type to be aliased (ap) + type (ocean_public_type), target :: Ocean + type (ocean_state_type), pointer :: Ocean_state => NULL() + + type(atmos_land_boundary_type) :: Atmos_land_boundary + type(atmos_ice_boundary_type) :: Atmos_ice_boundary + type(land_ice_atmos_boundary_type) :: Land_ice_atmos_boundary + type(land_ice_boundary_type) :: Land_ice_boundary + type(ice_ocean_boundary_type) :: Ice_ocean_boundary + type(ocean_ice_boundary_type) :: Ocean_ice_boundary + type(ice_ocean_driver_type), pointer :: ice_ocean_driver_CS => NULL() + + type(FmsTime_type) :: Time, Time_init, Time_end + type(FmsTime_type) :: Time_step_atmos, Time_step_cpld + type(FmsTime_type) :: Time_atmos, Time_ocean + type(FmsTime_type) :: Time_flux_ice_to_ocean, Time_flux_ocean_to_ice + + integer :: num_atmos_calls, na + integer :: num_cpld_calls, nc + + type(FmsNetcdfDomainFile_t), dimension(:), pointer :: Ice_bc_restart => NULL() + type(FmsNetcdfDomainFile_t), dimension(:), pointer :: Ocn_bc_restart => NULL() + + integer :: num_ice_bc_restart=0, num_ocn_bc_restart=0 + type(FmsTime_type) :: Time_restart, Time_restart_current, Time_start + character(len=32), public :: timestamp + + !> coupled model initial date + integer :: date_init(6) = (/ 0, 0, 0, 0, 0, 0 /) + integer :: calendar_type = INVALID_CALENDAR + + integer :: initClock, mainClock, termClock + integer :: newClock0, newClock1, newClock2, newClock3, newClock4, newClock5, newClock7 + integer :: newClock6f, newClock6s, newClock6e, newClock10f, newClock10s, newClock10e + integer :: newClock8, newClock9, newClock11, newClock12, newClock13, newClock14, newClocka + integer :: newClockb, newClockc, newClockd, newClocke, newClockf, newClockg, newClockh, newClocki + integer :: newClockj, newClockk, newClockl + integer :: id_atmos_model_init, id_land_model_init, id_ice_model_init + integer :: id_ocean_model_init, id_flux_exchange_init + + integer :: outunit + integer :: ensemble_id = 1 + integer, allocatable :: ensemble_pelist(:, :) + integer, allocatable :: slow_ice_ocean_pelist(:) + integer :: conc_nthreads = 1 + real :: dsec, omp_sec(2)=0.0, imb_sec(2)=0.0 + + !> FREDB_ID related variables INTEGER :: i, status, arg_count CHARACTER(len=256) :: executable_name, arg, fredb_id @@ -381,8 +432,12 @@ program coupler_main call fms_init call fmsconstants_init call fms_affinity_init - - call coupler_init + + call coupler_init(Atm, Ocean, Land, Ice, Ocean_ice_boundary, Ice_ocean_boundary, & + Ice_bc_restart, num_ice_bc_restart, Ocn_bc_restart, num_ocn_bc_restart, ensemble_pelist, & + slow_ice_ocean_pelist, id_atmos_model_init, id_land_model_init, id_ocean_model_init, & + id_flux_exchange_init, mainClock, termClock, Time_init, Time_start, Time_end, Time_restart, & + Time_restart_current, Time_start, Time_step_cpld, Time_step_atmos, num_cpld_calls, num_atmos_calls) if (do_chksum) call coupler_chksum('coupler_init+', 0) call fms_mpp_set_current_pelist() diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index dad8661a..6b1e434e 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -126,63 +126,21 @@ module full_coupler_mod character(len=128), public :: version = '$Id$' character(len=128), public :: tag = '$Name$' -!----------------------------------------------------------------------- -!---- model defined-types ---- - - type (atmos_data_type), public :: Atm - type (land_data_type), public :: Land - type (ice_data_type), public :: Ice - ! allow members of ocean type to be aliased (ap) - type (ocean_public_type), target, public :: Ocean - type (ocean_state_type), pointer, public :: Ocean_state => NULL() - - type(atmos_land_boundary_type), public :: Atmos_land_boundary - type(atmos_ice_boundary_type), public :: Atmos_ice_boundary - type(land_ice_atmos_boundary_type), public :: Land_ice_atmos_boundary - type(land_ice_boundary_type), public :: Land_ice_boundary - type(ice_ocean_boundary_type), public :: Ice_ocean_boundary - type(ocean_ice_boundary_type), public :: Ocean_ice_boundary - type(ice_ocean_driver_type), pointer, public :: ice_ocean_driver_CS => NULL() - -!----------------------------------------------------------------------- -! ----- coupled model time ----- - - type(FmsTime_type), public :: Time, Time_init, Time_end - type(FmsTime_type), public :: Time_step_atmos, Time_step_cpld - type(FmsTime_type), public :: Time_atmos, Time_ocean - type(FmsTime_type), public :: Time_flux_ice_to_ocean, Time_flux_ocean_to_ice - - integer, public :: num_atmos_calls, na - integer, public :: num_cpld_calls, nc - - type(FmsNetcdfDomainFile_t), dimension(:), pointer, public :: Ice_bc_restart => NULL() - type(FmsNetcdfDomainFile_t), dimension(:), pointer, public :: Ocn_bc_restart => NULL() - - integer, public :: num_ice_bc_restart=0, num_ocn_bc_restart=0 - type(FmsTime_type), public :: Time_restart, Time_restart_current, Time_start - character(len=32), public :: timestamp - -! ----- coupled model initial date ----- - - integer :: date_init(6) = (/ 0, 0, 0, 0, 0, 0 /) - integer :: calendar_type = INVALID_CALENDAR - -!----------------------------------------------------------------------- -!------ namelist interface ------- +!> namelist interface !> The time interval that write out intermediate restart file. !! The format is (yr,mo,day,hr,min,sec). When restart_interval !! is all zero, no intermediate restart file will be written out integer, dimension(6), public :: restart_interval = (/ 0, 0, 0, 0, 0, 0/) - + !> The date that the current integration starts with. (See !! force_date_from_namelist.) - integer, dimension(6) :: current_date = (/ 0, 0, 0, 0, 0, 0 /) - + integer, dimension(6) :: current_date = (/ 0, 0, 0, 0, 0, 0 /) !< The calendar type used by the current integration. Valid values are !! consistent with the time_manager module: 'gregorian', 'julian', 'noleap', or 'thirty_day'. !! The value 'no_calendar' cannot be used because the time_manager's date !! functions are used. All values must be lower case. + character(len=17) :: calendar = ' ' !> Flag that determines whether the namelist variable current_date should override @@ -191,11 +149,11 @@ module full_coupler_mod !! will be used. logical :: force_date_from_namelist = .false. - integer :: months=0 !< Number of months the current integration will be run - integer :: days=0 !< Number of days the current integration will be run - integer :: hours=0 !< Number of hours the current integration will be run - integer :: minutes=0 !< Number of minutes the current integration will be run - integer :: seconds=0 !< Number of seconds the current integration will be run + integer, public :: months=0 !< Number of months the current integration will be run + integer, public :: days=0 !< Number of days the current integration will be run + integer, public :: hours=0 !< Number of hours the current integration will be run + integer, public :: minutes=0 !< Number of minutes the current integration will be run + integer, public :: seconds=0 !< Number of seconds the current integration will be run integer, public :: dt_atmos = 0 !< Atmospheric model time step in seconds, including the fast !! coupling with land and sea ice integer, public :: dt_cpld = 0 !< Time step in seconds for coupling between ocean and atmospheric models. This must @@ -264,33 +222,17 @@ module full_coupler_mod use_hyper_thread, concurrent_ice, slow_ice_with_ocean, & do_endpoint_chksum, combined_ice_and_ocean - integer, public :: initClock, mainClock, termClock - - integer, public :: newClock0, newClock1, newClock2, newClock3, newClock4, newClock5, newClock7 - integer, public :: newClock6f, newClock6s, newClock6e, newClock10f, newClock10s, newClock10e - integer, public :: newClock8, newClock9, newClock11, newClock12, newClock13, newClock14, newClocka - integer, public :: newClockb, newClockc, newClockd, newClocke, newClockf, newClockg, newClockh, newClocki - integer, public :: newClockj, newClockk, newClockl - - integer, public :: id_atmos_model_init, id_land_model_init, id_ice_model_init - integer, public :: id_ocean_model_init, id_flux_exchange_init - - character(len=80), public :: text - character(len=48), parameter :: mod_name = 'coupler_main_mod' - - integer, public :: outunit - integer :: ensemble_id = 1 - integer, allocatable, public :: ensemble_pelist(:, :) - integer, allocatable, public :: slow_ice_ocean_pelist(:) - integer, public :: conc_nthreads = 1 - real, public :: dsec, omp_sec(2)=0.0, imb_sec(2)=0.0 - contains !####################################################################### !> \brief Initialize all defined exchange grids and all boundary maps - subroutine coupler_init + subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_ice_boundary, Ice_ocean_boundary, + Ice_bc_restart, num_ice_bc_restart, Ocn_bc_restart, num_ocn_bc_restart, ensemble_pelist, + slow_ice_ocean_pelist, id_atmos_model_init, id_land_model_init, id_ocean_model_init, + id_flux_exchange_init, mainClock, termClock, Time_init, Time_start, Time_end, Time_restart, + Time_restart_current, Time_start, Time_step_cpld, Time_step_atmos, num_cpld_calls, num_atmos_calls, + use ensemble_manager_mod, only : ensemble_manager_init, get_ensemble_id,ensemble_pelist_setup use ensemble_manager_mod, only : get_ensemble_size, get_ensemble_pelist From e891d1890aae8753e8f322f2a848e18571edaad2 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Tue, 23 Apr 2024 09:23:06 -0400 Subject: [PATCH 11/19] make program variables --- full/coupler_main.F90 | 52 ++++++------ full/full_coupler_mod.F90 | 163 +++++++++++++++++++++++++++++--------- 2 files changed, 152 insertions(+), 63 deletions(-) diff --git a/full/coupler_main.F90 b/full/coupler_main.F90 index 0b2c8af5..330f639e 100644 --- a/full/coupler_main.F90 +++ b/full/coupler_main.F90 @@ -71,7 +71,7 @@ !! The three components of coupler: @ref coupler_main , flux_exchange_mod, and surface_flux_mod !! are configured through three namelists !! * \ref coupler_config "coupler_nml" -!! * \ref flux_exchange_conf "flux_exchange_nml" +!! * \ref flux_exchange_conf "flux_exchange_nml" !! * \ref surface_flux_config "surface_flux_nml" !! !! @@ -355,7 +355,7 @@ program coupler_main type(ocean_ice_boundary_type) :: Ocean_ice_boundary type(ice_ocean_driver_type), pointer :: ice_ocean_driver_CS => NULL() - type(FmsTime_type) :: Time, Time_init, Time_end + type(FmsTime_type) :: Time type(FmsTime_type) :: Time_step_atmos, Time_step_cpld type(FmsTime_type) :: Time_atmos, Time_ocean type(FmsTime_type) :: Time_flux_ice_to_ocean, Time_flux_ocean_to_ice @@ -366,15 +366,11 @@ program coupler_main type(FmsNetcdfDomainFile_t), dimension(:), pointer :: Ice_bc_restart => NULL() type(FmsNetcdfDomainFile_t), dimension(:), pointer :: Ocn_bc_restart => NULL() - integer :: num_ice_bc_restart=0, num_ocn_bc_restart=0 - type(FmsTime_type) :: Time_restart, Time_restart_current, Time_start - character(len=32), public :: timestamp + type(FmsTime_type) :: Time_restart, Time_start, Time_end + type(FmsTime_type) :: Time_restart_current + character(len=32) :: timestamp - !> coupled model initial date - integer :: date_init(6) = (/ 0, 0, 0, 0, 0, 0 /) - integer :: calendar_type = INVALID_CALENDAR - - integer :: initClock, mainClock, termClock + integer :: initClock, mainClock, termClock integer :: newClock0, newClock1, newClock2, newClock3, newClock4, newClock5, newClock7 integer :: newClock6f, newClock6s, newClock6e, newClock10f, newClock10s, newClock10e integer :: newClock8, newClock9, newClock11, newClock12, newClock13, newClock14, newClocka @@ -384,7 +380,7 @@ program coupler_main integer :: id_ocean_model_init, id_flux_exchange_init integer :: outunit - integer :: ensemble_id = 1 + character(len=80) :: text integer, allocatable :: ensemble_pelist(:, :) integer, allocatable :: slow_ice_ocean_pelist(:) integer :: conc_nthreads = 1 @@ -432,13 +428,17 @@ program coupler_main call fms_init call fmsconstants_init call fms_affinity_init - - call coupler_init(Atm, Ocean, Land, Ice, Ocean_ice_boundary, Ice_ocean_boundary, & - Ice_bc_restart, num_ice_bc_restart, Ocn_bc_restart, num_ocn_bc_restart, ensemble_pelist, & - slow_ice_ocean_pelist, id_atmos_model_init, id_land_model_init, id_ocean_model_init, & - id_flux_exchange_init, mainClock, termClock, Time_init, Time_start, Time_end, Time_restart, & - Time_restart_current, Time_start, Time_step_cpld, Time_step_atmos, num_cpld_calls, num_atmos_calls) - if (do_chksum) call coupler_chksum('coupler_init+', 0) + + + call coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, Atmos_ice_boundary, & + Ocean_ice_boundary, Ice_ocean_boundary, Land_ice_atmos_boundary, Land_ice_boundary, & + Ice_ocean_driver_CS, Ice_bc_restart, Ocn_bc_restart, & + ensemble_pelist, slow_ice_ocean_pelist, id_atmos_model_init, id_land_model_init, & + id_ice_model_init, id_ocean_model_init, id_flux_exchange_init, mainClock, termClock, & + Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean, num_cpld_calls, num_atmos_calls, & + Time_start, Time_end, Time_restart) + + if (do_chksum) call coupler_chksum('coupler_init+', 0, Atm, Land, Ice) call fms_mpp_set_current_pelist() @@ -511,7 +511,7 @@ program coupler_main newClock14 = fms_mpp_clock_id( 'final flux_check_stocks' ) do nc = 1, num_cpld_calls - if (do_chksum) call coupler_chksum('top_of_coupled_loop+', nc) + if (do_chksum) call coupler_chksum('top_of_coupled_loop+', nc, Atm, Land, Ice) call fms_mpp_set_current_pelist() if (do_chksum) then @@ -552,7 +552,7 @@ program coupler_main endif if (do_chksum) then - call coupler_chksum('flux_ocn2ice+', nc) + call coupler_chksum('flux_ocn2ice+', nc, Atm, Land, Ice) if (Atm%pe) then call fms_mpp_set_current_pelist(Atm%pelist) call atmos_ice_land_chksum('fluxocn2ice+', nc, Atm, Land, Ice, & @@ -944,11 +944,12 @@ program coupler_main if (Ocean%is_ocean_pe) then call ocean_model_restart(Ocean_state, timestamp) endif - call coupler_restart(Time, Time_restart_current, timestamp) + call coupler_restart(Atm, Ice, Ocean, Ocn_bc_restart, Ice_bc_restart, & + Time, Time_restart_current, Time_start, Time_end, timestamp) endif !-------------- - if (do_chksum) call coupler_chksum('MAIN_LOOP+', nc) + if (do_chksum) call coupler_chksum('MAIN_LOOP+', nc, Atm, Land, Ice) write( text,'(a,i6)' )'Main loop at coupling timestep=', nc call fms_memutils_print_memuse_stats(text) outunit= fms_mpp_stdout() @@ -976,8 +977,11 @@ program coupler_main call fms_mpp_clock_end(mainClock) call fms_mpp_clock_begin(termClock) - if (do_chksum) call coupler_chksum('coupler_end-', nc) - call coupler_end + if (do_chksum) call coupler_chksum('coupler_end-', nc, Atm, Land, Ice) + call coupler_end(Atm, Land, Ice, Ocean, Ocean_state, Land_ice_atmos_boundary, Atmos_ice_boundary,& + Atmos_land_boundary, Ice_ocean_boundary, Ocean_ice_boundary, Ocn_bc_restart, Ice_bc_restart, & + Time, Time_start, Time_end, Time_restart_current) + call fms_mpp_clock_end(termClock) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 6b1e434e..43fab27f 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -12,7 +12,7 @@ !* WITHOUT ANY WARRANTY; without even the implied warranty of !* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU !* General Public License for more details. -!* + !* !* You should have received a copy of the GNU Lesser General Public !* License along with FMS Coupler. !* If not, see . @@ -90,6 +90,11 @@ module full_coupler_mod implicit none private + public :: atmos_data_type, land_data_type, ice_data_type + public :: ocean_public_type, ocean_state_type + public :: atmos_land_boundary_type, atmos_ice_boundary_type, land_ice_atmos_boundary_type + public :: land_ice_boundary_type, ice_ocean_boundary_type, ocean_ice_boundary_type, ice_ocean_driver_type + public :: fmsconstants_init public :: update_atmos_model_dynamics, update_atmos_model_down, update_atmos_model_up public :: update_atmos_model_radiation, update_atmos_model_state @@ -126,28 +131,28 @@ module full_coupler_mod character(len=128), public :: version = '$Id$' character(len=128), public :: tag = '$Name$' -!> namelist interface + !> namelist interface !> The time interval that write out intermediate restart file. !! The format is (yr,mo,day,hr,min,sec). When restart_interval !! is all zero, no intermediate restart file will be written out integer, dimension(6), public :: restart_interval = (/ 0, 0, 0, 0, 0, 0/) - + !> The date that the current integration starts with. (See !! force_date_from_namelist.) integer, dimension(6) :: current_date = (/ 0, 0, 0, 0, 0, 0 /) !< The calendar type used by the current integration. Valid values are !! consistent with the time_manager module: 'gregorian', 'julian', 'noleap', or 'thirty_day'. !! The value 'no_calendar' cannot be used because the time_manager's date - !! functions are used. All values must be lower case. + !! functions are used. All values must be lower case. - character(len=17) :: calendar = ' ' + character(len=17) :: calendar = ' ' !> Flag that determines whether the namelist variable current_date should override !! the date in the restart file `INPUT/coupler.res`. If the restart file does not !! exist then force_date_from_namelist has no effect, the value of current_date !! will be used. - logical :: force_date_from_namelist = .false. + logical :: force_date_from_namelist = .false. integer, public :: months=0 !< Number of months the current integration will be run integer, public :: days=0 !< Number of days the current integration will be run @@ -169,7 +174,7 @@ module full_coupler_mod !> Indicates if this component should be executed. If .FALSE., then execution is skipped. !! This is used when ALL the output fields sent by this component to the coupler have been !! overridden using the data_override feature. This is for advanced users only. - logical, public :: do_atmos =.true. + logical, public :: do_atmos =.true. logical, public :: do_land =.true. !< See do_atmos logical, public :: do_ice =.true. !< See do_atmos logical, public :: do_ocean=.true. !< See do_atmos @@ -178,7 +183,7 @@ module full_coupler_mod !> If .TRUE., the ocean executes concurrently with the atmosphere-land-ice on a separate !! set of PEs. Concurrent should be .TRUE. if concurrent_ice is .TRUE. !! If .FALSE., the execution is serial: call atmos... followed by call ocean... - logical, public :: concurrent=.FALSE. + logical, public :: concurrent=.FALSE. logical, public :: do_concurrent_radiation=.FALSE. !< If .TRUE. then radiation is done concurrently !> If .TRUE., the ocean is forced with SBCs from one coupling timestep ago. @@ -188,23 +193,23 @@ module full_coupler_mod !! is probably sufficient damping for MOM4. For more modern ocean models (such as !! MOM5, GOLD or MOM6) that do not use leapfrog timestepping, use_lag_fluxes=.False. !! should be much more stable. - logical, public :: use_lag_fluxes=.TRUE. + logical, public :: use_lag_fluxes=.TRUE. !> If .TRUE., the slow sea-ice is forced with the fluxes that were used for the !! fast ice processes one timestep before. When used in conjuction with setting !! slow_ice_with_ocean=.TRUE., this approach allows the atmosphere and !! ocean to run concurrently even if use_lag_fluxes=.FALSE., and it can !! be shown to ameliorate or eliminate several ice-ocean coupled instabilities. - logical, public :: concurrent_ice=.FALSE. + logical, public :: concurrent_ice=.FALSE. !> If true, the slow sea-ice is advanced on the ocean processors. Otherwise !! the slow sea-ice processes are on the same PEs as the fast sea-ice. logical, public :: slow_ice_with_ocean=.FALSE. - + !< If true, there is a single call from the coupler to advance !! both the slow sea-ice and the ocean. slow_ice_with_ocean and !! concurrent_ice must both be true if combined_ice_and_ocean is true. - logical, public :: combined_ice_and_ocean=.FALSE. + logical, public :: combined_ice_and_ocean=.FALSE. logical, public :: do_chksum=.FALSE. !< If .TRUE., do multiple checksums throughout the execution of the model logical, public :: do_endpoint_chksum=.TRUE. !< If .TRUE., do checksums of the initial and final states. @@ -222,22 +227,52 @@ module full_coupler_mod use_hyper_thread, concurrent_ice, slow_ice_with_ocean, & do_endpoint_chksum, combined_ice_and_ocean -contains -!####################################################################### + character(len=80) :: text + character(len=48), parameter :: mod_name = 'coupler_main_mod' -!> \brief Initialize all defined exchange grids and all boundary maps - subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_ice_boundary, Ice_ocean_boundary, - Ice_bc_restart, num_ice_bc_restart, Ocn_bc_restart, num_ocn_bc_restart, ensemble_pelist, - slow_ice_ocean_pelist, id_atmos_model_init, id_land_model_init, id_ocean_model_init, - id_flux_exchange_init, mainClock, termClock, Time_init, Time_start, Time_end, Time_restart, - Time_restart_current, Time_start, Time_step_cpld, Time_step_atmos, num_cpld_calls, num_atmos_calls, - + integer :: calendar_type = INVALID_CALENDAR - use ensemble_manager_mod, only : ensemble_manager_init, get_ensemble_id,ensemble_pelist_setup - use ensemble_manager_mod, only : get_ensemble_size, get_ensemble_pelist + !> coupled model initial date + integer :: date_init(6) = (/ 0, 0, 0, 0, 0, 0 /) +contains + +!####################################################################### +!> \brief Initialize all defined exchange grids and all boundary maps + subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, Atmos_ice_boundary, & + Ocean_ice_boundary, Ice_ocean_boundary, Land_ice_atmos_boundary, Land_ice_boundary, & + Ice_ocean_driver_CS, Ice_bc_restart, Ocn_bc_restart, ensemble_pelist, slow_ice_ocean_pelist, & + id_atmos_model_init, id_land_model_init, id_ice_model_init, id_ocean_model_init, & + id_flux_exchange_init, mainClock, termClock, Time_step_cpld, Time_step_atmos, & + Time_atmos, Time_ocean, num_cpld_calls, num_atmos_calls, Time_start, Time_end, Time_restart) + + implicit none + + type(atmos_data_type), intent(inout) :: Atm + type(land_data_type), intent(inout) :: Land + type(ice_data_type), intent(inout) :: Ice + type(ocean_public_type), intent(inout) :: Ocean + type(ocean_state_type), pointer, intent(inout) :: Ocean_state + type(atmos_land_boundary_type), intent(inout) :: Atmos_land_boundary + type(atmos_ice_boundary_type), intent(inout) :: Atmos_ice_boundary + type(ice_ocean_boundary_type), intent(inout) :: Ice_ocean_boundary + type(ocean_ice_boundary_type), intent(inout) :: Ocean_ice_boundary + type(land_ice_boundary_type), intent(inout) :: Land_ice_boundary + type(ice_ocean_driver_type), pointer, intent(inout) :: Ice_ocean_driver_CS + type(land_ice_atmos_boundary_type), intent(inout) :: Land_ice_atmos_boundary + type(FmsNetcdfDomainFile_t), pointer, dimension(:), intent(inout) :: Ice_bc_restart, Ocn_bc_restart + + integer, allocatable, dimension(:,:), intent(inout) :: ensemble_pelist + integer, allocatable, dimension(:), intent(inout) :: slow_ice_ocean_pelist + integer, intent(inout) :: id_atmos_model_init, id_land_model_init + integer, intent(inout) :: id_ocean_model_init, id_flux_exchange_init, id_ice_model_init + integer, intent(inout) :: mainClock, termClock + type(FMSTime_type), intent(inout) :: Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean + type(FMSTime_type), intent(inout) :: Time_start, Time_end, Time_restart + + integer, intent(inout) :: num_cpld_calls, num_atmos_calls ! !----------------------------------------------------------------------- ! local parameters @@ -257,6 +292,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_ice_boundary, Ice_ocean_bou integer :: pe, npes integer :: ens_siz(6), ensemble_size + integer :: ensemble_id = 1 integer :: atmos_pe_start=0, atmos_pe_end=0, & ocean_pe_start=0, ocean_pe_end=0 @@ -275,13 +311,17 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_ice_boundary, Ice_ocean_bou integer :: time_stamp_unit !< Unif of the time_stamp file integer :: ascii_unit !< Unit of a dummy ascii file + type(FmsTime_type) :: Time, Time_init, Time_restart_current + type(FmsCoupler1dBC_type), pointer :: & gas_fields_atm => NULL(), & ! A pointer to the type describing the - ! atmospheric fields that will participate in the gas fluxes. + ! atmospheric fields that will participate in the gas fluxes. gas_fields_ocn => NULL(), & ! A pointer to the type describing the ocean - ! and ice surface fields that will participate in the gas fluxes. - gas_fluxes => NULL() ! A pointer to the type describing the - ! atmosphere-ocean gas and tracer fluxes. + ! and ice surface fields that will participate in the gas fluxes. + gas_fluxes => NULL() ! A pointer to the type describing the + ! atmosphere-ocean gas and tracer fluxes. + + integer :: num_ice_bc_restart, num_ocn_bc_restart !----------------------------------------------------------------------- outunit = fms_mpp_stdout() @@ -380,7 +420,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_ice_boundary, Ice_ocean_bou write(errunit,*) 'Finished initializing ensemble_manager at '& //trim(walldate)//' '//trim(walltime) endif - ens_siz = get_ensemble_size() + ens_siz = fms_ensemble_manager_get_ensemble_size() ensemble_size = ens_siz(1) npes = ens_siz(2) @@ -422,8 +462,9 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_ice_boundary, Ice_ocean_bou !set up affinities based on threads - ensemble_id = get_ensemble_id() + ensemble_id = fms_ensemble_manager_get_ensemble_id() + if(allocated(ensemble_pelist)) call mpp_error(FATAL, 'ensemble_pelist unexpectedly has already been allocated') allocate(ensemble_pelist(1:ensemble_size,1:npes)) call fms_ensemble_manager_get_ensemble_pelist(ensemble_pelist) @@ -445,7 +486,11 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_ice_boundary, Ice_ocean_bou allocate( Ice%slow_pelist(ice_npes) ) Ice%slow_pelist(:) = Ice%fast_pelist(:) if(concurrent) then - allocate(slow_ice_ocean_pelist(ocean_npes+ice_npes)) + if(.not.allocated(slow_ice_ocean_pelist)) then + allocate(slow_ice_ocean_pelist(ocean_npes+ice_npes)) + else + call mpp_error(FATAL, 'allocation of slow_ice_ocean_pelist unexpectedly has already been allocated') + end if slow_ice_ocean_pelist(1:ice_npes) = Ice%slow_pelist(:) slow_ice_ocean_pelist(ice_npes+1:ice_npes+ocean_npes) = Ocean%pelist(:) else @@ -720,7 +765,8 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_ice_boundary, Ice_ocean_bou !----------------------------------------------------------------------- !----- write time stamps (for start time and end time) ------ - if ( fms_mpp_pe().EQ.fms_mpp_root_pe() ) open(newunit = time_stamp_unit, file='time_stamp.out', status='replace', form='formatted') + if ( fms_mpp_pe().EQ.fms_mpp_root_pe() ) & + open(newunit = time_stamp_unit, file='time_stamp.out', status='replace', form='formatted') month = fms_time_manager_month_name(date(2)) if ( fms_mpp_pe().EQ.fms_mpp_root_pe() ) write (time_stamp_unit,20) date, month(1:3) @@ -1048,9 +1094,27 @@ end subroutine coupler_init !####################################################################### - subroutine coupler_end() + subroutine coupler_end(Atm, Land, Ice, Ocean, Ocean_state, Land_ice_atmos_boundary, Atmos_ice_boundary,& + Atmos_land_boundary, Ice_ocean_boundary, Ocean_ice_boundary, Ocn_bc_restart, & + Ice_bc_restart, Time, Time_start, Time_end, Time_restart_current) -!----------------------------------------------------------------------- + implicit none + + type(atmos_data_type), intent(inout) :: Atm + type(land_data_type), intent(inout) :: Land + type(ice_data_type), intent(inout) :: Ice + type(ocean_public_type), intent(inout) :: Ocean + type(ocean_state_type), pointer, intent(inout) :: Ocean_state + type(land_ice_atmos_boundary_type), intent(inout) :: Land_ice_atmos_boundary + type(atmos_ice_boundary_type), intent(inout) :: Atmos_ice_boundary + type(atmos_land_boundary_type), intent(inout) :: Atmos_land_boundary + type(ice_ocean_boundary_type), intent(inout) :: Ice_ocean_boundary + type(ocean_ice_boundary_type), intent(inout) :: Ocean_ice_boundary + type(FmsNetcdfDomainFile_t), dimension(:), pointer, intent(inout) :: Ocn_bc_restart + type(FmsNetcdfDomainFile_t), dimension(:), pointer, intent(inout) :: Ice_bc_restart + + type(FmsTime_type), intent(in) :: Time, Time_start, Time_end, Time_restart_current + integer :: num_ice_bc_restart, num_ocn_bc_restart if ( do_endpoint_chksum ) then if (Atm%pe) then @@ -1100,7 +1164,8 @@ subroutine coupler_end() endif !----- write restart file ------ - call coupler_restart(Time, Time_restart_current) + call coupler_restart(Atm, Ice, Ocean, Ocn_bc_restart, Ice_bc_restart, & + Time, Time_restart_current, Time_start, Time_end) call fms_diag_end (Time) #ifdef use_deprecated_io @@ -1128,15 +1193,29 @@ subroutine add_domain_dimension_data(fileobj) call fms2_io_write_data(fileobj, "yaxis_1", buffer) deallocate(buffer) - end subroutine add_domain_dimension_data + end subroutine add_domain_dimension_data !> \brief Writing restart file that contains running time and restart file writing time. - subroutine coupler_restart(Time_run, Time_res, time_stamp) - type(FmsTime_type), intent(in) :: Time_run, Time_res + subroutine coupler_restart(Atm, Ice, Ocean, Ocn_bc_restart, Ice_bc_restart, & + Time_run, Time_res, Time_start, Time_end, time_stamp) + + implicit none + + type(atmos_data_type), intent(inout) :: Atm + type(ice_data_type), intent(inout) :: Ice + type(ocean_public_type), intent(inout) :: Ocean + + type(FmsNetcdfDomainFile_t), dimension(:), pointer, intent(inout) :: Ocn_bc_restart + type(FmsNetcdfDomainFile_t), dimension(:), pointer, intent(inout) :: Ice_bc_restart + + type(FmsTime_type), intent(in) :: Time_run, Time_res, Time_start, Time_end character(len=*), intent(in), optional :: time_stamp - character(len=128) :: file_run, file_res + + character(len=128) :: file_run, file_res + integer :: yr, mon, day, hr, min, sec, date(6), n + integer :: num_ice_bc_restart, num_ocn_bc_restart integer :: restart_unit !< Unit for the coupler restart file call fms_mpp_set_current_pelist() @@ -1210,7 +1289,13 @@ end subroutine coupler_restart !-------------------------------------------------------------------------- !> \brief Print out checksums for several atm, land and ice variables - subroutine coupler_chksum(id, timestep) + subroutine coupler_chksum(id, timestep, Atm, Land, Ice) + + implicit none + + type(atmos_data_type), intent(in) :: Atm + type(land_data_type), intent(in) :: Land + type(ice_data_type), intent(in) :: Ice character(len=*), intent(in) :: id integer , intent(in) :: timestep From 1880bfe097188da7bfaaa9327f2d474e4bfcd3d4 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Tue, 23 Apr 2024 12:15:22 -0400 Subject: [PATCH 12/19] it compiles! --- full/full_coupler_mod.F90 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 43fab27f..8f3043a9 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -120,7 +120,6 @@ module full_coupler_mod public :: atm_lnd_bnd_type_chksum, land_data_type_chksum public :: ice_data_type_chksum, ocn_ice_bnd_type_chksum public :: atm_ice_bnd_type_chksum, lnd_ice_bnd_type_chksum - public :: ocean_ice_boundary_type, atmos_ice_boundary_type public :: ocean_public_type_chksum, ice_ocn_bnd_type_chksum public :: coupler_init, coupler_end, coupler_restart @@ -464,7 +463,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, ensemble_id = fms_ensemble_manager_get_ensemble_id() - if(allocated(ensemble_pelist)) call mpp_error(FATAL, 'ensemble_pelist unexpectedly has already been allocated') + if(allocated(ensemble_pelist)) call fms_mpp_error(FATAL, 'ensemble_pelist unexpectedly has already been allocated') allocate(ensemble_pelist(1:ensemble_size,1:npes)) call fms_ensemble_manager_get_ensemble_pelist(ensemble_pelist) @@ -489,7 +488,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, if(.not.allocated(slow_ice_ocean_pelist)) then allocate(slow_ice_ocean_pelist(ocean_npes+ice_npes)) else - call mpp_error(FATAL, 'allocation of slow_ice_ocean_pelist unexpectedly has already been allocated') + call fms_mpp_error(FATAL, 'allocation of slow_ice_ocean_pelist unexpectedly has already been allocated') end if slow_ice_ocean_pelist(1:ice_npes) = Ice%slow_pelist(:) slow_ice_ocean_pelist(ice_npes+1:ice_npes+ocean_npes) = Ocean%pelist(:) From 9c52fc63c3ccbd3c3839406ef8dc0e06cc71daaa Mon Sep 17 00:00:00 2001 From: mlee03 Date: Tue, 23 Apr 2024 14:00:18 -0400 Subject: [PATCH 13/19] conc_nthreads error that wasnt there before! --- full/coupler_main.F90 | 4 ++-- full/full_coupler_mod.F90 | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/full/coupler_main.F90 b/full/coupler_main.F90 index 330f639e..fad30a10 100644 --- a/full/coupler_main.F90 +++ b/full/coupler_main.F90 @@ -432,8 +432,8 @@ program coupler_main call coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, Atmos_ice_boundary, & Ocean_ice_boundary, Ice_ocean_boundary, Land_ice_atmos_boundary, Land_ice_boundary, & - Ice_ocean_driver_CS, Ice_bc_restart, Ocn_bc_restart, & - ensemble_pelist, slow_ice_ocean_pelist, id_atmos_model_init, id_land_model_init, & + Ice_ocean_driver_CS, Ice_bc_restart, Ocn_bc_restart, ensemble_pelist, slow_ice_ocean_pelist, & + conc_nthreads, id_atmos_model_init, id_land_model_init, & id_ice_model_init, id_ocean_model_init, id_flux_exchange_init, mainClock, termClock, & Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean, num_cpld_calls, num_atmos_calls, & Time_start, Time_end, Time_restart) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 8f3043a9..e9bf8c73 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -242,7 +242,7 @@ module full_coupler_mod !> \brief Initialize all defined exchange grids and all boundary maps subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, Atmos_ice_boundary, & Ocean_ice_boundary, Ice_ocean_boundary, Land_ice_atmos_boundary, Land_ice_boundary, & - Ice_ocean_driver_CS, Ice_bc_restart, Ocn_bc_restart, ensemble_pelist, slow_ice_ocean_pelist, & + Ice_ocean_driver_CS, Ice_bc_restart, Ocn_bc_restart, ensemble_pelist, slow_ice_ocean_pelist, conc_nthreads, & id_atmos_model_init, id_land_model_init, id_ice_model_init, id_ocean_model_init, & id_flux_exchange_init, mainClock, termClock, Time_step_cpld, Time_step_atmos, & Time_atmos, Time_ocean, num_cpld_calls, num_atmos_calls, Time_start, Time_end, Time_restart) @@ -260,9 +260,10 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, type(ocean_ice_boundary_type), intent(inout) :: Ocean_ice_boundary type(land_ice_boundary_type), intent(inout) :: Land_ice_boundary type(ice_ocean_driver_type), pointer, intent(inout) :: Ice_ocean_driver_CS - type(land_ice_atmos_boundary_type), intent(inout) :: Land_ice_atmos_boundary + type(land_ice_atmos_boundary_type), intent(inout) :: Land_ice_atmos_boundary type(FmsNetcdfDomainFile_t), pointer, dimension(:), intent(inout) :: Ice_bc_restart, Ocn_bc_restart + integer, intent(inout) :: conc_nthreads integer, allocatable, dimension(:,:), intent(inout) :: ensemble_pelist integer, allocatable, dimension(:), intent(inout) :: slow_ice_ocean_pelist integer, intent(inout) :: id_atmos_model_init, id_land_model_init From 7e13e96d29797ca1ef97430af9042892b12aeba5 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 6 May 2024 12:50:13 -0400 Subject: [PATCH 14/19] pass Time as coupler_init argument --- full/coupler_main.F90 | 2 +- full/full_coupler_mod.F90 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/full/coupler_main.F90 b/full/coupler_main.F90 index fad30a10..15b28441 100644 --- a/full/coupler_main.F90 +++ b/full/coupler_main.F90 @@ -436,7 +436,7 @@ program coupler_main conc_nthreads, id_atmos_model_init, id_land_model_init, & id_ice_model_init, id_ocean_model_init, id_flux_exchange_init, mainClock, termClock, & Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean, num_cpld_calls, num_atmos_calls, & - Time_start, Time_end, Time_restart) + Time, Time_start, Time_end, Time_restart) if (do_chksum) call coupler_chksum('coupler_init+', 0, Atm, Land, Ice) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index e9bf8c73..0a621a5a 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -245,7 +245,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, Ice_ocean_driver_CS, Ice_bc_restart, Ocn_bc_restart, ensemble_pelist, slow_ice_ocean_pelist, conc_nthreads, & id_atmos_model_init, id_land_model_init, id_ice_model_init, id_ocean_model_init, & id_flux_exchange_init, mainClock, termClock, Time_step_cpld, Time_step_atmos, & - Time_atmos, Time_ocean, num_cpld_calls, num_atmos_calls, Time_start, Time_end, Time_restart) + Time_atmos, Time_ocean, num_cpld_calls, num_atmos_calls, Time, Time_start, Time_end, Time_restart) implicit none @@ -270,7 +270,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, integer, intent(inout) :: id_ocean_model_init, id_flux_exchange_init, id_ice_model_init integer, intent(inout) :: mainClock, termClock type(FMSTime_type), intent(inout) :: Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean - type(FMSTime_type), intent(inout) :: Time_start, Time_end, Time_restart + type(FMSTime_type), intent(inout) :: Time, Time_start, Time_end, Time_restart integer, intent(inout) :: num_cpld_calls, num_atmos_calls ! From 0e8f21efd824d647a4d87049c8557e72ea8197f9 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Mon, 6 May 2024 12:56:52 -0400 Subject: [PATCH 15/19] add Time_restart_current to coupler_init argument --- full/coupler_main.F90 | 2 +- full/full_coupler_mod.F90 | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/full/coupler_main.F90 b/full/coupler_main.F90 index 15b28441..111b5e6f 100644 --- a/full/coupler_main.F90 +++ b/full/coupler_main.F90 @@ -436,7 +436,7 @@ program coupler_main conc_nthreads, id_atmos_model_init, id_land_model_init, & id_ice_model_init, id_ocean_model_init, id_flux_exchange_init, mainClock, termClock, & Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean, num_cpld_calls, num_atmos_calls, & - Time, Time_start, Time_end, Time_restart) + Time, Time_start, Time_end, Time_restart, Time_restart_current) if (do_chksum) call coupler_chksum('coupler_init+', 0, Atm, Land, Ice) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 0a621a5a..44111664 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -244,8 +244,8 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, Ocean_ice_boundary, Ice_ocean_boundary, Land_ice_atmos_boundary, Land_ice_boundary, & Ice_ocean_driver_CS, Ice_bc_restart, Ocn_bc_restart, ensemble_pelist, slow_ice_ocean_pelist, conc_nthreads, & id_atmos_model_init, id_land_model_init, id_ice_model_init, id_ocean_model_init, & - id_flux_exchange_init, mainClock, termClock, Time_step_cpld, Time_step_atmos, & - Time_atmos, Time_ocean, num_cpld_calls, num_atmos_calls, Time, Time_start, Time_end, Time_restart) + id_flux_exchange_init, mainClock, termClock, Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean, & + num_cpld_calls, num_atmos_calls, Time, Time_start, Time_end, Time_restart, Time_restart_current) implicit none @@ -270,7 +270,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, integer, intent(inout) :: id_ocean_model_init, id_flux_exchange_init, id_ice_model_init integer, intent(inout) :: mainClock, termClock type(FMSTime_type), intent(inout) :: Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean - type(FMSTime_type), intent(inout) :: Time, Time_start, Time_end, Time_restart + type(FMSTime_type), intent(inout) :: Time, Time_start, Time_end, Time_restart, Time_restart_current integer, intent(inout) :: num_cpld_calls, num_atmos_calls ! @@ -311,7 +311,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, integer :: time_stamp_unit !< Unif of the time_stamp file integer :: ascii_unit !< Unit of a dummy ascii file - type(FmsTime_type) :: Time, Time_init, Time_restart_current + type(FmsTime_type) :: Time_init type(FmsCoupler1dBC_type), pointer :: & gas_fields_atm => NULL(), & ! A pointer to the type describing the From 7b517c2f757af5cd5c97756a4766795cef99de1a Mon Sep 17 00:00:00 2001 From: mlee03 Date: Tue, 7 May 2024 14:27:42 -0400 Subject: [PATCH 16/19] change full to nothing --- full/full_coupler_mod.F90 | 140 +++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 77 deletions(-) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 11b9b395..fbb96a56 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -242,8 +242,8 @@ module full_coupler_mod use_hyper_thread, concurrent_ice, slow_ice_with_ocean, & do_endpoint_chksum, combined_ice_and_ocean - public :: full_coupler_clock_type - type full_coupler_clock_type + public :: coupler_clock_type + type coupler_clock_type integer :: initialization integer :: main integer :: generate_sfc_xgrid @@ -283,9 +283,9 @@ module full_coupler_mod integer :: ice_model_init integer :: ocean_model_init integer :: flux_exchange_init - end type full_coupler_clock_type + end type coupler_clock_type - type(full_coupler_clock_type), public :: coupler_clocks + type(coupler_clock_type), public :: coupler_clocks character(len=80), public :: text character(len=48), parameter :: mod_name = 'full_coupler_mod' @@ -592,9 +592,7 @@ subroutine coupler_init endif !> The pelists need to be set before initializing the clocks - call coupler_set_clock_ids(coupler_clocks, Atm, Land, Ice, Ocean, & - slow_ice_ocean_pelist, ensemble_pelist, ensemble_id, & - do_concurrent_radiation, clock_type='init_model_clocks') + call coupler_set_clock_ids(ensemble_id, clock_set='model_init_clocks') !Write out messages on root PEs if (fms_mpp_pe().EQ.fms_mpp_root_pe()) then @@ -971,9 +969,7 @@ subroutine coupler_init endif ! end of Ocean%is_ocean_pe - call coupler_set_clock_ids(coupler_clocks, Atm, Land, Ice, Ocean, & - slow_ice_ocean_pelist, ensemble_pelist, ensemble_id, & - do_concurrent_radiation, clock_type='init_coupler_clocks') + call coupler_set_clock_ids(ensemble_id, clock_set='coupler_clocks') !--------------------------------------------- if (fms_mpp_pe().EQ.fms_mpp_root_pe()) then @@ -1467,113 +1463,103 @@ subroutine ocean_chksum(id, timestep, Ocean, Ice_ocean_boundary) end subroutine ocean_chksum !> \brief This subroutine sets the ID for clocks used in coupler_main - subroutine coupler_set_clock_ids(coupler_clocks_in, Atm_in, Land_in, Ice_in, Ocean_in, & - slow_ice_ocean_pelist_in, ensemble_pelist_in, ensemble_id, & - do_concurrent_radiation_in, clock_type) + subroutine coupler_set_clock_ids(ensemble_id, clock_set) implicit none - type(full_coupler_clock_type), intent(inout) :: coupler_clocks_in - type(atmos_data_type), intent(in) :: Atm_in - type(land_data_type), intent(in) :: Land_in - type(ice_data_type), intent(in) :: Ice_in - type(ocean_public_type), intent(in) :: Ocean_in - integer, intent(in), dimension(:) :: slow_ice_ocean_pelist_in - integer, intent(in), dimension(:,:) :: ensemble_pelist_in integer, intent(in) :: ensemble_id - logical, intent(in) :: do_concurrent_radiation_in - character(len=*), intent(in) :: clock_type + character(len=*), intent(in) :: clock_set - if( trim(clock_type) == 'init_model_clocks' ) then + if( trim(clock_set) == 'model_init_clocks' ) then !> initialization clock - if (Atm_in%pe) then - call fms_mpp_set_current_pelist(Atm_in%pelist) - coupler_clocks_in%atmos_model_init = fms_mpp_clock_id( ' Init: atmos_model_init ' ) + if (Atm%pe) then + call fms_mpp_set_current_pelist(Atm%pelist) + coupler_clocks%atmos_model_init = fms_mpp_clock_id( ' Init: atmos_model_init ' ) endif - if (Land_in%pe) then - call fms_mpp_set_current_pelist(Land_in%pelist) - coupler_clocks_in%land_model_init = fms_mpp_clock_id( ' Init: land_model_init ' ) + if (Land%pe) then + call fms_mpp_set_current_pelist(Land%pelist) + coupler_clocks%land_model_init = fms_mpp_clock_id( ' Init: land_model_init ' ) endif - if (Ice_in%pe) then - if (Ice_in%shared_slow_fast_PEs) then ; call fms_mpp_set_current_pelist(Ice_in%pelist) - elseif (Ice_in%fast_ice_pe) then ; call fms_mpp_set_current_pelist(Ice_in%fast_pelist) - elseif (Ice_in%slow_ice_pe) then ; call fms_mpp_set_current_pelist(Ice_in%slow_pelist) + if (Ice%pe) then + if (Ice%shared_slow_fast_PEs) then ; call fms_mpp_set_current_pelist(Ice%pelist) + elseif (Ice%fast_ice_pe) then ; call fms_mpp_set_current_pelist(Ice%fast_pelist) + elseif (Ice%slow_ice_pe) then ; call fms_mpp_set_current_pelist(Ice%slow_pelist) else ; call fms_mpp_error(FATAL, "All Ice%pes must be a part of Ice%fast_ice_pe or Ice%slow_ice_pe") endif - coupler_clocks_in%ice_model_init = fms_mpp_clock_id( ' Init: ice_model_init ' ) + coupler_clocks%ice_model_init = fms_mpp_clock_id( ' Init: ice_model_init ' ) endif - if (Ocean_in%is_ocean_pe) then - call fms_mpp_set_current_pelist(Ocean_in%pelist) - coupler_clocks_in%ocean_model_init = fms_mpp_clock_id( ' Init: ocean_model_init ' ) + if (Ocean%is_ocean_pe) then + call fms_mpp_set_current_pelist(Ocean%pelist) + coupler_clocks%ocean_model_init = fms_mpp_clock_id( ' Init: ocean_model_init ' ) endif - call fms_mpp_set_current_pelist(ensemble_pelist_in(ensemble_id,:)) - coupler_clocks_in%flux_exchange_init = fms_mpp_clock_id( ' Init: flux_exchange_init' ) + call fms_mpp_set_current_pelist(ensemble_pelist(ensemble_id,:)) + coupler_clocks%flux_exchange_init = fms_mpp_clock_id( ' Init: flux_exchange_init' ) call fms_mpp_set_current_pelist() - coupler_clocks_in%main = fms_mpp_clock_id( 'Main loop' ) - coupler_clocks_in%termination = fms_mpp_clock_id( 'Termination' ) + coupler_clocks%main = fms_mpp_clock_id( 'Main loop' ) + coupler_clocks%termination = fms_mpp_clock_id( 'Termination' ) - else if( trim(clock_type) == 'init_coupler_clocks' ) then + else if( trim(clock_set) == 'coupler_clocks' ) then If(Atm_in%pe) then call fms_mpp_set_current_pelist(Atm_in%pelist) - coupler_clocks_in%generate_sfc_xgrid = fms_mpp_clock_id( 'generate_sfc_xgrid' ) + coupler_clocks%generate_sfc_xgrid = fms_mpp_clock_id( 'generate_sfc_xgrid' ) end if if (Ice_in%slow_ice_PE .or. Ocean_in%is_ocean_pe) then - call fms_mpp_set_current_pelist(slow_ice_ocean_pelist_in) - coupler_clocks_in%flux_ocean_to_ice = fms_mpp_clock_id( 'flux_ocean_to_ice' ) - coupler_clocks_in%flux_ice_to_ocean = fms_mpp_clock_id( 'flux_ice_to_ocean' ) + call fms_mpp_set_current_pelist(slow_ice_ocean_pelist) + coupler_clocks%flux_ocean_to_ice = fms_mpp_clock_id( 'flux_ocean_to_ice' ) + coupler_clocks%flux_ice_to_ocean = fms_mpp_clock_id( 'flux_ice_to_ocean' ) endif if (Atm_in%pe) then call fms_mpp_set_current_pelist(Atm_in%pelist) - coupler_clocks_in%atm = fms_mpp_clock_id( 'ATM' ) - coupler_clocks_in%atmos_loop = fms_mpp_clock_id( ' ATM: atmos loop' ) - coupler_clocks_in%atmos_tracer_driver_gather_data & + coupler_clocks%atm = fms_mpp_clock_id( 'ATM' ) + coupler_clocks%atmos_loop = fms_mpp_clock_id( ' ATM: atmos loop' ) + coupler_clocks%atmos_tracer_driver_gather_data & = fms_mpp_clock_id( ' A-L: atmos_tracer_driver_gather_data' ) - coupler_clocks_in%sfc_boundary_layer = fms_mpp_clock_id( ' A-L: sfc_boundary_layer' ) - coupler_clocks_in%update_atmos_model_dynamics = fms_mpp_clock_id( ' A-L: update_atmos_model_dynamics') - if (.not. do_concurrent_radiation_in) & - coupler_clocks_in%serial_radiation = fms_mpp_clock_id( ' A-L: serial radiation' ) - coupler_clocks_in%update_atmos_model_down = fms_mpp_clock_id( ' A-L: update_atmos_model_down' ) - coupler_clocks_in%flux_down_from_atmos = fms_mpp_clock_id( ' A-L: flux_down_from_atmos' ) - coupler_clocks_in%update_land_model_fast = fms_mpp_clock_id( ' A-L: update_land_model_fast' ) - coupler_clocks_in%update_ice_model_fast = fms_mpp_clock_id( ' A-L: update_ice_model_fast' ) - coupler_clocks_in%flux_up_to_atmos = fms_mpp_clock_id( ' A-L: flux_up_to_atmos' ) - coupler_clocks_in%update_atmos_model_up = fms_mpp_clock_id( ' A-L: update_atmos_model_up' ) - if (do_concurrent_radiation_in) then - coupler_clocks_in%concurrent_radiation = fms_mpp_clock_id( ' A-L: concurrent radiation' ) - coupler_clocks_in%concurrent_atmos = fms_mpp_clock_id( ' A-L: concurrent atmos' ) + coupler_clocks%sfc_boundary_layer = fms_mpp_clock_id( ' A-L: sfc_boundary_layer' ) + coupler_clocks%update_atmos_model_dynamics = fms_mpp_clock_id( ' A-L: update_atmos_model_dynamics') + if (.not. do_concurrent_radiation) & + coupler_clocks%serial_radiation = fms_mpp_clock_id( ' A-L: serial radiation' ) + coupler_clocks%update_atmos_model_down = fms_mpp_clock_id( ' A-L: update_atmos_model_down' ) + coupler_clocks%flux_down_from_atmos = fms_mpp_clock_id( ' A-L: flux_down_from_atmos' ) + coupler_clocks%update_land_model_fast = fms_mpp_clock_id( ' A-L: update_land_model_fast' ) + coupler_clocks%update_ice_model_fast = fms_mpp_clock_id( ' A-L: update_ice_model_fast' ) + coupler_clocks%flux_up_to_atmos = fms_mpp_clock_id( ' A-L: flux_up_to_atmos' ) + coupler_clocks%update_atmos_model_up = fms_mpp_clock_id( ' A-L: update_atmos_model_up' ) + if (do_concurrent_radiation) then + coupler_clocks%concurrent_radiation = fms_mpp_clock_id( ' A-L: concurrent radiation' ) + coupler_clocks%concurrent_atmos = fms_mpp_clock_id( ' A-L: concurrent atmos' ) endif - coupler_clocks_in%update_atmos_model_state = fms_mpp_clock_id( ' A-L: update_atmos_model_state') - coupler_clocks_in%update_land_model_slow = fms_mpp_clock_id( ' ATM: update_land_model_slow' ) - coupler_clocks_in%flux_land_to_ice = fms_mpp_clock_id( ' ATM: flux_land_to_ice' ) + coupler_clocks%update_atmos_model_state = fms_mpp_clock_id( ' A-L: update_atmos_model_state') + coupler_clocks%update_land_model_slow = fms_mpp_clock_id( ' ATM: update_land_model_slow' ) + coupler_clocks%flux_land_to_ice = fms_mpp_clock_id( ' ATM: flux_land_to_ice' ) endif if (Ice_in%pe) then if (Ice_in%fast_ice_pe) call fms_mpp_set_current_pelist(Ice_in%fast_pelist) - coupler_clocks_in%set_ice_surface_fast = fms_mpp_clock_id( ' Ice: set_ice_surface fast' ) - coupler_clocks_in%update_ice_model_slow_fast = fms_mpp_clock_id( ' Ice: update_ice_model_slow fast' ) + coupler_clocks%set_ice_surface_fast = fms_mpp_clock_id( ' Ice: set_ice_surface fast' ) + coupler_clocks%update_ice_model_slow_fast = fms_mpp_clock_id( ' Ice: update_ice_model_slow fast' ) if (Ice_in%slow_ice_pe) call fms_mpp_set_current_pelist(Ice_in%slow_pelist) - coupler_clocks_in%set_ice_surface_slow = fms_mpp_clock_id( ' Ice: set_ice_surface slow' ) - coupler_clocks_in%update_ice_model_slow_slow = fms_mpp_clock_id( ' Ice: update_ice_model_slow slow' ) - coupler_clocks_in%flux_ice_to_ocean_stocks = fms_mpp_clock_id( ' Ice: flux_ice_to_ocean_stocks' ) + coupler_clocks%set_ice_surface_slow = fms_mpp_clock_id( ' Ice: set_ice_surface slow' ) + coupler_clocks%update_ice_model_slow_slow = fms_mpp_clock_id( ' Ice: update_ice_model_slow slow' ) + coupler_clocks%flux_ice_to_ocean_stocks = fms_mpp_clock_id( ' Ice: flux_ice_to_ocean_stocks' ) call fms_mpp_set_current_pelist(Ice_in%pelist) - coupler_clocks_in%set_ice_surface_exchange = fms_mpp_clock_id( ' Ice: set_ice_surface exchange' ) - coupler_clocks_in%update_ice_model_slow_exchange = fms_mpp_clock_id( ' Ice: update_ice_model_slow exchange' ) + coupler_clocks%set_ice_surface_exchange = fms_mpp_clock_id( ' Ice: set_ice_surface exchange' ) + coupler_clocks%update_ice_model_slow_exchange = fms_mpp_clock_id( ' Ice: update_ice_model_slow exchange' ) endif if (Ocean_in%is_ocean_pe) then call fms_mpp_set_current_pelist(Ocean_in%pelist) - coupler_clocks_in%ocean = fms_mpp_clock_id( 'OCN' ) + coupler_clocks%ocean = fms_mpp_clock_id( 'OCN' ) endif call fms_mpp_set_current_pelist() - coupler_clocks_in%flux_check_stocks = fms_mpp_clock_id( 'flux_check_stocks' ) - coupler_clocks_in%intermediate_restart = fms_mpp_clock_id( 'intermediate restart' ) - coupler_clocks_in%final_flux_check_stocks = fms_mpp_clock_id( 'final flux_check_stocks' ) + coupler_clocks%flux_check_stocks = fms_mpp_clock_id( 'flux_check_stocks' ) + coupler_clocks%intermediate_restart = fms_mpp_clock_id( 'intermediate restart' ) + coupler_clocks%final_flux_check_stocks = fms_mpp_clock_id( 'final flux_check_stocks' ) else - call fms_mpp_error(FATAL, 'clock_type not recognized in coupler_set_clock_ids') + call fms_mpp_error(FATAL, 'clock_set not recognized in coupler_set_clock_ids') end if From 9af81baddce95df9d3ae3c5b73adc18a2015aa0e Mon Sep 17 00:00:00 2001 From: mlee03 Date: Tue, 7 May 2024 15:33:34 -0400 Subject: [PATCH 17/19] fixes for compilation --- full/full_coupler_mod.F90 | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 9e92f558..6425d79b 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -611,7 +611,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, endif !> The pelists need to be set before initializing the clocks - call coupler_set_clock_ids(ensemble_id, clock_set='model_init_clocks') + call coupler_set_clock_ids(Atm, Land, Ice, Ocean, ensemble_pelist, slow_ice_ocean_pelist, ensemble_id, clock_set='model_init_clocks') !Write out messages on root PEs if (fms_mpp_pe().EQ.fms_mpp_root_pe()) then @@ -989,7 +989,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, endif ! end of Ocean%is_ocean_pe - call coupler_set_clock_ids(ensemble_id, clock_set='coupler_clocks') + call coupler_set_clock_ids(Atm, Land, Ice, Ocean, ensemble_pelist, slow_ice_ocean_pelist, ensemble_id, clock_set='coupler_clocks') !--------------------------------------------- if (fms_mpp_pe().EQ.fms_mpp_root_pe()) then @@ -1522,11 +1522,17 @@ subroutine ocean_chksum(id, timestep, Ocean, Ice_ocean_boundary) end subroutine ocean_chksum !> \brief This subroutine sets the ID for clocks used in coupler_main - subroutine coupler_set_clock_ids(ensemble_id, clock_set) + subroutine coupler_set_clock_ids(Atm, Land, Ice, Ocean, ensemble_pelist, slow_ice_ocean_pelist, ensemble_id, clock_set) implicit none - - integer, intent(in) :: ensemble_id + + type(atmos_data_type), intent(in) :: Atm + type(land_data_type), intent(in) :: Land + type(ocean_public_type), intent(in) :: Ocean + type(ice_data_type), intent(in) :: Ice + integer, dimension(:), intent(in) :: slow_ice_ocean_pelist + integer, dimension(:,:), intent(in) :: ensemble_pelist + integer, intent(in) :: ensemble_id character(len=*), intent(in) :: clock_set if( trim(clock_set) == 'model_init_clocks' ) then @@ -1559,17 +1565,17 @@ subroutine coupler_set_clock_ids(ensemble_id, clock_set) coupler_clocks%termination = fms_mpp_clock_id( 'Termination' ) else if( trim(clock_set) == 'coupler_clocks' ) then - If(Atm_in%pe) then - call fms_mpp_set_current_pelist(Atm_in%pelist) + If(Atm%pe) then + call fms_mpp_set_current_pelist(Atm%pelist) coupler_clocks%generate_sfc_xgrid = fms_mpp_clock_id( 'generate_sfc_xgrid' ) end if - if (Ice_in%slow_ice_PE .or. Ocean_in%is_ocean_pe) then + if (Ice%slow_ice_PE .or. Ocean%is_ocean_pe) then call fms_mpp_set_current_pelist(slow_ice_ocean_pelist) coupler_clocks%flux_ocean_to_ice = fms_mpp_clock_id( 'flux_ocean_to_ice' ) coupler_clocks%flux_ice_to_ocean = fms_mpp_clock_id( 'flux_ice_to_ocean' ) endif - if (Atm_in%pe) then - call fms_mpp_set_current_pelist(Atm_in%pelist) + if (Atm%pe) then + call fms_mpp_set_current_pelist(Atm%pelist) coupler_clocks%atm = fms_mpp_clock_id( 'ATM' ) coupler_clocks%atmos_loop = fms_mpp_clock_id( ' ATM: atmos loop' ) coupler_clocks%atmos_tracer_driver_gather_data & @@ -1592,23 +1598,23 @@ subroutine coupler_set_clock_ids(ensemble_id, clock_set) coupler_clocks%update_land_model_slow = fms_mpp_clock_id( ' ATM: update_land_model_slow' ) coupler_clocks%flux_land_to_ice = fms_mpp_clock_id( ' ATM: flux_land_to_ice' ) endif - if (Ice_in%pe) then - if (Ice_in%fast_ice_pe) call fms_mpp_set_current_pelist(Ice_in%fast_pelist) + if (Ice%pe) then + if (Ice%fast_ice_pe) call fms_mpp_set_current_pelist(Ice%fast_pelist) coupler_clocks%set_ice_surface_fast = fms_mpp_clock_id( ' Ice: set_ice_surface fast' ) coupler_clocks%update_ice_model_slow_fast = fms_mpp_clock_id( ' Ice: update_ice_model_slow fast' ) - if (Ice_in%slow_ice_pe) call fms_mpp_set_current_pelist(Ice_in%slow_pelist) + if (Ice%slow_ice_pe) call fms_mpp_set_current_pelist(Ice%slow_pelist) coupler_clocks%set_ice_surface_slow = fms_mpp_clock_id( ' Ice: set_ice_surface slow' ) coupler_clocks%update_ice_model_slow_slow = fms_mpp_clock_id( ' Ice: update_ice_model_slow slow' ) coupler_clocks%flux_ice_to_ocean_stocks = fms_mpp_clock_id( ' Ice: flux_ice_to_ocean_stocks' ) - call fms_mpp_set_current_pelist(Ice_in%pelist) + call fms_mpp_set_current_pelist(Ice%pelist) coupler_clocks%set_ice_surface_exchange = fms_mpp_clock_id( ' Ice: set_ice_surface exchange' ) coupler_clocks%update_ice_model_slow_exchange = fms_mpp_clock_id( ' Ice: update_ice_model_slow exchange' ) endif - if (Ocean_in%is_ocean_pe) then - call fms_mpp_set_current_pelist(Ocean_in%pelist) + if (Ocean%is_ocean_pe) then + call fms_mpp_set_current_pelist(Ocean%pelist) coupler_clocks%ocean = fms_mpp_clock_id( 'OCN' ) endif From 04f5ca28d4f5be2cd37aaa431007e49d26ef3b97 Mon Sep 17 00:00:00 2001 From: mlee03 Date: Thu, 9 May 2024 10:55:41 -0400 Subject: [PATCH 18/19] make coupler_clocks program variable --- full/coupler_main.F90 | 22 +++++++--------------- full/flux_exchange.F90 | 10 +++++----- full/full_coupler_mod.F90 | 26 ++++++++++++-------------- 3 files changed, 24 insertions(+), 34 deletions(-) diff --git a/full/coupler_main.F90 b/full/coupler_main.F90 index 4d2669a8..be68d6b2 100644 --- a/full/coupler_main.F90 +++ b/full/coupler_main.F90 @@ -331,6 +331,7 @@ !! This error should probably not occur because of checks done at initialization time. program coupler_main + !--- F90 module for OpenMP use omp_lib use FMS use full_coupler_mod @@ -369,15 +370,8 @@ program coupler_main type(FmsTime_type) :: Time_restart_current character(len=32) :: timestamp - integer :: initClock, mainClock, termClock - integer :: newClock0, newClock1, newClock2, newClock3, newClock4, newClock5, newClock7 - integer :: newClock6f, newClock6s, newClock6e, newClock10f, newClock10s, newClock10e - integer :: newClock8, newClock9, newClock11, newClock12, newClock13, newClock14, newClocka - integer :: newClockb, newClockc, newClockd, newClocke, newClockf, newClockg, newClockh, newClocki - integer :: newClockj, newClockk, newClockl - integer :: id_atmos_model_init, id_land_model_init, id_ice_model_init - integer :: id_ocean_model_init, id_flux_exchange_init - + type(coupler_clock_type) :: coupler_clocks + integer :: outunit character(len=80) :: text integer, allocatable :: ensemble_pelist(:, :) @@ -421,6 +415,7 @@ program coupler_main call fms_mpp_init() + !this clock is on the global pelist coupler_clocks%initialization = fms_mpp_clock_id( 'Initialization' ) call fms_mpp_clock_begin(coupler_clocks%initialization) @@ -428,14 +423,11 @@ program coupler_main call fmsconstants_init call fms_affinity_init - call coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, Atmos_ice_boundary, & - Ocean_ice_boundary, Ice_ocean_boundary, Land_ice_atmos_boundary, Land_ice_boundary, & + Ocean_ice_boundary, Ice_ocean_boundary, Land_ice_atmos_boundary, Land_ice_boundary, & Ice_ocean_driver_CS, Ice_bc_restart, Ocn_bc_restart, ensemble_pelist, slow_ice_ocean_pelist, & - conc_nthreads, id_atmos_model_init, id_land_model_init, & - id_ice_model_init, id_ocean_model_init, id_flux_exchange_init, mainClock, termClock, & - Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean, num_cpld_calls, num_atmos_calls, & - Time, Time_start, Time_end, Time_restart, Time_restart_current) + conc_nthreads, coupler_clocks, Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean, & + num_cpld_calls, num_atmos_calls, Time, Time_start, Time_end, Time_restart, Time_restart_current) if (do_chksum) call coupler_chksum('coupler_init+', 0, Atm, Land, Ice) diff --git a/full/flux_exchange.F90 b/full/flux_exchange.F90 index c1ac8381..35abf236 100644 --- a/full/flux_exchange.F90 +++ b/full/flux_exchange.F90 @@ -780,11 +780,11 @@ end subroutine flux_exchange_init subroutine flux_check_stocks(Time, Atm, Lnd, Ice, Ocn_state) - type(FmsTime_type), intent(in) :: Time - type(atmos_data_type), intent(inout), optional :: Atm - type(land_data_type), intent(inout), optional :: Lnd - type(ice_data_type), intent(inout), optional :: Ice - type(ocean_state_type), intent(inout), optional, pointer :: Ocn_state + type(FmsTime_type) :: Time + type(atmos_data_type), optional :: Atm + type(land_data_type), optional :: Lnd + type(ice_data_type), optional :: Ice + type(ocean_state_type), optional, pointer :: Ocn_state real :: ref_value integer :: i diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index 6425d79b..b9d0d472 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -226,7 +226,6 @@ module full_coupler_mod use_hyper_thread, concurrent_ice, slow_ice_with_ocean, & do_endpoint_chksum, combined_ice_and_ocean - public :: coupler_clock_type type coupler_clock_type integer :: initialization integer :: main @@ -269,8 +268,6 @@ module full_coupler_mod integer :: flux_exchange_init end type coupler_clock_type - type(coupler_clock_type), public :: coupler_clocks - character(len=80) :: text character(len=48), parameter :: mod_name = 'coupler_main_mod' @@ -285,11 +282,10 @@ module full_coupler_mod !> \brief Initialize all defined exchange grids and all boundary maps subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, Atmos_ice_boundary, & - Ocean_ice_boundary, Ice_ocean_boundary, Land_ice_atmos_boundary, Land_ice_boundary, & - Ice_ocean_driver_CS, Ice_bc_restart, Ocn_bc_restart, ensemble_pelist, slow_ice_ocean_pelist, conc_nthreads, & - id_atmos_model_init, id_land_model_init, id_ice_model_init, id_ocean_model_init, & - id_flux_exchange_init, mainClock, termClock, Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean, & - num_cpld_calls, num_atmos_calls, Time, Time_start, Time_end, Time_restart, Time_restart_current) + Ocean_ice_boundary, Ice_ocean_boundary, Land_ice_atmos_boundary, Land_ice_boundary, & + Ice_ocean_driver_CS, Ice_bc_restart, Ocn_bc_restart, ensemble_pelist, slow_ice_ocean_pelist, conc_nthreads, & + coupler_clocks, Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean, & + num_cpld_calls, num_atmos_calls, Time, Time_start, Time_end, Time_restart, Time_restart_current) implicit none @@ -310,9 +306,7 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, integer, intent(inout) :: conc_nthreads integer, allocatable, dimension(:,:), intent(inout) :: ensemble_pelist integer, allocatable, dimension(:), intent(inout) :: slow_ice_ocean_pelist - integer, intent(inout) :: id_atmos_model_init, id_land_model_init - integer, intent(inout) :: id_ocean_model_init, id_flux_exchange_init, id_ice_model_init - integer, intent(inout) :: mainClock, termClock + type(coupler_clock_type) :: coupler_clocks type(FMSTime_type), intent(inout) :: Time_step_cpld, Time_step_atmos, Time_atmos, Time_ocean type(FMSTime_type), intent(inout) :: Time, Time_start, Time_end, Time_restart, Time_restart_current @@ -611,7 +605,8 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, endif !> The pelists need to be set before initializing the clocks - call coupler_set_clock_ids(Atm, Land, Ice, Ocean, ensemble_pelist, slow_ice_ocean_pelist, ensemble_id, clock_set='model_init_clocks') + call coupler_set_clock_ids(coupler_clocks, Atm, Land, Ice, Ocean, ensemble_pelist, & + slow_ice_ocean_pelist, ensemble_id, clock_set='model_init_clocks') !Write out messages on root PEs if (fms_mpp_pe().EQ.fms_mpp_root_pe()) then @@ -989,7 +984,8 @@ subroutine coupler_init(Atm, Ocean, Land, Ice, Ocean_state, Atmos_land_boundary, endif ! end of Ocean%is_ocean_pe - call coupler_set_clock_ids(Atm, Land, Ice, Ocean, ensemble_pelist, slow_ice_ocean_pelist, ensemble_id, clock_set='coupler_clocks') + call coupler_set_clock_ids(coupler_clocks, Atm, Land, Ice, Ocean, ensemble_pelist, & + slow_ice_ocean_pelist, ensemble_id, clock_set='coupler_clocks') !--------------------------------------------- if (fms_mpp_pe().EQ.fms_mpp_root_pe()) then @@ -1522,10 +1518,12 @@ subroutine ocean_chksum(id, timestep, Ocean, Ice_ocean_boundary) end subroutine ocean_chksum !> \brief This subroutine sets the ID for clocks used in coupler_main - subroutine coupler_set_clock_ids(Atm, Land, Ice, Ocean, ensemble_pelist, slow_ice_ocean_pelist, ensemble_id, clock_set) + subroutine coupler_set_clock_ids(coupler_clocks, Atm, Land, Ice, Ocean, ensemble_pelist,& + slow_ice_ocean_pelist, ensemble_id, clock_set) implicit none + type(coupler_clock_type), intent(inout) :: coupler_clocks type(atmos_data_type), intent(in) :: Atm type(land_data_type), intent(in) :: Land type(ocean_public_type), intent(in) :: Ocean From cb7721b66731620a35ca2f565c1fc644af39450b Mon Sep 17 00:00:00 2001 From: mlee03 Date: Thu, 9 May 2024 13:18:40 -0400 Subject: [PATCH 19/19] make clock type public --- full/full_coupler_mod.F90 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/full/full_coupler_mod.F90 b/full/full_coupler_mod.F90 index b9d0d472..e6ea3ee4 100644 --- a/full/full_coupler_mod.F90 +++ b/full/full_coupler_mod.F90 @@ -125,6 +125,8 @@ module full_coupler_mod public :: coupler_init, coupler_end, coupler_restart public :: coupler_chksum, atmos_ice_land_chksum, slow_ice_chksum, ocean_chksum + public :: coupler_clock_type + !----------------------------------------------------------------------- character(len=128), public :: version = '$Id$' @@ -226,7 +228,7 @@ module full_coupler_mod use_hyper_thread, concurrent_ice, slow_ice_with_ocean, & do_endpoint_chksum, combined_ice_and_ocean - type coupler_clock_type + type coupler_clock_type integer :: initialization integer :: main integer :: generate_sfc_xgrid