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
cdo
Commits
deff029d
Commit
deff029d
authored
Apr 06, 2014
by
Uwe Schulzweida
Browse files
cast result of malloc
parent
bc590a12
Changes
201
Hide whitespace changes
Inline
Side-by-side
src/Fldstat.c
View file @
deff029d
...
...
@@ -165,10 +165,10 @@ void *Fldstat(void *argument)
field_init
(
&
field
);
lim
=
vlistGridsizeMax
(
vlistID1
);
field
.
ptr
=
malloc
(
lim
*
sizeof
(
double
));
field
.
ptr
=
(
double
*
)
malloc
(
lim
*
sizeof
(
double
));
field
.
weight
=
NULL
;
if
(
needWeights
)
field
.
weight
=
malloc
(
lim
*
sizeof
(
double
));
field
.
weight
=
(
double
*
)
malloc
(
lim
*
sizeof
(
double
));
tsID
=
0
;
while
(
(
nrecs
=
streamInqTimestep
(
streamID1
,
tsID
))
)
...
...
src/Fldstat2.c
View file @
deff029d
...
...
@@ -156,11 +156,11 @@ void *Fldstat2(void *argument)
gridsize
=
vlistGridsizeMax
(
vlistID1
);
array1
=
malloc
(
gridsize
*
sizeof
(
double
));
array2
=
malloc
(
gridsize
*
sizeof
(
double
));
array1
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
array2
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
weight
=
NULL
;
if
(
needWeights
)
weight
=
malloc
(
gridsize
*
sizeof
(
double
));
weight
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
tsID
=
0
;
while
(
(
nrecs
=
streamInqTimestep
(
streamID1
,
tsID
))
)
...
...
src/Fourier.c
View file @
deff029d
...
...
@@ -98,7 +98,7 @@ void *Fourier(void *argument)
streamInqRecord
(
streamID1
,
&
varID
,
&
levelID
);
gridID
=
vlistInqVarGrid
(
vlistID1
,
varID
);
gridsize
=
gridInqSize
(
gridID
);
vars
[
tsID
][
varID
][
levelID
].
ptr
=
malloc
(
2
*
gridsize
*
sizeof
(
double
));
vars
[
tsID
][
varID
][
levelID
].
ptr
=
(
double
*
)
malloc
(
2
*
gridsize
*
sizeof
(
double
));
streamReadRecord
(
streamID1
,
vars
[
tsID
][
varID
][
levelID
].
ptr
,
&
nmiss
);
vars
[
tsID
][
varID
][
levelID
].
nmiss
=
nmiss
;
}
...
...
@@ -110,15 +110,15 @@ void *Fourier(void *argument)
for
(
bit
=
nts
;
!
(
bit
&
1
);
bit
>>=
1
);
mem
=
malloc
(
ompNumThreads
*
sizeof
(
memory_t
));
mem
=
(
memory_t
*
)
malloc
(
ompNumThreads
*
sizeof
(
memory_t
));
for
(
i
=
0
;
i
<
ompNumThreads
;
i
++
)
{
mem
[
i
].
real
=
malloc
(
nts
*
sizeof
(
double
));
mem
[
i
].
imag
=
malloc
(
nts
*
sizeof
(
double
));
mem
[
i
].
real
=
(
double
*
)
malloc
(
nts
*
sizeof
(
double
));
mem
[
i
].
imag
=
(
double
*
)
malloc
(
nts
*
sizeof
(
double
));
if
(
bit
!=
1
)
{
mem
[
i
].
work_r
=
malloc
(
nts
*
sizeof
(
double
));
mem
[
i
].
work_i
=
malloc
(
nts
*
sizeof
(
double
));
mem
[
i
].
work_r
=
(
double
*
)
malloc
(
nts
*
sizeof
(
double
));
mem
[
i
].
work_i
=
(
double
*
)
malloc
(
nts
*
sizeof
(
double
));
}
}
...
...
src/Gather.c
View file @
deff029d
...
...
@@ -99,11 +99,11 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid)
if
(
gridtype
==
GRID_GENERIC
&&
gridInqXsize
(
gridID
)
==
0
&&
gridInqYsize
(
gridID
)
==
0
)
return
(
gridID2
);
xsize
=
malloc
(
nfiles
*
sizeof
(
int
));
ysize
=
malloc
(
nfiles
*
sizeof
(
int
));
xyinfo
=
malloc
(
nfiles
*
sizeof
(
xyinfo_t
));
xvals
=
malloc
(
nfiles
*
sizeof
(
double
));
yvals
=
malloc
(
nfiles
*
sizeof
(
double
));
xsize
=
(
int
*
)
malloc
(
nfiles
*
sizeof
(
int
));
ysize
=
(
int
*
)
malloc
(
nfiles
*
sizeof
(
int
));
xyinfo
=
(
xyinfo_t
*
)
malloc
(
nfiles
*
sizeof
(
xyinfo_t
));
xvals
=
(
double
*
)
malloc
(
nfiles
*
sizeof
(
double
));
yvals
=
(
double
*
)
malloc
(
nfiles
*
sizeof
(
double
));
for
(
fileID
=
0
;
fileID
<
nfiles
;
fileID
++
)
{
...
...
@@ -121,8 +121,8 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid)
if ( xsize != gridInqXsize(gridID) ) cdoAbort("xsize differ!");
if ( ysize != gridInqYsize(gridID) ) cdoAbort("ysize differ!");
*/
xvals
[
fileID
]
=
malloc
(
xsize
[
fileID
]
*
sizeof
(
double
));
yvals
[
fileID
]
=
malloc
(
ysize
[
fileID
]
*
sizeof
(
double
));
xvals
[
fileID
]
=
(
double
*
)
malloc
(
xsize
[
fileID
]
*
sizeof
(
double
));
yvals
[
fileID
]
=
(
double
*
)
malloc
(
ysize
[
fileID
]
*
sizeof
(
double
));
gridInqXvals
(
gridID
,
xvals
[
fileID
]);
gridInqYvals
(
gridID
,
yvals
[
fileID
]);
...
...
@@ -172,11 +172,11 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid)
for
(
j
=
0
;
j
<
ny
;
++
j
)
ysize2
+=
ysize
[
xyinfo
[
j
*
nx
].
id
];
if
(
cdoVerbose
)
cdoPrint
(
"xsize2 %d ysize2 %d"
,
xsize2
,
ysize2
);
xvals2
=
malloc
(
xsize2
*
sizeof
(
double
));
yvals2
=
malloc
(
ysize2
*
sizeof
(
double
));
xvals2
=
(
double
*
)
malloc
(
xsize2
*
sizeof
(
double
));
yvals2
=
(
double
*
)
malloc
(
ysize2
*
sizeof
(
double
));
xoff
=
malloc
((
nx
+
1
)
*
sizeof
(
int
));
yoff
=
malloc
((
ny
+
1
)
*
sizeof
(
int
));
xoff
=
(
int
*
)
malloc
((
nx
+
1
)
*
sizeof
(
int
));
yoff
=
(
int
*
)
malloc
((
ny
+
1
)
*
sizeof
(
int
));
xoff
[
0
]
=
0
;
for
(
i
=
0
;
i
<
nx
;
++
i
)
...
...
@@ -297,7 +297,7 @@ void *Gather(void *argument)
if
(
!
userFileOverwrite
(
ofilename
)
)
cdoAbort
(
"Outputfile %s already exists!"
,
ofilename
);
ef
=
malloc
(
nfiles
*
sizeof
(
ens_file_t
));
ef
=
(
ens_file_t
*
)
malloc
(
nfiles
*
sizeof
(
ens_file_t
));
for
(
fileID
=
0
;
fileID
<
nfiles
;
fileID
++
)
{
...
...
@@ -310,7 +310,7 @@ void *Gather(void *argument)
}
nvars
=
vlistNvars
(
ef
[
0
].
vlistID
);
vars
=
malloc
(
nvars
*
sizeof
(
int
));
vars
=
(
int
*
)
malloc
(
nvars
*
sizeof
(
int
));
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
vars
[
varID
]
=
FALSE
;
/* check that the contents is always the same */
...
...
@@ -332,13 +332,13 @@ void *Gather(void *argument)
gridsize
=
gridsizemax
;
for
(
fileID
=
0
;
fileID
<
nfiles
;
fileID
++
)
ef
[
fileID
].
array
=
malloc
(
gridsizemax
*
sizeof
(
double
));
ef
[
fileID
].
array
=
(
double
*
)
malloc
(
gridsizemax
*
sizeof
(
double
));
ngrids
=
vlistNgrids
(
ef
[
0
].
vlistID
);
gridIDs
=
malloc
(
ngrids
*
sizeof
(
int
));
gridindex
=
malloc
(
nfiles
*
sizeof
(
int
*
));
gridIDs
=
(
int
*
)
malloc
(
ngrids
*
sizeof
(
int
));
gridindex
=
(
int
**
)
malloc
(
nfiles
*
sizeof
(
int
*
));
for
(
fileID
=
0
;
fileID
<
nfiles
;
fileID
++
)
gridindex
[
fileID
]
=
malloc
(
gridsizemax
*
sizeof
(
int
));
gridindex
[
fileID
]
=
(
int
*
)
malloc
(
gridsizemax
*
sizeof
(
int
));
int
ginit
=
FALSE
;
for
(
i
=
0
;
i
<
ngrids
;
++
i
)
...
...
@@ -387,7 +387,7 @@ void *Gather(void *argument)
streamDefVlist
(
streamID2
,
vlistID2
);
array2
=
malloc
(
gridsize2
*
sizeof
(
double
));
array2
=
(
double
*
)
malloc
(
gridsize2
*
sizeof
(
double
));
tsID
=
0
;
do
...
...
src/Gengrid.c
View file @
deff029d
...
...
@@ -62,9 +62,9 @@ void *Gengrid(void *argument)
xsize
=
gridInqXsize
(
gridID1
);
ysize
=
gridInqYsize
(
gridID1
);
array1
=
malloc
(
gridsize
*
sizeof
(
double
));
array2
=
malloc
(
gridsize
*
sizeof
(
double
));
array3
=
malloc
(
gridsize
*
sizeof
(
double
));
array1
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
array2
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
array3
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
tsID
=
0
;
nrecs
=
streamInqTimestep
(
streamID1
,
tsID
);
...
...
src/Gradsdes.c
View file @
deff029d
...
...
@@ -435,8 +435,8 @@ void ctl_xydef(FILE *gdp, int gridID, int *yrev)
xsize
,
ysize
,
originLat
,
originLon
,
lat1
,
lat2
,
lonParY
,
xincm
,
yincm
);
gridID
=
gridToCurvilinear
(
gridID
,
0
);
xvals
=
malloc
(
xsize
*
ysize
*
sizeof
(
double
));
yvals
=
malloc
(
xsize
*
ysize
*
sizeof
(
double
));
xvals
=
(
double
*
)
malloc
(
xsize
*
ysize
*
sizeof
(
double
));
yvals
=
(
double
*
)
malloc
(
xsize
*
ysize
*
sizeof
(
double
));
gridInqXvals
(
gridID
,
xvals
);
gridInqYvals
(
gridID
,
yvals
);
for
(
i
=
0
;
i
<
xsize
*
ysize
;
++
i
)
...
...
@@ -477,7 +477,7 @@ void ctl_xydef(FILE *gdp, int gridID, int *yrev)
xinc
=
gridInqXinc
(
gridID
);
if
(
IS_EQUAL
(
xinc
,
0
)
&&
gridInqXvals
(
gridID
,
NULL
)
)
{
xvals
=
malloc
(
xsize
*
sizeof
(
double
));
xvals
=
(
double
*
)
malloc
(
xsize
*
sizeof
(
double
));
gridInqXvals
(
gridID
,
xvals
);
fprintf
(
gdp
,
"XDEF %d LEVELS "
,
xsize
);
j
=
0
;
...
...
@@ -513,7 +513,7 @@ void ctl_xydef(FILE *gdp, int gridID, int *yrev)
if
(
IS_EQUAL
(
yinc
,
0
)
&&
gridInqYvals
(
gridID
,
NULL
)
)
{
yvals
=
malloc
(
ysize
*
sizeof
(
double
));
yvals
=
(
double
*
)
malloc
(
ysize
*
sizeof
(
double
));
gridInqYvals
(
gridID
,
yvals
);
fprintf
(
gdp
,
"YDEF %d LEVELS "
,
ysize
);
j
=
0
;
...
...
@@ -589,7 +589,7 @@ void ctl_zdef(FILE *gdp, int vlistID, int *zrev)
}
}
levels
=
malloc
(
nlevmax
*
sizeof
(
double
));
levels
=
(
double
*
)
malloc
(
nlevmax
*
sizeof
(
double
));
zaxisInqLevels
(
zaxisIDmax
,
levels
);
if
(
zaxisInqType
(
zaxisIDmax
)
==
ZAXIS_PRESSURE
)
lplev
=
TRUE
;
level0
=
levels
[
0
];
...
...
@@ -910,7 +910,7 @@ void write_map_grib1(const char *ctlfile, int map_version, int nrecords, int *in
if
(
map_version
==
1
)
{
int
*
intnumbuf
;
intnumbuf
=
malloc
(
indx
.
intnum
*
sizeof
(
int
));
intnumbuf
=
(
int
*
)
malloc
(
indx
.
intnum
*
sizeof
(
int
));
for
(
i
=
0
;
i
<
nrecords
;
i
++
)
{
intnumbuf
[
i
*
3
+
0
]
=
(
int
)
bignum
[
i
*
2
];
...
...
@@ -1063,8 +1063,8 @@ void *Gradsdes(void *argument)
cdoAbort
(
"No Lon/Lat, Gaussian or Lambert grid found (%s data unsupported)!"
,
gridNamePtr
(
gridtype
));
/* select all variables with used gridID */
vars
=
malloc
(
nvars
*
sizeof
(
int
));
recoffset
=
malloc
(
nvars
*
sizeof
(
int
));
vars
=
(
int
*
)
malloc
(
nvars
*
sizeof
(
int
));
recoffset
=
(
int
*
)
malloc
(
nvars
*
sizeof
(
int
));
nvarsout
=
0
;
nrecsout
=
0
;
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
...
...
@@ -1183,7 +1183,7 @@ void *Gradsdes(void *argument)
}
gridsize
=
vlistGridsizeMax
(
vlistID
);
array
=
malloc
(
gridsize
*
sizeof
(
double
));
array
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
}
else
if
(
filetype
==
FILETYPE_NC
)
{
...
...
src/Gridboxstat.c
View file @
deff029d
...
...
@@ -103,19 +103,19 @@ int genBoxGrid(int gridID1, int xinc, int yinc)
if
(
gridInqXbounds
(
gridID1
,
NULL
)
&&
gridInqYbounds
(
gridID1
,
NULL
)
)
gridHasBounds
=
TRUE
;
xvals1
=
malloc
(
nlon1
*
sizeof
(
double
));
yvals1
=
malloc
(
nlat1
*
sizeof
(
double
));
xvals2
=
malloc
(
nlon2
*
sizeof
(
double
));
yvals2
=
malloc
(
nlat2
*
sizeof
(
double
));
xvals1
=
(
double
*
)
malloc
(
nlon1
*
sizeof
(
double
));
yvals1
=
(
double
*
)
malloc
(
nlat1
*
sizeof
(
double
));
xvals2
=
(
double
*
)
malloc
(
nlon2
*
sizeof
(
double
));
yvals2
=
(
double
*
)
malloc
(
nlat2
*
sizeof
(
double
));
gridInqXvals
(
gridID1
,
xvals1
);
gridInqYvals
(
gridID1
,
yvals1
);
if
(
gridHasBounds
)
{
grid1_corner_lon
=
malloc
(
2
*
nlon1
*
sizeof
(
double
));
grid1_corner_lat
=
malloc
(
2
*
nlat1
*
sizeof
(
double
));
grid2_corner_lon
=
malloc
(
2
*
nlon2
*
sizeof
(
double
));
grid2_corner_lat
=
malloc
(
2
*
nlat2
*
sizeof
(
double
));
grid1_corner_lon
=
(
double
*
)
malloc
(
2
*
nlon1
*
sizeof
(
double
));
grid1_corner_lat
=
(
double
*
)
malloc
(
2
*
nlat1
*
sizeof
(
double
));
grid2_corner_lon
=
(
double
*
)
malloc
(
2
*
nlon2
*
sizeof
(
double
));
grid2_corner_lat
=
(
double
*
)
malloc
(
2
*
nlat2
*
sizeof
(
double
));
gridInqXbounds
(
gridID1
,
grid1_corner_lon
);
gridInqYbounds
(
gridID1
,
grid1_corner_lat
);
}
...
...
@@ -177,10 +177,10 @@ int genBoxGrid(int gridID1, int xinc, int yinc)
if
(
gridInqXbounds
(
gridID1
,
NULL
)
&&
gridInqYbounds
(
gridID1
,
NULL
)
)
gridHasBounds
=
TRUE
;
xvals1
=
malloc
(
nlon1
*
nlat1
*
sizeof
(
double
));
yvals1
=
malloc
(
nlon1
*
nlat1
*
sizeof
(
double
));
xvals2
=
malloc
(
nlon2
*
nlat2
*
sizeof
(
double
));
yvals2
=
malloc
(
nlon2
*
nlat2
*
sizeof
(
double
));
xvals1
=
(
double
*
)
malloc
(
nlon1
*
nlat1
*
sizeof
(
double
));
yvals1
=
(
double
*
)
malloc
(
nlon1
*
nlat1
*
sizeof
(
double
));
xvals2
=
(
double
*
)
malloc
(
nlon2
*
nlat2
*
sizeof
(
double
));
yvals2
=
(
double
*
)
malloc
(
nlon2
*
nlat2
*
sizeof
(
double
));
gridInqXvals
(
gridID1
,
xvals1
);
gridInqYvals
(
gridID1
,
yvals1
);
...
...
@@ -195,10 +195,10 @@ int genBoxGrid(int gridID1, int xinc, int yinc)
if
(
gridHasBounds
)
{
grid1_corner_lon
=
malloc
(
4
*
nlon1
*
nlat1
*
sizeof
(
double
));
grid1_corner_lat
=
malloc
(
4
*
nlon1
*
nlat1
*
sizeof
(
double
));
grid2_corner_lon
=
malloc
(
4
*
nlon2
*
nlat2
*
sizeof
(
double
));
grid2_corner_lat
=
malloc
(
4
*
nlon2
*
nlat2
*
sizeof
(
double
));
grid1_corner_lon
=
(
double
*
)
malloc
(
4
*
nlon1
*
nlat1
*
sizeof
(
double
));
grid1_corner_lat
=
(
double
*
)
malloc
(
4
*
nlon1
*
nlat1
*
sizeof
(
double
));
grid2_corner_lon
=
(
double
*
)
malloc
(
4
*
nlon2
*
nlat2
*
sizeof
(
double
));
grid2_corner_lat
=
(
double
*
)
malloc
(
4
*
nlon2
*
nlat2
*
sizeof
(
double
));
gridInqXbounds
(
gridID1
,
grid1_corner_lon
);
gridInqYbounds
(
gridID1
,
grid1_corner_lat
);
...
...
@@ -545,14 +545,14 @@ void gridboxstat(field_t *field1, field_t *field2, int xinc, int yinc, int statf
if
(
field1
->
weight
)
useWeight
=
TRUE
;
gridsize
=
xinc
*
yinc
;
field
=
malloc
(
ompNumThreads
*
sizeof
(
field_t
));
field
=
(
field_t
*
)
malloc
(
ompNumThreads
*
sizeof
(
field_t
));
for
(
i
=
0
;
i
<
ompNumThreads
;
i
++
)
{
field
[
i
].
size
=
gridsize
;
field
[
i
].
ptr
=
malloc
(
gridsize
*
sizeof
(
double
));
field
[
i
].
ptr
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
field
[
i
].
weight
=
NULL
;
if
(
useWeight
)
field
[
i
].
weight
=
malloc
(
gridsize
*
sizeof
(
double
));
field
[
i
].
weight
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
field
[
i
].
missval
=
field1
->
missval
;
field
[
i
].
nmiss
=
0
;
}
...
...
@@ -700,13 +700,13 @@ void *Gridboxstat(void *argument)
field_init
(
&
field2
);
gridsize1
=
gridInqSize
(
gridID1
);
field1
.
ptr
=
malloc
(
gridsize1
*
sizeof
(
double
));
field1
.
ptr
=
(
double
*
)
malloc
(
gridsize1
*
sizeof
(
double
));
field1
.
weight
=
NULL
;
if
(
needWeights
)
field1
.
weight
=
malloc
(
gridsize1
*
sizeof
(
double
));
field1
.
weight
=
(
double
*
)
malloc
(
gridsize1
*
sizeof
(
double
));
gridsize2
=
gridInqSize
(
gridID2
);
field2
.
ptr
=
malloc
(
gridsize2
*
sizeof
(
double
));
field2
.
ptr
=
(
double
*
)
malloc
(
gridsize2
*
sizeof
(
double
));
field2
.
weight
=
NULL
;
tsID
=
0
;
...
...
src/Gridcell.c
View file @
deff029d
...
...
@@ -137,7 +137,7 @@ void *Gridcell(void *argument)
gridsize
=
gridInqSize
(
gridID
);
array
=
malloc
(
gridsize
*
sizeof
(
double
));
array
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
if
(
operatorID
==
GRIDAREA
)
...
...
@@ -185,7 +185,7 @@ void *Gridcell(void *argument)
else
if
(
operatorID
==
GRIDMASK
)
{
int
*
mask
;
mask
=
malloc
(
gridsize
*
sizeof
(
int
));
mask
=
(
int
*
)
malloc
(
gridsize
*
sizeof
(
int
));
if
(
gridInqMask
(
gridID
,
NULL
)
)
{
gridInqMask
(
gridID
,
mask
);
...
...
@@ -218,8 +218,8 @@ void *Gridcell(void *argument)
xsize
=
gridInqXsize
(
gridID
);
ysize
=
gridInqYsize
(
gridID
);
xv
=
malloc
(
gridsize
*
sizeof
(
double
));
yv
=
malloc
(
gridsize
*
sizeof
(
double
));
xv
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
yv
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
gridInqXvals
(
gridID
,
xv
);
gridInqYvals
(
gridID
,
yv
);
...
...
src/Harmonic.c
View file @
deff029d
...
...
@@ -80,7 +80,7 @@ void *Harmonic(void *argument)
filesuffix
[
0
]
=
0
;
cdoGenFileSuffix
(
filesuffix
,
sizeof
(
filesuffix
),
streamInqFiletype
(
streamID1
),
vlistID1
,
refname
);
streamIDs
=
malloc
(
n_out
*
sizeof
(
int
));
streamIDs
=
(
int
*
)
malloc
(
n_out
*
sizeof
(
int
));
strcpy
(
filename
,
cdoStreamName
(
1
)
->
args
);
nchars
=
strlen
(
filename
);
...
...
@@ -102,35 +102,35 @@ void *Harmonic(void *argument)
nvars
=
vlistNvars
(
vlistID1
);
out
=
malloc
(
n_out
*
sizeof
(
double
**
));
work
=
malloc
(
2
*
n_out
*
sizeof
(
double
**
));
out
=
(
double
***
)
malloc
(
n_out
*
sizeof
(
double
**
));
work
=
(
double
***
)
malloc
(
2
*
n_out
*
sizeof
(
double
**
));
for
(
j
=
0
;
j
<
n_out
;
++
j
)
{
out
[
j
]
=
malloc
(
nvars
*
sizeof
(
double
*
));
out
[
j
]
=
(
double
**
)
malloc
(
nvars
*
sizeof
(
double
*
));
for
(
varID
=
0
;
varID
<
nvars
;
++
varID
)
{
gridsize
=
gridInqSize
(
vlistInqVarGrid
(
vlistID1
,
varID
));
nlevel
=
zaxisInqSize
(
vlistInqVarZaxis
(
vlistID1
,
varID
));
out
[
j
][
varID
]
=
malloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
out
[
j
][
varID
]
=
(
double
*
)
malloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
}
}
for
(
j
=
0
;
j
<
n_out
*
2
;
++
j
)
{
work
[
j
]
=
malloc
(
nvars
*
sizeof
(
double
*
));
work
[
j
]
=
(
double
**
)
malloc
(
nvars
*
sizeof
(
double
*
));
for
(
varID
=
0
;
varID
<
nvars
;
++
varID
)
{
gridsize
=
gridInqSize
(
vlistInqVarGrid
(
vlistID1
,
varID
));
nlevel
=
zaxisInqSize
(
vlistInqVarZaxis
(
vlistID1
,
varID
));
work
[
j
][
varID
]
=
malloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
work
[
j
][
varID
]
=
(
double
*
)
malloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
memset
(
work
[
j
][
varID
],
0
,
gridsize
*
nlevel
*
sizeof
(
double
));
}
}
gridsize
=
vlistGridsizeMax
(
vlistID1
);
array
=
malloc
(
gridsize
*
sizeof
(
double
));
array
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
tsID
=
0
;
while
(
(
nrecs
=
streamInqTimestep
(
streamID1
,
tsID
))
)
...
...
src/Hi.c
View file @
deff029d
...
...
@@ -123,9 +123,9 @@ void *Hi(void *argument)
field_init
(
&
field1
);
field_init
(
&
field2
);
field_init
(
&
field3
);
field1
.
ptr
=
malloc
(
gridsize
*
sizeof
(
double
));
field2
.
ptr
=
malloc
(
gridsize
*
sizeof
(
double
));
field3
.
ptr
=
malloc
(
gridsize
*
sizeof
(
double
));
field1
.
ptr
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
field2
.
ptr
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
field3
.
ptr
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
if
(
cdoVerbose
)
cdoPrint
(
"Number of timesteps: file1 %d, file2 %d, file3 %d"
,
...
...
src/Histogram.c
View file @
deff029d
...
...
@@ -82,7 +82,7 @@ void *Histogram(void *argument)
/* create zaxis for output bins */
zaxisID2
=
zaxisCreate
(
ZAXIS_GENERIC
,
nbins
);
bins
=
malloc
(
nbins
*
sizeof
(
double
));
bins
=
(
double
*
)
malloc
(
nbins
*
sizeof
(
double
));
/* for ( i = 0; i < nbins; i++ ) bins[i] = (fltarr[i]+fltarr[i+1])/2; */
for
(
i
=
0
;
i
<
nbins
;
i
++
)
bins
[
i
]
=
fltarr
[
i
];
zaxisDefLevels
(
zaxisID2
,
bins
);
...
...
@@ -112,22 +112,22 @@ void *Histogram(void *argument)
streamDefVlist
(
streamID2
,
vlistID2
);
nvars
=
vlistNvars
(
vlistID2
);
vardata
=
malloc
(
nvars
*
sizeof
(
double
*
));
varcount
=
malloc
(
nvars
*
sizeof
(
double
*
));
vartcount
=
malloc
(
nvars
*
sizeof
(
double
*
));
vardata
=
(
double
**
)
malloc
(
nvars
*
sizeof
(
double
*
));
varcount
=
(
double
**
)
malloc
(
nvars
*
sizeof
(
double
*
));
vartcount
=
(
double
**
)
malloc
(
nvars
*
sizeof
(
double
*
));
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
{
gridsize
=
gridInqSize
(
vlistInqVarGrid
(
vlistID2
,
varID
));
vardata
[
varID
]
=
malloc
(
nbins
*
gridsize
*
sizeof
(
double
));
varcount
[
varID
]
=
malloc
(
nbins
*
gridsize
*
sizeof
(
double
));
vartcount
[
varID
]
=
malloc
(
gridsize
*
sizeof
(
double
));
vardata
[
varID
]
=
(
double
*
)
malloc
(
nbins
*
gridsize
*
sizeof
(
double
));
varcount
[
varID
]
=
(
double
*
)
malloc
(
nbins
*
gridsize
*
sizeof
(
double
));
vartcount
[
varID
]
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
memset
(
vardata
[
varID
],
0
,
nbins
*
gridsize
*
sizeof
(
double
));
memset
(
varcount
[
varID
],
0
,
nbins
*
gridsize
*
sizeof
(
double
));
memset
(
vartcount
[
varID
],
0
,
gridsize
*
sizeof
(
double
));
}
gridsize
=
vlistGridsizeMax
(
vlistID1
);
array
=
malloc
(
gridsize
*
sizeof
(
double
));
array
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
tsID1
=
0
;
while
(
(
nrecs
=
streamInqTimestep
(
streamID1
,
tsID1
))
)
...
...
src/Importamsr.c
View file @
deff029d
...
...
@@ -228,7 +228,7 @@ void *Importamsr(void *argument)
if
(
fsize
==
12441600
)
{
nvars
=
6
;
for
(
i
=
0
;
i
<
nvars
;
++
i
)
data
[
i
]
=
malloc
(
gridsize
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
nvars
;
++
i
)
data
[
i
]
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
init_amsr_day
(
vlistID
,
gridID
,
zaxisID
,
nvars
);
...
...
@@ -253,7 +253,7 @@ void *Importamsr(void *argument)
else
if
(
fsize
==
5184000
)
{
nvars
=
5
;
for
(
i
=
0
;
i
<
nvars
;
++
i
)
data
[
i
]
=
malloc
(
gridsize
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
nvars
;
++
i
)
data
[
i
]
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
init_amsr_averaged
(
vlistID
,
gridID
,
zaxisID
,
nvars
);
...
...
src/Importbinary.c
View file @
deff029d
...
...
@@ -86,8 +86,8 @@ int y_is_gauss(double *gridyvals, int ysize)
if
(
ysize
>
2
)
{
double
*
yvals
,
*
yw
;
yvals
=
malloc
(
ysize
*
sizeof
(
double
));
yw
=
malloc
(
ysize
*
sizeof
(
double
));
yvals
=
(
double
*
)
malloc
(
ysize
*
sizeof
(
double
));
yw
=
(
double
*
)
malloc
(
ysize
*
sizeof
(
double
));
gaussaw
(
yvals
,
yw
,
ysize
);
free
(
yw
);
for
(
i
=
0
;
i
<
(
int
)
ysize
;
i
++
)
...
...
@@ -126,8 +126,8 @@ int define_grid(dsets_t *pfi)
nx
=
pfi
->
dnum
[
0
];
ny
=
pfi
->
dnum
[
1
];
xvals
=
malloc
(
nx
*
sizeof
(
double
));
yvals
=
malloc
(
ny
*
sizeof
(
double
));
xvals
=
(
double
*
)
malloc
(
nx
*
sizeof
(
double
));
yvals
=
(
double
*
)
malloc
(
ny
*
sizeof
(
double
));
get_dim_vals
(
pfi
,
xvals
,
nx
,
0
);
get_dim_vals
(
pfi
,
yvals
,
ny
,
1
);
...
...
@@ -164,7 +164,7 @@ int define_level(dsets_t *pfi, int nlev)
{
double
*
zvals
=
NULL
;
zvals
=
malloc
(
nz
*
sizeof
(
double
));
zvals
=
(
double
*
)
malloc
(
nz
*
sizeof
(
double
));
get_dim_vals
(
pfi
,
zvals
,
nz
,
2
);
...
...
@@ -252,10 +252,10 @@ void *Importbinary(void *argument)
vlistID
=
vlistCreate
();
var_zaxisID
=
malloc
(
nvars
*
sizeof
(
int
));
recVarID
=
malloc
(
nrecs
*
sizeof
(
int
));
recLevelID
=
malloc
(
nrecs
*
sizeof
(
int
));
var_dfrm
=
malloc
(
nrecs
*
sizeof
(
int
));
var_zaxisID
=
(
int
*
)
malloc
(
nvars
*
sizeof
(
int
));
recVarID
=
(
int
*
)
malloc
(
nrecs
*
sizeof
(
int
));
recLevelID
=
(
int
*
)
malloc
(
nrecs
*
sizeof
(
int
));
var_dfrm
=
(
int
*
)
malloc
(
nrecs
*
sizeof
(
int
));
recID
=
0
;
for
(
ivar
=
0
;
ivar
<
nvars
;
++
ivar
)
...
...
@@ -368,7 +368,7 @@ void *Importbinary(void *argument)
recsize
=
pfi
.
gsiz
*
8
;
rec
=
malloc
(
recsize
);
array
=
malloc
(
gridsize
*
sizeof
(
double
));
array
=
(
double
*
)
malloc
(
gridsize
*
sizeof
(
double
));
/*
if (pfi.tmplat)
...
...
src/Importcmsaf.c
View file @
deff029d
...
...
@@ -176,10 +176,10 @@ int defLonLatGrid(int nx, int ny, double c0, double lts, double re)
return
(
-
1
);
}
xvals
=
malloc
(
nx
*
sizeof
(
double
));
yvals
=
malloc
(
ny
*
sizeof
(
double
));
xbounds
=
malloc
(
nx
*
2
*
sizeof
(
double
));
ybounds
=
malloc
(
nx
*
2
*
sizeof
(
double
));
xvals
=
(
double
*
)
malloc
(
nx
*
sizeof
(
double
));
yvals
=
(
double
*
)
malloc
(
ny
*
sizeof
(
double
));
xbounds
=
(
double
*
)
malloc
(
nx
*
2
*
sizeof
(
double
));
ybounds
=
(
double
*
)
malloc
(
nx
*
2
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
nx
;
++
i
)
{
...
...
@@ -230,8 +230,8 @@ int defSinusoidalGrid(int nx, int ny, double xmin, double xmax, double ymin, dou
int
i
;
double
*
xvals
,
*
yvals
;
xvals
=
malloc
(
nx
*
sizeof
(
double
));
yvals
=
malloc
(
ny
*
sizeof
(
double
));
xvals
=
(
double
*
)
malloc
(
nx
*
sizeof
(
double
));
yvals
=
(
double
*
)
malloc
(
ny
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
nx
;
++
i
)
{
...
...
@@ -265,8 +265,8 @@ int defLaeaGrid(int nx, int ny, double xmin, double xmax, double ymin, double ym
int
i
;
double
*
xvals
,
*
yvals
;
xvals
=
malloc
(
nx
*
sizeof
(
double
));
yvals
=
malloc
(
ny
*
sizeof
(
double
));
xvals
=
(
double
*
)
malloc
(
nx
*
sizeof
(
double
));
yvals
=
(
double
*
)
malloc
(
ny
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
nx
;
++
i
)
{
...
...
@@ -1070,7 +1070,7 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
{
float
*
farray
;
int
i
;
farray
=
malloc
(
gridsize
*
nt
*
sizeof
(
float
));
farray
=
(
float
*
)
malloc
(
gridsize
*
nt
*
sizeof
(
float
));
status
=
H5Dread
(
dset_id
,
H5T_NATIVE_FLOAT
,
H5S_ALL
,
H5S_ALL
,
H5P_DEFAULT
,
farray
);
if
(
status
<
0
)
cdoAbort
(
"Reading of NATIVE_FLOAT variable %s failed!"
,
varname
);
...
...
@@ -1087,7 +1087,7 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
else
{
int
*
iarray
,
i
;
iarray
=
malloc
(
gridsize
*
nt
*
sizeof
(
int
));
iarray
=
(
int
*
)
malloc
(
gridsize
*
nt
*
sizeof
(
int
));
status
=
H5Dread
(
dset_id
,
H5T_NATIVE_INT
,
H5S_ALL
,
H5S_ALL
,
H5P_DEFAULT
,
iarray
);
if
(
status
<
0
)
cdoAbort
(
"Reading of NATIVE_INT variable %s failed!"
,
varname
);
...
...
@@ -1119,7 +1119,7 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
if
(
nz
==
1
)
((
datasets_t
*
)
opdata
)
->
nsets
++
;
mask
=
malloc
(
gridsize
*
nt
*
sizeof
(
short
));
mask
=
(
short
*
)
malloc
(
gridsize
*
nt
*
sizeof
(
short
));
memset
(
mask
,
0
,
gridsize
*
nt
*
sizeof
(
short
));