DEFINITION MODULE ForSiteDatIO;
(*******************************************************************
Module ForSiteDatIO (Version 1.0)
Copyright (c) 1997-2006 by Dimitrios Gyalistras, Andreas Fischlin
and ETH Zurich.
Purpose Read and write "site data" files as required
by the forest model ForClim (versions < 3.0).
Remarks --
Programming
o Design
Dimitrios Gyalistras 16/02/1997
o Implementation
Dimitrios Gyalistras 16/02/1997
Andreas Fischlin 11/05/2001
ETH Zurich
Systems Ecology
CHN E 35.1
Universitaetstrasse 16
8092 Zurich
SWITZERLAND
URLs:
<mailto:RAMSES@env.ethz.ch>
<http://www.sysecol.ethz.ch>
<http://www.sysecol.ethz.ch/SimSoftware/RAMSES>
Last revision of definition: 10/03/2004 DG
*******************************************************************)
IMPORT DMLanguage;
(**************************************)
(*##### General declarations #####*)
(**************************************)
CONST (* Result codes returned by exported procedures: *)
allOk = DMLanguage.allOk;
notDone = DMLanguage.onlyAnInsert;
TYPE
ShortString = ARRAY [0..23] OF CHAR;
ForSiteFileType = ( notAForSiteFile, forSiteBaseClimFile, forSiteClimStepFile );
(****************************************)
(*##### Retrieval of file type #####*)
(****************************************)
PROCEDURE GetForSiteFileTypeAndSite( fileName : ARRAY OF CHAR;
VAR fType : ForSiteFileType;
VAR siteName : ARRAY OF CHAR;
VAR resCode : INTEGER;
VAR errTxt : ARRAY OF CHAR );
(***********************************************)
(*##### I/O of baseline climate files #####*)
(***********************************************)
(*
The format of the site file is assumed to be similar to this example:
ForClim family 2.4-x.y (>= 2.4-1.2):
-----------------------------------
_________________________________________________________________________________________________
Site-specificÊdataÊframeÊforÊtheÊForClimÊmodel
**********************************************
SiteÊparametersÊandÊoutputÊvariablesÊfor Bever_S
------------------------------------------------
LatitudeÊofÊtheÊsiteÊ[NB] 46.6
FieldÊcapacityÊ[cmÊwater] 30
Slope/aspectÊqualifierÊ[-] 2
AnnualÊdegree-daysÊ[°C*days] 773.0
AnnualÊevapotranspirationÊ[mm] 518.6
MinimumÊwinterÊtemperatureÊ[°C] -10.189
AverageÊdroughtÊstressÊ[-] 0.042
ClimaticÊparametersÊ(TÊinʰC,ÊPÊinÊcm/month)
--------------------------------------------
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
mT -9.2 -7.5 -3.6 0.9 6.1 9.7 11.5 10.8 7.7 2.7 -3.2 -7.9
sdT 2.1 2.4 1.7 1.5 1.3 1.3 1.3 1.1 1.4 1.5 1.5 1.9
mP 4.16 3.92 5.09 5.24 7.50 8.95 10.14 10.97 8.07 7.59 7.20 5.28
sdP 2.90 3.37 3.59 2.89 3.10 3.94 3.71 4.57 5.27 5.74 5.35 3.78
r 0.34 0.33 0.07 -0.21 -0.09 -0.25 -0.37 -0.33 -0.16 -0.05 0.20 0.25
Variables for monitoring
------------------------
LdecÊB
PcemÊB
PexcÊB
PtreÊB
_________________________________________________________________________________________________
ForClim family 2.6-x.y (>= 2.6-3.3):
-----------------------------------
_________________________________________________________________________________________________
Site-specificÊdataÊframeÊforÊtheÊForClimÊmodel
**********************************************
SiteÊparametersÊandÊoutputÊvariablesÊfor Bern
---------------------------------------------
LatitudeÊofÊtheÊsiteÊ[°N] 46.9
BucketÊsizeÊ[cmÊwater] 20
Slope/aspectÊqualifierÊ[-] 0
AnnualÊdegree-daysÊ[°C*days] 1933.4
AnnualÊevapotranspirationÊ[mm] 591.9
MeanÊannualÊtemperatureÊ[°C] 8.4
SoilÊmoistureÊfractionÊ[-] 0.5
MinimumÊwinterÊtemperatureÊ[°C] -2.17
AverageÊdroughtÊstressÊ[-] 0.023
AverageÊNÊavailabilityÊ[kg/ha] 100.0
InitialÊfastÊhumusÊ[tÊC/ha] 50.0
InitialÊslowÊhumusÊ[tÊC/ha] 20.0
ClimaticÊparametersÊ(TÊinʰC,ÊPÊinÊcm/month)
--------------------------------------------
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
mT -1.0 0.4 4.2 8.1 12.6 15.8 17.8 17.0 13.8 8.6 3.4 0.2
sdT 2.3 2.5 1.7 1.6 1.6 1.3 1.6 1.3 1.6 1.4 1.5 1.9
mP 5.93 5.39 6.66 7.84 10.13 11.71 11.24 11.38 9.06 7.35 7.33 6.61
sdP 3.33 3.71 3.77 3.82 3.72 4.46 5.14 5.24 4.85 4.75 4.76 3.89
r 0.27 0.37 -0.13 -0.18 -0.33 -0.29 -0.63 -0.47 -0.16 -0.17 0.32 0.43
Variables for monitoring
------------------------
AalbÊB
ApseÊB
QpetÊB
QrobÊB
FsilÊB
PexcÊB
_________________________________________________________________________________________________
Watch out for the following pitfalls and idiosynchrasies:
========================================================
First line must begin with reserved word 'Site'
Row with first subheading must contain reserved word 'Site'
The site name must be preceeded by the reserved word 'for'
Parameter values must be given after the special symbol ']'
Row with second subheading must contain reserved word 'Climatic'
Row with month headers must start with reserved word 'Jan' and contain 11 more words
Row with third subheading must contain reserved word 'monitoring'
Old reading algorithms, i.e. not procedure ReadForSiteBaseClimFile, are even
more restrictive. They require hard blanks (ASCII code >=' ') in many
places and any reading fails, if these requirements are not met. In
particular the row with the first subheading and all paramater descriptions
are very critical. For the former make sure that up to the actual site
name, all spaces between words ARE HARD BLANKS. Before the site name MUST BE
an ordinary blank (space bar). The same is true for all text before the
parameters, except before the actual parameter value.
Missing output parameters may be specified by the reserved word 'N'
*)
PROCEDURE ReadForSiteBaseClimFile( fileName : ARRAY OF CHAR;
VAR fcVersion : ARRAY OF CHAR; (* I/O e.g. fcVersion := "2.6-3.3"
Supports 2.4 and 2.6 family of
ForClim models assuming member
version is >= 2.4-1.2 and >= 2.6-3.3
default >= v2.6-x.y model family *)
VAR siteName : ARRAY OF CHAR;
VAR latitude : REAL;
VAR fieldCapOrBS: REAL;
VAR saQualif : REAL;
VAR annDegDays : REAL;
VAR annET : REAL;
VAR meanAnnT : REAL;
VAR soilMoistF : REAL;
VAR minWinT : REAL;
VAR meanDrStr : REAL;
VAR meanN : REAL;
VAR initFastHum : REAL;
VAR initSlowHum : REAL;
VAR mT : ARRAY OF REAL;
VAR sdT : ARRAY OF REAL;
VAR mP : ARRAY OF REAL;
VAR sdP : ARRAY OF REAL;
VAR corTP : ARRAY OF REAL;
VAR nSpecIdents : INTEGER;
VAR specIdent : ARRAY OF ShortString;
VAR resCode : INTEGER;
VAR errTxt : ARRAY OF CHAR );
PROCEDURE WriteForSiteBaseClimFile( fileName : ARRAY OF CHAR;
fcVersion : ARRAY OF CHAR;
siteName : ARRAY OF CHAR;
latitude : REAL;
fieldCapOrBS : REAL;
saQualif : REAL;
annDegDays : REAL;
annET : REAL;
meanAnnT : REAL;
soilMoistF : REAL;
minWinT : REAL;
meanDrStr : REAL;
meanN : REAL;
initFastHum : REAL;
initSlowHum : REAL;
VAR mT : ARRAY OF REAL; (* VAR for speed-up only *)
VAR sdT : ARRAY OF REAL; (* VAR for speed-up only *)
VAR mP : ARRAY OF REAL; (* VAR for speed-up only *)
VAR sdP : ARRAY OF REAL; (* VAR for speed-up only *)
VAR corTP : ARRAY OF REAL; (* VAR for speed-up only *)
nSpecIdents : INTEGER;
VAR specIdent : ARRAY OF ShortString; (* VAR for speed-up only *)
VAR resCode : INTEGER;
VAR errTxt : ARRAY OF CHAR );
(****************************************************)
(*##### I/O of climate change (step) files #####*)
(****************************************************)
PROCEDURE ReadForSiteClimStepFile( fileName : ARRAY OF CHAR;
VAR siteName : ARRAY OF CHAR;
VAR ccYear : INTEGER;
VAR dMTInPerCent : BOOLEAN;
VAR dSdTInPerCent : BOOLEAN;
VAR dMPInPerCent : BOOLEAN;
VAR dSdPInPerCent : BOOLEAN;
VAR dCorTPInPerCent : BOOLEAN;
VAR dMT : ARRAY OF REAL;
VAR dSdT : ARRAY OF REAL;
VAR dMP : ARRAY OF REAL;
VAR dSdP : ARRAY OF REAL;
VAR dCorTP : ARRAY OF REAL;
VAR resCode : INTEGER;
VAR errTxt : ARRAY OF CHAR );
PROCEDURE WriteForSiteClimStepFile( fileName : ARRAY OF CHAR;
siteName : ARRAY OF CHAR;
ccYear : INTEGER;
dMTInPerCent : BOOLEAN;
dSdTInPerCent : BOOLEAN;
dMPInPerCent : BOOLEAN;
dSdPInPerCent : BOOLEAN;
dCorTPInPerCent : BOOLEAN;
VAR dMT : ARRAY OF REAL; (* VAR for speed-up only *)
VAR dSdT : ARRAY OF REAL; (* VAR for speed-up only *)
VAR dMP : ARRAY OF REAL; (* VAR for speed-up only *)
VAR dSdP : ARRAY OF REAL; (* VAR for speed-up only *)
VAR dCorTP : ARRAY OF REAL; (* VAR for speed-up only *)
VAR resCode : INTEGER;
VAR errTxt : ARRAY OF CHAR );
END ForSiteDatIO.