Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
8f0ed32b
Commit
8f0ed32b
authored
1 year ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Info: added asyncron processing task
parent
4923ed00
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!221
M214003/develop
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ChangeLog
+4
-0
4 additions, 0 deletions
ChangeLog
src/Info.cc
+179
-100
179 additions, 100 deletions
src/Info.cc
with
183 additions
and
100 deletions
ChangeLog
+
4
−
0
View file @
8f0ed32b
2024-04-18 Uwe Schulzweida
* Info: added asyncron processing task
2024-04-17 Uwe Schulzweida
* Diff: added asyncron processing task
...
...
This diff is collapsed.
Click to expand it.
src/Info.cc
+
179
−
100
View file @
8f0ed32b
...
...
@@ -16,6 +16,7 @@
#include
<cdi.h>
#include
"cdo_task.h"
#include
"cdo_options.h"
#include
"process_int.h"
#include
"mpmo_color.h"
...
...
@@ -267,15 +268,18 @@ infostat_init(InfoStat &infoStat)
}
static
void
print_header
(
int
fileIndex
,
bool
lvinfo
,
const
std
::
string
&
e
,
const
std
::
string
&
v
)
print_header
(
int
fileIndex
,
bool
lvinfo
,
int
operfunc
)
{
auto
e
=
(
operfunc
==
Func_Name
)
?
"Parameter name"
:
((
operfunc
==
Func_Code
)
?
"Code number"
:
"Parameter ID"
);
auto
v
=
(
Options
::
cdoVerbose
)
?
" : Extra"
:
""
;
set_text_color
(
stdout
,
BRIGHT
);
if
(
fileIndex
)
fprintf
(
stdout
,
"%6d : Date Time %s Gridsize Miss : Minimum Mean Maximum : %s%s
\n
"
,
fileIndex
,
lvinfo
?
"Nlevs"
:
"Level"
,
e
.
c_str
(),
v
.
c_str
()
);
lvinfo
?
"Nlevs"
:
"Level"
,
e
,
v
);
else
fprintf
(
stdout
,
" : Date Time %s Gridsize Miss : Minimum Mean Maximum : %s%s
\n
"
,
lvinfo
?
"Nlevs"
:
"Level"
,
e
.
c_str
(),
v
.
c_str
()
);
lvinfo
?
"Nlevs"
:
"Level"
,
e
,
v
);
reset_text_color
(
stdout
);
}
...
...
@@ -335,6 +339,7 @@ public:
using
Process
::
Process
;
inline
static
CdoModule
module
=
{
.
name
=
"Info"
,
// clang-format off
.
operators
=
{
{
"info"
,
Func_Param
,
0
,
InfoHelp
},
{
"infop"
,
Func_Param
,
0
,
InfoHelp
},
{
"infon"
,
Func_Name
,
0
,
InfoHelp
},
...
...
@@ -342,6 +347,7 @@ public:
{
"vinfon"
,
Func_Name
,
0
,
InfoHelp
},
{
"xinfon"
,
Func_Name
,
0
,
InfoHelp
},
{
"map"
,
Func_Param
,
0
,
InfoHelp
}
},
// clang-format on
.
aliases
=
{},
.
mode
=
EXPOSED
,
// Module mode: 0:intern 1:extern
.
number
=
CDI_BOTH
,
// Allowed number type
...
...
@@ -349,40 +355,177 @@ public:
};
inline
static
RegisterEntry
<
Info
>
registration
=
RegisterEntry
<
Info
>
(
module
);
int
VINFON
,
XINFON
,
MAP
;
size_t
imiss
=
0
;
int
operatorID
;
int
operfunc
;
bool
printMap
;
bool
lvinfo
;
std
::
string
e
;
// parameter_name
std
::
string
v
;
// verbose;
public
:
void
init
()
override
{
VINFON
=
module
.
get_id
(
"vinfon"
);
XINFON
=
module
.
get_id
(
"xinfon"
);
MAP
=
module
.
get_id
(
"map"
);
auto
VINFON
=
module
.
get_id
(
"vinfon"
);
auto
XINFON
=
module
.
get_id
(
"xinfon"
);
auto
MAP
=
module
.
get_id
(
"map"
);
operatorID
=
cdo_operator_id
();
auto
operatorID
=
cdo_operator_id
();
operfunc
=
cdo_operator_f1
(
operatorID
);
operator_check_argc
(
0
);
printMap
=
(
operatorID
==
MAP
);
lvinfo
=
(
operatorID
==
VINFON
||
operatorID
==
XINFON
);
}
struct
FuncArgs
{
FieldVector
&
fieldVector
;
std
::
vector
<
InfoStat
>
&
infoStatList
;
int
operfunc
;
bool
printMap
{
false
};
bool
lvinfo
{
false
};
int
t
{
0
};
int
indg
{
0
};
int
indf
{
0
};
int
tsID
{
0
};
int
recID
{
0
};
int
varID
{
0
};
int
levelID
{
0
};
CdoVar
var
;
CdiDateTime
vDateTime
{};
FuncArgs
(
FieldVector
&
_fieldVector
,
std
::
vector
<
InfoStat
>
&
_infoStatList
,
int
_operfunc
,
bool
_printMap
,
bool
_lvinfo
)
:
fieldVector
(
_fieldVector
),
infoStatList
(
_infoStatList
),
operfunc
(
_operfunc
),
printMap
(
_printMap
),
lvinfo
(
_lvinfo
)
{
}
void
set
(
int
_t
,
int
_indg
,
int
_indf
,
int
_tsID
,
int
_recID
,
int
_varID
,
int
_levelID
,
const
CdoVar
&
_var
,
CdiDateTime
_vDateTime
)
{
t
=
_t
;
indg
=
_indg
;
indf
=
_indf
;
tsID
=
_tsID
;
recID
=
_recID
;
varID
=
_varID
;
levelID
=
_levelID
;
var
=
_var
;
vDateTime
=
_vDateTime
;
}
};
static
void
*
info
(
void
*
_args
)
{
FuncArgs
*
args
=
(
FuncArgs
*
)
_args
;
auto
&
field
=
args
->
fieldVector
[
args
->
t
];
auto
indg
=
args
->
indg
;
auto
indf
=
args
->
indf
;
auto
tsID
=
args
->
tsID
;
auto
recID
=
args
->
recID
;
auto
varID
=
args
->
varID
;
auto
levelID
=
args
->
levelID
;
auto
&
var
=
args
->
var
;
auto
&
infoStat
=
args
->
infoStatList
[
varID
];
auto
operfunc
=
args
->
operfunc
;
auto
printMap
=
args
->
printMap
;
auto
lvinfo
=
args
->
lvinfo
;
if
((
tsID
==
0
&&
recID
==
0
)
||
printMap
)
print_header
(
-
(
indf
+
1
),
lvinfo
,
operfunc
);
auto
numMissVals
=
field
.
numMissVals
;
auto
loutput
=
!
lvinfo
;
if
(
loutput
)
infostat_init
(
infoStat
);
infoStat
.
nlevels
+=
1
;
infoStat
.
numMissVals
+=
numMissVals
;
if
(
var
.
nlevels
==
infoStat
.
nlevels
)
loutput
=
true
;
char
paramstr
[
32
];
if
(
loutput
)
{
cdiParamToString
(
var
.
param
,
paramstr
,
sizeof
(
paramstr
));
fprintf
(
stdout
,
"%6d "
,
indg
);
fprintf
(
stdout
,
":"
);
auto
vdateString
=
date_to_string
(
args
->
vDateTime
.
date
);
auto
vtimeString
=
time_to_string
(
args
->
vDateTime
.
time
);
set_text_color
(
stdout
,
MAGENTA
);
fprintf
(
stdout
,
"%s %s "
,
vdateString
.
c_str
(),
vtimeString
.
c_str
());
reset_text_color
(
stdout
);
set_text_color
(
stdout
,
GREEN
);
if
(
lvinfo
)
fprintf
(
stdout
,
"%7d "
,
var
.
nlevels
);
else
fprintf
(
stdout
,
"%7g "
,
cdo_zaxis_inq_level
(
var
.
zaxisID
,
levelID
));
fprintf
(
stdout
,
"%8zu %7zu "
,
var
.
gridsize
,
infoStat
.
numMissVals
);
reset_text_color
(
stdout
);
fprintf
(
stdout
,
":"
);
set_text_color
(
stdout
,
BLUE
);
}
size_t
imiss
=
0
;
// clang-format off
if
(
var
.
nwpv
==
CDI_REAL
)
compute_stat_real
(
field
,
infoStat
,
imiss
,
var
.
gridsize
);
else
compute_stat_comp
(
field
,
infoStat
,
imiss
,
var
.
gridsize
);
// clang-format on
if
(
loutput
)
{
// clang-format off
if
(
var
.
nwpv
==
CDI_REAL
)
print_stat_real
(
infoStat
);
else
print_stat_comp
(
infoStat
);
// clang-format on
reset_text_color
(
stdout
);
fprintf
(
stdout
,
" : "
);
// set_text_color(stdout, GREEN);
// clang-format off
if
(
operfunc
==
Func_Name
)
fprintf
(
stdout
,
"%-14s"
,
var
.
name
.
c_str
());
else
if
(
operfunc
==
Func_Code
)
fprintf
(
stdout
,
"%4d "
,
var
.
code
);
else
fprintf
(
stdout
,
"%-14s"
,
paramstr
);
// clang-format on
// reset_text_color(stdout);
e
=
(
operfunc
==
Func_Name
)
?
"Parameter name"
:
((
operfunc
==
Func_Code
)
?
"Code number"
:
"Parameter ID"
);
v
=
(
Options
::
cdoVerbose
)
?
" : Extra"
:
""
;
fprintf
(
stdout
,
"
\n
"
);
}
if
(
imiss
!=
numMissVals
&&
numMissVals
)
cdo_warning
(
"Found %zu of %zu missing values!"
,
imiss
,
numMissVals
);
if
(
printMap
)
{
auto
gridID
=
var
.
gridID
;
auto
gridtype
=
var
.
gridType
;
auto
nlon
=
gridInqXsize
(
gridID
);
auto
nlat
=
gridInqYsize
(
gridID
);
if
(
gridtype
==
GRID_GAUSSIAN
||
gridtype
==
GRID_LONLAT
||
gridtype
==
GRID_CURVILINEAR
||
(
gridtype
==
GRID_GENERIC
&&
nlon
*
nlat
==
gridInqSize
(
gridID
)
&&
nlon
<
1024
))
{
print_map
(
nlon
,
nlat
,
field
,
infoStat
);
}
}
return
nullptr
;
}
void
run
()
override
{
int
indg
=
0
;
int
numSets
=
0
;
auto
numStreams
=
cdo_stream_cnt
();
for
(
int
indf
=
0
;
indf
<
numStreams
;
indf
++
)
...
...
@@ -395,11 +538,16 @@ public:
auto
numVars
=
varList
.
numVars
();
if
(
numVars
==
0
)
continue
;
cdo
::
Task
task
;
auto
runAsync
=
(
Options
::
CDO_Parallel_Read
>
0
);
auto
numTasks
=
runAsync
?
2
:
1
;
FieldVector
fieldVector
(
numTasks
);
std
::
vector
<
InfoStat
>
infoStatList
(
numVars
);
F
ield
field
;
F
uncArgs
funcArgs
(
fieldVector
,
infoStatList
,
operfunc
,
printMap
,
lvinfo
)
;
indg
=
0
;
numSets
=
0
;
int
tsID
=
0
;
while
(
true
)
{
...
...
@@ -414,105 +562,36 @@ public:
{
auto
[
varID
,
levelID
]
=
cdo_inq_record
(
streamID
);
const
auto
&
var
=
varList
.
vars
[
varID
];
auto
taskNum
=
numSets
%
numTasks
;
auto
&
field
=
fieldVector
[
taskNum
];
field
.
init
(
var
);
cdo_read_record
(
streamID
,
field
);
if
((
tsID
==
0
&&
recID
==
0
)
||
operatorID
==
MAP
)
print_header
(
-
(
indf
+
1
),
lvinfo
,
e
,
v
);
auto
numMissVals
=
field
.
numMissVals
;
indg
=
lvinfo
?
varID
+
1
:
indg
+
1
;
auto
loutput
=
!
lvinfo
;
if
(
loutput
)
infostat_init
(
infoStatList
[
varID
]);
auto
&
infoStat
=
infoStatList
[
varID
];
infoStat
.
nlevels
+=
1
;
infoStat
.
numMissVals
+=
numMissVals
;
if
(
var
.
nlevels
==
infoStat
.
nlevels
)
loutput
=
true
;
char
paramstr
[
32
];
if
(
loutput
)
if
(
runAsync
)
{
cdiParamToString
(
var
.
param
,
paramstr
,
sizeof
(
paramstr
));
if
(
numSets
>
0
)
{
task
.
wait
();
}
fprintf
(
stdout
,
"%6d "
,
indg
);
fprintf
(
stdout
,
":"
);
auto
vdateString
=
date_to_string
(
vDateTime
.
date
);
auto
vtimeString
=
time_to_string
(
vDateTime
.
time
);
set_text_color
(
stdout
,
MAGENTA
);
fprintf
(
stdout
,
"%s %s "
,
vdateString
.
c_str
(),
vtimeString
.
c_str
());
reset_text_color
(
stdout
);
set_text_color
(
stdout
,
GREEN
);
if
(
lvinfo
)
fprintf
(
stdout
,
"%7d "
,
var
.
nlevels
);
else
fprintf
(
stdout
,
"%7g "
,
cdo_zaxis_inq_level
(
var
.
zaxisID
,
levelID
));
fprintf
(
stdout
,
"%8zu %7zu "
,
var
.
gridsize
,
infoStat
.
numMissVals
);
reset_text_color
(
stdout
);
fprintf
(
stdout
,
":"
);
set_text_color
(
stdout
,
BLUE
);
numSets
=
lvinfo
?
varID
+
1
:
numSets
+
1
;
funcArgs
.
set
(
taskNum
,
numSets
,
indf
,
tsID
,
recID
,
varID
,
levelID
,
var
,
vDateTime
);
task
.
start
(
info
,
&
funcArgs
);
}
// clang-format off
if
(
var
.
nwpv
==
CDI_REAL
)
compute_stat_real
(
field
,
infoStat
,
imiss
,
var
.
gridsize
);
else
compute_stat_comp
(
field
,
infoStat
,
imiss
,
var
.
gridsize
);
// clang-format on
if
(
loutput
)
else
{
// clang-format off
if
(
var
.
nwpv
==
CDI_REAL
)
print_stat_real
(
infoStat
);
else
print_stat_comp
(
infoStat
);
// clang-format on
reset_text_color
(
stdout
);
fprintf
(
stdout
,
" : "
);
// set_text_color(stdout, GREEN);
// clang-format off
if
(
operfunc
==
Func_Name
)
fprintf
(
stdout
,
"%-14s"
,
var
.
name
.
c_str
());
else
if
(
operfunc
==
Func_Code
)
fprintf
(
stdout
,
"%4d "
,
var
.
code
);
else
fprintf
(
stdout
,
"%-14s"
,
paramstr
);
// clang-format on
// reset_text_color(stdout);
fprintf
(
stdout
,
"
\n
"
);
}
if
(
imiss
!=
numMissVals
&&
numMissVals
)
cdo_warning
(
"Found %zu of %zu missing values!"
,
imiss
,
numMissVals
);
if
(
operatorID
==
MAP
)
{
auto
gridID
=
var
.
gridID
;
auto
gridtype
=
var
.
gridType
;
auto
nlon
=
gridInqXsize
(
gridID
);
auto
nlat
=
gridInqYsize
(
gridID
);
if
(
gridtype
==
GRID_GAUSSIAN
||
gridtype
==
GRID_LONLAT
||
gridtype
==
GRID_CURVILINEAR
||
(
gridtype
==
GRID_GENERIC
&&
nlon
*
nlat
==
gridInqSize
(
gridID
)
&&
nlon
<
1024
))
{
print_map
(
nlon
,
nlat
,
field
,
infoStat
);
}
numSets
=
lvinfo
?
varID
+
1
:
numSets
+
1
;
funcArgs
.
set
(
taskNum
,
numSets
,
indf
,
tsID
,
recID
,
varID
,
levelID
,
var
,
vDateTime
);
info
(
&
funcArgs
);
}
}
tsID
++
;
}
if
(
runAsync
)
task
.
wait
();
cdo_stream_close
(
streamID
);
}
if
(
indg
>
36
&&
operatorID
!=
MAP
)
print_header
(
0
,
lvinfo
,
e
,
v
);
if
(
numSets
>
36
&&
!
printMap
)
print_header
(
0
,
lvinfo
,
operfunc
);
}
void
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment