Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
cdo
Commits
8d6313d6
Commit
8d6313d6
authored
Sep 03, 2019
by
Uwe Schulzweida
Browse files
Set type of initialized variables to auto.
parent
1d73b5ea
Changes
49
Hide whitespace changes
Inline
Side-by-side
src/CMOR_lite.cc
View file @
8d6313d6
...
...
@@ -180,7 +180,7 @@ applyCmorList(PMList &pmlist, int nvars, int vlistID2, std::vector<CmorVar> &var
double
missval
=
0
;
{
const
KVList
*
kvlist
=
pmlist
.
getKVListVentry
(
hentry
);
auto
kvlist
=
pmlist
.
getKVListVentry
(
hentry
);
if
(
kvlist
)
{
for
(
const
auto
&
kv
:
*
kvlist
)
...
...
@@ -220,7 +220,7 @@ applyCmorList(PMList &pmlist, int nvars, int vlistID2, std::vector<CmorVar> &var
}
}
const
KVList
*
kvlist
=
pmlist
.
searchKVListVentry
(
"name"
,
varname
,
ventry
);
auto
kvlist
=
pmlist
.
searchKVListVentry
(
"name"
,
varname
,
ventry
);
if
(
kvlist
)
{
bool
lvalid_min
=
false
,
lvalid_max
=
false
;
...
...
src/Monarith.cc
View file @
8d6313d6
...
...
@@ -61,7 +61,7 @@ Monarith(void *process)
VarList
varList1
;
varListInit
(
varList1
,
vlistID1
);
const
size_t
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
const
auto
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
Field
field1
,
field2
;
field1
.
resize
(
gridsizemax
);
...
...
src/Mrotuvb.cc
View file @
8d6313d6
...
...
@@ -267,16 +267,16 @@ Mrotuvb(void *process)
const
auto
streamID1
=
cdoOpenRead
(
0
);
const
auto
streamID2
=
cdoOpenRead
(
1
);
const
int
vlistID1
=
cdoStreamInqVlist
(
streamID1
);
const
int
vlistID2
=
cdoStreamInqVlist
(
streamID2
);
const
auto
vlistID1
=
cdoStreamInqVlist
(
streamID1
);
const
auto
vlistID2
=
cdoStreamInqVlist
(
streamID2
);
int
nvars
=
vlistNvars
(
vlistID1
);
auto
nvars
=
vlistNvars
(
vlistID1
);
if
(
nvars
>
1
)
cdoAbort
(
"More than one variable found in %s"
,
cdoGetStreamName
(
0
));
nvars
=
vlistNvars
(
vlistID2
);
if
(
nvars
>
1
)
cdoAbort
(
"More than one variable found in %s"
,
cdoGetStreamName
(
1
));
int
gridID1
=
vlistGrid
(
vlistID1
,
0
);
int
gridID2
=
vlistGrid
(
vlistID2
,
0
);
auto
gridID1
=
vlistGrid
(
vlistID1
,
0
);
auto
gridID2
=
vlistGrid
(
vlistID2
,
0
);
const
auto
gridsize
=
gridInqSize
(
gridID1
);
if
(
gpint
&&
gridID1
==
gridID2
)
cdoAbort
(
"Input grids are the same, use parameter >noint< to disable interpolation!"
);
if
(
!
gpint
&&
gridID1
!=
gridID2
)
cdoAbort
(
"Input grids are not the same!"
);
...
...
@@ -293,8 +293,8 @@ Mrotuvb(void *process)
if
(
gridsize
!=
gridInqSize
(
gridID2
))
cdoAbort
(
"Internal problem: gridsize changed!"
);
const
size_t
nlon
=
gridInqXsize
(
gridID1
);
const
size_t
nlat
=
gridInqYsize
(
gridID1
);
const
auto
nlon
=
gridInqXsize
(
gridID1
);
const
auto
nlat
=
gridInqYsize
(
gridID1
);
std
::
vector
<
double
>
grid1x
(
gridsize
),
grid1y
(
gridsize
);
std
::
vector
<
double
>
grid2x
(
gridsize
),
grid2y
(
gridsize
);
...
...
@@ -347,20 +347,20 @@ Mrotuvb(void *process)
grid3y
[
i
]
*=
DEG2RAD
;
}
int
vlistID3
=
vlistCreate
();
auto
vlistID3
=
vlistCreate
();
vlistCopy
(
vlistID3
,
vlistID1
);
vlistCat
(
vlistID3
,
vlistID2
);
int
code1
=
vlistInqVarCode
(
vlistID1
,
0
);
int
code2
=
vlistInqVarCode
(
vlistID2
,
0
);
auto
code1
=
vlistInqVarCode
(
vlistID1
,
0
);
auto
code2
=
vlistInqVarCode
(
vlistID2
,
0
);
if
(
code1
==
code2
)
vlistDefVarCode
(
vlistID3
,
1
,
code1
+
1
);
vlistChangeGrid
(
vlistID3
,
gridID1
,
gridID3
);
vlistChangeGrid
(
vlistID3
,
gridID2
,
gridID3
);
int
taxisID1
=
vlistInqTaxis
(
vlistID1
);
int
taxisID3
=
taxisDuplicate
(
taxisID1
);
auto
taxisID1
=
vlistInqTaxis
(
vlistID1
);
auto
taxisID3
=
taxisDuplicate
(
taxisID1
);
vlistDefTaxis
(
vlistID3
,
taxisID3
);
if
(
Options
::
cdoVerbose
)
vlistPrint
(
vlistID3
);
...
...
@@ -368,8 +368,8 @@ Mrotuvb(void *process)
const
auto
streamID3
=
cdoOpenWrite
(
2
);
cdoDefVlist
(
streamID3
,
vlistID3
);
double
missval1
=
vlistInqVarMissval
(
vlistID1
,
0
);
double
missval2
=
vlistInqVarMissval
(
vlistID2
,
0
);
auto
missval1
=
vlistInqVarMissval
(
vlistID1
,
0
);
auto
missval2
=
vlistInqVarMissval
(
vlistID2
,
0
);
std
::
vector
<
double
>
ufield
(
gridsize
),
vfield
(
gridsize
);
std
::
vector
<
double
>
urfield
(
gridsize
),
vrfield
(
gridsize
);
...
...
src/Recttocomplex.cc
View file @
8d6313d6
...
...
@@ -52,7 +52,7 @@ Recttocomplex(void *process)
const
auto
streamID3
=
cdoOpenWrite
(
2
);
cdoDefVlist
(
streamID3
,
vlistID3
);
const
size_t
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
const
auto
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
std
::
vector
<
double
>
array1
(
gridsizemax
);
std
::
vector
<
double
>
array2
(
gridsizemax
);
std
::
vector
<
double
>
array3
(
2
*
gridsizemax
);
...
...
src/Remapweights.cc
View file @
8d6313d6
...
...
@@ -420,7 +420,7 @@ checkRemapFilesize(RemapGridW &src_grid, RemapGridW &tgt_grid, RemapVarsW &rv, i
if
(
filesize
>
0x7FFFFC00
)
// 2**31 - 1024 (<2GB)
{
const
size_t
maxlinks
=
0x3FFFFFFF
;
// 1GB
const
size_t
gridsizemax
=
(
src_grid
.
ncells
>
tgt_grid
.
ncells
)
?
src_grid
.
ncells
:
tgt_grid
.
ncells
;
const
auto
gridsizemax
=
(
src_grid
.
ncells
>
tgt_grid
.
ncells
)
?
src_grid
.
ncells
:
tgt_grid
.
ncells
;
if
(
nlinks
>
maxlinks
||
filesize
>
8
*
maxlinks
||
gridsizemax
>
0x7FFFFC00
)
{
#ifdef HAVE_NETCDF4
...
...
src/Replacevalues.cc
View file @
8d6313d6
...
...
@@ -92,7 +92,7 @@ Replacevalues(void *process)
cdoDefVlist
(
streamID2
,
vlistID2
);
const
size_t
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
const
auto
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
std
::
vector
<
double
>
array
(
gridsizemax
);
int
tsID
=
0
;
...
...
src/Rotuv.cc
View file @
8d6313d6
...
...
@@ -38,8 +38,8 @@ rot_uv_back(int gridID, double *us, double *vs)
if
(
gridInqType
(
gridID
)
==
GRID_PROJECTION
&&
gridInqProjType
(
gridID
)
==
CDI_PROJ_RLL
)
gridInqParamRLL
(
gridID
,
&
xpole
,
&
ypole
,
&
angle
);
const
size_t
nlon
=
gridInqXsize
(
gridID
);
const
size_t
nlat
=
gridInqYsize
(
gridID
);
const
auto
nlon
=
gridInqXsize
(
gridID
);
const
auto
nlat
=
gridInqYsize
(
gridID
);
std
::
vector
<
double
>
xvals
(
nlon
);
std
::
vector
<
double
>
yvals
(
nlat
);
...
...
@@ -62,9 +62,9 @@ rot_uv_back(int gridID, double *us, double *vs)
for
(
size_t
ilat
=
0
;
ilat
<
nlat
;
ilat
++
)
for
(
size_t
ilon
=
0
;
ilon
<
nlon
;
ilon
++
)
{
const
size_t
i
=
ilat
*
nlon
+
ilon
;
const
double
xval
=
lamrot_to_lam
(
yvals
[
ilat
],
xvals
[
ilon
],
ypole
,
xpole
,
angle
);
const
double
yval
=
phirot_to_phi
(
yvals
[
ilat
],
xvals
[
ilon
],
ypole
,
angle
);
const
auto
i
=
ilat
*
nlon
+
ilon
;
const
auto
xval
=
lamrot_to_lam
(
yvals
[
ilat
],
xvals
[
ilon
],
ypole
,
xpole
,
angle
);
const
auto
yval
=
phirot_to_phi
(
yvals
[
ilat
],
xvals
[
ilon
],
ypole
,
angle
);
usvs_to_uv
(
us
[
i
],
vs
[
i
],
yval
,
xval
,
ypole
,
xpole
,
&
us
[
i
],
&
vs
[
i
]);
}
}
...
...
src/Runstat.cc
View file @
8d6313d6
...
...
@@ -128,7 +128,7 @@ Runstat(void *process)
if
(
lvars2
)
fieldsFromVlist
(
vlistID1
,
vars2
[
its
],
FIELD_VEC
);
}
const
size_t
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
const
auto
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
std
::
vector
<
bool
>
imask
(
gridsizemax
);
int
tsID
=
0
;
...
...
src/Samplegrid.cc
View file @
8d6313d6
...
...
@@ -34,11 +34,11 @@
static
void
sampleData
(
const
double
*
array1
,
int
gridID1
,
double
*
array2
,
int
gridID2
,
int
resampleFactor
)
{
const
size_t
nlon1
=
gridInqXsize
(
gridID1
);
const
size_t
nlat1
=
gridInqYsize
(
gridID1
);
const
auto
nlon1
=
gridInqXsize
(
gridID1
);
const
auto
nlat1
=
gridInqYsize
(
gridID1
);
const
size_t
nlon2
=
gridInqXsize
(
gridID2
);
const
size_t
nlat2
=
gridInqYsize
(
gridID2
);
const
auto
nlon2
=
gridInqXsize
(
gridID2
);
const
auto
nlat2
=
gridInqYsize
(
gridID2
);
if
(
cdoDebugExt
>=
100
)
cdoPrint
(
"%s(): (nlon1: %zu; nlat1: %zu) => (nlon2: %zu; nlat2: %zu); "
...
...
@@ -86,12 +86,12 @@ Samplegrid(void *process)
cdoInitialize
(
process
);
const
int
SAMPLEGRID
=
cdoOperatorAdd
(
"samplegrid"
,
0
,
0
,
"resample factor, typically 2 (which will half the resolution)"
);
const
int
SUBGRID
=
cdoOperatorAdd
(
"subgrid"
,
0
,
0
,
" sub-grid indices: i0,i1,j0,j1"
);
const
auto
SAMPLEGRID
=
cdoOperatorAdd
(
"samplegrid"
,
0
,
0
,
"resample factor, typically 2 (which will half the resolution)"
);
const
auto
SUBGRID
=
cdoOperatorAdd
(
"subgrid"
,
0
,
0
,
" sub-grid indices: i0,i1,j0,j1"
);
const
int
operatorID
=
cdoOperatorID
();
const
auto
operatorID
=
cdoOperatorID
();
const
int
nch
=
operatorArgc
();
const
auto
nch
=
operatorArgc
();
if
(
operatorID
==
SAMPLEGRID
)
{
...
...
@@ -117,18 +117,18 @@ Samplegrid(void *process)
const
auto
streamID1
=
cdoOpenRead
(
0
);
const
int
vlistID1
=
cdoStreamInqVlist
(
streamID1
);
const
int
vlistID2
=
vlistDuplicate
(
vlistID1
);
const
auto
vlistID1
=
cdoStreamInqVlist
(
streamID1
);
const
auto
vlistID2
=
vlistDuplicate
(
vlistID1
);
const
int
taxisID1
=
vlistInqTaxis
(
vlistID1
);
const
int
taxisID2
=
taxisDuplicate
(
taxisID1
);
const
auto
taxisID1
=
vlistInqTaxis
(
vlistID1
);
const
auto
taxisID2
=
taxisDuplicate
(
taxisID1
);
vlistDefTaxis
(
vlistID2
,
taxisID2
);
const
int
nvars
=
vlistNvars
(
vlistID1
);
const
auto
nvars
=
vlistNvars
(
vlistID1
);
std
::
vector
<
bool
>
vars
(
nvars
);
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
vars
[
varID
]
=
false
;
int
ngrids
=
vlistNgrids
(
vlistID1
);
auto
ngrids
=
vlistNgrids
(
vlistID1
);
Debug
(
cdoDebugExt
,
"ngrids = %d
\n
"
,
ngrids
);
...
...
@@ -136,7 +136,7 @@ Samplegrid(void *process)
for
(
int
index
=
0
;
index
<
ngrids
;
index
++
)
{
const
int
gridSrcID
=
vlistGrid
(
vlistID1
,
index
);
const
auto
gridSrcID
=
vlistGrid
(
vlistID1
,
index
);
int
gridIDsampled
=
-
1
;
if
(
gridInqSize
(
gridSrcID
)
<=
1
)
continue
;
...
...
@@ -175,7 +175,7 @@ Samplegrid(void *process)
const
auto
streamID2
=
cdoOpenWrite
(
1
);
cdoDefVlist
(
streamID2
,
vlistID2
);
size_t
gridsize
=
vlistGridsizeMax
(
vlistID1
);
auto
gridsize
=
vlistGridsizeMax
(
vlistID1
);
if
(
vlistNumber
(
vlistID1
)
!=
CDI_REAL
)
gridsize
*=
2
;
std
::
vector
<
double
>
array1
(
gridsize
);
...
...
src/Seascount.cc
View file @
8d6313d6
...
...
@@ -58,7 +58,7 @@ Seascount(void *process)
const
int
maxrecs
=
vlistNrecs
(
vlistID1
);
std
::
vector
<
RecordInfo
>
recList
(
maxrecs
);
size_t
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
auto
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
if
(
vlistNumber
(
vlistID1
)
!=
CDI_REAL
)
gridsizemax
*=
2
;
Field
field
;
...
...
src/Selbox.cc
View file @
8d6313d6
...
...
@@ -23,10 +23,9 @@
*/
#include
<cdi.h>
#include
<mpim_grid.h>
#include
<mpim_grid.h>
#include
"grid_define.h"
#include
"cdo_int.h"
#include
"cdo_options.h"
#include
"process_int.h"
...
...
@@ -34,6 +33,7 @@
#include
"param_conversion.h"
#include
"gridreference.h"
static
void
correct_xvals
(
const
long
nlon
,
const
long
inc
,
double
*
xvals
)
{
...
...
@@ -476,12 +476,7 @@ genlonlatboxCurv(const int gridID, double xlon1, double xlon2, double xlat1, dou
xlon2 += 360;
}
*/
if
(
xlat1
>
xlat2
)
{
const
double
xtemp
=
xlat1
;
xlat1
=
xlat2
;
xlat2
=
xtemp
;
}
if
(
xlat1
>
xlat2
)
std
::
swap
(
xlat1
,
xlat2
);
lat1
=
nlat
-
1
;
lat2
=
0
;
...
...
@@ -527,6 +522,7 @@ genlonlatboxCurv(const int gridID, double xlon1, double xlon2, double xlat1, dou
xlast
=
xfact
*
xvals
[
ilat
*
nlon
+
nlon
-
1
];
if
(
xlast
>
xlon2
)
xlast
=
xlon2
;
//printf("%g %g %g %g %g %g\n", yval, xval, xlon1, xlast, xfirst, xlon2);
if
(
xval
>=
xlon1
&&
xval
<=
xlast
)
{
if
(
ilon
<
lon21
)
lon21
=
ilon
;
...
...
@@ -574,8 +570,15 @@ genlonlatboxCurv(const int gridID, double xlon1, double xlon2, double xlat1, dou
// while ( lon12 >= lon21 ) lon12--;
// if ( lon12 <= lon11 ) { lon11 = nlon-1; lon12 = 0; }
if
(
lon12
==
0
&&
lon11
>
0
)
lon11
=
-
1
;
if
(
lon12
==
0
&&
lon11
>
0
)
{
lon11
=
0
;
lon12
=
-
1
;
}
/*
printf("lon21, lon22, lon11, lon12 idx: %ld %ld %ld %ld lon: %g %g %g %g\n",
lon21, lon22, lon11, lon12, xvals[lon21], xvals[lon22], xvals[lon11], xvals[lon12]);
*/
if
(
lat2
-
lat1
+
1
<=
0
)
cdoAbort
(
"Latitudinal dimension is too small!"
);
}
...
...
@@ -682,8 +685,8 @@ gencellgrid(int gridID1, long *gridsize2, std::vector<long> &cellidx)
long
nvals
=
0
;
for
(
size_t
i
=
0
;
i
<
gridsize1
;
++
i
)
{
double
xval
=
xvals
[
i
]
*
xfact
;
double
yval
=
yvals
[
i
]
*
yfact
;
const
double
xval
=
xvals
[
i
]
*
xfact
;
const
double
yval
=
yvals
[
i
]
*
yfact
;
if
(
yval
>=
xlat1
&&
yval
<=
xlat2
)
if
((
xval
>=
xlon1
&&
xval
<=
xlon2
)
||
(
xval
+
360
>=
xlon1
&&
xval
+
360
<=
xlon2
)
||
(
xval
-
360
>=
xlon1
&&
xval
-
360
<=
xlon2
))
...
...
src/Seloperator.cc
View file @
8d6313d6
...
...
@@ -95,7 +95,7 @@ Seloperator(void *process)
std
::
vector
<
double
>
array
;
if
(
!
lcopy
)
{
const
size_t
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
const
auto
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
array
.
resize
(
gridsizemax
);
}
...
...
src/Selvar.cc
View file @
8d6313d6
...
...
@@ -308,7 +308,7 @@ Selvar(void *process)
std
::
vector
<
double
>
array
;
if
(
!
lcopy
)
{
size_t
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
auto
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
if
(
vlistNumber
(
vlistID1
)
!=
CDI_REAL
)
gridsizemax
*=
2
;
array
.
resize
(
gridsizemax
);
}
...
...
src/Selyearidx.cc
View file @
8d6313d6
...
...
@@ -67,7 +67,7 @@ Selyearidx(void *process)
const
int
maxrecs
=
vlistNrecs
(
vlistID1
);
std
::
vector
<
RecordInfo
>
recList
(
maxrecs
);
const
size_t
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
const
auto
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
std
::
vector
<
double
>
array
(
gridsizemax
);
...
...
src/Set.cc
View file @
8d6313d6
...
...
@@ -33,6 +33,7 @@
#include
"param_conversion.h"
#include
"cdo_zaxis.h"
int
stringToParam
(
const
char
*
paramstr
)
{
...
...
@@ -59,13 +60,13 @@ Set(void *process)
cdoInitialize
(
process
);
// clang-format off
const
int
SETCODE
=
cdoOperatorAdd
(
"setcode"
,
0
,
0
,
"code number"
);
const
int
SETPARAM
=
cdoOperatorAdd
(
"setparam"
,
0
,
0
,
"parameter identifier (format: code[.tabnum] or num[.cat[.dis]])"
);
const
int
SETNAME
=
cdoOperatorAdd
(
"setname"
,
0
,
0
,
"variable name"
);
const
int
SETUNIT
=
cdoOperatorAdd
(
"setunit"
,
0
,
0
,
"variable unit"
);
const
int
SETLEVEL
=
cdoOperatorAdd
(
"setlevel"
,
0
,
0
,
"level"
);
const
int
SETLTYPE
=
cdoOperatorAdd
(
"setltype"
,
0
,
0
,
"GRIB level type"
);
const
int
SETTABNUM
=
cdoOperatorAdd
(
"settabnum"
,
0
,
0
,
"GRIB table number"
);
const
auto
SETCODE
=
cdoOperatorAdd
(
"setcode"
,
0
,
0
,
"code number"
);
const
auto
SETPARAM
=
cdoOperatorAdd
(
"setparam"
,
0
,
0
,
"parameter identifier (format: code[.tabnum] or num[.cat[.dis]])"
);
const
auto
SETNAME
=
cdoOperatorAdd
(
"setname"
,
0
,
0
,
"variable name"
);
const
auto
SETUNIT
=
cdoOperatorAdd
(
"setunit"
,
0
,
0
,
"variable unit"
);
const
auto
SETLEVEL
=
cdoOperatorAdd
(
"setlevel"
,
0
,
0
,
"level"
);
const
auto
SETLTYPE
=
cdoOperatorAdd
(
"setltype"
,
0
,
0
,
"GRIB level type"
);
const
auto
SETTABNUM
=
cdoOperatorAdd
(
"settabnum"
,
0
,
0
,
"GRIB table number"
);
// clang-format on
const
int
operatorID
=
cdoOperatorID
();
...
...
@@ -98,12 +99,12 @@ Set(void *process)
const
auto
streamID1
=
cdoOpenRead
(
0
);
const
int
vlistID1
=
cdoStreamInqVlist
(
streamID1
);
const
int
vlistID2
=
vlistDuplicate
(
vlistID1
);
const
auto
vlistID1
=
cdoStreamInqVlist
(
streamID1
);
const
auto
vlistID2
=
vlistDuplicate
(
vlistID1
);
/* vlistPrint(vlistID2);*/
const
int
taxisID1
=
vlistInqTaxis
(
vlistID1
);
const
int
taxisID2
=
taxisDuplicate
(
taxisID1
);
const
auto
taxisID1
=
vlistInqTaxis
(
vlistID1
);
const
auto
taxisID2
=
taxisDuplicate
(
taxisID1
);
vlistDefTaxis
(
vlistID2
,
taxisID2
);
if
(
operatorID
==
SETCODE
)
...
...
@@ -163,7 +164,7 @@ Set(void *process)
const
auto
streamID2
=
cdoOpenWrite
(
1
);
cdoDefVlist
(
streamID2
,
vlistID2
);
size_t
gridsize
=
vlistGridsizeMax
(
vlistID1
);
auto
gridsize
=
vlistGridsizeMax
(
vlistID1
);
if
(
vlistNumber
(
vlistID1
)
!=
CDI_REAL
)
gridsize
*=
2
;
std
::
vector
<
double
>
array
(
gridsize
);
...
...
src/Setgatt.cc
View file @
8d6313d6
...
...
@@ -107,7 +107,7 @@ Setgatt(void *process)
cdoDefVlist
(
streamID2
,
vlistID2
);
size_t
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
auto
gridsizemax
=
vlistGridsizeMax
(
vlistID1
);
if
(
vlistNumber
(
vlistID1
)
!=
CDI_REAL
)
gridsizemax
*=
2
;
std
::
vector
<
double
>
array
(
gridsizemax
);
...
...
src/Sethalo.cc
View file @
8d6313d6
...
...
@@ -33,16 +33,16 @@ gentpngrid(int gridID1)
{
size_t
ilat
,
ilon
,
ilonr
,
k
,
kr
;
size_t
nlon1
=
gridInqXsize
(
gridID1
);
size_t
nlat1
=
gridInqYsize
(
gridID1
);
auto
nlon1
=
gridInqXsize
(
gridID1
);
auto
nlat1
=
gridInqYsize
(
gridID1
);
size_t
nlon2
=
nlon1
;
size_t
nlat2
=
nlat1
+
2
;
auto
nlon2
=
nlon1
;
auto
nlat2
=
nlat1
+
2
;
int
gridtype
=
gridInqType
(
gridID1
);
int
prec
=
gridInqDatatype
(
gridID1
);
auto
gridtype
=
gridInqType
(
gridID1
);
auto
prec
=
gridInqDatatype
(
gridID1
);
int
gridID2
=
gridCreate
(
gridtype
,
nlon2
*
nlat2
);
auto
gridID2
=
gridCreate
(
gridtype
,
nlon2
*
nlat2
);
gridDefXsize
(
gridID2
,
nlon2
);
gridDefYsize
(
gridID2
,
nlat2
);
...
...
@@ -150,7 +150,7 @@ gentpngrid(int gridID1)
}
static
int
gengrid
(
int
gridID1
,
int
lhalo
,
int
rhalo
)
gengrid
(
int
gridID1
,
long
lhalo
,
long
rhalo
)
{
long
i
,
ilat
,
ilon
;
double
cpi2
=
M_PI
*
2
;
...
...
@@ -318,62 +318,62 @@ gengrid(int gridID1, int lhalo, int rhalo)
}
static
int
genindexgrid
(
int
gridID1
,
int
*
lhalo
,
int
*
rhalo
)
genindexgrid
(
int
gridID1
,
long
&
lhalo
,
long
&
rhalo
)
{
operatorCheckArgc
(
2
);
*
lhalo
=
parameter2
int
(
operatorArgv
()[
0
]);
*
rhalo
=
parameter2
int
(
operatorArgv
()[
1
]);
lhalo
=
parameter2
long
(
operatorArgv
()[
0
]);
rhalo
=
parameter2
long
(
operatorArgv
()[
1
]);
int
nlon1
=
gridInqXsize
(
gridID1
);
long
nlon1
=
gridInqXsize
(
gridID1
);
if
(
*
lhalo
>
nlon1
)
if
(
lhalo
>
nlon1
)
{
*
lhalo
=
nlon1
;
cdoWarning
(
"left halo out of range. Set to %d."
,
*
lhalo
);
lhalo
=
nlon1
;
cdoWarning
(
"left halo out of range. Set to %d."
,
lhalo
);
}
if
(
*
lhalo
<
0
&&
-
(
*
lhalo
)
>
nlon1
/
2
)
if
(
lhalo
<
0
&&
-
(
lhalo
)
>
nlon1
/
2
)
{
*
lhalo
=
-
nlon1
/
2
;
cdoWarning
(
"left halo out of range. Set to %d."
,
*
lhalo
);
lhalo
=
-
nlon1
/
2
;
cdoWarning
(
"left halo out of range. Set to %d."
,
lhalo
);
}
if
(
*
rhalo
>
nlon1
)
if
(
rhalo
>
nlon1
)
{
*
rhalo
=
nlon1
;
cdoWarning
(
"right halo out of range. Set to %d."
,
*
rhalo
);
rhalo
=
nlon1
;
cdoWarning
(
"right halo out of range. Set to %d."
,
rhalo
);
}
if
(
*
rhalo
<
0
&&
-
(
*
rhalo
)
>
nlon1
/
2
)
if
(
rhalo
<
0
&&
-
(
rhalo
)
>
nlon1
/
2
)
{
*
rhalo
=
-
nlon1
/
2
;
cdoWarning
(
"right halo out of range. Set to %d."
,
*
rhalo
);
rhalo
=
-
nlon1
/
2
;
cdoWarning
(
"right halo out of range. Set to %d."
,
rhalo
);
}
int
gridID2
=
gengrid
(
gridID1
,
*
lhalo
,
*
rhalo
);
int
gridID2
=
gengrid
(
gridID1
,
lhalo
,
rhalo
);
return
gridID2
;
}
static
void
halo
(
double
*
array1
,
int
gridID1
,
double
*
array2
,
int
lhalo
,
int
rhalo
)
halo
(
double
*
array1
,
int
gridID1
,
double
*
array2
,
long
lhalo
,
long
rhalo
)
{
int
nlon1
=
gridInqXsize
(
gridID1
);
int
nlat
=
gridInqYsize
(
gridID1
);
long
nlon1
=
gridInqXsize
(
gridID1
);
long
nlat
=
gridInqYsize
(
gridID1
);
int
nmin
=
0
;
int
nmax
=
nlon1
;
long
nmin
=
0
;
long
nmax
=
nlon1
;
if
(
lhalo
<
0
)
nmin
=
-
lhalo
;
if
(
rhalo
<
0
)
nmax
+=
rhalo
;
for
(
int
ilat
=
0
;
ilat
<
nlat
;
ilat
++
)
for
(
long
ilat
=
0
;
ilat
<
nlat
;
ilat
++
)
{
for
(
int
ilon
=
nlon1
-
lhalo
;
ilon
<
nlon1
;
ilon
++
)
*
array2
++
=
array1
[
ilat
*
nlon1
+
ilon
];
for
(
long
ilon
=
nlon1
-
lhalo
;
ilon
<
nlon1
;
ilon
++
)
*
array2
++
=
array1
[
ilat
*
nlon1
+
ilon
];
for
(
int
ilon
=
nmin
;
ilon
<
nmax
;
ilon
++
)
*
array2
++
=
array1
[
ilat
*
nlon1
+
ilon
];
for
(
long
ilon
=
nmin
;
ilon
<
nmax
;
ilon
++
)
*
array2
++
=
array1
[
ilat
*
nlon1
+
ilon
];
for
(
int
ilon
=
0
;
ilon
<
rhalo
;
ilon
++
)
*
array2
++
=
array1
[
ilat
*
nlon1
+
ilon
];
for
(
long
ilon
=
0
;
ilon
<
rhalo
;
ilon
++
)
*
array2
++
=
array1
[
ilat
*
nlon1
+
ilon
];
}
}
...
...
@@ -402,7 +402,7 @@ Sethalo(void *process)
int
gridID1
=
-
1
,
gridID2
;
int
index
;
size_t
nmiss
;
int
lhalo
=
0
,
rhalo
=
0
;
long
lhalo
=
0
,
rhalo
=
0
;
cdoInitialize
(
process
);
...
...
@@ -439,7 +439,7 @@ Sethalo(void *process)
if
(
operatorID
==
SETHALO
)
{
operatorInputArg
(
"left and right halo"
);
gridID2
=
genindexgrid
(
gridID1
,
&
lhalo
,
&
rhalo
);
gridID2
=
genindexgrid
(
gridID1
,
lhalo
,
rhalo
);
}
else
{
...
...
src/Setpartab.cc
View file @
8d6313d6
...
...
@@ -80,7 +80,7 @@ applyParameterList(pt_mode_t ptmode, PMList &pmlist, int nvars, int vlistID2, st
double
missval
=
0
;
{
const
auto
kvlist
=
pmlist
.
getKVListVentry
(
hentry
);
auto
kvlist
=
pmlist
.
getKVListVentry
(
hentry
);
if
(
kvlist
)
{
const
auto
kv
=
kvlist
->
search
(
"missing_value"
);
...
...
@@ -109,12 +109,12 @@ applyParameterList(pt_mode_t ptmode, PMList &pmlist, int nvars, int vlistID2, st
}
}
KVList
*
kvlist
=
nullptr
;
const
KVList
*
kvlist
=
nullptr
;
if
(
ptmode
==
CODE_NUMBER
)
{
codenum
=
vlistInqVarCode
(
vlistID2
,
varID
);
snprintf
(
valstr
,
sizeof
(
valstr
),
"%d"
,
codenum
);
kvlist
=
(
KVList
*
)
pmlist
.
searchKVListVentry
(
"code"
,
valstr
,
ventry
);
kvlist
=
pmlist
.
searchKVListVentry
(
"code"
,
valstr
,
ventry
);
if
(
kvlist
)
{
const
auto
tableID
=
vlistInqVarTable
(
vlistID2
,
varID
);
...
...
@@ -138,7 +138,7 @@ applyParameterList(pt_mode_t ptmode, PMList &pmlist, int nvars, int vlistID2, st
const
auto
param
=
vlistInqVarParam
(
vlistID2
,
varID
);
paramToString
(
param
,
paramstr
,
sizeof
(
paramstr
));
snprintf
(
valstr
,
sizeof
(
valstr
),
"%s"
,
paramstr
);
kvlist
=
(
KVList
*
)
pmlist
.
searchKVListVentry
(
"param"
,
valstr
,
ventry
);
kvlist
=
pmlist
.
searchKVListVentry
(
"param"
,
valstr
,
ventry
);
if
(
kvlist
)
{
const
auto
levtype
=
zaxisInqLtype
(
vlistInqVarZaxis
(
vlistID2
,
varID
));
...
...
@@ -149,7 +149,7 @@ applyParameterList(pt_mode_t ptmode, PMList &pmlist, int nvars, int vlistID2, st
}
else
if
(
ptmode
==
VARIABLE_NAME
)
{
kvlist
=
(
KVList
*
)
pmlist
.
searchKVListVentry
(
"name"
,
varname
,
ventry
);
kvlist
=
pmlist
.
searchKVListVentry
(
"name"
,
varname
,
ventry
);
}
if
(
kvlist
)
...
...
src/Shiftxy.cc
View file @
8d6313d6
...
...
@@ -92,10 +92,10 @@ shifty(bool lcyclic, int nshift, int nx, int ny, const double *array1, double *a
static
int
shiftx_coord
(
bool
lcyclic
,
int
nshift
,
int
gridID1
)
{
const
int
gridID2
=
gridDuplicate
(
gridID1
);
const
auto
gridID2
=
gridDuplicate
(
gridID1
);
const
size_t
nx
=
gridInqXsize
(
gridID1
);
size_t
ny
=
gridInqYsize
(
gridID1
);
const
auto
nx
=
gridInqXsize
(
gridID1
);
auto
ny
=
gridInqYsize
(
gridID1
);
if
(
gridInqType
(
gridID1
)
!=
GRID_CURVILINEAR
)
ny
=
1
;
std
::
vector
<
double
>
array1
(
nx
*
ny
);
...
...
@@ -126,10 +126,10 @@ shiftx_coord(bool lcyclic, int nshift, int gridID1)
static
int
shifty_coord
(
bool
lcyclic
,
int
nshift
,
int
gridID1
)
{
const
int
gridID2
=
gridDuplicate
(
gridID1
);
const
auto
gridID2
=
gridDuplicate
(
gridID1
);