Skip to content

Commit 1f3c1ee

Browse files
Add river routing grid comp (#145)
Add river routing grid comp
2 parents b241d31 + d9773a7 commit 1f3c1ee

7 files changed

Lines changed: 168 additions & 34 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Added
1313

14+
- Added support for river routing.
1415
- Added optional NetCDF4 output mode for ObsFcstAna, including NetCDF metadata and runtime context. Changed namelist variable "out_ObsFcstAna" from logical to integer.
1516

1617
### Changed

‎CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ esma_add_library(${this}
1111
SRCS GEOS_LdasGridComp.F90
1212
SUBCOMPONENTS ${alldirs}
1313
SUBDIRS LDAS_Shared
14-
DEPENDENCIES GEOSland_GridComp GEOSlandice_GridComp makebcs MAPL
14+
DEPENDENCIES GEOSland_GridComp GEOSlandice_GridComp GEOSroute_GridComp makebcs MAPL
1515
INCLUDES ${INC_ESMF})
1616

1717
esma_add_subdirectory(GEOSldas_App)

‎GEOS_LdasGridComp.F90‎

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module GEOS_LdasGridCompMod
1515
use GEOS_EnsGridCompMod, only: EnsSetServices => SetServices
1616
use GEOS_LandAssimGridCompMod, only: LandAssimSetServices => SetServices
1717
use GEOS_LandiceGridCompMod, only: LandiceSetServices => SetServices
18+
use GEOS_RouteGridCompMod, only: RouteSetServices => SetServices
1819

1920
use LDAS_TileCoordType, only: tile_coord_type , T_TILECOORD_STATE, TILECOORD_WRAP
2021
use LDAS_TileCoordType, only: grid_def_type, io_grid_def_type, operator (==)
@@ -51,6 +52,7 @@ module GEOS_LdasGridCompMod
5152
! All children
5253
integer,allocatable :: LAND(:)
5354
integer,allocatable :: LANDICE(:)
55+
integer,allocatable :: ROUTE(:)
5456
integer,allocatable :: LANDPERT(:)
5557
integer,allocatable :: METFORCE(:)
5658
integer :: ENSAVG, LANDASSIM
@@ -62,6 +64,7 @@ module GEOS_LdasGridCompMod
6264
logical :: ensemble_forcing ! switch between deterministic and ensemble forcing
6365
logical :: with_landice ! true if landice tiles requested by config
6466
logical :: with_land ! true if land tiles requested by config
67+
integer :: RUN_ROUTE ! 0:, no river routing, 1: routing w/o reservoirs, 2: routing w/ reservoirs
6568

6669
contains
6770

@@ -143,13 +146,15 @@ subroutine SetServices(gc, rc)
143146
!create ensemble children
144147
call MAPL_GetObjectFromGC(gc, MAPL, rc=status)
145148
VERIFY_(status)
146-
call MAPL_GetResource ( MAPL, NUM_ENSEMBLE, Label="NUM_LDAS_ENSEMBLE:", DEFAULT=1, RC=STATUS)
149+
call MAPL_GetResource ( MAPL, NUM_ENSEMBLE, Label="NUM_LDAS_ENSEMBLE:", DEFAULT=1, RC=STATUS)
147150
VERIFY_(STATUS)
148-
call MAPL_GetResource ( MAPL, ens_id_width, Label="ENS_ID_WIDTH:", DEFAULT=0, RC=STATUS)
151+
call MAPL_GetResource ( MAPL, ens_id_width, Label="ENS_ID_WIDTH:", DEFAULT=0, RC=STATUS)
149152
VERIFY_(STATUS)
150-
call MAPL_GetResource ( MAPL, FIRST_ENS_ID, Label="FIRST_ENS_ID:", DEFAULT=0, RC=STATUS)
153+
call MAPL_GetResource ( MAPL, RUN_ROUTE, Label="RUN_ROUTE:", DEFAULT=0, RC=STATUS)
154+
VERIFY_(STATUS)
155+
call MAPL_GetResource ( MAPL, FIRST_ENS_ID, Label="FIRST_ENS_ID:", DEFAULT=0, RC=STATUS)
151156
VERIFY_(STATUS)
152-
call MAPL_GetResource ( MAPL, ENS_FORCING_STR, Label="ENSEMBLE_FORCING:", DEFAULT="NO", RC=STATUS)
157+
call MAPL_GetResource ( MAPL, ENS_FORCING_STR, Label="ENSEMBLE_FORCING:", DEFAULT="NO", RC=STATUS)
153158
VERIFY_(STATUS)
154159
ENS_FORCING_STR = ESMF_UtilStringUpperCase(ENS_FORCING_STR, rc=STATUS)
155160
VERIFY_(STATUS)
@@ -174,6 +179,10 @@ subroutine SetServices(gc, rc)
174179
if (any(tile_types == MAPL_LAND )) with_land = .true.
175180
! if (any(tile_types == MAPL_LAKE )) with_lake = .true.
176181

182+
if (NUM_ENSEMBLE>1) then
183+
_ASSERT( .not. (with_landice .or. RUN_ROUTE>0), "Landice and route not supported in ensemble mode.")
184+
endif
185+
177186
call MAPL_GetResource ( MAPL, LAND_ASSIM_STR, Label="LAND_ASSIM:", DEFAULT="NO", RC=STATUS)
178187
VERIFY_(STATUS)
179188
LAND_ASSIM_STR = ESMF_UtilStringUpperCase(LAND_ASSIM_STR, rc=STATUS)
@@ -205,7 +214,10 @@ subroutine SetServices(gc, rc)
205214

206215
if (with_land) allocate(LAND( NUM_ENSEMBLE),LANDPERT(NUM_ENSEMBLE))
207216
if (with_landice) allocate(LANDICE(NUM_ENSEMBLE))
208-
217+
if (RUN_ROUTE >= 1) then
218+
_ASSERT( with_land, "RUNOFF must be from the export of land_gridcomp for now.")
219+
allocate(ROUTE(NUM_ENSEMBLE))
220+
endif
209221
! ens_id_with = 2 + number of digits = total number of chars in ensid_string ("_eXXXX")
210222
!
211223
! Assert ens_id_width<=2+9 so number of digits remains single-digit and "I1" can be
@@ -253,6 +265,12 @@ subroutine SetServices(gc, rc)
253265
LANDICE(i) = MAPL_AddChild(gc, name=childname, ss=LandiceSetServices, rc=status)
254266
VERIFY_(status)
255267
endif
268+
269+
if (RUN_ROUTE >= 1) then
270+
childname='ROUTE'//trim(ensid_string)
271+
ROUTE(i) = MAPL_AddChild(gc, name=childname, ss=RouteSetServices, rc=status)
272+
VERIFY_(status)
273+
endif
256274
enddo
257275

258276
if (with_land) then
@@ -302,6 +320,17 @@ subroutine SetServices(gc, rc)
302320
rc = status &
303321
)
304322
VERIFY_(status)
323+
324+
IF(RUN_ROUTE >= 1) THEN
325+
call MAPL_AddConnectivity ( &
326+
GC ,&
327+
SHORT_NAME = (/'RUNOFF '/) ,& ! RUNOFF = total runoff = surface runoff + baseflow
328+
SRC_ID = LAND(I) ,&
329+
DST_ID = ROUTE(I) ,&
330+
RC=STATUS )
331+
VERIFY_(STATUS)
332+
ENDIF
333+
305334
enddo
306335

307336
if(land_assim .or. mwRTM) then
@@ -788,6 +817,13 @@ subroutine Initialize(gc, import, export, clock, rc)
788817
call MAPL_Set(CHILD_MAPL, LocStream=landice_locstream, rc=status)
789818
VERIFY_(status)
790819
endif
820+
821+
if (RUN_ROUTE >= 1) then
822+
call MAPL_GetObjectFromGC(gcs(ROUTE(i)), CHILD_MAPL, rc=status)
823+
VERIFY_(status) ! CHILD = ens_avg
824+
call MAPL_Set(CHILD_MAPL, LocStream=land_locstream, rc=status)
825+
VERIFY_(status)
826+
endif
791827

792828
enddo
793829

@@ -1016,6 +1052,16 @@ subroutine Run(gc, import, export, clock, rc)
10161052
call MAPL_TimerOff(MAPL, gcnames(igc))
10171053
endif ! with_land_ice
10181054

1055+
if ( RUN_ROUTE >= 1 ) then
1056+
igc = ROUTE(i)
1057+
call MAPL_TimerOn(MAPL, gcnames(igc))
1058+
call ESMF_GridCompRun(gcs(igc), importState=gim(igc), exportState=gex(igc), clock=clock, phase=1, userRC=status)
1059+
VERIFY_(status)
1060+
call ESMF_GridCompRun(gcs(ENSAVG), importState=gex(igc), exportState=gex(ENSAVG), clock=clock,phase=4, userRC=status)
1061+
VERIFY_(status)
1062+
call MAPL_TimerOff(MAPL, gcnames(igc))
1063+
endif ! river-routine
1064+
10191065
if (with_land) then
10201066
! ApplyPrognPert - moved: now before calculating ensemble average that is picked up by land analysis and HISTORY; reichle 28 May 2020
10211067
igc = LANDPERT(i)

‎GEOSens_GridComp/GEOS_EnsGridComp.F90‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,9 +2041,6 @@ subroutine Collect_force_ens(gc, import, export, clock, rc)
20412041
character(len=ESMF_MAXSTR) :: Iam
20422042
character(len=ESMF_MAXSTR) :: comp_name
20432043

2044-
! ESMF variables
2045-
type(ESMF_VM) :: vm
2046-
20472044
! MAPL variables
20482045
type(MAPL_MetaComp), pointer :: MAPL=>null() ! MAPL obj
20492046

@@ -2264,9 +2261,6 @@ subroutine Collect_land_ens(gc, import, export, clock, rc)
22642261
character(len=ESMF_MAXSTR) :: Iam
22652262
character(len=ESMF_MAXSTR) :: comp_name
22662263

2267-
! ESMF variables
2268-
type(ESMF_VM) :: vm
2269-
22702264
! MAPL variables
22712265
type(MAPL_MetaComp), pointer :: MAPL=>null() ! MAPL obj
22722266

‎GEOSldas_App/GEOSldas_HIST.rc‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ COLLECTIONS:
2424
# 'const_2d_lnd_Nx'
2525
# 'tavg24_2d_glc_Nx'
2626
# 'tavg24_1d_glc_Nt'
27+
# 'tavg24_1d_route'
2728
::
2829

2930
# --------------------------------------------------------------------------------------------------
@@ -580,4 +581,20 @@ EASEv2_M36.LM: 1
580581
'WESNBOT' , 'LANDICE' ,
581582
'WESNEXT' , 'LANDICE' ,
582583
::
584+
585+
tavg24_1d_route.descr: 'Catchment-space,Daily,Time-Averaged,Single-level,Runoff Routing Diagnostics',
586+
tavg24_1d_route.nbits: 12,
587+
tavg24_1d_route.template: '%y4%m2%d2_%h2%n2z.nc4',
588+
tavg24_1d_route.archive: '%c/Y%y4',
589+
tavg24_1d_route.format: 'CFIO',
590+
tavg24_1d_route.mode: 'time-averaged',
591+
tavg24_1d_route.frequency: 240000,
592+
tavg24_1d_route.ref_time: 000000,
593+
tavg24_1d_route.fields: 'QSFLOW' , 'ROUTE' ,
594+
'QOUTFLOW' , 'ROUTE' ,
595+
'QRES' , 'ROUTE' ,
596+
'QCAT' , 'ROUTE' ,
597+
'QINFLOW' , 'ROUTE' ,
598+
'QRUNOFF_CAT' , 'ROUTE' ,
599+
::
583600
# ========================== EOF ==============================================================

0 commit comments

Comments
 (0)