Skip to content

Commit 43eb07e

Browse files
authored
eCLM-ParFlow related fixes in PDAF interface (#30)
Adding `CLMSA` conditions on code that relies on CLM-module (not used in eCLM-ParFlow-PDAF).
1 parent 46dc967 commit 43eb07e

9 files changed

Lines changed: 36 additions & 6 deletions

interface/framework/assimilate_pdaf.F90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ SUBROUTINE assimilate_pdaf()
4646
USE mod_assimilation, & ! Variables for assimilation
4747
ONLY: filtertype
4848
USE mod_assimilation, ONLY: use_omi
49+
#ifdef CLMSA
4950
#ifdef CLMFIVE
5051
USE PDAF_interfaces_module, & ! Check consistency of PDAF calls
5152
ONLY: PDAFomi_assimilate_local, PDAFomi_assimilate_global, &
5253
PDAFomi_assimilate_lenkf, PDAF_get_localfilter, &
5354
PDAFomi_assimilate_enkf_nondiagR, &
5455
PDAFomi_assimilate_global_nondiagR, PDAFomi_assimilate_local_nondiagR
56+
#endif
5557
#endif
5658

5759
IMPLICIT NONE
@@ -134,6 +136,7 @@ SUBROUTINE assimilate_pdaf()
134136
! *********************************
135137

136138
OMI: IF (use_omi) THEN
139+
#ifdef CLMSA
137140
#ifdef CLMFIVE
138141
CALL PDAF_get_localfilter(localfilter)
139142

@@ -167,6 +170,7 @@ SUBROUTINE assimilate_pdaf()
167170
END IF
168171

169172
END IF
173+
#endif
170174
#endif
171175
ELSE OMI
172176

interface/framework/callback_obs_pdafomi.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
! Author: Yorck Ewerdwalbesloh
3434

35+
#ifdef CLMSA
3536
#ifdef CLMFIVE
3637
SUBROUTINE init_dim_obs_pdafomi(step, dim_obs)
3738

@@ -365,3 +366,4 @@ SUBROUTINE deallocate_obs_pdafomi()
365366
END SUBROUTINE deallocate_obs_pdafomi
366367

367368
#endif
369+
#endif

interface/framework/init_pdaf_parse.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ SUBROUTINE init_pdaf_parse()
5959
use mod_assimilation,&
6060
only: cradius_GRACE, sradius_GRACE, &
6161
cradius_SM, sradius_SM
62+
#ifdef CLMSA
6263
#ifdef CLMFIVE
6364
use obs_GRACE_pdafomi, only: rms_obs_GRACE
6465
use obs_SM_pdafomi, only: rms_obs_SM
65-
#endif
66-
#if defined CLMSA
67-
#ifdef CLMFIVE
6866
use enkf_clm_mod, only: use_omi_model
6967
#endif
7068
#endif
@@ -99,6 +97,7 @@ SUBROUTINE init_pdaf_parse()
9997
handle = "rms_obs" ! Assumed uniform RMS error of the observations
10098
CALL parse(handle, rms_obs)
10199

100+
#ifdef CLMSA
102101
#ifdef CLMFIVE
103102
rms_obs_GRACE = rms_obs ! backward compatibility
104103
handle = "rms_obs_GRACE" ! RMS error for GRACE observations
@@ -109,6 +108,7 @@ SUBROUTINE init_pdaf_parse()
109108
! rms_obs_C = rms_obs ! backward compatibility
110109
! handle = 'rms_obs_C' ! RMS error for C observations
111110
! CALL parse(handle, rms_obs_C)
111+
#endif
112112
#endif
113113

114114
handle = "dim_obs" ! Number of observations

interface/framework/mod_read_obs.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ subroutine check(status)
837837
end subroutine check
838838

839839

840+
#ifdef CLMSA
840841
#ifdef CLMFIVE
841842
!> @author Anne Springer, adaptation for TSMP2 by Yorck Ewerdwalbesloh
842843
!> @date 04.12.2023
@@ -888,7 +889,6 @@ subroutine check_n_observationfile_set_zero(fn,nn)
888889
end if
889890

890891
end subroutine check_n_observationfile_set_zero
891-
#endif
892892

893893
!> @author Yorck Ewerdwalbesloh
894894
!> @date 29.10.2025
@@ -947,7 +947,6 @@ subroutine check_n_observationfile_next_type(fn, obs_type_str)
947947
end subroutine check_n_observationfile_next_type
948948

949949

950-
#ifdef CLMFIVE
951950
!> @author Yorck Ewerdwalbesloh
952951
!> @date 29.10.2025
953952
!> @brief Update observation type for next assimilation cycle
@@ -1188,6 +1187,7 @@ subroutine domain_def_clm(lon_clmobs, lat_clmobs, dim_obs, &
11881187

11891188
end subroutine domain_def_clm
11901189
#endif
1190+
#endif
11911191

11921192

11931193
end module mod_read_obs

interface/framework/next_observation_pdaf.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ SUBROUTINE next_observation_pdaf(stepnow, nsteps, doexit, time)
6565
USE mod_assimilation, ONLY: use_omi
6666
use mod_read_obs, &
6767
only: check_n_observationfile, check_n_observationfile_da_interval
68+
#ifdef CLMSA
6869
#ifdef CLMFIVE
6970
use mod_read_obs, only: check_n_observationfile_set_zero
7071
use mod_read_obs, only: check_n_observationfile_next_type
@@ -73,6 +74,7 @@ SUBROUTINE next_observation_pdaf(stepnow, nsteps, doexit, time)
7374
use clm_varcon, only: set_averaging_to_zero
7475
use clm_varcon, only: ispval
7576
use enkf_clm_mod, only: clmupdate_tws
77+
#endif
7678
#endif
7779
IMPLICIT NONE
7880

interface/framework/obs_GRACE_pdafomi.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
!! * 2019-06 - Lars Nerger - Initial code
5151
!! * Later revisions - see repository log
5252
!!
53+
#ifdef CLMSA
5354
#ifdef CLMFIVE
5455
MODULE obs_GRACE_pdafomi
5556

@@ -1420,6 +1421,7 @@ end subroutine deallocate_obs_GRACE
14201421

14211422
END MODULE obs_GRACE_pdafomi
14221423
#endif
1424+
#endif
14231425

14241426

14251427

interface/framework/obs_SM_pdafomi.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
! Author: Yorck Ewerdwalbesloh, adaptations of original implementations of TSMP2-PDAF interface for OMI framework
5555

5656

57+
#ifdef CLMSA
5758
#ifdef CLMFIVE
5859
MODULE obs_SM_pdafomi
5960

@@ -1403,3 +1404,4 @@ end subroutine deallocate_obs_SM
14031404

14041405
END MODULE obs_SM_pdafomi
14051406
#endif
1407+
#endif

interface/framework/prepoststep_ens_pdaf.F90

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,18 @@ SUBROUTINE prepoststep_ens_pdaf(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, &
7575
use mod_tsmp, &
7676
only: tag_model_parflow, pf_statevecsize, nprocclm, model
7777

78+
#ifdef CLMSA
7879
#ifdef CLMFIVE
7980
USE mod_assimilation, ONLY: use_omi
81+
#endif
8082
#endif
8183

8284
IMPLICIT NONE
8385

86+
#ifdef CLMSA
8487
#ifdef CLMFIVE
8588
external :: deallocate_obs_pdafomi
89+
#endif
8690
#endif
8791

8892
! !ARGUMENTS:
@@ -275,6 +279,7 @@ SUBROUTINE prepoststep_ens_pdaf(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, &
275279
firsttime = .FALSE.
276280
end if
277281

282+
#ifdef CLMSA
278283
#ifdef CLMFIVE
279284
OMI: IF (use_omi) THEN ! deallocate observation arrays for second call of prepoststep
280285
if (firsttime_omi) then
@@ -285,4 +290,5 @@ SUBROUTINE prepoststep_ens_pdaf(step, dim_p, dim_ens, dim_ens_p, dim_obs_p, &
285290
end if
286291
end if OMI
287292
#endif
293+
#endif
288294
END SUBROUTINE prepoststep_ens_pdaf

interface/model/eclm/enkf_clm_5.F90

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ subroutine clm_init(finname, pdaf_id, pdaf_max, mype) bind(C,name="clm_init")
6868
!!<< TSMP PDAF comment out end
6969
!!>> TSMP PDAF addition beginning
7070
use, intrinsic :: iso_C_binding, only: c_char, c_int
71-
use enkf_clm_mod, only: COMM_model_clm
7271
#if defined CLMSA
72+
use enkf_clm_mod, only: COMM_model_clm
7373
use enkf_clm_mod, only: define_clm_statevec
7474
#endif
7575
use clm_varcon, only: averaging_var
@@ -108,10 +108,18 @@ subroutine clm_init(finname, pdaf_id, pdaf_max, mype) bind(C,name="clm_init")
108108
!!>> TSMP PDAF comment out beginning
109109
! call cime_pre_init1(esmf_logfile_option)
110110
!!>> TSMP PDAF addition beginning
111+
#if defined CLMSA
111112
call cime_pre_init1(esmf_logfile_option, &
112113
COMM_model_clm, &
113114
pdaf_id=pdaf_id, &
114115
pdaf_max=pdaf_max)
116+
#endif
117+
118+
#if defined COUP_OAS_PFL
119+
! EXPERIMENTAL: For eCLM-ParFlow-PDAF, the whole management of
120+
! communicators has to be re-traced, see HPSCTerrSys/pdaf#82
121+
call cime_pre_init1(esmf_logfile_option)
122+
#endif
115123
!!<< TSMP PDAF addition end
116124

117125
end_count = shr_sys_irtc(irtc_rate)
@@ -203,10 +211,12 @@ end subroutine clm_init
203211
!--------------------------------------------------------------------------
204212
subroutine clm_advance(ntstep, tstartcycle, mype) bind(C,name="clm_advance")
205213
use cime_comp_mod, only : cime_run
214+
#if defined CLMSA
206215
use enkf_clm_mod, only : cleanup_clm_statevec
207216
use enkf_clm_mod, only : define_clm_statevec
208217
use enkf_clm_mod, only : set_clm_statevec
209218
use enkf_clm_mod, only : use_omi_model
219+
#endif
210220
use, intrinsic :: iso_C_binding, only : c_int
211221

212222
implicit none
@@ -242,7 +252,9 @@ subroutine clm_finalize() bind(C,name="clm_finalize")
242252

243253
! use ESMF, only : ESMF_Initialize, ESMF_Finalize
244254
use cime_comp_mod, only : cime_final
255+
#if defined CLMSA
245256
use enkf_clm_mod, only : cleanup_clm_statevec
257+
#endif
246258

247259
implicit none
248260

0 commit comments

Comments
 (0)