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
170cf3b7
Commit
170cf3b7
authored
Feb 01, 2018
by
Uwe Schulzweida
Browse files
Merge branch 'develop' of git.mpimet.mpg.de:libcdi into develop
parents
ac212779
20a83220
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
170cf3b7
2018-01-31 Uwe Schulzweida
* Fix GRIB_API AEC compression for unstructured grids
2018-01-29 Uwe Schulzweida
* Version 1.9.3 released
...
...
config/default
View file @
170cf3b7
...
...
@@ -58,8 +58,9 @@ case "${HOSTNAME}" in
--enable-iso-c-interface
\
--enable-swig
\
--enable-python
\
--with-
grib_api
=
$HOME
/local/
gribapi-1.1
3.0
\
--with-
eccodes
=
$HOME
/local/
eccodes-2.
3.0
\
--with-netcdf
=
$HOME
/local
\
LDFLAGS
=
"-Wl,-rpath,
$HOME
/local/eccodes-2.3.0/lib"
\
CC
=
gcc
CFLAGS
=
"-g -pipe -D_REENTRANT -Wall -Wwrite-strings -W -Wfloat-equal -pedantic -O3"
;;
# x86_64-squeeze-x64-linux
...
...
configure
View file @
170cf3b7
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for cdi 1.9.
3
.
# Generated by GNU Autoconf 2.68 for cdi 1.9.
4rc1
.
#
# Report bugs to <http://mpimet.mpg.de/cdi>.
#
...
...
@@ -570,8 +570,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='cdi'
PACKAGE_TARNAME='cdi'
PACKAGE_VERSION='1.9.
3
'
PACKAGE_STRING='cdi 1.9.
3
'
PACKAGE_VERSION='1.9.
4rc1
'
PACKAGE_STRING='cdi 1.9.
4rc1
'
PACKAGE_BUGREPORT='http://mpimet.mpg.de/cdi'
PACKAGE_URL=''
...
...
@@ -1483,7 +1483,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures cdi 1.9.
3
to adapt to many kinds of systems.
\`configure' configures cdi 1.9.
4rc1
to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
...
...
@@ -1553,7 +1553,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdi 1.9.
3
:";;
short | recursive ) echo "Configuration of cdi 1.9.
4rc1
:";;
esac
cat <<\_ACEOF
...
...
@@ -1783,7 +1783,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdi configure 1.9.
3
cdi configure 1.9.
4rc1
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
...
...
@@ -2628,7 +2628,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by cdi $as_me 1.9.
3
, which was
It was created by cdi $as_me 1.9.
4rc1
, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
...
...
@@ -3580,7 +3580,7 @@ fi
# Define the identity of the package.
PACKAGE='cdi'
VERSION='1.9.
3
'
VERSION='1.9.
4rc1
'
cat >>confdefs.h <<_ACEOF
...
...
@@ -23497,7 +23497,7 @@ Usage: $0 [OPTIONS]
Report bugs to <bug-libtool@gnu.org>."
lt_cl_version="\
cdi config.lt 1.9.
3
cdi config.lt 1.9.
4rc1
configured by $0, generated by GNU Autoconf 2.68.
Copyright (C) 2011 Free Software Foundation, Inc.
...
...
@@ -31350,7 +31350,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by cdi $as_me 1.9.
3
, which was
This file was extended by cdi $as_me 1.9.
4rc1
, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
...
...
@@ -31416,7 +31416,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
cdi config.status 1.9.
3
cdi config.status 1.9.
4rc1
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
configure.ac
View file @
170cf3b7
...
...
@@ -4,7 +4,7 @@
# autoconf 2.68
# libtool 2.4.2
AC_INIT([cdi], [1.9.
3
], [http://mpimet.mpg.de/cdi])
AC_INIT([cdi], [1.9.
4rc1
], [http://mpimet.mpg.de/cdi])
AC_DEFINE_UNQUOTED(CDI, ["$PACKAGE_VERSION"], [CDI version])
...
...
src/gribapi.h
View file @
170cf3b7
...
...
@@ -58,15 +58,6 @@ void gribContainersNew(stream_t * streamptr);
void
gribContainersDelete
(
stream_t
*
streamptr
);
#ifdef HAVE_LIBGRIB_API
static
inline
void
*
gribHandleNew
(
int
editionNumber
)
{
void
*
gh
=
(
void
*
)
grib_handle_new_from_samples
(
NULL
,
(
editionNumber
==
1
)
?
"GRIB1"
:
"GRIB2"
);
if
(
gh
==
NULL
)
Error
(
"grib_handle_new_from_samples failed!"
);
return
gh
;
}
static
inline
int
my_grib_set_double
(
grib_handle
*
h
,
const
char
*
key
,
double
val
)
{
if
(
cdiGribApiDebug
)
...
...
@@ -100,6 +91,16 @@ static inline int my_grib_set_string(grib_handle* h, const char* key, const char
return
ret_val
;
}
static
inline
void
*
gribHandleNew
(
int
editionNumber
)
{
void
*
gh
=
(
void
*
)
grib_handle_new_from_samples
(
NULL
,
(
editionNumber
==
1
)
?
"GRIB1"
:
"GRIB2"
);
if
(
gh
==
NULL
)
Error
(
"grib_handle_new_from_samples failed!"
);
if
(
editionNumber
>
1
)
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"numberOfValues"
,
0L
),
0
);
return
gh
;
}
static
inline
void
gribHandleDelete
(
void
*
gh
)
{
grib_handle_delete
((
struct
grib_handle
*
)
gh
);
...
...
src/stream_cgribex.c
View file @
170cf3b7
...
...
@@ -1607,260 +1607,219 @@ void cgribexDefTime(int *isec1, int vdate, int vtime, int tsteptype, int numavg,
}
static
void
cgribexDefGrid
(
int
*
isec1
,
int
*
isec2
,
double
*
fsec2
,
int
*
isec4
,
int
gridID
)
void
cgribexDefGrid
Regular
(
int
*
isec2
,
double
*
fsec2
,
int
gridID
,
int
gridtype
,
bool
gridIsRotated
,
bool
gridIsCurvilinear
)
{
bool
lrotated
=
false
;
bool
lcurvi
=
false
;
memset
(
isec2
,
0
,
16
*
sizeof
(
int
))
;
ISEC
1_Sec2Or3Flag
=
128
;
if
(
gridtype
==
GRID_GAUSSIAN
||
gridtype
==
GRID_GAUSSIAN_REDUCED
)
ISEC2_GridType
=
GRIB1_GTYPE_GAUSSIAN
;
else
if
(
gridtype
==
GRID_LONLAT
&&
gridIsRotated
)
ISEC2_GridType
=
GRIB1_GTYPE_LATLON_ROT
;
else
ISEC
2_GridType
=
GRIB1_GTYPE_LATLON
;
int
gridtype
=
gridInqType
(
gridID
);
double
xfirst
=
0
,
xlast
=
0
,
xinc
=
0
;
double
yfirst
=
0
,
ylast
=
0
,
yinc
=
0
;
ISEC1_GridDefinition
=
255
;
int
nlon
=
(
int
)
gridInqXsize
(
gridID
);
int
nlat
=
(
int
)
gridInqYsize
(
gridID
);
if
(
gridtype
==
GRID_G
ENERIC
)
if
(
gridtype
==
GRID_G
AUSSIAN_REDUCED
)
{
int
gridsize
=
(
int
)
gridInqSize
(
gridID
);
int
xsize
=
(
int
)
gridInqXsize
(
gridID
);
int
ysize
=
(
int
)
gridInqYsize
(
gridID
);
if
(
(
ysize
==
32
||
ysize
==
48
||
ysize
==
64
||
ysize
==
96
||
ysize
==
160
||
ysize
==
192
||
ysize
==
240
||
ysize
==
320
||
ysize
==
384
||
ysize
==
480
||
ysize
==
768
)
&&
(
xsize
==
2
*
ysize
||
xsize
==
1
)
)
{
gridtype
=
GRID_GAUSSIAN
;
gridChangeType
(
gridID
,
gridtype
);
}
else
if
(
gridsize
==
1
)
{
gridtype
=
GRID_LONLAT
;
gridChangeType
(
gridID
,
gridtype
);
}
else
if
(
gridInqXvals
(
gridID
,
NULL
)
&&
gridInqYvals
(
gridID
,
NULL
)
)
{
gridtype
=
GRID_LONLAT
;
gridChangeType
(
gridID
,
gridtype
);
}
ISEC2_Reduced
=
true
;
nlon
=
0
;
gridInqRowlon
(
gridID
,
ISEC2_RowLonPtr
);
}
else
if
(
gridtype
==
GRID_CURVILINEAR
)
else
{
int
projID
=
gridInqProj
(
gridID
);
if
(
projID
!=
CDI_UNDEFID
&&
gridInqType
(
projID
)
==
GRID_PROJECTION
)
{
gridID
=
projID
;
gridtype
=
GRID_PROJECTION
;
}
if
(
nlon
==
0
)
nlon
=
1
;
else
{
static
bool
lwarning
=
true
;
if
(
lwarning
&&
gridInqSize
(
gridID
)
>
1
)
{
lwarning
=
false
;
Warning
(
"Curvilinear grid is unsupported in GRIB1! Created wrong Grid Description Section!"
);
}
lcurvi
=
true
;
gridtype
=
GRID_LONLAT
;
xfirst
=
gridInqXval
(
gridID
,
0
);
xlast
=
gridInqXval
(
gridID
,
(
gridIsCurvilinear
?
nlon
*
nlat
:
nlon
)
-
1
);
xinc
=
fabs
(
gridInqXinc
(
gridID
));
}
}
if
(
gridtype
==
GRID_PROJECTION
)
if
(
nlat
==
0
)
nlat
=
1
;
else
{
if
(
gridInqProjType
(
gridID
)
==
CDI_PROJ_RLL
)
{
gridtype
=
GRID_LONLAT
;
lrotated
=
true
;
}
else
if
(
gridInqProjType
(
gridID
)
==
CDI_PROJ_LCC
)
{
gridtype
=
GRID_LCC
;
}
yfirst
=
gridInqYval
(
gridID
,
0
);
ylast
=
gridInqYval
(
gridID
,
(
gridIsCurvilinear
?
nlon
*
nlat
:
nlat
)
-
1
);
yinc
=
fabs
(
gridInqYinc
(
gridID
));
}
ISEC2_Reduced
=
false
;
ISEC2_ScanFlag
=
0
;
ISEC2_NumLon
=
nlon
;
ISEC2_NumLat
=
nlat
;
ISEC2_FirstLat
=
(
int
)
lround
(
yfirst
*
1000
);
ISEC2_LastLat
=
(
int
)
lround
(
ylast
*
1000
);
if
(
gridtype
==
GRID_GAUSSIAN_REDUCED
)
{
ISEC2_FirstLon
=
0
;
ISEC2_LastLon
=
(
int
)
lround
(
1000
*
(
360
.
-
360
.
/
(
nlat
*
2
)));
ISEC2_LonIncr
=
(
int
)
lround
(
1000
*
360
.
/
(
nlat
*
2
));
}
else
{
ISEC2_FirstLon
=
(
int
)
lround
(
xfirst
*
1000
);
ISEC2_LastLon
=
(
int
)
lround
(
xlast
*
1000
);
ISEC2_LonIncr
=
(
int
)
lround
(
xinc
*
1000
);
}
switch
(
gridtype
)
if
(
gridtype
==
GRID_GAUSSIAN
||
gridtype
==
GRID_GAUSSIAN_REDUCED
)
{
case
GRID_LONLAT
:
case
GRID_GAUSSIAN
:
case
GRID_GAUSSIAN_REDUCED
:
case
GRID_TRAJECTORY
:
{
double
xfirst
=
0
,
xlast
=
0
,
xinc
=
0
;
double
yfirst
=
0
,
ylast
=
0
,
yinc
=
0
;
int
np
=
gridInqNP
(
gridID
);
if
(
np
==
0
)
np
=
nlat
/
2
;
ISEC2_NumPar
=
np
;
}
else
{
ISEC2_LatIncr
=
(
int
)
lround
(
yinc
*
1000
);
}
if
(
gridtype
==
GRID_GAUSSIAN
||
gridtype
==
GRID_GAUSSIAN_REDUCED
)
ISEC2_GridType
=
GRIB1_GTYPE_GAUSSIAN
;
else
if
(
gridtype
==
GRID_LONLAT
&&
lrotated
)
ISEC2_GridType
=
GRIB1_GTYPE_LATLON_ROT
;
else
ISEC2_GridType
=
GRIB1_GTYPE_LATLON
;
if
(
ISEC2_NumLon
>
1
&&
ISEC2_NumLat
==
1
)
if
(
ISEC2_LonIncr
!=
0
&&
ISEC2_LatIncr
==
0
)
ISEC2_LatIncr
=
ISEC2_LonIncr
;
int
nl
on
=
(
int
)
gridInqXsize
(
gridID
);
int
nlat
=
(
int
)
gridInqYsize
(
gridID
)
;
if
(
ISEC2_NumL
on
=
=
1
&&
ISEC2_NumLat
>
1
)
if
(
ISEC2_LonIncr
==
0
&&
ISEC2_LatIncr
!=
0
)
ISEC2_LonIncr
=
ISEC2_LatIncr
;
if
(
gridtype
==
GRID_GAUSSIAN_REDUCED
)
{
ISEC2_Reduced
=
true
;
nlon
=
0
;
gridInqRowlon
(
gridID
,
ISEC2_RowLonPtr
);
}
else
{
if
(
nlon
==
0
)
nlon
=
1
;
else
{
xfirst
=
gridInqXval
(
gridID
,
0
);
xlast
=
gridInqXval
(
gridID
,
(
lcurvi
?
nlon
*
nlat
:
nlon
)
-
1
);
xinc
=
fabs
(
gridInqXinc
(
gridID
));
}
}
ISEC2_ResFlag
=
0
;
if
(
ISEC2_LatIncr
&&
ISEC2_LonIncr
)
gribbyte_set_bit
(
&
ISEC2_ResFlag
,
1
);
if
(
gridInqUvRelativeToGrid
(
gridID
)
)
gribbyte_set_bit
(
&
ISEC2_ResFlag
,
5
);
if
(
nlat
==
0
)
nlat
=
1
;
else
{
yfirst
=
gridInqYval
(
gridID
,
0
);
ylast
=
gridInqYval
(
gridID
,
(
lcurvi
?
nlon
*
nlat
:
nlat
)
-
1
);
yinc
=
fabs
(
gridInqYinc
(
gridID
));
}
if
(
gridIsRotated
)
{
double
xpole
=
0
,
ypole
=
0
,
angle
=
0
;
gridInqParamRLL
(
gridID
,
&
xpole
,
&
ypole
,
&
angle
);
ISEC2_NumLon
=
nlon
;
ISEC2_NumLat
=
nlat
;
ISEC2_FirstLat
=
(
int
)
lround
(
yfirst
*
1000
);
ISEC2_LastLat
=
(
int
)
lround
(
ylast
*
1000
);
if
(
gridtype
==
GRID_GAUSSIAN_REDUCED
)
{
ISEC2_FirstLon
=
0
;
ISEC2_LastLon
=
(
int
)
lround
(
1000
*
(
360
.
-
360
.
/
(
nlat
*
2
)));
ISEC2_LonIncr
=
(
int
)
lround
(
1000
*
360
.
/
(
nlat
*
2
));
}
else
{
ISEC2_FirstLon
=
(
int
)
lround
(
xfirst
*
1000
);
ISEC2_LastLon
=
(
int
)
lround
(
xlast
*
1000
);
ISEC2_LonIncr
=
(
int
)
lround
(
xinc
*
1000
);
}
ISEC2_LatSP
=
-
(
int
)
lround
(
ypole
*
1000
);
ISEC2_LonSP
=
(
int
)
lround
((
xpole
+
180
)
*
1000
);
if
(
fabs
(
angle
)
>
0
)
angle
=
-
angle
;
FSEC2_RotAngle
=
angle
;
}
if
(
gridtype
==
GRID_GAUSSIAN
||
gridtype
==
GRID_GAUSSIAN_REDUCED
)
{
int
np
=
gridInqNP
(
gridID
);
if
(
np
==
0
)
np
=
nlat
/
2
;
ISEC2_NumPar
=
np
;
}
else
{
ISEC2_LatIncr
=
(
int
)
lround
(
yinc
*
1000
);
}
ISEC2_ScanFlag
=
0
;
if
(
ISEC2_LastLon
<
ISEC2_FirstLon
)
gribbyte_set_bit
(
&
ISEC2_ScanFlag
,
1
);
// East -> West
if
(
ISEC2_LastLat
>
ISEC2_FirstLat
)
gribbyte_set_bit
(
&
ISEC2_ScanFlag
,
2
);
// South -> North
}
if
(
ISEC2_NumLon
>
1
&&
ISEC2_NumLat
==
1
)
if
(
ISEC2_LonIncr
!=
0
&&
ISEC2_LatIncr
==
0
)
ISEC2_LatIncr
=
ISEC2_LonIncr
;
static
void
cgribexDefGridLambert
(
int
*
isec2
,
int
gridID
)
{
int
xsize
=
(
int
)
gridInqXsize
(
gridID
);
int
ysize
=
(
int
)
gridInqYsize
(
gridID
);
double
lon_0
,
lat_0
,
lat_1
,
lat_2
,
a
,
rf
,
xval_0
,
yval_0
,
x_0
,
y_0
;
gridInqParamLCC
(
gridID
,
grid_missval
,
&
lon_0
,
&
lat_0
,
&
lat_1
,
&
lat_2
,
&
a
,
&
rf
,
&
xval_0
,
&
yval_0
,
&
x_0
,
&
y_0
);
gridVerifyGribParamLCC
(
grid_missval
,
&
lon_0
,
&
lat_0
,
&
lat_1
,
&
lat_2
,
&
a
,
&
rf
,
&
xval_0
,
&
yval_0
,
&
x_0
,
&
y_0
);
bool
lsouth
=
(
lat_1
<
0
);
if
(
lsouth
)
{
lat_1
=
-
lat_2
;
lat_2
=
-
lat_2
;
}
double
xinc
=
gridInqXinc
(
gridID
);
double
yinc
=
gridInqYinc
(
gridID
);
ISEC2_GridType
=
GRIB1_GTYPE_LCC
;
ISEC2_NumLon
=
xsize
;
ISEC2_NumLat
=
ysize
;
ISEC2_FirstLon
=
(
int
)
lround
(
xval_0
*
1000
);
ISEC2_FirstLat
=
(
int
)
lround
(
yval_0
*
1000
);
ISEC2_Lambert_Lov
=
(
int
)
lround
(
lon_0
*
1000
);
ISEC2_Lambert_LatS1
=
(
int
)
lround
(
lat_1
*
1000
);
ISEC2_Lambert_LatS2
=
(
int
)
lround
(
lat_2
*
1000
);
ISEC2_Lambert_dx
=
(
int
)
lround
(
xinc
);
ISEC2_Lambert_dy
=
(
int
)
lround
(
yinc
);
ISEC2_Lambert_LatSP
=
0
;
ISEC2_Lambert_LonSP
=
0
;
ISEC2_Lambert_ProjFlag
=
0
;
if
(
lsouth
)
gribbyte_set_bit
(
&
ISEC2_Lambert_ProjFlag
,
1
);
bool
earthIsOblate
=
(
IS_EQUAL
(
a
,
6378160
.)
&&
IS_EQUAL
(
rf
,
297
.));
ISEC2_ResFlag
=
0
;
if
(
ISEC2_Lambert_dx
&&
ISEC2_Lambert_dy
)
gribbyte_set_bit
(
&
ISEC2_ResFlag
,
1
);
if
(
earthIsOblate
)
gribbyte_set_bit
(
&
ISEC2_ResFlag
,
2
);
if
(
gridInqUvRelativeToGrid
(
gridID
)
)
gribbyte_set_bit
(
&
ISEC2_ResFlag
,
5
);
if
(
ISEC2_NumLon
==
1
&&
ISEC2_NumLat
>
1
)
if
(
ISEC2_LonIncr
==
0
&&
ISEC2_LatIncr
!=
0
)
ISEC2_LonIncr
=
ISEC2_LatIncr
;
ISEC2_ScanFlag
=
0
;
gribbyte_set_bit
(
&
ISEC2_ScanFlag
,
2
);
// South -> North
}
ISEC2_ResFlag
=
0
;
if
(
ISEC2_LatIncr
&&
ISEC2_LonIncr
)
gribbyte_set_bit
(
&
ISEC2_ResFlag
,
1
);
if
(
gridInqUvRelativeToGrid
(
gridID
)
)
gribbyte_set_bit
(
&
ISEC2_ResFlag
,
5
);
static
void
cgribexDefGridSpectal
(
int
*
isec2
,
int
*
isec4
,
int
gridID
)
{
ISEC2_GridType
=
GRIB1_GTYPE_SPECTRAL
;
ISEC2_PentaJ
=
gridInqTrunc
(
gridID
);
ISEC2_PentaK
=
ISEC2_PentaJ
;
ISEC2_PentaM
=
ISEC2_PentaJ
;
ISEC2_RepType
=
1
;
isec4
[
2
]
=
128
;
if
(
gridInqComplexPacking
(
gridID
)
&&
ISEC2_PentaJ
>=
21
)
{
ISEC2_RepMode
=
2
;
isec4
[
3
]
=
64
;
isec4
[
16
]
=
0
;
isec4
[
17
]
=
20
;
isec4
[
18
]
=
20
;
isec4
[
19
]
=
20
;
}
else
{
ISEC2_RepMode
=
1
;
isec4
[
3
]
=
0
;
}
}
if
(
lrotated
)
{
double
xpole
=
0
,
ypole
=
0
,
angle
=
0
;
gridInqParamRLL
(
gridID
,
&
xpole
,
&
ypole
,
&
angle
);
static
void
cgribexDefGridGME
(
int
*
isec2
,
int
gridID
)
{
ISEC2_GridType
=
GRIB1_GTYPE_GME
;
int
nd
=
0
,
ni
=
0
,
ni2
=
0
,
ni3
=
0
;
gridInqParamGME
(
gridID
,
&
nd
,
&
ni
,
&
ni2
,
&
ni3
);
ISEC2_GME_ND
=
nd
;
ISEC2_GME_NI
=
ni
;
ISEC2_GME_NI2
=
ni2
;
ISEC2_GME_NI3
=
ni3
;
ISEC2_GME_AFlag
=
0
;
ISEC2_GME_LatPP
=
90000
;
ISEC2_GME_LonPP
=
0
;
ISEC2_GME_LonMPL
=
0
;
ISEC2_GME_BFlag
=
0
;
}
ISEC2_LatSP
=
-
(
int
)
lround
(
ypole
*
1000
);
ISEC2_LonSP
=
(
int
)
lround
((
xpole
+
180
)
*
1000
);
if
(
fabs
(
angle
)
>
0
)
angle
=
-
angle
;
FSEC2_RotAngle
=
angle
;
}
static
void
cgribexDefGrid
(
int
*
isec1
,
int
*
isec2
,
double
*
fsec2
,
int
*
isec4
,
int
gridID
)
{
memset
(
isec2
,
0
,
16
*
sizeof
(
int
));
ISEC1_Sec2Or3Flag
=
128
;
ISEC1_GridDefinition
=
255
;
ISEC2_Reduced
=
false
;
ISEC2_ScanFlag
=
0
;
ISEC2_ScanFlag
=
0
;
if
(
ISEC2_LastLon
<
ISEC2_FirstLon
)
gribbyte_set_bit
(
&
ISEC2_ScanFlag
,
1
);
// East -> West
if
(
ISEC2_LastLat
>
ISEC2_FirstLat
)
gribbyte_set_bit
(
&
ISEC2_ScanFlag
,
2
);
// South -> North
int
gridsize
=
(
int
)
gridInqSize
(
gridID
);
bool
gridIsRotated
=
false
;
bool
gridIsCurvilinear
=
false
;
int
gridtype
=
grbGetGridtype
(
gridID
,
gridsize
,
&
gridIsRotated
,
&
gridIsCurvilinear
);
switch
(
gridtype
)
{
case
GRID_LONLAT
:
case
GRID_GAUSSIAN
:
case
GRID_GAUSSIAN_REDUCED
:
case
GRID_TRAJECTORY
:
{
cgribexDefGridRegular
(
isec2
,
fsec2
,
gridID
,
gridtype
,
gridIsRotated
,
gridIsCurvilinear
);
break
;
}
case
GRID_LCC
:
{
int
xsize
=
(
int
)
gridInqXsize
(
gridID
);
int
ysize
=
(
int
)
gridInqYsize
(
gridID
);
double
lon_0
,
lat_0
,
lat_1
,
lat_2
,
a
,
rf
,
xval_0
,
yval_0
,
x_0
,
y_0
;
gridInqParamLCC
(
gridID
,
grid_missval
,
&
lon_0
,
&
lat_0
,
&
lat_1
,
&
lat_2
,
&
a
,
&
rf
,
&
xval_0
,
&
yval_0
,
&
x_0
,
&
y_0
);
gridVerifyGribParamLCC
(
grid_missval
,
&
lon_0
,
&
lat_0
,
&
lat_1
,
&
lat_2
,
&
a
,
&
rf
,
&
xval_0
,
&
yval_0
,
&
x_0
,
&
y_0
);
bool
lsouth
=
(
lat_1
<
0
);
if
(
lsouth
)
{
lat_1
=
-
lat_2
;
lat_2
=
-
lat_2
;
}
double
xinc
=
gridInqXinc
(
gridID
);
double
yinc
=
gridInqYinc
(
gridID
);
ISEC2_GridType
=
GRIB1_GTYPE_LCC
;
ISEC2_NumLon
=
xsize
;
ISEC2_NumLat
=
ysize
;
ISEC2_FirstLon
=
(
int
)
lround
(
xval_0
*
1000
);
ISEC2_FirstLat
=
(
int
)
lround
(
yval_0
*
1000
);
ISEC2_Lambert_Lov
=
(
int
)
lround
(
lon_0
*
1000
);
ISEC2_Lambert_LatS1
=
(
int
)
lround
(
lat_1
*
1000
);
ISEC2_Lambert_LatS2
=
(
int
)
lround
(
lat_2
*
1000
);
ISEC2_Lambert_dx
=
(
int
)
lround
(
xinc
);
ISEC2_Lambert_dy
=
(
int
)
lround
(
yinc
);
ISEC2_Lambert_LatSP
=
0
;
ISEC2_Lambert_LonSP
=
0
;
ISEC2_Lambert_ProjFlag
=
0
;
if
(
lsouth
)
gribbyte_set_bit
(
&
ISEC2_Lambert_ProjFlag
,
1
);
bool
earthIsOblate
=
(
IS_EQUAL
(
a
,
6378160
.)
&&
IS_EQUAL
(
rf
,
297
.));
ISEC2_ResFlag
=
0
;
if
(
ISEC2_Lambert_dx
&&
ISEC2_Lambert_dy
)
gribbyte_set_bit
(
&
ISEC2_ResFlag
,
1
);
if
(
earthIsOblate
)
gribbyte_set_bit
(
&
ISEC2_ResFlag
,
2
);
if
(
gridInqUvRelativeToGrid
(
gridID
)
)
gribbyte_set_bit
(
&
ISEC2_ResFlag
,
5
);
ISEC2_ScanFlag
=
0
;
gribbyte_set_bit
(
&
ISEC2_ScanFlag
,
2
);
// South -> North
cgribexDefGridLambert
(
isec2
,
gridID
);
break
;
}
case
GRID_SPECTRAL
:
{
ISEC2_GridType
=
GRIB1_GTYPE_SPECTRAL
;
ISEC2_PentaJ
=
gridInqTrunc
(
gridID
);
ISEC2_PentaK
=
ISEC2_PentaJ
;
ISEC2_PentaM
=
ISEC2_PentaJ
;
ISEC2_RepType
=
1
;
isec4
[
2
]
=
128
;
if
(
gridInqComplexPacking
(
gridID
)
&&
ISEC2_PentaJ
>=
21
)
{
ISEC2_RepMode
=
2
;
isec4
[
3
]
=
64
;
isec4
[
16
]
=
0
;
isec4
[
17
]
=
20
;
isec4
[
18
]
=
20
;
isec4
[
19
]
=
20
;
}
else
{
ISEC2_RepMode
=
1
;
isec4
[
3
]
=
0
;
}
cgribexDefGridSpectal
(
isec2
,
isec4
,
gridID
);
break
;
}
case
GRID_GME
:
{
ISEC2_GridType
=
GRIB1_GTYPE_GME
;
int
nd
=
0
,
ni
=
0
,
ni2
=
0
,
ni3
=
0
;
gridInqParamGME
(
gridID
,
&
nd
,
&
ni
,
&
ni2
,
&
ni3
);
ISEC2_GME_ND
=
nd
;
ISEC2_GME_NI
=
ni
;
ISEC2_GME_NI2
=
ni2
;
ISEC2_GME_NI3
=
ni3
;
ISEC2_GME_AFlag
=
0
;
ISEC2_GME_LatPP
=
90000
;
ISEC2_GME_LonPP
=
0
;
ISEC2_GME_LonMPL
=
0
;
ISEC2_GME_BFlag
=
0
;
cgribexDefGridGME
(
isec2
,
gridID
);
break
;
}
case
GRID_GENERIC
:
...
...
@@ -1876,7 +1835,6 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
}
}
if
(
cdiGribChangeModeUvRelativeToGrid
.
active
)
{
// this will overrule/change the UvRelativeToGrid flag;
...
...
src/stream_grb.c
View file @
170cf3b7
...
...
@@ -386,6 +386,71 @@ void streamInqGRIBinfo(int streamID, int *intnum, float *fltnum, off_t *bignum)
grib_info_for_grads
(
recpos
,
(
long
)
gribbuffersize
,
(
unsigned
char
*
)
gribbuffer
,
intnum
,
fltnum
,
bignum
);
}
}
int
grbGetGridtype
(
int
gridID
,
size_t
gridsize
,
bool
*
gridIsRotated
,
bool
*
gridIsCurvilinear
)
{
int
gridtype
=
gridInqType
(
gridID
);
if
(
gridtype
==
GRID_GENERIC
)
{
int
xsize
=
(
int
)
gridInqXsize
(
gridID
);
int
ysize
=
(
int
)
gridInqYsize
(
gridID
);
if
(
(
ysize
==
32
||
ysize
==
48
||
ysize
==
64
||