/[MITgcm]/MITgcm/tools/OAD_support/ad_template.streamice_get_vel_resid_err_oad.F
ViewVC logotype

Contents of /MITgcm/tools/OAD_support/ad_template.streamice_get_vel_resid_err_oad.F

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


Revision 1.5 - (show annotations) (download)
Fri Mar 18 19:17:35 2016 UTC (3 years, 4 months ago) by dgoldberg
Branch: MAIN
CVS Tags: checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65v, checkpoint65w, HEAD
Changes since 1.4: +39 -1 lines
allow for different error norms in iteration

1 #include "STREAMICE_OPTIONS.h"
2
3 SUBROUTINE template()
4 use OAD_cp
5 use OAD_tape
6 use OAD_rev
7
8
9 !$TEMPLATE_PRAGMA_DECLARATIONS
10
11 integer testTape
12 !logical isTape
13 !type(modeType) :: our_orig_mode
14
15 #if (defined (ALLOW_STREAMICE_OAD_FP))
16
17 if (our_rev_mode%plain .or. our_rev_mode%tape) then
18 ! if (our_rev_mode%plain) then
19
20 if (our_rev_mode%tape) then
21 testTape=1
22 our_rev_mode%plain=.true.
23 our_rev_mode%tape=.false.
24 our_rev_mode%adjoint=.false.
25 else
26 testTape=0
27 endif
28
29
30 err_max = 0. _d 0
31 err_sum = 0. _d 0
32
33 DO bj = myByLo(myThid), myByHi(myThid)
34 DO bi = myBxLo(myThid), myBxHi(myThid)
35 err_sum_tile(bi,bj) = 0. _d 0
36 ENDDO
37 ENDDO
38
39 DO bj = myByLo(myThid), myByHi(myThid)
40 DO bi = myBxLo(myThid), myBxHi(myThid)
41 DO j=1-oly,sNy+oly
42 DO i=1-olx,sNx+olx
43 Au_SI (i,j,bi,bj) = 0. _d 0
44 Av_SI (i,j,bi,bj) = 0. _d 0
45 u_dummy (i,j,bi,bj) = u_streamice(i,j,bi,bj)%v
46 v_dummy (i,j,bi,bj) = v_streamice(i,j,bi,bj)%v
47 ubd_SI (i,j,bi,bj)%v = 0. _d 0
48 vbd_SI (i,j,bi,bj)%v = 0. _d 0
49 ENDDO
50 ENDDO
51 ENDDO
52 ENDDO
53
54 CALL openad_STREAMICE_CG_BOUND_VALS( myThid,
55 O ubd_SI,
56 O vbd_SI)
57
58 CALL openad_STREAMICE_CG_ACTION( myThid,
59 O Au_SI,
60 O Av_SI,
61 I U_dummy,
62 I V_dummy,
63 I 0, sNx+1, 0, sNy+1 )
64
65
66 IF (streamice_err_norm .LT. 1.0) then
67
68 DO bj = myByLo(myThid), myByHi(myThid)
69 DO bi = myBxLo(myThid), myBxHi(myThid)
70 DO j=1,sNy
71 DO i=1,sNx
72 err_tempu = 0. _d 0
73 err_tempv = 0. _d 0
74 IF (STREAMICE_umask(i,j,bi,bj).eq.1) THEN
75 err_tempu =
76 & ABS (Au_SI(i,j,bi,bj)+0*ubd_SI(i,j,bi,bj)%v -
77 & taudx_SI(i,j,bi,bj)%v)
78 ENDIF
79 IF (STREAMICE_vmask(i,j,bi,bj).eq.1) THEN
80 err_tempv = MAX( err_tempu,
81 & ABS (Av_SI(i,j,bi,bj)+0*vbd_SI(i,j,bi,bj)%v -
82 & taudy_SI(i,j,bi,bj)%v))
83 ENDIF
84 IF (err_tempv .ge. err_max) THEN
85 err_max = err_tempv
86 ENDIF
87 ENDDO
88 ENDDO
89 ENDDO
90 ENDDO
91
92 CALL GLOBAL_MAX_R8 (err_max, myThid)
93
94 ELSE
95
96 DO bj = myByLo(myThid), myByHi(myThid)
97 DO bi = myBxLo(myThid), myBxHi(myThid)
98 DO j=1,sNy
99 DO i=1,sNx
100
101 IF (STREAMICE_umask(i,j,bi,bj).eq.1) THEN
102 err_sum_tile(bi,bj) = err_sum_tile(bi,bj) +
103 & (ABS (Au_SI(i,j,bi,bj)+0*ubd_SI(i,j,bi,bj)%v -
104 & taudx_SI(i,j,bi,bj)%v)) ** streamice_err_norm
105 ENDIF
106 IF (STREAMICE_vmask(i,j,bi,bj).eq.1) THEN
107 err_sum_tile(bi,bj) = err_sum_tile(bi,bj) +
108 & (ABS (Av_SI(i,j,bi,bj)+0*vbd_SI(i,j,bi,bj)%v -
109 & taudy_SI(i,j,bi,bj)%v)) ** streamice_err_norm
110 ENDIF
111
112 ENDDO
113 ENDDO
114 ENDDO
115 ENDDO
116
117 CALL GLOBAL_SUM_TILE_RL( err_sum_tile, err_sum, myThid )
118
119 err_max = err_sum ** (1./streamice_err_norm)
120
121 ENDIF
122
123 if (testTape.eq.1) then
124 our_rev_mode%plain=.false.
125 our_rev_mode%tape=.true.
126 our_rev_mode%adjoint=.false.
127 endif
128
129 end if
130
131
132 #endif
133 end subroutine template

  ViewVC Help
Powered by ViewVC 1.1.22