/[MITgcm]/MITgcm/pkg/autodiff/global_sum_tile_ad.F
ViewVC logotype

Contents of /MITgcm/pkg/autodiff/global_sum_tile_ad.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Wed Apr 22 01:28:47 2009 UTC (15 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint61n, checkpoint61o, checkpoint61m
hand written adjoint version of S/R GLOBAL_SUM_TILE_RL

1 C $Header: /u/gcmpack/MITgcm/pkg/autodiff/global_sum_ad.F,v 1.7 2008/08/02 23:16:58 jmc Exp $
2 C $Name: $
3
4 C-- File global_adsum.F: Routines that perform adjoint of
5 C global sum on an array of thread values.
6 C Contents
7 C o global_adsum_tile_rl
8 C o global_adsum_tile_rs <- not yet coded
9 #include "AUTODIFF_OPTIONS.h"
10
11 CBOP
12 C !ROUTINE: GLOBAL_ADSUM_TILE_RL
13
14 C !INTERFACE:
15 SUBROUTINE GLOBAL_ADSUM_TILE_RL(
16 O adPhiTile,
17 I adsumPhi,
18 I myThid )
19
20 C !DESCRIPTION:
21 C *==========================================================*
22 C | SUBROUTINE GLOBAL\_ADSUM\_TILE\_RL
23 C | o Handle sum for _RL data.
24 C *==========================================================*
25 C | Apply sum on an array of one value per tile
26 C | and operate over all tiles & all the processes.
27 C *==========================================================*
28
29 IMPLICIT NONE
30 C == Global data ==
31 #include "SIZE.h"
32 #include "EEPARAMS.h"
33 #include "EESUPPORT.h"
34 #include "GLOBAL_SUM.h"
35
36 C == Routine arguments ==
37 C phiTile :: Input array with one value per tile
38 C sumPhi :: Result of sum.
39 C myThid :: My thread id.
40 _RL adphiTile(nSx,nSy)
41 _RL adsumPhi
42 INTEGER myThid
43 CEOP
44
45 C == Local variables ==
46 C bi,bj :: tile indices
47 C mpiRC :: MPI return code
48 INTEGER bi,bj
49 Real*8 tmp
50 #ifdef ALLOW_USE_MPI
51 INTEGER mpiRC
52 #endif /* ALLOW_USE_MPI */
53
54 C-- Can not start until everyone is ready
55 _BARRIER
56
57 C-- broadcast to all processes
58 _BEGIN_MASTER( myThid )
59
60 tmp = adsumPhi
61
62 #ifdef ALLOW_USE_MPI
63 #ifndef ALWAYS_USE_MPI
64 IF ( usingMPI ) THEN
65 #endif
66 CALL MPI_Bcast( tmp, 1, MPI_DOUBLE_PRECISION, 0,
67 & MPI_COMM_WORLD, mpiRC )
68 #ifndef ALWAYS_USE_MPI
69 ENDIF
70 #endif
71 #endif /* ALLOW_USE_MPI */
72
73 shareBufGSR8(1,1) = tmp
74
75 _END_MASTER( myThid )
76 C--
77 _BARRIER
78
79 C-- every thread takes its adjoint sum
80 DO bj = myByLo(myThid), myByHi(myThid)
81 DO bi = myBxLo(myThid), myBxHi(myThid)
82 adphiTile(bi,bj) = shareBufGSR8(1,1)
83 ENDDO
84 ENDDO
85 C-- reset input to zero (jmc: is it right ? necessary ?)
86 c adsumPhi = 0.
87
88 RETURN
89 END

  ViewVC Help
Powered by ViewVC 1.1.22