Language Syntax

Initialization


The data Statement

Local variables, arrays, and character strings may be initialized at compile time with the
data statement. Data in a global common may not be initialized at compile time. If initialization of data in a global common is required, it must be done at run time by an initialization procedure. The syntax of the data statement is defined identically to the standard Fortran 77 DATA statement. Some simple examples follow.

real     x, y[2] 
char     ch[2] 
data     x/0/, y/1.0,2.0/, ch/'a','b',EOS/ 
Any data statements must follow all declarations. Note that variables initialized by data are not guaranteed to have that value except the first time the task is executed from the cl. IRAF tasks executed from the cl may be cached or stored in the process cache. That is, they are not restarted from the main procedure except the first time they are executed and after the process cache is flushed (using the cl task flprcache). Therefore, a variable modified in a task procedure will not have the initialized value the next time the task is executed, but will have the modified value. It is always safer to initialize variables with macro
symbolic constant define statements or explicit assignment statements.

The string Statement

Character strings may be declared and initialized with the string statement. This consists of the keyword string followed by the identifier name, followed by the initialization value enclosed in double quotes. Not that there is no explicit string size. A char array is implicitly declared the size of the initialization string.

string  errmsg "Could not open input" 
The data Statement
The string Statement

Generated with CERN WebMaker