Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
0a63c031
Commit
0a63c031
authored
Sep 10, 2015
by
Oliver Heidmann
Browse files
reintegrated cdi-conversion_c++
parents
80d34564
2c309907
Changes
59
Show whitespace changes
Inline
Side-by-side
app/cdi.c
View file @
0a63c031
...
@@ -57,7 +57,7 @@ static
...
@@ -57,7 +57,7 @@ static
void
version
(
void
)
void
version
(
void
)
{
{
int
filetypes
[]
=
{
FILETYPE_SRV
,
FILETYPE_EXT
,
FILETYPE_IEG
,
FILETYPE_GRB
,
FILETYPE_GRB2
,
FILETYPE_NC
,
FILETYPE_NC2
,
FILETYPE_NC4
,
FILETYPE_NC4C
};
int
filetypes
[]
=
{
FILETYPE_SRV
,
FILETYPE_EXT
,
FILETYPE_IEG
,
FILETYPE_GRB
,
FILETYPE_GRB2
,
FILETYPE_NC
,
FILETYPE_NC2
,
FILETYPE_NC4
,
FILETYPE_NC4C
};
char
*
typenames
[]
=
{
"srv"
,
"ext"
,
"ieg"
,
"grb"
,
"grb2"
,
"nc"
,
"nc2"
,
"nc4"
,
"nc4c"
};
const
char
*
typenames
[]
=
{
"srv"
,
"ext"
,
"ieg"
,
"grb"
,
"grb2"
,
"nc"
,
"nc2"
,
"nc4"
,
"nc4c"
};
fprintf
(
stderr
,
"CDI version 1.8
\n
"
);
fprintf
(
stderr
,
"CDI version 1.8
\n
"
);
#if defined (COMPILER)
#if defined (COMPILER)
...
...
examples/pio/collectData.c
View file @
0a63c031
...
@@ -39,7 +39,7 @@ static void modelRun(MPI_Comm commModel)
...
@@ -39,7 +39,7 @@ static void modelRun(MPI_Comm commModel)
maxlev
=
5
};
maxlev
=
5
};
static
int
nlev
[
nVars
]
=
{
1
,
1
,
5
,
5
,
2
};
static
int
nlev
[
nVars
]
=
{
1
,
1
,
5
,
5
,
2
};
static
char
*
name
=
"example"
;
const
static
char
*
name
=
"example"
;
int
gridID
,
zaxisID
[
nVars
],
taxisID
;
int
gridID
,
zaxisID
[
nVars
],
taxisID
;
int
vlistID
,
varID
[
nVars
],
streamID
,
tsID
,
tfID
=
0
;
int
vlistID
,
varID
[
nVars
],
streamID
,
tsID
,
tfID
=
0
;
...
...
src/cdi.h
View file @
0a63c031
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#include <stdio.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/types.h>
/*
/*
#if
def
ined(
__cplusplus
)
#ifdef
__cplusplus
extern "C" {
extern "C" {
#endif
#endif
*/
*/
...
@@ -1103,8 +1103,8 @@ const char *institutInqLongnamePtr(int instID);
...
@@ -1103,8 +1103,8 @@ const char *institutInqLongnamePtr(int instID);
/* Model routines */
/* Model routines */
int
modelDef
(
int
instID
,
int
modelgribID
,
const
char
*
name
);
int
modelDef
(
int
instID
,
int
modelgribID
,
const
char
*
name
);
int
modelInq
(
int
instID
,
int
modelgribID
,
char
*
name
);
int
modelInq
(
int
instID
,
int
modelgribID
,
const
char
*
name
);
int
modelInqInstitut
(
int
modelID
);
int
modelInqInstitut
(
int
modelID
)
;
int
modelInqGribID
(
int
modelID
);
int
modelInqGribID
(
int
modelID
);
const
char
*
modelInqNamePtr
(
int
modelID
);
const
char
*
modelInqNamePtr
(
int
modelID
);
...
@@ -1186,7 +1186,6 @@ int vlistInqVarSubtype(int vlistID, int varID);
...
@@ -1186,7 +1186,6 @@ int vlistInqVarSubtype(int vlistID, int varID);
void
gribapiLibraryVersion
(
int
*
major_version
,
int
*
minor_version
,
int
*
revision_version
);
void
gribapiLibraryVersion
(
int
*
major_version
,
int
*
minor_version
,
int
*
revision_version
);
/*
/*
#if defined (__cplusplus)
#if defined (__cplusplus)
}
}
...
...
src/cdi_int.c
View file @
0a63c031
...
@@ -74,7 +74,7 @@ int cdiSortName = 0;
...
@@ -74,7 +74,7 @@ int cdiSortName = 0;
int
cdiHaveMissval
=
0
;
int
cdiHaveMissval
=
0
;
static
long
cdiGetenvInt
(
char
*
envName
)
static
long
cdiGetenvInt
(
const
char
*
envName
)
{
{
char
*
envString
;
char
*
envString
;
long
envValue
=
-
1
;
long
envValue
=
-
1
;
...
...
src/cdi_int.h
View file @
0a63c031
...
@@ -327,7 +327,7 @@ int streamInqFileID(int streamID);
...
@@ -327,7 +327,7 @@ int streamInqFileID(int streamID);
void
gridDefHasDims
(
int
gridID
,
int
hasdims
);
void
gridDefHasDims
(
int
gridID
,
int
hasdims
);
int
gridInqHasDims
(
int
gridID
);
int
gridInqHasDims
(
int
gridID
);
const
char
*
gridNamePtr
(
int
gridtype
);
const
char
*
gridNamePtr
(
int
gridtype
);
char
*
zaxisNamePtr
(
int
leveltype
);
const
char
*
zaxisNamePtr
(
int
leveltype
);
int
zaxisInqLevelID
(
int
zaxisID
,
double
level
);
int
zaxisInqLevelID
(
int
zaxisID
,
double
level
);
void
streamCheckID
(
const
char
*
caller
,
int
streamID
);
void
streamCheckID
(
const
char
*
caller
,
int
streamID
);
...
...
src/cdi_util.c
View file @
0a63c031
...
@@ -90,9 +90,9 @@ void cdiParamToString(int param, char *paramstr, int maxlen)
...
@@ -90,9 +90,9 @@ void cdiParamToString(int param, char *paramstr, int maxlen)
}
}
char
*
cdiUnitNamePtr
(
int
cdi_unit
)
const
char
*
cdiUnitNamePtr
(
int
cdi_unit
)
{
{
char
*
cdiUnits
[]
=
{
const
char
*
cdiUnits
[]
=
{
/* 0 */
"undefined"
,
/* 0 */
"undefined"
,
/* 1 */
"Pa"
,
/* 1 */
"Pa"
,
/* 2 */
"hPa"
,
/* 2 */
"hPa"
,
...
@@ -102,7 +102,7 @@ char *cdiUnitNamePtr(int cdi_unit)
...
@@ -102,7 +102,7 @@ char *cdiUnitNamePtr(int cdi_unit)
/* 6 */
"m"
,
/* 6 */
"m"
,
};
};
enum
{
numUnits
=
(
int
)
(
sizeof
(
cdiUnits
)
/
sizeof
(
char
*
))
};
enum
{
numUnits
=
(
int
)
(
sizeof
(
cdiUnits
)
/
sizeof
(
char
*
))
};
char
*
name
=
(
cdi_unit
>
0
&&
cdi_unit
<
numUnits
)
?
const
char
*
name
=
(
cdi_unit
>
0
&&
cdi_unit
<
numUnits
)
?
cdiUnits
[
cdi_unit
]
:
NULL
;
cdiUnits
[
cdi_unit
]
:
NULL
;
return
name
;
return
name
;
}
}
...
...
src/extralib.c
View file @
0a63c031
...
@@ -58,7 +58,7 @@ void extDebug(int debug)
...
@@ -58,7 +58,7 @@ void extDebug(int debug)
static
void
extLibInit
()
static
void
extLibInit
()
{
{
char
*
envString
;
char
*
envString
;
char
*
envName
=
"EXT_PRECISION"
;
const
char
*
envName
=
"EXT_PRECISION"
;
envString
=
getenv
(
envName
);
envString
=
getenv
(
envName
);
...
...
src/file.c
View file @
0a63c031
...
@@ -190,7 +190,7 @@ void file_list_new(void)
...
@@ -190,7 +190,7 @@ void file_list_new(void)
{
{
assert
(
_fileList
==
NULL
);
assert
(
_fileList
==
NULL
);
_fileList
=
(
filePtrToIdx
*
)
x
malloc
((
size_t
)
_file_max
*
sizeof
(
filePtrToIdx
));
_fileList
=
(
filePtrToIdx
*
)
malloc
((
size_t
)
_file_max
*
sizeof
(
filePtrToIdx
));
}
}
static
static
...
@@ -1206,8 +1206,8 @@ int fileClose_serial(int fileID)
...
@@ -1206,8 +1206,8 @@ int fileClose_serial(int fileID)
{
{
char
*
name
;
char
*
name
;
int
ret
;
int
ret
;
char
*
fbtname
[]
=
{
"unknown"
,
"standard"
,
"mmap"
};
const
char
*
fbtname
[]
=
{
"unknown"
,
"standard"
,
"mmap"
};
char
*
ftname
[]
=
{
"unknown"
,
"open"
,
"fopen"
};
const
char
*
ftname
[]
=
{
"unknown"
,
"open"
,
"fopen"
};
bfile_t
*
fileptr
=
file_to_pointer
(
fileID
);
bfile_t
*
fileptr
=
file_to_pointer
(
fileID
);
double
rout
=
0
;
double
rout
=
0
;
...
...
src/gaussgrid.c
View file @
0a63c031
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <config.h>
#include <math.h>
#include <math.h>
#include <float.h>
#include <float.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include "dmemory.h"
#include "dmemory.h"
#ifndef M_PI
#ifndef M_PI
...
...
src/gribapi.c
View file @
0a63c031
...
@@ -88,7 +88,7 @@ void gribContainersNew(stream_t * streamptr)
...
@@ -88,7 +88,7 @@ void gribContainersNew(stream_t * streamptr)
streamptr
->
gribContainers
=
(
void
**
)
gribContainers
;
streamptr
->
gribContainers
=
(
void
**
)
gribContainers
;
#else
#else
gribContainer_t
*
gribContainers
gribContainer_t
*
gribContainers
=
(
gribContainer_t
*
)
x
malloc
((
size_t
)
nvars
*
sizeof
(
gribContainer_t
));
=
(
gribContainer_t
*
)
malloc
((
size_t
)
nvars
*
sizeof
(
gribContainer_t
));
for
(
int
varID
=
0
;
varID
<
nvars
;
++
varID
)
for
(
int
varID
=
0
;
varID
<
nvars
;
++
varID
)
{
{
...
...
src/gribapi_utilities.c
View file @
0a63c031
...
@@ -32,9 +32,9 @@ char* gribCopyString(grib_handle* gribHandle, const char* key)
...
@@ -32,9 +32,9 @@ char* gribCopyString(grib_handle* gribHandle, const char* key)
#ifdef HAVE_GRIB_GET_LENGTH
#ifdef HAVE_GRIB_GET_LENGTH
if
(
!
grib_get_length
(
gribHandle
,
key
,
&
length
))
if
(
!
grib_get_length
(
gribHandle
,
key
,
&
length
))
{
{
char
*
result
=
(
char
*
)
x
malloc
(
length
);
char
*
result
=
(
char
*
)
malloc
(
length
);
if
(
!
grib_get_string
(
gribHandle
,
key
,
result
,
&
length
))
if
(
!
grib_get_string
(
gribHandle
,
key
,
result
,
&
length
))
result
=
(
char
*
)
x
realloc
(
result
,
length
);
result
=
(
char
*
)
realloc
(
result
,
length
);
else
else
{
{
...
@@ -48,20 +48,20 @@ char* gribCopyString(grib_handle* gribHandle, const char* key)
...
@@ -48,20 +48,20 @@ char* gribCopyString(grib_handle* gribHandle, const char* key)
* this unlikely in grib_api versions
* this unlikely in grib_api versions
* not providing grib_get_length */
* not providing grib_get_length */
int
rc
;
int
rc
;
result
=
(
char
*
)
x
malloc
(
length
);
result
=
(
char
*
)
malloc
(
length
);
while
((
rc
=
grib_get_string
(
gribHandle
,
key
,
result
,
&
length
))
while
((
rc
=
grib_get_string
(
gribHandle
,
key
,
result
,
&
length
))
==
GRIB_BUFFER_TOO_SMALL
||
rc
==
GRIB_ARRAY_TOO_SMALL
)
==
GRIB_BUFFER_TOO_SMALL
||
rc
==
GRIB_ARRAY_TOO_SMALL
)
{
{
if
(
length
<=
1024UL
*
1024UL
)
if
(
length
<=
1024UL
*
1024UL
)
{
{
length
*=
2
;
length
*=
2
;
result
=
x
realloc
(
result
,
length
);
result
=
realloc
(
result
,
length
);
}
}
else
else
break
;
break
;
}
}
if
(
!
rc
)
if
(
!
rc
)
result
=
x
realloc
(
result
,
length
);
result
=
realloc
(
result
,
length
);
else
else
{
{
free
(
result
);
free
(
result
);
...
@@ -80,7 +80,7 @@ bool gribCheckString(grib_handle* gribHandle, const char* key, const char* expec
...
@@ -80,7 +80,7 @@ bool gribCheckString(grib_handle* gribHandle, const char* key, const char* expec
size_t
length
;
size_t
length
;
if
(
grib_get_length
(
gribHandle
,
key
,
&
length
))
return
false
;
if
(
grib_get_length
(
gribHandle
,
key
,
&
length
))
return
false
;
if
(
length
!=
expectedLength
)
return
false
;
if
(
length
!=
expectedLength
)
return
false
;
char
*
value
=
(
char
*
)
x
malloc
(
length
);
char
*
value
=
(
char
*
)
malloc
(
length
);
if
(
grib_get_string
(
gribHandle
,
key
,
value
,
&
length
))
return
false
;
if
(
grib_get_string
(
gribHandle
,
key
,
value
,
&
length
))
return
false
;
int
rc
=
!
strcmp
(
value
,
expectedValue
);
int
rc
=
!
strcmp
(
value
,
expectedValue
);
free
(
value
);
free
(
value
);
...
@@ -259,7 +259,7 @@ static int addToDate(struct tm* me, long long amount, long unit)
...
@@ -259,7 +259,7 @@ static int addToDate(struct tm* me, long long amount, long unit)
static
char
*
makeDateString
(
struct
tm
*
me
)
static
char
*
makeDateString
(
struct
tm
*
me
)
{
{
char
*
result
char
*
result
=
(
char
*
)
x
malloc
(
4
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
4
+
1
);
=
(
char
*
)
malloc
(
4
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
1
+
2
+
4
+
1
);
sprintf
(
result
,
"%04d-%02d-%02dT%02d:%02d:%02d.000"
,
me
->
tm_year
+
1900
,
me
->
tm_mon
+
1
,
me
->
tm_mday
,
me
->
tm_hour
,
me
->
tm_min
,
me
->
tm_sec
);
sprintf
(
result
,
"%04d-%02d-%02dT%02d:%02d:%02d.000"
,
me
->
tm_year
+
1900
,
me
->
tm_mon
+
1
,
me
->
tm_mday
,
me
->
tm_hour
,
me
->
tm_min
,
me
->
tm_sec
);
return
result
;
return
result
;
}
}
...
...
src/grid.c
View file @
0a63c031
...
@@ -169,7 +169,7 @@ void grid_free(grid_t *gridptr)
...
@@ -169,7 +169,7 @@ void grid_free(grid_t *gridptr)
static
grid_t
*
static
grid_t
*
gridNewEntry
(
cdiResH
resH
)
gridNewEntry
(
cdiResH
resH
)
{
{
grid_t
*
gridptr
=
(
grid_t
*
)
x
malloc
(
sizeof
(
grid_t
));
grid_t
*
gridptr
=
(
grid_t
*
)
malloc
(
sizeof
(
grid_t
));
grid_init
(
gridptr
);
grid_init
(
gridptr
);
if
(
resH
==
CDI_UNDEFID
)
if
(
resH
==
CDI_UNDEFID
)
gridptr
->
self
=
reshPut
(
gridptr
,
&
gridOps
);
gridptr
->
self
=
reshPut
(
gridptr
,
&
gridOps
);
...
@@ -233,7 +233,7 @@ void gridGenXvals(int xsize, double xfirst, double xlast, double xinc, double *x
...
@@ -233,7 +233,7 @@ void gridGenXvals(int xsize, double xfirst, double xlast, double xinc, double *x
static
static
void
calc_gaussgrid
(
double
*
yvals
,
int
ysize
,
double
yfirst
,
double
ylast
)
void
calc_gaussgrid
(
double
*
yvals
,
int
ysize
,
double
yfirst
,
double
ylast
)
{
{
double
*
restrict
yw
=
(
double
*
)
x
malloc
((
size_t
)
ysize
*
sizeof
(
double
));
double
*
restrict
yw
=
(
double
*
)
malloc
((
size_t
)
ysize
*
sizeof
(
double
));
gaussaw
(
yvals
,
yw
,
(
size_t
)
ysize
);
gaussaw
(
yvals
,
yw
,
(
size_t
)
ysize
);
free
(
yw
);
free
(
yw
);
for
(
int
i
=
0
;
i
<
ysize
;
i
++
)
for
(
int
i
=
0
;
i
<
ysize
;
i
++
)
...
@@ -273,7 +273,7 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
...
@@ -273,7 +273,7 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
/* printf("%g %g %g %g %g %d\n", ylast, yfirst, ylast-yfirst,yinc, 180/yinc, ny); */
/* printf("%g %g %g %g %g %d\n", ylast, yfirst, ylast-yfirst,yinc, 180/yinc, ny); */
if
(
ny
>
ysize
&&
ny
<
4096
)
if
(
ny
>
ysize
&&
ny
<
4096
)
{
{
ytmp
=
(
double
*
)
x
malloc
((
size_t
)
ny
*
sizeof
(
double
));
ytmp
=
(
double
*
)
malloc
((
size_t
)
ny
*
sizeof
(
double
));
calc_gaussgrid
(
ytmp
,
ny
,
yfirst
,
ylast
);
calc_gaussgrid
(
ytmp
,
ny
,
yfirst
,
ylast
);
int
i
;
int
i
;
for
(
i
=
0
;
i
<
(
ny
-
ysize
);
i
++
)
for
(
i
=
0
;
i
<
(
ny
-
ysize
);
i
++
)
...
@@ -1213,7 +1213,7 @@ void gridDefRowlon(int gridID, int nrowlon, const int rowlon[])
...
@@ -1213,7 +1213,7 @@ void gridDefRowlon(int gridID, int nrowlon, const int rowlon[])
{
{
grid_t
*
gridptr
=
gridID2Ptr
(
gridID
);
grid_t
*
gridptr
=
gridID2Ptr
(
gridID
);
gridptr
->
rowlon
=
(
int
*
)
x
malloc
((
size_t
)
nrowlon
*
sizeof
(
int
));
gridptr
->
rowlon
=
(
int
*
)
malloc
((
size_t
)
nrowlon
*
sizeof
(
int
));
gridptr
->
nrowlon
=
nrowlon
;
gridptr
->
nrowlon
=
nrowlon
;
memcpy
(
gridptr
->
rowlon
,
rowlon
,
(
size_t
)
nrowlon
*
sizeof
(
int
));
memcpy
(
gridptr
->
rowlon
,
rowlon
,
(
size_t
)
nrowlon
*
sizeof
(
int
));
reshSetStatus
(
gridID
,
&
gridOps
,
RESH_DESYNC_IN_USE
);
reshSetStatus
(
gridID
,
&
gridOps
,
RESH_DESYNC_IN_USE
);
...
@@ -1278,7 +1278,7 @@ void gridDefMask(int gridID, const int *mask)
...
@@ -1278,7 +1278,7 @@ void gridDefMask(int gridID, const int *mask)
else
else
{
{
if
(
gridptr
->
mask
==
NULL
)
if
(
gridptr
->
mask
==
NULL
)
gridptr
->
mask
=
(
mask_t
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
gridptr
->
mask
=
(
mask_t
*
)
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
else
if
(
CDI_Debug
)
else
if
(
CDI_Debug
)
Warning
(
"grid mask already defined!"
);
Warning
(
"grid mask already defined!"
);
...
@@ -1317,7 +1317,7 @@ void gridDefMaskGME(int gridID, const int *mask)
...
@@ -1317,7 +1317,7 @@ void gridDefMaskGME(int gridID, const int *mask)
Error
(
"Size undefined for gridID = %d"
,
gridID
);
Error
(
"Size undefined for gridID = %d"
,
gridID
);
if
(
gridptr
->
mask_gme
==
NULL
)
if
(
gridptr
->
mask_gme
==
NULL
)
gridptr
->
mask_gme
=
(
mask_t
*
)
x
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
gridptr
->
mask_gme
=
(
mask_t
*
)
malloc
((
size_t
)
size
*
sizeof
(
mask_t
));
else
if
(
CDI_Debug
)
else
if
(
CDI_Debug
)
Warning
(
"mask already defined!"
);
Warning
(
"mask already defined!"
);
...
@@ -1401,7 +1401,7 @@ void gridDefXvals(int gridID, const double *xvals)
...
@@ -1401,7 +1401,7 @@ void gridDefXvals(int gridID, const double *xvals)
if
(
gridptr
->
xvals
&&
CDI_Debug
)
if
(
gridptr
->
xvals
&&
CDI_Debug
)
Warning
(
"values already defined!"
);
Warning
(
"values already defined!"
);
gridptr
->
xvals
=
(
double
*
)
x
realloc
(
gridptr
->
xvals
,
gridptr
->
xvals
=
(
double
*
)
realloc
(
gridptr
->
xvals
,
(
size_t
)
size
*
sizeof
(
double
));
(
size_t
)
size
*
sizeof
(
double
));
memcpy
(
gridptr
->
xvals
,
xvals
,
(
size_t
)
size
*
sizeof
(
double
));
memcpy
(
gridptr
->
xvals
,
xvals
,
(
size_t
)
size
*
sizeof
(
double
));
reshSetStatus
(
gridID
,
&
gridOps
,
RESH_DESYNC_IN_USE
);
reshSetStatus
(
gridID
,
&
gridOps
,
RESH_DESYNC_IN_USE
);
...
@@ -1476,7 +1476,7 @@ void gridDefYvals(int gridID, const double *yvals)
...
@@ -1476,7 +1476,7 @@ void gridDefYvals(int gridID, const double *yvals)
if
(
gridptr
->
yvals
&&
CDI_Debug
)
if
(
gridptr
->
yvals
&&
CDI_Debug
)
Warning
(
"Values already defined!"
);
Warning
(
"Values already defined!"
);
gridptr
->
yvals
=
(
double
*
)
x
realloc
(
gridptr
->
yvals
,
(
size_t
)
size
*
sizeof
(
double
));
gridptr
->
yvals
=
(
double
*
)
realloc
(
gridptr
->
yvals
,
(
size_t
)
size
*
sizeof
(
double
));
memcpy
(
gridptr
->
yvals
,
yvals
,
(
size_t
)
size
*
sizeof
(
double
));
memcpy
(
gridptr
->
yvals
,
yvals
,
(
size_t
)
size
*
sizeof
(
double
));
reshSetStatus
(
gridID
,
&
gridOps
,
RESH_DESYNC_IN_USE
);
reshSetStatus
(
gridID
,
&
gridOps
,
RESH_DESYNC_IN_USE
);
}
}
...
@@ -1997,7 +1997,7 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
...
@@ -1997,7 +1997,7 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
if
(
!
differ
&&
xsize
==
gridInqXvals
(
gridID
,
NULL
)
)
if
(
!
differ
&&
xsize
==
gridInqXvals
(
gridID
,
NULL
)
)
{
{
double
*
xvals
=
(
double
*
)
x
malloc
((
size_t
)
xsize
*
sizeof
(
double
));
double
*
xvals
=
(
double
*
)
malloc
((
size_t
)
xsize
*
sizeof
(
double
));
gridInqXvals
(
gridID
,
xvals
);
gridInqXvals
(
gridID
,
xvals
);
...
@@ -2013,7 +2013,7 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
...
@@ -2013,7 +2013,7 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
if
(
!
differ
&&
ysize
==
gridInqYvals
(
gridID
,
NULL
)
)
if
(
!
differ
&&
ysize
==
gridInqYvals
(
gridID
,
NULL
)
)
{
{
double
*
yvals
=
(
double
*
)
x
malloc
((
size_t
)
ysize
*
sizeof
(
double
));
double
*
yvals
=
(
double
*
)
malloc
((
size_t
)
ysize
*
sizeof
(
double
));
gridInqYvals
(
gridID
,
yvals
);
gridInqYvals
(
gridID
,
yvals
);
...
@@ -2430,7 +2430,7 @@ int gridGenerate(const grid_t *grid)
...
@@ -2430,7 +2430,7 @@ int gridGenerate(const grid_t *grid)
else
if
(
grid
->
xdef
==
2
)
else
if
(
grid
->
xdef
==
2
)
{
{
double
*
xvals
double
*
xvals
=
(
double
*
)
x
malloc
((
size_t
)
grid
->
xsize
*
sizeof
(
double
));
=
(
double
*
)
malloc
((
size_t
)
grid
->
xsize
*
sizeof
(
double
));
gridGenXvals
(
grid
->
xsize
,
grid
->
xfirst
,
grid
->
xlast
,
grid
->
xinc
,
xvals
);
gridGenXvals
(
grid
->
xsize
,
grid
->
xfirst
,
grid
->
xlast
,
grid
->
xinc
,
xvals
);
gridDefXvals
(
gridID
,
xvals
);
gridDefXvals
(
gridID
,
xvals
);
free
(
xvals
);
free
(
xvals
);
...
@@ -2448,7 +2448,7 @@ int gridGenerate(const grid_t *grid)
...
@@ -2448,7 +2448,7 @@ int gridGenerate(const grid_t *grid)
else
if
(
grid
->
ydef
==
2
)
else
if
(
grid
->
ydef
==
2
)
{
{
double
*
yvals
double
*
yvals
=
(
double
*
)
x
malloc
((
size_t
)
grid
->
ysize
*
sizeof
(
double
));
=
(
double
*
)
malloc
((
size_t
)
grid
->
ysize
*
sizeof
(
double
));
gridGenYvals
(
grid
->
type
,
grid
->
ysize
,
grid
->
yfirst
,
grid
->
ylast
,
grid
->
yinc
,
yvals
);
gridGenYvals
(
grid
->
type
,
grid
->
ysize
,
grid
->
yfirst
,
grid
->
ylast
,
grid
->
yinc
,
yvals
);
gridDefYvals
(
gridID
,
yvals
);
gridDefYvals
(
gridID
,
yvals
);
free
(
yvals
);
free
(
yvals
);
...
@@ -2533,7 +2533,7 @@ int gridGenerate(const grid_t *grid)
...
@@ -2533,7 +2533,7 @@ int gridGenerate(const grid_t *grid)
else
if
(
grid
->
ydef
==
2
)
else
if
(
grid
->
ydef
==
2
)
{
{
double
*
yvals
double
*
yvals
=
(
double
*
)
x
malloc
((
size_t
)
grid
->
ysize
*
sizeof
(
double
));
=
(
double
*
)
malloc
((
size_t
)
grid
->
ysize
*
sizeof
(
double
));
gridGenYvals
(
grid
->
type
,
grid
->
ysize
,
grid
->
yfirst
,
grid
->
ylast
,
grid
->
yinc
,
yvals
);
gridGenYvals
(
grid
->
type
,
grid
->
ysize
,
grid
->
yfirst
,
grid
->
ylast
,
grid
->
yinc
,
yvals
);
gridDefYvals
(
gridID
,
yvals
);
gridDefYvals
(
gridID
,
yvals
);
free
(
yvals
);
free
(
yvals
);
...
@@ -2642,7 +2642,7 @@ int gridDuplicate(int gridID)
...
@@ -2642,7 +2642,7 @@ int gridDuplicate(int gridID)
int
irregular
=
gridtype
==
GRID_CURVILINEAR
||
gridtype
==
GRID_UNSTRUCTURED
;
int
irregular
=
gridtype
==
GRID_CURVILINEAR
||
gridtype
==
GRID_UNSTRUCTURED
;
if
(
nrowlon
)
if
(
nrowlon
)
{
{
gridptrnew
->
rowlon
=
(
int
*
)
x
malloc
(
nrowlon
*
sizeof
(
int
));
gridptrnew
->
rowlon
=
(
int
*
)
malloc
(
nrowlon
*
sizeof
(
int
));
memcpy
(
gridptrnew
->
rowlon
,
gridptr
->
rowlon
,
nrowlon
*
sizeof
(
int
));
memcpy
(
gridptrnew
->
rowlon
,
gridptr
->
rowlon
,
nrowlon
*
sizeof
(
int
));
}
}
...
@@ -2650,7 +2650,7 @@ int gridDuplicate(int gridID)
...
@@ -2650,7 +2650,7 @@ int gridDuplicate(int gridID)
{
{
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
xsize
);
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
xsize
);
gridptrnew
->
xvals
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptrnew
->
xvals
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
xvals
,
gridptr
->
xvals
,
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
xvals
,
gridptr
->
xvals
,
size
*
sizeof
(
double
));
}
}
...
@@ -2658,7 +2658,7 @@ int gridDuplicate(int gridID)
...
@@ -2658,7 +2658,7 @@ int gridDuplicate(int gridID)
{
{
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
ysize
);
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
ysize
);
gridptrnew
->
yvals
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptrnew
->
yvals
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
yvals
,
gridptr
->
yvals
,
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
yvals
,
gridptr
->
yvals
,
size
*
sizeof
(
double
));
}
}
...
@@ -2667,7 +2667,7 @@ int gridDuplicate(int gridID)
...
@@ -2667,7 +2667,7 @@ int gridDuplicate(int gridID)
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
xsize
)
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
xsize
)
*
(
size_t
)
gridptr
->
nvertex
;
*
(
size_t
)
gridptr
->
nvertex
;
gridptrnew
->
xbounds
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptrnew
->
xbounds
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
xbounds
,
gridptr
->
xbounds
,
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
xbounds
,
gridptr
->
xbounds
,
size
*
sizeof
(
double
));
}
}
...
@@ -2676,7 +2676,7 @@ int gridDuplicate(int gridID)
...
@@ -2676,7 +2676,7 @@ int gridDuplicate(int gridID)
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
ysize
)
size_t
size
=
(
size_t
)(
irregular
?
gridsize
:
gridptr
->
ysize
)
*
(
size_t
)
gridptr
->
nvertex
;
*
(
size_t
)
gridptr
->
nvertex
;
gridptrnew
->
ybounds
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptrnew
->
ybounds
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
ybounds
,
gridptr
->
ybounds
,
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
ybounds
,
gridptr
->
ybounds
,
size
*
sizeof
(
double
));
}
}
...
@@ -2684,7 +2684,7 @@ int gridDuplicate(int gridID)
...
@@ -2684,7 +2684,7 @@ int gridDuplicate(int gridID)
{
{
size_t
size
=
(
size_t
)
gridsize
;
size_t
size
=
(
size_t
)
gridsize
;
gridptrnew
->
area
=
(
double
*
)
x
malloc
(
size
*
sizeof
(
double
));
gridptrnew
->
area
=
(
double
*
)
malloc
(
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
area
,
gridptr
->
area
,
size
*
sizeof
(
double
));
memcpy
(
gridptrnew
->
area
,
gridptr
->
area
,
size
*
sizeof
(
double
));
}
}
...
@@ -2692,7 +2692,7 @@ int gridDuplicate(int gridID)
...
@@ -2692,7 +2692,7 @@ int gridDuplicate(int gridID)
{
{
size_t
size
=
(
size_t
)
gridsize
;
size_t
size
=
(
size_t
)
gridsize
;
gridptrnew
->
mask
=
(
mask_t
*
)
x
malloc
(
size
*
sizeof
(
mask_t
));
gridptrnew
->
mask
=
(
mask_t
*
)
malloc
(
size
*
sizeof
(
mask_t
));
memcpy
(
gridptrnew
->
mask
,
gridptr
->
mask
,
size
*
sizeof
(
mask_t
));
memcpy
(
gridptrnew
->
mask
,
gridptr
->
mask
,
size
*
sizeof
(
mask_t
));
}
}
...
@@ -2700,7 +2700,7 @@ int gridDuplicate(int gridID)
...
@@ -2700,7 +2700,7 @@ int gridDuplicate(int gridID)
{
{
size_t
size
=
(
size_t
)
gridsize
;
size_t
size
=
(
size_t
)
gridsize
;
gridptrnew
->
mask_gme
=
(
mask_t
*
)
x
malloc
(
size
*
sizeof
(
mask_t
));
gridptrnew
->
mask_gme
=
(
mask_t
*
)
malloc
(
size
*
sizeof
(
mask_t
));
memcpy
(
gridptrnew
->
mask_gme
,
gridptr
->
mask_gme
,
size
*
sizeof
(
mask_t
));
memcpy
(
gridptrnew
->
mask_gme
,
gridptr
->
mask_gme
,
size
*
sizeof
(
mask_t
));
}
}
...
@@ -2752,19 +2752,19 @@ void gridCompress(int gridID)
...
@@ -2752,19 +2752,19 @@ void gridCompress(int gridID)
gridptr
->
ysize
=
(
int
)
gridsize
;
gridptr
->
ysize
=
(
int
)
gridsize
;
if
(
gridptr
->
xvals
)
if
(
gridptr
->
xvals
)
gridptr
->
xvals
=
(
double
*
)
x
realloc
(
gridptr
->
xvals
,
gridsize
*
sizeof
(
double
));
gridptr
->
xvals
=
(
double
*
)
realloc
(
gridptr
->
xvals
,
gridsize
*
sizeof
(
double
));
if
(
gridptr
->
yvals
)
if
(
gridptr
->
yvals
)
gridptr
->
yvals
=
(
double
*
)
x
realloc
(
gridptr
->
yvals
,
gridsize
*
sizeof
(
double
));
gridptr
->
yvals
=
(
double
*
)
realloc
(
gridptr
->
yvals
,
gridsize
*
sizeof
(
double
));
if
(
gridptr
->
area
)
if
(
gridptr
->
area
)
gridptr
->
area
=
(
double
*
)
x
realloc
(
gridptr
->
area
,
gridsize
*
sizeof
(
double
));
gridptr
->
area
=
(
double
*
)
realloc
(
gridptr
->
area
,
gridsize
*
sizeof
(
double
));
if
(
gridptr
->
xbounds
)
if
(
gridptr
->
xbounds
)
gridptr
->
xbounds
=
(
double
*
)
x
realloc
(
gridptr
->
xbounds
,
nv
*
gridsize
*
sizeof
(
double
));
gridptr
->
xbounds
=
(
double
*
)
realloc
(
gridptr
->
xbounds
,
nv
*
gridsize
*
sizeof
(
double
));
if
(
gridptr
->
ybounds
)
if
(
gridptr
->
ybounds
)
gridptr
->
ybounds
=
(
double
*
)
x
realloc
(
gridptr
->
ybounds
,
nv
*
gridsize
*
sizeof
(
double
));
gridptr
->
ybounds
=
(
double
*
)
realloc
(
gridptr
->
ybounds
,
nv
*
gridsize
*
sizeof
(
double
));
free
(
gridptr
->
mask_gme
);
free
(
gridptr
->
mask_gme
);