1 |
C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_send_rx1.template,v 1.11 2009/05/30 21:18:59 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_EEOPTIONS.h" |
5 |
#include "W2_OPTIONS.h" |
6 |
|
7 |
CBOP 0 |
8 |
C !ROUTINE: EXCH2_SEND_RX1 |
9 |
|
10 |
C !INTERFACE: |
11 |
SUBROUTINE EXCH2_SEND_RX1 ( |
12 |
I thisTile, nN, |
13 |
I e2BufrRecSize, |
14 |
I iBufr, |
15 |
I e2Bufr1_RX, |
16 |
O e2_msgHandle, |
17 |
I commSetting, myThid ) |
18 |
|
19 |
C !DESCRIPTION: |
20 |
C Scalar field (1 component) Exchange: |
21 |
C Send buffer to the target Process. |
22 |
C buffer has been previously filled with interior data point |
23 |
C corresponding to the target-neighbour-edge overlap region. |
24 |
|
25 |
C !USES: |
26 |
IMPLICIT NONE |
27 |
|
28 |
#include "SIZE.h" |
29 |
#include "EEPARAMS.h" |
30 |
#include "EESUPPORT.h" |
31 |
#include "W2_EXCH2_SIZE.h" |
32 |
#include "W2_EXCH2_TOPOLOGY.h" |
33 |
|
34 |
C !INPUT/OUTPUT PARAMETERS: |
35 |
C === Routine arguments === |
36 |
C thisTile :: sending tile Id. number |
37 |
C nN :: Neighbour entry that we are processing |
38 |
C e2BufrRecSize :: Number of elements in each entry of e2Bufr1_RX |
39 |
C iBufr :: number of buffer elements to transfer |
40 |
C e2Bufr1_RX :: Data transport buffer array. This array is used in one of |
41 |
C :: two ways. For PUT communication the entry in the buffer |
42 |
C :: associated with the source for this receive (determined |
43 |
C :: from the opposing_send index) is read. |
44 |
C :: For MSG communication the entry in the buffer associated |
45 |
C :: with this neighbor of this tile is used as a receive |
46 |
C :: location for loading a linear stream of bytes. |
47 |
C e2_msgHandles :: Synchronization and coordination data structure used to |
48 |
C :: coordinate access to e2Bufr1_RX or to regulate message |
49 |
C :: buffering. In PUT communication sender will increment |
50 |
C :: handle entry once data is ready in buffer. Receiver will |
51 |
C :: decrement handle once data is consumed from buffer. |
52 |
C :: For MPI MSG communication MPI_Wait uses handle to check |
53 |
C :: Isend has cleared. This is done in routine after receives. |
54 |
C commSetting :: Mode of communication used to exchange with this neighbor |
55 |
C myThid :: my Thread Id. number |
56 |
|
57 |
INTEGER thisTile, nN |
58 |
INTEGER e2BufrRecSize |
59 |
INTEGER iBufr |
60 |
_RX e2Bufr1_RX( e2BufrRecSize ) |
61 |
INTEGER e2_msgHandle(1) |
62 |
CHARACTER commSetting |
63 |
INTEGER myThid |
64 |
CEOP |
65 |
|
66 |
#ifdef ALLOW_USE_MPI |
67 |
C !LOCAL VARIABLES: |
68 |
C == Local variables == |
69 |
C tgT :: Target tile |
70 |
INTEGER tgT |
71 |
|
72 |
C MPI setup |
73 |
INTEGER theTag, theType, theHandle |
74 |
INTEGER sProc, tProc, mpiRc |
75 |
#ifdef W2_E2_DEBUG_ON |
76 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
77 |
#endif |
78 |
|
79 |
tgT = exch2_neighbourId(nN, thisTile ) |
80 |
|
81 |
C Do data transport depending on communication mechanism between |
82 |
C source and target tile |
83 |
IF ( commSetting .EQ. 'M' ) THEN |
84 |
C Setup MPI stuff here |
85 |
theTag = (thisTile-1)*W2_maxNeighbours + nN |
86 |
tProc = exch2_tProc(tgT)-1 |
87 |
sProc = exch2_tProc(thisTile)-1 |
88 |
theType = _MPI_TYPE_RX |
89 |
#ifdef W2_E2_DEBUG_ON |
90 |
WRITE(msgBuf,'(A,I5,A,I5,A)') |
91 |
& ' SEND FROM TILE=', thisTile, ' (proc =',sProc,')' |
92 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
93 |
I SQUEEZE_RIGHT, myThid) |
94 |
WRITE(msgBuf,'(A,I5,A,I5,A)') |
95 |
& ' TO TILE=', tgT ' (proc =',tProc,')' |
96 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
97 |
I SQUEEZE_RIGHT, myThid) |
98 |
WRITE(msgBuf,'(A,I10)') ' TAG=', theTag |
99 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
100 |
I SQUEEZE_RIGHT, myThid) |
101 |
WRITE(msgBuf,'(A,I4)') ' NEL=', iBufr |
102 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
103 |
I SQUEEZE_RIGHT, myThid) |
104 |
#endif /* W2_E2_DEBUG_ON */ |
105 |
CALL MPI_Isend( e2Bufr1_RX, iBufr, theType, |
106 |
I tProc, theTag, MPI_COMM_MODEL, |
107 |
O theHandle, mpiRc ) |
108 |
C Store MPI_Wait token in messageHandle. |
109 |
e2_msgHandle(1) = theHandle |
110 |
ENDIF |
111 |
#endif /* ALLOW_USE_MPI */ |
112 |
|
113 |
RETURN |
114 |
END |
115 |
|
116 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
117 |
|
118 |
CEH3 ;;; Local Variables: *** |
119 |
CEH3 ;;; mode:fortran *** |
120 |
CEH3 ;;; End: *** |