Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes and minor improvements #452

Merged
merged 43 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e71c83b
reduce time step if snow layer melts entirely
Oct 10, 2020
319eae7
added GRU index and hruId reporting to run_oneGru & run_oneHru
Dec 3, 2020
5e183fa
removed unnecessary whitespace in run_oneGru
Dec 3, 2020
bad8436
Merge pull request #435 from martynpclark/bugFix/tooMuchMelt
arbennett Dec 3, 2020
a3837a2
bugfix of error reporting in coupled_em balance checks: incorrect sol…
Jan 2, 2021
85bd9fa
Merge pull request #439 from wknoben/feature/GruHruIdInError
arbennett Jan 5, 2021
ea09226
moved and split comments across multiple lines as requested in PR
Jan 5, 2021
6d872f1
fix water balance error associated with transpiration
martynpclark Jan 7, 2021
1c6bdd5
Fix for segfault
arbennett Jan 11, 2021
c2da2bf
Fix typo
arbennett Jan 11, 2021
1d83cc5
Merge pull request #445 from arbennett/bugfix/mw_exp-segfault
bartnijssen Jan 12, 2021
9c37240
Merge pull request #442 from wknoben/bugfix/opSplittinCouplingId
arbennett Jan 12, 2021
45af60b
Merge pull request #444 from martynpclark/bugFix/opSplittingTranspira…
arbennett Jan 20, 2021
bdd30a1
Added precision tolerance to balance check in updatState.f90 to avoid…
Feb 28, 2021
0667540
Add whatsnew, rename github folder
arbennett Mar 2, 2021
d699446
Merge pull request #450 from arbennett/feature/templates_and_whatsnew
arbennett Mar 2, 2021
f75949b
Merge branch 'master' into develop
arbennett Mar 2, 2021
0505428
Merge remote-tracking branch 'upstream/develop' into develop
Mar 2, 2021
8437cb0
udpated whatsnew
Mar 2, 2021
a165ac7
Merge pull request #451 from andywood/develop
arbennett Mar 2, 2021
657151d
BUG FIX: correcting calculation of averageRoutedRunoff in run_oneGRU.…
Apr 4, 2021
92c5591
Minor cleanup on PR #454 (A. Wood) to add solar radiation functionali…
Apr 5, 2021
c5f9ef9
Added note to docs about how SUMMA expects gru/hru order in nc files
wknoben Apr 7, 2021
b57d766
update to run_oneGRU to organize the total_runoff calculations, summi…
Apr 7, 2021
5774f6b
First pass on single precision, compiles, but does not run
arbennett May 12, 2021
81d2085
Move summa_prec -> rk
arbennett May 12, 2021
eab783f
Merge branch 'develop' into feature/single_precision
arbennett May 12, 2021
6129934
Update whatsnew
arbennett May 12, 2021
445ff63
Merge pull request #458 from arbennett/feature/single_precision
martynpclark May 12, 2021
434c013
Merge pull request #455 from wknoben/docs/netcdf-hru-order
arbennett May 12, 2021
c7e5eef
Fix merge conflicts
arbennett May 12, 2021
6d42d13
update Makefile
martynpclark May 26, 2021
b8d0dc8
Merge pull request #459 from martynpclark/bugfix/Makefile
arbennett May 26, 2021
73546f1
Merge pull request #1 from arbennett/conflicts/pr454
andywood May 26, 2021
34f07e7
enable writing parameters for the GRUs
martynpclark May 26, 2021
b425d44
Merge pull request #460 from martynpclark/bugfix/writeGRUparams
arbennett May 26, 2021
bda78e9
Revert "Create new unified real kind datatype"
arbennett May 26, 2021
7cb25d6
Merge pull request #461 from NCAR/revert-458-feature/single_precision
arbennett May 26, 2021
c151a50
Merge pull request #454 from andywood/develop
arbennett May 26, 2021
90df88d
Fix basin variable reference/initialization
arbennett May 26, 2021
f9d427d
Merge pull request #462 from arbennett/bugfix/basin_soil_drainage_in_…
arbennett May 26, 2021
89f760a
ensure write full GRU vector
martynpclark May 28, 2021
7e1c0c3
Merge pull request #463 from martynpclark/bugfix/writeGRUparams
arbennett May 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ ifeq "$(FC)" "gfortran"
endif

# Production runs
FLAGS_NOAH = -O3 -ffree-form -fdefault-real-8 -ffree-line-length-none -fmax-errors=0 $(FLAGS_OMP)
FLAGS_NOAH = -O3 -ffree-form -ffree-line-length-none -fmax-errors=0 $(FLAGS_OMP)
FLAGS_COMM = -O3 -ffree-line-length-none -fmax-errors=0 $(FLAGS_OMP)
FLAGS_SUMMA = -O3 -ffree-line-length-none -fmax-errors=0 $(FLAGS_OMP)

# Debug runs
#FLAGS_NOAH = -p -g -ffree-form -fdefault-real-8 -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument
#FLAGS_NOAH = -p -g -ffree-form -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument
#FLAGS_COMM = -p -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -fcheck=bounds
#FLAGS_SUMMA = -p -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -fcheck=bounds

Expand All @@ -110,12 +110,12 @@ ifeq "$(FC)" "ifort"
endif

# Production runs
FLAGS_NOAH = -O3 -autodouble -noerror_limit -FR -auto -fltconsistency $(FLAGS_OMP)
FLAGS_NOAH = -O3 -noerror_limit -FR -auto -fltconsistency $(FLAGS_OMP)
FLAGS_COMM = -O3 -FR -auto -fltconsistency -fpe0 $(FLAGS_OMP)
FLAGS_SUMMA = -O3 -FR -auto -fltconsistency -fpe0 $(FLAGS_OMP)

# Debug runs
#FLAGS_NOAH = -O0 -p -g -warn nounused -autodouble -noerror_limit -FR -auto -WB -traceback -fltconsistency
#FLAGS_NOAH = -O0 -p -g -warn nounused -noerror_limit -FR -auto -WB -traceback -fltconsistency
#FLAGS_COMM = -O0 -p -g -debug -warn all -check all -FR -auto -WB -traceback -fltconsistency -fpe0
#FLAGS_SUMMA = -O0 -p -g -debug -warn all -check all -FR -auto -WB -traceback -fltconsistency -fpe0
endif
Expand Down Expand Up @@ -357,7 +357,7 @@ update_version:

# compile Noah-MP routines
compile_noah:
$(FC_EXE) $(FLAGS_NOAH) -c $(NOAHMP)
$(FC_EXE) $(FLAGS_NOAH) -c $(NRUTIL) $(NOAHMP)

# compile common routines
compile_comm:
Expand Down
6 changes: 3 additions & 3 deletions build/source/driver/summa_defineOutput.f90
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ subroutine summa_defineOutputFiles(modelTimeStep, summa1_struc, err, message)
! *** define the name of the model output file
! *****************************************************************************

! define full name of output file
! define full name of output file
if(modelTimeStep==1)then
select case(newOutputFile)
case(noNewFiles); ! do nothing, just ensure validity of outputfile option
case(newFileEveryOct1);
case(newFileEveryOct1);
case default; err=20; message=trim(message)//'unable to identify the option to define new output files'; return
end select

Expand Down Expand Up @@ -141,7 +141,7 @@ subroutine summa_defineOutputFiles(modelTimeStep, summa1_struc, err, message)
end do ! (looping through HRUs)

! write GRU parameters
call writeParm(integerMissing,bparStruct%gru(iGRU),bpar_meta,err,cmessage)
call writeParm(iGRU,bparStruct%gru(iGRU),bpar_meta,err,cmessage)
if(err/=0)then; message=trim(message)//trim(cmessage); return; endif

end do ! (looping through GRUs)
Expand Down
2 changes: 1 addition & 1 deletion build/source/driver/summa_globalData.f90
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ subroutine summa_defineGlobalData(err, message)
doJacobian=.false. ! initialize the Jacobian flag

! define double precision NaNs (shared in globalData)
dNaN = ieee_value(1._dp, ieee_quiet_nan)
dNaN = ieee_value(1._rkind, ieee_quiet_nan)

! populate metadata for all model variables
call popMetadat(err,cmessage)
Expand Down
6 changes: 3 additions & 3 deletions build/source/driver/summa_init.f90
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ subroutine summa_initialize(summa1_struc, err, message)
ncid(:) = integerMissing

! initialize the elapsed time for cumulative quantities
elapsedRead=0._dp
elapsedWrite=0._dp
elapsedPhysics=0._dp
elapsedRead=0._rkind
elapsedWrite=0._rkind
elapsedPhysics=0._rkind

! get the command line arguments
call getCommandArguments(summa1_struc,err,cmessage)
Expand Down
14 changes: 7 additions & 7 deletions build/source/driver/summa_modelRun.f90
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ subroutine summa_runPhysics(modelTimeStep, summa1_struc, err, message)
integer(i4b) :: iGRU,jGRU,kGRU ! GRU indices
! local variables: veg phenology
logical(lgt) :: computeVegFluxFlag ! flag to indicate if we are computing fluxes over vegetation (.false. means veg is buried with snow)
real(dp) :: notUsed_canopyDepth ! NOT USED: canopy depth (m)
real(dp) :: notUsed_exposedVAI ! NOT USED: exposed vegetation area index (m2 m-2)
real(rkind) :: notUsed_canopyDepth ! NOT USED: canopy depth (m)
real(rkind) :: notUsed_exposedVAI ! NOT USED: exposed vegetation area index (m2 m-2)
! local variables: parallelize the model run
integer(i4b), allocatable :: ixExpense(:) ! ranked index GRU w.r.t. computational expense
integer(i4b), allocatable :: totalFluxCalls(:) ! total number of flux calls for each GRU
! local variables: timing information
integer*8 :: openMPstart,openMPend ! time for the start of the parallelization section
integer*8, allocatable :: timeGRUstart(:) ! time GRUs start
real(dp), allocatable :: timeGRUcompleted(:) ! time required to complete each GRU
real(dp), allocatable :: timeGRU(:) ! time spent on each GRU
real(rkind), allocatable :: timeGRUcompleted(:) ! time required to complete each GRU
real(rkind), allocatable :: timeGRU(:) ! time spent on each GRU
! ---------------------------------------------------------------------------------------
! associate to elements in the data structure
summaVars: associate(&
Expand Down Expand Up @@ -171,7 +171,7 @@ subroutine summa_runPhysics(modelTimeStep, summa1_struc, err, message)

! compute the total number of flux calls from the previous time step
do jGRU=1,nGRU
totalFluxCalls(jGRU) = 0._dp
totalFluxCalls(jGRU) = 0._rkind
do iHRU=1,gru_struc(jGRU)%hruCount
totalFluxCalls(jGRU) = totalFluxCalls(jGRU) + indxStruct%gru(jGRU)%hru(iHRU)%var(iLookINDEX%numberFluxCalc)%dat(1)
end do
Expand Down Expand Up @@ -268,8 +268,8 @@ subroutine summa_runPhysics(modelTimeStep, summa1_struc, err, message)
!$omp critical(saveTiming)
! save timing information
call system_clock(openMPend)
timeGRU(iGRU) = real(openMPend - timeGRUstart(iGRU), kind(dp))
timeGRUcompleted(iGRU) = real(openMPend - openMPstart , kind(dp))
timeGRU(iGRU) = real(openMPend - timeGRUstart(iGRU), kind(rkind))
timeGRUcompleted(iGRU) = real(openMPend - openMPstart , kind(rkind))
!$omp end critical(saveTiming)

end do ! (looping through GRUs)
Expand Down
8 changes: 4 additions & 4 deletions build/source/driver/summa_restart.f90
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ subroutine summa_readRestart(summa1_struc, err, message)

! initialize canopy drip
! NOTE: canopy drip from the previous time step is used to compute throughfall for the current time step
fluxStruct%gru(iGRU)%hru(iHRU)%var(iLookFLUX%scalarCanopyLiqDrainage)%dat(1) = 0._dp ! not used
fluxStruct%gru(iGRU)%hru(iHRU)%var(iLookFLUX%scalarCanopyLiqDrainage)%dat(1) = 0._rkind ! not used

end do ! end looping through HRUs

Expand All @@ -201,14 +201,14 @@ subroutine summa_readRestart(summa1_struc, err, message)

! the basin-average aquifer storage is not used if the groundwater is included in the local column
case(localColumn)
bvarStruct%gru(iGRU)%var(iLookBVAR%basin__AquiferStorage)%dat(1) = 0._dp ! set to zero to be clear that there is no basin-average aquifer storage in this configuration
bvarStruct%gru(iGRU)%var(iLookBVAR%basin__AquiferStorage)%dat(1) = 0._rkind ! set to zero to be clear that there is no basin-average aquifer storage in this configuration

! the local column aquifer storage is not used if the groundwater is basin-average
! (i.e., where multiple HRUs drain to a basin-average aquifer)
case(singleBasin)
bvarStruct%gru(iGRU)%var(iLookBVAR%basin__AquiferStorage)%dat(1) = 1._dp
bvarStruct%gru(iGRU)%var(iLookBVAR%basin__AquiferStorage)%dat(1) = 1._rkind
do iHRU=1,gru_struc(iGRU)%hruCount
progStruct%gru(iGRU)%hru(iHRU)%var(iLookPROG%scalarAquiferStorage)%dat(1) = 0._dp ! set to zero to be clear that there is no local aquifer storage in this configuration
progStruct%gru(iGRU)%hru(iHRU)%var(iLookPROG%scalarAquiferStorage)%dat(1) = 0._rkind ! set to zero to be clear that there is no local aquifer storage in this configuration
end do

! error check
Expand Down
6 changes: 3 additions & 3 deletions build/source/driver/summa_setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ subroutine summa_paramSetup(summa1_struc, err, message)
! *****************************************************************************

! define monthly fraction of green vegetation
greenVegFrac_monthly = (/0.01_dp, 0.02_dp, 0.03_dp, 0.07_dp, 0.50_dp, 0.90_dp, 0.95_dp, 0.96_dp, 0.65_dp, 0.24_dp, 0.11_dp, 0.02_dp/)
greenVegFrac_monthly = (/0.01_rkind, 0.02_rkind, 0.03_rkind, 0.07_rkind, 0.50_rkind, 0.90_rkind, 0.95_rkind, 0.96_rkind, 0.65_rkind, 0.24_rkind, 0.11_rkind, 0.02_rkind/)

! read Noah soil and vegetation tables
call soil_veg_gen_parm(trim(SETTINGS_PATH)//trim(VEGPARM), & ! filename for vegetation table
Expand Down Expand Up @@ -298,7 +298,7 @@ subroutine summa_paramSetup(summa1_struc, err, message)

! compute total area of the upstream HRUS that flow into each HRU
do iHRU=1,gru_struc(iGRU)%hruCount
upArea%gru(iGRU)%hru(iHRU) = 0._dp
upArea%gru(iGRU)%hru(iHRU) = 0._rkind
do jHRU=1,gru_struc(iGRU)%hruCount
! check if jHRU flows into iHRU; assume no exchange between GRUs
if(typeStruct%gru(iGRU)%hru(jHRU)%var(iLookTYPE%downHRUindex)==typeStruct%gru(iGRU)%hru(iHRU)%var(iLookID%hruId))then
Expand All @@ -309,7 +309,7 @@ subroutine summa_paramSetup(summa1_struc, err, message)

! identify the total basin area for a GRU (m2)
associate(totalArea => bvarStruct%gru(iGRU)%var(iLookBVAR%basin__totalArea)%dat(1) )
totalArea = 0._dp
totalArea = 0._rkind
do iHRU=1,gru_struc(iGRU)%hruCount
totalArea = totalArea + attrStruct%gru(iGRU)%hru(iHRU)%var(iLookATTR%HRUarea)
end do
Expand Down
4 changes: 2 additions & 2 deletions build/source/driver/summa_type.f90
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ MODULE summa_type
! define miscellaneous variables
integer(i4b) :: summa1open ! flag to define if the summa file is open??
integer(i4b) :: numout ! number of output variables??
real(dp) :: ts ! model time step ??
real(rkind) :: ts ! model time step ??
integer(i4b) :: nGRU ! number of grouped response units
integer(i4b) :: nHRU ! number of global hydrologic response units
integer(i4b) :: hruCount ! number of local hydrologic response units
real(dp),dimension(12) :: greenVegFrac_monthly ! fraction of green vegetation in each month (0-1)
real(rkind),dimension(12) :: greenVegFrac_monthly ! fraction of green vegetation in each month (0-1)
character(len=256) :: summaFileManagerFile ! path/name of file defining directories and files

end type summa1_type_dec
Expand Down
8 changes: 4 additions & 4 deletions build/source/driver/summa_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ subroutine stop_program(err,message)
integer(i4b) :: endModelRun(8) ! final time
integer(i4b) :: localErr ! local error code
integer(i4b) :: iFreq ! loop through output frequencies
real(dp) :: elpSec ! elapsed seconds
real(rkind) :: elpSec ! elapsed seconds

! close any remaining output files
! NOTE: use the direct NetCDF call with no error checking since the file may already be closed
Expand Down Expand Up @@ -392,9 +392,9 @@ subroutine stop_program(err,message)

! print total elapsed time
write(outunit,"(/,A,1PG15.7,A)") ' elapsed time = ', elpSec, ' s'
write(outunit,"(A,1PG15.7,A)") ' or ', elpSec/60_dp, ' m'
write(outunit,"(A,1PG15.7,A)") ' or ', elpSec/3600_dp, ' h'
write(outunit,"(A,1PG15.7,A/)") ' or ', elpSec/86400_dp, ' d'
write(outunit,"(A,1PG15.7,A)") ' or ', elpSec/60_rkind, ' m'
write(outunit,"(A,1PG15.7,A)") ' or ', elpSec/3600_rkind, ' h'
write(outunit,"(A,1PG15.7,A/)") ' or ', elpSec/86400_rkind, ' d'

! print the number of threads
write(outunit,"(A,i10,/)") ' number threads = ', nThreads
Expand Down
16 changes: 8 additions & 8 deletions build/source/dshare/data_types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ MODULE data_types
integer(i4b),allocatable :: var_ix(:) ! index of each forcing data variable in the data structure
integer(i4b),allocatable :: data_id(:) ! netcdf variable id for each forcing data variable
character(len=256),allocatable :: varName(:) ! netcdf variable name for each forcing data variable
real(dp) :: firstJulDay ! first julian day in forcing file
real(dp) :: convTime2Days ! factor to convert time to days
real(rkind) :: firstJulDay ! first julian day in forcing file
real(rkind) :: convTime2Days ! factor to convert time to days
end type file_info

! ***********************************************************************************************************
! Define metadata on model parameters
! ***********************************************************************************************************
! define a data type to store model parameter information
type,public :: par_info
real(dp) :: default_val ! default parameter value
real(dp) :: lower_limit ! lower bound
real(dp) :: upper_limit ! upper bound
real(rkind) :: default_val ! default parameter value
real(rkind) :: lower_limit ! lower bound
real(rkind) :: upper_limit ! upper bound
endtype par_info

! ***********************************************************************************************************
Expand Down Expand Up @@ -131,7 +131,7 @@ MODULE data_types
! NOTE: use derived types here to facilitate adding the "variable" dimension
! ** double precision type
type, public :: dlength
real(dp),allocatable :: dat(:) ! dat(:)
real(rkind),allocatable :: dat(:) ! dat(:)
endtype dlength
! ** integer type (4 byte)
type, public :: ilength
Expand Down Expand Up @@ -168,7 +168,7 @@ MODULE data_types

! ** double precision type of fixed length
type, public :: var_d
real(dp),allocatable :: var(:) ! var(:)
real(rkind),allocatable :: var(:) ! var(:)
endtype var_d
! ** integer type of fixed length (4 byte)
type, public :: var_i
Expand All @@ -181,7 +181,7 @@ MODULE data_types

! ** double precision type of fixed length
type, public :: hru_d
real(dp),allocatable :: hru(:) ! hru(:)
real(rkind),allocatable :: hru(:) ! hru(:)
endtype hru_d
! ** integer type of fixed length (4 byte)
type, public :: hru_i
Expand Down
3 changes: 3 additions & 0 deletions build/source/dshare/get_ixname.f90
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ function get_ixAttr(varName)
case('contourLength' ); get_ixAttr = iLookATTR%contourLength ! length of contour at downslope edge of HRU (m)
case('HRUarea' ); get_ixAttr = iLookATTR%HRUarea ! area of each HRU (m2)
case('mHeight' ); get_ixAttr = iLookATTR%mHeight ! measurement height above bare ground (m)
case('aspect' ); get_ixAttr = iLookATTR%aspect ! azimuth in degrees East of North (degrees)
! get to here if cannot find the variable
case default
get_ixAttr = integerMissing
Expand Down Expand Up @@ -886,6 +887,8 @@ function get_ixbvar(varName)
case('basin__AquiferRecharge' ); get_ixbvar = iLookBVAR%basin__AquiferRecharge ! recharge to the aquifer (m s-1)
case('basin__AquiferBaseflow' ); get_ixbvar = iLookBVAR%basin__AquiferBaseflow ! baseflow from the aquifer (m s-1)
case('basin__AquiferTranspire' ); get_ixbvar = iLookBVAR%basin__AquiferTranspire ! transpiration from the aquifer (m s-1)
case('basin__TotalRunoff' ); get_ixbvar = iLookBVAR%basin__TotalRunoff ! total runoff to channel from all active components (m s-1)
case('basin__SoilDrainage' ); get_ixbvar = iLookBVAR%basin__SoilDrainage ! soil drainage (m s-1)
! variables to compute runoff
case('routingRunoffFuture' ); get_ixbvar = iLookBVAR%routingRunoffFuture ! runoff in future time steps (m s-1)
case('routingFractionFuture' ); get_ixbvar = iLookBVAR%routingFractionFuture ! fraction of runoff in future time steps (-)
Expand Down
Loading