Last change
on this file since 2507 was
2507,
checked in by ymipsl, 16 months ago
|
Merging XIOS3_ATTACHED branch into XIOS3 trunk.
YM
|
-
Property svn:eol-style set to
native
-
Property svn:executable set to
*
|
File size:
1.2 KB
|
Line | |
---|
1 | #include "mpi.hpp" |
---|
2 | #include "mpi_tools.hpp" |
---|
3 | |
---|
4 | |
---|
5 | #include <string> |
---|
6 | |
---|
7 | namespace xios |
---|
8 | { |
---|
9 | int MPI_Bcast_string(std::string& str, int root, MPI_Comm comm) |
---|
10 | { |
---|
11 | int commRank ; |
---|
12 | int ret ; |
---|
13 | MPI_Comm_rank(comm,&commRank) ; |
---|
14 | int strSize ; |
---|
15 | if (commRank==root) strSize=str.size() ; |
---|
16 | MPI_Bcast(&strSize,1,MPI_INT,root,comm) ; |
---|
17 | |
---|
18 | if (commRank==root) ret=MPI_Bcast((char*)str.data(), strSize, MPI_CHAR, root, comm) ; |
---|
19 | else |
---|
20 | { |
---|
21 | char* tmp=new char[strSize] ; |
---|
22 | ret=MPI_Bcast(tmp, strSize, MPI_CHAR, root, comm) ; |
---|
23 | str=std::string(tmp,strSize) ; |
---|
24 | delete [] tmp ; |
---|
25 | } |
---|
26 | return ret ; |
---|
27 | } |
---|
28 | |
---|
29 | template<> |
---|
30 | MPI_Datatype MPI_GetType<bool>(void) { return MPI_CXX_BOOL ;} |
---|
31 | |
---|
32 | template<> |
---|
33 | MPI_Datatype MPI_GetType<char>(void) { return MPI_CHAR ;} |
---|
34 | |
---|
35 | template<> |
---|
36 | MPI_Datatype MPI_GetType<short int>(void) { return MPI_SHORT ;} |
---|
37 | |
---|
38 | template<> |
---|
39 | MPI_Datatype MPI_GetType<int>(void) { return MPI_INT ;} |
---|
40 | |
---|
41 | template<> |
---|
42 | MPI_Datatype MPI_GetType<size_t>(void) { return MPI_SIZE_T ;} |
---|
43 | |
---|
44 | template<> |
---|
45 | MPI_Datatype MPI_GetType<float>(void) { return MPI_FLOAT ;} |
---|
46 | |
---|
47 | template<> |
---|
48 | MPI_Datatype MPI_GetType<double>(void) { return MPI_DOUBLE ;} |
---|
49 | |
---|
50 | template<> |
---|
51 | MPI_Datatype MPI_GetType<long double>(void) { return MPI_LONG_DOUBLE ;} |
---|
52 | |
---|
53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.