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
cf1c2ee2
Commit
cf1c2ee2
authored
Jul 19, 2010
by
Uwe Schulzweida
Browse files
cgribexlib update
parent
d46594a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/cgribexlib.c
View file @
cf1c2ee2
/* Automatically generated by m214003 at 2010-07-
05
, do not edit */
/* Automatically generated by m214003 at 2010-07-
19
, do not edit */
/* CGRIBEXLIB_VERSION="1.4.5.
1
" */
/* CGRIBEXLIB_VERSION="1.4.5.
2
" */
#if defined (HAVE_CONFIG_H)
# include "config.h"
...
...
@@ -15,6 +15,7 @@
#include
"file.h"
#include
"dmemory.h"
#include
"dtypes.h"
#include
"calendar.h"
#include
"timebase.h"
#ifndef _GRIB_INT_H
...
...
@@ -124,6 +125,14 @@ int cdiEncodeDate(int year, int month, int day);
void
cdiDecodeTime
(
int
time
,
int
*
hour
,
int
*
minute
,
int
*
second
);
int
cdiEncodeTime
(
int
hour
,
int
minute
,
int
second
);
/* CALENDAR types */
#define CALENDAR_STANDARD 0
/* don't change this value (used also in cgribexlib)! */
#define CALENDAR_PROLEPTIC 1
#define CALENDAR_360DAYS 2
#define CALENDAR_365DAYS 3
#define CALENDAR_366DAYS 4
#define CALENDAR_NONE 5
extern
FILE
*
grprsm
;
...
...
@@ -1069,10 +1078,11 @@ void gribDateTime(int *isec1, int *date, int *time)
{
static
char
func
[]
=
"gribDateTime"
;
static
int
lprint
=
TRUE
;
int
ryear
,
rmonth
,
rday
,
rhour
,
rminute
;
int
ryear
,
rmonth
,
rday
,
rhour
,
rminute
,
second
;
int
time_period
=
0
;
int
julday
,
secofday
,
addsec
;
int
century
;
extern
int
grib_calendar
;
century
=
ISEC1_Century
;
if
(
century
<
0
)
century
=
-
century
;
...
...
@@ -1102,6 +1112,7 @@ void gribDateTime(int *isec1, int *date, int *time)
rhour
=
ISEC1_Hour
;
rminute
=
ISEC1_Minute
;
second
=
0
;
/* printf("ref %d/%d/%d %d:%d\n", ryear, rmonth, rday, rhour, rminute); */
...
...
@@ -1114,7 +1125,7 @@ void gribDateTime(int *isec1, int *date, int *time)
if
(
time_period
>
0
&&
rday
>
0
)
{
encode_
ju
ldaysec
(
0
,
ryear
,
rmonth
,
rday
,
rhour
,
rminute
,
&
julday
,
&
secofday
);
encode_
ca
ldaysec
(
grib_calendar
,
ryear
,
rmonth
,
rday
,
rhour
,
rminute
,
second
,
&
julday
,
&
secofday
);
addsec
=
0
;
switch
(
ISEC1_TimeUnit
)
...
...
@@ -1136,7 +1147,7 @@ void gribDateTime(int *isec1, int *date, int *time)
julday_add_seconds
(
addsec
,
&
julday
,
&
secofday
);
decode_
ju
ldaysec
(
0
,
julday
,
secofday
,
&
ryear
,
&
rmonth
,
&
rday
,
&
rhour
,
&
rminute
);
decode_
ca
ldaysec
(
grib_calendar
,
julday
,
secofday
,
&
ryear
,
&
rmonth
,
&
rday
,
&
rhour
,
&
rminute
,
&
second
);
}
/*
printf("new %d/%d/%d %d:%d\n", ryear, rmonth, rday, rhour, rminute);
...
...
@@ -6713,6 +6724,13 @@ int num2ok;
int
next2o
;
int
nloc2o
;
int
nsubce
;
int
grib_calendar
=
-
1
;
void
gribSetCalendar
(
int
calendar
)
{
grib_calendar
=
calendar
;
}
void
grsdef
(
void
)
...
...
@@ -6785,7 +6803,7 @@ C ----------------------------------------------------------------
C* Section 0 . Definition of variables.
C ----------------------------------------------------------------
*/
char
*
hndbg
,
*
hnvck
;
char
*
hndbg
,
*
hnvck
,
*
envString
;
char
*
env_stream
;
static
int
lfirst
=
TRUE
;
...
...
@@ -6818,6 +6836,30 @@ C ----------------------------------------------------------------
Set rounding to 120 bytes on.
*/
nrnd
=
1
;
/*
Set GRIB calendar.
*/
if
(
grib_calendar
==
-
1
)
{
grib_calendar
=
CALENDAR_PROLEPTIC
;
envString
=
getenv
(
"GRIB_CALENDAR"
);
if
(
envString
)
{
if
(
strncmp
(
envString
,
"standard"
,
8
)
==
0
)
grib_calendar
=
CALENDAR_STANDARD
;
else
if
(
strncmp
(
envString
,
"proleptic"
,
9
)
==
0
)
grib_calendar
=
CALENDAR_PROLEPTIC
;
else
if
(
strncmp
(
envString
,
"360days"
,
7
)
==
0
)
grib_calendar
=
CALENDAR_360DAYS
;
else
if
(
strncmp
(
envString
,
"365days"
,
7
)
==
0
)
grib_calendar
=
CALENDAR_365DAYS
;
else
if
(
strncmp
(
envString
,
"366days"
,
7
)
==
0
)
grib_calendar
=
CALENDAR_366DAYS
;
else
if
(
strncmp
(
envString
,
"none"
,
4
)
==
0
)
grib_calendar
=
CALENDAR_NONE
;
}
}
/*
Set debug print off.
*/
...
...
@@ -8312,6 +8354,149 @@ void gribPrintBDS(int nrec, long recpos, long recsize, unsigned char *gribbuffer
}
}
void
gribCheck1
(
int
nrec
,
long
recpos
,
long
recsize
,
unsigned
char
*
gribbuffer
)
{
int
level
,
nerr
;
unsigned
char
*
pds
=
NULL
,
*
gds
=
NULL
,
*
bms
=
NULL
,
*
bds
=
NULL
;
double
cr
=
1
;
nerr
=
grib1Sections
(
gribbuffer
,
recsize
,
&
pds
,
&
gds
,
&
bms
,
&
bds
);
if
(
nerr
)
{
fprintf
(
stdout
,
"%5d : error
\n
"
,
nrec
);
return
;
}
if
(
PDS_LevelType
==
100
)
level
=
PDS_Level
*
100
;
else
if
(
PDS_LevelType
==
99
)
level
=
PDS_Level
;
else
level
=
PDS_Level1
;
if
(
(
BDS_Flag
>>
4
)
&
1
&&
BDS_Z
==
128
)
{
int
s1
,
s2
;
s1
=
((
int
)
((
bds
[
17
]
<<
16
)
+
(
bds
[
18
]
<<
8
)
+
bds
[
19
]));
s2
=
((
int
)
((
bds
[
20
]
<<
16
)
+
(
bds
[
21
]
<<
8
)
+
bds
[
22
]));
cr
=
((
double
)
s1
)
/
s2
;
}
if
(
cr
==
1
&&
BDS_NumBits
==
24
)
{
fprintf
(
stdout
,
"GRIB record %5d : code = %4d level = %7d
\n
"
,
nrec
,
PDS_Parameter
,
level
);
}
}
static
void
repair1
(
unsigned
char
*
gbuf
,
long
gbufsize
)
{
static
char
func
[]
=
"repair1"
;
long
i
;
int
nerr
;
unsigned
char
*
pds
=
NULL
,
*
gds
=
NULL
,
*
bms
=
NULL
,
*
bds
=
NULL
;
int
recLen
;
unsigned
char
*
source
;
size_t
sourceLen
;
int
bds_len
,
bds_nbits
,
bds_flag
,
lspherc
,
lcomplex
,
lcompress
;
int
bds_head
=
11
;
int
bds_ext
=
0
,
bds_ubits
;
int
datstart
=
0
;
int
llarge
=
FALSE
;
nerr
=
grib1Sections
(
gbuf
,
gbufsize
,
&
pds
,
&
gds
,
&
bms
,
&
bds
);
if
(
nerr
)
{
fprintf
(
stdout
,
"grib1Sections error
\n
"
);
}
recLen
=
gribrec_len
(
gbuf
[
4
],
gbuf
[
5
],
gbuf
[
6
]);
if
(
recLen
>
JP23SET
)
llarge
=
TRUE
;
bds_len
=
BDS_Len
;
bds_nbits
=
BDS_NumBits
;
bds_flag
=
BDS_Flag
;
bds_ubits
=
bds_flag
&
15
;
lspherc
=
bds_flag
>>
7
;
lcomplex
=
(
bds_flag
>>
6
)
&
1
;
lcompress
=
(
bds_flag
>>
4
)
&
1
;
if
(
lspherc
)
{
if
(
lcomplex
)
{
int
jup
,
ioff
;
jup
=
bds
[
15
];
ioff
=
(
jup
+
1
)
*
(
jup
+
2
);
bds_ext
=
4
+
3
+
4
*
ioff
;
}
else
{
bds_ext
=
4
;
}
}
datstart
=
bds_head
+
bds_ext
;
source
=
(
char
*
)
bds
+
datstart
;
sourceLen
=
((((
bds_len
-
datstart
)
*
8
-
bds_ubits
)
/
bds_nbits
)
*
bds_nbits
)
/
8
;
if
(
bds_nbits
==
24
)
{
long
nelem
;
unsigned
char
*
pbuf
;
nelem
=
sourceLen
/
3
;
pbuf
=
(
unsigned
char
*
)
malloc
(
sourceLen
);
for
(
i
=
0
;
i
<
nelem
;
i
++
)
{
pbuf
[
3
*
i
]
=
source
[
i
];
pbuf
[
3
*
i
+
1
]
=
source
[
nelem
+
i
];
pbuf
[
3
*
i
+
2
]
=
source
[
2
*
nelem
+
i
];
}
memcpy
(
source
,
pbuf
,
sourceLen
);
free
(
pbuf
);
}
}
void
gribRepair1
(
int
nrec
,
long
recpos
,
long
recsize
,
unsigned
char
*
gribbuffer
)
{
int
level
,
nerr
;
unsigned
char
*
pds
=
NULL
,
*
gds
=
NULL
,
*
bms
=
NULL
,
*
bds
=
NULL
;
double
cr
=
1
;
nerr
=
grib1Sections
(
gribbuffer
,
recsize
,
&
pds
,
&
gds
,
&
bms
,
&
bds
);
if
(
nerr
)
{
fprintf
(
stdout
,
"%5d : error
\n
"
,
nrec
);
return
;
}
if
(
PDS_LevelType
==
100
)
level
=
PDS_Level
*
100
;
else
if
(
PDS_LevelType
==
99
)
level
=
PDS_Level
;
else
level
=
PDS_Level1
;
if
(
(
BDS_Flag
>>
4
)
&
1
&&
BDS_Z
==
128
)
{
int
s1
,
s2
;
s1
=
((
int
)
((
bds
[
17
]
<<
16
)
+
(
bds
[
18
]
<<
8
)
+
bds
[
19
]));
s2
=
((
int
)
((
bds
[
20
]
<<
16
)
+
(
bds
[
21
]
<<
8
)
+
bds
[
22
]));
cr
=
((
double
)
s1
)
/
s2
;
}
if
(
cr
==
1
&&
BDS_NumBits
==
24
)
{
fprintf
(
stdout
,
"Repair GRIB record %5d : code = %4d level = %7d
\n
"
,
nrec
,
PDS_Parameter
,
level
);
repair1
(
gribbuffer
,
recsize
);
}
}
#if defined (HAVE_CONFIG_H)
# include "config.h"
#endif
...
...
@@ -8876,7 +9061,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
return
(
gribLen
);
}
static
const
char
grb_libvers
[]
=
"1.4.5.
1
"
" of ""Jul
5
2010"" ""
09:21:38
"
;
static
const
char
grb_libvers
[]
=
"1.4.5.
2
"
" of ""Jul
19
2010"" ""
10:04:01
"
;
const
char
*
cgribexLibraryVersion
(
void
)
{
...
...
src/stream_int.c
View file @
cf1c2ee2
...
...
@@ -180,6 +180,7 @@ void cdiInitialize(void)
if
(
CDI_Debug
)
Message
(
func
,
"Default calendar set to %s!"
,
envString
);
}
gribSetCalendar
(
cdiDefaultCalendar
);
envString
=
getenv
(
"PARTAB_INTERN"
);
if
(
envString
)
cdiPartabIntern
=
atoi
(
envString
);
...
...
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