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
90611d88
Commit
90611d88
authored
Jul 08, 2016
by
Uwe Schulzweida
Browse files
Added function cdf_set_unstructured_par().
parent
90d01888
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/stream_cdf_i.c
View file @
90611d88
...
...
@@ -2031,6 +2031,55 @@ void cdf_check_gridtype(int *gridtype, bool islon, bool islat, size_t xsize, siz
*
gridtype
=
GRID_GENERIC
;
}
static
bool
cdf_set_unstructured_par
(
ncvar_t
*
ncvar
,
grid_t
*
grid
,
int
xdimid
,
int
ydimid
,
unsigned
char
*
uuidOfHGrid
)
{
int
ndims
=
ncvar
->
ndims
;
int
*
dimtype
=
ncvar
->
dimtype
;
int
zdimid
=
UNDEFID
;
int
xdimidx
=
UNDEFID
,
ydimidx
=
UNDEFID
;
for
(
int
i
=
0
;
i
<
ndims
;
i
++
)
{
if
(
dimtype
[
i
]
==
X_AXIS
)
xdimidx
=
i
;
else
if
(
dimtype
[
i
]
==
Y_AXIS
)
ydimidx
=
i
;
else
if
(
dimtype
[
i
]
==
Z_AXIS
)
zdimid
=
ncvar
->
dimids
[
i
];
}
if
(
xdimid
!=
UNDEFID
&&
ydimid
!=
UNDEFID
&&
zdimid
==
UNDEFID
)
{
if
(
grid
->
x
.
size
>
grid
->
y
.
size
&&
grid
->
y
.
size
<
1000
)
{
dimtype
[
ydimidx
]
=
Z_AXIS
;
ydimid
=
UNDEFID
;
grid
->
size
=
grid
->
x
.
size
;
grid
->
y
.
size
=
0
;
}
else
if
(
grid
->
y
.
size
>
grid
->
x
.
size
&&
grid
->
x
.
size
<
1000
)
{
dimtype
[
xdimidx
]
=
Z_AXIS
;
xdimid
=
ydimid
;
ydimid
=
UNDEFID
;
grid
->
size
=
grid
->
y
.
size
;
grid
->
x
.
size
=
grid
->
y
.
size
;
grid
->
y
.
size
=
0
;
}
}
if
(
grid
->
size
!=
grid
->
x
.
size
)
{
Warning
(
"Unsupported array structure, skipped variable %s!"
,
ncvar
->
name
);
ncvar
->
isvar
=
-
1
;
return
true
;
}
if
(
ncvar
->
position
>
0
)
grid
->
position
=
ncvar
->
position
;
if
(
uuidOfHGrid
[
0
]
!=
0
)
memcpy
(
grid
->
uuid
,
uuidOfHGrid
,
16
);
return
false
;
}
static
void
cdf_set_proj_atts
(
int
ncid
,
int
gmapvarid
,
grid_t
*
grid
)
{
...
...
@@ -2543,55 +2592,13 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
}
if
(
grid
->
type
==
GRID_UNSTRUCTURED
)
{
int
zdimid
=
UNDEFID
;
int
xdimidx
=
UNDEFID
,
ydimidx
=
UNDEFID
;
for
(
int
i
=
0
;
i
<
ndims
;
i
++
)
{
if
(
dimtype
[
i
]
==
X_AXIS
)
xdimidx
=
i
;
else
if
(
dimtype
[
i
]
==
Y_AXIS
)
ydimidx
=
i
;
else
if
(
dimtype
[
i
]
==
Z_AXIS
)
zdimid
=
ncvar
->
dimids
[
i
];
}
if
(
xdimid
!=
UNDEFID
&&
ydimid
!=
UNDEFID
&&
zdimid
==
UNDEFID
)
{
if
(
grid
->
x
.
size
>
grid
->
y
.
size
&&
grid
->
y
.
size
<
1000
)
{
dimtype
[
ydimidx
]
=
Z_AXIS
;
ydimid
=
UNDEFID
;
grid
->
size
=
grid
->
x
.
size
;
grid
->
y
.
size
=
0
;
}
else
if
(
grid
->
y
.
size
>
grid
->
x
.
size
&&
grid
->
x
.
size
<
1000
)
{
dimtype
[
xdimidx
]
=
Z_AXIS
;
xdimid
=
ydimid
;
ydimid
=
UNDEFID
;
grid
->
size
=
grid
->
y
.
size
;
grid
->
x
.
size
=
grid
->
y
.
size
;
grid
->
y
.
size
=
0
;
}
}
if
(
grid
->
size
!=
grid
->
x
.
size
)
{
Warning
(
"Unsupported array structure, skipped variable %s!"
,
ncvar
->
name
);
ncvar
->
isvar
=
-
1
;
continue
;
}
if
(
ncvar
->
position
>
0
)
grid
->
position
=
ncvar
->
position
;
if
(
uuidOfHGrid
[
0
]
!=
0
)
memcpy
(
grid
->
uuid
,
uuidOfHGrid
,
16
);
}
if
(
cdf_set_unstructured_par
(
ncvar
,
grid
,
xdimid
,
ydimid
,
uuidOfHGrid
)
)
continue
;
#if defined (PROJECTION_TEST)
if
(
proj
->
type
==
GRID_PROJECTION
)
{
if
(
grid
->
type
==
GRID_GENERIC
)
{
grid
->
type
=
GRID_CURVILINEAR
;
}
if
(
grid
->
type
==
GRID_GENERIC
)
grid
->
type
=
GRID_CURVILINEAR
;
if
(
grid
->
type
==
GRID_CURVILINEAR
)
{
...
...
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