Blame view

php/src/getncvars.c 1.1 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netcdf.h>

/**************************
   Function prototypes
**************************/
 
void handle_netcdf_error (int);

main(int argc, char **argv)
{
      int ncID;
      int i, status, nvars;
      
      char varname[NC_MAX_NAME];
	    
      
        if (argc <= 1) {
            printf("Incorrect number of arguments\n"); 
   	    exit(0);
	}
	
	if((status = nc_open(argv[1],0,&ncID)) != NC_NOERR){
	    printf("%d",status);
	    exit(0);
	}
			 	
	 status = nc_inq_nvars(ncID, &nvars);
	 for (i = 0; i < nvars; i++) {
	     status = nc_inq_varname(ncID, i, varname);	     
	      if (strncmp(varname,"Time",4) != 0 && 
		  strncmp(varname,"StartTime",9) != 0 && 
		  strncmp(varname,"StopTime",8) != 0) 
			    printf("%s#",varname);  
	 }

	 status = nc_close(ncID);
}
/*--------------------------------------------------------------------------
 *  Handles a netCDF error.
 *--------------------------------------------------------------------------*/

void handle_netcdf_error(int status) {
  fprintf(stderr, "%s\n", nc_strerror(status));  
}