55int main(
int argc,
char ** argv) {
59 char const * grid_name, * grid_filename, * vtk_filename;
63 double * clon, * clat, * lon, * lat;
64 int * gid, * cmk, * rnk;
67 grid_filename, grid_name,
68 &nv, &nc, &clon, &clat, &lon, &lat, &gid, &cmk, &rnk);
71 vtk_filename, grid_name,
72 nv, nc, clon, clat, lon, lat, gid, cmk, rnk);
104 char const * grid_filename,
char const * grid_name,
105 size_t * nv,
size_t * nc,
106 double ** clon,
double ** clat,
double ** lon,
double ** lat,
107 int ** gid,
int ** cmk,
int ** rnk) {
111 size_t grid_name_len = strlen(grid_name) + 1;
112 char nv_dim_name[3 + grid_name_len];
113 char nc_dim_name[3 + grid_name_len];
114 char cla_var_name[4 + grid_name_len];
115 char clo_var_name[4 + grid_name_len];
116 char lat_var_name[4 + grid_name_len];
117 char lon_var_name[4 + grid_name_len];
118 char gid_var_name[4 + grid_name_len];
119 char cmk_var_name[4 + grid_name_len];
120 char rnk_var_name[4 + grid_name_len];
122 snprintf(nv_dim_name, 3 + grid_name_len,
"nv_%s", grid_name);
123 snprintf(nc_dim_name, 3 + grid_name_len,
"nc_%s", grid_name);
124 snprintf(cla_var_name, 4 + grid_name_len,
"%s.cla", grid_name);
125 snprintf(clo_var_name, 4 + grid_name_len,
"%s.clo", grid_name);
126 snprintf(lat_var_name, 4 + grid_name_len,
"%s.lat", grid_name);
127 snprintf(lon_var_name, 4 + grid_name_len,
"%s.lon", grid_name);
128 snprintf(gid_var_name, 4 + grid_name_len,
"%s.gid", grid_name);
129 snprintf(cmk_var_name, 4 + grid_name_len,
"%s.cmk", grid_name);
130 snprintf(rnk_var_name, 4 + grid_name_len,
"%s.rnk", grid_name);
133 yac_file_exists(grid_filename),
"File %s does not exist.", grid_filename)
135 int ncid, dimid, var_id;
148 status = nc_inq_varid(ncid, lat_var_name, &var_id);
149 if (status == NC_NOERR) {
151 }
else if (status == NC_ENOTVAR) {
156 status = nc_inq_varid(ncid, lon_var_name, &var_id);
157 if (status == NC_NOERR) {
159 }
else if (status == NC_ENOTVAR) {
165 status = nc_inq_varid(ncid, gid_var_name, &var_id);
166 if (status == NC_NOERR) {
168 }
else if (status == NC_ENOTVAR) {
174 status = nc_inq_varid(ncid, cmk_var_name, &var_id);
175 if (status == NC_NOERR) {
177 }
else if (status == NC_ENOTVAR) {
208 char const * vtk_filename,
char const * grid_name,
209 size_t nv,
size_t nc,
210 double * clon,
double * clat,
double * lon,
double * lat,
211 int * gid,
int * cmk,
int * rnk) {
214 malloc((nv * nc + ((lon && lat)?nc:0)) *
sizeof(*points));
216 for (
size_t i = 0; i < nv * nc; ++i)
LLtoXYZ(clon[i], clat[i],
points[i]);
218 for (
size_t i = 0; i < nc; ++i)
221 unsigned * num_points_per_polygon =
222 malloc(nc *
sizeof(*num_points_per_polygon));
223 for (
size_t i = 0; i < nc; ++i) num_points_per_polygon[i] = (
unsigned)nv;
225 unsigned * polygon_data = malloc(nc * nv *
sizeof(*polygon_data));
226 for (
size_t i = 0; i < nv * nc; ++i) polygon_data[i] = (
unsigned)i;
231 file, polygon_data, num_points_per_polygon, nc);
238 free(num_points_per_polygon);
static void write_vtk_file(char const *vtk_filename, char const *grid_name, size_t nv, size_t nc, double *clon, double *clat, double *vlon, double *vlat, int *gid, int *cmk, int *rnk)
static void read_grid_file(char const *grid_filename, char const *grid_name, size_t *nv, size_t *nc, double **clon, double **clat, double **vlon, double **vlat, int **gid, int **cmk, int **rnk)