Skip to content

Commit 746db40

Browse files
committed
allowing to specify multiple tracers in control file and reading tracer names
1 parent f4151be commit 746db40

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

route/build/src/globalData.f90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,12 @@ MODULE globalData
252252
real(dp), allocatable, public :: basinEvapo_main(:) ! HRU evaporation array (m/s) for mainstem
253253
real(dp), allocatable, public :: basinPrecip_trib(:) ! HRU precipitation array (m/s) for tributaries
254254
real(dp), allocatable, public :: basinPrecip_main(:) ! HRU precipitation array (m/s) for mainstem
255-
! solute (tracer) data
255+
256+
! solute (tracer) data
256257
integer(i4b) :: nTracer ! number of tracers
257258
real(dp), allocatable, public :: basinSolute_trib(:,:) ! HRU constituent array [nhru, nTracer] (mg/s) for tributaries
258259
real(dp), allocatable, public :: basinSolute_main(:,:) ! HRU constituent array [nhru, nTracer] (mg/s) for mainstem
260+
259261
! seg water management fluxes and target volume
260262
type(wm), public :: wm_data ! SEG flux and target vol data structure for one time step for river network
261263
real(dp), allocatable, public :: flux_wm_trib(:) ! SEG flux array (m3/s) for tributaries

route/build/src/read_control.f90

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ SUBROUTINE read_control(ctl_fname, err, message)
3737
USE globalData, ONLY: idxSUM,idxIRF,idxKWT, &
3838
idxKW,idxMC,idxDW
3939
USE globalData, ONLY: runMode ! mizuRoute run mode: standalone, cesm-coupling
40+
USE globalData, ONLY: nTracer ! number of active tracers
4041
! index of named variables in each structure
4142
USE var_lookup, ONLY: ixHRU
4243
USE var_lookup, ONLY: ixHRU2SEG
@@ -48,6 +49,7 @@ SUBROUTINE read_control(ctl_fname, err, message)
4849
! external subroutines
4950
USE ascii_utils, ONLY: file_open ! open file (performs a few checks as well)
5051
USE ascii_utils, ONLY: get_vlines ! get a list of character strings from non-comment lines
52+
USE ascii_utils, ONLY: split_line ! split string into sub-strings with delimiter
5153
USE ascii_utils, ONLY: lower ! convert string to lower case
5254
USE nr_utils, ONLY: char2int ! convert integer number to a array containing individual digits
5355

@@ -61,7 +63,7 @@ SUBROUTINE read_control(ctl_fname, err, message)
6163
character(len=strLen) :: cName,cData ! name and data from cLines(iLine)
6264
character(len=strLen) :: cLength,cTime ! length and time units
6365
character(len=strLen) :: cMass ! mass units needed only when tracer is on
64-
character(len=strLen) :: vname ! multiple variable names with semi-colon delimited
66+
character(len=strLen),allocatable :: vname_tmp(:) ! multiple variable names with semi-colon delimited
6567
logical(lgt) :: isGeneric ! temporal logical scalar
6668
logical(lgt) :: onlyOneRouting ! temporal logical scalar
6769
integer(i4b) :: ipos ! index of character string
@@ -159,7 +161,7 @@ SUBROUTINE read_control(ctl_fname, err, message)
159161
case('<vname_qsim>'); vname_qsim = trim(cData) ! name of runoff variable
160162
case('<vname_evapo>'); vname_evapo = trim(cData) ! name of actual evapoartion variable
161163
case('<vname_precip>'); vname_precip = trim(cData) ! name of precipitation variable
162-
case('<vname_solute>'); vname = trim(cData) ! name of solute mass flux variables (up to 10 is ok)
164+
case('<vname_solute>'); vname_tmp = split_line(trim(cData),delim=';,:') ! name of solute mass flux variables (up to 10 is ok), acceptable delimiter: : , :
163165
case('<vname_time>'); vname_time = trim(cData) ! name of time variable in the runoff file
164166
case('<vname_hruid>'); vname_hruid = trim(cData) ! name of the HRU id
165167
case('<dname_time>'); dname_time = trim(cData) ! name of time variable in the runoff file
@@ -383,6 +385,9 @@ SUBROUTINE read_control(ctl_fname, err, message)
383385
end do ! looping through lines in the control file
384386

385387
! ---------- Perform minor processing and checking control variables ----------------------------------------
388+
! extract tracer names into vname_solute
389+
nTracer=size(vname_tmp)
390+
vname_solute(1:nTracer)=vname_tmp(:)
386391

387392
! ---------- directory option ---------------------------------------------------------------------
388393
if (trim(restart_dir)==charMissing) then

0 commit comments

Comments
 (0)