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
libcdi
Commits
69ddc399
Commit
69ddc399
authored
Mar 07, 2017
by
Uwe Schulzweida
Browse files
Added function streamGrbChangeParameterIdentification() (patch from Michal Koutek, KMNI).
parent
f433e9fe
Changes
8
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
69ddc399
...
...
@@ -2,6 +2,10 @@
* Version 1.8.1 released
2017-03-07 Uwe Schulzweida
* Added function streamGrbChangeParameterIdentification() (patch from Michal Koutek, KMNI)
2017-02-27 Uwe Schulzweida
* Added function gridDefUvRelativeToGrid()
...
...
src/grb_read.c
View file @
69ddc399
...
...
@@ -12,7 +12,6 @@
#include
"stream_gribapi.h"
#include
"file.h"
#include
"cgribex.h"
/* gribZip gribGetZip gribGinfo */
#include
"gribapi.h"
#include
"namespace.h"
...
...
src/grb_write.c
View file @
69ddc399
...
...
@@ -12,7 +12,6 @@
#include
"stream_gribapi.h"
#include
"file.h"
#include
"cgribex.h"
/* gribZip gribGetZip gribGinfo */
#include
"gribapi.h"
#include
"namespace.h"
...
...
@@ -116,6 +115,28 @@ void grbCopyRecord(stream_t * streamptr2, stream_t * streamptr1)
size_t
nbytes
=
recsize
;
if
(
filetype
==
CDI_FILETYPE_GRB
)
{
extern
int
GribChangeParameterIdentification
;
if
(
GribChangeParameterIdentification
==
1
)
{
extern
int
GribChangeParID_code
;
extern
int
GribChangeParID_ltype
;
extern
int
GribChangeParID_lev
;
// Even if you are stream-copy records you might need to change a bit of grib-header !
#if defined HAVE_LIBCGRIBEX
void
*
gh
=
cgribex_handle_new_from_meassage
((
void
*
)
gribbuffer
,
recsize
);
cgribexChangeParameterIdentification
(
gh
,
GribChangeParID_code
,
GribChangeParID_ltype
,
GribChangeParID_lev
);
cgribex_handle_delete
(
gh
);
#elif defined HAVE_LIBGRIB_API
grib_handle
*
gh
=
grib_handle_new_from_message
(
NULL
,
(
void
*
)
gribbuffer
,
recsize
);
gribapiChangeParameterIdentification
(
gh
,
GribChangeParID_code
,
GribChangeParID_ltype
,
GribChangeParID_lev
);
grib_handle_delete
(
gh
);
#endif
GribChangeParameterIdentification
=
-
1
;
// after grib attributes have been changed turn it off again
}
}
if
(
filetype
==
CDI_FILETYPE_GRB
)
{
size_t
unzipsize
;
...
...
src/stream_cgribex.c
View file @
69ddc399
...
...
@@ -2104,6 +2104,67 @@ size_t cgribexEncode(int memtype, int varID, int levelID, int vlistID, int gridI
size_t
nbytes
=
(
size_t
)
iword
*
sizeof
(
int
);
return
nbytes
;
}
typedef
struct
{
void
*
gribbuffer
;
size_t
gribbuffersize
;
unsigned
char
*
pds
;
unsigned
char
*
gds
;
unsigned
char
*
bms
;
unsigned
char
*
bds
;
}
cgribex_handle
;
int
grib1Sections
(
unsigned
char
*
gribbuffer
,
long
gribbufsize
,
unsigned
char
**
pdsp
,
unsigned
char
**
gdsp
,
unsigned
char
**
bmsp
,
unsigned
char
**
bdsp
,
long
*
gribrecsize
);
void
*
cgribex_handle_new_from_meassage
(
void
*
gribbuffer
,
size_t
gribbuffersize
)
{
cgribex_handle
*
gh
=
(
cgribex_handle
*
)
Malloc
(
sizeof
(
cgribex_handle
));
gh
->
gribbuffer
=
NULL
;
gh
->
gribbuffersize
=
0
;
gh
->
pds
=
NULL
;
if
(
gribbuffersize
&&
gribbuffer
)
{
unsigned
char
*
pds
=
NULL
,
*
gds
=
NULL
,
*
bms
=
NULL
,
*
bds
=
NULL
;
long
gribrecsize
;
int
status
=
grib1Sections
((
unsigned
char
*
)
gribbuffer
,
(
long
)
gribbuffersize
,
&
pds
,
&
gds
,
&
bms
,
&
bds
,
&
gribrecsize
);
if
(
status
>=
0
)
{
gh
->
gribbuffer
=
gribbuffer
;
gh
->
gribbuffersize
=
gribbuffersize
;
gh
->
pds
=
pds
;
gh
->
gds
=
gds
;
gh
->
bms
=
bms
;
gh
->
bds
=
bds
;
}
}
return
(
void
*
)
gh
;
}
void
cgribex_handle_delete
(
void
*
gh
)
{
if
(
gh
)
Free
(
gh
);
}
void
cgribexChangeParameterIdentification
(
void
*
gh
,
int
code
,
int
ltype
,
int
lev
)
{
if
(
!
gh
)
return
;
unsigned
char
*
pds
=
((
cgribex_handle
*
)
gh
)
->
pds
;
if
(
!
pds
)
return
;
pds
[
8
]
=
(
unsigned
char
)
code
;
pds
[
9
]
=
(
unsigned
char
)
ltype
;
pds
[
10
]
=
(
unsigned
char
)
lev
;
}
#endif
/*
* Local Variables:
...
...
src/stream_cgribex.h
View file @
69ddc399
...
...
@@ -12,6 +12,11 @@ size_t cgribexEncode(int memtype, int varID, int levelID, int vlistID, int gridI
int
vdate
,
int
vtime
,
int
tsteptype
,
int
numavg
,
long
datasize
,
const
void
*
data
,
int
nmiss
,
void
*
gribbuffer
,
size_t
gribbuffersize
);
void
*
cgribex_handle_new_from_meassage
(
void
*
gribbuffer
,
size_t
recsize
);
void
cgribex_handle_delete
(
void
*
gh
);
void
cgribexChangeParameterIdentification
(
void
*
gh
,
int
code
,
int
ltype
,
int
lev
);
#endif
/* _STREAM_CGRIBEX_H */
/*
* Local Variables:
...
...
src/stream_grb.c
View file @
69ddc399
...
...
@@ -9,7 +9,28 @@
#include
"stream_gribapi.h"
#include
"file.h"
#include
"cgribex.h"
/* gribZip gribGetZip gribGinfo */
#include
"gribapi.h"
// Regarding operation to change parameter identification:
// -1: don't change; 1: change (GribChangeParID_code, GribChangeParID_ltype, GribChangeParID_lev)
int
GribChangeParameterIdentification
=
-
1
;
int
GribChangeParID_code
;
int
GribChangeParID_ltype
;
int
GribChangeParID_lev
;
// Used only in CDO
void
streamGrbChangeParameterIdentification
(
int
code
,
int
ltype
,
int
lev
)
{
// NOTE this is a "PROXY" function for gribapiChangeParameterIdentification();
// This just sets the globals. There are probably better solutions to this.
// The parameter change is done by function gribapiChangeParameterIdentification() in stream_gribapi.c
GribChangeParameterIdentification
=
1
;
// Setting this control variable to 1 will cause calling fnc. gribapiChangeParameterIdentification later.
// After grib attributes have been changed this variable goes to -1.
GribChangeParID_code
=
code
;
GribChangeParID_ltype
=
ltype
;
GribChangeParID_lev
=
lev
;
}
int
grib1ltypeToZaxisType
(
int
grib_ltype
)
...
...
src/stream_gribapi.c
View file @
69ddc399
...
...
@@ -2691,6 +2691,20 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
return
recsize
;
}
void
gribapiChangeParameterIdentification
(
grib_handle
*
gh
,
int
code
,
int
ltype
,
int
lev
)
{
long
indicatorOfParameter
,
indicatorOfTypeOfLevel
,
level
;
// timeRangeIndicator: could be included later
indicatorOfParameter
=
code
;
indicatorOfTypeOfLevel
=
ltype
;
level
=
lev
;
if
(
indicatorOfParameter
!=-
1
)
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"indicatorOfParameter"
,
indicatorOfParameter
),
0
);
if
(
indicatorOfTypeOfLevel
!=-
1
)
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"indicatorOfTypeOfLevel"
,
indicatorOfTypeOfLevel
),
0
);
if
(
level
!=-
1
)
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"level"
,
level
),
0
);
}
#endif
/*
...
...
src/stream_gribapi.h
View file @
69ddc399
#ifndef _STREAM_GRIBAPI_H
#define _STREAM_GRIBAPI_H
#include
"gribapi.h"
int
gribapiScanTimestep1
(
stream_t
*
streamptr
);
int
gribapiScanTimestep2
(
stream_t
*
streamptr
);
int
gribapiScanTimestep
(
stream_t
*
streamptr
);
...
...
@@ -13,6 +15,8 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
long
datasize
,
const
double
*
data
,
int
nmiss
,
void
**
gribbuffer
,
size_t
*
gribbuffersize
,
int
ljpeg
,
void
*
gribContainer
);
void
gribapiChangeParameterIdentification
(
grib_handle
*
gh
,
int
code
,
int
ltype
,
int
lev
);
#endif
/* _STREAM_GRIBAPI_H */
/*
* Local Variables:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment