next up previous contents index
Next: Initialising Arrays Up: DATA Statement Previous: Defined and Undefined Values

Initialising Variables

 

The simplest form of the DATA statement consists of a list of the variable names each followed by a constant enclosed in a pair of slashes:

 
       DOUBLE PRECISION EPOCH 
       LOGICAL OPENED 
       CHARACTER INFILE*20 
       DATA EPOCH/1950.0D0/, OPENED/.TRUE./, INFILE/'B:OBS.DAT'/

Note that DATA statements must follow all specification statements. An alternative form is to give a complete list of names can be given first and followed by a separate list of constants:

 
      DATA EPOCH, OPENED, INFILE / 1950.0D0, .TRUE., 'B:OBS.DAT'/

When there are many items to be initialised it is a matter of taste whether to use several DATA statements or to use one with many continuation lines. It is, of course, illegal to have the same name appearing twice.

Character variables can be initialised in sections using the substring notation if this is more convenient:

 
      CHARACTER*52 LETTER 
      DATA LETTER(1:26)/'ABCDEFGHIJKLMNOPQRSTUVWXYZ'/, 
     $     LETTER(27:) /'abcdefghijklmnopqrstuvwxyz'/

If the length of the character constant differs from that of the variable then the string is truncated or padded with blanks as in an assignment statement. The type conversion rules of assignment statements also apply to arithmetic items in DATA statements.



Mario Storti
Wed Nov 4 19:32:56 ART 1998