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
2b60e240
Commit
2b60e240
authored
Oct 23, 2015
by
Thomas Jahns
🤸
Browse files
Clarify namespace states.
parent
13e2e31d
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/namespace.c
View file @
2b60e240
...
...
@@ -64,10 +64,10 @@ static const union namespaceSwitchValue
static
struct
Namespace
{
s
tatus
Code
resStage
;
enum
namespaceS
tatus
resStage
;
union
namespaceSwitchValue
switches
[
NUM_NAMESPACE_SWITCH
];
}
initialNamespace
=
{
.
resStage
=
STAGE_DEFINITION
,
.
resStage
=
NAMESPACE_STATUS_INUSE
,
.
switches
=
defaultSwitches
};
...
...
@@ -153,7 +153,7 @@ namespaceNew()
{
/* namespace is already available and only needs reinitialization */
for
(
unsigned
i
=
0
;
i
<
namespacesSize
;
++
i
)
if
(
namespaces
[
i
].
resStage
==
STAGE
_UNUSED
)
if
(
namespaces
[
i
].
resStage
==
NAMESPACE_STATUS
_UNUSED
)
{
newNamespaceID
=
(
int
)
i
;
break
;
...
...
@@ -184,16 +184,16 @@ namespaceNew()
}
xassert
(
newNamespaceID
>=
0
&&
newNamespaceID
<
NUM_NAMESPACES
);
++
nNamespaces
;
namespaces
[
newNamespaceID
].
resStage
=
STAGE_DEFINITION
;
#if defined (SX) || defined (__cplusplus)
namespaces
[
newNamespaceID
].
resStage
=
NAMESPACE_STATUS_INUSE
;
#if defined (SX) || defined (__cplusplus)
memcpy
(
namespaces
[
newNamespaceID
].
switches
,
defaultSwitches_
,
sizeof
(
namespaces
[
newNamespaceID
].
switches
));
#else
#else
memcpy
(
namespaces
[
newNamespaceID
].
switches
,
(
union
namespaceSwitchValue
[
NUM_NAMESPACE_SWITCH
])
defaultSwitches
,
sizeof
(
namespaces
[
newNamespaceID
].
switches
));
#endif
#endif
reshListCreate
(
newNamespaceID
);
NAMESPACE_UNLOCK
();
return
newNamespaceID
;
...
...
@@ -207,7 +207,7 @@ namespaceDelete(int namespaceID)
xassert
(
namespaceID
>=
0
&&
(
unsigned
)
namespaceID
<
namespacesSize
&&
nNamespaces
);
reshListDestruct
(
namespaceID
);
namespaces
[
namespaceID
].
resStage
=
STAGE
_UNUSED
;
namespaces
[
namespaceID
].
resStage
=
NAMESPACE_STATUS
_UNUSED
;
--
nNamespaces
;
NAMESPACE_UNLOCK
();
}
...
...
@@ -221,7 +221,7 @@ int namespaceGetNumber ()
void
namespaceSetActive
(
int
nId
)
{
xassert
((
unsigned
)
nId
<
namespacesSize
&&
namespaces
[
nId
].
resStage
!=
STAGE
_UNUSED
);
&&
namespaces
[
nId
].
resStage
!=
NAMESPACE_STATUS
_UNUSED
);
activeNamespace
=
nId
;
}
...
...
@@ -265,14 +265,14 @@ int namespaceAdaptKey2 ( int originResH )
}
void
namespaceDefResStatus
(
s
tatus
Code
argResStatus
)
void
namespaceDefResStatus
(
enum
namespaceS
tatus
argResStatus
)
{
int
nsp
=
namespaceGetActive
();
namespaces
[
nsp
].
resStage
=
argResStatus
;
}
s
tatus
Code
namespaceInqResStatus
(
void
)
enum
namespaceS
tatus
namespaceInqResStatus
(
void
)
{
int
nsp
=
namespaceGetActive
();
return
namespaces
[
nsp
].
resStage
;
...
...
@@ -297,7 +297,7 @@ void cdiReset(void)
NAMESPACE_INIT
();
NAMESPACE_LOCK
();
for
(
unsigned
namespaceID
=
0
;
namespaceID
<
namespacesSize
;
++
namespaceID
)
if
(
namespaces
[
namespaceID
].
resStage
!=
STAGE
_UNUSED
)
if
(
namespaces
[
namespaceID
].
resStage
!=
NAMESPACE_STATUS
_UNUSED
)
namespaceDelete
((
int
)
namespaceID
);
if
(
namespaces
!=
&
initialNamespace
)
{
...
...
src/namespace.h
View file @
2b60e240
...
...
@@ -6,10 +6,10 @@
#endif
typedef
enum
{
STAGE_DEFINITION
=
0
,
STAGE_UNUSED
=
3
,
}
statusCode
;
enum
namespaceStatus
{
NAMESPACE_STATUS_INUSE
,
NAMESPACE_STATUS_UNUSED
,
};
typedef
struct
{
int
idx
;
...
...
@@ -66,8 +66,8 @@ int namespaceIdxEncode2 ( int, int );
namespaceTuple_t
namespaceResHDecode
(
int
);
int
namespaceAdaptKey
(
int
originResH
,
int
originNamespace
);
int
namespaceAdaptKey2
(
int
);
void
namespaceDefResStatus
(
s
tatus
Code
);
s
tatus
Code
namespaceInqResStatus
(
void
);
void
namespaceDefResStatus
(
enum
namespaceS
tatus
);
enum
namespaceS
tatus
namespaceInqResStatus
(
void
);
void
namespaceSwitchSet
(
enum
namespaceSwitch
sw
,
union
namespaceSwitchValue
value
);
union
namespaceSwitchValue
namespaceSwitchGet
(
enum
namespaceSwitch
sw
);
...
...
src/pio_client.c
View file @
2b60e240
...
...
@@ -30,10 +30,10 @@ cdiPioClientStreamOpen(const char *filename, char filemode,
int
fileID
;
if
(
filemode
==
'w'
)
{
s
tatus
Code
nspStatus
=
namespaceInqResStatus
();
enum
namespaceS
tatus
nspStatus
=
namespaceInqResStatus
();
switch
(
nspStatus
)
{
case
STAGE_DEFINITION
:
case
NAMESPACE_STATUS_INUSE
:
{
MPI_Comm
comm
=
cdiPioInqInterComm
();
int
clientRank
=
commInqRankModel
(),
...
...
@@ -96,11 +96,11 @@ cdiPioClientStreamOpen(const char *filename, char filemode,
static
void
cdiPioClientStreamDefVlist_
(
int
streamID
,
int
vlistID
)
{
s
tatus
Code
nspStatus
=
namespaceInqResStatus
();
enum
namespaceS
tatus
nspStatus
=
namespaceInqResStatus
();
cdiStreamDefVlist_
(
streamID
,
vlistID
);
switch
(
nspStatus
)
{
case
STAGE_DEFINITION
:
case
NAMESPACE_STATUS_INUSE
:
{
int
clientRank
=
commInqRankModel
(),
numClients
=
cdiPioCommInqSizeClients
(),
...
...
@@ -184,7 +184,7 @@ cdiPioClientStreamWriteVarPart(int streamID, int varID, const void *data,
{
switch
(
namespaceInqResStatus
())
{
case
STAGE_DEFINITION
:
case
NAMESPACE_STATUS_INUSE
:
pioBufferPartData
(
streamID
,
varID
,
data
,
nmiss
,
partDesc
);
return
;
default:
...
...
@@ -201,7 +201,7 @@ cdiPioClientStreamWriteScatteredVarPart(int streamID, int varID,
{
switch
(
namespaceInqResStatus
())
{
case
STAGE_DEFINITION
:
case
NAMESPACE_STATUS_INUSE
:
cdiPioBufferPartDataGather
(
streamID
,
varID
,
data
,
numBlocks
,
blocklengths
,
displacements
,
nmiss
,
partDesc
);
return
;
...
...
@@ -228,12 +228,12 @@ cdiPioClientStreamNOP(stream_t *streamptr)
static
void
cdiPioClientStreamClose
(
stream_t
*
streamptr
,
int
recordBufIsToBeDeleted
)
{
s
tatus
Code
nspStatus
=
namespaceInqResStatus
();
enum
namespaceS
tatus
nspStatus
=
namespaceInqResStatus
();
(
void
)
recordBufIsToBeDeleted
;
int
streamID
=
streamptr
->
self
;
switch
(
nspStatus
)
{
case
STAGE_DEFINITION
:
case
NAMESPACE_STATUS_INUSE
:
{
int
clientRank
=
commInqRankModel
(),
numClients
=
cdiPioCommInqSizeClients
(),
...
...
@@ -281,11 +281,11 @@ static int
cdiPioClientStreamDefTimestep_
(
stream_t
*
streamptr
,
int
tsID
)
{
struct
winHeaderEntry
header
;
s
tatus
Code
nspStatus
=
namespaceInqResStatus
();
enum
namespaceS
tatus
nspStatus
=
namespaceInqResStatus
();
int
taxisID
;
switch
(
nspStatus
)
{
case
STAGE_DEFINITION
:
case
NAMESPACE_STATUS_INUSE
:
taxisID
=
vlistInqTaxis
(
streamptr
->
vlistID
);
header
=
(
struct
winHeaderEntry
){
.
id
=
STREAMDEFTIMESTEP
,
...
...
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