Skip to content

Commit

Permalink
Merge pull request #421 from NCAR/develop
Browse files Browse the repository at this point in the history
Prep for 3.0.1 release
  • Loading branch information
arbennett authored Sep 8, 2020
2 parents a843a8c + dc28171 commit 079d249
Show file tree
Hide file tree
Showing 21 changed files with 190 additions and 103 deletions.
13 changes: 9 additions & 4 deletions build/source/driver/summa_init.f90
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ module summa_init
USE globalData,only:statBvar_meta ! child metadata for stats

! provide access to file paths
USE summaFileManager,only:SETNGS_PATH ! define path to settings files (e.g., Noah vegetation tables)
USE summaFileManager,only:SETTINGS_PATH ! define path to settings files (e.g., parameters, soil and veg. tables)
USE summaFileManager,only:STATE_PATH ! optional path to state/init. condition files (defaults to SETTINGS_PATH)
USE summaFileManager,only:MODEL_INITCOND ! name of model initial conditions file
USE summaFileManager,only:LOCAL_ATTRIBUTES ! name of model initial attributes file
USE summaFileManager,only:OUTPUT_PATH,OUTPUT_PREFIX ! define output file
Expand Down Expand Up @@ -194,7 +195,7 @@ subroutine summa_initialize(summa1_struc, err, message)
! *** read the number of GRUs and HRUs
! *****************************************************************************
! obtain the HRU and GRU dimensions in the LocalAttribute file
attrFile = trim(SETNGS_PATH)//trim(LOCAL_ATTRIBUTES)
attrFile = trim(SETTINGS_PATH)//trim(LOCAL_ATTRIBUTES)
select case (iRunMode)
case(iRunModeFull); call read_dimension(trim(attrFile),fileGRU,fileHRU,nGRU,nHRU,err,cmessage)
case(iRunModeGRU ); call read_dimension(trim(attrFile),fileGRU,fileHRU,nGRU,nHRU,err,cmessage,startGRU=startGRU)
Expand All @@ -205,8 +206,12 @@ subroutine summa_initialize(summa1_struc, err, message)
! *****************************************************************************
! *** read the number of snow and soil layers
! *****************************************************************************
! obtain the number of snow and soil layers from the initial conditions file
restartFile = trim(SETNGS_PATH)//trim(MODEL_INITCOND)
! set restart filename and read the number of snow and soil layers from the initial conditions (restart) file
if(STATE_PATH == '') then
restartFile = trim(SETTINGS_PATH)//trim(MODEL_INITCOND)
else
restartFile = trim(STATE_PATH)//trim(MODEL_INITCOND)
endif
call read_icond_nlayers(trim(restartFile),nGRU,indx_meta,err,cmessage)
if(err/=0)then; message=trim(message)//trim(cmessage); return; endif

Expand Down
11 changes: 8 additions & 3 deletions build/source/driver/summa_restart.f90
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ subroutine summa_readRestart(summa1_struc, err, message)
USE globalData,only:gru_struc ! gru-hru mapping structures
USE globalData,only:model_decisions ! model decision structure
! file paths
USE summaFileManager,only:SETNGS_PATH ! define path to settings files (e.g., Noah vegetation tables)
USE summaFileManager,only:SETTINGS_PATH ! path to settings files (e.g., Noah vegetation tables)
USE summaFileManager,only:STATE_PATH ! optional path to state/init. condition files (defaults to SETTINGS_PATH)
USE summaFileManager,only:MODEL_INITCOND ! name of model initial conditions file
! timing variables
USE globalData,only:startRestart,endRestart ! date/time for the start and end of reading model restart files
Expand Down Expand Up @@ -111,8 +112,12 @@ subroutine summa_readRestart(summa1_struc, err, message)
! *** read/check initial conditions
! *****************************************************************************

! define restart file
restartFile = trim(SETNGS_PATH)//trim(MODEL_INITCOND)
! define restart file path/name
if(STATE_PATH == '') then
restartFile = trim(SETTINGS_PATH)//trim(MODEL_INITCOND)
else
restartFile = trim(STATE_PATH)//trim(MODEL_INITCOND)
endif

! read initial conditions
call read_icond(restartFile, & ! intent(in): name of initial conditions file
Expand Down
12 changes: 6 additions & 6 deletions build/source/driver/summa_setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ subroutine summa_paramSetup(summa1_struc, err, message)
USE globalData,only:startSetup,endSetup ! date/time for the start and end of the parameter setup
USE globalData,only:elapsedSetup ! elapsed time for the parameter setup
! file paths
USE summaFileManager,only:SETNGS_PATH ! define path to settings files (e.g., Noah vegetation tables)
USE summaFileManager,only:SETTINGS_PATH ! define path to settings files (e.g., parameters, soil and veg. tables)
USE summaFileManager,only:LOCAL_ATTRIBUTES ! name of model initial attributes file
USE summaFileManager,only:LOCALPARAM_INFO,BASINPARAM_INFO ! files defining the default values and constraints for model parameters
USE summaFileManager,only:GENPARM,VEGPARM,SOILPARM,MPTABLE ! files defining the noah tables
Expand Down Expand Up @@ -168,7 +168,7 @@ subroutine summa_paramSetup(summa1_struc, err, message)
! *****************************************************************************

! define the attributes file
attrFile = trim(SETNGS_PATH)//trim(LOCAL_ATTRIBUTES)
attrFile = trim(SETTINGS_PATH)//trim(LOCAL_ATTRIBUTES)

! read local attributes for each HRU
call read_attrb(trim(attrFile),nGRU,attrStruct,typeStruct,idStruct,err,cmessage)
Expand All @@ -194,14 +194,14 @@ subroutine summa_paramSetup(summa1_struc, err, message)
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/)

! read Noah soil and vegetation tables
call soil_veg_gen_parm(trim(SETNGS_PATH)//trim(VEGPARM), & ! filename for vegetation table
trim(SETNGS_PATH)//trim(SOILPARM), & ! filename for soils table
trim(SETNGS_PATH)//trim(GENPARM), & ! filename for general table
call soil_veg_gen_parm(trim(SETTINGS_PATH)//trim(VEGPARM), & ! filename for vegetation table
trim(SETTINGS_PATH)//trim(SOILPARM), & ! filename for soils table
trim(SETTINGS_PATH)//trim(GENPARM), & ! filename for general table
trim(model_decisions(iLookDECISIONS%vegeParTbl)%cDecision), & ! classification system used for vegetation
trim(model_decisions(iLookDECISIONS%soilCatTbl)%cDecision)) ! classification system used for soils

! read Noah-MP vegetation tables
call read_mp_veg_parameters(trim(SETNGS_PATH)//trim(MPTABLE), & ! filename for Noah-MP table
call read_mp_veg_parameters(trim(SETTINGS_PATH)//trim(MPTABLE), & ! filename for Noah-MP table
trim(model_decisions(iLookDECISIONS%vegeParTbl)%cDecision)) ! classification system used for vegetation

! define urban vegetation category
Expand Down
13 changes: 10 additions & 3 deletions build/source/driver/summa_writeOutput.f90
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ subroutine summa_writeOutputFiles(modelTimeStep, summa1_struc, err, message)
USE globalData,only:elapsedWrite ! elapsed time to write data
! file information
USE summaFileManager,only:OUTPUT_PATH,OUTPUT_PREFIX ! define output file
USE globalData,only:output_fileSuffix ! suffix for the output file
USE summaFileManager,only:STATE_PATH ! optional path to state output files (defaults to OUTPUT_PATH)
USE globalData,only:output_fileSuffix ! suffix for the output & state files (optional summa argument)
USE globalData,only:nHRUrun ! number of HRU in the run
USE globalData,only:nGRUrun ! number of GRU in the run
! ---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -278,8 +279,14 @@ subroutine summa_writeOutputFiles(modelTimeStep, summa1_struc, err, message)

! print a restart file if requested
if(printRestart)then
write(timeString,'(a,i4,3(a,i2.2))') '_',timeStruct%var(iLookTIME%iyyy),'-',timeStruct%var(iLookTIME%im),'-',timeStruct%var(iLookTIME%id),'-',timeStruct%var(iLookTIME%ih)
restartFile=trim(OUTPUT_PATH)//trim(OUTPUT_PREFIX)//'_'//trim('summaRestart')//trim(timeString)//trim(output_fileSuffix)//'.nc'
write(timeString,'(i4,3(i2.2))') timeStruct%var(iLookTIME%iyyy),timeStruct%var(iLookTIME%im),timeStruct%var(iLookTIME%id),timeStruct%var(iLookTIME%ih)

if(STATE_PATH == '') then
restartFile=trim(OUTPUT_PATH)//trim(OUTPUT_PREFIX)//'_restart_'//trim(timeString)//trim(output_fileSuffix)//'.nc'
else
restartFile=trim(STATE_PATH)//trim(OUTPUT_PREFIX)//'_restart_'//trim(timeString)//trim(output_fileSuffix)//'.nc'
endif

call writeRestart(restartFile,nGRU,nHRU,prog_meta,progStruct,maxLayers,maxSnowLayers,indx_meta,indxStruct,err,cmessage)
if(err/=0)then; message=trim(message)//trim(cmessage); return; endif
end if
Expand Down
2 changes: 1 addition & 1 deletion build/source/dshare/globalData.f90
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ MODULE globalData
integer(i4b),parameter,public :: iname_snow=1003 ! named variable to denote a snow layer
integer(i4b),parameter,public :: iname_aquifer=1004 ! named variable to denote a snow layer

! define named variables to describe the state varible type
! define named variables to describe the state variable type
integer(i4b),parameter,public :: iname_nrgCanair=2001 ! named variable defining the energy of the canopy air space
integer(i4b),parameter,public :: iname_nrgCanopy=2002 ! named variable defining the energy of the vegetation canopy
integer(i4b),parameter,public :: iname_watCanopy=2003 ! named variable defining the mass of total water on the vegetation canopy
Expand Down
4 changes: 2 additions & 2 deletions build/source/dshare/popMetadat.f90
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ end subroutine popMetadat
subroutine read_output_file(err,message)
USE netcdf
! to get name of output control file from user
USE summaFileManager,only:SETNGS_PATH ! path for metadata files
USE summaFileManager,only:SETTINGS_PATH ! path for metadata files
USE summaFileManager,only:OUTPUT_CONTROL ! file with output controls

! some dimensional parameters
Expand Down Expand Up @@ -764,7 +764,7 @@ subroutine read_output_file(err,message)
! **********************************************************************************************
! (1) open file and read variable data
! **********************************************************************************************
outfile = trim(SETNGS_PATH)//trim(OUTPUT_CONTROL) ! build filename
outfile = trim(SETTINGS_PATH)//trim(OUTPUT_CONTROL) ! build filename
call file_open(trim(outfile),unt,err,cmessage) ! open file
if(err/=0)then; message=trim(message)//trim(cmessage); return; end if

Expand Down
5 changes: 4 additions & 1 deletion build/source/engine/computResid.f90
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ subroutine computResid(&
! --> energy balance
if(ixCasNrg/=integerMissing) rVec(ixCasNrg) = sMul(ixCasNrg)*scalarCanairTempTrial - ( (sMul(ixCasNrg)*scalarCanairTemp + fVec(ixCasNrg)*dt) + rAdd(ixCasNrg) )
if(ixVegNrg/=integerMissing) rVec(ixVegNrg) = sMul(ixVegNrg)*scalarCanopyTempTrial - ( (sMul(ixVegNrg)*scalarCanopyTemp + fVec(ixVegNrg)*dt) + rAdd(ixVegNrg) )

! --> mass balance
if(ixVegHyd/=integerMissing)then
scalarCanopyHyd = merge(scalarCanopyWat, scalarCanopyLiq, (ixStateType( ixHydCanopy(ixVegVolume) )==iname_watCanopy) )
Expand Down Expand Up @@ -261,7 +262,9 @@ subroutine computResid(&

! check
if(any(isNan(rVec)))then
message=trim(message)//'we found some Indian bread (NaN)'
message=trim(message)//'we found some Indian bread (NaN) '
write(*,'(a,1x,100(e12.5,1x))') 'rVec = ', rVec(min(iJac1,size(rVec)):min(iJac2,size(rVec)))
write(*,'(a,1x,100(e12.5,1x))') 'fVec = ', fVec(min(iJac1,size(rVec)):min(iJac2,size(rVec)))
err=20; return
endif

Expand Down
15 changes: 5 additions & 10 deletions build/source/engine/ffile_info.f90
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ subroutine ffile_info(nGRU,err,message)
USE ascii_util_module,only:linewidth
USE netcdf_util_module,only:nc_file_open ! open netCDF file
USE netcdf_util_module,only:netcdf_err ! netcdf error handling function
USE summaFileManager,only:SETNGS_PATH ! path for metadata files
USE summaFileManager,only:INPUT_PATH ! path for forcing files
USE summaFileManager,only:SETTINGS_PATH ! path for metadata files
USE summaFileManager,only:FORCING_PATH ! path for forcing files
USE summaFileManager,only:FORCING_FILELIST ! list of model forcing files
USE globalData,only:forcFileInfo,data_step ! info on model forcing file
USE globalData,only:forc_meta ! forcing metadata
Expand Down Expand Up @@ -82,8 +82,8 @@ subroutine ffile_info(nGRU,err,message)
! ------------------------------------------------------------------------------------------------------------------
! (1) read from the list of forcing files
! ------------------------------------------------------------------------------------------------------------------
! build filename for forcing file list
infile = trim(SETNGS_PATH)//trim(FORCING_FILELIST)
! build filename for forcing-file list file
infile = trim(SETTINGS_PATH)//trim(FORCING_FILELIST)

! open file
call file_open(trim(infile),unt,err,cmessage)
Expand Down Expand Up @@ -133,7 +133,7 @@ subroutine ffile_info(nGRU,err,message)
forcFileInfo(iFile)%data_id(:) = integerMissing

! build filename for actual forcing file
infile = trim(INPUT_PATH)//trim(forcFileInfo(iFile)%filenmData)
infile = trim(FORCING_PATH)//trim(forcFileInfo(iFile)%filenmData)
! check if file exists
inquire(file=trim(infile),exist=xist)
if(.not.xist)then
Expand Down Expand Up @@ -228,8 +228,6 @@ subroutine ffile_info(nGRU,err,message)
err = nf90_inq_varid(ncid,trim(varname),varId)
if(err/=0)then; message=trim(message)//'hruID variable not present'; return; endif

ixHRUfile_min=huge(1)
ixHRUfile_max=0
! check that the hruId is what we expect
! NOTE: we enforce that the HRU order in the forcing files is the same as in the zLocalAttributes files (too slow otherwise)
do iGRU=1,nGRU
Expand All @@ -242,9 +240,6 @@ subroutine ffile_info(nGRU,err,message)
write(message,'(a)') trim(message)//' order of hruId in forcing file needs to match order in zLocalAttributes.nc'
err=40; return
endif
! save the index of the minimum and maximum HRUs in the file
if(gru_struc(iGRU)%hruInfo(localHRU_ix)%hru_nc < ixHRUfile_min) ixHRUfile_min = gru_struc(iGRU)%hruInfo(localHRU_ix)%hru_nc
if(gru_struc(iGRU)%hruInfo(localHRU_ix)%hru_nc > ixHRUfile_max) ixHRUfile_max = gru_struc(iGRU)%hruInfo(localHRU_ix)%hru_nc
end do
end do

Expand Down
4 changes: 2 additions & 2 deletions build/source/engine/mDecisions.f90
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ subroutine readoption(err,message)
USE ascii_util_module,only:file_open ! open file
USE ascii_util_module,only:linewidth ! max character number for one line
USE ascii_util_module,only:get_vlines ! get a vector of non-comment lines
USE summaFileManager,only:SETNGS_PATH ! path for metadata files
USE summaFileManager,only:SETTINGS_PATH ! path for metadata files
USE summaFileManager,only:M_DECISIONS ! definition of modeling options
USE get_ixname_module,only:get_ixdecisions ! identify index of named variable
USE globalData,only:model_decisions ! model decision structure
Expand All @@ -715,7 +715,7 @@ subroutine readoption(err,message)
! Start procedure here
err=0; message='readoption/'
! build filename
infile = trim(SETNGS_PATH)//trim(M_DECISIONS)
infile = trim(SETTINGS_PATH)//trim(M_DECISIONS)
write(*,'(2(a,1x))') 'decisions file = ', trim(infile)
! open file
call file_open(trim(infile),unt,err,cmessage)
Expand Down
20 changes: 14 additions & 6 deletions build/source/engine/read_attrb.f90
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ subroutine read_dimension(attrFile,fileGRU,fileHRU,nGRU,nHRU,err,message,startGR

! locals
integer(i4b) :: sGRU ! starting GRU
integer(i4b) :: iHRU ! HRU couinting index
integer(i4b) :: iHRU ! HRU counting index
integer(i4b) :: jHRU ! HRU index within GRU
integer(i4b) :: iGRU ! GRU loop index
integer(8),allocatable :: gru_id(:),hru_id(:)! read gru/hru IDs in from attributes file
integer(8),allocatable :: hru2gru_id(:) ! read hru->gru mapping in from attributes file
Expand All @@ -68,7 +69,7 @@ subroutine read_dimension(attrFile,fileGRU,fileHRU,nGRU,nHRU,err,message,startGR
err=0; message="read_dimension/"

! check that we do not have conflicting flags
if(present(startGRU).and.present(checkHRU))then; message=trim(message)//'startGRU and checkHRU both exist'; return; end if
if(present(startGRU).and.present(checkHRU))then; message=trim(message)//'startGRU and checkHRU both exist, which is not supported'; return; end if

! open nc file
call nc_file_open(trim(attrFile),nf90_noWrite,ncID,err,cmessage)
Expand Down Expand Up @@ -97,8 +98,12 @@ subroutine read_dimension(attrFile,fileGRU,fileHRU,nGRU,nHRU,err,message,startGR
endif

! check dimensions
if ((present(startGRU)).and.(startGRU + nGRU - 1 > fileGRU)) then; err=20; message=trim(message)//'startGRU + nGRU is larger than then the GRU dimension'; return; end if
if ((present(checkHRU)).and.(checkHRU > fileHRU)) then; err=20; message=trim(message)//'checkHRU is larger than then the HRU dimension' ; return; end if
if (present(startGRU)) then
if(startGRU + nGRU - 1 > fileGRU) then; err=20; message=trim(message)//'startGRU + nGRU is larger than then the GRU dimension'; return; end if
end if
if (present(checkHRU)) then
if(checkHRU > fileHRU) then; err=20; message=trim(message)//'checkHRU is larger than then the HRU dimension'; return; end if
end if

! *********************************************************************************************
! read mapping vectors and populate mapping structures
Expand Down Expand Up @@ -176,9 +181,12 @@ subroutine read_dimension(attrFile,fileGRU,fileHRU,nGRU,nHRU,err,message,startGR
index_map(1)%localHRU_ix = hru_ix(1) ! index of hru within the gru

else ! anything other than a single HRU run

do iGRU = 1,nGRU
index_map(gru_struc(iGRU)%hruInfo(:)%hru_ix)%gru_ix = iGRU ! index of gru in run domain to which the hru belongs
index_map(gru_struc(iGRU)%hruInfo(:)%hru_ix)%localHRU_ix = hru_ix(1:gru_struc(iGRU)%hruCount)! index of hru within the gru
do jHRU = 1,gru_struc(iGRU)%hruCount
index_map(gru_struc(iGRU)%hruInfo(jHRU)%hru_nc)%gru_ix = iGRU ! index of gru in run domain to which the hru belongs
index_map(gru_struc(iGRU)%hruInfo(jHRU)%hru_nc)%localHRU_ix = jHRU ! index of hru within the gru
end do ! jHRU = 1,gru_struc(iGRU)%hruCount
enddo ! iGRU = 1,nGRU

end if ! not checkHRU
Expand Down
10 changes: 5 additions & 5 deletions build/source/engine/read_force.f90
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module read_force_module
USE var_lookup,only:iLookDECISIONS ! named variables for elements of the decision structure

! file paths
USE summaFileManager,only:INPUT_PATH ! path of the forcing data file
USE summaFileManager,only:FORCING_PATH ! path of the forcing data file

! privacy
implicit none
Expand Down Expand Up @@ -145,8 +145,8 @@ subroutine read_force(istep,iFile,iRead,ncid,time_data,forcStruct,err,message)
err=20; return
endif

! define new filename
infile=trim(INPUT_PATH)//trim(forcFileInfo(iFile)%filenmData)
! define new forcing filename
infile=trim(FORCING_PATH)//trim(forcFileInfo(iFile)%filenmData)

! open up the forcing file
call openForcingFile(iFile,trim(infile),ncId,err,cmessage)
Expand Down Expand Up @@ -264,8 +264,8 @@ subroutine getFirstTimestep(currentJulday,iFile,iRead,ncid,err,message)
! keep going until we find the file containing the first time step
do iFile=1,nFiles

! define new filename
infile=trim(INPUT_PATH)//trim(forcFileInfo(iFile)%filenmData)
! define new forcing filename
infile=trim(FORCING_PATH)//trim(forcFileInfo(iFile)%filenmData)

! open netCDF file
call openForcingFile(iFile,trim(infile),ncId,err,cmessage)
Expand Down
Loading

0 comments on commit 079d249

Please sign in to comment.