@@ -30,7 +30,7 @@ MODULE main_route_module
3030 SUBROUTINE main_route (basinRunoff_in , & ! input: basin (i.e. ,HRU ) runoff (m/ s)
3131 basinEvapo_in, & ! input: basin (i.e.,HRU) evaporation (m/s)
3232 basinPrecip_in, & ! input: basin (i.e.,HRU) precipitation (m/s)
33- basinSolute_in, & ! input: basin (i.e.,HRU) constituent mass fluw (mg/s/m2)
33+ basinSolute_in, & ! input: basin (i.e.,HRU) mass flux of constituent(s) (mg/s/m2)
3434 reachflux_in, & ! input: reach (i.e.,reach) flux (m3/s)
3535 reachvol_in, & ! input: reach (i.e.,reach) target volume for lakes (m3)
3636 ixRchProcessed, & ! input: indices of reach to be routed
@@ -52,7 +52,8 @@ SUBROUTINE main_route(basinRunoff_in, & ! input: basin (i.e.,HRU) runoff (m/s)
5252 USE globalData, ONLY: TSEC ! beginning/ending of simulation time step [sec]
5353 USE globalData, ONLY: simDatetime ! current model datetime
5454 USE globalData, ONLY: rch_routes !
55- USE public_var, ONLY: doesBasinRoute
55+ USE globalData, ONLY: nTracer ! number of active tracers
56+ USE public_var, ONLY: doesBasinRoute ! hillslope routing option
5657 USE public_var, ONLY: is_flux_wm ! logical whether or not fluxes should be passed
5758 USE public_var, ONLY: is_vol_wm ! logical whether or not target volume should be passed
5859 USE public_var, ONLY: qmodOption ! options for streamflow modification (DA)
@@ -62,7 +63,7 @@ SUBROUTINE main_route(basinRunoff_in, & ! input: basin (i.e.,HRU) runoff (m/s)
6263 real (dp), allocatable , intent (in ) :: basinRunoff_in(:) ! basin (i.e.,HRU) runoff (m/s)
6364 real (dp), allocatable , intent (in ) :: basinEvapo_in(:) ! basin (i.e.,HRU) evaporation (m/s)
6465 real (dp), allocatable , intent (in ) :: basinPrecip_in(:) ! basin (i.e.,HRU) precipitation (m/s)
65- real (dp), allocatable , intent (in ) :: basinSolute_in(:) ! basin (i.e.,HRU) constituent (mg/s/m2)
66+ real (dp), allocatable , intent (in ) :: basinSolute_in(:,: ) ! basin (i.e.,HRU) constituent(s) (mg/s/m2)
6667 real (dp), allocatable , intent (in ) :: reachflux_in(:) ! reach (i.e.,reach) flux (m3/s)
6768 real (dp), allocatable , intent (in ) :: reachvol_in(:) ! reach (i.e.,reach) target volume for lakes (m3)
6869 integer (i4b), allocatable , intent (in ) :: ixRchProcessed(:) ! indices of reach to be routed
@@ -78,11 +79,12 @@ SUBROUTINE main_route(basinRunoff_in, & ! input: basin (i.e.,HRU) runoff (m/s)
7879 character (len= strLen) :: cmessage ! error message of downwind routine
7980 real (dp) :: qobs ! observed discharge at a time step and site
8081 real (dp), allocatable :: reachRunoff_local(:) ! reach runoff (m3/s)
81- real (dp), allocatable :: reachSolute_local(:) ! reach constituent (mg/s)
82+ real (dp), allocatable :: reachSolute_local(:,: ) ! reach constituent(s) (mg/s)
8283 real (dp), allocatable :: reachEvapo_local(:) ! reach evaporation (m3/s)
8384 real (dp), allocatable :: reachPrecip_local(:) ! reach precipitation (m3/s)
8485 integer (i4b) :: nSeg ! number of reach to be processed
8586 integer (i4b) :: iSeg ! index of reach
87+ integer (i4b) :: iTracer ! index of tracers
8688 integer (i4b) :: ix,jx ! loop index
8789 integer (i4b), allocatable :: reach_ix(:)
8890 integer (i4b), parameter :: no_mod= 0
@@ -149,16 +151,17 @@ SUBROUTINE main_route(basinRunoff_in, & ! input: basin (i.e.,HRU) runoff (m/s)
149151 if (ierr/= 0 )then ; message= trim (message)// trim (cmessage); return ; endif
150152
151153 if (tracer) then
152- allocate (reachSolute_local(nSeg), source= 0._dp , stat= ierr)
154+ allocate (reachSolute_local(nSeg,nTracer ), source= 0._dp , stat= ierr)
153155 if (ierr/= 0 )then ; message= trim (message)// ' problem allocating arrays for [reachSolute_local]' ; return ; endif
154-
155- call basin2reach_mass(basinSolute_in, & ! input: basin total constitunet (mg/s/m2)
156- NETOPO_in, & ! input: reach topology
157- RPARAM_in, & ! input: reach parameter
158- reachSolute_local, & ! output:total constituent going to reach (mg/s)
159- ierr, cmessage, & ! output: error control
160- ixRchProcessed) ! optional input: indices of reach to be routed
161- if (ierr/= 0 )then ; message= trim (message)// trim (cmessage); return ; endif
156+ do iTracer= 1 ,nTracer
157+ call basin2reach_mass(basinSolute_in(:,iTracer), & ! input: basin total constitunet (mg/s/m2)
158+ NETOPO_in, & ! input: reach topology
159+ RPARAM_in, & ! input: reach parameter
160+ reachSolute_local(:,iTracer), & ! output:total constituent going to reach (mg/s)
161+ ierr, cmessage, & ! output: error control
162+ ixRchProcessed) ! optional input: indices of reach to be routed
163+ if (ierr/= 0 )then ; message= trim (message)// trim (cmessage); return ; endif
164+ end do
162165 end if
163166
164167 if (is_lake_sim) then
@@ -196,7 +199,9 @@ SUBROUTINE main_route(basinRunoff_in, & ! input: basin (i.e.,HRU) runoff (m/s)
196199 RCHFLX_out(ixRchProcessed(iSeg))% BASIN_QI = reachRunoff_local(iSeg)
197200 if (tracer) then
198201 if (RCHFLX_out(ixRchProcessed(iSeg))% BASIN_QI> 0 ) then ! this may cause mass inbalance between input and output. so may need to feed flag to land surface model
199- RCHFLX_out(ixRchProcessed(iSeg))% BASIN_solute_inst = reachSolute_local(iSeg)
202+ do iTracer= 1 ,nTracer
203+ RCHFLX_out(ixRchProcessed(iSeg))% BASIN_solute_inst(iTracer) = reachSolute_local(iSeg,iTracer)
204+ end do
200205 else
201206 RCHFLX_out(ixRchProcessed(iSeg))% BASIN_solute_inst = 0._dp
202207 endif
@@ -218,7 +223,9 @@ SUBROUTINE main_route(basinRunoff_in, & ! input: basin (i.e.,HRU) runoff (m/s)
218223 if (tracer) then
219224 do iSeg = 1 ,nSeg
220225 if (RCHFLX_out(ixRchProcessed(iSeg))% BASIN_QR(1 )>0 ) then
221- RCHFLX_out(ixRchProcessed(iSeg))% BASIN_solute = reachSolute_local(iSeg) ! total constituent going to reach (mg/s)
226+ do iTracer= 1 ,nTracer
227+ RCHFLX_out(ixRchProcessed(iSeg))% BASIN_solute(iTracer) = reachSolute_local(iSeg,iTracer) ! total constituent going to reach (mg/s)
228+ end do
222229 else
223230 RCHFLX_out(ixRchProcessed(iSeg))% BASIN_solute = 0._dp
224231 endif
0 commit comments