diff --git a/interface/framework/assimilate_pdaf.F90 b/interface/framework/assimilate_pdaf.F90 index 3afcd201..4784b07d 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() END IF END IF +#endif #endif ELSE OMI diff --git a/interface/framework/callback_obs_pdafomi.F90 b/interface/framework/callback_obs_pdafomi.F90 index c34031d3..05cfa953 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/init_pdaf_parse.F90 b/interface/framework/init_pdaf_parse.F90 index 9a3356c3..09025113 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 diff --git a/interface/framework/mod_read_obs.F90 b/interface/framework/mod_read_obs.F90 index 51d2c59b..af734d79 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 7f246c4d..ba4c043a 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 657c7def..47dc8e1d 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 @@ -1420,6 +1421,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 e6c10b81..4a5d1439 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 @@ -1403,3 +1404,4 @@ end subroutine deallocate_obs_SM END MODULE obs_SM_pdafomi #endif +#endif diff --git a/interface/framework/prepoststep_ens_pdaf.F90 b/interface/framework/prepoststep_ens_pdaf.F90 index 0c8b97ba..7814b31b 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 diff --git a/interface/model/eclm/enkf_clm_5.F90 b/interface/model/eclm/enkf_clm_5.F90 index b383c28b..7ab90f15 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 @@ -108,10 +108,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, see HPSCTerrSys/pdaf#82 + call cime_pre_init1(esmf_logfile_option) +#endif !!<< TSMP PDAF addition end end_count = shr_sys_irtc(irtc_rate) @@ -203,10 +211,12 @@ 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 : cleanup_clm_statevec use enkf_clm_mod, only : define_clm_statevec use enkf_clm_mod, only : set_clm_statevec use enkf_clm_mod, only : use_omi_model +#endif use, intrinsic :: iso_C_binding, only : c_int implicit none @@ -242,7 +252,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