Commit 1ace4005 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added option --Dkext.

parent 7d13512e
......@@ -6,15 +6,12 @@
subgrid Similar to selindexbox but this operator works for LCC grids (tested on HARMONIE NWP model).
*/
#include "cdi.h"
#include <cdi.h>
#include "cdo_int.h"
#include "grid.h"
#include "griddes.h"
#include "pstream.h"
#include "grid.h"
extern int cdoDebugExt; // defined in cdo.c
static
void sampleData(double *array1, int gridID1, double *array2, int gridID2, int resampleFactor)
{
......@@ -43,7 +40,7 @@ void cropData(double *array1, int gridID1, double *array2, int gridID2, int subI
if ( rowLen!= nlon2 )
cdoAbort("cropData() rowLen!= nlon2 [%d != %d]", rowLen, nlon2);
if ( cdoDebugExt>=10 ) cdoPrint("cropData(%d,%d,%d,%d) ...\n",subI0,subI1, subJ0, subJ1 );
if ( cdoDebugExt>=10 ) cdoPrint("cropData(%d,%d,%d,%d) ...\n", subI0, subI1, subJ0, subJ1 );
long array2Idx = 0;
for ( long ilat1 = subJ0; ilat1 <= subJ1; ilat1++ ) // copy the last row as well..
......@@ -81,7 +78,7 @@ void *SampleGrid(void *argument)
if ( operatorID == SAMPLEGRID )
{
if ( cdoDebugExt ) cdoPrint("samplegrid operator requested..");
if ( nch<1 ) cdoAbort("Number of input arguments < 1; At least 1 argument needed: resample-factor (2,3,4, .. etc)");
if ( nch < 1 ) cdoAbort("Number of input arguments < 1; At least 1 argument needed: resample-factor (2,3,4, .. etc)");
resampleFactor = parameter2int(operatorArgv()[0]);
if ( cdoDebugExt ) cdoPrint("resampleFactor = %d", resampleFactor);
......@@ -89,7 +86,7 @@ void *SampleGrid(void *argument)
else if ( operatorID == SUBGRID )
{
if ( cdoDebugExt ) cdoPrint("subgrid operator requested..");
if ( nch<4 ) cdoAbort("Number of input arguments < 4; Must specify sub-grid indices: i0,i1,j0,j1; This works only with LCC grid. For other grids use: selindexbox");
if ( nch < 4 ) cdoAbort("Number of input arguments < 4; Must specify sub-grid indices: i0,i1,j0,j1; This works only with LCC grid. For other grids use: selindexbox");
subI0 = parameter2int(operatorArgv()[0]);
subI1 = parameter2int(operatorArgv()[1]);
subJ0 = parameter2int(operatorArgv()[2]);
......@@ -137,11 +134,6 @@ void *SampleGrid(void *argument)
cdoAbort("Unsupported grid type: %s; This works only with LCC grid. For other grids use: selindexbox", gridNamePtr(gridtype));
int gridIDcurvl = gridToCurvilinear(gridSrcID, 1);
if ( gridInqType(gridIDcurvl) != GRID_CURVILINEAR )
{
gridDestroy(gridIDcurvl);
cdoAbort("cdo SampleGrid: define_subgrid_grid() Creation of curvilinear grid definition failed: type != GRID_CURVILINEAR");
}
gridIDsampled = cdo_define_subgrid_grid(gridSrcID, gridIDcurvl, subI0, subI1, subJ0, subJ1);
......
......@@ -16,12 +16,10 @@
*/
#include <cdi.h>
#include "cdo.h"
#include "cdo_int.h"
#include "pstream.h"
#include "listarray.h"
int cdoDebugExt = 0; // Debug level for the KNMI extensions
/*
Supported notations:
......@@ -149,11 +147,6 @@ int getNumberOfDeleteSelectionTuples();
int multiSelectionParser(const char *filenameOrString);
//extern static void cdoSetDebug(int level); // defined in cdo.c
extern int cdoDebugExt; // defined in cdo.c
// Defined in stream_grd.c:
void *Selmulti(void *argument)
{
......
......@@ -27,34 +27,13 @@
rotuvNorth : rotate grid-relative wind(u,v) to North_pole-relative
*/
static int cdoDebugExt = 0; // Debug level for the KNMI extensions
#include <ctype.h>
#include "cdo.h"
#include "cdi.h"
#include <cdi.h>
#include "cdo_int.h"
#include "grid.h"
#include "griddes.h"
#include "pstream.h"
#include "specspace.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846 // pi
#endif
#ifndef rad2deg
#define rad2deg (180./M_PI) // conversion for rad to deg
#endif
#ifndef deg2rad
#define deg2rad (M_PI/180.) // conversion for deg to rad
#endif
#include "grid.h"
/*
extern int cdoDebugExt; // debug level for the KNMI extensions
extern int cdoGribDataScanningMode; // -1: not used; allowed modes: <0, 64, 96>; Default is 64
int define_destagered_grid(int gridID_u_stag, int gridID_v_stag, double *destagGridOffsets);
......@@ -1111,7 +1090,7 @@ void rot_uv_north(int gridID, double *us, double *vs)
#define OPTrotuvNorth 1 // ACTIVATE SPEED - OPTIMIZATION
#define radians(aDeg) (deg2rad*aDeg)
#define radians(aDeg) (DEG2RAD*aDeg)
#define NormVector(vec0,vec1,vec2) {\
double vecLen = sqrt(vec0*vec0 + vec1*vec1 + vec2*vec2);\
vec0 = vec0/vecLen; vec1 = vec1/vecLen; vec2 = vec2/vecLen; }
......@@ -1247,13 +1226,13 @@ void rot_uv_north(int gridID, double *us, double *vs)
if ( ((i<3) && (j<3)) || ((i>(nx-3)) && (j>(ny-3)) ) )
{
cdoPrint("grid point [%03d,%03d] with latlon[%3.6f,%3.6f]; (lon_pntNorth, lat_pntNorth) = [%3.6f,%3.6f]; dLonNorth=%3.6f; dLatNorth=%3.6f (Northing grid relative) ",\
i,j, lon_pnt0, lat_pnt0,lon_pntNorth, lat_pntNorth, rad2deg*dLonNorth, rad2deg*dLatNorth );
i,j, lon_pnt0, lat_pnt0,lon_pntNorth, lat_pntNorth, RAD2DEG*dLonNorth, RAD2DEG*dLatNorth );
cdoPrint("grid point [%03d,%03d] with latlon[%3.6f,%3.6f]; (lon_pntEast,lat_pntEast )= [%3.6f,%3.6f]; dLonEast =%3.6f; dLatEast =%3.6f (Easting grid relative ) ",\
i,j, lon_pnt0, lat_pnt0,lon_pntEast,lat_pntEast, rad2deg*dLonEast, rad2deg*dLatEast );
i,j, lon_pnt0, lat_pnt0,lon_pntEast,lat_pntEast, RAD2DEG*dLonEast, RAD2DEG*dLatEast );
//cdoPrint("(xpntNorthSph, ypntNorthSph)= [%3.6f,%3.6f]; (xpntEastSph,ypntEastSph) = [%3.6f,%3.6f];",
// xpntNorthSph, ypntNorthSph, xpntEastSph,ypntEastSph );
//vecAngle = rad2deg * acos( (xpntEastSph*xpntNorthSph + ypntEastSph*ypntNorthSph + zpntEastSph*zpntNorthSph) );
//vecAngle = rad2deg * acos( (xpntEastSph*xpntNorthSph + ypntEastSph*ypntNorthSph) );
//vecAngle = RAD2DEG * acos( (xpntEastSph*xpntNorthSph + ypntEastSph*ypntNorthSph + zpntEastSph*zpntNorthSph) );
//vecAngle = RAD2DEG * acos( (xpntEastSph*xpntNorthSph + ypntEastSph*ypntNorthSph) );
cdoPrint("(xpntNorthSph, ypntNorthSph, zpntNorthSph)= [%3.6f,%3.6f,%3.6f]; (xpntEastSph,ypntEastSph, zpntEastSph) = [%3.6f,%3.6f,%3.6f]; vecAngle= %3.6f",\
xpntNorthSph, ypntNorthSph, zpntNorthSph, xpntEastSph, ypntEastSph, zpntEastSph, vecAngle );
cdoPrint("rotation matrix for grid point [%03d,%03d] with latlon[%3.6f,%3.6f]: (VJaa, VJab, VJba, VJbb) = (%3.6f,%3.6f,%3.6f,%3.6f)",\
......
......@@ -1075,6 +1075,7 @@ int parse_options_long(int argc, char *argv[])
int ltimestat_bounds;
int lsortname;
int lsortparam;
int ldebLevel;
struct cdo_option opt_long[] =
{
......@@ -1110,6 +1111,7 @@ int parse_options_long(int argc, char *argv[])
{ "table", required_argument, NULL, 't' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
{ "Dkext", required_argument, &ldebLevel, 1 },
{ NULL, 0, NULL, 0 }
};
......@@ -1117,6 +1119,8 @@ int parse_options_long(int argc, char *argv[])
while ( 1 )
{
// IMPORTANT: BY EVERY OPTION that takes arguments you MUST set its trigger variable to ZERO;
// otherwise the parameters of other options get wrongly assigned.
lprecision = 0;
lpercentile = 0;
lnetcdf_hdr_pad = 0;
......@@ -1129,6 +1133,7 @@ int parse_options_long(int argc, char *argv[])
ltimestat_bounds = 0;
lsortname = 0;
lsortparam = 0;
ldebLevel = 0;
c = cdo_getopt_long(argc, argv, "f:b:e:P:g:i:k:l:m:n:t:D:z:aBCcdhLMOpQRrsSTuVvWXZ", opt_long, NULL);
if ( c == -1 ) break;
......@@ -1221,6 +1226,11 @@ int parse_options_long(int argc, char *argv[])
{
cdiDefGlobal("SORTPARAM", TRUE);
}
else if ( ldebLevel )
{
int newDebLevelVal = parameter2int(CDO_optarg);
if ( newDebLevelVal > 0 ) cdoDebugExt = newDebLevelVal;
}
break;
case 'a':
cdoDefaultTimeType = TAXIS_ABSOLUTE;
......
......@@ -2,7 +2,6 @@
#include "cdo_int.h"
#include "grid.h"
extern int cdoDebugExt;
/*
@Function define_sample_grid
@Title Define a sampled grid of another grid
......
......@@ -109,7 +109,7 @@ int cdoCompress = FALSE;
int cdoInteractive = FALSE;
int cdoParIO = FALSE;
int cdoRegulargrid = FALSE;
int cdoDebugExt = 0; // Debug level for the KNMI extensions
int cdoNumVarnames = 0;
char **cdoVarnames = NULL;
......
......@@ -89,6 +89,7 @@ extern int cdoDebug;
extern int cdoCompress;
extern int cdoInteractive;
extern int cdoParIO;
extern int cdoDebugExt;
extern int cdoCompType;
extern int cdoCompLevel;
......
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