Skip to content
Snippets Groups Projects
Commit 2763c30d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added example cdi_open.c

parent 64ae99f0
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,7 @@ examples/Makefile.in -text
examples/cdi_copy.c -text
examples/cdi_copy_f.f -text
examples/cdi_copy_file.c -text
examples/cdi_open.c -text
examples/cdi_read.c -text
examples/cdi_read_example.f90 -text
examples/cdi_read_f.f -text
......
#include <stdio.h>
#include "cdi.h"
#define NOPEN 8096
#define FILENAME "example.grb"
int main(void)
{
int iopen;
int taxisID, vlistID, streamID;
int streamIDs[NOPEN];
for ( iopen = 0; iopen < NOPEN; ++iopen )
{
fprintf(stderr, "sequential open %d\n", iopen+1);
/* Open the dataset */
streamID = streamOpenRead(FILENAME);
if ( streamID < 0 )
{
fprintf(stderr, "%s\n", cdiStringError(streamID));
return(1);
}
/* Get the variable list of the dataset */
vlistID = streamInqVlist(streamID);
/* Get the Time axis from the variable list */
taxisID = vlistInqTaxis(vlistID);
/* Close the input stream */
streamClose(streamID);
}
for ( iopen = 0; iopen < NOPEN; ++iopen )
{
fprintf(stderr, "simultaneous open %d\n", iopen+1);
/* Open the dataset */
streamID = streamOpenRead(FILENAME);
if ( streamID < 0 )
{
fprintf(stderr, "%s\n", cdiStringError(streamID));
return(1);
}
/* Get the variable list of the dataset */
vlistID = streamInqVlist(streamID);
/* Get the Time axis from the variable list */
taxisID = vlistInqTaxis(vlistID);
streamIDs[iopen] = streamID;
}
for ( iopen = 0; iopen < NOPEN; ++iopen )
{
/* Close the input stream */
streamClose(streamIDs[iopen]);
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment