Skip to content

Commit 4ee457d

Browse files
authored
Merge pull request #438 from NCAR/develop
Develop
2 parents f36864c + f7e6953 commit 4ee457d

16 files changed

+220
-82
lines changed

build/source/driver/summa_alarms.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ subroutine summa_setWriteAlarms(oldTime, newTime, endTime, & ! time vect
123123
case(ixRestart_end); printRestart = (newTime(iLookTIME%im) == endTime(iLookTIME%im) .and. &
124124
newTime(iLookTIME%id) == endTime(iLookTIME%id) .and. &
125125
newTime(iLookTIME%ih) == endTime(iLookTIME%ih) .and. &
126-
newTime(iLookTIME%imin) == endTime(iLookTIME%imin))
126+
newTime(iLookTIME%imin) == endTime(iLookTIME%imin)) ! newTime does not have a '24h', won't write ending state if end_h=24
127127
case(ixRestart_never); printRestart = .false.
128128
case default; err=20; message=trim(message)//'unable to identify option for the restart file'; return
129129
end select

build/source/driver/summa_init.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ subroutine summa_initialize(summa1_struc, err, message)
121121
diagStat => summa1_struc%diagStat , & ! x%gru(:)%hru(:)%var(:)%dat -- model diagnostic variables
122122
fluxStat => summa1_struc%fluxStat , & ! x%gru(:)%hru(:)%var(:)%dat -- model fluxes
123123
indxStat => summa1_struc%indxStat , & ! x%gru(:)%hru(:)%var(:)%dat -- model indices
124-
bvarStat => summa1_struc%bvarStat , & ! x%gru(:)%var(:)%dat -- basin-average variabl
124+
bvarStat => summa1_struc%bvarStat , & ! x%gru(:)%var(:)%dat -- basin-average variables
125125

126126
! primary data structures (scalars)
127127
timeStruct => summa1_struc%timeStruct , & ! x%var(:) -- model time data

build/source/driver/summa_restart.f90

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ subroutine summa_readRestart(summa1_struc, err, message)
101101
nHRU => summa1_struc%nHRU & ! number of global hydrologic response units
102102

103103
) ! assignment to variables in the data structures
104+
104105
! ---------------------------------------------------------------------------------------
105106
! initialize error control
106107
err=0; message='summa_readRestart/'
@@ -116,14 +117,15 @@ subroutine summa_readRestart(summa1_struc, err, message)
116117
if(STATE_PATH == '') then
117118
restartFile = trim(SETTINGS_PATH)//trim(MODEL_INITCOND)
118119
else
119-
restartFile = trim(STATE_PATH)//trim(MODEL_INITCOND)
120+
restartFile = trim(STATE_PATH)//trim(MODEL_INITCOND)
120121
endif
121122

122123
! read initial conditions
123124
call read_icond(restartFile, & ! intent(in): name of initial conditions file
124125
nGRU, & ! intent(in): number of response units
125126
mparStruct, & ! intent(in): model parameters
126127
progStruct, & ! intent(inout): model prognostic variables
128+
bvarStruct, & ! intent(inout): model basin (GRU) variables
127129
indxStruct, & ! intent(inout): model indices
128130
err,cmessage) ! intent(out): error control
129131
if(err/=0)then; message=trim(message)//trim(cmessage); return; endif
@@ -143,7 +145,7 @@ subroutine summa_readRestart(summa1_struc, err, message)
143145
! *** compute ancillary variables
144146
! *****************************************************************************
145147

146-
! loop through local HRUs
148+
! loop through HRUs
147149
do iHRU=1,gru_struc(iGRU)%hruCount
148150

149151
! re-calculate height of each layer
@@ -178,7 +180,7 @@ subroutine summa_readRestart(summa1_struc, err, message)
178180
! NOTE: canopy drip from the previous time step is used to compute throughfall for the current time step
179181
fluxStruct%gru(iGRU)%hru(iHRU)%var(iLookFLUX%scalarCanopyLiqDrainage)%dat(1) = 0._dp ! not used
180182

181-
end do ! (looping through HRUs)
183+
end do ! end looping through HRUs
182184

183185
! *****************************************************************************
184186
! *** initialize aquifer storage
@@ -225,7 +227,7 @@ subroutine summa_readRestart(summa1_struc, err, message)
225227
dt_init%gru(iGRU)%hru(iHRU) = progStruct%gru(iGRU)%hru(iHRU)%var(iLookPROG%dt_init)%dat(1) ! seconds
226228
end do
227229

228-
end do ! (looping through GRUs)
230+
end do ! end looping through GRUs
229231

230232
! *****************************************************************************
231233
! *** finalize

build/source/driver/summa_writeOutput.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ subroutine summa_writeOutputFiles(modelTimeStep, summa1_struc, err, message)
287287
restartFile=trim(STATE_PATH)//trim(OUTPUT_PREFIX)//'_restart_'//trim(timeString)//trim(output_fileSuffix)//'.nc'
288288
endif
289289

290-
call writeRestart(restartFile,nGRU,nHRU,prog_meta,progStruct,maxLayers,maxSnowLayers,indx_meta,indxStruct,err,cmessage)
290+
call writeRestart(restartFile,nGRU,nHRU,prog_meta,progStruct,bvar_meta,bvarStruct,maxLayers,maxSnowLayers,indx_meta,indxStruct,err,cmessage)
291291
if(err/=0)then; message=trim(message)//trim(cmessage); return; endif
292292
end if
293293

build/source/dshare/data_types.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ MODULE data_types
112112

113113
! define mapping from GRUs to the HRUs
114114
type, public :: gru2hru_map
115-
integer(8) :: gruId ! id of the gru
115+
integer(8) :: gru_id ! id of the gru
116116
integer(i4b) :: hruCount ! total number of hrus in the gru
117117
type(hru_info), allocatable :: hruInfo(:) ! basic information of HRUs within the gru
118118
integer(i4b) :: gru_nc ! index of gru in the netcdf file

build/source/dshare/get_ixname.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ subroutine get_ixUnknown(varName,typeName,vDex,err,message)
977977
message='get_ixUnknown/'
978978

979979
! loop through all structure types to find the one with the given variable name
980-
! pill variable index plus return which structure it was found in
980+
! poll variable index plus return which structure it was found in
981981
do iStruc = 1,size(structInfo)
982982
select case(trim(structInfo(iStruc)%structName))
983983
case ('time' ); vDex = get_ixTime(trim(varName))

build/source/dshare/globalData.f90

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ MODULE globalData
250250
! define metadata for model forcing datafile
251251
type(file_info),save,public,allocatable :: forcFileInfo(:) ! file info for model forcing data
252252

253-
! define indices describing the indices of the first and last HRUs in the forcing file
253+
! define index variables describing the indices of the first and last HRUs in the forcing file
254254
integer(i4b),save,public :: ixHRUfile_min ! minimum index
255255
integer(i4b),save,public :: ixHRUfile_max ! maximum index
256256

@@ -336,5 +336,9 @@ MODULE globalData
336336
integer(i4b),parameter,public :: ncTime=1 ! time zone information from NetCDF file (timeOffset = longitude/15. - ncTimeOffset)
337337
integer(i4b),parameter,public :: utcTime=2 ! all times in UTC (timeOffset = longitude/15. hours)
338338
integer(i4b),parameter,public :: localTime=3 ! all times local (timeOffset = 0)
339+
340+
! define fixed dimensions
341+
integer(i4b),parameter,public :: nBand=2 ! number of spectral bands
342+
integer(i4b),parameter,public :: nTimeDelay=2000 ! number of hours in the time delay histogram (default: ~1 season = 24*365/4)
339343

340344
END MODULE globalData

build/source/engine/allocspace.f90

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ module allocspace_module
5555
USE globalData,only:integerMissing ! missing integer
5656
USE globalData,only:realMissing ! missing double precision number
5757

58+
USE globalData,only: nTimeDelay ! number of timesteps in the time delay histogram
59+
USE globalData,only: nBand ! number of spectral bands
60+
5861
! access variable types
5962
USE var_lookup,only:iLookVarType ! look up structure for variable typed
6063
USE var_lookup,only:maxvarFreq ! allocation dimension (output frequency)
@@ -66,9 +69,6 @@ module allocspace_module
6669
public::allocLocal
6770
public::resizeData
6871

69-
! define fixed dimensions
70-
integer(i4b),parameter :: nBand=2 ! number of spectral bands
71-
integer(i4b),parameter :: nTimeDelay=2000 ! number of elements in the time delay histogram
7272
! -----------------------------------------------------------------------------------------------------------------------------------
7373
contains
7474

@@ -530,6 +530,7 @@ subroutine allocateDat_dp(metadata,nSnow,nSoil,nLayers, & ! input
530530
varData,err,message) ! output
531531
! access subroutines
532532
USE get_ixName_module,only:get_varTypeName ! to access type strings for error messages
533+
533534
implicit none
534535
! input variables
535536
type(var_info),intent(in) :: metadata(:) ! metadata structure
@@ -543,7 +544,8 @@ subroutine allocateDat_dp(metadata,nSnow,nSoil,nLayers, & ! input
543544
! local variables
544545
integer(i4b) :: iVar ! variable index
545546
integer(i4b) :: nVars ! number of variables in the metadata structure
546-
! initialize error control
547+
548+
! initialize error control
547549
err=0; message='allocateDat_dp/'
548550

549551
! get the number of variables in the metadata structure
@@ -608,13 +610,14 @@ subroutine allocateDat_int(metadata,nSnow,nSoil,nLayers, & ! input
608610
! local variables
609611
integer(i4b) :: iVar ! variable index
610612
integer(i4b) :: nVars ! number of variables in the metadata structure
611-
! initialize error control
613+
614+
! initialize error control
612615
err=0; message='allocateDat_int/'
613616

614617
! get the number of variables in the metadata structure
615618
nVars = size(metadata)
616619

617-
! loop through variables in the data structure
620+
! loop through variables in the data structure
618621
do iVar=1,nVars
619622

620623
! check allocated
@@ -670,13 +673,14 @@ subroutine allocateDat_flag(metadata,nSnow,nSoil,nLayers, & ! input
670673
! local variables
671674
integer(i4b) :: iVar ! variable index
672675
integer(i4b) :: nVars ! number of variables in the metadata structure
673-
! initialize error control
676+
677+
! initialize error control
674678
err=0; message='allocateDat_flag/'
675679

676680
! get the number of variables in the metadata structure
677681
nVars = size(metadata)
678682

679-
! loop through variables in the data structure
683+
! loop through variables in the data structure
680684
do iVar=1,nVars
681685

682686
! check allocated

build/source/engine/check_icond.f90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ subroutine check_icond(nGRU, & ! number of GRUs and HRU
207207
if(scalarTheta > theta_sat(iSoil)+xTol)then; write(message,'(a,1x,i0)') trim(message)//'cannot initialize the model with total water fraction [liquid + ice] > theta_sat: layer = ',iLayer; err=20; return; end if
208208

209209
case default
210+
write(*,*) 'Cannot recognize case in initial vol water/ice check: type=', mlayerLayerType(iLayer)
210211
err=20; message=trim(message)//'cannot identify layer type'; return
211212
end select
212213

@@ -272,8 +273,8 @@ subroutine check_icond(nGRU, & ! number of GRUs and HRU
272273
do iLayer=1,nLayers
273274
h1 = sum(progData%gru(iGRU)%hru(iHRU)%var(iLookPROG%mLayerDepth)%dat(1:iLayer)) ! sum of the depths up to the current layer
274275
h2 = progData%gru(iGRU)%hru(iHRU)%var(iLookPROG%iLayerHeight)%dat(iLayer) - progData%gru(iGRU)%hru(iHRU)%var(iLookPROG%iLayerHeight)%dat(0) ! difference between snow-atm interface and bottom of layer
275-
if(abs(h1 - h2) > 1.e-12_dp)then
276-
write(message,'(a,1x,i0)') trim(message)//'mis-match between layer depth and layer height [suggest round numbers in initial conditions file]; layer = ', iLayer
276+
if(abs(h1 - h2) > 1.e-6_dp)then
277+
write(message,'(a,1x,i0)') trim(message)//'mis-match between layer depth and layer height; layer = ', iLayer, '; sum depths = ',h1,'; height = ',h2
277278
err=20; return
278279
end if
279280
end do

build/source/engine/read_attrb.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ subroutine read_dimension(attrFile,fileGRU,fileHRU,nGRU,nHRU,err,message,startGR
143143
! gru to hru mapping
144144
iGRU = 1
145145
gru_struc(iGRU)%hruCount = 1 ! number of HRUs in each GRU
146-
gru_struc(iGRU)%gruId = hru2gru_id(checkHRU) ! set gru id
146+
gru_struc(iGRU)%gru_id = hru2gru_id(checkHRU) ! set gru id
147147
gru_struc(iGRU)%gru_nc = sGRU ! set gru index within the netcdf file
148148
allocate(gru_struc(iGRU)%hruInfo(gru_struc(iGRU)%hruCount)) ! allocate second level of gru to hru map
149149
gru_struc(iGRU)%hruInfo(iGRU)%hru_nc = checkHRU ! set hru id in attributes netcdf file
@@ -157,11 +157,11 @@ subroutine read_dimension(attrFile,fileGRU,fileHRU,nGRU,nHRU,err,message,startGR
157157

158158
if (count(hru2gru_Id == gru_id(iGRU+sGRU-1)) < 1) then; err=20; message=trim(message)//'problem finding HRUs belonging to GRU'; return; end if
159159
gru_struc(iGRU)%hruCount = count(hru2gru_Id == gru_id(iGRU+sGRU-1)) ! number of HRUs in each GRU
160-
gru_struc(iGRU)%gruId = gru_id(iGRU+sGRU-1) ! set gru id
160+
gru_struc(iGRU)%gru_id = gru_id(iGRU+sGRU-1) ! set gru id
161161
gru_struc(iGRU)%gru_nc = iGRU+sGRU-1 ! set gru index in the netcdf file
162162

163163
allocate(gru_struc(iGRU)%hruInfo(gru_struc(iGRU)%hruCount)) ! allocate second level of gru to hru map
164-
gru_struc(iGRU)%hruInfo(:)%hru_nc = pack(hru_ix,hru2gru_id == gru_struc(iGRU)%gruId) ! set hru id in attributes netcdf file
164+
gru_struc(iGRU)%hruInfo(:)%hru_nc = pack(hru_ix,hru2gru_id == gru_struc(iGRU)%gru_id) ! set hru id in attributes netcdf file
165165
gru_struc(iGRU)%hruInfo(:)%hru_ix = arth(iHRU,1,gru_struc(iGRU)%hruCount) ! set index of hru in run domain
166166
gru_struc(iGRU)%hruInfo(:)%hru_id = hru_id(gru_struc(iGRU)%hruInfo(:)%hru_nc) ! set id of hru
167167
iHRU = iHRU + gru_struc(iGRU)%hruCount

0 commit comments

Comments
 (0)