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
dd00523b
Commit
dd00523b
authored
3 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
grbCopyRecord: Add support to retrieve data from fdb.
parent
e0f5b140
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#9893
failed
3 years ago
Stage: external
Changes
1
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/grb_write.c
+40
-8
40 additions, 8 deletions
src/grb_write.c
with
40 additions
and
8 deletions
src/grb_write.c
+
40
−
8
View file @
dd00523b
...
...
@@ -181,6 +181,12 @@ int get_fdb_param(int cdiParam)
return
fdbParam
;
}
static
void
fillup_gribbuffer
(
size_t
nbytes
,
unsigned
char
*
gribbuffer
)
{
while
(
nbytes
&
7
)
gribbuffer
[
nbytes
++
]
=
0
;
}
void
grbCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
)
{
const
int
filetype
=
streamptr1
->
filetype
;
...
...
@@ -191,17 +197,43 @@ void grbCopyRecord(stream_t *streamptr2, stream_t *streamptr1)
const
int
recID
=
streamptr1
->
tsteps
[
tsID
].
recIDs
[
vrecID
];
const
record_t
*
record
=
&
streamptr1
->
tsteps
[
tsID
].
records
[
recID
];
const
off_t
recpos
=
record
->
position
;
const
size_t
recsize
=
record
->
size
;
size_t
recsize
=
record
->
size
;
void
*
gribbuffer
=
NULL
;
if
(
streamptr1
->
fdbRetrieve
)
{
#ifdef HAVE_LIBFDB5
void
*
fdbItem
=
streamptr1
->
tsteps
[
tsID
].
records
[
recID
].
fdbItem
;
if
(
!
fdbItem
)
Error
(
"fdbItem not available!"
);
fileSetPos
(
fileID1
,
recpos
,
SEEK_SET
);
fdb_handle_t
*
fdb
;
fdb_new_handle
(
&
fdb
);
// round up recsize to next multiple of 8
const
size_t
gribbuffersize
=
((
recsize
+
7U
)
&
~
7U
);
size_t
buffersize
=
0
;
long
fdb_read_record
(
fdb_handle_t
*
fdb
,
char
*
item
,
size_t
*
buffersize
,
void
**
gribbuffer
);
recsize
=
fdb_read_record
(
fdb
,
fdbItem
,
&
buffersize
,
&
gribbuffer
);
unsigned
char
*
gribbuffer
=
(
unsigned
char
*
)
Malloc
(
gribbuffersize
);
fdb_delete_handle
(
fdb
);
if
(
fileRead
(
fileID1
,
gribbuffer
,
recsize
)
!=
recsize
)
Error
(
"Could not read GRIB record for copying!"
);
// round up recsize to next multiple of 8
const
size_t
gribbuffersize
=
((
recsize
+
7U
)
&
~
7U
);
gribbuffer
=
(
unsigned
char
*
)
Realloc
(
gribbuffer
,
gribbuffersize
);
#endif
}
else
{
fileSetPos
(
fileID1
,
recpos
,
SEEK_SET
);
// round up recsize to next multiple of 8
const
size_t
gribbuffersize
=
((
recsize
+
7U
)
&
~
7U
);
gribbuffer
=
(
unsigned
char
*
)
Malloc
(
gribbuffersize
);
if
(
fileRead
(
fileID1
,
gribbuffer
,
recsize
)
!=
recsize
)
Error
(
"Could not read GRIB record for copying!"
);
}
size_t
nbytes
=
recsize
;
...
...
@@ -284,7 +316,7 @@ void grbCopyRecord(stream_t *streamptr2, stream_t *streamptr1)
nbytes
=
grbSzip
(
filetype
,
gribbuffer
,
nbytes
);
}
while
(
nbytes
&
7
)
gribbuffer
[
nbytes
++
]
=
0
;
fillup_gribbuffer
(
nbytes
,
gribbuffer
)
;
if
(
streamptr2
->
fdbStore
)
{
...
...
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