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
7e0bb76c
Commit
7e0bb76c
authored
Oct 23, 2020
by
Uwe Schulzweida
Browse files
Magplot: removed include of dmemory.h
parent
8a0fe23e
Pipeline
#4858
passed with stages
in 21 minutes and 1 second
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Maggraph.cc
View file @
7e0bb76c
...
...
@@ -34,7 +34,6 @@
#include "util_string.h"
#include "cdo_vlist.h"
#include "functs.h"
#include "dmemory.h"
#include "printinfo.h"
#define DBG 0
...
...
@@ -298,7 +297,7 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
fprintf
(
stderr
,
"STAT %d
\n
"
,
(
int
)
stat
);
}
char
***
date_time_str
=
(
char
***
)
M
alloc
(
nfiles
*
sizeof
(
char
**
));
char
***
date_time_str
=
(
char
***
)
m
alloc
(
nfiles
*
sizeof
(
char
**
));
std
::
vector
<
double
>
date_time
;
std
::
vector
<
double
>
mean_val
,
std_dev_val
;
...
...
@@ -307,7 +306,7 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
if
(
stat
)
{
/* if all files are of same number of steps, only one date_time_str array is being used */
date_time_str
[
0
]
=
(
char
**
)
M
alloc
(
ntime_steps
*
sizeof
(
char
*
));
date_time_str
[
0
]
=
(
char
**
)
m
alloc
(
ntime_steps
*
sizeof
(
char
*
));
date_time
.
resize
(
ntime_steps
);
mean_val
.
resize
(
ntime_steps
);
...
...
@@ -318,7 +317,7 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
for
(
tsID
=
0
;
tsID
<
ntime_steps
;
++
tsID
)
{
date_time
[
tsID
]
=
tsID
+
1
;
date_time_str
[
0
][
tsID
]
=
(
char
*
)
M
alloc
(
256
);
date_time_str
[
0
][
tsID
]
=
(
char
*
)
m
alloc
(
256
);
sprintf
(
date_time_str
[
0
][
tsID
],
"%s %s"
,
dateToString
(
vdates
[
0
][
tsID
]).
c_str
(),
timeToString
(
vtimes
[
0
][
tsID
]).
c_str
());
mean_val
[
tsID
]
=
0.
;
std_dev_val
[
tsID
]
=
0.
;
...
...
@@ -399,13 +398,13 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
{
if
(
DBG
)
fprintf
(
stderr
,
"FILE %ld
\n
"
,
fileID
);
date_time
.
resize
(
nts
[
fileID
]);
date_time_str
[
fileID
]
=
(
char
**
)
M
alloc
(
nts
[
fileID
]
*
sizeof
(
char
*
));
date_time_str
[
fileID
]
=
(
char
**
)
m
alloc
(
nts
[
fileID
]
*
sizeof
(
char
*
));
for
(
tsID
=
0
;
tsID
<
nts
[
fileID
];
++
tsID
)
{
date_time
[
tsID
]
=
tsID
+
1
;
date_time_str
[
fileID
][
tsID
]
=
(
char
*
)
M
alloc
(
256
);
date_time_str
[
fileID
][
tsID
]
=
(
char
*
)
m
alloc
(
256
);
sprintf
(
date_time_str
[
fileID
][
tsID
],
"%s %s"
,
dateToString
(
vdates
[
fileID
][
tsID
]).
c_str
(),
timeToString
(
vtimes
[
fileID
][
tsID
]).
c_str
());
if
(
DBG
)
...
...
@@ -661,7 +660,7 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
}
char
*
lines
[
1
];
lines
[
0
]
=
(
char
*
)
M
alloc
(
1024
);
lines
[
0
]
=
(
char
*
)
m
alloc
(
1024
);
/* To be obtained from Meta Data */
/* sprintf( lines[0],"%s","ExpID : " );*/
/* sprintf( lines[0],"%sxxxx Variable : %s[%s]",lines[0], varname, varunits );*/
...
...
@@ -682,11 +681,11 @@ maggraph(const char *plotfile, const char *varname, const char *varunits, long n
mag_setc
(
"text_justification"
,
"left"
);
mag_text
();
F
ree
(
date_time_str
);
f
ree
(
date_time_str
);
if
(
DBG
)
fprintf
(
stderr
,
"%s
\n
"
,
lines
[
0
]);
F
ree
(
lines
[
0
]);
f
ree
(
lines
[
0
]);
}
static
void
...
...
@@ -811,7 +810,7 @@ VerifyGraphParameters(int num_param, std::vector<std::string> ¶m_names)
halt_flag
=
true
;
fprintf
(
stderr
,
"Invalid parameter specification '%s'!
\n
"
,
param_names
[
i
].
c_str
());
}
F
ree
(
split_str
);
f
ree
(
split_str
);
}
if
(
halt_flag
)
exit
(
0
);
...
...
src/Magplot.cc
View file @
7e0bb76c
...
...
@@ -31,7 +31,6 @@
#include "results_template_parser.h"
#include "string_utilities.h"
#include "util_string.h"
#include "dmemory.h"
#include "printinfo.h"
#define DBG 0
...
...
@@ -173,7 +172,8 @@ int checkprojection(char *projection_in);
/* Magics default values */
int
COUNT
=
10
,
isRGB
=
false
,
THICKNESS
=
1
,
NUM_LEVELS
=
0
,
FILE_SPLIT
=
false
;
double
YMIN
=
1.0e+200
,
YMAX
=
-
1.0e+200
,
INTERVAL
=
8.0
,
RESOLUTION
=
10.0
f
,
*
LEV_LIST
=
nullptr
;
double
YMIN
=
1.0e+200
,
YMAX
=
-
1.0e+200
,
INTERVAL
=
8.0
,
RESOLUTION
=
10.0
f
;
double
*
LEV_LIST
=
nullptr
;
double
LAT_MIN
=
1.0e+200
,
LAT_MAX
=
-
1.e+200
;
double
LON_MIN
=
1.0e+200
,
LON_MAX
=
-
1.e+200
;
const
char
*
COLOUR
=
nullptr
,
*
COLOUR_MIN
=
nullptr
,
*
COLOUR_MAX
=
nullptr
,
*
STYLE
=
nullptr
,
*
DEVICE
=
nullptr
,
...
...
@@ -189,7 +189,7 @@ magplot(const char *plotfile, int operatorID, const char *varname, const char *u
double
dlon
=
0
,
dlat
=
0
;
char
plotfilename
[
4096
];
char
*
titlename
;
int
j
,
split_str_count
;
int
j
;
const
char
*
sep_char
=
"="
;
char
**
split_str
=
nullptr
;
char
tempname
[
256
];
...
...
@@ -203,9 +203,8 @@ magplot(const char *plotfile, int operatorID, const char *varname, const char *u
for
(
i
=
0
;
i
<
nparam
;
++
i
)
{
split_str_count
=
0
;
sep_char
=
"="
;
split_str_count
=
cstrSplitWithSeperator
(
params
[
i
].
c_str
(),
sep_char
,
&
split_str
);
const
auto
split_str_count
=
cstrSplitWithSeperator
(
params
[
i
].
c_str
(),
sep_char
,
&
split_str
);
if
(
cdo_cmpstr
(
split_str
[
0
],
"min"
))
fprintf
(
stderr
,
"Min Val %g
\n
"
,
YMIN
);
if
(
cdo_cmpstr
(
split_str
[
0
],
"max"
))
fprintf
(
stderr
,
"Max Val %g
\n
"
,
YMAX
);
...
...
@@ -231,7 +230,7 @@ magplot(const char *plotfile, int operatorID, const char *varname, const char *u
if
(
cdo_cmpstr
(
split_str
[
0
],
"lon_max"
))
fprintf
(
stderr
,
"Lon Max Val %g
\n
"
,
LON_MAX
);
if
(
cdo_cmpstr
(
split_str
[
0
],
"projection"
))
fprintf
(
stderr
,
"PROJECTION %s
\n
"
,
PROJECTION
);
F
ree
(
split_str
);
f
ree
(
split_str
);
}
}
...
...
@@ -532,7 +531,7 @@ magplot(const char *plotfile, int operatorID, const char *varname, const char *u
mag_setc
(
"text_justification"
,
"left"
);
mag_text
();
if
(
LEV_LIST
)
F
ree
(
LEV_LIST
);
if
(
LEV_LIST
)
f
ree
(
LEV_LIST
);
}
static
void
...
...
@@ -560,7 +559,6 @@ verifyPlotParameters(int num_param, const std::vector<std::string> ¶m_names,
{
int
i
,
j
,
k
;
bool
found
=
false
,
syntax
=
true
,
halt_flag
=
false
;
int
split_str_count
;
int
param_count
=
0
;
const
char
**
params
=
nullptr
;
char
**
split_str
=
nullptr
,
**
split_str1
=
nullptr
;
...
...
@@ -577,10 +575,9 @@ verifyPlotParameters(int num_param, const std::vector<std::string> ¶m_names,
for
(
i
=
0
;
i
<
num_param
;
++
i
)
{
split_str_count
=
0
;
found
=
false
;
syntax
=
true
;
split_str_count
=
cstrSplitWithSeperator
(
param_names
[
i
].
c_str
(),
sep_char
,
&
split_str
);
auto
split_str_count
=
cstrSplitWithSeperator
(
param_names
[
i
].
c_str
(),
sep_char
,
&
split_str
);
if
(
DBG
)
fprintf
(
stderr
,
"Verifying params!
\n
"
);
...
...
@@ -769,12 +766,9 @@ verifyPlotParameters(int num_param, const std::vector<std::string> ¶m_names,
if
(
syntax
==
true
)
{
NUM_LEVELS
=
split_str_count
;
LEV_LIST
=
(
double
*
)
Malloc
(
sizeof
(
double
)
*
split_str_count
);
for
(
k
=
0
;
k
<
split_str_count
;
k
++
)
{
LEV_LIST
[
k
]
=
atof
(
split_str1
[
k
]);
}
Free
(
split_str1
);
LEV_LIST
=
(
double
*
)
malloc
(
split_str_count
*
sizeof
(
double
));
for
(
k
=
0
;
k
<
split_str_count
;
k
++
)
LEV_LIST
[
k
]
=
atof
(
split_str1
[
k
]);
free
(
split_str1
);
}
}
}
...
...
@@ -798,7 +792,7 @@ verifyPlotParameters(int num_param, const std::vector<std::string> ¶m_names,
fprintf
(
stderr
,
"Invalid parameter specification '%s'
\n
"
,
param_names
[
i
].
c_str
());
}
if
(
split_str
)
F
ree
(
split_str
);
if
(
split_str
)
f
ree
(
split_str
);
}
/*** Loop over params ****/
if
(
halt_flag
)
exit
(
0
);
...
...
@@ -807,8 +801,7 @@ verifyPlotParameters(int num_param, const std::vector<std::string> ¶m_names,
int
checkcolour
(
char
*
colour_in
)
{
int
i
,
n
;
int
split_str_count
;
int
i
;
const
char
*
sep_char
=
","
;
char
**
split_str
=
nullptr
;
float
rgb_values
[
3
];
...
...
@@ -821,11 +814,11 @@ checkcolour(char *colour_in)
if
(
strchr
(
colour_in
,
';'
)
==
nullptr
||
strstr
(
colour_in
,
"RGB("
)
==
nullptr
)
{
cdoWarning
(
"Found 'RGB=true',Specify Colour in 'RGB(r;g;b)' ( where r,g,b in [0.0,1.0] ) format!"
);
F
ree
(
split_str
);
f
ree
(
split_str
);
return
1
;
}
n
=
strlen
(
colour_in
);
int
n
=
strlen
(
colour_in
);
if
(
DBG
)
fprintf
(
stdout
,
" count %d original colour %s RGB %d
\n
"
,
n
,
colour_in
,
isRGB
);
...
...
@@ -843,12 +836,12 @@ checkcolour(char *colour_in)
if
(
DBG
)
fprintf
(
stdout
,
" count %d modified color %s
\n
"
,
(
int
)
strlen
(
temp
),
temp
);
sep_char
=
";"
;
split_str_count
=
cstrSplitWithSeperator
(
temp
,
sep_char
,
&
split_str
);
const
auto
split_str_count
=
cstrSplitWithSeperator
(
temp
,
sep_char
,
&
split_str
);
if
(
split_str_count
!=
3
)
{
cdoWarning
(
" Colour specified in Improper format!"
);
F
ree
(
split_str
);
f
ree
(
split_str
);
return
1
;
}
...
...
@@ -859,18 +852,18 @@ checkcolour(char *colour_in)
if
(
rgb_values
[
0
]
+
rgb_values
[
1
]
+
rgb_values
[
2
]
>
3.0
f
||
rgb_values
[
0
]
+
rgb_values
[
1
]
+
rgb_values
[
2
]
<
0.0
f
)
{
cdoWarning
(
" RGB Colour specified with Improper values!"
);
F
ree
(
split_str
);
f
ree
(
split_str
);
return
1
;
}
F
ree
(
split_str
);
f
ree
(
split_str
);
}
else
{
if
(
strchr
(
colour_in
,
';'
)
!=
nullptr
||
strstr
(
colour_in
,
"RGB("
)
!=
nullptr
)
{
cdoWarning
(
"Found Colour with 'RGB(r;g;b)' format, set parameter RGB='true' !"
);
F
ree
(
split_str
);
f
ree
(
split_str
);
return
1
;
}
...
...
@@ -913,12 +906,12 @@ ReadColourTable(char *filepath)
}
USR_COLOUR_COUNT
=
0
;
USR_COLOUR_TABLE
=
(
char
**
)
M
alloc
(
num_colors
*
sizeof
(
char
*
));
char
**
temp_table
=
(
char
**
)
M
alloc
(
num_colors
*
sizeof
(
char
*
));
USR_COLOUR_TABLE
=
(
char
**
)
m
alloc
(
num_colors
*
sizeof
(
char
*
));
char
**
temp_table
=
(
char
**
)
m
alloc
(
num_colors
*
sizeof
(
char
*
));
for
(
i
=
0
;
i
<
num_colors
;
i
++
)
{
temp_table
[
i
]
=
(
char
*
)
M
alloc
(
256
*
sizeof
(
char
));
temp_table
[
i
]
=
(
char
*
)
m
alloc
(
256
*
sizeof
(
char
));
fscanf
(
fp
,
"%s"
,
temp_table
[
i
]);
if
(
DBG
)
fprintf
(
stdout
,
"%s
\n
"
,
temp_table
[
i
]);
}
...
...
@@ -944,13 +937,10 @@ ReadColourTable(char *filepath)
}
}
if
(
USR_COLOUR_COUNT
<
num_colors
)
{
cdoWarning
(
" Discarding improper format colours and continuing!"
);
}
if
(
USR_COLOUR_COUNT
<
num_colors
)
cdoWarning
(
" Discarding improper format colours and continuing!"
);
for
(
i
=
0
;
i
<
num_colors
;
i
++
)
F
ree
(
temp_table
[
i
]);
F
ree
(
temp_table
);
for
(
i
=
0
;
i
<
num_colors
;
i
++
)
f
ree
(
temp_table
[
i
]);
f
ree
(
temp_table
);
return
0
;
}
...
...
src/magics_template_parser.cc
View file @
7e0bb76c
...
...
@@ -20,7 +20,6 @@
#include "cdo_output.h"
#include "compare.h"
#include "dmemory.h"
#include "magics_template_parser.h"
#include "string_utilities.h"
...
...
@@ -139,7 +138,6 @@ SetMagicsParameterValue(const char *, const char *, const char *)
char
**
split_str
=
nullptr
;
const
char
*
sep_char
=
","
;
const
char
*
search_char
=
";"
;
double
*
float_param_list
=
nullptr
;
if
(
param_name
==
nullptr
)
{
...
...
@@ -199,17 +197,16 @@ SetMagicsParameterValue(const char *, const char *, const char *)
split_str_count
=
cstrSplitWithSeperator
(
param_value
,
sep_char
,
&
split_str
);
if
(
split_str_count
)
{
float_param_list
=
(
double
*
)
Malloc
(
sizeof
(
double
)
*
split_str_count
);
std
::
vector
<
double
>
float_param_list
(
split_str_count
);
for
(
i
=
0
;
i
<
split_str_count
;
i
++
)
{
#if 0
fprintf(stderr, "%d %d %s\n", i, split_str_count, split_str[i]);
fprintf(stderr, "%d %d %s\n", i, split_str_count, split_str[i]);
#endif
float_param_list
[
i
]
=
atof
(
split_str
[
i
]);
}
mag_set1r
(
param_name
,
float_param_list
,
split_str_count
);
Free
(
float_param_list
);
Free
(
split_str
);
mag_set1r
(
param_name
,
float_param_list
.
data
(),
split_str_count
);
free
(
split_str
);
}
}
...
...
@@ -226,14 +223,13 @@ SetMagicsParameterValue(const char *, const char *, const char *)
split_str_count
=
cstrSplitWithSeperator
(
param_value
,
sep_char
,
&
split_str
);
if
(
split_str_count
)
{
int
*
int_param_list
=
(
int
*
)
Malloc
(
sizeof
(
int
)
*
split_str_count
);
std
::
vector
<
int
>
int_param_list
(
split_str_count
);
for
(
i
=
0
;
i
<
split_str_count
;
i
++
)
{
int_param_list
[
i
]
=
atoi
(
split_str
[
i
]);
}
mag_set1i
(
param_name
,
int_param_list
,
split_str_count
);
Free
(
int_param_list
);
Free
(
split_str
);
mag_set1i
(
param_name
,
int_param_list
.
data
(),
split_str_count
);
free
(
split_str
);
}
}
...
...
@@ -258,7 +254,7 @@ SetMagicsParameterValue(const char *, const char *, const char *)
if
(
DBG
)
fprintf
(
stderr
,
"Input strarr is %s split str count is %d Sep char is %s
\n
"
,
param_value
,
split_str_count
,
sep_char
);
mag_set1c
(
param_name
,
(
const
char
**
)
split_str
,
split_str_count
);
F
ree
(
split_str
);
f
ree
(
split_str
);
}
else
{
...
...
src/string_utilities.cc
View file @
7e0bb76c
...
...
@@ -17,7 +17,6 @@
#include <algorithm>
#include "cdo_output.h"
#include "dmemory.h"
#include "string_utilities.h"
#include "util_string.h"
...
...
@@ -34,6 +33,7 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, std::ve
}
return
split_string
.
size
();
}
int
cstrSplitWithSeperator
(
const
char
*
source_string
,
const
char
*
seperator
,
char
***
ptr_split_string
)
{
...
...
@@ -54,7 +54,7 @@ cstrSplitWithSeperator(const char *source_string, const char *seperator, char **
if
(
duplicate_src
[
i
]
==
*
seperator
)
sep_count
++
;
}
temp_list
=
(
char
**
)
M
alloc
(
sizeof
(
char
*
)
*
(
sep_count
+
1
));
temp_list
=
(
char
**
)
m
alloc
(
sizeof
(
char
*
)
*
(
sep_count
+
1
));
if
(
DBG
)
fprintf
(
stderr
,
"Input str %s , seperator %s sep count %d
\n
"
,
duplicate_src
,
seperator
,
sep_count
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment