ETHZ_Logo RAMSES_Logo_Right   RAMSES   RAMSES_Logo_Left Systems Ecology  
Start    search button      Modules:   A-Z   Function   Layer        QuickRefs:   DM   AuxLib   AuxLibE   SciLib   EasyMW   MW   ISIS   RMSLib

DEFINITION MODULE MWGParamsIO;

  (*******************************************************************

    Module  MWGParamsIO     (Version 1.0)

      Copyright (c) 1996-2006 by Dimitrios Gyalistras and ETH Zurich.

    Purpose   File input/output of parameters needed for
              stochastic simulation of monthly weather
              variables.

    Remarks   Files syntax:

                 MWGParamFile   = ParamBlock {ParamBlock}.
                 ParamBlock     = PBlockHeader VarSpecif {VarSpecif} MatSpecif.
                 PBlockHeader   = "#" siteID "N_VARS" numVars "MAX_ITERS" maxIters.
                 VarSpecif      = (SimpleVarSp | LogNTrfVarSp).
                 SimpleVarSp    = VarID "MU" "SIG" "R_MIN" "R_MAX"
                                  SimpleVarData {SimpleVarData}.
                 LogNTrfVarSp   = VarID "MU" "SIG" "LN_MU" "LN_SIG" "LN_THETA"
                                  "R_MIN" "R_MAX" LogNTrfVarData {LogNTrfVarData}.
                 SimpleVarData  = monthNr mu sig rangeMin rangeMax.
                 LogNTrfVarData = monthNr mu sig lnMu lnSig lnTheta rangeMin rangeMax.
                 MatSpecif      = [MatrixA] MatrixB.
                 MatrixA        = "A_MATRIX" MatElementID {MatElementID} MatData.
                 MatrixB        = "B_MATRIX" MatElementID {MatElementID} MatData.
                 MatElementID   = IDENTIFIER.
                 MatData        = monthNr matElement {matElement}.
                 siteID         = LONGINT.
                 numVars        = INTEGER.
                 maxIters       = INTEGER.
                 VarID          = IDENTIFIER.
                 monthNr        = INTEGER.
                 mu, sig        = LONGREAL.
                 rangeMin       = LONGREAL.
                 rangeMax       = LONGREAL.
                 lnMu, lnSig    = LONGREAL.
                 lnTheta        = LONGREAL.
                 matElement     = LONGREAL.

  	 	   	  Within a "ParamBlock" expected are exactly 12 "SimpleVarData" and/or
  	 	   	  "LogNTrfVarData" entries per Variable, and 12 "MatData" entries per A-
  	 	   	  oder B-Matrix, one for each month, respectively.  The "MatElementIDs" of
  	 	   	  a "MatrixA" or a "MatrixB" must start with "A" and "B", respectively.
  	 	   	  For each matrix and month in total exactly numVars "MatElementIDs" and
  	 	   	  numVars^2 "matElements" are expected.

              This module is part of the package MonWeathGen.


    Programming

      o Design
        Dimitrios Gyalistras      08/12/1996

      o Implementation
        Dimitrios Gyalistras      08/12/1996


    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:  14/06/2000  DG

  *******************************************************************)


  IMPORT Errors;

  FROM DMFiles IMPORT
    TextFile;

  FROM MonWeathGen IMPORT
    MaxMWGVars, MWGLRealVecArr, MWGLnTrfTVecArr, MWGLMatrixArr;


  CONST  (* result codes returned *)
    allOk   = Errors.allOk;
    notDone = Errors.onlyAnInsert;


  TYPE
    VariableID    = ARRAY [1..64] OF CHAR;
    VariableIDArr = ARRAY [1..MaxMWGVars] OF VariableID;


 (*****************************************************************************)


  PROCEDURE WriteMWGParams( VAR outFile    : TextFile;
                            paramBlockID   : LONGINT;
                            nDecDigsVecs   : INTEGER;
                            nDecDigsMats   : INTEGER;
                            nVars          : INTEGER;
                            VAR varID      : VariableIDArr;    (* VAR for speed-up only *)
                            VAR mu         : MWGLRealVecArr;   (* VAR for speed-up only *)
                            VAR sig        : MWGLRealVecArr;   (* VAR for speed-up only *)
                            VAR lnTrfType  : MWGLnTrfTVecArr;  (* VAR for speed-up only *)
                            VAR lnTrfMu    : MWGLRealVecArr;   (* VAR for speed-up only *)
                            VAR lnTrfSig   : MWGLRealVecArr;   (* VAR for speed-up only *)
                            VAR lnTrfTheta : MWGLRealVecArr;   (* VAR for speed-up only *)
                            VAR A, B       : MWGLMatrixArr;    (* VAR for speed-up only *)
                            VAR allowedMin : MWGLRealVecArr;   (* VAR for speed-up only *)
                            VAR allowedMax : MWGLRealVecArr;   (* VAR for speed-up only *)
                            maxIters       : INTEGER;
                            VAR resCode    : INTEGER;
  					        VAR errTxt     : ARRAY OF CHAR );


  PROCEDURE RetrieveMWGParams( fName          : ARRAY OF CHAR;
                               paramBlockID   : LONGINT;
                               VAR nVars      : INTEGER;
                               VAR varID      : VariableIDArr;
                               VAR mu         : MWGLRealVecArr;
                               VAR sig        : MWGLRealVecArr;
                               VAR lnTrfType  : MWGLnTrfTVecArr;
                               VAR lnTrfMu    : MWGLRealVecArr;
                               VAR lnTrfSig   : MWGLRealVecArr;
                               VAR lnTrfTheta : MWGLRealVecArr;
                               VAR A, B       : MWGLMatrixArr;
                               VAR allowedMin : MWGLRealVecArr;
                               VAR allowedMax : MWGLRealVecArr;
                               VAR maxIters   : INTEGER;
                               VAR resCode    : INTEGER;
                               VAR errTxt     : ARRAY OF CHAR );

  (* NOTE: all LMatrix objects in A and B are first de-allocated and then
  re-allocated.  Usage of MonWeathGen.ResetMWGLMatrixArr prior to calling
  this procedure for the first time is recommended. *)

END MWGParamsIO.

  Contact RAMSES@env.ethz.ch Last updated: 25-Jul-2011 [Top of page]