260 likes | 429 Views
MAIN PROGRAM. Code structure - HYSS. Handle input and output data. Calibration and criteria calculation. S Y S T E M. H Y S S. M O D E L. A hydrological model. eg. H Y P E. MODVAR and MODELMODULE. State variables Variables for model parameters
E N D
MAIN PROGRAM Codestructure- HYSS Handle input and output data Calibration and criteriacalculation S Y S T E M H Y S S M O D E L A hydrologicalmodel eg. H Y P E
MODVAR and MODELMODULE • State variables • Variables for model parameters • Variables for input and output • Derived data typedeclarations • Othervariables (time, numberofsubbasinsetc.) • MODEL – calculationsduringonetime step • INITIATE_MODEL – sets initial values for statevariables, initialisationofmodel parameters • INITIATE_MODEL_PARAMETERS – definition ofmodel parameters • INITIATE_OUTPUT_VARIABLES – definition of output variables • MODEL_VERSION_INFORMATION – information for log-file • DEFINE_AND_ALLOCATE_MODELMODULE_STATE – definition ofself-definedstatevariables • GET_MODELMODULE_STATE – get values for self-definedstatevariables from HYSS • SET_MODELMODULE_STATE – save valuesofself-definedstatevariables for HYSS HYSS variables for the model Modelsubroutines for HYSS
MAIN PROGRAM Read INPUT DATA Optimization loop Time loop Write RESULT and CRITERIA Time loop Calculate new parameters MODEL Prepare OUTPUT MODEL
MAIN PROGRAM read info model, simulation and input data optimization model- and output initiation time loop write result and criteria read opt. input data MODEL calc. crit. print out during simulation timestep input opt. loop write opt. result mod. init. set best parameters time loop timestep input MODEL calc. crit. calculate new parameters
FILES and MODULES ofHYSS and HYPE
main.f90 HYSS/HYPE – source codefiles worldvar.f90 S Y S T E M optim.f90 data.f90 • 13 files • 20000 linesofcode • 7 Fortran modules • + three extra in hype • 243 procedures • 66 ofthese in hype H Y S S readwrite.f90 compout.f90 convert.f90 modvar.f90 time.f90 model_hype.f90 H Y P E M O D E L npproc_2.f90 tocproc.f90 hypevar.f90
HYSS/HYPE – source code files • main.f90 main program • data.f90 subroutines for indata and print out • optim.f90 subroutines for optimization • compout.f90 subroutines for calculations in HYSS; for accumulation (for print out) and criteria • readwrite.f90 subroutines for read and writetofile • time.f90, convert.f90 subroutines for time and conversion • worvar.f90 variables in HYSS and subroutines for these • modvar.f90 variables for the model and subroutines for these • model_hype.f90 subroutines for HYPE-modelrequired by HYSS and subroutines for water • hypevar.f90 variables for HYPE • npproc2.f90 subroutines for nitrogen and phosphorus • tocproc.f90 subroutines for organiccarbon
main.f90 Modulehierarchy(short names) data.f90 optim.f90 modelmodule readwrite compout convert timeroutines toc_processes worldvar np_processes modvar hypevar
main.f90 Moduledependence data.f90 optim.f90 modelmodule readwrite compout convert timeroutines toc_processes worldvar np_processes modvar hypevar
Someprinciples • Fortran 90/95, free format • Balance explicit code /calls to subroutines. • ! is used for comments. Comment blocks before or specific lines to the right. • Subroutines: name after END SUBROUTINE, use INTENT on all arguments • Name major DO-loops • IMPLICIT NONE is used • Use x(:) for an array than x or x(1:n) if possible. • Fileunits: Specific fileunits set in WORLDVAR. 6 is used for hyss.log. fileunit_temp for temporary
Someother tips • Your own model variables can be declared in the MODELMODULE or in a separate module. These are used via "USE" or host association. • In HYSS -9999 denotes missing values. • All files are ASCII files. • Maximum 200 output variables and 200 model parameters can be defined. • All output variables and parameter names are to be defined with small letters • The connection between output variables and their value is an index which may be a defined constant in the modelmodule. E.g. m_tt=1, o_snow=3
MODVAR - details Variablesmadeavailable by HYSS to the modelprogrammer
END HERE? • Questions? • A fileyouwanttohave a closer look at?
MODEL subroutine - details Calculationsduringonetime step for HYPE
MODEL() for HYPE For everysubbasin: Regional groundwaterflows (for everysubbasin/class) Class processes Routing (river and lake processes) Prepare for output For local and main river/lake: For land classes: For lake classes: River flow Transformation (NPC) Outflow from lake Updating (QW) Snow Soilrunoff Groundwater table transformations in soil (NPC) Subbasinavarage Atmospheric deposition (NPC) Precipitation Evaporation Exampleofcalculations
Calculation order land class • Atmospheric deposition (NPC) • Precipitation • Plant growth (NPC) • Snow • Evapotranspiration • Runoff(soillayer, tile) • Add regional groundwaterflow • Diffuse source (NP) • Otherflows (surfaceflow, macroporeflow) • Add infiltration • Snowdepth, soiltemp, frostdepth
Calculation order land class (continued) • Percolation • Surface flow, erosion (P) • Addmacroporeflow • Delaypool (P) • Groundwater table • NPC transformations in soil • Subbasinavarage
Calculation order lake class • Atmosphericdeposition (NPC) • Precipitation • Evaporation
Couplingbetweensubbasins local river and lake main river and outlet lake groundwaterpaths surfacewaterpath
Calculationlocal river and lake • Riparian zone C processes • Watertemperature • Inflow from soil • Diffuse source (NP) • Wetland (NP) • River flowdelay • transformation in river (NPC) • Inflowto lake • transformation in lake (NPC) • Outflow from lake • Lake waterstage
Calculationmain river and lake • Inflow from upstreamsubbasins • Point sources (NP) • Wetland (NP) • River flowdelay • transformation in river (NPC) • Inflowto lake • transformation in lake (NPC) • Outflow from lake/subbasin • Lake waterstage • Within lake flows • Updating QW