Skip to content

Commit

Permalink
Merge pull request #408 from arbennett/refactor/config_names
Browse files Browse the repository at this point in the history
Rename variables for file manager, update conversion script
  • Loading branch information
bartnijssen authored Jul 20, 2020
2 parents d0fac1c + cb0ed87 commit fd9ef03
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 28 deletions.
9 changes: 5 additions & 4 deletions build/source/driver/summa_setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ subroutine summa_paramSetup(summa1_struc, err, message)
USE summaFileManager,only:SETNGS_PATH ! define path to settings files (e.g., Noah vegetation 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
! Noah-MP parameters
USE NOAHMP_VEG_PARAMETERS,only:SAIM,LAIM ! 2-d tables for stem area index and leaf area index (vegType,month)
USE NOAHMP_VEG_PARAMETERS,only:HVT,HVB ! height at the top and bottom of vegetation (vegType)
Expand Down Expand Up @@ -193,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)//'VEGPARM.TBL', & ! filename for vegetation table
trim(SETNGS_PATH)//'SOILPARM.TBL', & ! filename for soils table
trim(SETNGS_PATH)//'GENPARM.TBL', & ! filename for general table
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
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)//'MPTABLE.TBL', & ! filename for Noah-MP table
call read_mp_veg_parameters(trim(SETNGS_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
38 changes: 23 additions & 15 deletions build/source/hookup/summaFileManager.f90
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ MODULE summaFileManager
CHARACTER(LEN=summaPathLen) :: LOCAL_ATTRIBUTES = 'summa_zLocalAttributes.txt' ! local attributes
CHARACTER(LEN=summaPathLen) :: LOCALPARAM_INFO = 'summa_zLocalParamInfo.txt' ! default values and constraints for local model parameters
CHARACTER(LEN=summaPathLen) :: BASINPARAM_INFO = 'summa_zBasinParamInfo.txt' ! default values and constraints for basin model parameters
CHARACTER(LEN=summaPathLen) :: VEGPARM = 'VEGPARM.TBL' ! noah vegetation parameter table
CHARACTER(LEN=summaPathLen) :: SOILPARM = 'SOILPARM.TBL' ! noah soil parameter table
CHARACTER(LEN=summaPathLen) :: GENPARM = 'GENPARM.TBL' ! noah general parameter table
CHARACTER(LEN=summaPathLen) :: MPTABLE = 'MPTABLE.TBL' ! noah mp parameter table
CHARACTER(LEN=summaPathLen) :: FORCING_FILELIST = 'summa_zForcingFileList.txt' ! list of focing files for each HRU
CHARACTER(LEN=summaPathLen) :: MODEL_INITCOND = 'summa_zInitialCond.txt' ! model initial conditions
CHARACTER(LEN=summaPathLen) :: PARAMETER_TRIAL = 'summa_zParamTrial.txt' ! trial values for model parameters
Expand Down Expand Up @@ -110,21 +114,25 @@ subroutine summa_SetTimesDirsAndFiles(summaFileManagerIn,err,message)
err=20
return
end if
case('simStartTime' ); SIM_START_TM = trim(varEntry) ! start simulation time
case('simEndTime' ); SIM_END_TM = trim(varEntry) ! end simulation time
case('tmZoneInfo' ); NC_TIME_ZONE = trim(varEntry) ! time zone info
case('settingsPath' ); SETNGS_PATH = trim(varEntry) ! settings directory
case('forcingPath' ); INPUT_PATH = trim(varEntry) ! input forcing directory
case('outputPath' ); OUTPUT_PATH = trim(varEntry) ! output directory
case('decisionsFile' ); M_DECISIONS = trim(varEntry) ! model decisions file
case('outputDefFile' ); OUTPUT_CONTROL = trim(varEntry) ! output control file
case('hruParamFile' ); LOCALPARAM_INFO = trim(varEntry) ! default hru-level param file
case('gruParamFile' ); BASINPARAM_INFO = trim(varEntry) ! default gru-level param file
case('attributeFile' ); LOCAL_ATTRIBUTES = trim(varEntry) ! attribute file
case('trialParamFile' ); PARAMETER_TRIAL = trim(varEntry) ! trial parameters file
case('forcingList' ); FORCING_FILELIST = trim(varEntry) ! file listing forcing filenames
case('initCondFile' ); MODEL_INITCOND = trim(varEntry) ! initial conditions file (cold State)
case('outFilePrefix' ); OUTPUT_PREFIX = trim(varEntry) ! filename root for output files
case('simStartTime' ); SIM_START_TM = trim(varEntry) ! start simulation time
case('simEndTime' ); SIM_END_TM = trim(varEntry) ! end simulation time
case('tmZoneInfo' ); NC_TIME_ZONE = trim(varEntry) ! time zone info
case('settingsPath' ); SETNGS_PATH = trim(varEntry) ! settings directory
case('forcingPath' ); INPUT_PATH = trim(varEntry) ! input forcing directory
case('outputPath' ); OUTPUT_PATH = trim(varEntry) ! output directory
case('decisionsFile' ); M_DECISIONS = trim(varEntry) ! model decisions file
case('outputControlFile' ); OUTPUT_CONTROL = trim(varEntry) ! output control file
case('globalHruParamFile' ); LOCALPARAM_INFO = trim(varEntry) ! default hru-level param file
case('globalGruParamFile' ); BASINPARAM_INFO = trim(varEntry) ! default gru-level param file
case('attributeFile' ); LOCAL_ATTRIBUTES = trim(varEntry) ! attribute file
case('trialParamFile' ); PARAMETER_TRIAL = trim(varEntry) ! trial parameters file
case('vegTableFile' ); VEGPARM = trim(varEntry) ! vegetation parameter table
case('soilTableFile' ); SOILPARM = trim(varEntry) ! soil parameter table
case('generalTableFile' ); GENPARM = trim(varEntry) ! general parameter table
case('noahmpTableFile' ); MPTABLE = trim(varEntry) ! noah mp parameter table
case('forcingListFile' ); FORCING_FILELIST = trim(varEntry) ! file listing forcing filenames
case('initConditionFile' ); MODEL_INITCOND = trim(varEntry) ! initial conditions file (cold State)
case('outFilePrefix' ); OUTPUT_PREFIX = trim(varEntry) ! filename root for output files
! get to here if cannot find the variable
case default
err=10; message=trim(message)//"unknown control file option: "//trim(option); return
Expand Down
23 changes: 14 additions & 9 deletions utils/convert_summa_config_v2_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@
fm_v2_keys = ['controlVersion', 'settingsPath', 'forcingPath',
'outputPath', 'decisionsFile', 'notused_1',
'notused_2', 'notused_3', 'notused_4',
'notused_5', 'outputDefFile', 'notused_6',
'notused_5', 'outputControlFile', 'notused_6',
'notused_7', 'notused_8', 'attributeFile',
'hruParamFile', 'gruParamFile', 'forcingList',
'initCondFile', 'trialParamFile', 'outFilePrefix']
'globalHruParamFile', 'globalGruParamFile', 'forcingListFile',
'initConditionFile', 'trialParamFile', 'outFilePrefix']

fm_v3_keys = ['controlVersion', 'simStartTime' , 'simEndTime',
fm_v3_keys = ['controlVersion', 'simStartTime', 'simEndTime',
'tmZoneInfo', 'settingsPath', 'forcingPath',
'outputPath', 'decisionsFile', 'outputDefFile',
'hruParamFile', 'gruParamFile', 'attributeFile',
'trialParamFile', 'forcingList', 'initCondFile',
'outFilePrefix']
'outputPath', 'decisionsFile', 'outputControlFile',
'globalHruParamFile', 'globalGruParamFile', 'attributeFile',
'trialParamFile', 'forcingListFile', 'initConditionFile',
'outFilePrefix', 'vegTableFile', 'soilTableFile',
'generalTableFile', 'noahmpTableFile']

decision_v2_to_fm_v3 = {'simulStart': 'simStartTime',
'simulFinsh': 'simEndTime',
Expand Down Expand Up @@ -112,6 +113,10 @@ def fm_v3_create(fm_v2, fm_v2_comments):
fm_v3_comments[key] = ''

fm_v3['controlVersion'] = 'SUMMA_FILE_MANAGER_V3.0.0'
fm_v3['vegTableFile'] = 'VEGPARM.TBL'
fm_v3['soilTableFile'] = 'SOILPARM.TBL'
fm_v3['generalTableFile'] = 'GENPARM.TBL'
fm_v3['noahmpTableFile'] = 'MPTABLE.TBL'
return fm_v3, fm_v3_comments


Expand Down Expand Up @@ -186,7 +191,7 @@ def make_backup(path, ext='.v2'):
# Make copies by appending v2 to each of the file names
fm_v3_path, fm_v2_path = make_backup(fm_v2_path)
dec_v3_path, dec_v2_path = make_backup(dec_v2_path)
hruparam_v3_path, hruparam_v2_path = make_backup(os.path.join(fm_v2['settingsPath'], fm_v2['hruParamFile']))
hruparam_v3_path, hruparam_v2_path = make_backup(os.path.join(fm_v2['settingsPath'], fm_v2['globalHruParamFile']))

# create a history string to be passed to all updated files
history = '{} history {}: {}\n'.format(comment_sep, datetime.now().strftime('%c'), ' '.join(sys.argv))
Expand Down

0 comments on commit fd9ef03

Please sign in to comment.