------------------------------------------------------------------------------
| 769 | |
| 770 | //------------------------------------------------------------------------------ |
| 771 | int vtkMPICommunicator::SplitInitialize(vtkCommunicator* oldcomm, int color, int key) |
| 772 | { |
| 773 | if (this->Initialized) |
| 774 | return 0; |
| 775 | |
| 776 | vtkMPICommunicator* mpiComm = vtkMPICommunicator::SafeDownCast(oldcomm); |
| 777 | if (!mpiComm) |
| 778 | { |
| 779 | vtkErrorMacro("Split communicator must be an MPI communicator."); |
| 780 | return 0; |
| 781 | } |
| 782 | |
| 783 | // If mpiComm has been initialized, it is guaranteed (unless the MPI calls |
| 784 | // return an error somewhere) to have valid Communicator. |
| 785 | if (!mpiComm->Initialized) |
| 786 | { |
| 787 | vtkWarningMacro("The communicator passed has not been initialized!"); |
| 788 | return 0; |
| 789 | } |
| 790 | |
| 791 | this->KeepHandleOff(); |
| 792 | |
| 793 | this->MPIComm->Handle = new MPI_Comm; |
| 794 | int err; |
| 795 | if ((err = MPI_Comm_split(*(mpiComm->MPIComm->Handle), color, key, this->MPIComm->Handle)) != |
| 796 | MPI_SUCCESS) |
| 797 | { |
| 798 | delete this->MPIComm->Handle; |
| 799 | this->MPIComm->Handle = nullptr; |
| 800 | |
| 801 | char* msg = vtkMPIController::ErrorString(err); |
| 802 | vtkErrorMacro("MPI error occurred: " << msg); |
| 803 | delete[] msg; |
| 804 | |
| 805 | return 0; |
| 806 | } |
| 807 | |
| 808 | this->InitializeNumberOfProcesses(); |
| 809 | this->Initialized = 1; |
| 810 | |
| 811 | this->Modified(); |
| 812 | |
| 813 | return 1; |
| 814 | } |
| 815 | |
| 816 | int vtkMPICommunicator::InitializeExternal(vtkMPICommunicatorOpaqueComm* comm) |
| 817 | { |
no test coverage detected