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