DEFINITION MODULE SimDatDump;
(*******************************************************************
Module SimDatDump (SD_Version_2.0)
Copyright (c) 1997-2006 by Andreas Fischlin and ETH Zurich.
Purpose Dumps all currently known models plus
model objects as data frames onto a file.
Remarks Operates only on the current values. Declares the
current values as new default values, which is
actually the main purpose for using data frames
(see module SimBase and Fischlin et al., 1994).
May be used with plain vanilla ModelWorks MDPs
(Model Definition Programs) as well as SysMod
models. However, in the first case, a proper
syntax and subsequent rereadability of data frames
is not guaranteed. It is the modeller's
responsibility to ensure that all identifiers given
to models and model objects have proper identifiers
(i.e. start with a letter and contain only letters
or digits, no special characters nor blanks).
References:
FISCHLIN, A., GYALISTRAS, D., ROTH, O., ULRICH, M.,
THOENY, J., NEMECEK, T., BUGMANN, H. & THOMMEN, F.,
1994. Model Works 2.2 Ð an interactive simulation
environment for personal computers and
work-stations. Systems Ecology Report No.14, 324pp.
Programming
o Design
Andreas Fischlin 27/02/1997
o Implementation
Andreas Fischlin 27/02/1997
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: 01/05/1998 AF
*******************************************************************)
(* Uses only standard error codes as exported by module DMLanguage
and or Errors *)
TYPE
DataKind = BITSET;
CONST
project = 1; (* data frame describing the project *)
systems = 2; (* data frame tabulating all systems *)
models = 3; (* data frame tabulating all models *)
modObjects = 4; (* data frame tabulating all model objects
(including state variables, parameters,
input, output, plus auxiliary variables)
on a per model basis. *)
stateVars = 5; (* data frame tabulating only state
variables plus their derivatives and
new states, respectively (on a per
model basis). *)
params = 6; (* data frame tabulating all model
parameters (on a per model basis). *)
monit = 7; (* data frame tabulating all monitoring
attributes (on a per model basis). *)
tally = 8; (* data frame tabulating all tallying
attributes (on a per model basis). *)
globSimPars = 9; (* data frame tabulating all global
simulation parameters (see module
SimBase). *)
windows = 10; (* data frame tabulating the properties,
e.g. position, of the windows used in the
simulation environment (see module
SimBase). *)
simEnvOptions = 11; (* data frame tabulating the global options
of the simulation environment (see module
SimBase). *)
(*
Note, in case 'modObjects' is IN current data kind 'dk',
the data frames tabulating state variables model
parameters, and monitoring attributes will have a slightly
different format. In particular descriptor strings and
units will be omitted from the latter to avoid redundancy
and will be tabulated only in the model objects data frame.
Thus, it is recommended to write data of kind 'modObjects'
always (third normal form of the data base).
*)
VAR
allData: DataKind; (* read only (use SetDumpOption to customize);
initally defined as:
{project, systems, models,
modObjects, stateVars, params,
monit, tally, globSimPars,
windows, simEnvOptions}.
This default ensures a normal form of
the data base produced and avoids
redundancies (Third normal form of
relational data base). The principal
key to identify models and model
objects is the globally unique
identifier for every item. *)
PROCEDURE SaveDFsOnFile(VAR fn: ARRAY OF CHAR);
(*
Core routine of this module allowing to save, i.e. write
all current data used in the simulation environment. In
particular this encompasses all numerical data required to
define a particular numerical solution of model equations
such as the specific values of model parameters or the
numerical method used to solve models. Any data apart from
the mathematical properties of the model can be saved for
documentation or later reproduction. Models and model
objects can be instantiated within the simulation
environment by any means, i.e. using module SysModBase or
SimBase (ModelWorks); even in any mixture to warrant
complete reproducability. The data are written as simple
text files in the format of data frames (see module
DataFrames) and can easily be reread and assigned to all
objects present in the simulation environment for
reproducing a particular simulation or restoring the same
initial conditions. The format supports also easy editing
in a spread sheet application like Excel.
To customize the kind of data to be written use routines
GetDumpOptions and SetDumpOptions (default is 'allData').
Note, fn is an IO parameter. In: A non-empty string fn is the
name of the file to which the data ought to be saved.
This string may also contain a path (use e.g. routines
from FileNamStrs for constructing machine independent,
fully portable path specifications). NOTE: A non-empty
string will result in the creation of a file and the
quiet overwriting of an eventually existing file with the
same name without any warning! Pass entry string for
requesting a CreateNewFile dialog. Out: Upon successful
file creation, fn contains the name of the file.
*)
PROCEDURE SetDumpOptions( dk: DataKind;
filetype,creator: ARRAY OF CHAR);
PROCEDURE GetDumpOptions(VAR dk: DataKind;
VAR filetype,creator: ARRAY OF CHAR);
(*
Allows to control the dump options, i.e. the kind of
data written and the appearance (type, creator) of the
file. The initial default is set to allData and the
default filetype and creator as that used by the "Dialog
Machine" (see module DMFiles).
*)
END SimDatDump.