@@ -18,11 +18,9 @@ module GEOS_RouteGridCompMod
1818 use ESMF
1919 use MAPL_Mod
2020 use MAPL_ConstantsMod
21- use ROUTING_MODEL, ONLY: river_routing_lin, river_routing_hyd, ROUTE_DT
21+ use ROUTING_MODEL, ONLY: river_routing_hyd
2222 use reservoirMod, ONLY: RES_STATE, Reservoir
2323 use catch_constants, ONLY: N_pfaf_g = > CATCH_N_PFAFS
24-
25- use , intrinsic :: iso_c_binding
2624
2725 implicit none
2826
@@ -45,16 +43,13 @@ module GEOS_RouteGridCompMod
4543 integer :: myPe
4644 integer :: minCatch
4745 integer :: maxCatch
46+ integer :: route_dt
4847
4948 real , allocatable :: areacat(:) ! m2
5049 real , allocatable :: lengsc(:) ! m
5150 integer , allocatable :: downid(:)
5251
53- real , allocatable :: runoff_acc(:)
54- real , allocatable :: wriver_acc(:)
55- real , allocatable :: wstream_acc(:)
56- real , allocatable :: qoutflow_acc(:)
57- real , allocatable :: qsflow_acc(:)
52+ real , allocatable :: runoff_acc(:)
5853
5954 real , allocatable :: lstr(:) ! m
6055 real , allocatable :: qri_clmt(:) ! m3/s
@@ -341,9 +336,12 @@ subroutine INITIALIZE (GC,IMPORT, EXPORT, CLOCK, RC )
341336 integer :: myPE
342337 integer :: beforeMe, minCatch, maxCatch, i
343338 integer :: n_pfaf_local, nt_global
339+ integer :: ROUTE_DT
344340
345- type (ESMF_Grid) :: tileGrid
346- type (ESMF_Grid) :: newTileGrid, catch_grid
341+ type (ESMF_Grid) :: tileGrid
342+ type (ESMF_Grid) :: newTileGrid, catch_grid
343+ character (len= ESMF_MAXSTR) :: SURFRC
344+ type (ESMF_Config) :: SCF
347345
348346 type (MAPL_MetaComp), pointer :: MAPL
349347 type (MAPL_LocStream) :: locstream, catch_LocStream
@@ -423,6 +421,12 @@ subroutine INITIALIZE (GC,IMPORT, EXPORT, CLOCK, RC )
423421 route% minCatch = minCatch
424422 route% maxCatch = maxCatch
425423
424+ call MAPL_GetResource (MAPL, SURFRC, label = ' SURFRC:' , default = ' GEOS_SurfaceGridComp.rc' , RC= STATUS) ; VERIFY_(STATUS)
425+ SCF = ESMF_ConfigCreate(rc= status) ; VERIFY_(STATUS)
426+ call ESMF_ConfigLoadFile(SCF,SURFRC,rc= status) ; VERIFY_(STATUS)
427+ call MAPL_GetResource (SCF, ROUTE_DT, label= ' RRM_DT:' , DEFAULT= 3600 , RC= STATUS )
428+ route% route_dt = ROUTE_DT
429+
426430 call MAPL_GetResource (MAPL, RIVER_INPUT_FILE, label = ' RIVER_INPUT_FILE:' , default = ' ../input/river_input.nc' , RC= STATUS )
427431 if (MAPL_AM_I_Root()) then
428432 call formatter% open (RIVER_INPUT_FILE, PFIO_READ, _RC)
@@ -504,16 +508,9 @@ subroutine INITIALIZE (GC,IMPORT, EXPORT, CLOCK, RC )
504508
505509 allocate (route% runoff_acc(nt_local), source = 0 .)
506510
507- ! accumulated variables for output
508- allocate (route% wriver_acc(n_pfaf_local),route% wstream_acc(n_pfaf_local),route% qoutflow_acc(n_pfaf_local),route% qsflow_acc(n_pfaf_local))
509- route% wriver_acc = 0 .
510- route% wstream_acc = 0 .
511- route% qoutflow_acc= 0 .
512- route% qsflow_acc = 0 .
513511
514512 ! Initial reservoir module
515513 route% reservoir = Reservoir(layout, trim (RIVER_INPUT_FILE), N_pfaf_g,n_pfaf_local, minCatch,maxCatch,use_res, _RC)
516- allocate (route% reservoir% qres_acc(n_pfaf_local), source = 0.0 )
517514
518515 if (mapl_am_I_root()) print * ," reservoir init success"
519516
@@ -843,11 +840,12 @@ subroutine RUN (GC,IMPORT, EXPORT, CLOCK, RC )
843840 type (MAPL_LocStream) :: LOCSTREAM
844841
845842 integer :: n_pfaf_local, N_CYC
843+ integer :: ROUTE_DT
846844
847845 integer :: I
848846 REAL :: HEARTBEAT
849- REAL , ALLOCATABLE , DIMENSION (:) :: RUNOFF_ACT ,AREACAT_ACT,&
850- LENGSC_ACT, QSFLOW_ACT,QOUTFLOW_ACT,QRES_ACT ,QOUT_CAT
847+ REAL , ALLOCATABLE , DIMENSION (:) :: RUNOFF_IN ,AREACAT_ACT,&
848+ LENGSC_ACT, QSFLOW_OUT,QOUTFLOW_OUT,QRES_OUT ,QOUT_CAT
851849 type (ESMF_Field) :: runoff_src
852850
853851 integer :: ndes, mype
@@ -923,6 +921,7 @@ subroutine RUN (GC,IMPORT, EXPORT, CLOCK, RC )
923921 nt_global = route% nt_global
924922 nt_local = route% nt_local
925923 res = > route% reservoir
924+ ROUTE_DT = route% route_dt
926925
927926 ! get the field from IMPORT
928927 call ESMF_StateGet(IMPORT, ' RUNOFF' , field= runoff_src, RC= STATUS)
@@ -959,16 +958,16 @@ subroutine RUN (GC,IMPORT, EXPORT, CLOCK, RC )
959958 routeHandle= route% routeHandle, rc= rc)
960959 call ESMF_FieldGet(route% field, farrayPtr= arrayPtr, rc= status)
961960 VERIFY_(STATUS)
962- RUNOFF_ACT = arrayPtr * route% areacat/ 1000 .
961+ RUNOFF_IN = arrayPtr * route% areacat/ 1000 .
963962
964963
965964 ! Prepares to conduct routing model
966965 allocate (AREACAT_ACT (n_pfaf_local))
967966 allocate (LENGSC_ACT (n_pfaf_local))
968- allocate (QSFLOW_ACT (n_pfaf_local))
969- allocate (QOUTFLOW_ACT (n_pfaf_local),QRES_ACT (n_pfaf_local),QOUT_CAT(n_pfaf_local))
967+ allocate (QSFLOW_OUT (n_pfaf_local))
968+ allocate (QOUTFLOW_OUT (n_pfaf_local),QRES_OUT (n_pfaf_local),QOUT_CAT(n_pfaf_local))
970969
971- QRES_ACT = 0 .
970+ QRES_OUT = 0 .
972971 LENGSC_ACT = route% lengsc/ 1.e3 ! m->km
973972 AREACAT_ACT= route% areacat/ 1.e6 ! m2->km2
974973
@@ -977,53 +976,33 @@ subroutine RUN (GC,IMPORT, EXPORT, CLOCK, RC )
977976
978977 ! Call river_routing_model
979978 ! ------------------------
980- ! CALL RIVER_ROUTING_LIN (n_pfaf_local, RUNOFF_ACT,AREACAT_ACT,LENGSC_ACT, &
981- ! WSTREAM_ACT,WRIVER_ACT, QSFLOW_ACT,QOUTFLOW_ACT)
982-
983- CALL RIVER_ROUTING_HYD (n_pfaf_local, &
984- RUNOFF_ACT, route% lengsc, route% lstr, &
979+ CALL RIVER_ROUTING_HYD (n_pfaf_local, ROUTE_DT,&
980+ RUNOFF_IN, route% lengsc, route% lstr, &
985981 route% qstr_clmt, route% qri_clmt, route% qin_clmt, &
986982 route% K, route% Kstr, &
987983 WSTREAM,WRIVER, &
988- QSFLOW_ACT,QOUTFLOW_ACT)
989- ! Call reservoir module
984+ QSFLOW_OUT,QOUTFLOW_OUT)
990985
991- call res% calc( QOUTFLOW_ACT, QRES_ACT, WRES, real (route_dt), _RC)
992- QOUT_CAT = QOUTFLOW_ACT
993- where (res% active_res== 1 ) QOUT_CAT= QRES_ACT
986+ ! Call reservoir module
987+ call res% calc( QOUTFLOW_OUT, QRES_OUT, WRES, real (route_dt), _RC)
988+ QOUT_CAT = QOUTFLOW_OUT
989+ where (res% active_res== 1 ) QOUT_CAT= QRES_OUT
994990 allocate (QINFLOW_LOCAL(n_pfaf_local))
995991 call exchange_water(QOUT_CAT, QINFLOW_LOCAL, _RC)
996992 WRIVER = WRIVER + QINFLOW_LOCAL* real (route_dt)
997993
998994 ! Check balance if needed
999995 ! call check_balance(route,n_pfaf_local,nt_local,runoff_acc,WRIVER_ACT,WSTREAM_ACT,WTOT_BEFORE,RUNOFF_ACT,QINFLOW_LOCAL,QOUT_CAT,FirstTime,yr_s,mon_s)
1000996
1001- ! Update accumulated variables for output
1002- nstep_per_day = 86400 / route_dt
1003-
1004- route% wriver_acc = route% wriver_acc + WRIVER / real (nstep_per_day)
1005- route% wstream_acc = route% wstream_acc + WSTREAM / real (nstep_per_day)
1006- route% qoutflow_acc = route% qoutflow_acc + QOUTFLOW_ACT/ real (nstep_per_day)
1007- route% qsflow_acc = route% qsflow_acc + QSFLOW_ACT / real (nstep_per_day)
1008-
1009- res% qres_acc = res% qres_acc + QRES_ACT / real (nstep_per_day)
1010-
1011- if (associated (QSFLOW)) QSFLOW = QSFLOW_ACT
1012- if (associated (QOUTFLOW)) QOUTFLOW = QOUTFLOW_ACT
997+ if (associated (QSFLOW)) QSFLOW = QSFLOW_OUT
998+ if (associated (QOUTFLOW)) QOUTFLOW = QOUTFLOW_OUT
1013999 if (associated (QRES)) then
10141000 _ASSERT(use_res, " Set use_res be true to get QRES export" )
1015- QRES = QRES_ACT
1001+ QRES = QRES_OUT
10161002 endif
1017- deallocate (RUNOFF_ACT ,AREACAT_ACT,LENGSC_ACT,QOUTFLOW_ACT ,QINFLOW_LOCAL,QSFLOW_ACT ,WTOT_BEFORE,QRES_ACT ,QOUT_CAT)
1003+ deallocate (RUNOFF_IN ,AREACAT_ACT,LENGSC_ACT,QOUTFLOW_OUT ,QINFLOW_LOCAL,QSFLOW_OUT ,WTOT_BEFORE,QRES_OUT ,QOUT_CAT)
10181004
10191005 route% runoff_acc = 0 .
1020- if (HH == 23 ) then
1021- route% wriver_acc = 0 .
1022- route% wstream_acc = 0 .
1023- route% qoutflow_acc = 0 .
1024- route% qsflow_acc = 0 .
1025- res% qres_acc = 0 .
1026- endif
10271006 else
10281007
10291008 route% runoff_acc = route% runoff_acc + RUNOFF_SRC0
0 commit comments