Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
libcdi
Commits
aa2cd9a7
Commit
aa2cd9a7
authored
9 months ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
cdfDefVarFilter: added support for list of filterSpec
parent
6d57f10a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!88
M214003/develop
,
!87
M214003/develop
,
!86
M214003/develop
Pipeline
#70891
failed
9 months ago
Stage: external
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ChangeLog
+4
-0
4 additions, 0 deletions
ChangeLog
src/cdf_write.c
+47
-16
47 additions, 16 deletions
src/cdf_write.c
with
51 additions
and
16 deletions
ChangeLog
+
4
−
0
View file @
aa2cd9a7
...
...
@@ -4,6 +4,10 @@
* using EXSE library version 2.0.0
* Version 2.4.2 released
2024-06-17 Uwe Schulzweida
* cdfDefVarFilter: added support for list of filterSpec
2024-05-22 Uwe Schulzweida
* cdiInqContents: missing lock of non thread-safe netCDF4/HDF5 calls (bug fix)
...
...
This diff is collapsed.
Click to expand it.
src/cdf_write.c
+
47
−
16
View file @
aa2cd9a7
...
...
@@ -14,23 +14,49 @@
#include
"vlist_var.h"
// #include <netcdf_filter.h>
#ifdef HAVE_NETCDF4
#include
"netcdf_aux.h"
#endif
void
cdf_def_var_filter
(
int
ncid
,
int
ncvarID
,
unsigned
int
id
,
size_t
nparams
,
const
unsigned
int
*
params
)
static
void
cdf_def_var_filter
(
int
ncid
,
int
ncvarID
,
const
char
*
filterSpec
)
{
#ifdef HAVE_NETCDF4
int
status
;
if
((
status
=
nc_def_var_filter
(
ncid
,
ncvarID
,
id
,
nparams
,
params
)))
if
(
filterSpec
)
{
Message
(
"filterId=%u numParams=%zu"
,
id
,
nparams
);
Error
(
"nc_def_var_filter failed; %s"
,
nc_strerror
(
status
));
size_t
nfilters
=
0
;
NC_H5_Filterspec
**
filters
=
NULL
;
int
status
=
ncaux_h5filterspec_parselist
(
filterSpec
,
NULL
,
&
nfilters
,
&
filters
);
if
(
status
!=
NC_NOERR
)
{
Message
(
"filterSpec=%s"
,
filterSpec
);
Error
(
"ncaux_h5filterspec_parselist failed; %s"
,
nc_strerror
(
status
));
}
if
(
filters
!=
NULL
)
{
for
(
size_t
i
=
0
;
i
<
nfilters
;
i
++
)
{
unsigned
int
filterid
=
filters
[
i
]
->
filterid
;
// printf("filter %zu id:%d nparams:%zu param1 %d\n", i + 1, filterid, filters[i]->nparams, filters[i]->params[0]);
status
=
nc_def_var_filter
(
ncid
,
ncvarID
,
filterid
,
filters
[
i
]
->
nparams
,
filters
[
i
]
->
params
);
if
(
status
!=
NC_NOERR
)
{
Message
(
"filterid=%u numParams=%zu"
,
filterid
,
filters
[
i
]
->
nparams
);
Error
(
"nc_def_var_filter failed; %s"
,
nc_strerror
(
status
));
}
}
for
(
size_t
i
=
0
;
i
<
nfilters
;
i
++
)
ncaux_h5filterspec_free
(
filters
[
i
]);
free
(
filters
);
}
}
#else
static
bool
lwarn
=
true
;
if
(
lwarn
)
{
lwarn
=
false
;
Warning
(
"
f
ilter failed, NetCDF4 not available!"
);
Warning
(
"
F
ilter failed, NetCDF4 not available!"
);
}
#endif
}
...
...
@@ -460,13 +486,13 @@ xtype2ppb(nc_type xtype)
}
static
void
cdfDefVarFilter
(
const
stream_t
*
s
,
int
ncvarID
)
cdfDefVarFilter
(
int
fileID
,
int
fileType
,
int
ncvarID
,
const
char
*
filterSpec
)
{
if
(
s
->
filter
Id
!=
0
)
if
(
filter
Spec
)
{
if
(
s
->
file
t
ype
==
CDI_FILETYPE_NC4
||
s
->
file
t
ype
==
CDI_FILETYPE_NC4C
||
s
->
file
t
ype
==
CDI_FILETYPE_NCZARR
)
if
(
file
T
ype
==
CDI_FILETYPE_NC4
||
file
T
ype
==
CDI_FILETYPE_NC4C
||
file
T
ype
==
CDI_FILETYPE_NCZARR
)
{
cdf_def_var_filter
(
s
->
fileID
,
ncvarID
,
s
->
filter
Id
,
s
->
numParams
,
s
->
params
);
cdf_def_var_filter
(
fileID
,
ncvarID
,
filter
Spec
);
}
else
{
...
...
@@ -920,6 +946,7 @@ cdfDefVar(stream_t *streamptr, int varID)
if
(
streamptr
->
vars
[
varID
].
ncvarid
!=
CDI_UNDEFID
)
return
streamptr
->
vars
[
varID
].
ncvarid
;
int
fileID
=
streamptr
->
fileID
;
int
fileType
=
streamptr
->
filetype
;
if
(
CDI_Debug
)
Message
(
"streamID = %d, fileID = %d, varID = %d"
,
streamptr
->
self
,
fileID
,
varID
);
int
vlistID
=
streamptr
->
vlistID
;
...
...
@@ -1002,14 +1029,18 @@ cdfDefVar(stream_t *streamptr, int varID)
}
#endif
if
(
useChunks
&&
(
streamptr
->
filetype
==
CDI_FILETYPE_NC4
||
streamptr
->
filetype
==
CDI_FILETYPE_NC4C
||
streamptr
->
filetype
==
CDI_FILETYPE_NCZARR
))
if
(
useChunks
&&
(
fileType
==
CDI_FILETYPE_NC4
||
fileType
==
CDI_FILETYPE_NC4C
||
fileType
==
CDI_FILETYPE_NCZARR
))
cdf_def_var_chunking
(
fileID
,
ncvarID
,
NC_CHUNKED
,
chunks
);
#endif
if
(
useChunks
)
cdfDefVarCompression
(
streamptr
,
ncvarID
,
xtype
);
if
(
useChunks
)
cdfDefVarFilter
(
streamptr
,
ncvarID
);
if
(
useChunks
)
{
char
filterSpec
[
CDI_MAX_NAME
];
length
=
CDI_MAX_NAME
;
if
(
cdiInqKeyString
(
vlistID
,
varID
,
CDI_KEY_FILTERSPEC
,
filterSpec
,
&
length
)
==
CDI_NOERR
)
cdfDefVarFilter
(
fileID
,
fileType
,
ncvarID
,
filterSpec
);
}
if
(
*
stdname
)
cdf_put_att_text
(
fileID
,
ncvarID
,
"standard_name"
,
strlen
(
stdname
),
stdname
);
if
(
*
longname
)
cdf_put_att_text
(
fileID
,
ncvarID
,
"long_name"
,
strlen
(
longname
),
longname
);
...
...
@@ -1056,7 +1087,7 @@ cdfDefVar(stream_t *streamptr, int varID)
cdfDefineCellMethods
(
streamptr
,
vlistID
,
varID
,
fileID
,
ncvarID
);
// Attributes
cdfDefineAttributes
(
streamptr
->
file
t
ype
,
vlistID
,
varID
,
fileID
,
ncvarID
);
cdfDefineAttributes
(
file
T
ype
,
vlistID
,
varID
,
fileID
,
ncvarID
);
// Institute
if
(
vlistInqInstitut
(
vlistID
)
==
CDI_UNDEFID
)
cdfDefineInstituteName
(
vlistID
,
varID
,
fileID
,
ncvarID
);
...
...
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