-
Notifications
You must be signed in to change notification settings - Fork 13
/
w2_e2setup.F
149 lines (127 loc) · 4.7 KB
/
w2_e2setup.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "PACKAGES_CONFIG.h"
#include "CPP_EEOPTIONS.h"
#include "W2_OPTIONS.h"
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
CBOP 0
C !ROUTINE: W2_E2SETUP
C !INTERFACE:
SUBROUTINE W2_E2SETUP( myThid )
C !DESCRIPTION:
C Set-up W2_EXCH2 tile topology structures
C !USES:
IMPLICIT NONE
C Tile topology settings data structures
#include "SIZE.h"
#include "EEPARAMS.h"
#ifdef ALLOW_EXCH2
#include "W2_EXCH2_SIZE.h"
#include "W2_EXCH2_TOPOLOGY.h"
#include "W2_EXCH2_PARAMS.h"
#endif
C !INPUT PARAMETERS:
C myThid :: my Thread Id number
C (Note: not relevant since threading has not yet started)
INTEGER myThid
#ifdef ALLOW_EXCH2
C !LOCAL VARIABLES:
C === Local variables ===
C msgBuf :: Informational/error message buffer
C stdUnit :: Standard-Output IO unit number
CHARACTER*(MAX_LEN_MBUF) msgBuf
INTEGER stdUnit
INTEGER i, j, k
LOGICAL addBlank
CEOP
stdUnit = standardMessageUnit
C-- Initialise parameters from EXCH2_PARAMS common blocks
C (except params from namelist which are set in W2_READPARMS)
DO j=1,W2_maxNbFacets
facet_owns(1,j) = 0
facet_owns(2,j) = 0
DO i=1,4
DO k=1,4
facet_pij(k,i,j) = 0
ENDDO
facet_oi(i,j) = 0
facet_oj(i,j) = 0
ENDDO
ENDDO
C-- Count Nb of Blank-Tiles and set Number of tiles:
nBlankTiles = 0
DO i=1,W2_maxNbTiles
IF (blankList(i).NE.0 ) THEN
addBlank = .TRUE.
DO j=1,nBlankTiles
IF ( blankList(i).EQ.blankList(j) ) THEN
addBlank = .FALSE.
WRITE(msgBuf,'(A,I8,A,2I8,A)')
& '** WARNING ** W2_E2SETUP: #', blankList(i),
& ' appears several times in blankList (',j,i,')'
CALL PRINT_MESSAGE( msgBuf, W2_oUnit,SQUEEZE_RIGHT,myThid )
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
& SQUEEZE_RIGHT, myThid )
ENDIF
ENDDO
IF ( addBlank ) THEN
nBlankTiles = nBlankTiles + 1
blankList(nBlankTiles) = blankList(i)
ENDIF
ENDIF
ENDDO
exch2_nTiles = nBlankTiles + (nSx*nSy*nPx*nPy)
WRITE(msgBuf,'(A,I8)')
& 'W2_E2SETUP: number of Active Tiles =', nSx*nSy*nPx*nPy
CALL PRINT_MESSAGE( msgBuf, W2_oUnit, SQUEEZE_RIGHT, myThid )
WRITE(msgBuf,'(A,I8)')
& 'W2_E2SETUP: number of Blank Tiles =', nBlankTiles
CALL PRINT_MESSAGE( msgBuf, W2_oUnit, SQUEEZE_RIGHT, myThid )
WRITE(msgBuf,'(A,I8)')
& 'W2_E2SETUP: Total number of Tiles =', exch2_nTiles
CALL PRINT_MESSAGE( msgBuf, W2_oUnit, SQUEEZE_RIGHT, myThid )
IF ( exch2_nTiles.GT.W2_maxNbTiles ) THEN
WRITE(msgBuf,'(3(A,I8))') 'W2_E2SETUP: Number of Tiles=',
& exch2_nTiles, ' >', W2_maxNbTiles, ' =W2_maxNbTiles'
CALL PRINT_ERROR( msgBuf, myThid )
WRITE(msgBuf,'(2A)') 'Must increase "W2_maxNbTiles"',
& ' in "W2_EXCH2_SIZE.h" + recompile'
CALL PRINT_ERROR( msgBuf, myThid )
STOP 'ABNORMAL END: S/R W2_E2SETUP (nTiles>maxNbTiles)'
ENDIF
C-- Check blankList:
DO i=1,nBlankTiles
IF ( blankList(i).LT.1 .OR. blankList(i).GT.exch2_nTiles ) THEN
WRITE(msgBuf,'(A,I8,A,I8)')
& 'W2_E2SETUP: Invalid blankTile number (i=', i,
& ' )=', blankList(i)
WRITE(msgBuf,'(A,I8,A,I8,A)') 'W2_E2SETUP:', blankList(i),
& ' = Invalid blankTile number (i=', i, ')'
CALL PRINT_ERROR( msgBuf, myThid )
STOP 'ABNORMAL END: S/R W2_E2SETUP (blankList error)'
ENDIF
ENDDO
C-- Define Facet (sub-domain) Topology: Size and Connections
IF ( preDefTopol.EQ.0 ) THEN
CALL W2_SET_GEN_FACETS( myThid )
ELSEIF ( preDefTopol.EQ.1 ) THEN
CALL W2_SET_SINGLE_FACET( myThid )
ELSEIF ( preDefTopol.EQ.2 ) THEN
CALL W2_SET_MYOWN_FACETS( myThid )
ELSEIF ( preDefTopol.EQ.3 ) THEN
CALL W2_SET_CS6_FACETS( myThid )
ELSE
STOP 'ABNORMAL END: S/R W2_E2SETUP (invalid preDefTopol)'
ENDIF
WRITE(msgBuf,'(A,I8)')
& 'W2_E2SETUP: Total number of Facets =', nFacets
CALL PRINT_MESSAGE( msgBuf, W2_oUnit, SQUEEZE_RIGHT, myThid )
C-- Check Topology; setup correspondence matrix for connected Facet-Edges
CALL W2_SET_F2F_INDEX( myThid )
C-- Define Tile Mapping (+ IO global mapping)
CALL W2_SET_MAP_TILES( myThid )
C-- Define Tile Mapping (for Cumulated Sum)
CALL W2_SET_MAP_CUMSUM( myThid )
C-- Set-up tile neighbours and index relations for EXCH2
CALL W2_SET_TILE2TILES( myThid )
#endif /* ALLOW_EXCH2 */
RETURN
END