Advertisement
Guest User

nc_open/nc_close problem

a guest
Aug 1st, 2011
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. // Test function testing strings.
  2. int rv, ncid;
  3. if(rv = nc_create(fname, NC_NETCDF4, &ncid))
  4.     goto error;     // Error opening file.
  5.  
  6. char *string = malloc(250);
  7. sprintf(string, "This is a string.");
  8.    
  9. nc_put_att_string(ncid, NC_GLOBAL, "string1", 1, &string);
  10.    
  11. char *string2 = "This is also a string";
  12. nc_put_att_string(ncid, NC_GLOBAL, "string2", 1, &string2);
  13.    
  14. free(string);
  15.    
  16. nc_close(ncid);
  17. return rv;
  18.  
  19. /******* nc_open call: ********/
  20. // Open the netCDF file.
  21. if(rv = nc_open(fname, NC_NOWRITE, &ncid))
  22.         goto error;
  23.  
  24. /******* nc_close call: ********/
  25. if(ncid >= 0)
  26.      nc_close(ncid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement