00001 !||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 00002 00003 module ice_broadcast 00004 00005 !BOP 00006 ! !MODULE: ice_broadcast 00007 ! !DESCRIPTION: 00008 ! This module contains all the broadcast routines. This 00009 ! particular version contains MPI versions of these routines. 00010 ! 00011 ! !REVISION HISTORY: 00012 ! SVN:$Id: ice_broadcast.F90 100 2008-01-29 00:25:32Z eclare $ 00013 ! 00014 ! author: Phil Jones, LANL 00015 ! Oct. 2004: Adapted from POP version by William H. Lipscomb, LANL 00016 ! 00017 ! !USES: 00018 00019 use ice_kinds_mod 00020 use ice_communicate 00021 00022 implicit none 00023 private 00024 save 00025 00026 ! !PUBLIC MEMBER FUNCTIONS: 00027 00028 public :: broadcast_scalar, & 00029 broadcast_array 00030 00031 !EOP 00032 !BOC 00033 !----------------------------------------------------------------------- 00034 ! 00035 ! generic interfaces for module procedures 00036 ! 00037 !----------------------------------------------------------------------- 00038 00039 interface broadcast_scalar 00040 module procedure broadcast_scalar_dbl, & 00041 broadcast_scalar_real, & 00042 broadcast_scalar_int, & 00043 broadcast_scalar_log, & 00044 broadcast_scalar_char 00045 end interface 00046 00047 interface broadcast_array 00048 module procedure broadcast_array_dbl_1d, & 00049 broadcast_array_real_1d, & 00050 broadcast_array_int_1d, & 00051 broadcast_array_log_1d, & 00052 broadcast_array_dbl_2d, & 00053 broadcast_array_real_2d, & 00054 broadcast_array_int_2d, & 00055 broadcast_array_log_2d, & 00056 broadcast_array_dbl_3d, & 00057 broadcast_array_real_3d, & 00058 broadcast_array_int_3d, & 00059 broadcast_array_log_3d 00060 end interface 00061 00062 !EOC 00063 !*********************************************************************** 00064 00065 contains 00066 00067 !*********************************************************************** 00068 !BOP 00069 ! !IROUTINE: broadcast_scalar_dbl 00070 ! !INTERFACE: 00071 00072 subroutine broadcast_scalar_dbl(scalar, root_pe) 00073 00074 ! !DESCRIPTION: 00075 ! Broadcasts a scalar dbl variable from one processor (root_pe) 00076 ! to all other processors. This is a specific instance of the generic 00077 ! broadcast\_scalar interface. 00078 ! 00079 ! !REVISION HISTORY: 00080 ! same as module 00081 00082 ! !INCLUDES: 00083 00084 include 'mpif.h' ! MPI Fortran include file 00085 00086 ! !INPUT PARAMETERS: 00087 00088 integer (int_kind), intent(in) :: 00089 root_pe ! processor number to broadcast from 00090 00091 ! !INPUT/OUTPUT PARAMETERS: 00092 00093 real (dbl_kind), intent(inout) :: 00094 scalar ! scalar to be broadcast 00095 00096 !EOP 00097 !BOC 00098 !----------------------------------------------------------------------- 00099 ! 00100 ! local variables 00101 ! 00102 !----------------------------------------------------------------------- 00103 00104 integer (int_kind) :: ierr ! local MPI error flag 00105 00106 !----------------------------------------------------------------------- 00107 00108 call MPI_BCAST(scalar, 1, mpiR8, root_pe, MPI_COMM_ICE, ierr) 00109 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00110 00111 !----------------------------------------------------------------------- 00112 !EOC 00113 00114 end subroutine broadcast_scalar_dbl 00115 00116 !*********************************************************************** 00117 !BOP 00118 ! !IROUTINE: broadcast_scalar_real 00119 ! !INTERFACE: 00120 00121 subroutine broadcast_scalar_real(scalar, root_pe) 00122 00123 ! !DESCRIPTION: 00124 ! Broadcasts a scalar real variable from one processor (root_pe) 00125 ! to all other processors. This is a specific instance of the generic 00126 ! broadcast\_scalar interface. 00127 ! 00128 ! !REVISION HISTORY: 00129 ! same as module 00130 ! 00131 ! !INCLUDES: 00132 00133 include 'mpif.h' ! MPI Fortran include file 00134 00135 ! !INPUT PARAMETERS: 00136 00137 integer (int_kind), intent(in) :: 00138 root_pe ! processor number to broadcast from 00139 00140 ! !INPUT/OUTPUT PARAMETERS: 00141 00142 real (real_kind), intent(inout) :: 00143 scalar ! scalar to be broadcast 00144 00145 !EOP 00146 !BOC 00147 !----------------------------------------------------------------------- 00148 ! 00149 ! local variables 00150 ! 00151 !----------------------------------------------------------------------- 00152 00153 integer (int_kind) :: ierr ! local MPI error flag 00154 00155 !----------------------------------------------------------------------- 00156 00157 call MPI_BCAST(scalar, 1, mpiR4, root_pe, MPI_COMM_ICE, ierr) 00158 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00159 00160 !----------------------------------------------------------------------- 00161 !EOC 00162 00163 end subroutine broadcast_scalar_real 00164 00165 !*********************************************************************** 00166 !BOP 00167 ! !IROUTINE: broadcast_scalar_int 00168 ! !INTERFACE: 00169 00170 subroutine broadcast_scalar_int(scalar, root_pe) 00171 00172 ! !DESCRIPTION: 00173 ! Broadcasts a scalar integer variable from one processor (root_pe) 00174 ! to all other processors. This is a specific instance of the generic 00175 ! broadcast\_scalar interface. 00176 ! 00177 ! !REVISION HISTORY: 00178 ! same as module 00179 00180 ! !INCLUDES: 00181 00182 include 'mpif.h' ! MPI Fortran include file 00183 00184 ! !INPUT PARAMETERS: 00185 00186 integer (int_kind), intent(in) :: 00187 root_pe ! processor number to broadcast from 00188 00189 ! !INPUT/OUTPUT PARAMETERS: 00190 00191 integer (int_kind), intent(inout) :: 00192 scalar ! scalar to be broadcast 00193 00194 !EOP 00195 !BOC 00196 !----------------------------------------------------------------------- 00197 ! 00198 ! local variables 00199 ! 00200 !----------------------------------------------------------------------- 00201 00202 integer (int_kind) :: ierr ! local MPI error flag 00203 00204 !----------------------------------------------------------------------- 00205 00206 call MPI_BCAST(scalar, 1, MPI_INTEGER, root_pe, MPI_COMM_ICE,ierr) 00207 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00208 00209 !----------------------------------------------------------------------- 00210 !EOC 00211 00212 end subroutine broadcast_scalar_int 00213 00214 !*********************************************************************** 00215 !BOP 00216 ! !IROUTINE: broadcast_scalar_log 00217 ! !INTERFACE: 00218 00219 subroutine broadcast_scalar_log(scalar, root_pe) 00220 00221 ! !DESCRIPTION: 00222 ! Broadcasts a scalar logical variable from one processor (root_pe) 00223 ! to all other processors. This is a specific instance of the generic 00224 ! broadcast\_scalar interface. 00225 ! 00226 ! !REVISION HISTORY: 00227 ! same as module 00228 00229 ! !INCLUDES: 00230 00231 include 'mpif.h' ! MPI Fortran include file 00232 00233 ! !INPUT PARAMETERS: 00234 00235 integer (int_kind), intent(in) :: 00236 root_pe ! processor number to broadcast from 00237 00238 ! !INPUT/OUTPUT PARAMETERS: 00239 00240 logical (log_kind), intent(inout) :: 00241 scalar ! scalar to be broadcast 00242 00243 !EOP 00244 !BOC 00245 !----------------------------------------------------------------------- 00246 ! 00247 ! local variables 00248 ! 00249 !----------------------------------------------------------------------- 00250 00251 integer (int_kind) :: 00252 itmp, ! local temporary 00253 ierr ! MPI error flag 00254 00255 !----------------------------------------------------------------------- 00256 00257 if (scalar) then 00258 itmp = 1 00259 else 00260 itmp = 0 00261 endif 00262 00263 call MPI_BCAST(itmp, 1, MPI_INTEGER, root_pe, MPI_COMM_ICE, ierr) 00264 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00265 00266 if (itmp == 1) then 00267 scalar = .true. 00268 else 00269 scalar = .false. 00270 endif 00271 00272 !----------------------------------------------------------------------- 00273 !EOC 00274 00275 end subroutine broadcast_scalar_log 00276 00277 !*********************************************************************** 00278 !BOP 00279 ! !IROUTINE: broadcast_scalar_char 00280 ! !INTERFACE: 00281 00282 subroutine broadcast_scalar_char(scalar, root_pe) 00283 00284 ! !DESCRIPTION: 00285 ! Broadcasts a scalar character variable from one processor (root_pe) 00286 ! to all other processors. This is a specific instance of the generic 00287 ! broadcast\_scalar interface. 00288 ! 00289 ! !REVISION HISTORY: 00290 ! same as module 00291 00292 ! !INCLUDES: 00293 00294 include 'mpif.h' ! MPI Fortran include file 00295 00296 ! !INPUT PARAMETERS: 00297 00298 integer (int_kind), intent(in) :: 00299 root_pe ! processor number to broadcast from 00300 00301 ! !INPUT/OUTPUT PARAMETERS: 00302 00303 character (*), intent(inout) :: 00304 scalar ! scalar to be broadcast 00305 00306 !EOP 00307 !BOC 00308 !----------------------------------------------------------------------- 00309 ! 00310 ! local variables 00311 ! 00312 !----------------------------------------------------------------------- 00313 00314 integer (int_kind) :: 00315 clength, ! length of character 00316 ierr ! MPI error flag 00317 00318 !----------------------------------------------------------------------- 00319 00320 clength = len(scalar) 00321 00322 call MPI_BCAST(scalar, clength, MPI_CHARACTER, root_pe, MPI_COMM_ICE, ierr) 00323 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00324 00325 !-------------------------------------------------------------------- 00326 !EOC 00327 00328 end subroutine broadcast_scalar_char 00329 00330 !*********************************************************************** 00331 !BOP 00332 ! !IROUTINE: broadcast_array_dbl_1d 00333 ! !INTERFACE: 00334 00335 subroutine broadcast_array_dbl_1d(array, root_pe) 00336 00337 ! !DESCRIPTION: 00338 ! Broadcasts a vector dbl variable from one processor (root_pe) 00339 ! to all other processors. This is a specific instance of the generic 00340 ! broadcast\_array interface. 00341 ! 00342 ! !REVISION HISTORY: 00343 ! same as module 00344 00345 ! !INCLUDES: 00346 00347 include 'mpif.h' ! MPI Fortran include file 00348 00349 ! !INPUT PARAMETERS: 00350 00351 integer (int_kind), intent(in) :: 00352 root_pe ! processor number to broadcast from 00353 00354 ! !INPUT/OUTPUT PARAMETERS: 00355 00356 real (dbl_kind), dimension(:), intent(inout) :: 00357 array ! array to be broadcast 00358 00359 !EOP 00360 !BOC 00361 !----------------------------------------------------------------------- 00362 ! 00363 ! local variables 00364 ! 00365 !----------------------------------------------------------------------- 00366 00367 integer (int_kind) :: 00368 nelements, ! size of array 00369 ierr ! local MPI error flag 00370 00371 !----------------------------------------------------------------------- 00372 00373 nelements = size(array) 00374 00375 call MPI_BCAST(array, nelements, mpiR8, root_pe, MPI_COMM_ICE, ierr) 00376 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00377 00378 !----------------------------------------------------------------------- 00379 !EOC 00380 00381 end subroutine broadcast_array_dbl_1d 00382 00383 !*********************************************************************** 00384 !BOP 00385 ! !IROUTINE: broadcast_array_real_1d 00386 ! !INTERFACE: 00387 00388 subroutine broadcast_array_real_1d(array, root_pe) 00389 00390 ! !DESCRIPTION: 00391 ! Broadcasts a real vector from one processor (root_pe) 00392 ! to all other processors. This is a specific instance of the generic 00393 ! broadcast\_array interface. 00394 ! 00395 ! !REVISION HISTORY: 00396 ! same as module 00397 00398 ! !INCLUDES: 00399 00400 include 'mpif.h' ! MPI Fortran include file 00401 00402 ! !INPUT PARAMETERS: 00403 00404 integer (int_kind), intent(in) :: 00405 root_pe ! processor number to broadcast from 00406 00407 ! !INPUT/OUTPUT PARAMETERS: 00408 00409 real (real_kind), dimension(:), intent(inout) :: 00410 array ! array to be broadcast 00411 00412 !EOP 00413 !BOC 00414 !----------------------------------------------------------------------- 00415 ! 00416 ! local variables 00417 ! 00418 !----------------------------------------------------------------------- 00419 00420 integer (int_kind) :: 00421 nelements, ! size of array to be broadcast 00422 ierr ! local MPI error flag 00423 00424 !----------------------------------------------------------------------- 00425 00426 nelements = size(array) 00427 00428 call MPI_BCAST(array, nelements, mpiR4, root_pe, MPI_COMM_ICE, ierr) 00429 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00430 00431 !----------------------------------------------------------------------- 00432 !EOC 00433 00434 end subroutine broadcast_array_real_1d 00435 00436 !*********************************************************************** 00437 !BOP 00438 ! !IROUTINE: broadcast_array_int_1d 00439 ! !INTERFACE: 00440 00441 subroutine broadcast_array_int_1d(array, root_pe) 00442 00443 ! !DESCRIPTION: 00444 ! Broadcasts an integer vector from one processor (root_pe) 00445 ! to all other processors. This is a specific instance of the generic 00446 ! broadcast\_array interface. 00447 ! 00448 ! !REVISION HISTORY: 00449 ! same as module 00450 00451 ! !INCLUDES: 00452 00453 include 'mpif.h' ! MPI Fortran include file 00454 00455 ! !INPUT PARAMETERS: 00456 00457 integer (int_kind), intent(in) :: 00458 root_pe ! processor number to broadcast from 00459 00460 ! !INPUT/OUTPUT PARAMETERS: 00461 00462 integer (int_kind), dimension(:), intent(inout) :: 00463 array ! array to be broadcast 00464 00465 !EOP 00466 !BOC 00467 !----------------------------------------------------------------------- 00468 ! 00469 ! local variables 00470 ! 00471 !----------------------------------------------------------------------- 00472 00473 integer (int_kind) :: 00474 nelements, ! size of array to be broadcast 00475 ierr ! local MPI error flag 00476 00477 !----------------------------------------------------------------------- 00478 00479 nelements = size(array) 00480 00481 call MPI_BCAST(array, nelements, MPI_INTEGER, root_pe, MPI_COMM_ICE, ierr) 00482 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00483 00484 !----------------------------------------------------------------------- 00485 !EOC 00486 00487 end subroutine broadcast_array_int_1d 00488 00489 !*********************************************************************** 00490 !BOP 00491 ! !IROUTINE: broadcast_array_log_1d 00492 ! !INTERFACE: 00493 00494 subroutine broadcast_array_log_1d(array, root_pe) 00495 00496 ! !DESCRIPTION: 00497 ! Broadcasts a logical vector from one processor (root_pe) 00498 ! to all other processors. This is a specific instance of the generic 00499 ! broadcast\_array interface. 00500 ! 00501 ! !REVISION HISTORY: 00502 ! same as module 00503 00504 ! !INCLUDES: 00505 00506 include 'mpif.h' ! MPI Fortran include file 00507 00508 ! !INPUT PARAMETERS: 00509 00510 integer (int_kind), intent(in) :: 00511 root_pe ! processor number to broadcast from 00512 00513 ! !INPUT/OUTPUT PARAMETERS: 00514 00515 logical (log_kind), dimension(:), intent(inout) :: 00516 array ! array to be broadcast 00517 00518 !EOP 00519 !BOC 00520 !----------------------------------------------------------------------- 00521 ! 00522 ! local variables 00523 ! 00524 !----------------------------------------------------------------------- 00525 00526 integer (int_kind), dimension(:), allocatable :: 00527 array_int ! temporary array for MPI bcast 00528 00529 integer (int_kind) :: 00530 nelements, ! size of array to be broadcast 00531 ierr ! local MPI error flag 00532 00533 !----------------------------------------------------------------------- 00534 00535 nelements = size(array) 00536 allocate(array_int(nelements)) 00537 00538 where (array) 00539 array_int = 1 00540 elsewhere 00541 array_int = 0 00542 end where 00543 00544 call MPI_BCAST(array_int, nelements, MPI_INTEGER, root_pe, & 00545 MPI_COMM_ICE, ierr) 00546 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00547 00548 where (array_int == 1) 00549 array = .true. 00550 elsewhere 00551 array = .false. 00552 end where 00553 00554 deallocate(array_int) 00555 00556 !----------------------------------------------------------------------- 00557 !EOC 00558 00559 end subroutine broadcast_array_log_1d 00560 00561 !*********************************************************************** 00562 !BOP 00563 ! !IROUTINE: broadcast_array_dbl_2d 00564 ! !INTERFACE: 00565 00566 subroutine broadcast_array_dbl_2d(array, root_pe) 00567 00568 ! !DESCRIPTION: 00569 ! Broadcasts a dbl 2d array from one processor (root_pe) 00570 ! to all other processors. This is a specific instance of the generic 00571 ! broadcast\_array interface. 00572 ! 00573 ! !REVISION HISTORY: 00574 ! same as module 00575 00576 ! !INCLUDES: 00577 00578 include 'mpif.h' ! MPI Fortran include file 00579 00580 ! !INPUT PARAMETERS: 00581 00582 integer (int_kind), intent(in) :: 00583 root_pe ! processor number to broadcast from 00584 00585 ! !INPUT/OUTPUT PARAMETERS: 00586 00587 real (dbl_kind), dimension(:,:), intent(inout) :: 00588 array ! array to be broadcast 00589 00590 !EOP 00591 !BOC 00592 !----------------------------------------------------------------------- 00593 ! 00594 ! local variables 00595 ! 00596 !----------------------------------------------------------------------- 00597 00598 integer (int_kind) :: 00599 nelements, ! size of array 00600 ierr ! local MPI error flag 00601 00602 !----------------------------------------------------------------------- 00603 00604 nelements = size(array) 00605 00606 call MPI_BCAST(array, nelements, mpiR8, root_pe, MPI_COMM_ICE, ierr) 00607 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00608 00609 !----------------------------------------------------------------------- 00610 !EOC 00611 00612 end subroutine broadcast_array_dbl_2d 00613 00614 !*********************************************************************** 00615 !BOP 00616 ! !IROUTINE: broadcast_array_real_2d 00617 ! !INTERFACE: 00618 00619 subroutine broadcast_array_real_2d(array, root_pe) 00620 00621 ! !DESCRIPTION: 00622 ! Broadcasts a real 2d array from one processor (root_pe) 00623 ! to all other processors. This is a specific instance of the generic 00624 ! broadcast\_array interface. 00625 ! 00626 ! !REVISION HISTORY: 00627 ! same as module 00628 00629 ! !INCLUDES: 00630 00631 include 'mpif.h' ! MPI Fortran include file 00632 00633 ! !INPUT PARAMETERS: 00634 00635 integer (int_kind), intent(in) :: 00636 root_pe ! processor number to broadcast from 00637 00638 ! !INPUT/OUTPUT PARAMETERS: 00639 00640 real (real_kind), dimension(:,:), intent(inout) :: 00641 array ! array to be broadcast 00642 00643 !EOP 00644 !BOC 00645 !----------------------------------------------------------------------- 00646 ! 00647 ! local variables 00648 ! 00649 !----------------------------------------------------------------------- 00650 00651 integer (int_kind) :: 00652 nelements, ! size of array to be broadcast 00653 ierr ! local MPI error flag 00654 00655 !----------------------------------------------------------------------- 00656 00657 nelements = size(array) 00658 00659 call MPI_BCAST(array, nelements, mpiR4, root_pe, MPI_COMM_ICE, ierr) 00660 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00661 00662 !----------------------------------------------------------------------- 00663 !EOC 00664 00665 end subroutine broadcast_array_real_2d 00666 00667 !*********************************************************************** 00668 !BOP 00669 ! !IROUTINE: broadcast_array_int_2d 00670 ! !INTERFACE: 00671 00672 subroutine broadcast_array_int_2d(array, root_pe) 00673 00674 ! !DESCRIPTION: 00675 ! Broadcasts a 2d integer array from one processor (root_pe) 00676 ! to all other processors. This is a specific instance of the generic 00677 ! broadcast\_array interface. 00678 ! 00679 ! !REVISION HISTORY: 00680 ! same as module 00681 00682 ! !INCLUDES: 00683 00684 include 'mpif.h' ! MPI Fortran include file 00685 00686 ! !INPUT PARAMETERS: 00687 00688 integer (int_kind), intent(in) :: 00689 root_pe ! processor number to broadcast from 00690 00691 ! !INPUT/OUTPUT PARAMETERS: 00692 00693 integer (int_kind), dimension(:,:), intent(inout) :: 00694 array ! array to be broadcast 00695 00696 !EOP 00697 !BOC 00698 !----------------------------------------------------------------------- 00699 ! 00700 ! local variables 00701 ! 00702 !----------------------------------------------------------------------- 00703 00704 integer (int_kind) :: 00705 nelements, ! size of array to be broadcast 00706 ierr ! local MPI error flag 00707 00708 !----------------------------------------------------------------------- 00709 00710 nelements = size(array) 00711 00712 call MPI_BCAST(array, nelements, MPI_INTEGER, root_pe, MPI_COMM_ICE, ierr) 00713 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00714 00715 !----------------------------------------------------------------------- 00716 !EOC 00717 00718 end subroutine broadcast_array_int_2d 00719 00720 !*********************************************************************** 00721 !BOP 00722 ! !IROUTINE: broadcast_array_log_2d 00723 ! !INTERFACE: 00724 00725 subroutine broadcast_array_log_2d(array, root_pe) 00726 00727 ! !DESCRIPTION: 00728 ! Broadcasts a logical 2d array from one processor (root_pe) 00729 ! to all other processors. This is a specific instance of the generic 00730 ! broadcast\_array interface. 00731 ! 00732 ! !REVISION HISTORY: 00733 ! same as module 00734 00735 ! !INCLUDES: 00736 00737 include 'mpif.h' ! MPI Fortran include file 00738 00739 ! !INPUT PARAMETERS: 00740 00741 integer (int_kind), intent(in) :: 00742 root_pe ! processor number to broadcast from 00743 00744 ! !INPUT/OUTPUT PARAMETERS: 00745 00746 logical (log_kind), dimension(:,:), intent(inout) :: 00747 array ! array to be broadcast 00748 00749 !EOP 00750 !BOC 00751 !----------------------------------------------------------------------- 00752 ! 00753 ! local variables 00754 ! 00755 !----------------------------------------------------------------------- 00756 00757 integer (int_kind), dimension(:,:), allocatable :: 00758 array_int ! temporary array for MPI bcast 00759 00760 integer (int_kind) :: 00761 nelements, ! size of array to be broadcast 00762 ierr ! local MPI error flag 00763 00764 !----------------------------------------------------------------------- 00765 00766 nelements = size(array) 00767 allocate(array_int(size(array,dim=1),size(array,dim=2))) 00768 00769 where (array) 00770 array_int = 1 00771 elsewhere 00772 array_int = 0 00773 end where 00774 00775 call MPI_BCAST(array_int, nelements, MPI_INTEGER, root_pe, & 00776 MPI_COMM_ICE, ierr) 00777 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00778 00779 where (array_int == 1) 00780 array = .true. 00781 elsewhere 00782 array = .false. 00783 end where 00784 00785 deallocate(array_int) 00786 00787 !----------------------------------------------------------------------- 00788 !EOC 00789 00790 end subroutine broadcast_array_log_2d 00791 00792 !*********************************************************************** 00793 !BOP 00794 ! !IROUTINE: broadcast_array_dbl_3d 00795 ! !INTERFACE: 00796 00797 subroutine broadcast_array_dbl_3d(array, root_pe) 00798 00799 ! !DESCRIPTION: 00800 ! Broadcasts a double 3d array from one processor (root_pe) 00801 ! to all other processors. This is a specific instance of the generic 00802 ! broadcast\_array interface. 00803 ! 00804 ! !REVISION HISTORY: 00805 ! same as module 00806 00807 ! !INCLUDES: 00808 00809 include 'mpif.h' ! MPI Fortran include file 00810 00811 ! !INPUT PARAMETERS: 00812 00813 integer (int_kind), intent(in) :: 00814 root_pe ! processor number to broadcast from 00815 00816 ! !INPUT/OUTPUT PARAMETERS: 00817 00818 real (dbl_kind), dimension(:,:,:), intent(inout) :: 00819 array ! array to be broadcast 00820 00821 !EOP 00822 !BOC 00823 !----------------------------------------------------------------------- 00824 ! 00825 ! local variables 00826 ! 00827 !----------------------------------------------------------------------- 00828 00829 integer (int_kind) :: 00830 nelements, ! size of array 00831 ierr ! local MPI error flag 00832 00833 !----------------------------------------------------------------------- 00834 00835 nelements = size(array) 00836 00837 call MPI_BCAST(array, nelements, mpiR8, root_pe, MPI_COMM_ICE, ierr) 00838 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00839 00840 !----------------------------------------------------------------------- 00841 !EOC 00842 00843 end subroutine broadcast_array_dbl_3d 00844 00845 !*********************************************************************** 00846 !BOP 00847 ! !IROUTINE: broadcast_array_real_3d 00848 ! !INTERFACE: 00849 00850 subroutine broadcast_array_real_3d(array, root_pe) 00851 00852 ! !DESCRIPTION: 00853 ! Broadcasts a real 3d array from one processor (root_pe) 00854 ! to all other processors. This is a specific instance of the generic 00855 ! broadcast\_array interface. 00856 ! 00857 ! !REVISION HISTORY: 00858 ! same as module 00859 00860 ! !INCLUDES: 00861 00862 include 'mpif.h' ! MPI Fortran include file 00863 00864 ! !INPUT PARAMETERS: 00865 00866 integer (int_kind), intent(in) :: 00867 root_pe ! processor number to broadcast from 00868 00869 ! !INPUT/OUTPUT PARAMETERS: 00870 00871 real (real_kind), dimension(:,:,:), intent(inout) :: 00872 array ! array to be broadcast 00873 00874 !EOP 00875 !BOC 00876 !----------------------------------------------------------------------- 00877 ! 00878 ! local variables 00879 ! 00880 !----------------------------------------------------------------------- 00881 00882 integer (int_kind) :: 00883 nelements, ! size of array to be broadcast 00884 ierr ! local MPI error flag 00885 00886 !----------------------------------------------------------------------- 00887 00888 nelements = size(array) 00889 00890 call MPI_BCAST(array, nelements, mpiR4, root_pe, MPI_COMM_ICE, ierr) 00891 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00892 00893 !----------------------------------------------------------------------- 00894 !EOC 00895 00896 end subroutine broadcast_array_real_3d 00897 00898 !*********************************************************************** 00899 !BOP 00900 ! !IROUTINE: broadcast_array_int_3d 00901 ! !INTERFACE: 00902 00903 subroutine broadcast_array_int_3d(array, root_pe) 00904 00905 ! !DESCRIPTION: 00906 ! Broadcasts an integer 3d array from one processor (root_pe) 00907 ! to all other processors. This is a specific instance of the generic 00908 ! broadcast\_array interface. 00909 ! 00910 ! !REVISION HISTORY: 00911 ! same as module 00912 00913 ! !INCLUDES: 00914 00915 include 'mpif.h' ! MPI Fortran include file 00916 00917 ! !INPUT PARAMETERS: 00918 00919 integer (int_kind), intent(in) :: 00920 root_pe ! processor number to broadcast from 00921 00922 ! !INPUT/OUTPUT PARAMETERS: 00923 00924 integer (int_kind), dimension(:,:,:), intent(inout) :: 00925 array ! array to be broadcast 00926 00927 !EOP 00928 !BOC 00929 !----------------------------------------------------------------------- 00930 ! 00931 ! local variables 00932 ! 00933 !----------------------------------------------------------------------- 00934 00935 integer (int_kind) :: 00936 nelements, ! size of array to be broadcast 00937 ierr ! local MPI error flag 00938 00939 !----------------------------------------------------------------------- 00940 00941 nelements = size(array) 00942 00943 call MPI_BCAST(array, nelements, MPI_INTEGER, root_pe, MPI_COMM_ICE, ierr) 00944 call MPI_BARRIER(MPI_COMM_ICE, ierr) 00945 00946 !----------------------------------------------------------------------- 00947 !EOC 00948 00949 end subroutine broadcast_array_int_3d 00950 00951 !*********************************************************************** 00952 !BOP 00953 ! !IROUTINE: broadcast_array_log_3d 00954 ! !INTERFACE: 00955 00956 subroutine broadcast_array_log_3d(array, root_pe) 00957 00958 ! !DESCRIPTION: 00959 ! Broadcasts a logical 3d array from one processor (root_pe) 00960 ! to all other processors. This is a specific instance of the generic 00961 ! broadcast\_array interface. 00962 ! 00963 ! !REVISION HISTORY: 00964 ! same as module 00965 00966 ! !INCLUDES: 00967 00968 include 'mpif.h' ! MPI Fortran include file 00969 00970 ! !INPUT PARAMETERS: 00971 00972 integer (int_kind), intent(in) :: 00973 root_pe ! processor number to broadcast from 00974 00975 ! !INPUT/OUTPUT PARAMETERS: 00976 00977 logical (log_kind), dimension(:,:,:), intent(inout) :: 00978 array ! array to be broadcast 00979 00980 !EOP 00981 !BOC 00982 !----------------------------------------------------------------------- 00983 ! 00984 ! local variables 00985 ! 00986 !----------------------------------------------------------------------- 00987 00988 integer (int_kind), dimension(:,:,:), allocatable :: 00989 array_int ! temporary array for MPI bcast 00990 00991 integer (int_kind) :: 00992 nelements, ! size of array to be broadcast 00993 ierr ! local MPI error flag 00994 00995 !----------------------------------------------------------------------- 00996 00997 nelements = size(array) 00998 allocate(array_int(size(array,dim=1), & 00999 size(array,dim=2), & 01000 size(array,dim=3))) 01001 01002 where (array) 01003 array_int = 1 01004 elsewhere 01005 array_int = 0 01006 end where 01007 01008 call MPI_BCAST(array_int, nelements, MPI_INTEGER, root_pe, & 01009 MPI_COMM_ICE, ierr) 01010 call MPI_BARRIER(MPI_COMM_ICE, ierr) 01011 01012 where (array_int == 1) 01013 array = .true. 01014 elsewhere 01015 array = .false. 01016 end where 01017 01018 deallocate(array_int) 01019 01020 !----------------------------------------------------------------------- 01021 !EOC 01022 01023 end subroutine broadcast_array_log_3d 01024 01025 !*********************************************************************** 01026 01027 end module ice_broadcast 01028 01029 !|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||