1 |
jmc |
1.12 |
C $Header: /u/gcmpack/MITgcm/pkg/exch2/exch2_send_rx1.template,v 1.11 2009/05/30 21:18:59 jmc Exp $ |
2 |
edhill |
1.3 |
C $Name: $ |
3 |
|
|
|
4 |
jmc |
1.5 |
#include "CPP_EEOPTIONS.h" |
5 |
|
|
#include "W2_OPTIONS.h" |
6 |
afe |
1.1 |
|
7 |
jmc |
1.11 |
CBOP 0 |
8 |
|
|
C !ROUTINE: EXCH2_SEND_RX1 |
9 |
|
|
|
10 |
|
|
C !INTERFACE: |
11 |
afe |
1.1 |
SUBROUTINE EXCH2_SEND_RX1 ( |
12 |
|
|
I thisTile, nN, |
13 |
jmc |
1.11 |
I e2BufrRecSize, |
14 |
|
|
I iBufr, |
15 |
|
|
I e2Bufr1_RX, |
16 |
afe |
1.1 |
O e2_msgHandle, |
17 |
|
|
I commSetting, myThid ) |
18 |
|
|
|
19 |
jmc |
1.11 |
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 |
afe |
1.1 |
IMPLICIT NONE |
27 |
|
|
|
28 |
jmc |
1.5 |
#include "SIZE.h" |
29 |
|
|
#include "EEPARAMS.h" |
30 |
|
|
#include "EESUPPORT.h" |
31 |
jmc |
1.9 |
#include "W2_EXCH2_SIZE.h" |
32 |
afe |
1.1 |
#include "W2_EXCH2_TOPOLOGY.h" |
33 |
|
|
|
34 |
jmc |
1.11 |
C !INPUT/OUTPUT PARAMETERS: |
35 |
afe |
1.1 |
C === Routine arguments === |
36 |
jmc |
1.11 |
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 |
jmc |
1.12 |
C iBufr :: number of buffer elements to transfer |
40 |
jmc |
1.11 |
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 |
jmc |
1.12 |
C :: For MPI MSG communication MPI_Wait uses handle to check |
53 |
jmc |
1.11 |
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 |
afe |
1.1 |
INTEGER thisTile, nN |
58 |
jmc |
1.10 |
INTEGER e2BufrRecSize |
59 |
jmc |
1.11 |
INTEGER iBufr |
60 |
afe |
1.1 |
_RX e2Bufr1_RX( e2BufrRecSize ) |
61 |
|
|
INTEGER e2_msgHandle(1) |
62 |
jmc |
1.11 |
CHARACTER commSetting |
63 |
afe |
1.1 |
INTEGER myThid |
64 |
jmc |
1.11 |
CEOP |
65 |
afe |
1.1 |
|
66 |
jmc |
1.11 |
#ifdef ALLOW_USE_MPI |
67 |
|
|
C !LOCAL VARIABLES: |
68 |
afe |
1.1 |
C == Local variables == |
69 |
jmc |
1.11 |
C tgT :: Target tile |
70 |
|
|
INTEGER tgT |
71 |
afe |
1.1 |
|
72 |
|
|
C MPI setup |
73 |
|
|
INTEGER theTag, theType, theHandle |
74 |
|
|
INTEGER sProc, tProc, mpiRc |
75 |
jmc |
1.4 |
#ifdef W2_E2_DEBUG_ON |
76 |
jmc |
1.11 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
77 |
jmc |
1.4 |
#endif |
78 |
afe |
1.1 |
|
79 |
jmc |
1.11 |
tgT = exch2_neighbourId(nN, thisTile ) |
80 |
afe |
1.1 |
|
81 |
jmc |
1.11 |
C Do data transport depending on communication mechanism between |
82 |
|
|
C source and target tile |
83 |
|
|
IF ( commSetting .EQ. 'M' ) THEN |
84 |
afe |
1.1 |
C Setup MPI stuff here |
85 |
jmc |
1.9 |
theTag = (thisTile-1)*W2_maxNeighbours + nN |
86 |
jmc |
1.11 |
tProc = exch2_tProc(tgT)-1 |
87 |
afe |
1.1 |
sProc = exch2_tProc(thisTile)-1 |
88 |
jmc |
1.10 |
theType = _MPI_TYPE_RX |
89 |
afe |
1.1 |
#ifdef W2_E2_DEBUG_ON |
90 |
jmc |
1.11 |
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 |
afe |
1.1 |
#endif /* W2_E2_DEBUG_ON */ |
105 |
|
|
CALL MPI_Isend( e2Bufr1_RX, iBufr, theType, |
106 |
jmc |
1.10 |
I tProc, theTag, MPI_COMM_MODEL, |
107 |
afe |
1.1 |
O theHandle, mpiRc ) |
108 |
|
|
C Store MPI_Wait token in messageHandle. |
109 |
|
|
e2_msgHandle(1) = theHandle |
110 |
|
|
ENDIF |
111 |
jmc |
1.11 |
#endif /* ALLOW_USE_MPI */ |
112 |
jmc |
1.10 |
|
113 |
afe |
1.1 |
RETURN |
114 |
|
|
END |
115 |
edhill |
1.3 |
|
116 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
117 |
|
|
|
118 |
|
|
CEH3 ;;; Local Variables: *** |
119 |
|
|
CEH3 ;;; mode:fortran *** |
120 |
|
|
CEH3 ;;; End: *** |