/[MITgcm]/MITgcm/pkg/ctrl/adctrl_bound.F
ViewVC logotype

Contents of /MITgcm/pkg/ctrl/adctrl_bound.F

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


Revision 1.4 - (show annotations) (download)
Sat Feb 9 23:28:58 2008 UTC (16 years, 4 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint59p, checkpoint59o
Changes since 1.3: +135 -19 lines
- Rewrite of ctrl_map_ini_ecco.F, introducing a generic
routine (ctrl_map_ini_gen.F).
- Modification of ctrl_bound/adctrl_bound handling
control vector bounds.

1 C $Header: /u/gcmpack/MITgcm/pkg/ctrl/adctrl_bound.F,v 1.3 2008/01/23 17:32:16 gforget Exp $
2 C $Name: $
3
4 #include "CPP_OPTIONS.h"
5
6 C !ROUTINE: ADCTRL_BOUND_3D
7 C !INTERFACE:
8 SUBROUTINE ADCTRL_BOUND_3D(
9 I fieldCur,maskFld3d,
10 I boundsVec,myThid,
11 I adjFieldCur)
12 C !DESCRIPTION: \bv
13 C *==========================================================*
14 C | started: Gael Forget gforget@mit.edu 20-Aug-2007
15 C |
16 C | o in forward mode: impose bounds on ctrl vector values
17 C | o in adjoint mode: do nothing ... or emulate local minimum
18 C *==========================================================*
19
20 #include "SIZE.h"
21 #include "EEPARAMS.h"
22 #include "PARAMS.h"
23
24 integer myThid,bi,bj,i,j,k
25 integer itlo,ithi,jtlo,jthi
26 _RL fieldCur(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nsx,nsy)
27 _RL maskFld3d(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nsx,nsy)
28 _RL adjFieldCur(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nsx,nsy)
29 _RL boundsVec(5)
30 _RL x0,x0p5,l0p5,x1,x2,x2p5,l2p5,x3
31 _RL xCur,adxCur
32
33 jtlo = mybylo(mythid)
34 jthi = mybyhi(mythid)
35 itlo = mybxlo(mythid)
36 ithi = mybxhi(mythid)
37
38
39 #ifdef ALLOW_ADCTRLBOUND
40
41 x0=boundsVec(1)
42 x1=boundsVec(2)
43 x0p5=(x0+x1)/2
44 l0p5=(x1-x0)/1.5
45 x2=boundsVec(3)
46 x3=boundsVec(4)
47 x2p5=(x2+x3)/2
48 l2p5=(x3-x2)/1.5
49
50 C x0<x1<x2<x3 => ctrl_bound and adctrl_bound act on xx/adxx
51 C x0=x3 => ctrl_bound and adctrl_bound do nothing
52 C otherwise => error
53
54 if ( x0.LT.x3 ) then
55 if ( (x0.LT.x1).AND.(x1.LT.x2).AND.(x2.LT.x3) ) then
56
57 do bj = jtlo,jthi
58 do bi = itlo,ithi
59 do k = 1,nr
60 do j = 1,sny
61 do i = 1,snx
62 IF (maskFld3d(i,j,k,bi,bj).NE.0.) then
63 xCur=fieldCur(i,j,k,bi,bj)
64 adxCur=adjFieldCur(i,j,k,bi,bj)
65 IF ( (xCur.gt.x2).AND.(adxCur.LT.0) ) then
66 adjFieldCur(i,j,k,bi,bj)=
67 & tanh((xCur-x2p5)/l2p5)*abs(adxCur)
68 ENDIF
69 IF ( (xCur.lt.x1).AND.(adxCur.GT.0) ) then
70 adjFieldCur(i,j,k,bi,bj)=
71 & -tanh((xCur-x0p5)/l0p5)*abs(adxCur)
72 ENDIF
73 ENDIF
74 enddo
75 enddo
76 enddo
77 enddo
78 enddo
79
80 else
81 print*,"boundsVec is not self-consistent"
82 stop
83 endif
84 endif
85
86 #endif
87
88 end
89
90 C !ROUTINE: ADCTRL_BOUND_2D
91 C !INTERFACE:
92 SUBROUTINE ADCTRL_BOUND_2D(
93 I fieldCur,maskFld3d,
94 I boundsVec,myThid,
95 I adjFieldCur)
96 C !DESCRIPTION: \bv
97 C *==========================================================*
98 C | started: Gael Forget gforget@mit.edu 20-Aug-2007
99 C |
100 C | o in forward mode: impose bounds on ctrl vector values
101 C | o in adjoint mode: do nothing ... or emulate local minimum
102 C *==========================================================*
103
104 #include "SIZE.h"
105 #include "EEPARAMS.h"
106 #include "PARAMS.h"
107
108 integer myThid,bi,bj,i,j,k
109 integer itlo,ithi,jtlo,jthi
110 _RL fieldCur(1-Olx:sNx+Olx,1-Oly:sNy+Oly,nsx,nsy)
111 _RL maskFld3d(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nsx,nsy)
112 _RL adjFieldCur(1-Olx:sNx+Olx,1-Oly:sNy+Oly,nsx,nsy)
113 _RL boundsVec(5)
114
115 jtlo = mybylo(mythid)
116 jthi = mybyhi(mythid)
117 itlo = mybxlo(mythid)
118 ithi = mybxhi(mythid)
119
120
121 #ifdef ALLOW_ADCTRLBOUND
122
123 x0=boundsVec(1)
124 x1=boundsVec(2)
125 x0p5=(x0+x1)/2
126 l0p5=(x1-x0)/1.5
127 x2=boundsVec(3)
128 x3=boundsVec(4)
129 x2p5=(x2+x3)/2
130 l2p5=(x3-x2)/1.5
131
132 C x0<x1<x2<x3 => ctrl_bound and adctrl_bound act on xx/adxx
133 C x0=x3 => ctrl_bound and adctrl_bound do nothing
134 C otherwise => error
135
136 if ( x0.LT.x3 ) then
137 if ( (x0.LT.x1).AND.(x1.LT.x2).AND.(x2.LT.x3) ) then
138
139 do bj = jtlo,jthi
140 do bi = itlo,ithi
141 do j = 1,sny
142 do i = 1,snx
143 IF (maskFld3d(i,j,1,bi,bj).NE.0.) then
144 xCur=fieldCur(i,j,bi,bj)
145 adxCur=adjFieldCur(i,j,bi,bj)
146 IF ( (xCur.gt.x2).AND.(adxCur.LT.0) ) then
147 adjFieldCur(i,j,bi,bj)=
148 & tanh((xCur-x2p5)/l2p5)*abs(adxCur)
149 ENDIF
150 IF ( (xCur.lt.x1).AND.(adxCur.GT.0) ) then
151 adjFieldCur(i,j,bi,bj)=
152 & -tanh((xCur-x0p5)/l0p5)*abs(adxCur)
153 ENDIF
154 ENDIF
155 enddo
156 enddo
157 enddo
158 enddo
159
160 else
161 print*,"boundsVec is not self-consistent"
162 stop
163 endif
164 endif
165
166 #endif
167
168 end
169

  ViewVC Help
Powered by ViewVC 1.1.22