Skip to content
GitLab
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
27b1363f
Commit
27b1363f
authored
Sep 14, 2015
by
Uwe Schulzweida
Browse files
replaced calloc/malloc/realloc/free by Calloc/Malloc/Realloc/Free from dmemory.h
parent
7628316b
Changes
236
Hide whitespace changes
Inline
Side-by-side
src/Adisit.c
View file @
27b1363f
...
...
@@ -247,7 +247,7 @@ void *Adisit(void *argument)
if
(
nlevel1
!=
nlevel2
)
cdoAbort
(
"temperature and salinity have different number of levels!"
);
nlevel
=
nlevel1
;
pressure
=
(
double
*
)
m
alloc
(
nlevel
*
sizeof
(
double
));
pressure
=
(
double
*
)
M
alloc
(
nlevel
*
sizeof
(
double
));
zaxisInqLevels
(
zaxisID
,
pressure
);
if
(
pin
>=
0
)
...
...
@@ -265,9 +265,9 @@ void *Adisit(void *argument)
field_init
(
&
tho
);
field_init
(
&
sao
);
field_init
(
&
tis
);
tho
.
ptr
=
(
double
*
)
m
alloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
sao
.
ptr
=
(
double
*
)
m
alloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
tis
.
ptr
=
(
double
*
)
m
alloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
tho
.
ptr
=
(
double
*
)
M
alloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
sao
.
ptr
=
(
double
*
)
M
alloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
tis
.
ptr
=
(
double
*
)
M
alloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
tho
.
nmiss
=
0
;
sao
.
nmiss
=
0
;
...
...
@@ -373,10 +373,10 @@ void *Adisit(void *argument)
vlistDestroy
(
vlistID2
);
f
ree
(
pressure
);
f
ree
(
tis
.
ptr
);
f
ree
(
tho
.
ptr
);
f
ree
(
sao
.
ptr
);
F
ree
(
pressure
);
F
ree
(
tis
.
ptr
);
F
ree
(
tho
.
ptr
);
F
ree
(
sao
.
ptr
);
cdoFinish
();
...
...
src/Afterburner.c
View file @
27b1363f
...
...
@@ -1486,7 +1486,7 @@ void after_precntl(struct Control *globs, struct Variable *vars)
iVertID
=
zaxisID
;
globs
->
NumLevelFound
=
numlevel
;
LevelFound
=
(
double
*
)
m
alloc
(
globs
->
NumLevelFound
*
sizeof
(
double
));
LevelFound
=
(
double
*
)
M
alloc
(
globs
->
NumLevelFound
*
sizeof
(
double
));
for
(
l
=
0
;
l
<
globs
->
NumLevelFound
;
l
++
)
LevelFound
[
l
]
=
(
int
)
zaxisInqLevel
(
zaxisID
,
l
);
...
...
@@ -1500,7 +1500,7 @@ void after_precntl(struct Control *globs, struct Variable *vars)
if
(
globs
->
vct
==
NULL
)
{
globs
->
vct
=
(
double
*
)
m
alloc
(
globs
->
nvct
*
sizeof
(
double
));
globs
->
vct
=
(
double
*
)
M
alloc
(
globs
->
nvct
*
sizeof
(
double
));
memcpy
(
globs
->
vct
,
zaxisInqVctPtr
(
zaxisID
),
globs
->
nvct
*
sizeof
(
double
));
}
}
...
...
@@ -1510,7 +1510,7 @@ void after_precntl(struct Control *globs, struct Variable *vars)
{
fprintf
(
stderr
,
" Using internal VCT for L191
\n
"
);
globs
->
nvct
=
(
191
+
1
)
*
2
;
globs
->
vct
=
(
double
*
)
m
alloc
(
globs
->
nvct
*
sizeof
(
double
));
globs
->
vct
=
(
double
*
)
M
alloc
(
globs
->
nvct
*
sizeof
(
double
));
memcpy
(
globs
->
vct
,
VCT_L191
,
globs
->
nvct
*
sizeof
(
double
));
zaxisDefVct
(
zaxisID
,
globs
->
nvct
,
globs
->
vct
);
}
...
...
@@ -1609,7 +1609,7 @@ void after_precntl(struct Control *globs, struct Variable *vars)
if
(
globs
->
Debug
)
Message
(
"FieldDim = %d"
,
FieldDim
);
globs
->
Field
=
(
double
*
)
m
alloc
(
FieldDim
*
sizeof
(
double
));
globs
->
Field
=
(
double
*
)
M
alloc
(
FieldDim
*
sizeof
(
double
));
if
(
globs
->
Debug
)
for
(
code
=
0
;
code
<
MaxCodes
;
code
++
)
...
...
@@ -1776,7 +1776,7 @@ void after_readVct(struct Control *globs, const char *vctfile)
while
(
fgets
(
line
,
1023
,
fp
)
)
globs
->
nvct
++
;
globs
->
nvct
*=
2
;
globs
->
vct
=
(
double
*
)
m
alloc
(
globs
->
nvct
*
sizeof
(
double
));
globs
->
vct
=
(
double
*
)
M
alloc
(
globs
->
nvct
*
sizeof
(
double
));
rewind
(
fp
);
for
(
i
=
0
;
i
<
globs
->
nvct
/
2
;
i
++
)
...
...
@@ -2057,9 +2057,9 @@ void after_processing(struct Control *globs, struct Variable *vars)
after_dimcalc
(
globs
);
globs
->
rcoslat
=
(
double
*
)
m
alloc
(
globs
->
Latitudes
*
sizeof
(
double
));
globs
->
coslat
=
(
double
*
)
m
alloc
(
globs
->
Latitudes
*
sizeof
(
double
));
globs
->
DerivationFactor
=
(
double
*
)
m
alloc
(
globs
->
Latitudes
*
sizeof
(
double
));
globs
->
rcoslat
=
(
double
*
)
M
alloc
(
globs
->
Latitudes
*
sizeof
(
double
));
globs
->
coslat
=
(
double
*
)
M
alloc
(
globs
->
Latitudes
*
sizeof
(
double
));
globs
->
DerivationFactor
=
(
double
*
)
M
alloc
(
globs
->
Latitudes
*
sizeof
(
double
));
if
(
globs
->
Type
<
50
&&
globs
->
AnalysisData
)
{
...
...
@@ -2123,8 +2123,8 @@ void after_processing(struct Control *globs, struct Variable *vars)
/* if ( vars[U_WIND].needed || vars[V_WIND].needed ) */
if
(
vars
[
U_WIND
].
comp
||
vars
[
V_WIND
].
comp
)
{
globs
->
dv2uv_f1
=
(
double
*
)
m
alloc
(
globs
->
DimSP_half
*
sizeof
(
double
));
globs
->
dv2uv_f2
=
(
double
*
)
m
alloc
(
globs
->
DimSP_half
*
sizeof
(
double
));
globs
->
dv2uv_f1
=
(
double
*
)
M
alloc
(
globs
->
DimSP_half
*
sizeof
(
double
));
globs
->
dv2uv_f2
=
(
double
*
)
M
alloc
(
globs
->
DimSP_half
*
sizeof
(
double
));
geninx
(
globs
->
Truncation
,
globs
->
dv2uv_f1
,
globs
->
dv2uv_f2
);
}
...
...
@@ -2152,16 +2152,16 @@ void after_processing(struct Control *globs, struct Variable *vars)
#endif
streamClose
(
globs
->
istreamID
);
if
(
globs
->
rcoslat
)
f
ree
(
globs
->
rcoslat
);
if
(
globs
->
coslat
)
f
ree
(
globs
->
coslat
);
if
(
globs
->
DerivationFactor
)
f
ree
(
globs
->
DerivationFactor
);
if
(
globs
->
rcoslat
)
F
ree
(
globs
->
rcoslat
);
if
(
globs
->
coslat
)
F
ree
(
globs
->
coslat
);
if
(
globs
->
DerivationFactor
)
F
ree
(
globs
->
DerivationFactor
);
if
(
globs
->
Field
)
f
ree
(
globs
->
Field
);
if
(
globs
->
Field
)
F
ree
(
globs
->
Field
);
if
(
globs
->
poli
)
f
ree
(
globs
->
poli
);
if
(
globs
->
pold
)
f
ree
(
globs
->
pold
);
if
(
globs
->
pdev
)
f
ree
(
globs
->
pdev
);
if
(
globs
->
pol2
)
f
ree
(
globs
->
pol2
);
if
(
globs
->
pol3
)
f
ree
(
globs
->
pol3
);
if
(
globs
->
poli
)
F
ree
(
globs
->
poli
);
if
(
globs
->
pold
)
F
ree
(
globs
->
pold
);
if
(
globs
->
pdev
)
F
ree
(
globs
->
pdev
);
if
(
globs
->
pol2
)
F
ree
(
globs
->
pol2
);
if
(
globs
->
pol3
)
F
ree
(
globs
->
pol3
);
}
extern
char
*
optarg
;
...
...
@@ -2223,7 +2223,7 @@ int afterburner(int argc, char *argv[])
fclose
(
fp
);
}
struct
Control
*
globs
=
(
struct
Control
*
)
m
alloc
(
sizeof
(
struct
Control
));
struct
Control
*
globs
=
(
struct
Control
*
)
M
alloc
(
sizeof
(
struct
Control
));
after_control_init
(
globs
);
globs
->
Verbose
=
1
;
...
...
@@ -2319,7 +2319,7 @@ int afterburner(int argc, char *argv[])
if
(
globs
->
Multi
>
0
)
Error
(
"Namelist parameter MULTI works only with one inputfile"
);
ifiles
=
(
char
**
)
m
alloc
(
globs
->
Nfiles
*
sizeof
(
char
*
));
ifiles
=
(
char
**
)
M
alloc
(
globs
->
Nfiles
*
sizeof
(
char
*
));
for
(
i
=
0
;
i
<
globs
->
Nfiles
;
i
++
)
ifiles
[
i
]
=
argv
[
--
fargcn
];
}
...
...
@@ -2350,7 +2350,7 @@ int afterburner(int argc, char *argv[])
FreeMean
(
vars
);
f
ree
(
globs
);
F
ree
(
globs
);
return
(
0
);
}
...
...
@@ -2363,7 +2363,7 @@ void *Afterburner(void *argument)
lstdout
=
!
cdoSilentMode
;
struct
Control
*
globs
=
(
struct
Control
*
)
m
alloc
(
sizeof
(
struct
Control
));
struct
Control
*
globs
=
(
struct
Control
*
)
M
alloc
(
sizeof
(
struct
Control
));
after_control_init
(
globs
);
globs
->
Verbose
=
cdoVerbose
;
...
...
@@ -2389,7 +2389,7 @@ void *Afterburner(void *argument)
if
(
globs
->
Multi
>
0
)
Error
(
"Namelist parameter MULTI works only with one inputfile"
);
ifiles
=
(
char
**
)
m
alloc
(
globs
->
Nfiles
*
sizeof
(
char
*
));
ifiles
=
(
char
**
)
M
alloc
(
globs
->
Nfiles
*
sizeof
(
char
*
));
for
(
int
i
=
0
;
i
<
globs
->
Nfiles
;
++
i
)
ifiles
[
i
]
=
cdoStreamName
(
--
nfiles
)
->
args
;
for
(
int
i
=
0
;
i
<
globs
->
Nfiles
;
++
i
)
printf
(
"files %d %s
\n
"
,
i
+
1
,
ifiles
[
i
]);
...
...
@@ -2399,7 +2399,7 @@ void *Afterburner(void *argument)
FreeMean
(
vars
);
f
ree
(
globs
);
F
ree
(
globs
);
cdoFinish
();
...
...
src/Arith.c
View file @
27b1363f
...
...
@@ -147,12 +147,12 @@ void *Arith(void *argument)
field_init
(
&
field1
);
field_init
(
&
field2
);
field1
.
ptr
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
field2
.
ptr
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
field1
.
ptr
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
field2
.
ptr
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
if
(
filltype
==
FILL_VAR
||
filltype
==
FILL_VARTS
)
{
vardata2
=
(
double
*
)
m
alloc
(
gridsize
*
nlevels2
*
sizeof
(
double
));
varnmiss2
=
(
int
*
)
m
alloc
(
nlevels2
*
sizeof
(
int
));
vardata2
=
(
double
*
)
M
alloc
(
gridsize
*
nlevels2
*
sizeof
(
double
));
varnmiss2
=
(
int
*
)
M
alloc
(
nlevels2
*
sizeof
(
int
));
}
if
(
cdoVerbose
)
cdoPrint
(
"Number of timesteps: file1 %d, file2 %d"
,
ntsteps1
,
ntsteps2
);
...
...
@@ -180,14 +180,14 @@ void *Arith(void *argument)
if
(
filltype
==
FILL_TS
)
{
nvars
=
vlistNvars
(
vlistIDx2
);
vardata
=
(
double
**
)
m
alloc
(
nvars
*
sizeof
(
double
*
));
varnmiss
=
(
int
**
)
m
alloc
(
nvars
*
sizeof
(
int
*
));
vardata
=
(
double
**
)
M
alloc
(
nvars
*
sizeof
(
double
*
));
varnmiss
=
(
int
**
)
M
alloc
(
nvars
*
sizeof
(
int
*
));
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
{
gridsize
=
gridInqSize
(
vlistInqVarGrid
(
vlistIDx2
,
varID
));
nlev
=
zaxisInqSize
(
vlistInqVarZaxis
(
vlistIDx2
,
varID
));
vardata
[
varID
]
=
(
double
*
)
m
alloc
(
nlev
*
gridsize
*
sizeof
(
double
));
varnmiss
[
varID
]
=
(
int
*
)
m
alloc
(
nlev
*
sizeof
(
int
));
vardata
[
varID
]
=
(
double
*
)
M
alloc
(
nlev
*
gridsize
*
sizeof
(
double
));
varnmiss
[
varID
]
=
(
int
*
)
M
alloc
(
nlev
*
sizeof
(
int
));
}
}
}
...
...
@@ -325,18 +325,18 @@ void *Arith(void *argument)
{
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
{
f
ree
(
vardata
[
varID
]);
f
ree
(
varnmiss
[
varID
]);
F
ree
(
vardata
[
varID
]);
F
ree
(
varnmiss
[
varID
]);
}
f
ree
(
vardata
);
f
ree
(
varnmiss
);
F
ree
(
vardata
);
F
ree
(
varnmiss
);
}
if
(
field1
.
ptr
)
f
ree
(
field1
.
ptr
);
if
(
field2
.
ptr
)
f
ree
(
field2
.
ptr
);
if
(
vardata2
)
f
ree
(
vardata2
);
if
(
varnmiss2
)
f
ree
(
varnmiss2
);
if
(
field1
.
ptr
)
F
ree
(
field1
.
ptr
);
if
(
field2
.
ptr
)
F
ree
(
field2
.
ptr
);
if
(
vardata2
)
F
ree
(
vardata2
);
if
(
varnmiss2
)
F
ree
(
varnmiss2
);
cdoFinish
();
...
...
src/Arithc.c
View file @
27b1363f
...
...
@@ -36,7 +36,7 @@ int *fill_vars(int vlistID)
{
int
varID
;
int
nvars
=
vlistNvars
(
vlistID
);
int
*
vars
=
(
int
*
)
m
alloc
(
nvars
*
sizeof
(
int
));
int
*
vars
=
(
int
*
)
M
alloc
(
nvars
*
sizeof
(
int
));
if
(
cdoNumVarnames
)
{
...
...
@@ -109,7 +109,7 @@ void *Arithc(void *argument)
field_t
field
;
field_init
(
&
field
);
field
.
ptr
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
field
.
ptr
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
field
.
weight
=
NULL
;
int
tsID
=
0
;
...
...
@@ -147,8 +147,8 @@ void *Arithc(void *argument)
streamClose
(
streamID2
);
streamClose
(
streamID1
);
if
(
field
.
ptr
)
f
ree
(
field
.
ptr
);
if
(
vars
)
f
ree
(
vars
);
if
(
field
.
ptr
)
F
ree
(
field
.
ptr
);
if
(
vars
)
F
ree
(
vars
);
vlistDestroy
(
vlistID2
);
...
...
src/Arithdays.c
View file @
27b1363f
...
...
@@ -116,7 +116,7 @@ void *Arithdays(void *argument)
gridsize
=
vlistGridsizeMax
(
vlistID1
);
field_init
(
&
field
);
field
.
ptr
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
field
.
ptr
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
field
.
weight
=
NULL
;
tsID
=
0
;
...
...
@@ -165,7 +165,7 @@ void *Arithdays(void *argument)
streamClose
(
streamID2
);
streamClose
(
streamID1
);
if
(
field
.
ptr
)
f
ree
(
field
.
ptr
);
if
(
field
.
ptr
)
F
ree
(
field
.
ptr
);
cdoFinish
();
...
...
src/Arithlat.c
View file @
27b1363f
...
...
@@ -71,7 +71,7 @@ void *Arithlat(void *argument)
gridsize
=
vlistGridsizeMax
(
vlistID1
);
array
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
array
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
tsID
=
0
;
while
(
(
nrecs
=
streamInqTimestep
(
streamID1
,
tsID
))
)
...
...
@@ -118,7 +118,7 @@ void *Arithlat(void *argument)
gridsize
=
gridInqSize
(
gridID
);
scale
=
(
double
*
)
r
ealloc
(
scale
,
gridsize
*
sizeof
(
double
));
scale
=
(
double
*
)
R
ealloc
(
scale
,
gridsize
*
sizeof
(
double
));
gridInqYvals
(
gridID
,
scale
);
/* Convert lat/lon units if required */
...
...
@@ -147,8 +147,8 @@ void *Arithlat(void *argument)
streamClose
(
streamID2
);
streamClose
(
streamID1
);
if
(
array
)
f
ree
(
array
);
if
(
scale
)
f
ree
(
scale
);
if
(
array
)
F
ree
(
array
);
if
(
scale
)
F
ree
(
scale
);
cdoFinish
();
...
...
src/CDIread.c
View file @
27b1363f
...
...
@@ -134,8 +134,8 @@ void *CDIread(void *argument)
gridsize
=
vlistGridsizeMax
(
vlistID
);
if
(
darray
==
NULL
)
darray
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
if
(
farray
==
NULL
&&
memtype
==
MEMTYPE_FLOAT
)
farray
=
(
float
*
)
m
alloc
(
gridsize
*
sizeof
(
float
));
if
(
darray
==
NULL
)
darray
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
if
(
farray
==
NULL
&&
memtype
==
MEMTYPE_FLOAT
)
farray
=
(
float
*
)
M
alloc
(
gridsize
*
sizeof
(
float
));
t0
=
timer_val
(
timer_read
);
...
...
@@ -189,8 +189,8 @@ void *CDIread(void *argument)
if
(
nruns
>
1
)
print_stat
(
"(mean)"
,
memtype
,
datatype
,
filetype
,
nvalues
,
data_size
,
file_size
,
twsum
/
nruns
);
if
(
darray
)
f
ree
(
darray
);
if
(
farray
)
f
ree
(
farray
);
if
(
darray
)
F
ree
(
darray
);
if
(
farray
)
F
ree
(
farray
);
cdoFinish
();
...
...
src/CDItest.c
View file @
27b1363f
...
...
@@ -79,7 +79,7 @@ void *CDItest(void *argument)
streamDefVlist
(
streamID2
,
vlistID2
);
gridsize
=
vlistGridsizeMax
(
vlistID1
);
array
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
array
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
tsID1
=
0
;
tsID2
=
0
;
...
...
@@ -114,7 +114,7 @@ void *CDItest(void *argument)
vlistDestroy
(
vlistID2
);
taxisDestroy
(
taxisID2
);
if
(
array
)
f
ree
(
array
);
if
(
array
)
F
ree
(
array
);
n
++
;
...
...
src/CDIwrite.c
View file @
27b1363f
...
...
@@ -165,9 +165,9 @@ void *CDIwrite(void *argument)
cdoPrint
(
"nvars : %d"
,
nvars
);
}
double
*
array
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
double
*
xvals
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
double
*
yvals
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
double
*
array
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
double
*
xvals
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
double
*
yvals
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
int
gridID2
=
gridID
;
if
(
gridInqType
(
gridID
)
==
GRID_GME
)
gridID2
=
gridToUnstructured
(
gridID
,
0
);
...
...
@@ -188,23 +188,23 @@ void *CDIwrite(void *argument)
for
(
i
=
0
;
i
<
gridsize
;
i
++
)
array
[
i
]
=
2
-
cos
(
acos
(
cos
(
xvals
[
i
])
*
cos
(
yvals
[
i
]))
/
1
.
2
);
f
ree
(
xvals
);
f
ree
(
yvals
);
F
ree
(
xvals
);
F
ree
(
yvals
);
vars
=
(
double
***
)
m
alloc
(
nvars
*
sizeof
(
double
**
));
vars
=
(
double
***
)
M
alloc
(
nvars
*
sizeof
(
double
**
));
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
{
vars
[
varID
]
=
(
double
**
)
m
alloc
(
nlevs
*
sizeof
(
double
*
));
vars
[
varID
]
=
(
double
**
)
M
alloc
(
nlevs
*
sizeof
(
double
*
));
for
(
levelID
=
0
;
levelID
<
nlevs
;
levelID
++
)
{
vars
[
varID
][
levelID
]
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
vars
[
varID
][
levelID
]
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
gridsize
;
++
i
)
vars
[
varID
][
levelID
][
i
]
=
varID
+
array
[
i
]
*
(
levelID
+
1
);
// vars[varID][levelID][i] = varID + rand()/(RAND_MAX+1.0);
}
}
if
(
memtype
==
MEMTYPE_FLOAT
)
farray
=
(
float
*
)
m
alloc
(
gridsize
*
sizeof
(
float
));
if
(
memtype
==
MEMTYPE_FLOAT
)
farray
=
(
float
*
)
M
alloc
(
gridsize
*
sizeof
(
float
));
vlistID
=
vlistCreate
();
...
...
@@ -293,14 +293,14 @@ void *CDIwrite(void *argument)
for
(
varID
=
0
;
varID
<
nvars
;
varID
++
)
{
for
(
levelID
=
0
;
levelID
<
nlevs
;
levelID
++
)
f
ree
(
vars
[
varID
][
levelID
]);
f
ree
(
vars
[
varID
]);
for
(
levelID
=
0
;
levelID
<
nlevs
;
levelID
++
)
F
ree
(
vars
[
varID
][
levelID
]);
F
ree
(
vars
[
varID
]);
}
f
ree
(
vars
);
F
ree
(
vars
);
f
ree
(
array
);
F
ree
(
array
);
if
(
farray
)
f
ree
(
farray
);
if
(
farray
)
F
ree
(
farray
);
cdoFinish
();
...
...
src/Cat.c
View file @
27b1363f
...
...
@@ -114,7 +114,7 @@ void *Cat(void *argument)
if
(
!
lcopy
)
{
gridsize
=
vlistGridsizeMax
(
vlistID1
);
array
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
array
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
}
}
else
...
...
@@ -166,7 +166,7 @@ void *Cat(void *argument)
if
(
cdoTimer
)
timer_stop
(
timer_cat
);
if
(
array
)
f
ree
(
array
);
if
(
array
)
F
ree
(
array
);
cdoFinish
();
...
...
src/Change.c
View file @
27b1363f
...
...
@@ -204,8 +204,8 @@ void *Change(void *argument)
{
zaxisID1
=
vlistZaxis
(
vlistID2
,
index
);
nlevs
=
zaxisInqSize
(
zaxisID1
);
levels
=
(
double
*
)
m
alloc
(
nlevs
*
sizeof
(
double
));
newlevels
=
(
double
*
)
m
alloc
(
nlevs
*
sizeof
(
double
));
levels
=
(
double
*
)
M
alloc
(
nlevs
*
sizeof
(
double
));
newlevels
=
(
double
*
)
M
alloc
(
nlevs
*
sizeof
(
double
));
zaxisInqLevels
(
zaxisID1
,
levels
);
for
(
k
=
0
;
k
<
nlevs
;
k
++
)
newlevels
[
k
]
=
levels
[
k
];
...
...
@@ -227,8 +227,8 @@ void *Change(void *argument)
vlistChangeZaxis
(
vlistID2
,
zaxisID1
,
zaxisID2
);
}
f
ree
(
levels
);
f
ree
(
newlevels
);
F
ree
(
levels
);
F
ree
(
newlevels
);
}
}
else
if
(
operatorID
==
CHLEVELC
||
operatorID
==
CHLEVELV
)
...
...
@@ -255,7 +255,7 @@ void *Change(void *argument)
zaxisID1
=
vlistInqVarZaxis
(
vlistID2
,
varID
);
nlevs
=
zaxisInqSize
(
zaxisID1
);
levels
=
(
double
*
)
m
alloc
(
nlevs
*
sizeof
(
double
));
levels
=
(
double
*
)
M
alloc
(
nlevs
*
sizeof
(
double
));
zaxisInqLevels
(
zaxisID1
,
levels
);
nfound
=
0
;
for
(
k
=
0
;
k
<
nlevs
;
k
++
)
...
...
@@ -274,7 +274,7 @@ void *Change(void *argument)
else
cdoAbort
(
"Level %g not found!"
,
chlevels
[
0
]);
f
ree
(
levels
);
F
ree
(
levels
);
}
else
if
(
operatorID
==
CHLTYPE
)
{
...
...
@@ -308,7 +308,7 @@ void *Change(void *argument)
streamDefVlist
(
streamID2
,
vlistID2
);
gridsize
=
vlistGridsizeMax
(
vlistID2
);
array
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
array
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
tsID1
=
0
;
while
(
(
nrecs
=
streamInqTimestep
(
streamID1
,
tsID1
))
)
...
...
@@ -331,7 +331,7 @@ void *Change(void *argument)
streamClose
(
streamID1
);
streamClose
(
streamID2
);
if
(
array
)
f
ree
(
array
);
if
(
array
)
F
ree
(
array
);
cdoFinish
();
...
...
src/Change_e5slm.c
View file @
27b1363f
...
...
@@ -75,9 +75,9 @@ void *Change_e5slm(void *argument)
gridsize
=
gridInqSize
(
vlistInqVarGrid
(
vlistIDslm
,
0
));
array
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
cland
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
lsea
=
(
short
*
)
m
alloc
(
gridsize
*
sizeof
(
short
));
array
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
cland
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
lsea
=
(
short
*
)
M
alloc
(
gridsize
*
sizeof
(
short
));
streamInqTimestep
(
streamIDslm
,
0
);
...
...
@@ -102,7 +102,7 @@ void *Change_e5slm(void *argument)
nvars
=
vlistNvars
(
vlistID1
);
codes
=
(
short
*
)
m
alloc
(
nvars
*
sizeof
(
short
));
codes
=
(
short
*
)
M
alloc
(
nvars
*
sizeof
(
short
));
for
(
varID
=
0
;
varID
<
nvars
;
++
varID
)
{
...
...
@@ -183,10 +183,10 @@ void *Change_e5slm(void *argument)
streamClose
(
streamID1
);
streamClose
(
streamID2
);
f
ree
(
array
);
f
ree
(
cland
);
f
ree
(
lsea
);
f
ree
(
codes
);
F
ree
(
array
);
F
ree
(
cland
);
F
ree
(
lsea
);
F
ree
(
codes
);
cdoFinish
();
...
...
src/Cloudlayer.c
View file @
27b1363f
...
...
@@ -200,13 +200,13 @@ void *Cloudlayer(void *argument)
nlevel
=
zaxisInqSize
(
zaxisID
);
int
nhlev
=
nlevel
+
1
;
double
*
aclcac
=
(
double
*
)
m
alloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
double
*
aclcac
=
(
double
*
)
M
alloc
(
gridsize
*
nlevel
*
sizeof
(
double
));
for
(
varID
=
0
;
varID
<
nvars2
;
++
varID
)
cloud
[
varID
]
=
(
double
*
)
m
alloc
(
gridsize
*
sizeof
(
double
));
cloud
[
varID
]
=
(
double
*
)
M
alloc
(
gridsize
*
sizeof
(
double
));
if
(
zaxisInqType
(
zaxisID
)
==
ZAXIS_PRESSURE
)
{
plevs
=
(
double
*
)
m
alloc
(
nlevel
*
sizeof
(
double
));
plevs
=
(
double
*
)
M
alloc
(
nlevel
*
sizeof
(
double
));
zaxisInqLevels
(
zaxisID
,
plevs
);
if
(
plevs
[
0
]
>
plevs
[
nlevel
-
1
]
)
{
...
...
@@ -236,7 +236,7 @@ void *Cloudlayer(void *argument)
pl_index
(
&
kmax
[
0
],
&
kmin
[
0
],
75000
.,
101300
.,
nlevel
,
plevs
);
}
f
ree
(
plevs
);
F
ree
(
plevs
);
}
else
if
(
zaxisInqType
(
zaxisID
)
==
ZAXIS_HYBRID
)
{
...
...
@@ -247,13 +247,13 @@ void *Cloudlayer(void *argument)
{
double
*
vct
;
vct
=
(
double
*
)
m
alloc
(
nvct
*
sizeof
(
double
));
vct
=
(
double
*
)
M
alloc
(
nvct
*
sizeof
(
double
));
zaxisInqVct
(
zaxisID
,
vct
);
nlevs
=
nlevel
+
1
;
plevs
=
(
double
*
)
m
alloc
(
nlevs
*
sizeof
(
double
));
plevs
=
(
double
*
)
M
alloc
(
nlevs
*
sizeof
(
double
));
vct2plev
(
vct
,
plevs
,
nlevs
);
f
ree
(
vct
);
F
ree
(
vct
);
if
(
nvars2
==
1
)
{
...
...
@@ -266,7 +266,7 @@ void *Cloudlayer(void *argument)
hl_index
(
&
kmax
[
0
],
&
kmin
[
0
],
75000
.,
101300
.,
nhlev
,
plevs
);
}
f
ree
(
plevs
);
F
ree
(
plevs
);
}
else
cdoAbort
(
"Unsupported vertical coordinate table format!"
);
...
...
@@ -369,9 +369,9 @@ void *Cloudlayer(void *argument)
vlistDestroy
(
vlistID2
);
f
ree
(
aclcac
);
F
ree
(
aclcac
);
for
(
varID
=
0
;
varID
<
nvars2
;
++
varID
)
f
ree
(
cloud
[
varID
]);
F
ree
(
cloud
[
varID
]);
cdoFinish
();
...
...
src/Collgrid.c
View file @
27b1363f
...
...
@@ -96,11 +96,11 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid, int nxblocks
if
(
gridtype
==
GRID_GENERIC
&&
gridInqXsize
(
gridID
)
==
0
&&
gridInqYsize
(
gridID
)
==
0
)
return
gridID2
;
int
*
xsize
=
(
int
*
)
m
alloc
(
nfiles
*
sizeof
(
int
));
int
*
ysize
=
(
int
*
)
m
alloc
(
nfiles
*
sizeof
(
int
));
xyinfo_t
*
xyinfo
=
(
xyinfo_t
*
)
m
alloc
(
nfiles
*
sizeof
(
xyinfo_t
));
double
**
xvals
=
(
double
**
)
m
alloc
(
nfiles
*
sizeof
(
double
*
));
double
**
yvals
=
(
double
**
)
m
alloc
(
nfiles
*
sizeof
(
double
*
));
int
*
xsize
=
(
int
*
)
M
alloc
(
nfiles
*
sizeof
(
int
));
int
*
ysize
=
(
int
*
)
M
alloc
(
nfiles
*
sizeof
(
int
));