Changeset 7325
- Timestamp:
- 16/08/10 11:25:36 (11 years ago)
- Location:
- TI12-security/trunk/NDGSecurity/C/openDapPatch
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/NDGSecurity/C/openDapPatch
- Property svn:ignore
-
old new 4 4 ca 5 5 cookie.txt 6 netcdf-4.1.2-beta1-snapshot2010081520 7 *.pem 8 netcdf-4-daily.tar.gz
-
- Property svn:ignore
-
TI12-security/trunk/NDGSecurity/C/openDapPatch/Makefile
r6876 r7325 1 1 2 NETCDF_LIB_PATH=-L../netcdf-4.1.1/libsrc/.libs/ 3 ncopen: 4 cc -g ncopen.c ${NETCDF_LIB_PATH} -lnetcdf -lcurl -o ncopen 2 NETCDF_LIB=-lnetcdf 3 NETCDF_LIB_PATH=-L./netcdf-4.1.2-beta1-snapshot2010081520/liblib/.libs/ 4 NETCDF_INCLUDES=-I./netcdf-4.1.2-beta1-snapshot2010081520/include 5 6 ncopen: ncopen.c 7 cc -Wall -g ${NETCDF_INCLUDES} ${NETCDF_LIB_PATH} ncopen.c ${NETCDF_LIB} -lcurl -o ncopen 5 8 6 9 clean: -
TI12-security/trunk/NDGSecurity/C/openDapPatch/ncopen.c
r6876 r7325 1 /* 2 * Test Harness for ESG Security extensions to NetCDF OPeNDAP client 3 * 4 * Author: Steve Crothers 5 * 6 * Modified: Philip Kershaw 7 * 8 * Copyright: STFC Rutherford Appleton Laboratory 9 * 10 * $Id$ 11 */ 1 12 #include <stdio.h> 2 #include <netcdf.h> 3 4 int main(int argc, char **argv) { 5 int ncidp, ans; 13 #include <stdlib.h> 14 #include <libgen.h> 15 16 #include "netcdf.h" 17 18 19 int main(int argc, char **argv) 20 { 21 int ncId, status; 22 int nDims, nVars, nGlobalAttrs, unlimitedDimId; 23 24 int i=0; 25 int j=0; 26 nc_type varType; 27 char varName[NC_MAX_NAME+1]; 28 int varNDims; 29 int varDimIds[NC_MAX_VAR_DIMS]; 30 int varNVarAttrs; 31 6 32 printf("%s\n",nc_inq_libvers()); 7 printf("Go %s\n",argv[1]); 8 ans=nc_open(argv[1],NC_NOWRITE,&ncidp); 9 printf("got %d %d\n",ans,ncidp); 10 if (ans != NC_NOERR) { 11 printf("%s\n", nc_strerror(ans)); 33 34 if (argc < 2) 35 { 36 fprintf(stderr, "Usage: %s <netcdf file>\n", 37 (const char *)basename(argv[0])); 38 exit(1); 12 39 } 40 printf("Go %s\n", argv[1]); 41 status = nc_open(argv[1], NC_NOWRITE, &ncId); 42 printf("Got nc_open status=%d; id=%d\n", status, ncId); 43 if (status != NC_NOERR) 44 { 45 fprintf(stderr, "Opening URI: %s\n", nc_strerror(status)); 46 exit(1); 47 } 48 49 status = nc_inq(ncId, &nDims, &nVars, &nGlobalAttrs, &unlimitedDimId); 50 if (status != NC_NOERR) 51 { 52 printf("Getting information about dataset: %s\n", nc_strerror(status)); 53 exit(1); 54 } 55 56 printf("Number of dimensions: %d\n", nDims); 57 printf("Number of variables: %d\n", nVars); 58 printf("Number of global attributes: %d\n", nGlobalAttrs); 59 printf("Unlimited dimension ID: %d\n", unlimitedDimId); 60 61 for (i=0; i < nVars; i++) 62 { 63 status = nc_inq_var(ncId, i, &varName, &varType, 64 &varNDims, varDimIds, &varNVarAttrs); 65 if (status != NC_NOERR) 66 { 67 printf("Getting information about variable %d: %s\n", i, 68 nc_strerror(status)); 69 exit(1); 70 } 71 printf("Variable name: %s\n", varName); 72 printf("Variable type: %d\n", varType); 73 for (j=0; j < varNDims; j++) 74 printf("Variable dimension ID: %d\n", varDimIds[j]); 75 76 printf("Variable number of variable attributes: %d\n", varNVarAttrs); 77 } 78 79 nc_close(ncId); 80 81 exit(0); 13 82 } 14 83
Note: See TracChangeset
for help on using the changeset viewer.