From bb36988816f760b58c1f5a05a63ab4ec46e6cce5 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Wed, 4 Nov 2026 13:01:20 +0100 Subject: [PATCH 1/7] Sent OASIS fields before history & restart file I/O --- src/clm5/cpl/lnd_comp_mct.F90 | 18 +++++++----------- src/clm5/main/clm_driver.F90 | 21 +++++++++++++++++++++ src/clm5/oasis3/oas_sendReceiveMod.F90 | 8 ++++---- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/clm5/cpl/lnd_comp_mct.F90 b/src/clm5/cpl/lnd_comp_mct.F90 index 56179beab6..954d0d33f2 100644 --- a/src/clm5/cpl/lnd_comp_mct.F90 +++ b/src/clm5/cpl/lnd_comp_mct.F90 @@ -15,10 +15,10 @@ module lnd_comp_mct #if defined(USE_OASIS) use oas_defineMod , only : oas_definitions_init #ifdef COUP_OAS_ICON - use oas_sendReceiveMod, only : oas_receive_icon, oas_send_icon + use oas_sendReceiveMod, only : oas_receive_icon #endif #ifdef COUP_OAS_PFL - use oas_sendReceiveMod, only : oas_receive, oas_send + use oas_sendReceiveMod, only : oas_receive_parflow #endif #endif ! @@ -462,7 +462,9 @@ subroutine lnd_run_mct(EClock, cdata_l, x2l_l, l2x_l) if (nlend_sync .and. dosend) nlend = .true. #ifdef COUP_OAS_ICON + call t_startf('oas_receive_icon') call oas_receive_icon(bounds, time_elapsed, x2l = x2l_l%rattr) + call t_stopf ('oas_receive_icon') call t_startf ('lc_lnd_import') call lnd_import( bounds, & @@ -474,7 +476,9 @@ subroutine lnd_run_mct(EClock, cdata_l, x2l_l, l2x_l) #endif #ifdef COUP_OAS_PFL - call oas_receive(bounds, time_elapsed, atm2lnd_inst) + call t_startf('oas_receive_parflow') + call oas_receive_parflow(bounds, time_elapsed, atm2lnd_inst) + call t_stopf('oas_receive_parflow') #endif ! Run clm call t_barrierf('sync_clm_run1', mpicom) @@ -487,14 +491,6 @@ subroutine lnd_run_mct(EClock, cdata_l, x2l_l, l2x_l) call clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, rof_prognostic) call t_stopf ('clm_run') - -#if defined(COUP_OAS_ICON) - call oas_send_icon(bounds, time_elapsed, lnd2atm_inst) -#endif - -#if defined(COUP_OAS_PFL) - call oas_send(bounds, time_elapsed, lnd2atm_inst) -#endif ! Create l2x_l export state - add river runoff input to l2x_l if appropriate call t_startf ('lc_lnd_export') call lnd_export(bounds, lnd2atm_inst, lnd2glc_inst, l2x_l%rattr) diff --git a/src/clm5/main/clm_driver.F90 b/src/clm5/main/clm_driver.F90 index 1a25eb4905..96586f6f2b 100644 --- a/src/clm5/main/clm_driver.F90 +++ b/src/clm5/main/clm_driver.F90 @@ -111,6 +111,12 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro use clm_time_manager , only : get_curr_date use clm_varctl , only : use_lai_streams use SatellitePhenologyMod, only : lai_advance +#ifdef COUP_OAS_ICON + use oas_sendReceiveMod, only : oas_send_icon +#endif +#ifdef COUP_OAS_PFL + use oas_sendReceiveMod, only : oas_send_parflow +#endif ! ! !ARGUMENTS: implicit none @@ -1075,6 +1081,21 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro deallocate(net_carbon_exchange_grc) call t_stopf('lnd2atm') + ! ============================================================================ + ! Send coupled fields to ICON and/or Parflow. + ! ============================================================================ +#if defined(COUP_OAS_ICON) + call t_startf('oas_send_icon') + call oas_send_icon(bounds, time_elapsed, lnd2atm_inst) + call t_stopf('oas_send_icon') +#endif + +#if defined(COUP_OAS_PFL) + call t_startf('oas_send_parflow') + call oas_send_parflow(bounds, time_elapsed, lnd2atm_inst) + call t_stopf('oas_send_parflow') +#endif + ! ============================================================================ ! Determine gridcell averaged properties to send to glc ! ============================================================================ diff --git a/src/clm5/oasis3/oas_sendReceiveMod.F90 b/src/clm5/oasis3/oas_sendReceiveMod.F90 index bcd7856306..c745791fac 100644 --- a/src/clm5/oasis3/oas_sendReceiveMod.F90 +++ b/src/clm5/oasis3/oas_sendReceiveMod.F90 @@ -23,7 +23,7 @@ module oas_sendReceiveMod contains #ifdef COUP_OAS_PFL - subroutine oas_receive(bounds, seconds_elapsed, atm2lnd_inst) + subroutine oas_receive_parflow(bounds, seconds_elapsed, atm2lnd_inst) use atm2lndType, only: atm2lnd_type type(bounds_type), intent(in) :: bounds @@ -34,9 +34,9 @@ subroutine oas_receive(bounds, seconds_elapsed, atm2lnd_inst) call oasis_get(oas_psi_id, seconds_elapsed, atm2lnd_inst%pfl_psi_grc, info) call oasis_get(oas_sat_id, seconds_elapsed, atm2lnd_inst%pfl_h2osoi_liq_grc, info) - end subroutine oas_receive + end subroutine oas_receive_parflow - subroutine oas_send(bounds, seconds_elapsed, lnd2atm_inst) + subroutine oas_send_parflow(bounds, seconds_elapsed, lnd2atm_inst) use lnd2atmType, only : lnd2atm_type use spmdMod, only : mpicom use shr_mpi_mod, only: shr_mpi_barrier @@ -49,7 +49,7 @@ subroutine oas_send(bounds, seconds_elapsed, lnd2atm_inst) call oasis_put(oas_et_loss_id, seconds_elapsed, lnd2atm_inst%qflx_parflow_grc, info) - end subroutine oas_send + end subroutine oas_send_parflow #endif #ifdef COUP_OAS_ICON From f47b7a1ecdc9a8524f88cbd9b41ffe85fc9ec4ba Mon Sep 17 00:00:00 2001 From: kvrigor Date: Wed, 4 Nov 2026 13:25:24 +0100 Subject: [PATCH 2/7] Renamed oas_send/oas_receive to oas_send_parflow/oas_receive_parflow --- src/clm5/oasis3/oas_sendReceiveMod.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clm5/oasis3/oas_sendReceiveMod.F90 b/src/clm5/oasis3/oas_sendReceiveMod.F90 index c745791fac..dcfe6103a7 100644 --- a/src/clm5/oasis3/oas_sendReceiveMod.F90 +++ b/src/clm5/oasis3/oas_sendReceiveMod.F90 @@ -11,8 +11,8 @@ module oas_sendReceiveMod private #ifdef COUP_OAS_PFL - public :: oas_send - public :: oas_receive + public :: oas_send_parflow + public :: oas_receive_parflow #endif #ifdef COUP_OAS_ICON From 3546ec7e74e8c5c1fefde7ce89d69673663ead6b Mon Sep 17 00:00:00 2001 From: kvrigor Date: Wed, 4 Nov 2026 13:37:41 +0100 Subject: [PATCH 3/7] time_elapsed should be defined. --- src/clm5/main/clm_driver.F90 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/clm5/main/clm_driver.F90 b/src/clm5/main/clm_driver.F90 index 96586f6f2b..deffc42fcd 100644 --- a/src/clm5/main/clm_driver.F90 +++ b/src/clm5/main/clm_driver.F90 @@ -13,7 +13,7 @@ module clm_driver use clm_varctl , only : use_cn, use_lch4, use_noio, use_c13, use_c14 use clm_varctl , only : use_crop, ndep_from_cpl use clm_varctl , only : use_soil_moisture_streams - use clm_time_manager , only : get_nstep, is_beg_curr_day + use clm_time_manager , only : get_nstep, get_step_size, is_beg_curr_day use clm_time_manager , only : get_prev_date, is_first_step use clm_varpar , only : nlevsno, nlevgrnd use clm_varorb , only : obliqr @@ -135,6 +135,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ! !LOCAL VARIABLES: integer :: nstep ! time step number + integer :: time_elapsed ! elapsed time (dtime * nstep) integer :: nc, c, p, l, g ! indices integer :: nclumps ! number of clumps on this processor integer :: yr ! year (0, ...) @@ -1084,6 +1085,8 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ============================================================================ ! Send coupled fields to ICON and/or Parflow. ! ============================================================================ + nstep = get_nstep() + time_elapsed = get_step_size() * nstep #if defined(COUP_OAS_ICON) call t_startf('oas_send_icon') call oas_send_icon(bounds, time_elapsed, lnd2atm_inst) @@ -1116,7 +1119,6 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! Write global average diagnostics to standard output ! ============================================================================ - nstep = get_nstep() if (wrtdia) call mpi_barrier(mpicom,ier) call t_startf('wrtdiag') call write_diagnostic(bounds_proc, wrtdia, nstep, lnd2atm_inst) From 65d6c57734683f40748ff73a2512ad2babefa946 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Wed, 4 Nov 2026 13:41:07 +0100 Subject: [PATCH 4/7] bounds -> bounds_proc --- src/clm5/main/clm_driver.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clm5/main/clm_driver.F90 b/src/clm5/main/clm_driver.F90 index deffc42fcd..5fc1e9506c 100644 --- a/src/clm5/main/clm_driver.F90 +++ b/src/clm5/main/clm_driver.F90 @@ -1089,13 +1089,13 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro time_elapsed = get_step_size() * nstep #if defined(COUP_OAS_ICON) call t_startf('oas_send_icon') - call oas_send_icon(bounds, time_elapsed, lnd2atm_inst) + call oas_send_icon(bounds_proc, time_elapsed, lnd2atm_inst) call t_stopf('oas_send_icon') #endif #if defined(COUP_OAS_PFL) call t_startf('oas_send_parflow') - call oas_send_parflow(bounds, time_elapsed, lnd2atm_inst) + call oas_send_parflow(bounds_proc, time_elapsed, lnd2atm_inst) call t_stopf('oas_send_parflow') #endif From 6e8c055b93d9e93dc7797e17a74493e93b18b9e2 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Mon, 9 Nov 2026 13:18:26 +0100 Subject: [PATCH 5/7] Wrapped get_step_size and time_elapsed with COUP_OAS_* flags Even though it's unnecessary --- src/clm5/main/clm_driver.F90 | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/clm5/main/clm_driver.F90 b/src/clm5/main/clm_driver.F90 index 5fc1e9506c..2cd128c3df 100644 --- a/src/clm5/main/clm_driver.F90 +++ b/src/clm5/main/clm_driver.F90 @@ -13,7 +13,10 @@ module clm_driver use clm_varctl , only : use_cn, use_lch4, use_noio, use_c13, use_c14 use clm_varctl , only : use_crop, ndep_from_cpl use clm_varctl , only : use_soil_moisture_streams - use clm_time_manager , only : get_nstep, get_step_size, is_beg_curr_day + use clm_time_manager , only : get_nstep, is_beg_curr_day +#ifdef (COUP_OAS_ICON || COUP_OAS_PFL) + use clm_time_manager , only : get_step_size +#endif use clm_time_manager , only : get_prev_date, is_first_step use clm_varpar , only : nlevsno, nlevgrnd use clm_varorb , only : obliqr @@ -135,7 +138,9 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ! !LOCAL VARIABLES: integer :: nstep ! time step number +#if defined(COUP_OAS_ICON || COUP_OAS_PFL) integer :: time_elapsed ! elapsed time (dtime * nstep) +#endif integer :: nc, c, p, l, g ! indices integer :: nclumps ! number of clumps on this processor integer :: yr ! year (0, ...) @@ -1085,18 +1090,21 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ============================================================================ ! Send coupled fields to ICON and/or Parflow. ! ============================================================================ +#if defined(COUP_OAS_ICON || COUP_OAS_PFL) nstep = get_nstep() time_elapsed = get_step_size() * nstep +#endif + #if defined(COUP_OAS_ICON) - call t_startf('oas_send_icon') - call oas_send_icon(bounds_proc, time_elapsed, lnd2atm_inst) - call t_stopf('oas_send_icon') + call t_startf('oas_send_icon') + call oas_send_icon(bounds_proc, time_elapsed, lnd2atm_inst) + call t_stopf('oas_send_icon') #endif #if defined(COUP_OAS_PFL) - call t_startf('oas_send_parflow') - call oas_send_parflow(bounds_proc, time_elapsed, lnd2atm_inst) - call t_stopf('oas_send_parflow') + call t_startf('oas_send_parflow') + call oas_send_parflow(bounds_proc, time_elapsed, lnd2atm_inst) + call t_stopf('oas_send_parflow') #endif ! ============================================================================ @@ -1119,6 +1127,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! Write global average diagnostics to standard output ! ============================================================================ + nstep = get_nstep() if (wrtdia) call mpi_barrier(mpicom,ier) call t_startf('wrtdiag') call write_diagnostic(bounds_proc, wrtdia, nstep, lnd2atm_inst) From 24dfc123a5d3fbdb48fe891300482d04f042e554 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Mon, 9 Nov 2026 13:29:16 +0100 Subject: [PATCH 6/7] Fixed #ifdef syntax --- src/clm5/main/clm_driver.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clm5/main/clm_driver.F90 b/src/clm5/main/clm_driver.F90 index 2cd128c3df..8d3198e291 100644 --- a/src/clm5/main/clm_driver.F90 +++ b/src/clm5/main/clm_driver.F90 @@ -14,7 +14,7 @@ module clm_driver use clm_varctl , only : use_crop, ndep_from_cpl use clm_varctl , only : use_soil_moisture_streams use clm_time_manager , only : get_nstep, is_beg_curr_day -#ifdef (COUP_OAS_ICON || COUP_OAS_PFL) +#if defined(COUP_OAS_ICON) || defined(COUP_OAS_PFL) use clm_time_manager , only : get_step_size #endif use clm_time_manager , only : get_prev_date, is_first_step @@ -138,7 +138,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ! !LOCAL VARIABLES: integer :: nstep ! time step number -#if defined(COUP_OAS_ICON || COUP_OAS_PFL) +#if defined(COUP_OAS_ICON) || defined(COUP_OAS_PFL) integer :: time_elapsed ! elapsed time (dtime * nstep) #endif integer :: nc, c, p, l, g ! indices From 17c641190bc05a16d12f700292c41a8456a97210 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Mon, 9 Nov 2026 13:33:20 +0100 Subject: [PATCH 7/7] Fixed #ifdef syntax --- src/clm5/main/clm_driver.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clm5/main/clm_driver.F90 b/src/clm5/main/clm_driver.F90 index 8d3198e291..ca73f12c01 100644 --- a/src/clm5/main/clm_driver.F90 +++ b/src/clm5/main/clm_driver.F90 @@ -1090,7 +1090,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro ! ============================================================================ ! Send coupled fields to ICON and/or Parflow. ! ============================================================================ -#if defined(COUP_OAS_ICON || COUP_OAS_PFL) +#if defined(COUP_OAS_ICON) || defined(COUP_OAS_PFL) nstep = get_nstep() time_elapsed = get_step_size() * nstep #endif