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