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
7c1dc9a5
Commit
7c1dc9a5
authored
Jul 19, 2016
by
Uwe Schulzweida
Browse files
Added function cdf_def_mapping().
parent
faf298b7
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/cdf_write.c
View file @
7c1dc9a5
...
...
@@ -164,8 +164,8 @@ void *resizeBuf(void **buf, size_t *bufSize, size_t reqSize)
return
*
buf
;
}
static
void
cdfDefineAttributes
(
int
vlist
ID
,
int
varID
,
int
fileID
,
int
ncvarID
)
void
cdfDefineAttributes
(
int
cdi
ID
,
int
varID
,
int
fileID
,
int
ncvarID
)
{
int
atttype
,
attlen
;
size_t
len
;
...
...
@@ -174,11 +174,11 @@ void cdfDefineAttributes(int vlistID, int varID, int fileID, int ncvarID)
size_t
attBufSize
=
0
;
int
natts
;
vlistInqNatts
(
vlist
ID
,
varID
,
&
natts
);
vlistInqNatts
(
cdi
ID
,
varID
,
&
natts
);
for
(
int
iatt
=
0
;
iatt
<
natts
;
iatt
++
)
{
vlistInqAtt
(
vlist
ID
,
varID
,
iatt
,
attname
,
&
atttype
,
&
attlen
);
vlistInqAtt
(
cdi
ID
,
varID
,
iatt
,
attname
,
&
atttype
,
&
attlen
);
if
(
attlen
==
0
)
continue
;
...
...
@@ -186,7 +186,7 @@ void cdfDefineAttributes(int vlistID, int varID, int fileID, int ncvarID)
{
size_t
attSize
=
(
size_t
)
attlen
*
sizeof
(
char
);
char
*
atttxt
=
(
char
*
)
resizeBuf
(
&
attBuf
,
&
attBufSize
,
attSize
);
vlistInqAttTxt
(
vlist
ID
,
varID
,
attname
,
attlen
,
atttxt
);
vlistInqAttTxt
(
cdi
ID
,
varID
,
attname
,
attlen
,
atttxt
);
len
=
(
size_t
)
attlen
;
cdf_put_att_text
(
fileID
,
ncvarID
,
attname
,
len
,
atttxt
);
}
...
...
@@ -196,7 +196,7 @@ void cdfDefineAttributes(int vlistID, int varID, int fileID, int ncvarID)
{
size_t
attSize
=
(
size_t
)
attlen
*
sizeof
(
int
);
int
*
attint
=
(
int
*
)
resizeBuf
(
&
attBuf
,
&
attBufSize
,
attSize
);
vlistInqAttInt
(
vlist
ID
,
varID
,
attname
,
attlen
,
&
attint
[
0
]);
vlistInqAttInt
(
cdi
ID
,
varID
,
attname
,
attlen
,
&
attint
[
0
]);
len
=
(
size_t
)
attlen
;
nc_type
xtype
=
(
atttype
==
DATATYPE_INT8
)
?
NC_BYTE
:
(
atttype
==
DATATYPE_INT16
)
?
NC_SHORT
:
...
...
@@ -212,7 +212,7 @@ void cdfDefineAttributes(int vlistID, int varID, int fileID, int ncvarID)
{
size_t
attSize
=
(
size_t
)
attlen
*
sizeof
(
double
);
double
*
attflt
=
(
double
*
)
resizeBuf
(
&
attBuf
,
&
attBufSize
,
attSize
);
vlistInqAttFlt
(
vlist
ID
,
varID
,
attname
,
attlen
,
attflt
);
vlistInqAttFlt
(
cdi
ID
,
varID
,
attname
,
attlen
,
attflt
);
len
=
(
size_t
)
attlen
;
if
(
atttype
==
DATATYPE_FLT32
)
{
...
...
@@ -581,7 +581,8 @@ int cdfDefVar(stream_t *streamptr, int varID)
}
}
if
(
gridtype
!=
GRID_GENERIC
&&
gridtype
!=
GRID_LONLAT
&&
gridtype
!=
GRID_CURVILINEAR
)
if
(
gridtype
!=
GRID_GENERIC
&&
gridtype
!=
GRID_LONLAT
&&
gridtype
!=
GRID_PROJECTION
&&
gridtype
!=
GRID_CURVILINEAR
)
{
size_t
len
=
strlen
(
gridNamePtr
(
gridtype
));
if
(
len
>
0
)
...
...
@@ -594,7 +595,12 @@ int cdfDefVar(stream_t *streamptr, int varID)
cdf_put_att_text
(
fileID
,
ncvarid
,
"grid_mapping"
,
strlen
(
mapping
),
mapping
);
}
if
(
gridtype
==
GRID_SINUSOIDAL
)
if
(
gridtype
==
GRID_PROJECTION
)
{
char
mapping
[]
=
"dummy"
;
cdf_put_att_text
(
fileID
,
ncvarid
,
"grid_mapping"
,
strlen
(
mapping
),
mapping
);
}
else
if
(
gridtype
==
GRID_SINUSOIDAL
)
{
char
mapping
[]
=
"sinusoidal"
;
cdf_put_att_text
(
fileID
,
ncvarid
,
"grid_mapping"
,
strlen
(
mapping
),
mapping
);
...
...
src/grid.c
View file @
7c1dc9a5
...
...
@@ -170,7 +170,7 @@ void grid_init(grid_t *gridptr)
memset
(
gridptr
->
uuid
,
0
,
CDI_UUID_SIZE
);
gridptr
->
name
=
NULL
;
gridptr
->
vtable
=
&
cdiGridVtable
;
gridptr
->
atts
.
nalloc
=
0
;
gridptr
->
atts
.
nalloc
=
MAX_ATTRIBUTES
;
gridptr
->
atts
.
nelems
=
0
;
}
...
...
src/stream_cdf.h
View file @
7c1dc9a5
...
...
@@ -16,6 +16,8 @@ void cdfDefRecord(stream_t * streamptr);
void
cdfCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
);
void
cdfDefineAttributes
(
int
vlistID
,
int
varID
,
int
fileID
,
int
ncvarID
);
void
cdf_read_record
(
stream_t
*
streamptr
,
int
memtype
,
void
*
data
,
int
*
nmiss
);
void
cdf_write_record
(
stream_t
*
streamptr
,
int
memtype
,
const
void
*
data
,
int
nmiss
);
...
...
src/stream_cdf_i.c
View file @
7c1dc9a5
...
...
@@ -943,7 +943,7 @@ void cdf_set_cdi_attr(int ncid, int ncvarid, int attnum, int cdiID, int varID)
int
attint
[
attlen
];
cdfGetAttInt
(
ncid
,
ncvarid
,
attname
,
(
int
)
attlen
,
attint
);
int
datatype
=
(
atttype
==
NC_SHORT
)
?
DATATYPE_INT16
:
(
atttype
==
NC_BYTE
)
?
DATATYPE_INT8
:
(
atttype
==
NC_BYTE
)
?
DATATYPE_INT8
:
#if defined (HAVE_NETCDF4)
(
atttype
==
NC_UBYTE
)
?
DATATYPE_UINT8
:
(
atttype
==
NC_USHORT
)
?
DATATYPE_UINT16
:
...
...
src/stream_cdf_o.c
View file @
7c1dc9a5
...
...
@@ -1966,6 +1966,23 @@ void cdfDefPole(stream_t *streamptr, int gridID)
cdf_enddef
(
fileID
);
}
static
void
cdf_def_mapping
(
stream_t
*
streamptr
,
int
gridID
)
{
int
fileID
=
streamptr
->
fileID
;
static
const
char
varname
[]
=
"dummy"
;
cdf_redef
(
fileID
);
int
ncvarid
;
int
ncerrcode
=
nc_def_var
(
fileID
,
varname
,
(
nc_type
)
NC_CHAR
,
0
,
NULL
,
&
ncvarid
);
if
(
ncerrcode
==
NC_NOERR
)
cdfDefineAttributes
(
gridID
,
CDI_GLOBAL
,
fileID
,
ncvarid
);
cdf_enddef
(
fileID
);
}
static
void
cdfDefMapping
(
stream_t
*
streamptr
,
int
gridID
)
{
...
...
@@ -2061,8 +2078,9 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
if
(
CDI_Debug
)
Message
(
"gridtype = %d size = %d"
,
gridtype
,
size
);
if
(
gridtype
==
GRID_GAUSSIAN
||
gridtype
==
GRID_LONLAT
||
if
(
gridtype
==
GRID_GAUSSIAN
||
gridtype
==
GRID_LONLAT
||
gridtype
==
GRID_PROJECTION
||
gridtype
==
GRID_GENERIC
)
{
if
(
gridtype
==
GRID_GENERIC
)
...
...
@@ -2097,6 +2115,8 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
if
(
gridInqXsize
(
gridID
)
>
0
)
cdfDefXaxis
(
streamptr
,
gridID
,
ndims
);
if
(
gridInqYsize
(
gridID
)
>
0
)
cdfDefYaxis
(
streamptr
,
gridID
,
ndims
);
if
(
gridtype
==
GRID_PROJECTION
)
cdf_def_mapping
(
streamptr
,
gridID
);
}
if
(
gridIsRotated
(
gridID
)
)
cdfDefPole
(
streamptr
,
gridID
);
...
...
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