Changeset 5263 for anuga_work
- Timestamp:
- May 1, 2008, 3:34:03 PM (17 years ago)
- Location:
- anuga_work/development/anugavis/src
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/anugavis/src/Makefile.am
r5261 r5263 13 13 init.c \ 14 14 init.h \ 15 netcdf_util.c \ 16 netcdf_util.h \ 15 17 xmalloc.c \ 16 18 xmalloc.h -
anuga_work/development/anugavis/src/anugavis_simple.c
r5262 r5263 3 3 #include "height_quantity.h" 4 4 #include "init.h" 5 #include "globals.h" 6 #include <stdio.h> 5 7 int main(int argc, char *argv[]){ 6 8 if(argc != 2){ … … 12 14 return 1; 13 15 } 16 17 printf("points: %d\nvertices: %d\nvolumes: %d\n", 18 anugavis.number_of_points, 19 anugavis.number_of_vertices, 20 anugavis.number_of_volumes); 14 21 15 22 if(AnugaVis_DefineHeightQuantity("elevation", 0, 1, 128, 128, 128) == -1){ -
anuga_work/development/anugavis/src/globals.h
r5261 r5263 9 9 int netcdfId; 10 10 size_t number_of_points; 11 size_t number_of_vertices; 12 size_t number_of_volumes; 11 13 float *x; 12 14 float *y; -
anuga_work/development/anugavis/src/init.c
r5261 r5263 20 20 #include "error.h" 21 21 #include "globals.h" 22 #include "netcdf_util.h" 22 23 #include "xmalloc.h" 23 24 … … 51 52 52 53 if((ncstatus = nc_open(swwFilePath, NC_SHARE, 53 &anugavis.netcdfId)) != NC_NOERR) goto nc_err; 54 if((ncstatus = nc_inq_dimid(anugavis.netcdfId, "number_of_points", 55 &ncdimid)) != NC_NOERR) goto nc_err1; 56 if((ncstatus = nc_inq_dimlen(anugavis.netcdfId, ncdimid, 57 &anugavis.number_of_points)) != NC_NOERR) 58 goto nc_err1; 54 &anugavis.netcdfId)) != NC_NOERR){ 55 SDL_Quit(); 56 return -1; 57 } 59 58 60 /* Get the number of vertices to keep space for. */ 61 if((anugavis.x = xmalloc(sizeof(float) * anugavis.number_of_points, 62 "AnugaVis_Init()")) == NULL) 63 goto bad_malloc; 64 if((anugavis.y = xmalloc(sizeof(float) * anugavis.number_of_points, 65 "AnugaVis_Init()")) == NULL) 66 goto bad_malloc; 67 68 /* Load the list of x and y points from the NetCDF file. */ 69 if((ncstatus = nc_inq_varid(anugavis.netcdfId, "x", 70 &ncvarid)) != NC_NOERR) goto nc_err1; 71 if((ncstatus = nc_get_var_float(anugavis.netcdfId, ncvarid, 72 anugavis.x)) != NC_NOERR) goto nc_err1; 73 if((ncstatus = nc_inq_varid(anugavis.netcdfId, "y", 74 &ncvarid)) != NC_NOERR) goto nc_err1; 75 if((ncstatus = nc_get_var_float(anugavis.netcdfId, ncvarid, 76 anugavis.y)) != NC_NOERR) goto nc_err1; 77 59 if((nc_inq_dimlen_by_name(anugavis.netcdfId, "number_of_points", 60 &anugavis.number_of_points) != NC_NOERR) || 61 (nc_inq_dimlen_by_name(anugavis.netcdfId, "number_of_vertices", 62 &anugavis.number_of_vertices) != NC_NOERR) || 63 (nc_inq_dimlen_by_name(anugavis.netcdfId, "number_of_volumes", 64 &anugavis.number_of_volumes) != NC_NOERR) || 65 ((anugavis.x = xmalloc(sizeof(float) * anugavis.number_of_points, 66 "AnugaVis_Init()")) == NULL) || 67 ((anugavis.y = xmalloc(sizeof(float) * anugavis.number_of_points, 68 "AnugaVis_Init()")) == NULL) || 69 (nc_get_var_float_by_name(anugavis.netcdfId, "x", 70 anugavis.x) != NC_NOERR) || 71 (nc_get_var_float_by_name(anugavis.netcdfId, "y", 72 anugavis.y) != NC_NOERR)){ 73 nc_close(anugavis.netcdfId); 74 if(anugavis.x != NULL) free(anugavis.x); 75 if(anugavis.y != NULL) free(anugavis.y); 76 SDL_Quit(); 77 return -1; 78 } 78 79 return 0; 79 nc_err1:80 nc_close(anugavis.netcdfId);81 nc_err:82 AnugaVis_NetCDFError(ncstatus);83 bad_malloc:84 if(anugavis.x != NULL) free(anugavis.x);85 if(anugavis.y != NULL) free(anugavis.y);86 SDL_Quit();87 return -1;88 80 } 89 81
Note: See TracChangeset
for help on using the changeset viewer.