From 7fcb3302a412139748f07b53971131145bb2004b Mon Sep 17 00:00:00 2001 From: Johannes Keller Date: Fri, 11 Jul 2025 16:08:47 +0200 Subject: [PATCH 1/9] enkf_clm: do not load CLMSA-specific subroutines --- interface/model/clm5_0/enkf_clm_5.F90 | 4 ++++ interface/model/eclm/enkf_clm_5.F90 | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/interface/model/clm5_0/enkf_clm_5.F90 b/interface/model/clm5_0/enkf_clm_5.F90 index ab11532e7..7d0861826 100644 --- a/interface/model/clm5_0/enkf_clm_5.F90 +++ b/interface/model/clm5_0/enkf_clm_5.F90 @@ -194,7 +194,9 @@ end subroutine clm_init !-------------------------------------------------------------------------- subroutine clm_advance(ntstep, tstartcycle, mype) bind(C,name="clm_advance") use cime_comp_mod, only : cime_run +#if defined CLMSA use enkf_clm_mod, only : set_clm_statevec +#endif use iso_C_binding implicit none @@ -224,7 +226,9 @@ subroutine clm_finalize() bind(C,name="clm_finalize") ! use ESMF, only : ESMF_Initialize, ESMF_Finalize use cime_comp_mod, only : cime_final +#if defined CLMSA use enkf_clm_mod, only : cleanup_clm_statevec +#endif implicit none diff --git a/interface/model/eclm/enkf_clm_5.F90 b/interface/model/eclm/enkf_clm_5.F90 index ab11532e7..7d0861826 100644 --- a/interface/model/eclm/enkf_clm_5.F90 +++ b/interface/model/eclm/enkf_clm_5.F90 @@ -194,7 +194,9 @@ end subroutine clm_init !-------------------------------------------------------------------------- subroutine clm_advance(ntstep, tstartcycle, mype) bind(C,name="clm_advance") use cime_comp_mod, only : cime_run +#if defined CLMSA use enkf_clm_mod, only : set_clm_statevec +#endif use iso_C_binding implicit none @@ -224,7 +226,9 @@ subroutine clm_finalize() bind(C,name="clm_finalize") ! use ESMF, only : ESMF_Initialize, ESMF_Finalize use cime_comp_mod, only : cime_final +#if defined CLMSA use enkf_clm_mod, only : cleanup_clm_statevec +#endif implicit none From f26e9822efa5fe37e1e6f14731c199241df0b6dc Mon Sep 17 00:00:00 2001 From: Johannes Keller Date: Fri, 11 Jul 2025 16:09:21 +0200 Subject: [PATCH 2/9] enkf_clm: COUP_OAS_PFL, experimental `cime_pre_init1` call --- interface/model/clm5_0/enkf_clm_5.F90 | 8 ++++++++ interface/model/eclm/enkf_clm_5.F90 | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/interface/model/clm5_0/enkf_clm_5.F90 b/interface/model/clm5_0/enkf_clm_5.F90 index 7d0861826..730d9a2de 100644 --- a/interface/model/clm5_0/enkf_clm_5.F90 +++ b/interface/model/clm5_0/enkf_clm_5.F90 @@ -100,10 +100,18 @@ subroutine clm_init(finname, pdaf_id, pdaf_max, mype) bind(C,name="clm_init") !!>> TSMP PDAF comment out beginning ! call cime_pre_init1(esmf_logfile_option) !!>> TSMP PDAF addition beginning +#if defined CLMSA call cime_pre_init1(esmf_logfile_option, & COMM_model_clm, & pdaf_id=pdaf_id, & pdaf_max=pdaf_max) +#endif + +#if defined COUP_OAS_PFL + ! EXPERIMENTAL: For eCLM-ParFlow-PDAF, the whole management of + ! communicators has to be re-traced + call cime_pre_init1(esmf_logfile_option) +#endif !!<< TSMP PDAF addition end end_count = shr_sys_irtc(irtc_rate) diff --git a/interface/model/eclm/enkf_clm_5.F90 b/interface/model/eclm/enkf_clm_5.F90 index 7d0861826..730d9a2de 100644 --- a/interface/model/eclm/enkf_clm_5.F90 +++ b/interface/model/eclm/enkf_clm_5.F90 @@ -100,10 +100,18 @@ subroutine clm_init(finname, pdaf_id, pdaf_max, mype) bind(C,name="clm_init") !!>> TSMP PDAF comment out beginning ! call cime_pre_init1(esmf_logfile_option) !!>> TSMP PDAF addition beginning +#if defined CLMSA call cime_pre_init1(esmf_logfile_option, & COMM_model_clm, & pdaf_id=pdaf_id, & pdaf_max=pdaf_max) +#endif + +#if defined COUP_OAS_PFL + ! EXPERIMENTAL: For eCLM-ParFlow-PDAF, the whole management of + ! communicators has to be re-traced + call cime_pre_init1(esmf_logfile_option) +#endif !!<< TSMP PDAF addition end end_count = shr_sys_irtc(irtc_rate) From 9c6c608cea958acddffb33dcc5ad99fd33c4963d Mon Sep 17 00:00:00 2001 From: Johannes Keller Date: Wed, 29 Oct 2025 10:42:13 +0100 Subject: [PATCH 3/9] fortitude fix --- interface/model/eclm/enkf_clm_5.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/model/eclm/enkf_clm_5.F90 b/interface/model/eclm/enkf_clm_5.F90 index 8a5991d7f..077b53e38 100644 --- a/interface/model/eclm/enkf_clm_5.F90 +++ b/interface/model/eclm/enkf_clm_5.F90 @@ -210,7 +210,7 @@ end subroutine clm_init subroutine clm_advance(ntstep, tstartcycle, mype) bind(C,name="clm_advance") use cime_comp_mod, only : cime_run #if defined CLMSA - use enkf_clm_mod, only : set_clm_statevec + use enkf_clm_mod, only : set_clm_statevec #endif use enkf_clm_mod, only : set_clm_statevec use iso_C_binding, only : c_int From 81710946b7fc9618af79e228ff5a8b2815a2fa18 Mon Sep 17 00:00:00 2001 From: Johannes Keller Date: Wed, 29 Oct 2025 10:53:29 +0100 Subject: [PATCH 4/9] fix --- interface/model/eclm/enkf_clm_5.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/model/eclm/enkf_clm_5.F90 b/interface/model/eclm/enkf_clm_5.F90 index 077b53e38..4dd6bda2d 100644 --- a/interface/model/eclm/enkf_clm_5.F90 +++ b/interface/model/eclm/enkf_clm_5.F90 @@ -212,7 +212,6 @@ subroutine clm_advance(ntstep, tstartcycle, mype) bind(C,name="clm_advance") #if defined CLMSA use enkf_clm_mod, only : set_clm_statevec #endif - use enkf_clm_mod, only : set_clm_statevec use iso_C_binding, only : c_int implicit none From 900a7a427068baa45358fcd3dbddae0e86c622db Mon Sep 17 00:00:00 2001 From: Johannes Keller Date: Thu, 28 May 2026 16:49:18 +0200 Subject: [PATCH 5/9] fix COMM_model_clm usage to CLMSA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in eCLM-ParFlow-PDAF compilatin: ``` eclm/enkf_clm_5.F90:71:25: 71 | use enkf_clm_mod, only: COMM_model_clm | 1 Error: Symbol ‘comm_model_clm’ referenced at (1) not found in module ‘enkf_clm_mod’ ``` --- interface/model/eclm/enkf_clm_5.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/model/eclm/enkf_clm_5.F90 b/interface/model/eclm/enkf_clm_5.F90 index c4f647410..ca5214836 100644 --- a/interface/model/eclm/enkf_clm_5.F90 +++ b/interface/model/eclm/enkf_clm_5.F90 @@ -68,8 +68,8 @@ subroutine clm_init(finname, pdaf_id, pdaf_max, mype) bind(C,name="clm_init") !!<< TSMP PDAF comment out end !!>> TSMP PDAF addition beginning use, intrinsic :: iso_C_binding, only: c_char, c_int - use enkf_clm_mod, only: COMM_model_clm #if defined CLMSA + use enkf_clm_mod, only: COMM_model_clm use enkf_clm_mod, only: define_clm_statevec #endif use clm_varcon, only: averaging_var From a8696277092365a7657789910c1b6ca1daf2b3e3 Mon Sep 17 00:00:00 2001 From: Johannes Keller Date: Thu, 28 May 2026 17:37:23 +0200 Subject: [PATCH 6/9] put OMI interface under CLMSA flag currently OMI interface is only available for CLM-observations in CLMSA simulations. --- interface/framework/assimilate_pdaf.F90 | 4 ++++ interface/framework/callback_obs_pdafomi.F90 | 2 ++ interface/framework/mod_read_obs.F90 | 4 ++-- interface/framework/next_observation_pdaf.F90 | 2 ++ interface/framework/obs_GRACE_pdafomi.F90 | 2 ++ interface/framework/obs_SM_pdafomi.F90 | 2 ++ 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/interface/framework/assimilate_pdaf.F90 b/interface/framework/assimilate_pdaf.F90 index 5492ef2f3..36fadc8ea 100644 --- a/interface/framework/assimilate_pdaf.F90 +++ b/interface/framework/assimilate_pdaf.F90 @@ -46,12 +46,14 @@ SUBROUTINE assimilate_pdaf() USE mod_assimilation, & ! Variables for assimilation ONLY: filtertype USE mod_assimilation, ONLY: use_omi +#ifdef CLMSA #ifdef CLMFIVE USE PDAF_interfaces_module, & ! Check consistency of PDAF calls ONLY: PDAFomi_assimilate_local, PDAFomi_assimilate_global, & PDAFomi_assimilate_lenkf, PDAF_get_localfilter, & PDAFomi_assimilate_enkf_nondiagR, & PDAFomi_assimilate_global_nondiagR, PDAFomi_assimilate_local_nondiagR +#endif #endif IMPLICIT NONE @@ -134,6 +136,7 @@ SUBROUTINE assimilate_pdaf() ! ********************************* OMI: IF (use_omi) THEN +#ifdef CLMSA #ifdef CLMFIVE CALL PDAF_get_localfilter(localfilter) @@ -167,6 +170,7 @@ SUBROUTINE assimilate_pdaf() ENDIF ENDIF +#endif #endif ELSE OMI diff --git a/interface/framework/callback_obs_pdafomi.F90 b/interface/framework/callback_obs_pdafomi.F90 index 354009363..8c988d1c7 100644 --- a/interface/framework/callback_obs_pdafomi.F90 +++ b/interface/framework/callback_obs_pdafomi.F90 @@ -32,6 +32,7 @@ ! Author: Yorck Ewerdwalbesloh +#ifdef CLMSA #ifdef CLMFIVE SUBROUTINE init_dim_obs_pdafomi(step, dim_obs) @@ -365,3 +366,4 @@ SUBROUTINE deallocate_obs_pdafomi() END SUBROUTINE deallocate_obs_pdafomi #endif +#endif diff --git a/interface/framework/mod_read_obs.F90 b/interface/framework/mod_read_obs.F90 index 46c0d0f99..2a4650d9d 100755 --- a/interface/framework/mod_read_obs.F90 +++ b/interface/framework/mod_read_obs.F90 @@ -837,6 +837,7 @@ subroutine check(status) end subroutine check +#ifdef CLMSA #ifdef CLMFIVE !> @author Anne Springer, adaptation for TSMP2 by Yorck Ewerdwalbesloh !> @date 04.12.2023 @@ -888,7 +889,6 @@ subroutine check_n_observationfile_set_zero(fn,nn) end if end subroutine check_n_observationfile_set_zero -#endif !> @author Yorck Ewerdwalbesloh !> @date 29.10.2025 @@ -947,7 +947,6 @@ subroutine check_n_observationfile_next_type(fn, obs_type_str) end subroutine check_n_observationfile_next_type -#ifdef CLMFIVE !> @author Yorck Ewerdwalbesloh !> @date 29.10.2025 !> @brief Update observation type for next assimilation cycle @@ -1188,6 +1187,7 @@ subroutine domain_def_clm(lon_clmobs, lat_clmobs, dim_obs, & end subroutine domain_def_clm #endif +#endif end module mod_read_obs diff --git a/interface/framework/next_observation_pdaf.F90 b/interface/framework/next_observation_pdaf.F90 index d22c80fa1..747582610 100644 --- a/interface/framework/next_observation_pdaf.F90 +++ b/interface/framework/next_observation_pdaf.F90 @@ -65,6 +65,7 @@ SUBROUTINE next_observation_pdaf(stepnow, nsteps, doexit, time) USE mod_assimilation, ONLY: use_omi use mod_read_obs, & only: check_n_observationfile, check_n_observationfile_da_interval +#ifdef CLMSA #ifdef CLMFIVE use mod_read_obs, only: check_n_observationfile_set_zero use mod_read_obs, only: check_n_observationfile_next_type @@ -73,6 +74,7 @@ SUBROUTINE next_observation_pdaf(stepnow, nsteps, doexit, time) use clm_varcon, only: set_averaging_to_zero use clm_varcon, only: ispval use enkf_clm_mod, only: clmupdate_tws +#endif #endif IMPLICIT NONE diff --git a/interface/framework/obs_GRACE_pdafomi.F90 b/interface/framework/obs_GRACE_pdafomi.F90 index 149a45814..8a5fc94cc 100644 --- a/interface/framework/obs_GRACE_pdafomi.F90 +++ b/interface/framework/obs_GRACE_pdafomi.F90 @@ -50,6 +50,7 @@ !! * 2019-06 - Lars Nerger - Initial code !! * Later revisions - see repository log !! +#ifdef CLMSA #ifdef CLMFIVE MODULE obs_GRACE_pdafomi @@ -1419,6 +1420,7 @@ end subroutine deallocate_obs_GRACE END MODULE obs_GRACE_pdafomi #endif +#endif diff --git a/interface/framework/obs_SM_pdafomi.F90 b/interface/framework/obs_SM_pdafomi.F90 index 7cc57dc9b..69bce5c27 100644 --- a/interface/framework/obs_SM_pdafomi.F90 +++ b/interface/framework/obs_SM_pdafomi.F90 @@ -54,6 +54,7 @@ ! Author: Yorck Ewerdwalbesloh, adaptations of original implementations of TSMP2-PDAF interface for OMI framework +#ifdef CLMSA #ifdef CLMFIVE MODULE obs_SM_pdafomi @@ -1402,3 +1403,4 @@ end subroutine deallocate_obs_SM END MODULE obs_SM_pdafomi #endif +#endif From 498a51ee319053ba879b6f0f7c06327be6174c8a Mon Sep 17 00:00:00 2001 From: Johannes Keller Date: Thu, 28 May 2026 17:46:44 +0200 Subject: [PATCH 7/9] put OMI interface under CLMSA flag II fix in init_pdaf_parse.F90 --- interface/framework/init_pdaf_parse.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/framework/init_pdaf_parse.F90 b/interface/framework/init_pdaf_parse.F90 index 1a15295a7..ad97dbc1d 100644 --- a/interface/framework/init_pdaf_parse.F90 +++ b/interface/framework/init_pdaf_parse.F90 @@ -59,12 +59,10 @@ SUBROUTINE init_pdaf_parse() use mod_assimilation,& only: cradius_GRACE, sradius_GRACE, & cradius_SM, sradius_SM +#ifdef CLMSA #ifdef CLMFIVE use obs_GRACE_pdafomi, only: rms_obs_GRACE use obs_SM_pdafomi, only: rms_obs_SM -#endif -#if defined CLMSA -#ifdef CLMFIVE use enkf_clm_mod, only: use_omi_model #endif #endif @@ -99,6 +97,7 @@ SUBROUTINE init_pdaf_parse() handle = 'rms_obs' ! Assumed uniform RMS error of the observations CALL parse(handle, rms_obs) +#ifdef CLMSA #ifdef CLMFIVE rms_obs_GRACE = rms_obs ! backward compatibility handle = 'rms_obs_GRACE' ! RMS error for GRACE observations @@ -109,6 +108,7 @@ SUBROUTINE init_pdaf_parse() ! rms_obs_C = rms_obs ! backward compatibility ! handle = 'rms_obs_C' ! RMS error for C observations ! CALL parse(handle, rms_obs_C) +#endif #endif handle = 'dim_obs' ! Number of observations From 661eee3a11cc7e35a8b6fc6104566c387342d4a3 Mon Sep 17 00:00:00 2001 From: Johannes Keller Date: Thu, 28 May 2026 18:01:50 +0200 Subject: [PATCH 8/9] put OMI interface under CLMSA flag III fix in prepoststep_ens_pdaf.F90 --- interface/framework/prepoststep_ens_pdaf.F90 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/interface/framework/prepoststep_ens_pdaf.F90 b/interface/framework/prepoststep_ens_pdaf.F90 index 7ae7fac05..5335fe895 100644 --- a/interface/framework/prepoststep_ens_pdaf.F90 +++ b/interface/framework/prepoststep_ens_pdaf.F90 @@ -75,14 +75,18 @@ SUBROUTINE prepoststep_ens_pdaf(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, & use mod_tsmp, & only: tag_model_parflow, pf_statevecsize, nprocclm, model +#ifdef CLMSA #ifdef CLMFIVE USE mod_assimilation, ONLY: use_omi +#endif #endif IMPLICIT NONE +#ifdef CLMSA #ifdef CLMFIVE external :: deallocate_obs_pdafomi +#endif #endif ! !ARGUMENTS: @@ -275,6 +279,7 @@ SUBROUTINE prepoststep_ens_pdaf(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, & firsttime = .FALSE. end if +#ifdef CLMSA #ifdef CLMFIVE OMI: IF (use_omi) THEN ! deallocate observation arrays for second call of prepoststep if (firsttime_omi) then @@ -285,4 +290,5 @@ SUBROUTINE prepoststep_ens_pdaf(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, & end if end if OMI #endif +#endif END SUBROUTINE prepoststep_ens_pdaf From 7dfc97f5185bb824edb334df25685721346a2b38 Mon Sep 17 00:00:00 2001 From: Johannes Keller Date: Fri, 29 May 2026 13:47:24 +0200 Subject: [PATCH 9/9] add note to issue --- interface/model/eclm/enkf_clm_5.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/model/eclm/enkf_clm_5.F90 b/interface/model/eclm/enkf_clm_5.F90 index b46fa077d..7ab90f152 100644 --- a/interface/model/eclm/enkf_clm_5.F90 +++ b/interface/model/eclm/enkf_clm_5.F90 @@ -117,7 +117,7 @@ subroutine clm_init(finname, pdaf_id, pdaf_max, mype) bind(C,name="clm_init") #if defined COUP_OAS_PFL ! EXPERIMENTAL: For eCLM-ParFlow-PDAF, the whole management of - ! communicators has to be re-traced + ! communicators has to be re-traced, see HPSCTerrSys/pdaf#82 call cime_pre_init1(esmf_logfile_option) #endif !!<< TSMP PDAF addition end