| 136 | |
| 137 | |
| 138 | void Foam::UPstream::exit(int errnum) |
| 139 | { |
| 140 | if (debug) |
| 141 | { |
| 142 | Pout<< "UPstream::exit." << endl; |
| 143 | } |
| 144 | |
| 145 | #ifndef SGIMPI |
| 146 | int size; |
| 147 | char* buff; |
| 148 | MPI_Buffer_detach(&buff, &size); |
| 149 | delete[] buff; |
| 150 | #endif |
| 151 | |
| 152 | if (PstreamGlobals::outstandingRequests_.size()) |
| 153 | { |
| 154 | label n = PstreamGlobals::outstandingRequests_.size(); |
| 155 | PstreamGlobals::outstandingRequests_.clear(); |
| 156 | |
| 157 | WarningInFunction |
| 158 | << "There are still " << n << " outstanding MPI_Requests." << endl |
| 159 | << "This means that your code exited before doing a" |
| 160 | << " UPstream::waitRequests()." << endl |
| 161 | << "This should not happen for a normal code exit." |
| 162 | << endl; |
| 163 | } |
| 164 | |
| 165 | // Clean mpi communicators |
| 166 | forAll(myProcNo_, communicator) |
| 167 | { |
| 168 | if (myProcNo_[communicator] != -1) |
| 169 | { |
| 170 | freePstreamCommunicator(communicator); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | if (errnum == 0) |
| 175 | { |
| 176 | MPI_Finalize(); |
| 177 | ::exit(errnum); |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | MPI_Abort(MPI_COMM_WORLD, errnum); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | |
| 186 | void Foam::UPstream::abort() |