1 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_salt0.F,v 1.5 2005/12/22 21:13:21 heimbach Exp $ |
2 |
|
3 |
#include "COST_CPPOPTIONS.h" |
4 |
|
5 |
|
6 |
subroutine cost_salt0( |
7 |
I myiter, |
8 |
I mytime, |
9 |
I mythid |
10 |
& ) |
11 |
|
12 |
c ================================================================== |
13 |
c SUBROUTINE cost_salt0 |
14 |
c ================================================================== |
15 |
c |
16 |
c o Calculate the zonal wind stress contribution to the cost function. |
17 |
c |
18 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
19 |
c |
20 |
c changed: Christian Eckert eckert@mit.edu 25-Feb-2000 |
21 |
c |
22 |
c - Restructured the code in order to create a package |
23 |
c for the MITgcmUV. |
24 |
c |
25 |
c ================================================================== |
26 |
c SUBROUTINE cost_salt0 |
27 |
c ================================================================== |
28 |
|
29 |
implicit none |
30 |
|
31 |
c == global variables == |
32 |
|
33 |
#include "EEPARAMS.h" |
34 |
#include "SIZE.h" |
35 |
#include "GRID.h" |
36 |
|
37 |
#include "ecco_cost.h" |
38 |
#include "ctrl.h" |
39 |
#include "ctrl_dummy.h" |
40 |
#include "optim.h" |
41 |
|
42 |
c == routine arguments == |
43 |
|
44 |
integer myiter |
45 |
_RL mytime |
46 |
integer mythid |
47 |
|
48 |
c == local variables == |
49 |
|
50 |
integer bi,bj |
51 |
integer i,j,k |
52 |
integer itlo,ithi |
53 |
integer jtlo,jthi |
54 |
integer jmin,jmax |
55 |
integer imin,imax |
56 |
integer nrec |
57 |
integer irec |
58 |
integer ilfld |
59 |
|
60 |
_RL fctile |
61 |
_RL tmpx |
62 |
_RL lengthscale |
63 |
|
64 |
logical doglobalread |
65 |
logical ladinit |
66 |
|
67 |
character*(80) fnamefld |
68 |
|
69 |
character*(MAX_LEN_MBUF) msgbuf |
70 |
|
71 |
c == external functions == |
72 |
|
73 |
integer ilnblnk |
74 |
external ilnblnk |
75 |
|
76 |
c == end of interface == |
77 |
|
78 |
jtlo = mybylo(mythid) |
79 |
jthi = mybyhi(mythid) |
80 |
itlo = mybxlo(mythid) |
81 |
ithi = mybxhi(mythid) |
82 |
jmin = 1 |
83 |
jmax = sny |
84 |
imin = 1 |
85 |
imax = snx |
86 |
|
87 |
lengthscale = 1. _d 0 |
88 |
|
89 |
c-- Read state record from global file. |
90 |
doglobalread = .false. |
91 |
ladinit = .false. |
92 |
|
93 |
irec = 1 |
94 |
|
95 |
#ifdef ALLOW_SALT0_COST_CONTRIBUTION |
96 |
|
97 |
if (optimcycle .ge. 0) then |
98 |
ilfld = ilnblnk( xx_salt_file ) |
99 |
write(fnamefld(1:80),'(2a,i10.10)') |
100 |
& xx_salt_file(1:ilfld),'.',optimcycle |
101 |
endif |
102 |
|
103 |
call active_read_xyz_loc( fnamefld, tmpfld3d, irec, doglobalread, |
104 |
& ladinit, optimcycle, mythid |
105 |
& , xx_salt_dummy ) |
106 |
|
107 |
c-- Loop over this thread's tiles. |
108 |
do bj = jtlo,jthi |
109 |
do bi = itlo,ithi |
110 |
|
111 |
c-- Determine the weights to be used. |
112 |
|
113 |
fctile = 0. _d 0 |
114 |
do k = 1,nr |
115 |
do j = jmin,jmax |
116 |
do i = imin,imax |
117 |
if (_hFacC(i,j,k,bi,bj) .ne. 0.) then |
118 |
tmpx = tmpfld3d(i,j,k,bi,bj) |
119 |
if ( ABS(R_low(i,j,bi,bj)) .LT. 100. ) |
120 |
& tmpx = tmpx*ABS(R_low(i,j,bi,bj))/100. |
121 |
fctile = fctile |
122 |
& + wsaltLev(i,j,k,bi,bj)*cosphi(i,j,bi,bj) |
123 |
& *tmpx*tmpx |
124 |
if ( wsaltLev(i,j,k,bi,bj)*cosphi(i,j,bi,bj).ne.0. ) |
125 |
& num_salt0(bi,bj) = num_salt0(bi,bj) + 1. _d 0 |
126 |
endif |
127 |
enddo |
128 |
enddo |
129 |
enddo |
130 |
|
131 |
objf_salt0(bi,bj) = objf_salt0(bi,bj) + fctile |
132 |
|
133 |
enddo |
134 |
enddo |
135 |
|
136 |
#ifdef ALLOW_SMOOTH_IC_COST_CONTRIBUTION |
137 |
|
138 |
call active_read_xyz_loc( |
139 |
& fnamefld, tmpfld3d, irec, doglobalread, |
140 |
& ladinit, optimcycle, mythid, xx_salt_dummy ) |
141 |
|
142 |
_EXCH_XYZ_R8(tmpfld3d, mythid) |
143 |
|
144 |
c-- Loop over this thread's tiles. |
145 |
do bj = jtlo,jthi |
146 |
do bi = itlo,ithi |
147 |
|
148 |
fctile = 0. _d 0 |
149 |
do k = 1,nr |
150 |
do j = jmin,jmax |
151 |
do i = imin,imax |
152 |
if (_hFacC(i,j,k,bi,bj) .ne. 0.) then |
153 |
tmpx = |
154 |
& ( tmpfld3d(i+2,j,k,bi,bj)-tmpfld3d(i+1,j,k,bi,bj) ) |
155 |
& *maskW(i+1,j,k,bi,bj)*maskW(i+2,j,k,bi,bj) |
156 |
& + ( tmpfld3d(i+1,j,k,bi,bj)-tmpfld3d(i,j,k,bi,bj) ) |
157 |
& *maskW(i+1,j,k,bi,bj) |
158 |
& + ( tmpfld3d(i,j+2,k,bi,bj)-tmpfld3d(i,j+1,k,bi,bj) ) |
159 |
& *maskS(i,j+1,k,bi,bj)*maskS(i,j+2,k,bi,bj) |
160 |
& + ( tmpfld3d(i,j+1,k,bi,bj)-tmpfld3d(i,j,k,bi,bj) ) |
161 |
& *maskS(i,j+1,k,bi,bj) |
162 |
if ( ABS(R_low(i,j,bi,bj)) .LT. 100. ) |
163 |
& tmpx = tmpx*ABS(R_low(i,j,bi,bj))/100. |
164 |
fctile = fctile |
165 |
& + wsaltLev(i,j,k,bi,bj)*cosphi(i,j,bi,bj) |
166 |
* *0.0161*lengthscale/4.0 |
167 |
& *tmpx*tmpx |
168 |
endif |
169 |
enddo |
170 |
enddo |
171 |
enddo |
172 |
|
173 |
objf_salt0smoo(bi,bj) = objf_salt0smoo(bi,bj) + fctile |
174 |
|
175 |
enddo |
176 |
enddo |
177 |
#endif |
178 |
|
179 |
#endif |
180 |
|
181 |
end |