Using Vector and Scalar Data with Grids

For meshes, TINs, and scatter point sets, the order that the values are listed in the file is simply the sequential order of the node, TIN, or scatter point ids. However, vector and scalar data can also be associated with the nodes or cells of a 2D or 3D grid. T For 2D grids, data values are ordered using a row-column (I-J) priority. For 3D grids, data values are ordered using a layer-row-column (K-I-J) priority.

The following C source code examples illustrate how a 2D or 3D array of scalar values corresponding to the nodes of a grid would be written to the main portion of an ASCII scalar file.

2D Grid Example:

for(i=0; i<nrow; i++){
for(j=0; j<ncol; j++){
fprintf(fp, "%f\n", scalar[i][j]);
}
}

3D Grid Example:

for(k=0; k<nlay; k++){
for(i=0; i<nrow; i++){
for(j=0; j<ncol; j++){
fprintf(fp, "%f\n", scalar[k][i][j]);
}
}
}