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
84b5c0ee
Commit
84b5c0ee
authored
Aug 01, 2014
by
Thomas Jahns
🤸
Browse files
Move stream_new_entry and stream_delete_entry to only user stream.c.
parent
11607331
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/cdi.h
View file @
84b5c0ee
...
...
@@ -40,6 +40,7 @@ extern "C" {
/* File types */
#define FILETYPE_UNDEF -1
/* Unknown/not yet defined file type */
#define FILETYPE_GRB 1
/* File type GRIB */
#define FILETYPE_GRB2 2
/* File type GRIB version 2 */
#define FILETYPE_NC 3
/* File type netCDF */
...
...
src/cdi.inc
View file @
84b5c0ee
...
...
@@ -48,6 +48,8 @@
!
!
File
types
!
INTEGER
FILETYPE_UNDEF
PARAMETER
(
FILETYPE_UNDEF
=
-
1
)
INTEGER
FILETYPE_GRB
PARAMETER
(
FILETYPE_GRB
=
1
)
INTEGER
FILETYPE_GRB2
...
...
src/cdi_int.c
View file @
84b5c0ee
...
...
@@ -66,13 +66,13 @@ const char Filetypes[][9] = {
int
CDI_Debug
=
0
;
/* If set to 1, debugging */
static
int
STREAM_Debug
=
0
;
/* If set to 1, debugging */
int
STREAM_Debug
=
0
;
/* If set to 1, debugging */
int
cdiGribApiDebug
=
0
;
int
cdiDefaultLeveltype
=
-
1
;
static
int
cdiDataUnreduced
=
0
;
static
int
cdiSortName
=
0
;
static
int
cdiHaveMissval
=
0
;
int
cdiDataUnreduced
=
0
;
int
cdiSortName
=
0
;
int
cdiHaveMissval
=
0
;
static
int
streamCompareP
(
void
*
streamptr1
,
void
*
streamptr2
);
...
...
@@ -297,95 +297,6 @@ stream_t *stream_to_pointer(int idx)
return
(
stream_t
*
)
reshGetVal
(
idx
,
&
streamOps
);
}
static
void
streamDefaultValue
(
stream_t
*
streamptr
)
{
int
i
;
streamptr
->
self
=
UNDEFID
;
streamptr
->
accesstype
=
UNDEFID
;
streamptr
->
accessmode
=
0
;
streamptr
->
filetype
=
UNDEFID
;
streamptr
->
byteorder
=
UNDEFID
;
streamptr
->
fileID
=
0
;
streamptr
->
dimgroupID
=
UNDEFID
;
streamptr
->
filemode
=
0
;
streamptr
->
numvals
=
0
;
streamptr
->
filename
=
NULL
;
streamptr
->
record
=
NULL
;
streamptr
->
varsAllocated
=
0
;
streamptr
->
nrecs
=
0
;
streamptr
->
nvars
=
0
;
streamptr
->
vars
=
NULL
;
streamptr
->
varinit
=
0
;
streamptr
->
ncmode
=
0
;
streamptr
->
curTsID
=
UNDEFID
;
streamptr
->
rtsteps
=
0
;
streamptr
->
ntsteps
=
UNDEFID
;
streamptr
->
numTimestep
=
0
;
streamptr
->
tsteps
=
NULL
;
streamptr
->
tstepsTableSize
=
0
;
streamptr
->
tstepsNextID
=
0
;
streamptr
->
historyID
=
UNDEFID
;
streamptr
->
vlistID
=
UNDEFID
;
streamptr
->
globalatts
=
0
;
streamptr
->
localatts
=
0
;
streamptr
->
vct
.
ilev
=
0
;
streamptr
->
vct
.
mlev
=
0
;
streamptr
->
vct
.
ilevID
=
UNDEFID
;
streamptr
->
vct
.
mlevID
=
UNDEFID
;
streamptr
->
unreduced
=
cdiDataUnreduced
;
streamptr
->
sortname
=
cdiSortName
;
streamptr
->
have_missval
=
cdiHaveMissval
;
streamptr
->
comptype
=
COMPRESS_NONE
;
streamptr
->
complevel
=
0
;
basetimeInit
(
&
streamptr
->
basetime
);
for
(
i
=
0
;
i
<
MAX_GRIDS_PS
;
i
++
)
streamptr
->
xdimID
[
i
]
=
UNDEFID
;
for
(
i
=
0
;
i
<
MAX_GRIDS_PS
;
i
++
)
streamptr
->
ydimID
[
i
]
=
UNDEFID
;
for
(
i
=
0
;
i
<
MAX_ZAXES_PS
;
i
++
)
streamptr
->
zaxisID
[
i
]
=
UNDEFID
;
for
(
i
=
0
;
i
<
MAX_GRIDS_PS
;
i
++
)
streamptr
->
ncxvarID
[
i
]
=
UNDEFID
;
for
(
i
=
0
;
i
<
MAX_GRIDS_PS
;
i
++
)
streamptr
->
ncyvarID
[
i
]
=
UNDEFID
;
for
(
i
=
0
;
i
<
MAX_GRIDS_PS
;
i
++
)
streamptr
->
ncavarID
[
i
]
=
UNDEFID
;
streamptr
->
curfile
=
0
;
streamptr
->
nfiles
=
0
;
streamptr
->
fnames
=
NULL
;
streamptr
->
gribContainers
=
NULL
;
streamptr
->
vlistIDorig
=
UNDEFID
;
}
stream_t
*
stream_new_entry
(
void
)
{
stream_t
*
streamptr
;
cdiInitialize
();
/* ***************** make MT version !!! */
streamptr
=
(
stream_t
*
)
xmalloc
(
sizeof
(
stream_t
));
streamDefaultValue
(
streamptr
);
streamptr
->
self
=
reshPut
((
void
*
)
streamptr
,
&
streamOps
);
return
streamptr
;
}
void
stream_delete_entry
(
stream_t
*
streamptr
)
{
int
idx
;
xassert
(
streamptr
);
idx
=
streamptr
->
self
;
free
(
streamptr
);
reshRemove
(
idx
,
&
streamOps
);
if
(
STREAM_Debug
)
Message
(
"Removed idx %d from stream list"
,
idx
);
}
void
stream_check_ptr
(
const
char
*
caller
,
stream_t
*
streamptr
)
{
...
...
@@ -516,7 +427,7 @@ void cdiDefAccesstype(int streamID, int type)
streamptr
=
(
stream_t
*
)
reshGetVal
(
streamID
,
&
streamOps
);
if
(
streamptr
->
accesstype
==
UNDEFID
)
if
(
streamptr
->
accesstype
==
CDI_
UNDEFID
)
{
streamptr
->
accesstype
=
type
;
}
...
...
src/cdi_int.h
View file @
84b5c0ee
...
...
@@ -265,13 +265,16 @@ extern int cdiDefaultLeveltype;
extern
int
cdiNcChunksizehint
;
extern
int
cdiChunkType
;
extern
int
cdiSplitLtype105
;
extern
int
cdiDataUnreduced
;
extern
int
cdiSortName
;
extern
int
cdiHaveMissval
;
extern
int
STREAM_Debug
;
extern
char
*
cdiPartabPath
;
extern
int
cdiPartabIntern
;
stream_t
*
stream_to_pointer
(
int
idx
);
stream_t
*
stream_new_entry
(
void
);
void
stream_delete_entry
(
stream_t
*
streamptr
);
void
stream_check_ptr
(
const
char
*
caller
,
stream_t
*
streamptr
);
int
streamInqFileID
(
int
streamID
);
...
...
src/pio_server.c
View file @
84b5c0ee
...
...
@@ -532,7 +532,7 @@ buildStreamMap(struct winHeaderEntry *winDict)
{
int
streamIDOld
=
CDI_UNDEFID
;
int
oldStreamIdx
=
CDI_UNDEFID
;
int
filetype
=
CDI
_UNDEF
ID
;
int
filetype
=
FILETYPE
_UNDEF
;
int
sizeStreamMap
=
16
;
struct
streamMapping
*
streamMap
=
(
struct
streamMapping
*
)
xmalloc
(
sizeStreamMap
*
sizeof
(
streamMap
[
0
]));
int
numDataEntries
=
winDict
[
0
].
specific
.
headerSize
.
numDataEntries
;
...
...
src/stream.c
View file @
84b5c0ee
...
...
@@ -35,6 +35,10 @@
#define MAX_FNAMES 3
static
stream_t
*
stream_new_entry
(
void
);
static
void
stream_delete_entry
(
stream_t
*
streamptr
);
static
void
cdiPrintDefaults
(
void
)
{
...
...
@@ -1043,6 +1047,81 @@ int streamOpenWrite(const char *filename, int filetype)
return
(
streamOpen
(
filename
,
"w"
,
filetype
));
}
static
void
streamDefaultValue
(
stream_t
*
streamptr
)
{
int
i
;
streamptr
->
self
=
CDI_UNDEFID
;
streamptr
->
accesstype
=
CDI_UNDEFID
;
streamptr
->
accessmode
=
0
;
streamptr
->
filetype
=
FILETYPE_UNDEF
;
streamptr
->
byteorder
=
CDI_UNDEFID
;
streamptr
->
fileID
=
0
;
streamptr
->
dimgroupID
=
CDI_UNDEFID
;
streamptr
->
filemode
=
0
;
streamptr
->
numvals
=
0
;
streamptr
->
filename
=
NULL
;
streamptr
->
record
=
NULL
;
streamptr
->
varsAllocated
=
0
;
streamptr
->
nrecs
=
0
;
streamptr
->
nvars
=
0
;
streamptr
->
vars
=
NULL
;
streamptr
->
varinit
=
0
;
streamptr
->
ncmode
=
0
;
streamptr
->
curTsID
=
CDI_UNDEFID
;
streamptr
->
rtsteps
=
0
;
streamptr
->
ntsteps
=
CDI_UNDEFID
;
streamptr
->
numTimestep
=
0
;
streamptr
->
tsteps
=
NULL
;
streamptr
->
tstepsTableSize
=
0
;
streamptr
->
tstepsNextID
=
0
;
streamptr
->
historyID
=
CDI_UNDEFID
;
streamptr
->
vlistID
=
CDI_UNDEFID
;
streamptr
->
globalatts
=
0
;
streamptr
->
localatts
=
0
;
streamptr
->
vct
.
ilev
=
0
;
streamptr
->
vct
.
mlev
=
0
;
streamptr
->
vct
.
ilevID
=
CDI_UNDEFID
;
streamptr
->
vct
.
mlevID
=
CDI_UNDEFID
;
streamptr
->
unreduced
=
cdiDataUnreduced
;
streamptr
->
sortname
=
cdiSortName
;
streamptr
->
have_missval
=
cdiHaveMissval
;
streamptr
->
comptype
=
COMPRESS_NONE
;
streamptr
->
complevel
=
0
;
basetimeInit
(
&
streamptr
->
basetime
);
for
(
i
=
0
;
i
<
MAX_GRIDS_PS
;
i
++
)
streamptr
->
xdimID
[
i
]
=
CDI_UNDEFID
;
for
(
i
=
0
;
i
<
MAX_GRIDS_PS
;
i
++
)
streamptr
->
ydimID
[
i
]
=
CDI_UNDEFID
;
for
(
i
=
0
;
i
<
MAX_ZAXES_PS
;
i
++
)
streamptr
->
zaxisID
[
i
]
=
CDI_UNDEFID
;
for
(
i
=
0
;
i
<
MAX_GRIDS_PS
;
i
++
)
streamptr
->
ncxvarID
[
i
]
=
CDI_UNDEFID
;
for
(
i
=
0
;
i
<
MAX_GRIDS_PS
;
i
++
)
streamptr
->
ncyvarID
[
i
]
=
CDI_UNDEFID
;
for
(
i
=
0
;
i
<
MAX_GRIDS_PS
;
i
++
)
streamptr
->
ncavarID
[
i
]
=
CDI_UNDEFID
;
streamptr
->
curfile
=
0
;
streamptr
->
nfiles
=
0
;
streamptr
->
fnames
=
NULL
;
streamptr
->
gribContainers
=
NULL
;
streamptr
->
vlistIDorig
=
CDI_UNDEFID
;
}
static
stream_t
*
stream_new_entry
(
void
)
{
stream_t
*
streamptr
;
cdiInitialize
();
/* ***************** make MT version !!! */
streamptr
=
(
stream_t
*
)
xmalloc
(
sizeof
(
stream_t
));
streamDefaultValue
(
streamptr
);
streamptr
->
self
=
reshPut
((
void
*
)
streamptr
,
&
streamOps
);
return
streamptr
;
}
void
cdiStreamCloseDefaultDelegate
(
stream_t
*
streamptr
,
int
recordBufIsToBeDeleted
)
{
...
...
@@ -1193,6 +1272,21 @@ void streamClose(int streamID)
stream_delete_entry
(
streamptr
);
}
static
void
stream_delete_entry
(
stream_t
*
streamptr
)
{
int
idx
;
xassert
(
streamptr
);
idx
=
streamptr
->
self
;
free
(
streamptr
);
reshRemove
(
idx
,
&
streamOps
);
if
(
STREAM_Debug
)
Message
(
"Removed idx %d from stream list"
,
idx
);
}
void
cdiStreamSync_
(
stream_t
*
streamptr
)
{
int
fileID
=
streamptr
->
fileID
;
...
...
src/stream_record.c
View file @
84b5c0ee
...
...
@@ -444,7 +444,7 @@ void streamWriteRecordF(int streamID, const float *data, int nmiss)
void
streamCopyRecord
(
int
streamID2
,
int
streamID1
)
{
int
status
=
0
;
int
filetype
=
CDI
_UNDEF
ID
,
filetype1
,
filetype2
;
int
filetype
=
FILETYPE
_UNDEF
,
filetype1
,
filetype2
;
stream_t
*
streamptr1
;
stream_t
*
streamptr2
;
...
...
@@ -480,7 +480,7 @@ void streamCopyRecord(int streamID2, int streamID1)
}
}
if
(
filetype
==
CDI
_UNDEF
ID
)
if
(
filetype
==
FILETYPE
_UNDEF
)
Error
(
"Streams have different file types (%s -> %s)!"
,
strfiletype
(
filetype1
),
strfiletype
(
filetype2
));
switch
(
filetype
)
...
...
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