1 |
C $Header: /u/gcmpack/MITgcm/pkg/ctrl/ctrl_bound.F,v 1.2 2007/10/09 00:00:00 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_OPTIONS.h" |
5 |
|
6 |
C !ROUTINE: CTRL_BOUND_3D |
7 |
C !INTERFACE: |
8 |
SUBROUTINE CTRL_BOUND_3D( |
9 |
I fieldCur,maskFld3d, |
10 |
I boundsVec,myThid) |
11 |
C !DESCRIPTION: \bv |
12 |
C *==========================================================* |
13 |
C | started: Gael Forget gforget@mit.edu 20-Aug-2007 |
14 |
C | |
15 |
C | o in forward mode: impose bounds on ctrl vector values |
16 |
C | o in adjoint mode: do nothing ... or emulate local minimum |
17 |
C *==========================================================* |
18 |
|
19 |
#include "SIZE.h" |
20 |
#include "EEPARAMS.h" |
21 |
#include "PARAMS.h" |
22 |
|
23 |
integer myThid,bi,bj,i,j,k |
24 |
integer itlo,ithi,jtlo,jthi |
25 |
_RL fieldCur(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nsx,nsy) |
26 |
_RL maskFld3d(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nsx,nsy) |
27 |
_RL boundsVec(5) |
28 |
|
29 |
jtlo = mybylo(mythid) |
30 |
jthi = mybyhi(mythid) |
31 |
itlo = mybxlo(mythid) |
32 |
ithi = mybxhi(mythid) |
33 |
|
34 |
if (boundsVec(1).LT.boundsVec(4)) then |
35 |
|
36 |
do bj = jtlo,jthi |
37 |
do bi = itlo,ithi |
38 |
do k = 1,nr |
39 |
do j = 1,sny |
40 |
do i = 1,snx |
41 |
IF (maskFld3d(i,j,k,bi,bj).NE.0.) then |
42 |
IF (fieldCur(i,j,k,bi,bj).gt.boundsVec(4)) then |
43 |
fieldCur(i,j,k,bi,bj)=boundsVec(4) |
44 |
ENDIF |
45 |
IF (fieldCur(i,j,k,bi,bj).lt.boundsVec(1)) then |
46 |
fieldCur(i,j,k,bi,bj)=boundsVec(1) |
47 |
ENDIF |
48 |
ENDIF |
49 |
enddo |
50 |
enddo |
51 |
enddo |
52 |
enddo |
53 |
enddo |
54 |
|
55 |
endif |
56 |
|
57 |
end |
58 |
|
59 |
C !ROUTINE: CTRL_BOUND_2D |
60 |
C !INTERFACE: |
61 |
SUBROUTINE CTRL_BOUND_2D( |
62 |
I fieldCur,maskFld3d, |
63 |
I boundsVec,myThid) |
64 |
C !DESCRIPTION: \bv |
65 |
C *==========================================================* |
66 |
C | started: Gael Forget gforget@mit.edu 20-Aug-2007 |
67 |
C | |
68 |
C | o in forward mode: impose bounds on ctrl vector values |
69 |
C | o in adjoint mode: do nothing ... or emulate local minimum |
70 |
C *==========================================================* |
71 |
|
72 |
#include "SIZE.h" |
73 |
#include "EEPARAMS.h" |
74 |
#include "PARAMS.h" |
75 |
|
76 |
|
77 |
integer myThid,bi,bj,i,j,k |
78 |
integer itlo,ithi,jtlo,jthi |
79 |
_RL fieldCur(1-Olx:sNx+Olx,1-Oly:sNy+Oly,nsx,nsy) |
80 |
_RL maskFld3d(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nsx,nsy) |
81 |
_RL boundsVec(5) |
82 |
|
83 |
jtlo = mybylo(mythid) |
84 |
jthi = mybyhi(mythid) |
85 |
itlo = mybxlo(mythid) |
86 |
ithi = mybxhi(mythid) |
87 |
|
88 |
if (boundsVec(1).LT.boundsVec(4)) then |
89 |
|
90 |
do bj = jtlo,jthi |
91 |
do bi = itlo,ithi |
92 |
do j = 1-oly,sny+oly |
93 |
do i = 1-olx,snx+olx |
94 |
IF (maskFld3d(i,j,1,bi,bj).NE.0.) then |
95 |
IF (fieldCur(i,j,bi,bj).gt.boundsVec(4)) then |
96 |
fieldCur(i,j,bi,bj)=boundsVec(4) |
97 |
ENDIF |
98 |
IF (fieldCur(i,j,bi,bj).lt.boundsVec(1)) then |
99 |
fieldCur(i,j,bi,bj)=boundsVec(1) |
100 |
ENDIF |
101 |
ENDIF |
102 |
enddo |
103 |
enddo |
104 |
enddo |
105 |
enddo |
106 |
|
107 |
endif |
108 |
|
109 |
|
110 |
end |
111 |
|