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
31f5dd5c
Commit
31f5dd5c
authored
May 26, 2011
by
Deike Kleberg
Browse files
Testcase to compare resource arrays, adaptation of foreign keys in namespace.
parent
81f36f38
Changes
19
Hide whitespace changes
Inline
Side-by-side
.gitattributes
View file @
31f5dd5c
...
...
@@ -140,6 +140,7 @@ pioExamples/cdi_write_more_nodes.F90 -text
pioExamples/cdi_write_more_nodes.job -text
pioExamples/cdi_write_parallel.job -text
pioExamples/cdi_write_serial.job -text
pioExamples/compareResourcesArray.c -text
pioExamples/myModel.c -text
pioExamples/myModel2003.F90 -text
pioExamples/pio_write.F90 -text
...
...
pioExamples/Makefile.am
View file @
31f5dd5c
noinst_PROGRAMS
=
myModel
if
USE_MPI
noinst_PROGRAMS
+=
pio_write myModel2003
noinst_PROGRAMS
+=
pio_write myModel2003
compareResourcesArray
endif
AM_CFLAGS
=
-I
$(top_srcdir)
/src
...
...
@@ -16,4 +16,8 @@ myModel_LDADD=-L../src -lcdi
myModel2003_SOURCES
=
myModel2003.F90
myModel2003_LDADD
=
-L
../src
-lcdi
\ No newline at end of file
myModel2003_LDADD
=
-L
../src
-lcdi
compareResourcesArray_SOURCES
=
compareResourcesArray.c
compareResourcesArray_LDADD
=
-L
../src
-lcdi
\ No newline at end of file
pioExamples/Makefile.in
View file @
31f5dd5c
...
...
@@ -33,7 +33,7 @@ POST_UNINSTALL = :
build_triplet
=
@build@
host_triplet
=
@host@
noinst_PROGRAMS
=
myModel
$(EXEEXT)
$(am__EXEEXT_1)
@USE_MPI_TRUE@
am__append_1
=
pio_write myModel2003
@USE_MPI_TRUE@
am__append_1
=
pio_write myModel2003
compareResourcesArray
subdir
=
pioExamples
DIST_COMMON
=
README
$(srcdir)
/Makefile.am
$(srcdir)
/Makefile.in
ACLOCAL_M4
=
$(top_srcdir)
/aclocal.m4
...
...
@@ -48,8 +48,12 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs
=
$(SHELL)
$(top_srcdir)
/config/mkinstalldirs
CONFIG_HEADER
=
$(top_builddir)
/src/config.h
CONFIG_CLEAN_FILES
=
@USE_MPI_TRUE@
am__EXEEXT_1
=
pio_write
$(EXEEXT)
myModel2003
$(EXEEXT)
@USE_MPI_TRUE@
am__EXEEXT_1
=
pio_write
$(EXEEXT)
myModel2003
$(EXEEXT)
\
@USE_MPI_TRUE@ compareResourcesArray
$(EXEEXT)
PROGRAMS
=
$(noinst_PROGRAMS)
am_compareResourcesArray_OBJECTS
=
compareResourcesArray.
$(OBJEXT)
compareResourcesArray_OBJECTS
=
$(am_compareResourcesArray_OBJECTS)
compareResourcesArray_DEPENDENCIES
=
am_myModel_OBJECTS
=
myModel.
$(OBJEXT)
myModel_OBJECTS
=
$(am_myModel_OBJECTS)
myModel_DEPENDENCIES
=
...
...
@@ -80,10 +84,10 @@ CCLD = $(CC)
LINK
=
$(LIBTOOL)
--tag
=
CC
$(AM_LIBTOOLFLAGS)
$(LIBTOOLFLAGS)
\
--mode
=
link
$(CCLD)
$(AM_CFLAGS)
$(CFLAGS)
$(AM_LDFLAGS)
\
$(LDFLAGS)
-o
$@
SOURCES
=
$(
myModel
_SOURCES)
$(myModel
2003
_SOURCES)
\
$(pio_write_SOURCES)
DIST_SOURCES
=
$(
myModel
_SOURCES)
$(myModel
2003
_SOURCES)
\
$(pio_write_SOURCES)
SOURCES
=
$(
compareResourcesArray
_SOURCES)
$(myModel_SOURCES)
\
$(myModel2003_SOURCES)
$(pio_write_SOURCES)
DIST_SOURCES
=
$(
compareResourcesArray
_SOURCES)
$(myModel_SOURCES)
\
$(myModel2003_SOURCES)
$(pio_write_SOURCES)
ETAGS
=
etags
CTAGS
=
ctags
DISTFILES
=
$(DIST_COMMON)
$(DIST_SOURCES)
$(TEXINFOS)
$(EXTRA_DIST)
...
...
@@ -251,6 +255,8 @@ myModel_SOURCES = myModel.c
myModel_LDADD
=
-L
../src
-lcdi
myModel2003_SOURCES
=
myModel2003.F90
myModel2003_LDADD
=
-L
../src
-lcdi
compareResourcesArray_SOURCES
=
compareResourcesArray.c
compareResourcesArray_LDADD
=
-L
../src
-lcdi
all
:
all-am
.SUFFIXES
:
...
...
@@ -291,6 +297,9 @@ clean-noinstPROGRAMS:
echo
" rm -f
$$
p
$$
f"
;
\
rm
-f
$$
p
$$
f
;
\
done
compareResourcesArray$(EXEEXT)
:
$(compareResourcesArray_OBJECTS) $(compareResourcesArray_DEPENDENCIES)
@
rm
-f
compareResourcesArray
$(EXEEXT)
$(LINK)
$(compareResourcesArray_OBJECTS)
$(compareResourcesArray_LDADD)
$(LIBS)
myModel$(EXEEXT)
:
$(myModel_OBJECTS) $(myModel_DEPENDENCIES)
@
rm
-f
myModel
$(EXEEXT)
$(LINK)
$(myModel_OBJECTS)
$(myModel_LDADD)
$(LIBS)
...
...
@@ -307,6 +316,7 @@ mostlyclean-compile:
distclean-compile
:
-
rm
-f
*
.tab.c
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/compareResourcesArray.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/myModel.Po@am__quote@
.F90.o
:
...
...
pioExamples/compareResourcesArray.c
0 → 100644
View file @
31f5dd5c
#if defined (HAVE_CONFIG_H)
#include
"config.h"
#endif
#define nProcsIO 1
#define nNodes 1
#ifdef USE_MPI
#include
<mpi.h>
#endif
#include
"cdi.h"
#include
"pio_c_temp.h"
#include
"pio_util.h"
extern
void
reshPackBufferCreate
(
char
**
,
int
*
,
MPI_Comm
);
extern
void
reshPackBufferDestroy
(
char
**
);
extern
void
rpcUnpackResources
(
char
*
,
int
,
MPI_Comm
);
#define nlon 12 // Number of longitudes
#define nlat 6 // Number of latitudes
#define nlev 5 // Number of levels
#define ntsteps 3 // Number of time steps
/*
int nodeSizes[nNodes] = {1,2};
int nStreams = 6;
int streamSizes[6] = {5,127,19,18,9,52};
int vlistSizes[230] = {
1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,
47,47,47,47,47,47,47,47,47,47,
1,1,1,
11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,5,
1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,
11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,
11,11,11,11,11 };
*/
int
nodeSizes
[
nNodes
]
=
{
1
};
int
nStreams
=
4
;
int
streamSizes
[
4
]
=
{
2
,
5
,
1
,
3
};
int
vlistSizes
[
11
]
=
{
5
,
1
,
7
,
3
,
2
,
47
,
11
,
11
,
5
,
47
,
1
};
static
int
hlf
[]
=
{
0
,
1
};
void
modelRun
()
{
int
gridID
,
zaxisID1
,
zaxisID2
,
taxisID
;
int
vlistID
,
varID1
,
varID2
,
streamID
,
tsID
;
int
instID
,
modelID
;
double
lons
[
nlon
]
=
{
0
,
30
,
60
,
90
,
120
,
150
,
180
,
210
,
240
,
270
,
300
,
330
};
double
lats
[
nlat
]
=
{
-
75
,
-
45
,
-
15
,
15
,
45
,
75
};
double
levs
[
nlev
]
=
{
101300
,
92500
,
85000
,
50000
,
20000
};
double
var1
[
nlon
*
nlat
];
double
var2
[
nlon
*
nlat
*
nlev
];
char
*
recvBuffer
,
*
sendBuffer
;
int
bufferSize
;
MPI_Status
status
;
namespaceInit
(
2
,
hlf
);
namespaceSetActive
(
0
);
// Create a regular lon/lat grid
gridID
=
gridCreate
(
GRID_LONLAT
,
nlon
*
nlat
);
gridDefXsize
(
gridID
,
nlon
);
gridDefYsize
(
gridID
,
nlat
);
gridDefXvals
(
gridID
,
lons
);
gridDefYvals
(
gridID
,
lats
);
// Create a surface level Z-axis
zaxisID1
=
zaxisCreate
(
ZAXIS_SURFACE
,
1
);
// Create a pressure level Z-axis
zaxisID2
=
zaxisCreate
(
ZAXIS_PRESSURE
,
nlev
);
zaxisDefLevels
(
zaxisID2
,
levs
);
// Create a variable list
vlistID
=
vlistCreate
();
// Define the variables
varID1
=
vlistDefVar
(
vlistID
,
gridID
,
zaxisID1
,
TIME_VARIABLE
);
varID2
=
vlistDefVar
(
vlistID
,
gridID
,
zaxisID2
,
TIME_VARIABLE
);
instID
=
institutDef
(
0
,
0
,
"MYINSTITUTE"
,
"myInstitute"
);
modelID
=
modelDef
(
instID
,
0
,
"myModel"
);
// Define the variable names
vlistDefVarName
(
vlistID
,
varID1
,
"varname1"
);
{
int
globfac
[]
=
{
23
,
42
};
vlistDefAttInt
(
vlistID
,
varID1
,
"seer's globule factors"
,
DATATYPE_INT16
,
2
,
globfac
);
}
vlistDefVarName
(
vlistID
,
varID2
,
"varname2"
);
vlistDefAttTxt
(
vlistID
,
varID2
,
"txt demo"
,
6
,
"banana"
);
// Create a Time axis
taxisID
=
taxisCreate
(
TAXIS_ABSOLUTE
);
// Assign the Time axis to the variable list
vlistDefTaxis
(
vlistID
,
taxisID
);
// Create a dataset in netCDF fromat
streamID
=
streamOpenWrite
(
"example.grb"
,
FILETYPE_GRB
);
if
(
streamID
<
0
)
{
fprintf
(
stderr
,
"%s
\n
"
,
cdiStringError
(
streamID
));
return
;
}
// Assign the variable list to the dataset
streamDefVlist
(
streamID
,
vlistID
);
// compare test
reshPackBufferCreate
(
&
sendBuffer
,
&
bufferSize
,
MPI_COMM_WORLD
);
xmpi
(
MPI_Send
(
sendBuffer
,
bufferSize
,
MPI_PACKED
,
0
,
0
,
MPI_COMM_WORLD
));
recvBuffer
=
xmalloc
(
bufferSize
*
sizeof
(
char
));
xmpi
(
MPI_Recv
(
recvBuffer
,
bufferSize
,
MPI_PACKED
,
0
,
0
,
MPI_COMM_WORLD
,
&
status
));
namespaceSetActive
(
1
);
rpcUnpackResources
(
recvBuffer
,
bufferSize
,
MPI_COMM_WORLD
);
namespaceSetActive
(
0
);
free
(
recvBuffer
);
reshPackBufferDestroy
(
&
sendBuffer
);
reshArrayPrint
(
"reshArrayModel"
);
// Close the output stream
streamClose
(
streamID
);
// Destroy the objects
vlistDestroy
(
vlistID
);
taxisDestroy
(
taxisID
);
zaxisDestroy
(
zaxisID1
);
zaxisDestroy
(
zaxisID2
);
gridDestroy
(
gridID
);
return
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
size
;
MPI_Init
(
&
argc
,
&
argv
);
MPI_Comm_set_errhandler
(
MPI_COMM_WORLD
,
MPI_ERRORS_RETURN
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
size
);
if
(
size
!=
1
)
xabort
(
"test transition of resource array only with 1 PE."
);
modelRun
();
MPI_Finalize
();
return
0
;
}
src/grid.c
View file @
31f5dd5c
...
...
@@ -372,8 +372,6 @@ int gridCreate(int gridtype, int size)
int
gridID
;
grid_t
*
gridptr
;
xdebug
();
if
(
CDI_Debug
)
Message
(
"gridtype: %d size: %d"
,
gridtype
,
size
);
...
...
@@ -3869,7 +3867,7 @@ void gridDefReference(int gridID, const char *reference)
void
gridGetIndexArray
(
int
ngrids
,
int
*
gridIndexArray
)
{
reshGet
Indice
ArrayOfType
(
ngrids
,
gridIndexArray
,
&
gridOps
);
reshGet
Keys
ArrayOfType
(
ngrids
,
gridIndexArray
,
&
gridOps
);
}
#ifdef USE_MPI
...
...
src/institution.c
View file @
31f5dd5c
...
...
@@ -46,6 +46,7 @@ resOps instituteOps = { instituteCompareP, instituteDestroyP, institutePrintP
#endif
};
static
int
*
instituteInitializedNsp
;
static
void
instituteDefaultValue
(
institute_t
*
instituteptr
)
...
...
@@ -113,14 +114,33 @@ void instituteDefaultEntries ( void )
}
static
void
instituteFinalize
(
void
)
{
free
(
instituteInitializedNsp
);
}
static
void
instituteInit
(
void
)
{
static
int
instituteInitialized
=
0
;
int
nsp
,
nspc
;
char
*
env
;
if
(
instituteInitialized
)
return
;
nspc
=
namespaceGetNumber
();
if
(
!
instituteInitialized
)
{
instituteInitialized
=
1
;
instituteInitializedNsp
=
xcalloc
(
1
,
nspc
*
sizeof
(
int
));
atexit
(
instituteFinalize
);
}
instituteInitialized
=
1
;
nsp
=
namespaceGetActive
();
if
(
instituteInitializedNsp
[
nsp
]
)
return
;
instituteInitializedNsp
[
nsp
]
=
1
;
instituteDefaultEntries
();
}
...
...
@@ -185,7 +205,7 @@ int instituteCompareP ( void * instituteptr1, void * instituteptr2 )
int
institutInq
(
int
center
,
int
subcenter
,
const
char
*
name
,
const
char
*
longname
)
{
int
instID
=
UNDEFID
,
instCount
,
*
inst
Indice
,
i
;
int
instID
=
UNDEFID
,
instCount
,
*
inst
Keys
,
i
;
institute_t
*
ip1
;
institute_t
*
ip2
;
...
...
@@ -201,12 +221,12 @@ int institutInq(int center, int subcenter, const char *name, const char *longnam
ip1
->
longname
=
(
char
*
)
longname
;
instCount
=
instituteCount
();
inst
Indice
=
xmalloc
(
instCount
*
sizeof
(
int
));
reshGet
Indice
ArrayOfType
(
instCount
,
inst
Indice
,
&
instituteOps
);
inst
Keys
=
xmalloc
(
instCount
*
sizeof
(
int
));
reshGet
Keys
ArrayOfType
(
instCount
,
inst
Keys
,
&
instituteOps
);
for
(
i
=
0
;
i
<
instCount
;
i
++
)
{
instID
=
inst
Indice
[
i
];
instID
=
inst
Keys
[
i
];
ip2
=
(
institute_t
*
)
reshGetVal
(
instID
,
&
instituteOps
);
assert
(
ip2
);
...
...
@@ -217,7 +237,7 @@ int institutInq(int center, int subcenter, const char *name, const char *longnam
}
}
free
(
inst
Indice
);
free
(
inst
Keys
);
free
(
ip1
);
return
(
instID
);
...
...
@@ -291,23 +311,23 @@ char *institutInqLongnamePtr(int instID)
int
institutInqNumber
(
void
)
{
int
i
,
instCount
,
*
inst
Indice
,
instNum
=
0
;
int
i
,
instCount
,
*
inst
Keys
,
instNum
=
0
;
institute_t
*
instituteptr
;
instituteInit
();
instCount
=
reshCountType
(
&
instituteOps
);
inst
Indice
=
xmalloc
(
instCount
*
sizeof
(
int
));
reshGet
Indice
ArrayOfType
(
instCount
,
inst
Indice
,
&
instituteOps
);
inst
Keys
=
xmalloc
(
instCount
*
sizeof
(
int
));
reshGet
Keys
ArrayOfType
(
instCount
,
inst
Keys
,
&
instituteOps
);
for
(
i
=
0
;
i
<
instCount
;
i
++
)
{
instituteptr
=
(
institute_t
*
)
reshGetVal
(
inst
Indice
[
i
],
&
instituteOps
);
instituteptr
=
(
institute_t
*
)
reshGetVal
(
inst
Keys
[
i
],
&
instituteOps
);
if
(
instituteptr
&&
instituteptr
->
used
)
instNum
++
;
}
if
(
inst
Indice
)
free
(
inst
Indice
);
if
(
inst
Keys
)
free
(
inst
Keys
);
return
instNum
;
}
...
...
@@ -362,7 +382,6 @@ int instituteGetSizeP ( void * instituteptr, MPI_Comm comm )
{
institute_t
*
p
=
instituteptr
;
int
txsize
=
0
,
txinc
;
xdebug
();
xmpi
(
MPI_Pack_size
(
institute_nints
,
MPI_INT
,
comm
,
&
txsize
));
xmpi
(
MPI_Pack_size
(
strlen
(
p
->
name
)
+
1
,
MPI_CHAR
,
comm
,
&
txinc
));
txsize
+=
txinc
;
...
...
@@ -378,7 +397,6 @@ void institutePackP ( void * instituteptr, void *buf, int size,
{
institute_t
*
p
=
instituteptr
;
int
tempbuf
[
institute_nints
];
xdebug
();
tempbuf
[
0
]
=
p
->
self
;
tempbuf
[
1
]
=
p
->
center
;
tempbuf
[
2
]
=
p
->
subcenter
;
...
...
@@ -396,7 +414,6 @@ instituteUnpack(void *buf, int size, int *position,
int
tempbuf
[
institute_nints
];
int
instituteID
;
char
*
name
,
*
longname
;
xdebug
();
xmpi
(
MPI_Unpack
(
buf
,
size
,
position
,
tempbuf
,
institute_nints
,
MPI_INT
,
comm
));
name
=
xmalloc
(
tempbuf
[
3
]);
longname
=
xmalloc
(
tempbuf
[
4
]);
...
...
src/model.c
View file @
31f5dd5c
...
...
@@ -29,6 +29,7 @@ model_t;
static
int
MODEL_Debug
=
0
;
/* If set to 1, debugging */
static
int
*
modelInitializedNsp
;
static
void
modelInit
(
void
);
...
...
@@ -84,9 +85,7 @@ void modelDefaultEntries ( void )
instID
=
institutInq
(
0
,
0
,
"ECMWF"
,
NULL
);
/* (void) modelDef(instID, 131, "ERA15"); */
/* (void) modelDef(instID, 199, "ERA40"); */
instID
=
institutInq
(
0
,
0
,
"MPIMET"
,
NULL
);
resH
[
0
]
=
ECHAM5
=
modelDef
(
instID
,
64
,
"ECHAM5.4"
);
resH
[
1
]
=
modelDef
(
instID
,
63
,
"ECHAM5.3"
);
...
...
@@ -113,19 +112,36 @@ void modelDefaultEntries ( void )
reshSetStatus
(
resH
[
i
],
&
modelOps
,
SUSPENDED
);
}
static
void
modelFinalize
(
void
)
{
free
(
modelInitializedNsp
);
}
static
void
modelInit
(
void
)
{
static
int
modelInitialized
=
0
;
int
nsp
,
nspc
;
char
*
env
;
if
(
modelInitialized
)
return
;
modelInitialized
=
1
;
env
=
getenv
(
"MODEL_DEBUG"
);
if
(
env
)
MODEL_Debug
=
atoi
(
env
);
nspc
=
namespaceGetNumber
();
if
(
!
modelInitialized
)
{
modelInitialized
=
1
;
modelInitializedNsp
=
xcalloc
(
1
,
nspc
*
sizeof
(
int
));
atexit
(
modelFinalize
);
env
=
getenv
(
"MODEL_DEBUG"
);
if
(
env
)
MODEL_Debug
=
atoi
(
env
);
}
nsp
=
namespaceGetActive
();
if
(
modelInitializedNsp
[
nsp
]
)
return
;
modelInitializedNsp
[
nsp
]
=
1
;
modelDefaultEntries
();
}
...
...
@@ -142,17 +158,17 @@ int modelInq(int instID, int modelgribID, char *name)
int
found
;
int
modelCount
;
model_t
*
modelptr
;
int
i
,
*
model
Indice
;
int
i
,
*
model
Keys
;
modelInit
();
modelCount
=
modelSize
();
model
Indice
=
xmalloc
(
modelCount
*
sizeof
(
int
));
reshGet
Indice
ArrayOfType
(
modelCount
,
model
Indice
,
&
modelOps
);
model
Keys
=
xmalloc
(
modelCount
*
sizeof
(
int
));
reshGet
Keys
ArrayOfType
(
modelCount
,
model
Keys
,
&
modelOps
);
for
(
i
=
0
;
i
<
modelCount
;
i
++
)
{
modelID
=
model
Indice
[
i
];
modelID
=
model
Keys
[
i
];
modelptr
=
(
model_t
*
)
reshGetVal
(
modelID
,
&
modelOps
);
if
(
modelptr
->
used
)
...
...
@@ -184,7 +200,7 @@ int modelInq(int instID, int modelgribID, char *name)
if
(
modelID
==
modelCount
)
modelID
=
UNDEFID
;
if
(
model
Indice
)
free
(
model
Indice
);
if
(
model
Keys
)
free
(
model
Keys
);
return
(
modelID
);
}
...
...
@@ -288,7 +304,6 @@ int modelGetSizeP ( void * modelptr, MPI_Comm comm )
{
model_t
*
p
=
modelptr
;
int
txsize
=
0
,
txinc
;
xdebug
();
xmpi
(
MPI_Pack_size
(
model_nints
,
MPI_INT
,
comm
,
&
txsize
));
xmpi
(
MPI_Pack_size
(
strlen
(
p
->
name
)
+
1
,
MPI_CHAR
,
comm
,
&
txinc
));
txsize
+=
txinc
;
...
...
@@ -302,7 +317,6 @@ void modelPackP ( void * modelptr, void * buf, int size,
{
model_t
*
p
=
modelptr
;
int
tempbuf
[
model_nints
];
xdebug
();
tempbuf
[
0
]
=
p
->
self
;
tempbuf
[
1
]
=
p
->
instID
;
tempbuf
[
2
]
=
p
->
modelgribID
;
...
...
@@ -312,17 +326,16 @@ void modelPackP ( void * modelptr, void * buf, int size,
}
int
modelUnpack
(
void
*
buf
,
int
size
,
int
*
position
,
modelUnpack
(
void
*
buf
,
int
size
,
int
*
position
,
int
nspTarget
,
MPI_Comm
comm
)
{
int
tempbuf
[
model_nints
];
int
modelID
;
char
*
name
;
xdebug
();
xmpi
(
MPI_Unpack
(
buf
,
size
,
position
,
tempbuf
,
model_nints
,
MPI_INT
,
comm
));
name
=
xmalloc
(
tempbuf
[
3
]);
xmpi
(
MPI_Unpack
(
buf
,
size
,
position
,
name
,
tempbuf
[
3
],
MPI_CHAR
,
comm
));
modelID
=
modelDef
(
tempbuf
[
1
]
,
tempbuf
[
2
],
name
);
modelID
=
modelDef
(
namespaceAdaptKey
(
tempbuf
[
1
],
nspTarget
)
,
tempbuf
[
2
],
name
);
// FIXME: this should work, once all types are transferred
//assert(modelID == tempbuf[0]);
return
modelID
;
...
...
src/model.h
View file @
31f5dd5c
...
...
@@ -3,6 +3,6 @@
int
modelUnpack
(
void
*
buf
,
int
size
,
int
*
position
,
MPI_Comm
comm
);
int
,
MPI_Comm
comm
);
#endif
src/namespace.c
View file @
31f5dd5c
...
...
@@ -115,3 +115,21 @@ int namespaceHasLocalFile ( int nId )
return
hasLocalFile
[
nId
];
}
int
namespaceAdaptKey
(
int
key
,
int
nspTarget
)
{
namespaceTuple_t
tin
;
int
nsp
;
if
(
key
==
CDI_UNDEFID
)
return
CDI_UNDEFID
;
tin
.
idx
=
key
&
idxmask
;
tin
.
nsp
=
(
int
)(((
unsigned
)(
key
&
nspmask
))
>>
idxbits
);
assert
(
tin
.
nsp
==
nspTarget
);
nsp
=
namespaceGetActive
();
return
namespaceIdxEncode2
(
nsp
,
tin
.
idx
);
}
src/namespace.h
View file @
31f5dd5c
...
...
@@ -15,5 +15,6 @@ int namespaceIdxEncode2 ( int, int );
namespaceTuple_t
namespaceIdxDecode
(
int
);
int
namespaceHasLocalFile
(
int
);
void
namespaceCleanup
(
void
);
int
namespaceAdaptKey
(
int
,
int
);
#endif
src/pio_rpc.c
View file @
31f5dd5c
...
...
@@ -9,6 +9,7 @@
#include
"institution.h"
#include
"model.h"
#include
"vlist.h"
#include
"namespace.h"
MPI_Comm
commGlob
;
int
sizeGlob
;
...
...
@@ -17,6 +18,9 @@ int nProcsIO;
int
nProcsCalc
;
MPI_Comm
*
commsIO
;
MPI_Comm
commCalc
;
extern
void
reshArrayPrint
(
char
*
filename
);
void
commsIOCreate
(
MPI_Comm
commGlob
,
int
nIOP
)
...
...
@@ -180,7 +184,7 @@ void unpackTaxis ( char * unpackBuffer, int unpackBufferSize,
void
unpackStream
(
char
*
unpackBuffer
,
int
unpackBufferSize
,
int
*
unpackBufferPos
,
MPI_Comm
comm
)
int
*
unpackBufferPos
,
int
nspTarget
,
MPI_Comm
comm
)
{
int
streamID
;
int
filenameLen
,
filetype
,
vlistID
;
...
...
@@ -199,7 +203,7 @@ void unpackStream ( char * unpackBuffer, int unpackBufferSize,
xmpi
(
MPI_Unpack
(
unpackBuffer
,
unpackBufferSize
,
unpackBufferPos
,
&
vlistID
,
1
,
MPI_INT
,
comm
));
streamDefVlist
(
streamID
,
vlistID
);
streamDefVlist
(
streamID
,
namespaceAdaptKey
(
vlistID
,
nspTarget
)
);
}
...
...
@@ -209,7 +213,7 @@ void unpackStream ( char * unpackBuffer, int unpackBufferSize,
void
rpcUnpackResources
(
char
*
unpackBuffer
,
int
unpackBufferSize
,
MPI_Comm
comm
)
{
int
token1
,
token2
;
int
token1
,
token2
,
nspTarget
;
int
unpackBufferPos
=
0
;
char
text
[
4096
];
...
...
@@ -221,30 +225,38 @@ void rpcUnpackResources ( char * unpackBuffer, int unpackBufferSize,
switch
(
token1
)
{
case
END
:
xdebug
(
"#### end of packed data"
);
if
(
rankGlob
==
sizeGlob
-
1
)
reshArrayPrint
(
"reshArrayIOServer"
);
return
;
case
START
:
xmpi
(
MPI_Unpack