Skip to content

Commit c1a54bb

Browse files
authored
Merge pull request #169 from nmizukami/master
v1.2.1
2 parents 7428a63 + 005a372 commit c1a54bb

32 files changed

+2132
-1270
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3953155.svg)](https://doi.org/10.5281/zenodo.3953155)
1+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4395155.svg)](https://doi.org/10.5281/zenodo.4395155)
22
[![Documentation Status](https://readthedocs.org/projects/mizuroute/badge/?version=master)](https://mizuroute.readthedocs.io/en/master/?badge=master)
33

44
# mizuRoute

docs/source/Control_file.rst

+37-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Control file
22
============
33

4-
Control file is a simple text file, mainly defining model control such as simulation time, file name and locations, routing option etc.
4+
Control file is a simple text file, defining various model controls such as simulation time, file names and locations, routing options etc.
55
Variables in control file are read in the beginning of the code (see ``./build/src/read_control.f90``) and
66
saved in fortran variable specified by tag (inside <> in table) and as public variables (see ``./build/src/public_var.f90``) .
7-
Some of such public varialbes have some default values, but most of them are not defined.
7+
Some of control varialbes have their default values, but most of them are not defined.
88
Those undefined variables need to be defined in control file.
99
Other variables in supplement table have their default values but can be also included in control file to overwrite the values.
1010
The order of variables in the control file does not matter. However, grouping variables into similar themes is recommended for readibility.
@@ -19,6 +19,7 @@ Some of rules
1919
* Format: <tag> variable ! comments
2020
* tag is Fortran variable name and cannot be changed and have to be enclosed by <>
2121
* need ! after variable, otherwise getting error.
22+
* Do not leave any lines empty in control file
2223

2324

2425
The following variables (not pre-defined in the code) need to be defined in control file.
@@ -86,12 +87,6 @@ The following variables (not pre-defined in the code) need to be defined in cont
8687
+--------+------------------------+-------------------------------------------------------------------------------------------+
8788
| 2,3 | <dname_data_remap> | dimension name for data |
8889
+--------+------------------------+-------------------------------------------------------------------------------------------+
89-
| 1,2,3 | <restart_write> | restart ouput timing options. N[n]ever, L[l]ast, S[s]pecified. |
90-
+--------+------------------------+-------------------------------------------------------------------------------------------+
91-
| 1,2,3 | <restart_date> | specified restart date in yyyy-mm-dd (hh:mm:ss) if <restart_write> = "Specified" |
92-
+--------+------------------------+-------------------------------------------------------------------------------------------+
93-
| 1,2,3 | <fname_state_in> | input restart netCDF name. If not specified, simulation start with cold start |
94-
+--------+------------------------+-------------------------------------------------------------------------------------------+
9590
| 1,2,3 | <route_opt> | option for routing schemes 0-> both, 1->IRF, 2->KWT, otherwise error |
9691
+--------+------------------------+-------------------------------------------------------------------------------------------+
9792

@@ -120,6 +115,8 @@ Variables that have default values but can be overwritten
120115
+------------------------+------------------------+--------------------------------------------------------------------------+
121116
| <time_units> | From runoff input | specified time units <unit> since yyyy-mm-dd (hh:mm:ss). See note 4 |
122117
+------------------------+------------------------+--------------------------------------------------------------------------+
118+
| <netcdf_format> | netcdf4 | netcdf format for output netcdf. other options: classic, 64bit_offset. |
119+
+------------------------+------------------------+--------------------------------------------------------------------------+
123120

124121
1. River network subset mode.
125122

@@ -138,10 +135,42 @@ Often case, river network data has different variable names than defaults. In th
138135
See :doc:`River parameters <seg_hru_param>`.
139136

140137

138+
Restart options
139+
---------------------
140+
141+
mizuRoute does not write restart netCDF as default. The following control variables are used to control restart dropoff timing and use restart file for continuous run from the previous simulations.
142+
The restart file is written at previous time step to the specified time. In other words, if ``Specified`` is used for <restart_write> and ``1981-01-01-00000`` is specified in <restart_date>, mizuRoute writes restart file
143+
at ``1980-12-31 00:00:00`` for daily time step. The restart file name uses the time stamp at user specified timing. ``Annual``, ``Monthly``, ``Daily`` options also follow This convention.
144+
145+
The restart file name convension: <case_name>.r.yyyy-mm-dd-sssss.nc
146+
147+
148+
+---------------------+---------------------------------------------------------------------------------------------------------+
149+
| tag | Description |
150+
+=====================+=========================================================================================================+
151+
| <restart_dir> | directory for restart files. defualt is <output_dir> |
152+
+---------------------+---------------------------------------------------------------------------------------------------------+
153+
| <restart_write> | restart ouput options. N[n]ever (default), L[l]ast, S[s]pecified, Annual, M[m]onthly, D[d]aily. |
154+
+---------------------+---------------------------------------------------------------------------------------------------------+
155+
| <restart_date> | restart time in yyyy-mm-dd (hh:mm:ss). required if <restart_write> = "Specified" |
156+
+---------------------+---------------------------------------------------------------------------------------------------------+
157+
| <restart_month> | periodic restart month (default 1). Effective if <restart_write>="Annual" |
158+
+---------------------+---------------------------------------------------------------------------------------------------------+
159+
| <restart_day> | periodic restart day (default 1). Effective if <restart_write>="Annual" or "Monthly" |
160+
+---------------------+---------------------------------------------------------------------------------------------------------+
161+
| <restart_hour> | periodic restart hour (default 0). Effective if <restart_write>="Annual", "Monthly", or "Daily" |
162+
+---------------------+---------------------------------------------------------------------------------------------------------+
163+
| <fname_state_in> | input restart netCDF name. If not specified, simulation start with cold start |
164+
+---------------------+---------------------------------------------------------------------------------------------------------+
165+
166+
141167
Output variables
142168
---------------------
143169

144170
The following variables, besides time, basinID (RN_hru ID) and reachID can be output in netCDF. Users can control which variables are output by setting <variable_name> to T or F in control file. All the variables are set to T by default.
171+
The output file name includes a timie stamp at the first time step.
172+
173+
The output file name convension: <case_name>.h.yyyy-mm-dd-sssss.nc
145174

146175

147176
+------------------------+------------------------------------------------------------------------------------------------+

route/build/Makefile

+11-10
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,24 @@ DATATYPES = \
120120
public_var.f90 \
121121
dataTypes.f90 \
122122
var_lookup.f90 \
123+
time_utils.f90 \
124+
datetime_data.f90 \
123125
globalData.f90 \
124126
popMetadat.f90 \
125127
allocation.f90
126128
# define utilities
127129
UTILS = \
128130
nr_utility.f90 \
129131
ascii_util.f90 \
130-
time_utils.f90 \
131132
ncio_utils.f90 \
132133
gamma_func.f90
134+
# initialization
135+
INIT = \
136+
network_topo.f90 \
137+
process_param.f90 \
138+
process_ntopo.f90 \
139+
pfafstetter.f90 \
140+
domain_decomposition.f90
133141
# read/write files
134142
IO = \
135143
remap.f90 \
@@ -143,16 +151,9 @@ IO = \
143151
read_restart.f90 \
144152
write_restart.f90 \
145153
write_simoutput.f90
146-
# initialization
147-
INIT = \
148-
process_time.f90 \
149-
network_topo.f90 \
150-
process_param.f90 \
151-
process_ntopo.f90 \
152-
pfafstetter.f90 \
153-
domain_decomposition.f90
154154
# CORE
155155
CORE = \
156+
model_finalize.f90 \
156157
accum_runoff.f90 \
157158
basinUH.f90 \
158159
irf_route.f90 \
@@ -161,7 +162,7 @@ CORE = \
161162
model_setup.f90
162163

163164
# concatanate model subroutines
164-
TEMP_MODSUB = $(DATATYPES) $(UTILS) $(IO) $(INIT) $(CORE)
165+
TEMP_MODSUB = $(DATATYPES) $(UTILS) $(INIT) $(IO) $(CORE)
165166

166167
# insert appropriate directory name
167168
MODSUB = $(patsubst %, $(F_KORE_DIR)%, $(TEMP_MODSUB))

route/build/src/accum_runoff.f90

+20-26
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ SUBROUTINE accum_runoff(iEns, & ! input: index of runoff ensemble to be
3333
!
3434
! ----------------------------------------------------------------------------------------
3535

36-
USE dataTypes, ONLY: subbasin_omp ! mainstem+tributary data structures
36+
USE dataTypes, ONLY: subbasin_omp ! mainstem+tributary data structures
37+
USE model_finalize, ONLY : handle_err
3738

3839
implicit none
3940
! input
@@ -56,14 +57,9 @@ SUBROUTINE accum_runoff(iEns, & ! input: index of runoff ensemble to be
5657
integer(i4b) :: iTrib, ix ! loop indices
5758
logical(lgt), allocatable :: doRoute(:) ! logical to indicate which reaches are processed
5859
character(len=strLen) :: cmessage ! error message from subroutines
59-
integer*8 :: cr ! rate
60-
integer*8 :: startTime,endTime ! date/time for the start and end of the initialization
61-
real(dp) :: elapsedTime ! elapsed time for the process
6260

6361
ierr=0; message='accum_runoff/'
64-
call system_clock(count_rate=cr)
6562

66-
! check
6763
if (size(NETOPO_in)/=size(RCHFLX_out(iens,:))) then
6864
ierr=20; message=trim(message)//'sizes of NETOPO and RCHFLX mismatch'; return
6965
endif
@@ -84,8 +80,6 @@ SUBROUTINE accum_runoff(iEns, & ! input: index of runoff ensemble to be
8480

8581
nDom = size(river_basin)
8682

87-
call system_clock(startTime)
88-
8983
do ix = 1,nDom
9084
! 1. Route tributary reaches (parallel)
9185
! compute the sum of all upstream runoff at each point in the river network
@@ -107,17 +101,13 @@ SUBROUTINE accum_runoff(iEns, & ! input: index of runoff ensemble to be
107101
if (.not. doRoute(jSeg)) cycle
108102

109103
call accum_qupstream(iens, jSeg, ixDesire, NETOPO_in, RCHFLX_out, ierr, cmessage)
110-
!if(ierr/=0)then; message=trim(message)//trim(cmessage); return; endif
104+
if(ierr/=0) call handle_err(ierr, trim(message)//trim(cmessage))
111105

112106
end do
113107
end do
114108
!$OMP END PARALLEL DO
115109

116-
end do ! looping through stream segments
117-
118-
call system_clock(endTime)
119-
elapsedTime = real(endTime-startTime, kind(dp))/real(cr)
120-
!write(*,"(A,1PG15.7,A)") ' elapsed-time [routing/accum] = ', elapsedTime, ' s'
110+
end do
121111

122112
END SUBROUTINE accum_runoff
123113

@@ -142,40 +132,44 @@ subroutine accum_qupstream(iEns, & ! input: index of runoff ensemble to
142132
integer(i4b), intent(out) :: ierr ! error code
143133
character(*), intent(out) :: message ! error message
144134
! Local variables to
145-
real(dp), allocatable :: uprflux(:) ! upstream Reach fluxes
135+
real(dp) :: q_upstream ! upstream Reach fluxes
146136
integer(i4b) :: nUps ! number of upstream segment
147137
integer(i4b) :: iUps ! upstream reach index
148138
integer(i4b) :: iRch_ups ! index of upstream reach in NETOPO
139+
character(len=strLen) :: fmt1,fmt2 ! format string
149140
character(len=strLen) :: cmessage ! error message from subroutine
150141

151-
! initialize error control
152142
ierr=0; message='accum_qupstream/'
153143

154144
! identify number of upstream segments of the reach being processed
155145
nUps = size(NETOPO_in(segIndex)%UREACHI)
156146

157147
RCHFLX_out(iEns,segIndex)%UPSTREAM_QI = RCHFLX_out(iEns,segIndex)%BASIN_QR(1)
158148

149+
q_upstream = 0._dp
159150
if (nUps>0) then
160151

161-
allocate(uprflux(nUps), stat=ierr, errmsg=cmessage)
162-
if(ierr/=0)then; message=trim(message)//trim(cmessage)//': uprflux'; return; endif
163-
164152
do iUps = 1,nUps
165153
iRch_ups = NETOPO_in(segIndex)%UREACHI(iUps) ! index of upstream of segIndex-th reach
166-
uprflux(iUps) = RCHFLX_out(iens,iRch_ups)%UPSTREAM_QI
154+
q_upstream = q_upstream + RCHFLX_out(iens,iRch_ups)%UPSTREAM_QI
167155
end do
168156

169-
RCHFLX_out(iEns,segIndex)%UPSTREAM_QI = RCHFLX_out(iEns,segIndex)%UPSTREAM_QI + sum(uprflux)
157+
RCHFLX_out(iEns,segIndex)%UPSTREAM_QI = RCHFLX_out(iEns,segIndex)%UPSTREAM_QI + q_upstream
170158

171159
endif
172160

173161
! check
174-
if(NETOPO_in(segIndex)%REACHIX == ixDesire)then
175-
print*, 'CHECK ACCUM_RUNOFF'
176-
print*, ' UREACHK, uprflux = ', (NETOPO_in(segIndex)%UREACHK(iUps), uprflux(iUps), iUps=1,nUps)
177-
print*, ' RCHFLX_out(iEns,segIndex)%BASIN_QR(1) = ', RCHFLX_out(iEns,segIndex)%BASIN_QR(1)
178-
print*, ' RCHFLX_out%UPSTREAM_QI = ', RCHFLX_out(iens,segIndex)%UPSTREAM_QI
162+
if(segIndex == ixDesire)then
163+
write(fmt1,'(A,I5,A)') '(A,1X',nUps,'(1X,I10))'
164+
write(fmt2,'(A,I5,A)') '(A,1X',nUps,'(1X,F20.7))'
165+
write(*,'(2a)') new_line('a'),'** Check upstream discharge accumulation **'
166+
write(*,'(a,x,I10,x,I10)') ' Reach index & ID =', segIndex, NETOPO_in(segIndex)%REACHID
167+
write(*,'(a)') ' * upstream reach index (NETOPO_in%UREACH) and discharge (uprflux) [m3/s] :'
168+
write(*,fmt1) ' UREACHK =', (NETOPO_in(segIndex)%UREACHK(iUps), iUps=1,nUps)
169+
write(*,fmt2) ' prflux =', (RCHFLX_out(iens,NETOPO_in(segIndex)%UREACHI(iUps))%UPSTREAM_QI, iUps=1,nUps)
170+
write(*,'(a)') ' * local area discharge (RCHFLX_out%BASIN_QR(1)) and final discharge (RCHFLX_out%UPSTREAM_QI) [m3/s] :'
171+
write(*,'(a,x,F15.7)') ' RCHFLX_out%BASIN_QR(1) =', RCHFLX_out(iEns,segIndex)%BASIN_QR(1)
172+
write(*,'(a,x,F15.7)') ' RCHFLX_out%UPSTREAM_QI =', RCHFLX_out(iens,segIndex)%UPSTREAM_QI
179173
endif
180174

181175
end subroutine accum_qupstream

route/build/src/basinUH.f90

-9
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@ SUBROUTINE IRF_route_basin(iens, & ! input: ensemble index
3636
integer(i4b) :: iSeg ! reach loop indix
3737
logical(lgt), allocatable :: doRoute(:) ! logical to indicate which reaches are processed
3838
character(len=strLen) :: cmessage ! error message from subroutines
39-
integer*8 :: cr ! rate
40-
integer*8 :: startTime,endTime ! date/time for the start and end of the initialization
41-
real(dp) :: elapsedTime ! elapsed time for the process
4239

4340
ierr=0; message='IRF_route_basin/'
44-
call system_clock(count_rate=cr)
4541

4642
nSeg = size(RCHFLX_out(iens,:))
4743

@@ -56,7 +52,6 @@ SUBROUTINE IRF_route_basin(iens, & ! input: ensemble index
5652
doRoute(:) = .true.
5753
endif
5854

59-
call system_clock(startTime)
6055
!$OMP PARALLEL DO schedule(dynamic,1) &
6156
!$OMP private(iSeg) & ! loop index
6257
!$OMP private(ierr, cmessage) & ! private for a given thread
@@ -75,10 +70,6 @@ SUBROUTINE IRF_route_basin(iens, & ! input: ensemble index
7570
end do
7671
!$OMP END PARALLEL DO
7772

78-
call system_clock(endTime)
79-
elapsedTime = real(endTime-startTime, kind(dp))/real(cr)
80-
! write(*,"(A,1PG15.7,A)") ' elapsed-time [routing/irf_hru] = ', elapsedTime, ' s'
81-
8273
END SUBROUTINE IRF_route_basin
8374

8475

0 commit comments

Comments
 (0)