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