1 |
C $Header: /u/gcmpack/MITgcm/pkg/autodiff/global_sum_tile_ad.F,v 1.5 2011/03/18 10:40:37 mlosch Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "AUTODIFF_OPTIONS.h" |
5 |
|
6 |
C-- File global_sum_tile_ad.F: Routines that perform adjoint of |
7 |
C global sum on an array of thread values. |
8 |
C Contents |
9 |
C o GLOBAL_ADSUM_TILE_RL |
10 |
C o GLOBAL_ADSUM_TILE_RS <- not yet coded |
11 |
|
12 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
13 |
CBOP |
14 |
C !ROUTINE: GLOBAL_ADSUM_TILE_RL |
15 |
|
16 |
C !INTERFACE: |
17 |
SUBROUTINE GLOBAL_ADSUM_TILE_RL( |
18 |
U adPhiTile, |
19 |
U adsumPhi, |
20 |
I myThid ) |
21 |
|
22 |
C !DESCRIPTION: |
23 |
C *==========================================================* |
24 |
C | SUBROUTINE GLOBAL\_ADSUM\_TILE\_RL |
25 |
C | o Adjoint version of global_sum_tile which returns |
26 |
C | global sum over all tiles |
27 |
C | Note: Assume that adsumPhi is local to this thread |
28 |
C | (i.e., is not a shared var. and is not in a common block) |
29 |
C *==========================================================* |
30 |
C | Apply sum on an array of one value per tile |
31 |
C | and operate over all tiles & all the processes. |
32 |
C *==========================================================* |
33 |
|
34 |
C !USES: |
35 |
IMPLICIT NONE |
36 |
|
37 |
C == Global data == |
38 |
#include "SIZE.h" |
39 |
#include "EEPARAMS.h" |
40 |
|
41 |
C !INPUT/OUTPUT PARAMETERS: |
42 |
C == Routine arguments == |
43 |
C phiTile :: Input array with one value per tile |
44 |
C sumPhi :: Result of sum. |
45 |
C myThid :: My Thread Id. |
46 |
_RL adphiTile(nSx,nSy) |
47 |
_RL adsumPhi |
48 |
INTEGER myThid |
49 |
CEOP |
50 |
|
51 |
C !LOCAL VARIABLES: |
52 |
C == Local variables == |
53 |
C bi,bj :: tile indices |
54 |
INTEGER bi,bj |
55 |
Real*8 tmp |
56 |
|
57 |
C note: arithmetic has been checked versus TAF generated adjoint |
58 |
C of a simplified version of global_sum_tile.F code. |
59 |
|
60 |
tmp = adsumPhi |
61 |
|
62 |
CALL GLOBAL_SUM_R8( tmp, myThid ) |
63 |
|
64 |
C-- each thread updates its tile adjoint sum |
65 |
DO bj = myByLo(myThid), myByHi(myThid) |
66 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
67 |
adphiTile(bi,bj) = adphiTile(bi,bj) + tmp |
68 |
ENDDO |
69 |
ENDDO |
70 |
|
71 |
adsumPhi = 0. |
72 |
|
73 |
RETURN |
74 |
END |