[1900] | 1 | MODULE pmc_mpi_wrapper |
---|
[1762] | 2 | |
---|
[1933] | 3 | !-------------------------------------------------------------------------------! |
---|
[1762] | 4 | ! This file is part of PALM. |
---|
| 5 | ! |
---|
| 6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 8 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 9 | ! |
---|
| 10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 13 | ! |
---|
| 14 | ! You should have received a copy of the GNU General Public License along with |
---|
| 15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 16 | ! |
---|
[1818] | 17 | ! Copyright 1997-2016 Leibniz Universitaet Hannover |
---|
[1933] | 18 | !-------------------------------------------------------------------------------! |
---|
[1762] | 19 | ! |
---|
| 20 | ! Current revisions: |
---|
| 21 | ! ------------------ |
---|
[1851] | 22 | ! |
---|
[1933] | 23 | ! |
---|
[1762] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: pmc_mpi_wrapper_mod.f90 1933 2016-06-13 07:12:51Z maronga $ |
---|
| 27 | ! |
---|
[1933] | 28 | ! 1901 2016-05-04 15:39:38Z raasch |
---|
| 29 | ! Code clean up. The words server/client changed to parent/child. |
---|
| 30 | ! |
---|
[1901] | 31 | ! 1900 2016-05-04 15:27:53Z raasch |
---|
| 32 | ! re-formatted to match PALM style |
---|
| 33 | ! |
---|
[1851] | 34 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
| 35 | ! Module renamed |
---|
| 36 | ! |
---|
| 37 | ! |
---|
[1809] | 38 | ! 1808 2016-04-05 19:44:00Z raasch |
---|
| 39 | ! MPI module used by default on all machines |
---|
| 40 | ! |
---|
[1780] | 41 | ! 1779 2016-03-03 08:01:28Z raasch |
---|
| 42 | ! kind=dp replaced by wp |
---|
| 43 | ! |
---|
[1765] | 44 | ! 1764 2016-02-28 12:45:19Z raasch |
---|
| 45 | ! cpp-statement added (nesting can only be used in parallel mode), |
---|
| 46 | ! kind-parameters adjusted to PALM-kinds |
---|
| 47 | ! |
---|
[1763] | 48 | ! 1762 2016-02-25 12:31:13Z hellstea |
---|
| 49 | ! Initial revision by K. Ketelsen |
---|
[1762] | 50 | ! |
---|
| 51 | ! Description: |
---|
| 52 | ! ------------ |
---|
| 53 | ! |
---|
| 54 | ! MPI Wrapper of Palm Model Coupler |
---|
[1933] | 55 | !-------------------------------------------------------------------------------! |
---|
[1762] | 56 | |
---|
[1764] | 57 | #if defined( __parallel ) |
---|
[1900] | 58 | USE, INTRINSIC :: ISO_C_BINDING |
---|
[1762] | 59 | |
---|
[1808] | 60 | #if defined( __mpifh ) |
---|
| 61 | INCLUDE "mpif.h" |
---|
| 62 | #else |
---|
[1764] | 63 | USE MPI |
---|
| 64 | #endif |
---|
[1762] | 65 | |
---|
[1900] | 66 | USE kinds |
---|
[1933] | 67 | USE pmc_handle_communicator, & |
---|
| 68 | ONLY: m_model_comm, m_model_rank, m_to_parent_comm, m_to_child_comm |
---|
[1762] | 69 | |
---|
[1900] | 70 | IMPLICIT NONE |
---|
[1762] | 71 | |
---|
[1900] | 72 | PRIVATE |
---|
| 73 | SAVE |
---|
[1762] | 74 | |
---|
[1933] | 75 | INTERFACE pmc_send_to_parent |
---|
| 76 | MODULE PROCEDURE pmc_send_to_parent_integer |
---|
| 77 | MODULE PROCEDURE pmc_send_to_parent_integer_2 |
---|
| 78 | MODULE PROCEDURE pmc_send_to_parent_real_r1 |
---|
| 79 | MODULE PROCEDURE pmc_send_to_parent_real_r2 |
---|
| 80 | MODULE PROCEDURE pmc_send_to_parent_real_r3 |
---|
| 81 | END INTERFACE pmc_send_to_parent |
---|
[1762] | 82 | |
---|
[1933] | 83 | INTERFACE pmc_recv_from_parent |
---|
| 84 | MODULE PROCEDURE pmc_recv_from_parent_integer |
---|
| 85 | MODULE PROCEDURE pmc_recv_from_parent_real_r1 |
---|
| 86 | MODULE PROCEDURE pmc_recv_from_parent_real_r2 |
---|
| 87 | MODULE PROCEDURE pmc_recv_from_parent_real_r3 |
---|
| 88 | END INTERFACE pmc_recv_from_parent |
---|
[1762] | 89 | |
---|
[1933] | 90 | INTERFACE pmc_send_to_child |
---|
| 91 | MODULE PROCEDURE pmc_send_to_child_integer |
---|
| 92 | MODULE PROCEDURE pmc_send_to_child_real_r1 |
---|
| 93 | MODULE PROCEDURE pmc_send_to_child_real_r2 |
---|
| 94 | MODULE PROCEDURE pmc_send_to_child_real_r3 |
---|
| 95 | END INTERFACE pmc_send_to_child |
---|
[1762] | 96 | |
---|
[1933] | 97 | INTERFACE pmc_recv_from_child |
---|
| 98 | MODULE PROCEDURE pmc_recv_from_child_integer |
---|
| 99 | MODULE PROCEDURE pmc_recv_from_child_integer_2 |
---|
| 100 | MODULE PROCEDURE pmc_recv_from_child_real_r1 |
---|
| 101 | MODULE PROCEDURE pmc_recv_from_child_real_r2 |
---|
| 102 | MODULE PROCEDURE pmc_recv_from_child_real_r3 |
---|
| 103 | END INTERFACE pmc_recv_from_child |
---|
[1762] | 104 | |
---|
[1900] | 105 | INTERFACE pmc_bcast |
---|
| 106 | MODULE PROCEDURE pmc_bcast_integer |
---|
| 107 | MODULE PROCEDURE pmc_bcast_character |
---|
| 108 | END INTERFACE pmc_bcast |
---|
[1762] | 109 | |
---|
[1900] | 110 | INTERFACE pmc_inter_bcast |
---|
| 111 | MODULE PROCEDURE pmc_inter_bcast_integer_1 |
---|
| 112 | END INTERFACE pmc_inter_bcast |
---|
[1762] | 113 | |
---|
[1900] | 114 | INTERFACE pmc_alloc_mem |
---|
| 115 | MODULE PROCEDURE pmc_alloc_mem_integer_1 |
---|
| 116 | MODULE PROCEDURE pmc_alloc_mem_Real_1 |
---|
| 117 | END INTERFACE pmc_alloc_mem |
---|
[1762] | 118 | |
---|
[1900] | 119 | INTERFACE pmc_time |
---|
| 120 | MODULE PROCEDURE pmc_time |
---|
| 121 | END INTERFACE pmc_time |
---|
[1762] | 122 | |
---|
[1933] | 123 | PUBLIC pmc_alloc_mem, pmc_bcast, pmc_inter_bcast, pmc_recv_from_child, & |
---|
| 124 | pmc_recv_from_parent, pmc_send_to_child, pmc_send_to_parent, & |
---|
[1900] | 125 | pmc_time |
---|
[1762] | 126 | |
---|
[1900] | 127 | CONTAINS |
---|
[1762] | 128 | |
---|
| 129 | |
---|
[1933] | 130 | SUBROUTINE pmc_send_to_parent_integer( buf, n, parent_rank, tag, ierr ) |
---|
[1762] | 131 | |
---|
[1900] | 132 | IMPLICIT NONE |
---|
[1762] | 133 | |
---|
[1900] | 134 | INTEGER, DIMENSION(:), INTENT(IN) :: buf !< |
---|
| 135 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 136 | INTEGER, INTENT(IN) :: parent_rank !< |
---|
[1900] | 137 | INTEGER, INTENT(IN) :: tag !< |
---|
| 138 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1762] | 139 | |
---|
[1900] | 140 | ierr = 0 |
---|
[1933] | 141 | CALL MPI_SEND( buf, n, MPI_INTEGER, parent_rank, tag, m_to_parent_comm, & |
---|
[1900] | 142 | ierr) |
---|
[1779] | 143 | |
---|
[1933] | 144 | END SUBROUTINE pmc_send_to_parent_integer |
---|
[1762] | 145 | |
---|
[1779] | 146 | |
---|
[1762] | 147 | |
---|
[1933] | 148 | SUBROUTINE pmc_recv_from_parent_integer( buf, n, parent_rank, tag, ierr ) |
---|
[1762] | 149 | |
---|
[1900] | 150 | IMPLICIT NONE |
---|
[1779] | 151 | |
---|
[1900] | 152 | INTEGER, DIMENSION(:), INTENT(OUT) :: buf !< |
---|
| 153 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 154 | INTEGER, INTENT(IN) :: parent_rank !< |
---|
[1900] | 155 | INTEGER, INTENT(IN) :: tag !< |
---|
| 156 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1762] | 157 | |
---|
[1900] | 158 | ierr = 0 |
---|
[1933] | 159 | CALL MPI_RECV( buf, n, MPI_INTEGER, parent_rank, tag, m_to_parent_comm, & |
---|
[1900] | 160 | MPI_STATUS_IGNORE, ierr ) |
---|
[1779] | 161 | |
---|
[1933] | 162 | END SUBROUTINE pmc_recv_from_parent_integer |
---|
[1762] | 163 | |
---|
| 164 | |
---|
[1779] | 165 | |
---|
[1933] | 166 | SUBROUTINE pmc_send_to_parent_integer_2( buf, n, parent_rank, tag, ierr ) |
---|
[1762] | 167 | |
---|
[1900] | 168 | IMPLICIT NONE |
---|
[1779] | 169 | |
---|
[1900] | 170 | INTEGER, DIMENSION(:,:), INTENT(IN) :: buf !< |
---|
| 171 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 172 | INTEGER, INTENT(IN) :: parent_rank !< |
---|
[1900] | 173 | INTEGER, INTENT(IN) :: tag !< |
---|
| 174 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1762] | 175 | |
---|
[1900] | 176 | ierr = 0 |
---|
[1933] | 177 | CALL MPI_SEND( buf, n, MPI_INTEGER, parent_rank, tag, m_to_parent_comm, & |
---|
[1900] | 178 | ierr ) |
---|
[1762] | 179 | |
---|
[1933] | 180 | END SUBROUTINE pmc_send_to_parent_integer_2 |
---|
[1779] | 181 | |
---|
[1762] | 182 | |
---|
[1779] | 183 | |
---|
[1933] | 184 | SUBROUTINE pmc_send_to_parent_real_r1( buf, n, parent_rank, tag, ierr ) |
---|
[1762] | 185 | |
---|
[1900] | 186 | IMPLICIT NONE |
---|
[1762] | 187 | |
---|
[1900] | 188 | REAL(wp), DIMENSION(:), INTENT(IN) :: buf !< |
---|
| 189 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 190 | INTEGER, INTENT(IN) :: parent_rank !< |
---|
[1900] | 191 | INTEGER, INTENT(IN) :: tag !< |
---|
| 192 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1779] | 193 | |
---|
[1900] | 194 | ierr = 0 |
---|
[1933] | 195 | CALL MPI_SEND( buf, n, MPI_REAL, parent_rank, tag, m_to_parent_comm, ierr ) |
---|
[1762] | 196 | |
---|
[1933] | 197 | END SUBROUTINE pmc_send_to_parent_real_r1 |
---|
[1779] | 198 | |
---|
[1762] | 199 | |
---|
| 200 | |
---|
[1933] | 201 | SUBROUTINE pmc_recv_from_parent_real_r1( buf, n, parent_rank, tag, ierr ) |
---|
[1779] | 202 | |
---|
[1900] | 203 | IMPLICIT NONE |
---|
[1762] | 204 | |
---|
[1900] | 205 | REAL(wp), DIMENSION(:), INTENT(OUT) :: buf !< |
---|
| 206 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 207 | INTEGER, INTENT(IN) :: parent_rank !< |
---|
[1900] | 208 | INTEGER, INTENT(IN) :: tag !< |
---|
| 209 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1779] | 210 | |
---|
[1900] | 211 | ierr = 0 |
---|
[1933] | 212 | CALL MPI_RECV( buf, n, MPI_REAL, parent_rank, tag, m_to_parent_comm, & |
---|
[1900] | 213 | MPI_STATUS_IGNORE, ierr ) |
---|
[1762] | 214 | |
---|
[1933] | 215 | END SUBROUTINE pmc_recv_from_parent_real_r1 |
---|
[1762] | 216 | |
---|
| 217 | |
---|
| 218 | |
---|
[1933] | 219 | SUBROUTINE pmc_send_to_parent_real_r2( buf, n, parent_rank, tag, ierr ) |
---|
[1762] | 220 | |
---|
[1900] | 221 | IMPLICIT NONE |
---|
[1762] | 222 | |
---|
[1900] | 223 | REAL(wp), DIMENSION(:,:), INTENT(IN) :: buf !< |
---|
| 224 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 225 | INTEGER, INTENT(IN) :: parent_rank !< |
---|
[1900] | 226 | INTEGER, INTENT(IN) :: tag !< |
---|
| 227 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1762] | 228 | |
---|
[1900] | 229 | ierr = 0 |
---|
[1933] | 230 | CALL MPI_SEND( buf, n, MPI_REAL, parent_rank, tag, m_to_parent_comm, ierr ) |
---|
[1762] | 231 | |
---|
[1933] | 232 | END SUBROUTINE pmc_send_to_parent_real_r2 |
---|
[1762] | 233 | |
---|
| 234 | |
---|
[1933] | 235 | SUBROUTINE pmc_recv_from_parent_real_r2( buf, n, parent_rank, tag, ierr ) |
---|
[1762] | 236 | |
---|
[1900] | 237 | IMPLICIT NONE |
---|
[1762] | 238 | |
---|
[1900] | 239 | REAL(wp), DIMENSION(:,:), INTENT(OUT) :: buf !< |
---|
| 240 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 241 | INTEGER, INTENT(IN) :: parent_rank !< |
---|
[1900] | 242 | INTEGER, INTENT(IN) :: tag !< |
---|
| 243 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1779] | 244 | |
---|
[1900] | 245 | ierr = 0 |
---|
[1933] | 246 | CALL MPI_RECV( buf, n, MPI_REAL, parent_rank, tag, m_to_parent_comm, & |
---|
[1900] | 247 | MPI_STATUS_IGNORE, ierr ) |
---|
[1762] | 248 | |
---|
[1933] | 249 | END SUBROUTINE pmc_recv_from_parent_real_r2 |
---|
[1779] | 250 | |
---|
[1762] | 251 | |
---|
| 252 | |
---|
[1933] | 253 | SUBROUTINE pmc_send_to_parent_real_r3( buf, n, parent_rank, tag, ierr ) |
---|
[1779] | 254 | |
---|
[1900] | 255 | IMPLICIT NONE |
---|
[1762] | 256 | |
---|
[1900] | 257 | REAL(wp), DIMENSION(:,:,:), INTENT(IN) :: buf !< |
---|
| 258 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 259 | INTEGER, INTENT(IN) :: parent_rank !< |
---|
[1900] | 260 | INTEGER, INTENT(IN) :: tag !< |
---|
| 261 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1779] | 262 | |
---|
[1900] | 263 | ierr = 0 |
---|
[1933] | 264 | CALL MPI_SEND( buf, n, MPI_REAL, parent_rank, tag, m_to_parent_comm, ierr ) |
---|
[1762] | 265 | |
---|
[1933] | 266 | END SUBROUTINE pmc_send_to_parent_real_r3 |
---|
[1762] | 267 | |
---|
[1779] | 268 | |
---|
[1762] | 269 | |
---|
[1933] | 270 | SUBROUTINE pmc_recv_from_parent_real_r3( buf, n, parent_rank, tag, ierr ) |
---|
[1779] | 271 | |
---|
[1900] | 272 | IMPLICIT NONE |
---|
[1762] | 273 | |
---|
[1900] | 274 | REAL(wp), DIMENSION(:,:,:), INTENT(OUT) :: buf !< |
---|
| 275 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 276 | INTEGER, INTENT(IN) :: parent_rank !< |
---|
[1900] | 277 | INTEGER, INTENT(IN) :: tag !< |
---|
| 278 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1762] | 279 | |
---|
[1900] | 280 | ierr = 0 |
---|
[1933] | 281 | CALL MPI_RECV( buf, n, MPI_REAL, parent_rank, tag, m_to_parent_comm, & |
---|
[1900] | 282 | MPI_STATUS_IGNORE, ierr ) |
---|
[1779] | 283 | |
---|
[1933] | 284 | END SUBROUTINE pmc_recv_from_parent_real_r3 |
---|
[1762] | 285 | |
---|
[1779] | 286 | |
---|
[1762] | 287 | |
---|
[1933] | 288 | SUBROUTINE pmc_send_to_child_integer( child_id, buf, n, child_rank, tag, & |
---|
| 289 | ierr ) |
---|
[1762] | 290 | |
---|
[1900] | 291 | IMPLICIT NONE |
---|
[1779] | 292 | |
---|
[1933] | 293 | INTEGER, INTENT(IN) :: child_id !< |
---|
[1900] | 294 | INTEGER, DIMENSION(:), INTENT(IN) :: buf !< |
---|
| 295 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 296 | INTEGER, INTENT(IN) :: child_rank !< |
---|
[1900] | 297 | INTEGER, INTENT(IN) :: tag !< |
---|
| 298 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1762] | 299 | |
---|
[1900] | 300 | ierr = 0 |
---|
[1933] | 301 | CALL MPI_SEND( buf, n, MPI_INTEGER, child_rank, tag, & |
---|
| 302 | m_to_child_comm(child_id), ierr ) |
---|
[1779] | 303 | |
---|
[1933] | 304 | END SUBROUTINE pmc_send_to_child_integer |
---|
[1762] | 305 | |
---|
| 306 | |
---|
[1779] | 307 | |
---|
[1933] | 308 | SUBROUTINE pmc_recv_from_child_integer( child_id, buf, n, child_rank, tag, & |
---|
| 309 | ierr ) |
---|
[1762] | 310 | |
---|
[1900] | 311 | IMPLICIT NONE |
---|
[1779] | 312 | |
---|
[1933] | 313 | INTEGER, INTENT(IN) :: child_id !< |
---|
[1900] | 314 | INTEGER, DIMENSION(:), INTENT(INOUT) :: buf !< |
---|
| 315 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 316 | INTEGER, INTENT(IN) :: child_rank !< |
---|
[1900] | 317 | INTEGER, INTENT(IN) :: tag !< |
---|
| 318 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1762] | 319 | |
---|
[1900] | 320 | ierr = 0 |
---|
[1933] | 321 | CALL MPI_RECV( buf, n, MPI_INTEGER, child_rank, tag, & |
---|
| 322 | m_to_child_comm(child_id), MPI_STATUS_IGNORE, ierr ) |
---|
[1762] | 323 | |
---|
[1933] | 324 | END SUBROUTINE pmc_recv_from_child_integer |
---|
[1762] | 325 | |
---|
| 326 | |
---|
| 327 | |
---|
[1933] | 328 | SUBROUTINE pmc_recv_from_child_integer_2( child_id, buf, n, child_rank, & |
---|
| 329 | tag, ierr ) |
---|
[1762] | 330 | |
---|
[1900] | 331 | IMPLICIT NONE |
---|
[1762] | 332 | |
---|
[1933] | 333 | INTEGER, INTENT(IN) :: child_id !< |
---|
[1900] | 334 | INTEGER, DIMENSION(:,:), INTENT(OUT) :: buf !< |
---|
| 335 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 336 | INTEGER, INTENT(IN) :: child_rank !< |
---|
[1900] | 337 | INTEGER, INTENT(IN) :: tag !< |
---|
| 338 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1762] | 339 | |
---|
[1900] | 340 | ierr = 0 |
---|
[1933] | 341 | CALL MPI_RECV( buf, n, MPI_INTEGER, child_rank, tag, & |
---|
| 342 | m_to_child_comm(child_id), MPI_STATUS_IGNORE, ierr ) |
---|
[1762] | 343 | |
---|
[1933] | 344 | END SUBROUTINE pmc_recv_from_child_integer_2 |
---|
[1762] | 345 | |
---|
| 346 | |
---|
| 347 | |
---|
[1933] | 348 | SUBROUTINE pmc_send_to_child_real_r1( child_id, buf, n, child_rank, tag, & |
---|
| 349 | ierr ) |
---|
[1762] | 350 | |
---|
[1900] | 351 | IMPLICIT NONE |
---|
[1762] | 352 | |
---|
[1933] | 353 | INTEGER, INTENT(IN) :: child_id !< |
---|
[1900] | 354 | REAL(wp), DIMENSION(:), INTENT(IN) :: buf !< |
---|
| 355 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 356 | INTEGER, INTENT(IN) :: child_rank !< |
---|
[1900] | 357 | INTEGER, INTENT(IN) :: tag !< |
---|
| 358 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1762] | 359 | |
---|
[1900] | 360 | ierr = 0 |
---|
[1933] | 361 | CALL MPI_SEND( buf, n, MPI_REAL, child_rank, tag, & |
---|
| 362 | m_to_child_comm(child_id), ierr ) |
---|
[1762] | 363 | |
---|
[1933] | 364 | END SUBROUTINE pmc_send_to_child_real_r1 |
---|
[1762] | 365 | |
---|
| 366 | |
---|
| 367 | |
---|
[1933] | 368 | SUBROUTINE pmc_recv_from_child_real_r1( child_id, buf, n, child_rank, tag, & |
---|
| 369 | ierr ) |
---|
[1762] | 370 | |
---|
[1900] | 371 | IMPLICIT NONE |
---|
[1762] | 372 | |
---|
[1933] | 373 | INTEGER, INTENT(IN) :: child_id !< |
---|
[1900] | 374 | REAL(wp), DIMENSION(:), INTENT(INOUT) :: buf !< |
---|
| 375 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 376 | INTEGER, INTENT(IN) :: child_rank !< |
---|
[1900] | 377 | INTEGER, INTENT(IN) :: tag !< |
---|
| 378 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1762] | 379 | |
---|
[1900] | 380 | ierr = 0 |
---|
[1933] | 381 | CALL MPI_RECV( buf, n, MPI_REAL, child_rank, tag, & |
---|
| 382 | m_to_child_comm(child_id), MPI_STATUS_IGNORE, ierr ) |
---|
[1762] | 383 | |
---|
[1933] | 384 | END SUBROUTINE pmc_recv_from_child_real_r1 |
---|
[1762] | 385 | |
---|
| 386 | |
---|
| 387 | |
---|
[1933] | 388 | SUBROUTINE pmc_send_to_child_real_r2( child_id, buf, n, child_rank, tag, & |
---|
| 389 | ierr ) |
---|
[1762] | 390 | |
---|
[1900] | 391 | IMPLICIT NONE |
---|
[1762] | 392 | |
---|
[1933] | 393 | INTEGER, INTENT(IN) :: child_id !< |
---|
[1900] | 394 | REAL(wp), DIMENSION(:,:), INTENT(IN) :: buf !< |
---|
| 395 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 396 | INTEGER, INTENT(IN) :: child_rank !< |
---|
[1900] | 397 | INTEGER, INTENT(IN) :: tag !< |
---|
| 398 | INTEGER, INTENT(OUT) :: ierr !< |
---|
[1762] | 399 | |
---|
[1900] | 400 | ierr = 0 |
---|
[1933] | 401 | CALL MPI_SEND( buf, n, MPI_REAL, child_rank, tag, & |
---|
| 402 | m_to_child_comm(child_id), ierr ) |
---|
[1762] | 403 | |
---|
[1933] | 404 | END SUBROUTINE pmc_send_to_child_real_r2 |
---|
[1762] | 405 | |
---|
| 406 | |
---|
| 407 | |
---|
[1933] | 408 | SUBROUTINE pmc_recv_from_child_real_r2( child_id, buf, n, child_rank, tag, & |
---|
| 409 | ierr ) |
---|
[1762] | 410 | |
---|
[1900] | 411 | IMPLICIT NONE |
---|
[1762] | 412 | |
---|
[1933] | 413 | INTEGER, INTENT(IN) :: child_id !< |
---|
[1900] | 414 | REAL(wp), DIMENSION(:,:), INTENT(OUT) :: buf !< |
---|
| 415 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 416 | INTEGER, INTENT(IN) :: child_rank !< |
---|
[1900] | 417 | INTEGER, INTENT(IN) :: tag !< |
---|
| 418 | INTEGER, INTENT(OUT) :: ierr !< |
---|
| 419 | |
---|
| 420 | ierr = 0 |
---|
[1933] | 421 | CALL MPI_RECV( buf, n, MPI_REAL, child_rank, tag, & |
---|
| 422 | m_to_child_comm(child_id), MPI_STATUS_IGNORE, ierr ) |
---|
[1900] | 423 | |
---|
[1933] | 424 | END SUBROUTINE pmc_recv_from_child_real_r2 |
---|
[1900] | 425 | |
---|
| 426 | |
---|
| 427 | |
---|
[1933] | 428 | SUBROUTINE pmc_send_to_child_real_r3( child_id, buf, n, child_rank, tag, & |
---|
| 429 | ierr) |
---|
[1900] | 430 | |
---|
| 431 | IMPLICIT NONE |
---|
| 432 | |
---|
[1933] | 433 | INTEGER, INTENT(IN) :: child_id !< |
---|
[1900] | 434 | REAL(wp), DIMENSION(:,:,:), INTENT(IN) :: buf !< |
---|
| 435 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 436 | INTEGER, INTENT(IN) :: child_rank !< |
---|
[1900] | 437 | INTEGER, INTENT(IN) :: tag !< |
---|
| 438 | INTEGER, INTENT(OUT) :: ierr !< |
---|
| 439 | |
---|
| 440 | ierr = 0 |
---|
[1933] | 441 | CALL MPI_SEND( buf, n, MPI_REAL, child_rank, tag, & |
---|
| 442 | m_to_child_comm(child_id), ierr ) |
---|
[1900] | 443 | |
---|
[1933] | 444 | END SUBROUTINE pmc_send_to_child_real_r3 |
---|
[1900] | 445 | |
---|
| 446 | |
---|
| 447 | |
---|
[1933] | 448 | SUBROUTINE pmc_recv_from_child_real_r3( child_id, buf, n, child_rank, tag, & |
---|
| 449 | ierr ) |
---|
[1900] | 450 | |
---|
| 451 | IMPLICIT NONE |
---|
| 452 | |
---|
[1933] | 453 | INTEGER, INTENT(IN) :: child_id !< |
---|
[1900] | 454 | REAL(wp), DIMENSION(:,:,:), INTENT(OUT) :: buf !< |
---|
| 455 | INTEGER, INTENT(IN) :: n !< |
---|
[1933] | 456 | INTEGER, INTENT(IN) :: child_rank !< |
---|
[1900] | 457 | INTEGER, INTENT(IN) :: tag !< |
---|
| 458 | INTEGER, INTENT(OUT) :: ierr !< |
---|
| 459 | |
---|
| 460 | ierr = 0 |
---|
[1933] | 461 | CALL MPI_RECV( buf, n, MPI_REAL, child_rank, tag, & |
---|
| 462 | m_to_child_comm(child_id), MPI_STATUS_IGNORE, ierr ) |
---|
[1900] | 463 | |
---|
[1933] | 464 | END SUBROUTINE pmc_recv_from_child_real_r3 |
---|
[1900] | 465 | |
---|
| 466 | |
---|
| 467 | |
---|
| 468 | SUBROUTINE pmc_bcast_integer( buf, root_pe, comm, ierr ) |
---|
| 469 | |
---|
| 470 | IMPLICIT NONE |
---|
| 471 | |
---|
| 472 | INTEGER, INTENT(INOUT) :: buf !< |
---|
| 473 | INTEGER, INTENT(IN) :: root_pe !< |
---|
| 474 | INTEGER, INTENT(IN), OPTIONAL :: comm !< |
---|
| 475 | INTEGER, INTENT(OUT), OPTIONAL :: ierr !< |
---|
| 476 | |
---|
| 477 | INTEGER :: mycomm !< |
---|
| 478 | INTEGER :: myerr !< |
---|
| 479 | |
---|
| 480 | |
---|
| 481 | IF ( PRESENT( comm ) ) THEN |
---|
| 482 | mycomm = comm |
---|
| 483 | ELSE |
---|
| 484 | mycomm = m_model_comm |
---|
| 485 | ENDIF |
---|
| 486 | |
---|
| 487 | CALL MPI_BCAST( buf, 1, MPI_INTEGER, root_pe, mycomm, myerr ) |
---|
| 488 | |
---|
| 489 | IF ( PRESENT( ierr ) ) THEN |
---|
| 490 | ierr = myerr |
---|
| 491 | ENDIF |
---|
| 492 | |
---|
| 493 | END SUBROUTINE pmc_bcast_integer |
---|
| 494 | |
---|
| 495 | |
---|
| 496 | |
---|
| 497 | SUBROUTINE pmc_bcast_character( buf, root_pe, comm, ierr ) |
---|
| 498 | |
---|
| 499 | IMPLICIT NONE |
---|
| 500 | |
---|
| 501 | CHARACTER(LEN=*), INTENT(INOUT) :: buf !< |
---|
| 502 | INTEGER, INTENT(IN) :: root_pe !< |
---|
| 503 | INTEGER, INTENT(IN), OPTIONAL :: comm !< |
---|
| 504 | INTEGER, INTENT(OUT), OPTIONAL :: ierr !< |
---|
| 505 | |
---|
| 506 | INTEGER :: mycomm !< |
---|
| 507 | INTEGER :: myerr !< |
---|
| 508 | |
---|
| 509 | IF ( PRESENT( comm ) ) THEN |
---|
| 510 | mycomm = comm |
---|
| 511 | ELSE |
---|
| 512 | mycomm = m_model_comm |
---|
| 513 | ENDIF |
---|
| 514 | |
---|
| 515 | CALL MPI_BCAST( buf, LEN(buf), MPI_CHARACTER, root_pe, mycomm, myerr ) |
---|
| 516 | |
---|
| 517 | IF ( PRESENT( ierr ) ) THEN |
---|
| 518 | ierr = myerr |
---|
| 519 | ENDIF |
---|
| 520 | |
---|
| 521 | END SUBROUTINE pmc_bcast_character |
---|
| 522 | |
---|
| 523 | |
---|
| 524 | |
---|
[1933] | 525 | SUBROUTINE pmc_inter_bcast_integer_1( buf, child_id, ierr ) |
---|
[1900] | 526 | |
---|
| 527 | IMPLICIT NONE |
---|
| 528 | |
---|
| 529 | INTEGER, INTENT(INOUT),DIMENSION(:) :: buf !< |
---|
[1933] | 530 | INTEGER, INTENT(IN),optional :: child_id !< |
---|
[1900] | 531 | INTEGER, INTENT(OUT),optional :: ierr !< |
---|
| 532 | |
---|
| 533 | INTEGER :: mycomm !< |
---|
| 534 | INTEGER :: myerr !< |
---|
| 535 | INTEGER :: root_pe !< |
---|
| 536 | |
---|
| 537 | ! |
---|
[1933] | 538 | !-- PE 0 on parent broadcast to all child PEs |
---|
| 539 | IF ( PRESENT( child_id ) ) THEN |
---|
[1900] | 540 | |
---|
[1933] | 541 | mycomm = m_to_child_comm(child_id) |
---|
[1900] | 542 | |
---|
| 543 | IF ( m_model_rank == 0 ) THEN |
---|
| 544 | root_pe = MPI_ROOT |
---|
| 545 | ELSE |
---|
| 546 | root_pe = MPI_PROC_NULL |
---|
| 547 | ENDIF |
---|
| 548 | |
---|
| 549 | ELSE |
---|
[1933] | 550 | mycomm = m_to_parent_comm |
---|
[1900] | 551 | root_pe = 0 |
---|
| 552 | ENDIF |
---|
| 553 | |
---|
| 554 | CALL MPI_BCAST( buf, SIZE( buf ), MPI_INTEGER, root_pe, mycomm, myerr ) |
---|
| 555 | |
---|
| 556 | IF ( PRESENT( ierr ) ) THEN |
---|
| 557 | ierr = myerr |
---|
| 558 | ENDIF |
---|
| 559 | |
---|
| 560 | END SUBROUTINE pmc_inter_bcast_integer_1 |
---|
| 561 | |
---|
| 562 | |
---|
| 563 | |
---|
| 564 | SUBROUTINE pmc_alloc_mem_integer_1( iarray, idim1 ) |
---|
| 565 | ! |
---|
| 566 | !-- Allocate memory with MPI_ALLOC_MEM using intermediate C-pointer |
---|
| 567 | |
---|
| 568 | IMPLICIT NONE |
---|
| 569 | |
---|
| 570 | INTEGER, DIMENSION(:), POINTER, INTENT(INOUT) :: iarray !< |
---|
| 571 | INTEGER, INTENT(IN) :: idim1 !< |
---|
| 572 | |
---|
| 573 | INTEGER, DIMENSION(1) :: ashape !< |
---|
| 574 | INTEGER(KIND=MPI_ADDRESS_KIND) :: winsize !< |
---|
| 575 | INTEGER :: ierr !< |
---|
| 576 | |
---|
| 577 | TYPE(C_PTR) :: p_myind !< |
---|
| 578 | |
---|
| 579 | winsize = idim1 * C_SIZEOF( ierr ) |
---|
| 580 | |
---|
| 581 | CALL MPI_ALLOC_MEM( winsize, MPI_INFO_NULL, p_myind, ierr ) |
---|
| 582 | ashape(1) = idim1 |
---|
| 583 | CALL C_F_POINTER( p_myind, iarray, ashape ) |
---|
| 584 | |
---|
| 585 | END SUBROUTINE pmc_alloc_mem_integer_1 |
---|
| 586 | |
---|
| 587 | |
---|
| 588 | |
---|
| 589 | SUBROUTINE pmc_alloc_mem_real_1( array, idim1, base_ptr ) |
---|
| 590 | |
---|
| 591 | IMPLICIT NONE |
---|
| 592 | |
---|
| 593 | INTEGER(idp), INTENT(IN) :: idim1 !< |
---|
| 594 | REAL(KIND=wp), DIMENSION(:), POINTER, INTENT(INOUT) :: array !< |
---|
| 595 | TYPE(C_PTR), INTENT(OUT), OPTIONAL :: base_ptr !< |
---|
| 596 | |
---|
| 597 | INTEGER, DIMENSION(1) :: ashape !< |
---|
| 598 | INTEGER(KIND=MPI_ADDRESS_KIND) :: winsize !< |
---|
| 599 | INTEGER :: ierr !< |
---|
| 600 | |
---|
| 601 | TYPE(C_PTR) :: p_myind !< |
---|
| 602 | |
---|
| 603 | winsize = idim1 * wp |
---|
| 604 | |
---|
| 605 | CALL MPI_ALLOC_MEM( winsize , MPI_INFO_NULL, p_myind, ierr ) |
---|
| 606 | ashape(1) = idim1 |
---|
| 607 | CALL C_F_POINTER( p_myind, array, ashape ) |
---|
| 608 | |
---|
| 609 | IF ( PRESENT( base_ptr ) ) THEN |
---|
| 610 | base_ptr = p_myind |
---|
| 611 | ENDIF |
---|
| 612 | |
---|
| 613 | END SUBROUTINE pmc_alloc_mem_Real_1 |
---|
| 614 | |
---|
| 615 | |
---|
| 616 | |
---|
| 617 | FUNCTION pmc_time() |
---|
| 618 | |
---|
| 619 | REAL(kind=wp) :: pmc_time !< |
---|
| 620 | |
---|
| 621 | pmc_time = MPI_WTIME() |
---|
| 622 | |
---|
| 623 | END FUNCTION pmc_time |
---|
| 624 | |
---|
[1764] | 625 | #endif |
---|
[1762] | 626 | END MODULE pmc_mpi_wrapper |
---|