Changeset 242
- Timestamp:
- 07/04/11 15:17:55 (13 years ago)
- Location:
- XMLIO_V2/dev/dev_rv
- Files:
-
- 17 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
XMLIO_V2/dev/dev_rv/Makefile.wk
r238 r242 394 394 395 395 ifeq ($(VERSION), 4) 396 ELEMS_FOR = #vide 396 ELEMS_FOR = domain_interface domaingroup_interface \ 397 field_interface fieldgroup_interface \ 398 file_interface filegroup_interface \ 399 axis_interface axisgroup_interface axis \ 400 context_interface xml_tree 397 401 endif 398 402 -
XMLIO_V2/dev/dev_rv/src4/xmlio/main_server.cpp
r236 r242 36 36 try 37 37 { 38 std::cout << "Test input" << std::endl;39 CINetCDF4Adv file_coslatgrid("test/vtk/file_coslatgrid.nc4");40 CINetCDF4Adv file_xboundsybounds("test/vtk/file_xboundsybounds.nc4");41 CINetCDF4Adv sampleCurveGrid4("test/vtk/sampleCurveGrid4.nc4");42 CINetCDF4Adv sampleGenGrid3("test/vtk/sampleGenGrid3.nc4");43 CINetCDF4Adv ucov("test/vtk/ucov.nc4");44 45 std::vector<CINetCDF4Adv*> listinput;46 listinput.push_back(&file_coslatgrid);47 listinput.push_back(&file_xboundsybounds);48 listinput.push_back(&sampleCurveGrid4);49 listinput.push_back(&sampleGenGrid3);50 listinput.push_back(&ucov);51 std::vector<CINetCDF4Adv*>::iterator it = listinput.begin(), end = listinput.end();52 53 for (; it != end; it++)54 {55 std::cout << "-------------" << std::endl;56 std::map<std::string, std::size_t> dims = (*it)->getDimensions();57 std::map<std::string, std::size_t>::iterator it0 = dims.begin(), end0 = dims.end();58 59 for (; it0 != end0; it0++)60 {61 std::cout << "dimensions " << it0->first << " : " << it0->second << std::endl;62 }63 64 std::vector<std::string> vars = (*it)->getVariables();65 std::vector<std::string>::iterator it1 = vars.begin(), end1 = vars.end();66 for (; it1 != end1; it1++)67 {68 std::map<std::string, std::size_t> dims = (*it)->getDimensions(&(*it1));69 std::map<std::string, std::size_t>::iterator it3 = dims.begin(), end3 = dims.end();70 38 71 std::cout << "Variable " << *it1 << " [";72 for (; it3 != end3; it3++)73 {74 std::cout << it3->first << ":" << it3->second << " ";75 }76 std::cout << "] :" << std::endl;77 }78 }79 80 boost::multi_array<float, 1> data;81 file_coslatgrid.readData(data, "NTEMP", 1);82 std::cout << data.size() << std::endl;83 39 84 85 //vtkLSCEReader::ShowVariable("test/vtk/file_coslatgrid.nc4", "NTEMP");86 vtkLSCEReader::ShowVariable("test/vtk/ucov.nc4", "ucov");87 //vtkLSCEReader::ShowVariable("test/vtk/sampleCurveGrid4.nc4", "sample");88 //vtkLSCEReader::ShowVariable("test/vtk/sampleGenGrid3.nc4", "sample");89 //vtkLSCEReader::ShowVariable("test/vtk/file_xboundsybounds.nc4", "A");90 91 40 92 41 } -
XMLIO_V2/dev/dev_rv/src4/xmlio/mpi/mpi_interface.cpp
r238 r242 19 19 namespace comm { 20 20 21 // ---------------------- Initialisation & Finalisation --------------------- 22 23 void CMPIManager::Initialise(int * _argc, char *** _argv) 24 { 25 int flag = 0; 26 if (MPI_Initialized(&flag) != MPI_SUCCESS) 27 XIOS_ERROR("CMPIManager::Initialise(arc, argv)", << " MPI Error !"); 28 if (!flag) 29 { 30 if (MPI_Init(_argc, _argv) != MPI_SUCCESS) 31 XIOS_ERROR("CMPIManager::Initialise(arc, argv)", << " MPI Error !"); 32 } 33 34 } 35 36 void CMPIManager::Finalize(void) 37 { 38 if (MPI_Finalize() != MPI_SUCCESS) 39 XIOS_ERROR("CMPIManager::Finalize(void)", << " MPI Error !"); 40 } 41 42 // ------------------------------ Communicateurs ---------------------------- 43 44 int CMPIManager::GetCommRank(MPI_Comm _comm) 45 { 46 int rank = 0; 47 if (MPI_Comm_rank(_comm, &rank) != MPI_SUCCESS) 48 XIOS_ERROR("CMPIManager::GetCommRank(comm)", << " MPI Error !"); 49 return (rank); 50 } 51 52 int CMPIManager::GetCommSize(MPI_Comm _comm) 53 { 54 int size = 0; 55 if (MPI_Comm_size(_comm, &size) != MPI_SUCCESS) 56 XIOS_ERROR("CMPIManager::GetCommSize(comm)", << " MPI Error !"); 57 return (size); 58 } 59 60 MPI_Comm CMPIManager::CreateComm(MPI_Group _group, MPI_Comm _pcomm) 61 { 62 MPI_Comm commu; 63 if (MPI_Comm_create(_pcomm, _group, &commu) != MPI_SUCCESS) 64 XIOS_ERROR("CMPIManager::CreateComm(group, pcomm)", << " MPI Error !"); 65 return (commu); 66 } 67 68 MPI_Comm CMPIManager::GetCommWorld(void) 69 { 70 return (MPI_COMM_WORLD); 71 } 72 73 // ---------------------------------- Autre --------------------------------- 74 75 void CMPIManager::Barrier(MPI_Comm _comm) 76 { 77 if (MPI_Barrier(_comm) != MPI_SUCCESS) 78 XIOS_ERROR("CMPIManager::Barrier(comm)", << " MPI Error !"); 79 } 80 81 // --------------------------------- Groupes -------------------------------- 82 83 MPI_Group CMPIManager::GetGroupWorld(void) 84 { 85 MPI_Group group = 0; 86 if (MPI_Comm_group(CMPIManager::GetCommWorld(), &group) != MPI_SUCCESS) 87 XIOS_ERROR("CMPIManager::GetGroupWorld()", << " MPI Error !"); 88 return (group); 89 } 90 91 MPI_Group CMPIManager::CreateSubGroup(MPI_Group _pgroup, const std::vector<int> & _ranks) 92 { 93 MPI_Group group = 0; 94 if (MPI_Group_incl(_pgroup, _ranks.size(), const_cast<int*>(&(_ranks[0])), &group) != MPI_SUCCESS) 95 XIOS_ERROR("CMPIManager::CreateSubGroup(pgroup, ranks)", << " MPI Error !"); 96 return (group); 97 } 98 99 MPI_Group CMPIManager::CreateSubGroup 100 (MPI_Group _pgroup, int _min_rank, int _max_rank, int _intval) 101 { 102 std::vector<int> ranks; 103 for (int i = _min_rank; i <= _max_rank; i += _intval) 104 ranks.push_back(i); 105 return (CMPIManager::CreateSubGroup(_pgroup, ranks)); 106 } 107 108 // ----------------------------------- Tests -------------------------------- 109 110 bool CMPIManager::IsMaster(MPI_Comm _comm) 111 { 112 return (CMPIManager::GetCommRank(_comm) == 0); 113 } 114 115 bool CMPIManager::IsRank(int _rank, MPI_Comm _comm) 116 { 117 return (CMPIManager::GetCommRank(_comm) == _rank); 118 } 119 120 // --------------------------- Communication simple ------------------------- 121 122 void CMPIManager::Send (MPI_Comm _comm, int _dest_rank, char * _data, 123 std::size_t _size, MPI_Request & _request) 124 { 125 int nsize = _size; 126 if (MPI_Issend(_data, nsize, MPI_CHAR, _dest_rank, 0, _comm, &_request) != MPI_SUCCESS) 127 XIOS_ERROR("CMPIManager::Send (comm, dest_rank, data, size, request)", << " MPI Error !"); 128 } 129 130 void CMPIManager::Wait (MPI_Request & _request) 131 { 132 MPI_Status status; 133 if (MPI_Wait(&_request, &status) != MPI_SUCCESS) 134 XIOS_ERROR("CMPIManager::Wait (request)", << " MPI Error !"); 135 } 136 137 bool CMPIManager::Test (MPI_Request & _request) 138 { 139 MPI_Status status; 140 int flag = 0; 141 if (MPI_Test(&_request, &flag, &status) != MPI_SUCCESS) 142 XIOS_ERROR("CMPIManager::Test (request)", << " MPI Error !"); 143 return (flag); 144 } 145 146 bool CMPIManager::HasReceivedData(MPI_Comm _comm, int _src_rank) 147 { 148 MPI_Status status; 149 int flag = 0; 150 if (MPI_Iprobe(_src_rank, MPI_ANY_TAG, _comm, &flag, &status) != MPI_SUCCESS) 151 XIOS_ERROR("CMPIManager::HasReceivedData (comm, rank)", << " MPI Error !"); 152 return (flag); 153 } 154 155 std::size_t CMPIManager::GetReceivedDataSize(MPI_Comm _comm, int _src_rank) 156 { 157 MPI_Status status; 158 int flag = 0, size = 0; 159 if (MPI_Iprobe(_src_rank, MPI_ANY_TAG, _comm, &flag, &status) != MPI_SUCCESS) 160 XIOS_ERROR("CMPIManager::getReceivedDataSize (comm, rank)", << " MPI Error !"); 161 if (!flag) return (0); 162 if (MPI_Get_count(&status, MPI_CHAR, &size) != MPI_SUCCESS) 163 XIOS_ERROR("CMPIManager::getReceivedDataSize (comm, rank)", << " MPI Error !"); 164 165 return (size); 166 } 167 168 void CMPIManager::Receive(MPI_Comm _comm, int _src_rank, char * _data) 169 { 170 MPI_Request request = 0; 171 int size = CMPIManager::GetReceivedDataSize(_comm, _src_rank); 172 if (MPI_Irecv(_data, size, MPI_CHAR, _src_rank, MPI_ANY_TAG, _comm, &request) != MPI_SUCCESS) 173 XIOS_ERROR("CMPIManager::Receive (comm, src_rank, data)", << " MPI Error !"); 174 CMPIManager::Wait (request); // Temporaire 175 } 176 177 // ------------------------- Communication 'complexe' ----------------------- 178 179 //void SendLinearBuffer(MPIComm comm, int dest_rank, CLinearBuffer & buff, MPIRequest & request); 180 //void ReceiveLinearBuffer(MPIComm comm, int src_rank, CLinearBuffer & buff); 181 //boost::shared_ptr<CLinearBuffer> ReceiveLinearBuffer(MPIComm comm, int src_rank); 182 //void ReceiveCircularBuffer(MPIComm comm, int src_rank, CCircularBuffer & buff); 183 184 // ---------------------- Mémoire (non fonctionnel ....) -------------------- 185 186 void CMPIManager::AllocMemory(void * _data, std::size_t _size) 187 { 188 if (MPI_Alloc_mem(sizeof(char) * _size, MPI_INFO_NULL, _data) != MPI_SUCCESS) 189 XIOS_ERROR("CMPIManager::AllocMem(data, size)", << " MPI Error !"); 190 } 191 192 void CMPIManager::FreeMemory (void * _data) 193 { 194 MPI_Free_mem(_data); 195 } 196 21 197 } // namespace comm 22 198 } // namespace xmlioserver -
XMLIO_V2/dev/dev_rv/src4/xmlio/mpi/mpi_interface.hpp
r238 r242 71 71 public : // Communication simple 72 72 73 static void Send (MPI_Comm comm, int dest_rank, c onst char * data,73 static void Send (MPI_Comm comm, int dest_rank, char * data, 74 74 std::size_t size, MPI_Request & request); 75 75 static void Wait (MPI_Request & request);
Note: See TracChangeset
for help on using the changeset viewer.