Skip to content
GitLab
Menu
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
07faeca9
Commit
07faeca9
authored
Jan 13, 2013
by
Uwe Schulzweida
Browse files
stream_cdf: changed argument type of stream from int to stream_t
parent
96421425
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/stream.c
View file @
07faeca9
...
...
@@ -578,7 +578,7 @@ int cdiInqContents(int streamID)
case
FILETYPE_NC4
:
case
FILETYPE_NC4C
:
{
status
=
cdfInqContents
(
stream
ID
);
status
=
cdfInqContents
(
stream
ptr
);
break
;
}
#endif
...
...
@@ -1534,7 +1534,7 @@ int streamInqTimestep(int streamID, int tsID)
case
FILETYPE_NC4
:
case
FILETYPE_NC4C
:
{
nrecs
=
cdfInqTimestep
(
stream
ID
,
tsID
);
nrecs
=
cdfInqTimestep
(
stream
ptr
,
tsID
);
break
;
}
#endif
...
...
@@ -1720,8 +1720,8 @@ void stream_write_var(int streamID, int varID, int memtype, const void *data, in
case
FILETYPE_NC4
:
case
FILETYPE_NC4C
:
{
if
(
streamptr
->
accessmode
==
0
)
cdfEndDef
(
stream
ID
);
cdf_write_var
(
stream
ID
,
varID
,
memtype
,
data
,
nmiss
);
if
(
streamptr
->
accessmode
==
0
)
cdfEndDef
(
stream
ptr
);
cdf_write_var
(
stream
ptr
,
varID
,
memtype
,
data
,
nmiss
);
break
;
}
#endif
...
...
@@ -1920,7 +1920,7 @@ void stream_write_var_slice(int streamID, int varID, int levelID, int memtype, c
case
FILETYPE_NC4C
:
{
int
ierr
=
0
;
if
(
streamptr
->
accessmode
==
0
)
cdfEndDef
(
stream
ID
);
if
(
streamptr
->
accessmode
==
0
)
cdfEndDef
(
stream
ptr
);
ierr
=
cdf_write_var_slice
(
streamptr
,
varID
,
levelID
,
memtype
,
data
,
nmiss
);
break
;
}
...
...
src/stream_cdf.c
View file @
07faeca9
...
...
@@ -32,8 +32,8 @@
#define UNDEFID CDI_UNDEFID
void
cdfDefGlobalAtts
(
in
t
stream
ID
);
void
cdfDefLocalAtts
(
in
t
stream
ID
);
void
cdfDefGlobalAtts
(
stream_
t
*
stream
ptr
);
void
cdfDefLocalAtts
(
stream_
t
*
stream
ptr
);
#define X_AXIS 1
...
...
@@ -551,17 +551,9 @@ int cdfInqRecord(stream_t *streamptr, int *varID, int *levelID)
*/
int
cdfDefRecord
(
in
t
stream
ID
)
int
cdfDefRecord
(
stream_
t
*
stream
ptr
)
{
int
ierr
=
0
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
if
(
CDI_Debug
)
Message
(
"streamID = %d"
,
streamID
);
stream_check_ptr
(
__func__
,
streamptr
);
return
(
ierr
);
}
...
...
@@ -3391,7 +3383,7 @@ int cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtyp
}
#endif
void
cdf_write_var
(
in
t
stream
ID
,
int
varID
,
int
memtype
,
const
void
*
data
,
int
nmiss
)
void
cdf_write_var
(
stream_
t
*
stream
ptr
,
int
varID
,
int
memtype
,
const
void
*
data
,
int
nmiss
)
{
#if defined (HAVE_LIBNETCDF)
int
fileID
;
...
...
@@ -3412,19 +3404,14 @@ void cdf_write_var(int streamID, int varID, int memtype, const void *data, int n
int
gridindex
,
zaxisindex
;
int
dtype
;
int
vlistID
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
if
(
CDI_Debug
)
Message
(
"streamID = %d varID = %d"
,
streamID
,
varID
);
if
(
CDI_Debug
)
Message
(
"streamptr = %p varID = %d"
,
streamptr
,
varID
);
vlistID
=
streamptr
->
vlistID
;
fileID
=
streamptr
->
fileID
;
ntsteps
=
streamptr
->
ntsteps
;
if
(
CDI_Debug
)
Message
(
"ntsteps = %d"
,
ntsteps
);
if
(
CDI_Debug
)
Message
(
"ntsteps = %d"
,
ntsteps
);
if
(
vlistHasTime
(
vlistID
)
)
cdfDefTime
(
streamptr
);
...
...
@@ -3817,8 +3804,8 @@ int cdf_write_var_slice(stream_t *streamptr, int varID, int levelID, int memtype
return
(
0
);
}
void
cdfCreateRecords
(
in
t
stream
ID
,
int
tsID
)
static
void
cdfCreateRecords
(
stream_
t
*
stream
ptr
,
int
tsID
)
{
#if defined (HAVE_LIBNETCDF)
int
varID
,
levelID
,
recID
,
vrecID
,
zaxisID
;
...
...
@@ -3826,9 +3813,6 @@ void cdfCreateRecords(int streamID, int tsID)
record_t
*
records
=
NULL
;
int
*
recIDs
=
NULL
;
int
vlistID
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
vlistID
=
streamptr
->
vlistID
;
...
...
@@ -5909,17 +5893,12 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
/* define all input data variables */
static
void
define_all_vars
(
in
t
stream
ID
,
int
vlistID
,
int
instID
,
int
modelID
,
int
*
varids
,
int
nvars
,
ncvar_t
*
ncvars
)
void
define_all_vars
(
stream_
t
*
stream
ptr
,
int
vlistID
,
int
instID
,
int
modelID
,
int
*
varids
,
int
nvars
,
ncvar_t
*
ncvars
)
{
int
ncid
;
int
varID1
,
varID
,
ncvarid
;
int
code
;
int
tableID
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
stream_check_ptr
(
__func__
,
streamptr
);
if
(
streamptr
->
sortname
)
{
...
...
@@ -6286,7 +6265,7 @@ void read_global_attributtes(int fileID, int vlistID, stream_t *streamptr, int n
}
#endif
int
cdfInqContents
(
in
t
stream
ID
)
int
cdfInqContents
(
stream_
t
*
stream
ptr
)
{
#if defined (HAVE_LIBNETCDF)
int
ndims
,
nvars
,
ngatts
,
unlimdimid
;
...
...
@@ -6314,19 +6293,13 @@ int cdfInqContents(int streamID)
ncdim_t
*
ncdims
;
ncvar_t
*
ncvars
=
NULL
;
int
vlistID
;
stream_t
*
streamptr
;
int
format
=
0
;
int
ucla_les
=
FALSE
;
streamptr
=
stream_to_pointer
(
streamID
);
stream_check_ptr
(
__func__
,
streamptr
);
vlistID
=
streamptr
->
vlistID
;
fileID
=
streamptr
->
fileID
;
if
(
CDI_Debug
)
Message
(
"streamID = %d, fileID = %d"
,
streamID
,
fileID
);
if
(
CDI_Debug
)
Message
(
"streamptr = %p, fileID = %d"
,
streamptr
,
fileID
);
#if defined (HAVE_NETCDF4)
nc_inq_format
(
fileID
,
&
format
);
...
...
@@ -6726,10 +6699,10 @@ int cdfInqContents(int streamID)
streamptr
->
ntsteps
=
ntsteps
;
/* define all data variables */
define_all_vars
(
stream
ID
,
vlistID
,
instID
,
modelID
,
varids
,
nvars_data
,
ncvars
);
define_all_vars
(
stream
ptr
,
vlistID
,
instID
,
modelID
,
varids
,
nvars_data
,
ncvars
);
cdiCreateTimesteps
(
stream
ID
);
cdiCreateTimesteps
(
stream
ptr
);
/* time varID */
ncvarid
=
streamptr
->
basetime
.
ncvarid
;
...
...
@@ -6819,9 +6792,9 @@ int cdfInqContents(int streamID)
streamptr
->
curTsID
=
0
;
streamptr
->
rtsteps
=
1
;
(
void
)
cdfInqTimestep
(
stream
ID
,
0
);
(
void
)
cdfInqTimestep
(
stream
ptr
,
0
);
cdfCreateRecords
(
stream
ID
,
0
);
cdfCreateRecords
(
stream
ptr
,
0
);
/* free ncdims */
free
(
ncdims
);
...
...
@@ -6835,7 +6808,7 @@ int cdfInqContents(int streamID)
}
int
cdfInqTimestep
(
int
stream
ID
,
int
tsID
)
int
cdfInqTimestep
(
stream_t
*
stream
ptr
,
int
tsID
)
{
long
nrecs
=
0
;
#if defined (HAVE_LIBNETCDF)
...
...
@@ -6845,12 +6818,8 @@ int cdfInqTimestep(int streamID, int tsID)
int
fileID
;
size_t
index
;
taxis_t
*
taxis
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
if
(
CDI_Debug
)
Message
(
"streamID = %d tsID = %d"
,
streamID
,
tsID
);
if
(
CDI_Debug
)
Message
(
"streamptr= %p tsID = %d"
,
streamptr
,
tsID
);
stream_check_ptr
(
__func__
,
streamptr
);
...
...
@@ -6858,7 +6827,7 @@ int cdfInqTimestep(int streamID, int tsID)
if
(
tsID
<
streamptr
->
ntsteps
&&
streamptr
->
ntsteps
>
0
)
{
cdfCreateRecords
(
stream
ID
,
tsID
);
cdfCreateRecords
(
stream
ptr
,
tsID
);
taxis
=
&
streamptr
->
tsteps
[
tsID
].
taxis
;
if
(
tsID
>
0
)
...
...
@@ -6925,20 +6894,17 @@ int cdfInqTimestep(int streamID, int tsID)
}
void
cdfEndDef
(
in
t
stream
ID
)
void
cdfEndDef
(
stream_
t
*
stream
ptr
)
{
#if defined (HAVE_LIBNETCDF)
int
varID
;
int
nvars
;
int
fileID
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
fileID
=
streamptr
->
fileID
;
cdfDefGlobalAtts
(
stream
ID
);
cdfDefLocalAtts
(
stream
ID
);
cdfDefGlobalAtts
(
stream
ptr
);
cdfDefLocalAtts
(
stream
ptr
);
if
(
streamptr
->
accessmode
==
0
)
{
nvars
=
streamptr
->
nvars
;
...
...
@@ -6956,16 +6922,13 @@ void cdfEndDef(int streamID)
}
void
cdfDefInstitut
(
in
t
stream
ID
)
void
cdfDefInstitut
(
stream_
t
*
stream
ptr
)
{
#if defined (HAVE_LIBNETCDF)
int
fileID
,
instID
;
char
*
longname
;
size_t
len
;
int
vlistID
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
vlistID
=
streamptr
->
vlistID
;
fileID
=
streamptr
->
fileID
;
...
...
@@ -6988,16 +6951,14 @@ void cdfDefInstitut(int streamID)
#endif
}
void
cdfDefSource
(
int
streamID
)
void
cdfDefSource
(
stream_t
*
streamptr
)
{
#if defined (HAVE_LIBNETCDF)
int
fileID
,
modelID
;
char
*
longname
;
size_t
len
;
int
vlistID
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
vlistID
=
streamptr
->
vlistID
;
fileID
=
streamptr
->
fileID
;
...
...
@@ -7021,22 +6982,19 @@ void cdfDefSource(int streamID)
}
void
cdfDefGlobalAtts
(
in
t
stream
ID
)
void
cdfDefGlobalAtts
(
stream_
t
*
stream
ptr
)
{
#if defined (HAVE_LIBNETCDF)
int
fileID
,
vlistID
;
stream_t
*
streamptr
;
int
natts
;
streamptr
=
stream_to_pointer
(
streamID
);
if
(
streamptr
->
globalatts
)
return
;
vlistID
=
streamptr
->
vlistID
;
fileID
=
streamptr
->
fileID
;
cdfDefSource
(
stream
ID
);
cdfDefInstitut
(
stream
ID
);
cdfDefSource
(
stream
ptr
);
cdfDefInstitut
(
stream
ptr
);
vlistInqNatts
(
vlistID
,
CDI_GLOBAL
,
&
natts
);
...
...
@@ -7051,7 +7009,7 @@ void cdfDefGlobalAtts(int streamID)
}
void
cdfDefLocalAtts
(
in
t
stream
ID
)
void
cdfDefLocalAtts
(
stream_
t
*
stream
ptr
)
{
#if defined (HAVE_LIBNETCDF)
int
varID
,
instID
,
fileID
;
...
...
@@ -7059,9 +7017,6 @@ void cdfDefLocalAtts(int streamID)
size_t
len
;
int
ncvarid
;
int
vlistID
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
vlistID
=
streamptr
->
vlistID
;
fileID
=
streamptr
->
fileID
;
...
...
@@ -7092,27 +7047,23 @@ void cdfDefLocalAtts(int streamID)
#endif
}
void
cdfDefHistory
(
int
streamID
,
int
size
,
char
*
history
)
void
cdfDefHistory
(
stream_t
*
streamptr
,
int
size
,
char
*
history
)
{
#if defined (HAVE_LIBNETCDF)
int
ncid
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
ncid
=
streamptr
->
fileID
;
cdf_put_att_text
(
ncid
,
NC_GLOBAL
,
"history"
,
(
size_t
)
size
,
history
);
#endif
}
int
cdfInqHistorySize
(
int
streamID
)
int
cdfInqHistorySize
(
stream_t
*
streamptr
)
{
size_t
size
=
0
;
#if defined (HAVE_LIBNETCDF)
int
ncid
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
ncid
=
streamptr
->
fileID
;
if
(
streamptr
->
historyID
!=
UNDEFID
)
...
...
@@ -7123,13 +7074,10 @@ int cdfInqHistorySize(int streamID)
}
void
cdfInqHistoryString
(
in
t
stream
ID
,
char
*
history
)
void
cdfInqHistoryString
(
stream_
t
*
stream
ptr
,
char
*
history
)
{
#if defined (HAVE_LIBNETCDF)
int
ncid
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
ncid
=
streamptr
->
fileID
;
if
(
streamptr
->
historyID
!=
UNDEFID
)
...
...
src/stream_cdf.h
View file @
07faeca9
...
...
@@ -3,14 +3,14 @@
void
cdfDefVars
(
stream_t
*
streamptr
);
void
cdfDefTimestep
(
stream_t
*
streamptr
,
int
tsID
);
int
cdfInqTimestep
(
in
t
stream
ID
,
int
tsID
);
int
cdfInqContents
(
in
t
stream
ID
);
void
cdfDefHistory
(
in
t
stream
ID
,
int
size
,
char
*
history
);
int
cdfInqHistorySize
(
in
t
stream
ID
);
void
cdfInqHistoryString
(
in
t
stream
ID
,
char
*
history
);
int
cdfInqTimestep
(
stream_
t
*
stream
ptr
,
int
tsID
);
int
cdfInqContents
(
stream_
t
*
stream
ptr
);
void
cdfDefHistory
(
stream_
t
*
stream
ptr
,
int
size
,
char
*
history
);
int
cdfInqHistorySize
(
stream_
t
*
stream
ptr
);
void
cdfInqHistoryString
(
stream_
t
*
stream
ptr
,
char
*
history
);
void
cdfEndDef
(
int
stream
ID
);
int
cdfDefRecord
(
int
stream
ID
);
void
cdfEndDef
(
stream_t
*
stream
ptr
);
int
cdfDefRecord
(
stream_t
*
stream
ptr
);
int
cdfCopyRecord
(
stream_t
*
streamptr2
,
stream_t
*
streamptr1
);
...
...
@@ -18,7 +18,7 @@ int cdfReadRecord(stream_t *streamptr, double *data, int *nmiss);
void
cdf_write_record
(
stream_t
*
streamptr
,
int
memtype
,
const
void
*
data
,
int
nmiss
);
void
cdfReadVarDP
(
stream_t
*
streamptr
,
int
varID
,
double
*
data
,
int
*
nmiss
);
void
cdf_write_var
(
in
t
stream
ID
,
int
varID
,
int
memtype
,
const
void
*
data
,
int
nmiss
);
void
cdf_write_var
(
stream_
t
*
stream
ptr
,
int
varID
,
int
memtype
,
const
void
*
data
,
int
nmiss
);
int
cdfReadVarSliceDP
(
stream_t
*
streamptr
,
int
varID
,
int
levelID
,
double
*
data
,
int
*
nmiss
);
int
cdf_write_var_slice
(
stream_t
*
streamptr
,
int
varID
,
int
levelID
,
int
memtype
,
const
void
*
data
,
int
nmiss
);
...
...
src/stream_history.c
View file @
07faeca9
...
...
@@ -27,7 +27,7 @@ void streamDefHistory(int streamID, int length, const char *history)
if
(
len
)
{
histstring
=
strdupx
(
history
);
cdfDefHistory
(
stream
ID
,
length
,
histstring
);
cdfDefHistory
(
stream
ptr
,
length
,
histstring
);
free
(
histstring
);
}
}
...
...
@@ -47,7 +47,7 @@ int streamInqHistorySize(int streamID)
streamptr
->
filetype
==
FILETYPE_NC4
||
streamptr
->
filetype
==
FILETYPE_NC4C
)
{
size
=
cdfInqHistorySize
(
stream
ID
);
size
=
cdfInqHistorySize
(
stream
ptr
);
}
return
(
size
);
...
...
@@ -65,7 +65,7 @@ void streamInqHistoryString(int streamID, char *history)
streamptr
->
filetype
==
FILETYPE_NC4
||
streamptr
->
filetype
==
FILETYPE_NC4C
)
{
cdfInqHistoryString
(
stream
ID
,
history
);
cdfInqHistoryString
(
stream
ptr
,
history
);
}
}
/*
...
...
src/stream_int.h
View file @
07faeca9
...
...
@@ -299,7 +299,7 @@ void cdi_create_records(stream_t *streamptr, int tsID);
int
recordNewEntry
(
stream_t
*
streamptr
,
int
tsID
);
void
cdiCreateTimesteps
(
in
t
stream
ID
);
void
cdiCreateTimesteps
(
stream_
t
*
stream
ptr
);
void
recordInitEntry
(
record_t
*
record
);
...
...
src/stream_record.c
View file @
07faeca9
...
...
@@ -272,8 +272,8 @@ void streamDefRecord(int streamID, int varID, int levelID)
case
FILETYPE_NC4
:
case
FILETYPE_NC4C
:
{
if
(
streamptr
->
accessmode
==
0
)
cdfEndDef
(
stream
ID
);
status
=
cdfDefRecord
(
stream
ID
);
if
(
streamptr
->
accessmode
==
0
)
cdfEndDef
(
stream
ptr
);
status
=
cdfDefRecord
(
stream
ptr
);
break
;
}
#endif
...
...
src/tsteps.c
View file @
07faeca9
...
...
@@ -60,13 +60,10 @@ int tstepsNewEntry(stream_t *streamptr)
}
void
cdiCreateTimesteps
(
in
t
stream
ID
)
void
cdiCreateTimesteps
(
stream_
t
*
stream
ptr
)
{
int
ntsteps
;
int
tsID
;
stream_t
*
streamptr
;
streamptr
=
stream_to_pointer
(
streamID
);
if
(
streamptr
->
ntsteps
<
0
||
streamptr
->
tstepsTableSize
>
0
)
return
;
...
...
Write
Preview
Supports
Markdown
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