1 |
C $Header: /u/gcmpack/MITgcm/pkg/cost/Attic/cost_theta_ini_fin.F,v 1.1.2.1 2003/05/23 16:26:26 heimbach Exp $ |
2 |
|
3 |
#include "COST_CPPOPTIONS.h" |
4 |
|
5 |
|
6 |
subroutine cost_theta_ini_fin( |
7 |
I myiter, |
8 |
I mytime, |
9 |
I mythid |
10 |
& ) |
11 |
|
12 |
c ================================================================== |
13 |
c SUBROUTINE cost_theta_ini_fin |
14 |
c ================================================================== |
15 |
c |
16 |
c ================================================================== |
17 |
c SUBROUTINE cost_theta_ini_fin |
18 |
c ================================================================== |
19 |
|
20 |
implicit none |
21 |
|
22 |
c == global variables == |
23 |
|
24 |
#include "EEPARAMS.h" |
25 |
#include "SIZE.h" |
26 |
#include "GRID.h" |
27 |
#include "DYNVARS.h" |
28 |
|
29 |
#include "ecco_cost.h" |
30 |
#include "ctrl.h" |
31 |
#include "ctrl_dummy.h" |
32 |
#include "optim.h" |
33 |
|
34 |
c == routine arguments == |
35 |
|
36 |
integer myiter |
37 |
_RL mytime |
38 |
integer mythid |
39 |
|
40 |
c == local variables == |
41 |
|
42 |
integer bi,bj |
43 |
integer i,j,k |
44 |
integer itlo,ithi |
45 |
integer jtlo,jthi |
46 |
integer jmin,jmax |
47 |
integer imin,imax |
48 |
integer nrec |
49 |
integer irec |
50 |
integer ilfld |
51 |
|
52 |
_RL fctile |
53 |
_RL fcthread |
54 |
_RL tmpx |
55 |
|
56 |
logical doglobalread |
57 |
logical ladinit |
58 |
|
59 |
character*(80) fnamefld |
60 |
|
61 |
character*(MAX_LEN_MBUF) msgbuf |
62 |
|
63 |
c == external functions == |
64 |
|
65 |
integer ilnblnk |
66 |
external ilnblnk |
67 |
|
68 |
c == end of interface == |
69 |
|
70 |
jtlo = mybylo(mythid) |
71 |
jthi = mybyhi(mythid) |
72 |
itlo = mybxlo(mythid) |
73 |
ithi = mybxhi(mythid) |
74 |
jmin = 1 |
75 |
jmax = sny |
76 |
imin = 1 |
77 |
imax = snx |
78 |
|
79 |
c-- Read state record from global file. |
80 |
doglobalread = .false. |
81 |
ladinit = .false. |
82 |
|
83 |
irec = 1 |
84 |
|
85 |
#ifdef ALLOW_COST_INI_FIN |
86 |
|
87 |
ilfld = ilnblnk( xx_theta_ini_fin_file ) |
88 |
write(fnamefld(1:80),'(2a,i10.10)') |
89 |
& xx_theta_ini_fin_file(1:ilfld),'.',optimcycle |
90 |
|
91 |
fcthread = 0. _d 0 |
92 |
|
93 |
call active_read_xyz( fnamefld, tmpfld3d, irec, doglobalread, |
94 |
& ladinit, optimcycle, mythid, |
95 |
& xx_theta_ini_fin_dummy ) |
96 |
|
97 |
c-- Loop over this thread's tiles. |
98 |
do bj = jtlo,jthi |
99 |
do bi = itlo,ithi |
100 |
|
101 |
c-- Determine the weights to be used. |
102 |
|
103 |
fctile = 0. _d 0 |
104 |
do k = 1,nr |
105 |
do j = jmin,jmax |
106 |
do i = imin,imax |
107 |
if (_hFacC(i,j,k,bi,bj) .ne. 0.) then |
108 |
tmpx = tmpfld3d(i,j,k,bi,bj) - theta(i,j,k,bi,bj) |
109 |
fctile = fctile |
110 |
& + wtheta(k,bi,bj)*cosphi(i,j,bi,bj) |
111 |
& *tmpx*tmpx |
112 |
endif |
113 |
enddo |
114 |
enddo |
115 |
enddo |
116 |
|
117 |
objf_theta_ini_fin(bi,bj) = |
118 |
& objf_theta_ini_fin(bi,bj) + fctile |
119 |
fcthread = fcthread + fctile |
120 |
|
121 |
#ifdef ECCO_VERBOSE |
122 |
c-- Print cost function for each tile in each thread. |
123 |
write(msgbuf,'(a)') ' ' |
124 |
call print_message( msgbuf, standardmessageunit, |
125 |
& SQUEEZE_RIGHT , mythid) |
126 |
write(msgbuf,'(a,i8.8,1x,i3.3,1x,i3.3)') |
127 |
& ' cost_theta_ini_fin: irec,bi,bj = ',irec,bi,bj |
128 |
call print_message( msgbuf, standardmessageunit, |
129 |
& SQUEEZE_RIGHT , mythid) |
130 |
write(msgbuf,'(a,d22.15)') |
131 |
& ' cost_theta_ini_fin: irec,bi,bj = ', |
132 |
& fctile |
133 |
call print_message( msgbuf, standardmessageunit, |
134 |
& SQUEEZE_RIGHT , mythid) |
135 |
#endif |
136 |
enddo |
137 |
enddo |
138 |
|
139 |
#ifdef ECCO_VERBOSE |
140 |
c-- Print cost function for all tiles. |
141 |
_GLOBAL_SUM_R8( fcthread , myThid ) |
142 |
write(msgbuf,'(a)') ' ' |
143 |
call print_message( msgbuf, standardmessageunit, |
144 |
& SQUEEZE_RIGHT , mythid) |
145 |
write(msgbuf,'(a,i8.8)') |
146 |
& ' cost_: irec = ',irec |
147 |
call print_message( msgbuf, standardmessageunit, |
148 |
& SQUEEZE_RIGHT , mythid) |
149 |
write(msgbuf,'(a,d22.15)') |
150 |
& ' global cost function value = ', |
151 |
& fcthread |
152 |
call print_message( msgbuf, standardmessageunit, |
153 |
& SQUEEZE_RIGHT , mythid) |
154 |
write(msgbuf,'(a)') ' ' |
155 |
call print_message( msgbuf, standardmessageunit, |
156 |
& SQUEEZE_RIGHT , mythid) |
157 |
#endif |
158 |
|
159 |
#else |
160 |
c-- Do not enter the calculation of the salinity increment |
161 |
c-- contribution to the final cost function. |
162 |
|
163 |
fctile = 0. _d 0 |
164 |
fcthread = 0. _d 0 |
165 |
|
166 |
#ifdef ECCO_VERBOSE |
167 |
_BEGIN_MASTER( mythid ) |
168 |
write(msgbuf,'(a)') ' ' |
169 |
call print_message( msgbuf, standardmessageunit, |
170 |
& SQUEEZE_RIGHT , mythid) |
171 |
write(msgbuf,'(a,a)') |
172 |
& ' cost_theta_ini_fin : no contribution of the IC in salin. ', |
173 |
& ' to cost function.' |
174 |
call print_message( msgbuf, standardmessageunit, |
175 |
& SQUEEZE_RIGHT , mythid) |
176 |
write(msgbuf,'(a)') ' ' |
177 |
call print_message( msgbuf, standardmessageunit, |
178 |
& SQUEEZE_RIGHT , mythid) |
179 |
_END_MASTER( mythid ) |
180 |
#endif |
181 |
|
182 |
#endif |
183 |
|
184 |
return |
185 |
end |
186 |
|
187 |
|