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