/* readvis5d.c */ /* * This is an example program to show how to read the header and * data arrays from vis5d data files. The structure of this program * comes from v5dstats.c */ #include #include #include #include /* need to have the path set to the v5d.h file in the vis5d directory tree */ #include "../vis5d-4.1/src/v5d.h" int main( int argc, char *argv[] ) { v5dstruct v; int time, var; /* * Check the inputs */ if (argc!=2) { printf("Usage:\n"); printf(" v5dstats file\n"); exit(0); } /* * Open the input vis5d file and read in the vis5d header. The header * variables are stored in the structure v. */ if (!v5dOpenFile( argv[1], &v )) { printf("Error: couldn't open %s for reading\n", argv[1] ); exit(0); } /* * Now the data arrays can be read in. The data arrays are stored for * each time and each variable. You send the time and the variable of * the data array you want to read to v5dReadGrid and it returns the * needed data array. Space is opened up for the data in the malloc * command. If you want more than one data array available at once, * you have to create a new variable to store the data. */ for (time=0; timemax) { max = data[i]; } sum += data[i]; sumsum += data[i]*data[i]; } } */ free( data ); } printf("\n"); } v5dCloseFile( &v ); return 0; }