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
9e265752
Commit
9e265752
authored
Jan 31, 2018
by
Uwe Schulzweida
Browse files
Added gribapiDefGridSpectral().
parent
8edb2be3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stream_gribapi.c
View file @
9e265752
...
...
@@ -2074,6 +2074,23 @@ void gribapiDefGridUnstructured(grib_handle *gh, int gridID)
}
}
static
void
gribapiDefGridSpectral
(
grib_handle
*
gh
,
int
gridID
)
{
int
trunc
=
gridInqTrunc
(
gridID
);
enum
{
numTruncAtt
=
3
};
static
const
char
truncAttNames
[
numTruncAtt
][
2
]
=
{
"J"
,
"K"
,
"M"
};
for
(
size_t
i
=
0
;
i
<
numTruncAtt
;
++
i
)
GRIB_CHECK
(
my_grib_set_long
(
gh
,
truncAttNames
[
i
],
trunc
),
0
);
if
(
gridInqComplexPacking
(
gridID
)
)
{
static
const
char
truncAttNames
[
numTruncAtt
][
3
]
=
{
"JS"
,
"KS"
,
"MS"
};
for
(
size_t
i
=
0
;
i
<
numTruncAtt
;
++
i
)
GRIB_CHECK
(
my_grib_set_long
(
gh
,
truncAttNames
[
i
],
20
),
0
);
}
}
static
void
gribapiDefPackingType
(
grib_handle
*
gh
,
bool
lieee
,
bool
lspectral
,
bool
lcomplex
,
int
comptype
,
size_t
gridsize
)
{
...
...
@@ -2141,7 +2158,14 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
if
(
lieee
)
comptype
=
0
;
if
(
lspectral
)
lieee
=
false
;
if
(
gridtype
!=
GRID_SPECTRAL
)
gribapiDefPackingType
(
gh
,
lieee
,
lspectral
,
lcomplex
,
comptype
,
gridsize
);
if
(
lspectral
)
// gridType needs to be defined before packingType !!!
{
static
const
char
mesg
[]
=
"sh"
;
size_t
len
=
sizeof
(
mesg
)
-
1
;
GRIB_CHECK
(
my_grib_set_string
(
gh
,
"gridType"
,
mesg
,
&
len
),
0
);
}
gribapiDefPackingType
(
gh
,
lieee
,
lspectral
,
lcomplex
,
comptype
,
gridsize
);
if
(
lieee
)
GRIB_CHECK
(
my_grib_set_long
(
gh
,
"precision"
,
datatype
==
CDI_DATATYPE_FLT64
?
2
:
1
),
0
);
...
...
@@ -2164,36 +2188,7 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
}
case
GRID_SPECTRAL
:
{
{
static
const
char
mesg
[]
=
"sh"
;
size_t
len
=
sizeof
(
mesg
)
-
1
;
GRIB_CHECK
(
my_grib_set_string
(
gh
,
"gridType"
,
mesg
,
&
len
),
0
);
}
{
int
trunc
=
gridInqTrunc
(
gridID
);
enum
{
numTruncAtt
=
3
};
static
const
char
truncAttNames
[
numTruncAtt
][
2
]
=
{
"J"
,
"K"
,
"M"
};
for
(
size_t
i
=
0
;
i
<
numTruncAtt
;
++
i
)
GRIB_CHECK
(
my_grib_set_long
(
gh
,
truncAttNames
[
i
],
trunc
),
0
);
}
if
(
gridInqComplexPacking
(
gridID
)
)
{
static
const
char
mesg
[]
=
"spectral_complex"
;
size_t
len
=
sizeof
(
mesg
)
-
1
;
GRIB_CHECK
(
my_grib_set_string
(
gh
,
"packingType"
,
mesg
,
&
len
),
0
);
enum
{
numTruncAtt
=
3
};
static
const
char
truncAttNames
[
numTruncAtt
][
3
]
=
{
"JS"
,
"KS"
,
"MS"
};
for
(
size_t
i
=
0
;
i
<
numTruncAtt
;
++
i
)
GRIB_CHECK
(
my_grib_set_long
(
gh
,
truncAttNames
[
i
],
20
),
0
);
}
else
{
static
const
char
mesg
[]
=
"spectral_simple"
;
size_t
len
=
sizeof
(
mesg
)
-
1
;
GRIB_CHECK
(
my_grib_set_string
(
gh
,
"packingType"
,
mesg
,
&
len
),
0
);
}
gribapiDefGridSpectral
(
gh
,
gridID
);
break
;
}
case
GRID_GME
:
...
...
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