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
cef79787
Commit
cef79787
authored
Jul 22, 2016
by
Uwe Schulzweida
Browse files
Call cdfDefGrid() for 2nd grid (projection).
parent
13e793ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stream_cdf_o.c
View file @
cef79787
...
@@ -700,9 +700,8 @@ static void
...
@@ -700,9 +700,8 @@ static void
cdfDefAxisCommon
(
stream_t
*
streamptr
,
int
gridID
,
int
ndims
,
cdfDefAxisCommon
(
stream_t
*
streamptr
,
int
gridID
,
int
ndims
,
const
struct
cdfDefGridAxisInqs
*
gridAxisInq
,
const
struct
cdfDefGridAxisInqs
*
gridAxisInq
,
int
*
axisDimIDs
,
int
dimKey
,
char
axisLetter
,
int
*
axisDimIDs
,
int
dimKey
,
char
axisLetter
,
void
(
*
finishCyclicBounds
)(
double
*
pbounds
,
size_t
dimlen
,
void
(
*
finishCyclicBounds
)(
double
*
pbounds
,
size_t
dimlen
,
const
double
*
pvals
),
const
double
*
pvals
),
int
*
ncAxisVarIDs
,
bool
lstore
)
int
*
ncAxisVarIDs
)
{
{
int
dimID
=
UNDEFID
;
int
dimID
=
UNDEFID
;
int
ngrids
=
0
;
int
ngrids
=
0
;
...
@@ -716,7 +715,8 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int ndims,
...
@@ -716,7 +715,8 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int ndims,
if
(
ndims
)
ngrids
=
vlistNgrids
(
vlistID
);
if
(
ndims
)
ngrids
=
vlistNgrids
(
vlistID
);
size_t
dimlen
=
(
size_t
)
gridAxisInq
->
axisSize
(
gridID
);
size_t
dimlen
=
(
size_t
)
gridAxisInq
->
axisSize
(
gridID
);
int
gridindex
=
vlistGridIndex
(
vlistID
,
gridID
);
int
gridindex
=
-
1
;
if
(
lstore
)
gridindex
=
vlistGridIndex
(
vlistID
,
gridID
);
const
char
*
axisname
=
gridAxisInq
->
axisNamePtr
(
gridID
);
const
char
*
axisname
=
gridAxisInq
->
axisNamePtr
(
gridID
);
size_t
axisnameLen
=
strlen
(
axisname
);
size_t
axisnameLen
=
strlen
(
axisname
);
...
@@ -731,14 +731,14 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int ndims,
...
@@ -731,14 +731,14 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int ndims,
int
gridtype0
=
gridInqType
(
gridID0
);
int
gridtype0
=
gridInqType
(
gridID0
);
if
(
gridtype0
==
GRID_GAUSSIAN
||
if
(
gridtype0
==
GRID_GAUSSIAN
||
gridtype0
==
GRID_LONLAT
||
gridtype0
==
GRID_LONLAT
||
gridtype0
==
GRID_PROJECTION
||
gridtype0
==
GRID_CURVILINEAR
||
gridtype0
==
GRID_CURVILINEAR
||
gridtype0
==
GRID_GENERIC
)
gridtype0
==
GRID_GENERIC
)
{
{
size_t
dimlen0
=
(
size_t
)
gridAxisInq
->
axisSize
(
gridID0
);
size_t
dimlen0
=
(
size_t
)
gridAxisInq
->
axisSize
(
gridID0
);
if
(
dimlen
==
dimlen0
)
if
(
dimlen
==
dimlen0
)
{
{
double
(
*
inqVal
)(
int
gridID
,
int
index
)
double
(
*
inqVal
)(
int
gridID
,
int
index
)
=
gridAxisInq
->
axisVal
;
=
gridAxisInq
->
axisVal
;
if
(
IS_EQUAL
(
inqVal
(
gridID0
,
0
),
inqVal
(
gridID
,
0
))
&&
if
(
IS_EQUAL
(
inqVal
(
gridID0
,
0
),
inqVal
(
gridID
,
0
))
&&
IS_EQUAL
(
inqVal
(
gridID0
,
(
int
)
dimlen
-
1
),
inqVal
(
gridID
,
(
int
)
dimlen
-
1
))
)
IS_EQUAL
(
inqVal
(
gridID0
,
(
int
)
dimlen
-
1
),
inqVal
(
gridID
,
(
int
)
dimlen
-
1
))
)
{
{
...
@@ -758,15 +758,13 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int ndims,
...
@@ -758,15 +758,13 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int ndims,
char
extendedAxisname
[
axisnameLen
+
4
+
1
];
char
extendedAxisname
[
axisnameLen
+
4
+
1
];
memcpy
(
extendedAxisname
,
axisname
,
axisnameLen
+
1
);
memcpy
(
extendedAxisname
,
axisname
,
axisnameLen
+
1
);
checkGridName
(
extendedAxisname
,
fileID
,
vlistID
,
gridID
,
ngrids
,
axisLetter
);
checkGridName
(
extendedAxisname
,
fileID
,
vlistID
,
gridID
,
ngrids
,
axisLetter
);
size_t
extendedAxisnameLen
size_t
extendedAxisnameLen
=
axisnameLen
+
strlen
(
extendedAxisname
+
axisnameLen
);
=
axisnameLen
+
strlen
(
extendedAxisname
+
axisnameLen
);
if
(
streamptr
->
ncmode
==
2
)
cdf_redef
(
fileID
);
if
(
streamptr
->
ncmode
==
2
)
cdf_redef
(
fileID
);
if
(
ndims
)
if
(
ndims
)
{
{
char
dimname
[
CDI_MAX_NAME
+
3
];
char
dimname
[
CDI_MAX_NAME
+
3
];
dimname
[
0
]
=
0
;
dimname
[
0
]
=
0
;
if
(
pvals
==
NULL
)
if
(
pvals
==
NULL
)
cdiGridInqKeyStr
(
gridID
,
dimKey
,
CDI_MAX_NAME
,
dimname
);
cdiGridInqKeyStr
(
gridID
,
dimKey
,
CDI_MAX_NAME
,
dimname
);
...
@@ -828,10 +826,10 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int ndims,
...
@@ -828,10 +826,10 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int ndims,
if
(
ncbvarid
!=
UNDEFID
)
cdf_put_var_double
(
fileID
,
ncbvarid
,
pbounds
);
if
(
ncbvarid
!=
UNDEFID
)
cdf_put_var_double
(
fileID
,
ncbvarid
,
pbounds
);
if
(
gen_bounds
)
Free
(
pbounds
);
if
(
gen_bounds
)
Free
(
pbounds
);
if
(
ndims
==
0
)
ncAxisVarIDs
[
gridindex
]
=
ncvarid
;
if
(
ndims
==
0
&&
lstore
)
ncAxisVarIDs
[
gridindex
]
=
ncvarid
;
}
}
axisDimIDs
[
gridindex
]
=
dimID
;
if
(
lstore
)
axisDimIDs
[
gridindex
]
=
dimID
;
}
}
static
void
static
void
...
@@ -842,11 +840,11 @@ finishCyclicXBounds(double *pbounds, size_t dimlen, const double *pvals)
...
@@ -842,11 +840,11 @@ finishCyclicXBounds(double *pbounds, size_t dimlen, const double *pvals)
}
}
static
static
void
cdfDefXaxis
(
stream_t
*
streamptr
,
int
gridID
,
int
ndims
)
void
cdfDefXaxis
(
stream_t
*
streamptr
,
int
gridID
,
int
ndims
,
bool
lstore
)
{
{
cdfDefAxisCommon
(
streamptr
,
gridID
,
ndims
,
&
gridInqsX
,
streamptr
->
xdimID
,
cdfDefAxisCommon
(
streamptr
,
gridID
,
ndims
,
&
gridInqsX
,
streamptr
->
xdimID
,
CDI_KEY_XDIMNAME
,
'X'
,
finishCyclicXBounds
,
CDI_KEY_XDIMNAME
,
'X'
,
finishCyclicXBounds
,
streamptr
->
ncxvarID
);
streamptr
->
ncxvarID
,
lstore
);
}
}
static
void
static
void
...
@@ -857,11 +855,11 @@ finishCyclicYBounds(double *pbounds, size_t dimlen, const double *pvals)
...
@@ -857,11 +855,11 @@ finishCyclicYBounds(double *pbounds, size_t dimlen, const double *pvals)
}
}
static
static
void
cdfDefYaxis
(
stream_t
*
streamptr
,
int
gridID
,
int
ndims
)
void
cdfDefYaxis
(
stream_t
*
streamptr
,
int
gridID
,
int
ndims
,
bool
lstore
)
{
{
cdfDefAxisCommon
(
streamptr
,
gridID
,
ndims
,
&
gridInqsY
,
streamptr
->
ydimID
,
cdfDefAxisCommon
(
streamptr
,
gridID
,
ndims
,
&
gridInqsY
,
streamptr
->
ydimID
,
CDI_KEY_YDIMNAME
,
'Y'
,
finishCyclicYBounds
,
CDI_KEY_YDIMNAME
,
'Y'
,
finishCyclicYBounds
,
streamptr
->
ncyvarID
);
streamptr
->
ncyvarID
,
lstore
);
}
}
static
static
...
@@ -2071,11 +2069,14 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
...
@@ -2071,11 +2069,14 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
}
}
static
static
void
cdfDefGrid
(
stream_t
*
streamptr
,
int
gridID
)
void
cdfDefGrid
(
stream_t
*
streamptr
,
int
gridID
,
bool
lstore
)
{
{
int
vlistID
=
streamptr
->
vlistID
;
if
(
lstore
)
int
gridindex
=
vlistGridIndex
(
vlistID
,
gridID
);
{
if
(
streamptr
->
xdimID
[
gridindex
]
!=
UNDEFID
)
return
;
int
vlistID
=
streamptr
->
vlistID
;
int
gridindex
=
vlistGridIndex
(
vlistID
,
gridID
);
if
(
streamptr
->
xdimID
[
gridindex
]
!=
UNDEFID
)
return
;
}
int
gridtype
=
gridInqType
(
gridID
);
int
gridtype
=
gridInqType
(
gridID
);
int
size
=
gridInqSize
(
gridID
);
int
size
=
gridInqSize
(
gridID
);
...
@@ -2099,13 +2100,13 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
...
@@ -2099,13 +2100,13 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
int
lx
=
0
,
ly
=
0
;
int
lx
=
0
,
ly
=
0
;
if
(
gridInqXsize
(
gridID
)
>
0
/*&& gridInqXvals(gridID, NULL) > 0*/
)
if
(
gridInqXsize
(
gridID
)
>
0
/*&& gridInqXvals(gridID, NULL) > 0*/
)
{
{
cdfDefXaxis
(
streamptr
,
gridID
,
1
);
cdfDefXaxis
(
streamptr
,
gridID
,
1
,
lstore
);
lx
=
1
;
lx
=
1
;
}
}
if
(
gridInqYsize
(
gridID
)
>
0
/*&& gridInqYvals(gridID, NULL) > 0*/
)
if
(
gridInqYsize
(
gridID
)
>
0
/*&& gridInqYvals(gridID, NULL) > 0*/
)
{
{
cdfDefYaxis
(
streamptr
,
gridID
,
1
);
cdfDefYaxis
(
streamptr
,
gridID
,
1
,
lstore
);
ly
=
1
;
ly
=
1
;
}
}
...
@@ -2118,8 +2119,8 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
...
@@ -2118,8 +2119,8 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
if
(
gridtype
==
GRID_LONLAT
&&
size
==
1
&&
gridInqHasDims
(
gridID
)
==
FALSE
)
if
(
gridtype
==
GRID_LONLAT
&&
size
==
1
&&
gridInqHasDims
(
gridID
)
==
FALSE
)
ndims
=
0
;
ndims
=
0
;
if
(
gridInqXsize
(
gridID
)
>
0
)
cdfDefXaxis
(
streamptr
,
gridID
,
ndims
);
if
(
gridInqXsize
(
gridID
)
>
0
)
cdfDefXaxis
(
streamptr
,
gridID
,
ndims
,
lstore
);
if
(
gridInqYsize
(
gridID
)
>
0
)
cdfDefYaxis
(
streamptr
,
gridID
,
ndims
);
if
(
gridInqYsize
(
gridID
)
>
0
)
cdfDefYaxis
(
streamptr
,
gridID
,
ndims
,
lstore
);
cdf_def_mapping
(
streamptr
,
gridID
);
cdf_def_mapping
(
streamptr
,
gridID
);
}
}
...
@@ -2155,8 +2156,8 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
...
@@ -2155,8 +2156,8 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
}
}
else
if
(
gridtype
==
GRID_SINUSOIDAL
||
gridtype
==
GRID_LAEA
||
gridtype
==
GRID_LCC2
)
else
if
(
gridtype
==
GRID_SINUSOIDAL
||
gridtype
==
GRID_LAEA
||
gridtype
==
GRID_LCC2
)
{
{
cdfDefXaxis
(
streamptr
,
gridID
,
1
);
cdfDefXaxis
(
streamptr
,
gridID
,
1
,
true
);
cdfDefYaxis
(
streamptr
,
gridID
,
1
);
cdfDefYaxis
(
streamptr
,
gridID
,
1
,
true
);
cdfDefMapping
(
streamptr
,
gridID
);
cdfDefMapping
(
streamptr
,
gridID
);
}
}
...
@@ -2191,9 +2192,9 @@ void cdfDefVars(stream_t *streamptr)
...
@@ -2191,9 +2192,9 @@ void cdfDefVars(stream_t *streamptr)
for
(
int
index
=
0
;
index
<
ngrids
;
index
++
)
for
(
int
index
=
0
;
index
<
ngrids
;
index
++
)
{
{
int
gridID
=
vlistGrid
(
vlistID
,
index
);
int
gridID
=
vlistGrid
(
vlistID
,
index
);
cdfDefGrid
(
streamptr
,
gridID
);
cdfDefGrid
(
streamptr
,
gridID
,
true
);
int
projID
=
gridInqProj
(
gridID
);
int
projID
=
gridInqProj
(
gridID
);
//
if ( projID != CDI_UNDEFID ) cdfDefGrid(streamptr, projID);
if
(
projID
!=
CDI_UNDEFID
)
cdfDefGrid
(
streamptr
,
projID
,
false
);
}
}
int
nzaxis
=
vlistNzaxis
(
vlistID
);
int
nzaxis
=
vlistNzaxis
(
vlistID
);
...
...
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