1 |
C $Header: /u/gcmpack/MITgcm/pkg/atm_compon_interf/cpl_register.F,v 1.5 2015/11/12 01:01:58 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "ATM_CPL_OPTIONS.h" |
5 |
|
6 |
CBOP 0 |
7 |
C !ROUTINE: CPL_REGISTER |
8 |
|
9 |
C !INTERFACE: |
10 |
SUBROUTINE CPL_REGISTER |
11 |
|
12 |
C !DESCRIPTION: |
13 |
C *==========================================================* |
14 |
C | SUBROUTINE CPL_REGISTER |
15 |
C | o Routine controlling registration with MIT coupler. |
16 |
C | - Atmospheric version - |
17 |
C *==========================================================* |
18 |
C | This version talks to the MIT Coupler. It uses the MIT |
19 |
C | Coupler "checkpoint1" library calls. |
20 |
C *==========================================================* |
21 |
|
22 |
C !USES: |
23 |
IMPLICIT NONE |
24 |
C == Global variables == |
25 |
#include "SIZE.h" |
26 |
#include "EEPARAMS.h" |
27 |
#ifdef ALLOW_EXCH2 |
28 |
# include "W2_EXCH2_SIZE.h" |
29 |
# include "W2_EXCH2_TOPOLOGY.h" |
30 |
# include "W2_EXCH2_PARAMS.h" |
31 |
#endif /* ALLOW_EXCH2 */ |
32 |
|
33 |
C !INPUT/OUTPUT PARAMETERS: |
34 |
C == Routine arguments == |
35 |
C myThid :: Thread number for this instance of the routine |
36 |
c INTEGER myThid |
37 |
CEOP |
38 |
|
39 |
#ifdef COMPONENT_MODULE |
40 |
C !LOCAL VARIABLES: |
41 |
C == Local variables == |
42 |
C bi, bj :: Tile indices |
43 |
C j :: Loop counter |
44 |
C iG0, jG0 :: Base coordinates of a tile on the global grid. |
45 |
C iReg :: Array for passing attributes to the coupler |
46 |
C x,ySize :: expected size of the coupler 2-D maps |
47 |
INTEGER iG0, jG0 |
48 |
INTEGER bi, bj |
49 |
INTEGER j, nTiles |
50 |
INTEGER iReg(6,nSx*nSy) |
51 |
c INTEGER xSize, ySize |
52 |
#ifdef ALLOW_EXCH2 |
53 |
INTEGER tN |
54 |
LOGICAL useExch2LayOut |
55 |
#endif /* ALLOW_EXCH2 */ |
56 |
|
57 |
C-- Set dimensions of coupler 2-D maps: |
58 |
c xSize = Nx |
59 |
c ySize = Ny |
60 |
|
61 |
#ifdef ALLOW_EXCH2 |
62 |
C-- Note: current coupler mapping relies only on i0,j0,nx,ny ; this prevent to |
63 |
C map tiles to Exch-2 global map when faces do not fit in global-IO-array |
64 |
C (see, e.g., gather/scatter_2d routines in eesupp/src, case where |
65 |
C iGjLoc <> 0 or jGjLoc <> 1 ). |
66 |
useExch2LayOut = .FALSE. |
67 |
IF ( W2_useE2ioLayOut ) THEN |
68 |
useExch2LayOut = .TRUE. |
69 |
DO tN=1,exch2_nTiles |
70 |
IF ( exch2_mydNx(tN) .GT. exch2_global_Nx ) THEN |
71 |
useExch2LayOut = .FALSE. |
72 |
C- face x-size larger than glob-size : fold it |
73 |
c iGjLoc = 0 |
74 |
c jGjLoc = exch2_mydNx(tN) / xSize |
75 |
ELSEIF ( exch2_tNy(tN) .GT. exch2_global_Ny ) THEN |
76 |
useExch2LayOut = .FALSE. |
77 |
C- tile y-size larger than glob-size : make a long line |
78 |
c iGjLoc = exch2_mydNx(tN) |
79 |
c jGjLoc = 0 |
80 |
ELSE |
81 |
C- default (face fit into global-IO-array) |
82 |
c iGjLoc = 0 |
83 |
c jGjLoc = 1 |
84 |
ENDIF |
85 |
ENDDO |
86 |
ENDIF |
87 |
c IF ( useExch2LayOut ) THEN |
88 |
c xSize = exch2_global_Nx |
89 |
c ySize = exch2_global_Ny |
90 |
c ENDIF |
91 |
C-- Note: should check that xSize,ySize match with coupler Nx_atm,Ny_atm |
92 |
#endif /* ALLOW_EXCH2 */ |
93 |
|
94 |
C-- Register with the MIT coupler |
95 |
j = 0 |
96 |
DO bj=1,nSy |
97 |
DO bi=1,nSx |
98 |
j = j+1 |
99 |
jG0 = myYGlobalLo+(bj-1)*sNy |
100 |
iG0 = myXGlobalLo+(bi-1)*sNx |
101 |
#ifdef ALLOW_EXCH2 |
102 |
IF ( useExch2LayOut ) THEN |
103 |
tN = W2_myTileList(bi,bj) |
104 |
iG0 = exch2_txGlobalo(tN) |
105 |
jG0 = exch2_tyGlobalo(tN) |
106 |
ENDIF |
107 |
#endif /* ALLOW_EXCH2 */ |
108 |
iReg(1,j) = bi |
109 |
iReg(2,j) = bj |
110 |
iReg(3,j) = sNx |
111 |
iReg(4,j) = sNy |
112 |
iReg(5,j) = iG0 |
113 |
iReg(6,j) = jG0 |
114 |
ENDDO |
115 |
ENDDO |
116 |
nTiles = nSx*nSy |
117 |
CALL MITCOMPONENT_TILE_REGISTER( nTiles, iReg ) |
118 |
#endif /* COMPONENT_MODULE */ |
119 |
|
120 |
RETURN |
121 |
END |