array Statement

Added: build 115

Purpose

Creates a single dimensional array of input or output variables.

Applicability

The array statement can be used within RowFieldInputFile and RowFieldOutputFile sections.

Additional Information

The array statement allows the user to group rows, columns, or blocks of data in a file as a one-dimensional array property of the component. For example, if a column of ten variables are stress readings taken at ten different times, the user could create an array entitled "stressOverTime" that holds the ten values. Both input and output sections allow for fixed-length or variable-length arrays.

Syntax

array: <name> <type> <rowm:rown> <fieldm:fieldn> [default=value][fformat="string"]
                                                 [description="string"][units=value]
                                                 [upperBound=value][lowerBound=value]
                                                 [ignoreConversionErrors=true|false]
                                                 [enumValues=val1,val2,...valN]
                                                 [enumAliases=val1,val2,...,valN] 
                                                 [resize=true|false][numDimensions=1|2]

Arguments

NameDescription

name The name is a string that specifies what the array will be called.
type The type of array can be any primitive type supported by the Analysis Server: double, integer, string, and boolean.
rowm, rown These arguments are used along with fieldm and fieldn to specify a file location. The rowm argument specifies the first row in which the array lies, while the rown argument specifies the last row in which it lies. For example, a single column array that goes from rows 5 to 15 would use 5:15 as row arguments.

The row values can be determined in a number of ways. By default, the beginning and end of the file serve as the reference points. Positive row values use the beginning of the file reference point, and negative row values use the end of file reference point (see the markAsBeginning and markAsEnd sections).

If the array lies inside a single row, the rown field may be left blank. For example, an array that resides entirely in the 10th row of a file would use 10 as its row arguments.

fieldm, fieldn These arguments are used along with rowm and rown to specify a file location. The fieldm argument specifies the first field in which the array lies, while the field argument specifies the last row in which it lies. For example, an array that starts and field four and ends at field six would use 4:6 as arguments.

If the array lies inside a single column of a file (and thus can be found in the same field in each row), the fieldn field is left blank. For example, an array that resides entirely in the fifth column of a file would use 5 as its fieldm argument.

If the setDelimiters columns option is in effect, the fieldm argument will contain the column number of the file (measured in characters) where the left-most portion of the array element can be found. The fieldn argument is also left blank in this case: the fformat argument is required in this situation to specify the width of the element.

Options

NameDescription

fformat The fformat option is optional unless the setDelimiters columns statement is being used. It specifies a standard FORTRAN formatting string that controls the width of the formatted variable. The Analysis Server supports the I, G, E, F, and A FORTRAN formatting options.
description This option allows the user to write a description for the variable.
units This option allows the user to set a units string for the variable.
upperBound This argument allows the user to set an upper bound for the variable.
lowerBound This argument allows the user to set a lower bound for the variable.
ignoreConversionErrors This argument applies to doubles and integer type arrays only: if the number cannot be converted into an appropriate format, i.e., a string is assigned to a double, the FileWrapper will not generate an error with this argument set to true.
enumValues This option allows the user to specify the set of possible values for the variable. The enumerated values are specified as a comma separated list of values.
enumAliases New as of build 169. This option allows the user to specify a set of string values that may be associated with the enumerated values. If the variable is set to a value in the alias set, the actual value will be set to the corresponding value in the enumValues set. The aliases are specified as a comma separated list of values. There must be the same amount of elements in the enumValues and enumAliases sets.
resize If variable length arrays are required, the resize=true flag must be set. If the array length is larger than the one shown in the template file, FileWrapper will copy the last line of the array as many times as are needed when creating a new input file. If the array is smaller than that of the template file, FileWrapper will eliminate lines as needed when creating a new input file.

Because resizing works by adding or removing rows, it does not allow for resizing arrays in the horizontal direction, only in the vertical direction.

numDimensions This option allows the user to specify an array to be two dimensions instead of a single dimension. The dimensions will be determined automatically from the number of rows and columns that the array is parsed from. This flag does not work in conjunction with either the resize or fformat flags.

Example

If the following is a portion of an output file:
width=1,2,3,4,5,6
height depth
------ ------
10     20
11     21
12     22
13     23
then the section below could be used in a RowFieldOutputFile to describe the locations of variables:
setDelimiters " =,"
markAsBeginning "width"
#       name    type    row  field
array:  width   double  1    2:-1
array:  height  double  5:8  1
array:  depth   double  5:8  2
Note that the field value for the width variable starts at field 2 and ends at field -1. This means that the array starts at field 2 and continues until the last field on the line. Rows and fields may be referenced using negative numbers. A negative number indicates to count from the end rather then the beginning. For example, row -1 is the last line in a file while row -2 is the second to last line.

See also Analysis Server | FileWrapper | FileWrapper Statements