| 1 |
edhill |
1.1 |
C $Header: /u/gcmpack/MITgcm/pkg/ex3/ex3_recv_rx1.template,v 1.2 2006/02/06 21:09:54 edhill Exp $ |
| 2 |
|
|
C $Name: $ |
| 3 |
|
|
|
| 4 |
|
|
#include "EX3_OPTIONS.h" |
| 5 |
|
|
|
| 6 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 7 |
|
|
CBOP 0 |
| 8 |
|
|
C !ROUTINE: EX3_RECV_RX1 |
| 9 |
|
|
|
| 10 |
|
|
C !INTERFACE: |
| 11 |
|
|
SUBROUTINE EX3_RECV_RX1( |
| 12 |
|
|
I bufftag, sendProc, |
| 13 |
|
|
I along_i, |
| 14 |
|
|
I il,ih,is, jl,jh,js, kl,kh,ks, |
| 15 |
|
|
I idl1,idh1, jdl1,jdh1, kdl1,kdh1, |
| 16 |
|
|
I array1, |
| 17 |
|
|
B buff, n_buff, |
| 18 |
|
|
I commType, |
| 19 |
|
|
I myThid ) |
| 20 |
|
|
|
| 21 |
|
|
C !DESCRIPTION: |
| 22 |
|
|
C Scalar exchange routine which simply copies values from an input |
| 23 |
|
|
C array to a buffer in the specified order and then, if necessary, |
| 24 |
|
|
C calls the appropriate MPI send function. |
| 25 |
|
|
|
| 26 |
|
|
C !USES: |
| 27 |
|
|
IMPLICIT NONE |
| 28 |
|
|
#include "SIZE.h" |
| 29 |
|
|
#include "EEPARAMS.h" |
| 30 |
|
|
#include "EESUPPORT.h" |
| 31 |
|
|
|
| 32 |
|
|
C !INPUT PARAMETERS: |
| 33 |
|
|
INTEGER bufftag, sendProc |
| 34 |
|
|
LOGICAL along_i |
| 35 |
|
|
INTEGER il,ih,is, jl,jh,js, kl,kh,ks |
| 36 |
|
|
INTEGER idl1,idh1, jdl1,jdh1, kdl1,kdh1 |
| 37 |
|
|
_RX array1( idl1:idh1, jdl1:jdh1, kdl1:kdh1 ) |
| 38 |
|
|
INTEGER n_buff |
| 39 |
|
|
_RX buff( n_buff ) |
| 40 |
|
|
CHARACTER commType |
| 41 |
|
|
INTEGER myThid |
| 42 |
|
|
CEOP |
| 43 |
|
|
|
| 44 |
|
|
C !LOCAL VARIABLES |
| 45 |
|
|
INTEGER ii,jj,kk, ntb, nbv |
| 46 |
|
|
#ifdef ALLOW_USE_MPI |
| 47 |
|
|
INTEGER mpiStatus(MPI_STATUS_SIZE) |
| 48 |
|
|
INTEGER mpirc |
| 49 |
|
|
#endif |
| 50 |
|
|
character*(100) msgbuf |
| 51 |
|
|
|
| 52 |
|
|
C Calculate buffer sizes |
| 53 |
|
|
nbv = IABS((ih-il+1)/is) |
| 54 |
|
|
& * IABS((jh-jl+1)/js) |
| 55 |
|
|
& * IABS((kh-kl+1)/ks) |
| 56 |
|
|
IF ( nbv .GT. n_buff ) THEN |
| 57 |
|
|
WRITE(msgbuf,'(2a)') 'EX3_RECV_RX1 ERROR: buffer too small', |
| 58 |
|
|
& '--please increase EX3_BUFF_FAC in ''EX3_SIZE.h''' |
| 59 |
|
|
CALL print_error(msgbuf, mythid) |
| 60 |
|
|
WRITE(msgbuf,'(a,i9)') ' current buffer length = ', n_buff |
| 61 |
|
|
CALL print_error(msgbuf, mythid) |
| 62 |
|
|
WRITE(msgbuf,'(a,i9)') ' requested buffer length = ', nbv |
| 63 |
|
|
CALL print_error(msgbuf, mythid) |
| 64 |
|
|
STOP 'ABNORMAL END: S/R EX3_RECV_RX1' |
| 65 |
|
|
ENDIF |
| 66 |
|
|
|
| 67 |
|
|
IF ( commType .EQ. 'P' ) THEN |
| 68 |
|
|
C We may eventually need (?) some sort of synchronization |
| 69 |
|
|
C mechanism for multi-threaded mode |
| 70 |
|
|
ELSEIF ( commType .EQ. 'M' ) THEN |
| 71 |
|
|
#ifdef ALLOW_USE_MPI |
| 72 |
|
|
CALL MPI_Recv( |
| 73 |
|
|
I buff, nbv, EX3_MPI_TYPE_RX, sendProc, bufftag, |
| 74 |
|
|
I MPI_COMM_MODEL, |
| 75 |
|
|
O mpiStatus, mpirc ) |
| 76 |
|
|
#endif |
| 77 |
|
|
ELSE |
| 78 |
|
|
WRITE(msgbuf,'(3a)') 'EX3_RECV_RX1 ERROR: commType ''', |
| 79 |
|
|
& commType, ''' is invalid' |
| 80 |
|
|
CALL print_error(msgbuf, mythid) |
| 81 |
|
|
STOP 'ABNORMAL END: S/R EX3_RECV_RX1' |
| 82 |
|
|
ENDIF |
| 83 |
|
|
|
| 84 |
|
|
C Copy the values into the buffer in the specified order |
| 85 |
|
|
ntb = 0 |
| 86 |
|
|
DO kk = kl, kh, ks |
| 87 |
|
|
IF ( along_i ) THEN |
| 88 |
|
|
C Here, the "i" dimension cycles fastest and it "measures" the |
| 89 |
|
|
C overlap width |
| 90 |
|
|
DO jj = jl, jh, js |
| 91 |
|
|
DO ii = il, ih, is |
| 92 |
|
|
ntb = ntb + 1 |
| 93 |
|
|
array1( ii, jj, kk ) = buff( ntb ) |
| 94 |
|
|
ENDDO |
| 95 |
|
|
ENDDO |
| 96 |
|
|
ELSE |
| 97 |
|
|
C Here, the "j" dimension cycles fastest and it "measures" the |
| 98 |
|
|
C overlap width |
| 99 |
|
|
DO ii = il, ih, is |
| 100 |
|
|
DO jj = jl, jh, js |
| 101 |
|
|
ntb = ntb + 1 |
| 102 |
|
|
array1( ii, jj, kk ) = buff( ntb ) |
| 103 |
|
|
ENDDO |
| 104 |
|
|
ENDDO |
| 105 |
|
|
ENDIF |
| 106 |
|
|
ENDDO |
| 107 |
|
|
|
| 108 |
|
|
RETURN |
| 109 |
|
|
END |
| 110 |
|
|
|
| 111 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 112 |
|
|
|
| 113 |
|
|
CEH3 ;;; Local Variables: *** |
| 114 |
|
|
CEH3 ;;; mode:fortran *** |
| 115 |
|
|
CEH3 ;;; End: *** |