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 TallyMonit;

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

    Module  TallyMonit     (Version 1.0)

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

    Purpose   Procedures for automated monitoring
              and filing of ISIS variables and grids.

    Remarks   Uses modules Grids, Tallies and FileInfos.


    Programming

      o Design
        Dimitrios Gyalistras      30/03/2006

      o Implementation
        Dimitrios Gyalistras      30/03/2006


    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:  21/06/2006  DG & AF

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


  FROM SYSTEM  IMPORT ADDRESS;
  FROM DMFiles IMPORT TextFile;
  IMPORT Errors;
  FROM Grids   IMPORT GridData;
  FROM Tallies IMPORT Tally;


  (***********************)
  (*#####   Types   #####*)
  (***********************)

  CONST
    notDone = Errors.onlyAnInsert;
    (*
      The procedures exported below return errCode = Errors.allOk if the
      call to the procedure was succesfull, and resCode = notDone if not.
    *)

  CONST
    tallyMonitIntAttrVal = -9999;
    (*
      Tally objects declared by this module are marked with the
      above integer attribute value.  These objects should not
      be modified in order to guarantee correct functioning of
      this module.  To learn about a Tally object's current
      integer attribute value use procedure
      Tallies.TallyIntAttr.
    *)

  TYPE
    TalliedObject = ADDRESS;


  (*****************************************************)
  (*#####   Procedures for automated monitoring   #####*)
  (*****************************************************)


  PROCEDURE InitSimRuns ( outFilesSetId         : ARRAY OF CHAR;
                          numRuns               : INTEGER;
                          numMonitEventsPerRun  : INTEGER;
                          outFNamesPrfx         : ARRAY OF CHAR;
                          VAR monitoredVarsList : ARRAY OF CHAR;
                          VAR skippedVarsList   : ARRAY OF CHAR;
                          VAR resCode           : INTEGER;
                          VAR errTxt            : ARRAY OF CHAR );
  (*
    Initializes automated monitoring of multiple simulation runs.
    This includes the following actions:

    1. Preparation of information on requested output files.
       This information is retrieved from the currently loaded
       data frames for the output files set named "outFilesSetId".
       See also procedure "FileInfos.DeclareFileInfosFromDataFrames".

    2. Preparation of all tallies needed to produce ASCII text
       (matrix) formatted file output after termination of all
       simulation runs (see procedure "TermSimRuns" below).

    3. Preparation of all output files needed to produce binary/
       lola formatted output during the simulation runs (see
       procedure "DoMonitoring" below).

    Variable "monitoredVarsList" returns for each output file from the
    specified output files set "outFilesSetId" a list of all variables
    that are ready to be be monitored when procedure "DoMonitoring"
    (see below) is called.  Variable "skippedVarsList" returns for each
    output file a list of all variables that can not be monitored,
    because no corresponding objects (output variables or grids) could
    be identified by "InitSimRuns".  The identifiers of output files
    and variables in the two *VarsList variables are separated by the
    special characters "|" and ",", respectively.

    (to be continued)

  *)


  PROCEDURE DoMonitoring( runNr        : INTEGER;
                          simTime      : REAL;
                          monitEventNr : INTEGER );


  PROCEDURE TermSimRuns( outFNamesPrfx : ARRAY OF CHAR;
                         matrixDescr   : ARRAY OF CHAR );



  (**********************************************************)
  (*#####   Support of explicit monitoring by client   #####*)
  (**********************************************************)


  TYPE
    TallyingP = PROCEDURE ( Tally,         (* tally *)
                            INTEGER,       (* i1 = runNr *)
                            INTEGER,       (* i2 = monitEventNr *)
                            TalliedObject, (* tallied object attribute *)
                            LONGINT );     (* tallied object attribute *)

  PROCEDURE SetTallyingP( varId   : ARRAY OF CHAR;
                          adrAttr : TalliedObject;
                          liAttr  : LONGINT;
                          tp      : TallyingP );

  PROCEDURE GetTallyingP( varId       : ARRAY OF CHAR;
                          VAR adrAttr : TalliedObject;
                          VAR liAttr  : LONGINT;
                          VAR tp      : TallyingP );

  PROCEDURE GiveUpTallyingP( varId: ARRAY OF CHAR );




  TYPE
    GridDataMonitP = PROCEDURE ( VAR TextFile, (* outFile     *)
                                 GridData,     (* gridData    *)
                                 INTEGER,      (* dataLayerNr *)
                                 LONGINT,      (* date        *)
                                 LONGINT  );   (* time        *)

  PROCEDURE SetGridDataMonitP( varId : ARRAY OF CHAR;
                               gdmp  : GridDataMonitP );

  PROCEDURE GetGridDataMonitP( varId    : ARRAY OF CHAR;
                               VAR gdmp : GridDataMonitP );

  PROCEDURE GiveUpGridDataMonitP( varId: ARRAY OF CHAR );


END TallyMonit.

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