Commit f7306fe3 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

delete: don't abort if variables are available (bug fix)

parent c4ccd805
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
* using CDI library version 1.7.1 * using CDI library version 1.7.1
* Version 1.7.1 released * Version 1.7.1 released
2016-01-04 Uwe Schulzweida
* delete: don't abort if variables are available (bug fix) [report: Renate Brokopf]
2015-12-28 Uwe Schulzweida 2015-12-28 Uwe Schulzweida
* Exprf: init nmiss (bug fix) * Exprf: init nmiss (bug fix)
......
...@@ -102,7 +102,7 @@ const char *COLOUR = NULL, *COLOUR_MIN = NULL, *COLOUR_MAX = NULL, *STYLE = NULL ...@@ -102,7 +102,7 @@ const char *COLOUR = NULL, *COLOUR_MIN = NULL, *COLOUR_MAX = NULL, *STYLE = NULL
static static
void magplot( const char *plotfile, int operatorID, const char *varname, const char *units, long nlon, long nlat, double *grid_center_lon, double *grid_center_lat, double *array, int nparam, char **params, char *datetime ) void magplot( const char *plotfile, int operatorID, const char *varname, const char *units, long nlon, long nlat, double *grid_center_lon, double *grid_center_lat, double *array, int nparam, char **params, char *datetime, bool lregular)
{ {
long i; long i;
...@@ -211,20 +211,26 @@ void magplot( const char *plotfile, int operatorID, const char *varname, const c ...@@ -211,20 +211,26 @@ void magplot( const char *plotfile, int operatorID, const char *varname, const c
/* Set the input data arrays to magics++ */ /* Set the input data arrays to magics++ */
mag_set2r("input_field", array, nlon, nlat); mag_set2r("input_field", array, nlon, nlat);
/*
mag_setc("input_field_organization", "NONREGULAR");
mag_set2r("input_field_latitudes", grid_center_lat, nlon, nlat);
mag_set2r("input_field_longitudes", grid_center_lon, nlon, nlat);
*/
mag_setc("input_field_organization", "REGULAR");
// mag_setc("input_field_organization", "GAUSSIAN");
mag_setr("input_field_initial_latitude", grid_center_lat[0]);
mag_setr("input_field_latitude_step", dlat);
mag_setr("input_field_initial_longitude", grid_center_lon[0]); if ( lregular )
mag_setr("input_field_longitude_step", dlon); {
mag_setc("input_field_organization", "REGULAR");
// mag_setc("input_field_organization", "GAUSSIAN");
mag_setr("input_field_initial_latitude", grid_center_lat[0]);
mag_setr("input_field_latitude_step", dlat);
mag_setr("input_field_initial_longitude", grid_center_lon[0]);
mag_setr("input_field_longitude_step", dlon);
}
else
{
mag_setc("input_field_organization", "NONREGULAR");
mag_set2r("input_field_latitudes", grid_center_lat, nlon, nlat);
mag_set2r("input_field_longitudes", grid_center_lon, nlon, nlat);
}
/* magics_template_parser( magics_node ); */ /* magics_template_parser( magics_node ); */
/* results_template_parser(results_node, varname ); */ /* results_template_parser(results_node, varname ); */
...@@ -1161,11 +1167,14 @@ void *Magplot(void *argument) ...@@ -1161,11 +1167,14 @@ void *Magplot(void *argument)
// int zaxisID = vlistInqVarZaxis(vlistID, varID); // int zaxisID = vlistInqVarZaxis(vlistID, varID);
// double missval = vlistInqVarMissval(vlistID, varID); // double missval = vlistInqVarMissval(vlistID, varID);
if ( gridInqType(gridID) == GRID_GME ) cdoAbort("GME grid unspported!"); int gridtype = gridInqType(gridID);
if ( gridInqType(gridID) == GRID_UNSTRUCTURED ) cdoAbort("Unstructured grid unspported!"); if ( gridtype == GRID_GME ) cdoAbort("GME grid unspported!");
if ( gridtype == GRID_UNSTRUCTURED ) cdoAbort("Unstructured grid unspported!");
if ( gridInqType(gridID) != GRID_CURVILINEAR ) bool lregular = false;
gridID = gridToCurvilinear(gridID, 1); if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN ) lregular = true;
if ( gridtype != GRID_CURVILINEAR ) gridID = gridToCurvilinear(gridID, 1);
int gridsize = gridInqSize(gridID); int gridsize = gridInqSize(gridID);
int nlon = gridInqXsize(gridID); int nlon = gridInqXsize(gridID);
...@@ -1173,11 +1182,11 @@ void *Magplot(void *argument) ...@@ -1173,11 +1182,11 @@ void *Magplot(void *argument)
//int nlev = zaxisInqSize(zaxisID); //int nlev = zaxisInqSize(zaxisID);
double *array = (double*) Malloc(gridsize*sizeof(double)); double *array = (double*) Malloc(gridsize*sizeof(double));
double *grid_center_lat = (double*) Malloc(gridsize*sizeof(double));
double *grid_center_lon = (double*) Malloc(gridsize*sizeof(double)); double *grid_center_lon = (double*) Malloc(gridsize*sizeof(double));
double *grid_center_lat = (double*) Malloc(gridsize*sizeof(double));
gridInqYvals(gridID, grid_center_lat);
gridInqXvals(gridID, grid_center_lon); gridInqXvals(gridID, grid_center_lon);
gridInqYvals(gridID, grid_center_lat);
/* Convert lat/lon units if required */ /* Convert lat/lon units if required */
gridInqXunits(gridID, units); gridInqXunits(gridID, units);
...@@ -1264,7 +1273,7 @@ void *Magplot(void *argument) ...@@ -1264,7 +1273,7 @@ void *Magplot(void *argument)
if( DBG ) if( DBG )
fprintf( stderr,"Plot %d\n",varID ); fprintf( stderr,"Plot %d\n",varID );
magplot(cdoStreamName(1)->args, operatorID, varname, units, nlon, nlat, grid_center_lon, grid_center_lat, array, nparam, pnames, datetimestr ); magplot(cdoStreamName(1)->args, operatorID, varname, units, nlon, nlat, grid_center_lon, grid_center_lat, array, nparam, pnames, datetimestr, lregular);
} }
else else
fprintf(stderr,"operator not implemented\n"); fprintf(stderr,"operator not implemented\n");
......
...@@ -655,11 +655,11 @@ void *Select(void *argument) ...@@ -655,11 +655,11 @@ void *Select(void *argument)
if ( operatorID == DELETE ) if ( operatorID == DELETE )
{ {
result = FALSE; result = FALSE;
for ( varID = 0; varID < nvars; varID++ ) for ( int varID = 0; varID < nvars; varID++ )
{ {
zaxisID = vlistInqVarZaxis(vlistID1, varID); zaxisID = vlistInqVarZaxis(vlistID1, varID);
nlevs = zaxisInqSize(zaxisID); nlevs = zaxisInqSize(zaxisID);
for ( levID = 0; levID < nlevs; levID++ ) for ( int levID = 0; levID < nlevs; levID++ )
vlistDefFlag(vlistID1, varID, levID, TRUE); vlistDefFlag(vlistID1, varID, levID, TRUE);
} }
} }
...@@ -668,7 +668,7 @@ void *Select(void *argument) ...@@ -668,7 +668,7 @@ void *Select(void *argument)
result = TRUE; result = TRUE;
} }
for ( varID = 0; varID < nvars; varID++ ) for ( int varID = 0; varID < nvars; varID++ )
{ {
iparam = vlistInqVarParam(vlistID1, varID); iparam = vlistInqVarParam(vlistID1, varID);
code = vlistInqVarCode(vlistID1, varID); code = vlistInqVarCode(vlistID1, varID);
...@@ -727,7 +727,7 @@ void *Select(void *argument) ...@@ -727,7 +727,7 @@ void *Select(void *argument)
} }
} }
for ( varID = 0; varID < nvars; varID++ ) for ( int varID = 0; varID < nvars; varID++ )
{ {
if ( vars[varID] ) if ( vars[varID] )
{ {
...@@ -740,7 +740,7 @@ void *Select(void *argument) ...@@ -740,7 +740,7 @@ void *Select(void *argument)
} }
} }
for ( varID = 0; varID < nvars; varID++ ) for ( int varID = 0; varID < nvars; varID++ )
{ {
if ( vars[varID] ) if ( vars[varID] )
{ {
...@@ -792,15 +792,16 @@ void *Select(void *argument) ...@@ -792,15 +792,16 @@ void *Select(void *argument)
if ( npar_timestep_of_year || npar_timestep || npar_year || npar_month || npar_day || npar_hour || npar_minute ) ltimsel = TRUE; if ( npar_timestep_of_year || npar_timestep || npar_year || npar_month || npar_day || npar_hour || npar_minute ) ltimsel = TRUE;
npar = 0; npar = 0;
for ( varID = 0; varID < nvars; varID++ ) for ( int varID = 0; varID < nvars; varID++ )
{ {
zaxisID = vlistInqVarZaxis(vlistID1, varID); zaxisID = vlistInqVarZaxis(vlistID1, varID);
nlevs = zaxisInqSize(zaxisID); nlevs = zaxisInqSize(zaxisID);
for ( int levID = 0; levID < nlevs; levID++ )
for ( levID = 0; levID < nlevs; levID++ ) if ( vlistInqFlag(vlistID1, varID, levID) == TRUE )
if ( vlistInqFlag(vlistID1, varID, levID) == result ) break; {
npar++;
if ( levID < nlevs ) npar++; break;
}
} }
if ( npar == 0 ) if ( npar == 0 )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment