include
Include the contents of the given file into the FRED program.
Synopsis
include <filename>
Description
This statement allows users to write modular FRED programs by using
separate .fred
files for each condition in a model.
In addition, parameters and variables can be specified in their own .fred
files.
The include
statement inserts the contents of the given file at
the point where the include
statement appears when the program is compiled.
Examples
Here we show include
statements being used to include two .fred
files
called simpleflu.fred
and params.fred
into a FRED program.
params.fred
is assumed to be in the same directory as the file that
contains the include statement. The full path to simpleflu.fred
is given
relative to the FRED_PROJECT
directory that must be specified as an
environment variable.
include $FRED_PROJECT/FRED-tutorials/simpleflu/simpleflu.fred
include params.fred
Environment
In addition to the FRED_PROJECT
environment variable used in the above
example, include
statements can make use of the FRED_PATH
environment
variable. See the FRED Modeling Language Guide for details about how
include
statements interact with FRED_PATH
.
Errors
If fred_compile
cannot locate the file indicated by an include
statement,
it will raise an error. For example, if a FRED main.fred
file included the
line
include simpleflu.fred
but the file simpleflu.fred
did not exist in the same directory as
main.fred
, the following error would be raised.
fred_compile -p main.fred
===================================
FRED Error (file ./main.fred):
Cannot open file simpleflu.fred
Notes
This statement was introduced in FRED 7. By convention, FRED files use the extension .fred, although this is not enforced by the FRED compiler.