Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
8245b614
Commit
8245b614
authored
Jul 12, 2019
by
Uwe Schulzweida
Browse files
cdfDefRgrid: write reduced_points.
parent
31063c1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stream_cdf_o.c
View file @
8245b614
...
...
@@ -437,7 +437,6 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
void
(
*
finishCyclicBounds
)(
double
*
pbounds
,
size_t
dimlen
,
const
double
*
pvals
))
{
int
dimID
=
CDI_UNDEFID
;
int
ncvarid
=
CDI_UNDEFID
,
ncbvarid
=
CDI_UNDEFID
;
const
int
fileID
=
streamptr
->
fileID
;
const
size_t
dimlen
=
gridAxisInq
->
axisSize
(
gridID
);
const
nc_type
xtype
=
(
nc_type
)
cdfDefDatatype
(
gridInqDatatype
(
gridID
),
streamptr
);
...
...
@@ -477,6 +476,7 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
if
(
dimID
==
CDI_UNDEFID
)
{
int
ncvarid
=
CDI_UNDEFID
,
ncbvarid
=
CDI_UNDEFID
;
char
axisname
[
CDI_MAX_NAME
];
axisname
[
0
]
=
0
;
const
int
keyname
=
(
axisLetter
==
'X'
)
?
CDI_KEY_XNAME
:
CDI_KEY_YNAME
;
gridAxisInq
->
axisName
(
gridID
,
keyname
,
CDI_MAX_NAME
,
axisname
);
...
...
@@ -1755,39 +1755,81 @@ void cdfDefRgrid(stream_t *streamptr, int gridID, int gridindex)
{
ncgrid_t
*
ncgrid
=
streamptr
->
ncgrid
;
const
size_t
dimlen
=
gridInqSize
(
gridID
)
;
ncgrid
[
gridindex
].
gridID
=
gridID
;
struct
idSearch
search
=
cdfSearchIDBySize
(
0
,
(
size_t
)
gridindex
,
ncgrid
,
CDF_DIMID_X
,
GRID_GAUSSIAN_REDUCED
,
(
int
)
dimlen
,
gridInqType
,
gridInqSize
);
const
int
iz
=
search
.
numNonMatching
;
int
dimID
=
search
.
foundID
;
{
const
size_t
dimlen
=
gridInqSize
(
gridID
);
if
(
dimID
==
CDI_UNDEFID
)
{
const
int
fileID
=
streamptr
->
fileID
;
static
bool
lwarn
=
true
;
if
(
lwarn
)
{
Warning
(
"Creating a NetCDF file with data on a gaussian reduced grid."
);
Warning
(
"The further processing of the resulting file is unsupported!"
);
lwarn
=
false
;
}
struct
idSearch
search
=
cdfSearchIDBySize
(
0
,
(
size_t
)
gridindex
,
ncgrid
,
CDF_DIMID_X
,
GRID_GAUSSIAN_REDUCED
,
(
int
)
dimlen
,
gridInqType
,
gridInqSize
);
const
int
iz
=
search
.
numNonMatching
;
int
dimID
=
search
.
foundID
;
char
axisname
[
16
]
=
"rgridX"
;
if
(
iz
==
0
)
axisname
[
5
]
=
'\0'
;
else
sprintf
(
&
axisname
[
5
],
"%1d"
,
iz
+
1
);
if
(
dimID
==
CDI_UNDEFID
)
{
const
int
fileID
=
streamptr
->
fileID
;
static
bool
lwarn
=
true
;
if
(
lwarn
)
{
Warning
(
"Creating a NetCDF file with data on a gaussian reduced grid."
);
Warning
(
"The further processing of the resulting file is unsupported!"
);
lwarn
=
false
;
}
if
(
streamptr
->
ncmode
==
2
)
cdf_redef
(
fileID
);
char
axisname
[
16
]
=
"rgridX"
;
if
(
iz
==
0
)
axisname
[
5
]
=
'\0'
;
else
sprintf
(
&
axisname
[
5
],
"%1d"
,
iz
+
1
);
cdf_def_dim
(
fileID
,
axisname
,
dimlen
,
&
dim
ID
);
if
(
streamptr
->
ncmode
==
2
)
cdf_redef
(
file
ID
);
cdf_enddef
(
fileID
);
streamptr
->
ncmode
=
2
;
}
cdf_def_dim
(
fileID
,
axisname
,
dimlen
,
&
dimID
);
ncgrid
[
gridindex
].
gridID
=
gridID
;
ncgrid
[
gridindex
].
ncIDs
[
CDF_DIMID_X
]
=
dimID
;
cdf_enddef
(
fileID
);
streamptr
->
ncmode
=
2
;
}
ncgrid
[
gridindex
].
ncIDs
[
CDF_DIMID_X
]
=
dimID
;
}
{
const
size_t
dimlen
=
gridInqYsize
(
gridID
);
struct
idSearch
search
=
cdfSearchIDBySize
(
0
,
(
size_t
)
gridindex
,
ncgrid
,
CDF_DIMID_RP
,
GRID_GAUSSIAN_REDUCED
,
(
int
)
dimlen
,
gridInqType
,
gridInqSize
);
const
int
iz
=
search
.
numNonMatching
;
int
dimID
=
search
.
foundID
;
if
(
dimID
==
CDI_UNDEFID
)
{
const
int
fileID
=
streamptr
->
fileID
;
char
axisname
[
32
]
=
"reduced_pointsX"
;
if
(
iz
==
0
)
axisname
[
14
]
=
'\0'
;
else
sprintf
(
&
axisname
[
5
],
"%1d"
,
iz
+
1
);
if
(
streamptr
->
ncmode
==
2
)
cdf_redef
(
fileID
);
cdf_def_dim
(
fileID
,
axisname
,
dimlen
,
&
dimID
);
int
ncvarid
=
CDI_UNDEFID
;
int
ndims
=
1
;
const
nc_type
xtype
=
NC_INT
;
cdf_def_var
(
fileID
,
axisname
,
xtype
,
ndims
,
&
dimID
,
&
ncvarid
);
cdf_enddef
(
fileID
);
streamptr
->
ncmode
=
2
;
int
*
reducedPoints
=
(
int
*
)
Malloc
(
dimlen
*
sizeof
(
int
));
gridInqReducedPoints
(
gridID
,
reducedPoints
);
cdf_put_var_int
(
fileID
,
ncvarid
,
reducedPoints
);
Free
(
reducedPoints
);
ncgrid
[
gridindex
].
ncIDs
[
CDF_VARID_RP
]
=
ncvarid
;
}
ncgrid
[
gridindex
].
ncIDs
[
CDF_DIMID_RP
]
=
dimID
;
}
}
static
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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