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
9fff214e
Commit
9fff214e
authored
Jul 16, 2016
by
Uwe Schulzweida
Browse files
cdiVlistAddGridIfNew: added mode 2.
parent
6805d45c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/grid.c
View file @
9fff214e
...
...
@@ -4750,12 +4750,13 @@ gridCompareSearch(int id, void *res, void *data)
return
CDI_APPLY_GO_ON
;
}
/* Add grid (which must be Malloc'ed to vlist if not already found */
/* Add grid (which must be Malloc'ed to vlist if not already found
)
*/
struct
addIfNewRes
cdiVlistAddGridIfNew
(
int
vlistID
,
grid_t
*
grid
,
int
mode
)
{
/*
mode: 0 search in vlist and grid table
1 search in grid table only
2 search in grid table only and don't store the grid in vlist
*/
bool
gridglobdefined
=
false
;
bool
griddefined
=
false
;
...
...
@@ -4804,8 +4805,11 @@ struct addIfNewRes cdiVlistAddGridIfNew(int vlistID, grid_t *grid, int mode)
grid
->
self
=
gridID
=
reshPut
(
grid
,
&
gridOps
);
gridComplete
(
grid
);
}
vlistptr
->
gridIDs
[
ngrids
]
=
gridID
;
vlistptr
->
ngrids
++
;
if
(
mode
<
2
)
{
vlistptr
->
gridIDs
[
ngrids
]
=
gridID
;
vlistptr
->
ngrids
++
;
}
}
return
(
struct
addIfNewRes
){
.
Id
=
gridID
,
.
isNew
=
!
griddefined
&&
!
gridglobdefined
};
...
...
src/stream_cdf_i.c
View file @
9fff214e
...
...
@@ -2547,13 +2547,14 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
int
*
dimtype
=
ncvar
->
dimtype
;
int
vdimid
=
UNDEFID
;
struct
addIfNewRes
projAdded
=
{
.
Id
=
CDI_UNDEFID
,
.
isNew
=
0
},
gridAdded
=
{
.
Id
=
CDI_UNDEFID
,
.
isNew
=
0
};
gridAdded
=
{
.
Id
=
CDI_UNDEFID
,
.
isNew
=
0
};
int
xdimid
=
UNDEFID
,
ydimid
=
UNDEFID
;
int
nydims
=
cdf_get_xydimid
(
ndims
,
ncvar
->
dimids
,
dimtype
,
&
xdimid
,
&
ydimid
);
if
(
ncvar
->
gridtype
==
UNDEFID
||
ncvar
->
gridtype
==
GRID_GENERIC
)
if
(
xdimid
!=
UNDEFID
&&
xdimid
==
ydimid
&&
nydims
==
0
)
ncvar
->
gridtype
=
GRID_UNSTRUCTURED
;
if
(
(
ncvar
->
gridtype
==
UNDEFID
||
ncvar
->
gridtype
==
GRID_GENERIC
)
&&
xdimid
!=
UNDEFID
&&
xdimid
==
ydimid
&&
nydims
==
0
)
ncvar
->
gridtype
=
GRID_UNSTRUCTURED
;
{
#ifdef TEST_PROJ_RLL
...
...
@@ -2625,8 +2626,8 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
if
(
lgrid
)
{
int
dumid
;
cdf_read_coordinates
(
lazyProj
,
ncvar
,
ncvars
,
ncdims
,
timedimid
,
xaxisid
,
yaxisid
,
xsize
,
ysize
,
&
dumid
);
cdf_read_coordinates
(
lazyProj
,
ncvar
,
ncvars
,
ncdims
,
timedimid
,
xaxisid
,
yaxisid
,
xsize
,
ysize
,
&
dumid
);
}
}
}
...
...
@@ -2640,61 +2641,59 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
}
gridAdded
=
cdiVlistAddGridIfNew
(
vlistID
,
grid
,
1
);
ncvar
->
gridID
=
gridAdded
.
Id
;
if
(
lgrid
&&
lproj
)
if
(
lgrid
&&
lproj
&&
testproj
)
{
if
(
testproj
)
projAdded
=
cdiVlistAddGridIfNew
(
vlistID
,
proj
,
2
);
int
projID
=
projAdded
.
Id
;
printf
(
"proj size = %d type %d
\n
"
,
gridInqSize
(
projID
),
gridInqType
(
projID
));
int
ncid
=
ncvars
[
gmapvarid
].
ncid
;
nc_type
atttype
;
size_t
attlen
;
char
attname
[
CDI_MAX_NAME
];
enum
{
attstringlen
=
8192
};
char
attstring
[
attstringlen
];
if
(
cdfCheckAttText
(
ncid
,
gmapvarid
,
"grid_mapping_name"
)
)
{
projAdded
=
cdiVlistAddGridIfNew
(
vlistID
,
proj
,
1
);
int
projID
=
projAdded
.
Id
;
printf
(
"proj size = %d type %d
\n
"
,
gridInqSize
(
projID
),
gridInqType
(
projID
));
cdfGetAttText
(
ncid
,
gmapvarid
,
"grid_mapping_name"
,
attstringlen
,
attstring
);
printf
(
"grid_mapping_name: %s
\n
"
,
attstring
);
}
else
{
Warning
(
"Text attribute %s:grid_mapping_name missing!"
,
ncvars
[
gmapvarid
].
name
);
}
int
ncid
=
ncvars
[
gmapvarid
].
ncid
;
nc_type
atttype
;
size_t
attlen
;
char
attname
[
CDI_MAX_NAME
];
enum
{
attstringlen
=
8192
};
char
attstring
[
attstringlen
];
int
nvatts
;
cdf_inq_varnatts
(
ncid
,
gmapvarid
,
&
nvatts
);
for
(
int
iatt
=
0
;
iatt
<
nvatts
;
iatt
++
)
{
cdf_inq_attname
(
ncid
,
gmapvarid
,
iatt
,
attname
);
cdf_inq_attlen
(
ncid
,
gmapvarid
,
attname
,
&
attlen
);
cdf_inq_atttype
(
ncid
,
gmapvarid
,
attname
,
&
atttype
);
if
(
cdfCheckAttText
(
ncid
,
gmapvarid
,
"grid_mapping_name"
)
)
if
(
xtypeIsInt
(
atttype
)
)
{
cdfGetAttText
(
ncid
,
gmapvarid
,
"grid_mapping_name"
,
attstringlen
,
attstring
);
printf
(
"grid_mapping_name: %s
\n
"
,
attstring
);
int
attint
[
attlen
];
cdfGetAttInt
(
ncid
,
gmapvarid
,
attname
,
(
int
)
attlen
,
attint
);
printf
(
"atttype: %d attname: %s attr: %d
\n
"
,
atttype
,
attname
,
attint
[
0
]);
}
else
else
if
(
xtypeIsFloat
(
atttype
)
)
{
Warning
(
"Text attribute %s:grid_mapping_name missing!"
,
ncvars
[
gmapvarid
].
name
);
double
attflt
[
attlen
];
cdfGetAttDouble
(
ncid
,
gmapvarid
,
attname
,
(
int
)
attlen
,
attflt
);
printf
(
"atttype: %d attname: %s attr: %g
\n
"
,
atttype
,
attname
,
attflt
[
0
]);
}
int
nvatts
;
cdf_inq_varnatts
(
ncid
,
gmapvarid
,
&
nvatts
);
for
(
int
iatt
=
0
;
iatt
<
nvatts
;
iatt
++
)
else
if
(
xtypeIsText
(
atttype
)
&&
strcmp
(
attname
,
"grid_mapping_name"
)
)
{
cdf_inq_attname
(
ncid
,
gmapvarid
,
iatt
,
attname
);
cdf_inq_attlen
(
ncid
,
gmapvarid
,
attname
,
&
attlen
);
cdf_inq_atttype
(
ncid
,
gmapvarid
,
attname
,
&
atttype
);
if
(
xtypeIsInt
(
atttype
)
)
{
int
attint
[
attlen
];
cdfGetAttInt
(
ncid
,
gmapvarid
,
attname
,
(
int
)
attlen
,
attint
);
printf
(
"atttype: %d attname: %s attr: %d
\n
"
,
atttype
,
attname
,
attint
[
0
]);
}
else
if
(
xtypeIsFloat
(
atttype
)
)
{
double
attflt
[
attlen
];
cdfGetAttDouble
(
ncid
,
gmapvarid
,
attname
,
(
int
)
attlen
,
attflt
);
printf
(
"atttype: %d attname: %s attr: %g
\n
"
,
atttype
,
attname
,
attflt
[
0
]);
}
else
if
(
xtypeIsText
(
atttype
)
&&
strcmp
(
attname
,
"grid_mapping_name"
)
)
{
cdfGetAttText
(
ncid
,
gmapvarid
,
attname
,
attstringlen
,
attstring
);
printf
(
"atttype: %d attname: %s attr: %s
\n
"
,
atttype
,
attname
,
attstring
);
}
cdfGetAttText
(
ncid
,
gmapvarid
,
attname
,
attstringlen
,
attstring
);
printf
(
"atttype: %d attname: %s attr: %s
\n
"
,
atttype
,
attname
,
attstring
);
}
}
}
gridAdded
=
cdiVlistAddGridIfNew
(
vlistID
,
grid
,
1
);
ncvar
->
gridID
=
gridAdded
.
Id
;
int
gridID
=
ncvar
->
gridID
;
if
(
grid
->
type
==
GRID_UNSTRUCTURED
&&
gridfile
[
0
]
!=
0
)
...
...
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