1 |
heimbach |
1.7 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_mean_heatflux.F,v 1.6 2007/10/09 00:02:50 jmc Exp $ |
2 |
jmc |
1.6 |
C $Name: $ |
3 |
heimbach |
1.1 |
|
4 |
|
|
#include "COST_CPPOPTIONS.h" |
5 |
|
|
|
6 |
|
|
|
7 |
|
|
subroutine cost_mean_heatflux( |
8 |
|
|
I myiter, |
9 |
|
|
I mytime, |
10 |
|
|
I mythid |
11 |
|
|
& ) |
12 |
|
|
|
13 |
|
|
c ================================================================== |
14 |
|
|
c SUBROUTINE cost_mean_heatflux |
15 |
|
|
c ================================================================== |
16 |
|
|
c |
17 |
|
|
c o Evaluate cost function contribution of sea surface salinity. |
18 |
|
|
c |
19 |
|
|
c started: Elisabeth Remy 19-mar-2001 copy from cost_sst.F |
20 |
|
|
c |
21 |
|
|
c ================================================================== |
22 |
|
|
c SUBROUTINE cost_mean_heatflux |
23 |
|
|
c ================================================================== |
24 |
|
|
|
25 |
|
|
implicit none |
26 |
|
|
|
27 |
|
|
c == global variables == |
28 |
|
|
|
29 |
|
|
#include "EEPARAMS.h" |
30 |
|
|
#include "SIZE.h" |
31 |
|
|
#include "GRID.h" |
32 |
|
|
#include "DYNVARS.h" |
33 |
|
|
#include "PARAMS.h" |
34 |
|
|
|
35 |
|
|
#include "cal.h" |
36 |
|
|
#include "ecco_cost.h" |
37 |
|
|
#include "ctrl.h" |
38 |
|
|
#include "ctrl_dummy.h" |
39 |
|
|
#include "optim.h" |
40 |
|
|
|
41 |
|
|
c == routine arguments == |
42 |
|
|
|
43 |
|
|
integer myiter |
44 |
|
|
_RL mytime |
45 |
|
|
integer mythid |
46 |
|
|
|
47 |
|
|
c == local variables == |
48 |
|
|
|
49 |
|
|
integer bi,bj |
50 |
heimbach |
1.2 |
integer i,j,kk |
51 |
heimbach |
1.1 |
integer itlo,ithi |
52 |
|
|
integer jtlo,jthi |
53 |
|
|
integer jmin,jmax |
54 |
|
|
integer imin,imax |
55 |
|
|
integer irec |
56 |
|
|
integer levmon |
57 |
|
|
integer levoff |
58 |
|
|
integer ilsalt |
59 |
|
|
|
60 |
|
|
_RL tmpx |
61 |
heimbach |
1.5 |
_RL sumtot |
62 |
|
|
_RL fctiletot |
63 |
|
|
|
64 |
heimbach |
1.1 |
|
65 |
|
|
character*(80) fnamehflux |
66 |
|
|
|
67 |
|
|
logical doglobalread |
68 |
|
|
logical ladinit |
69 |
|
|
|
70 |
|
|
character*(MAX_LEN_MBUF) msgbuf |
71 |
|
|
|
72 |
|
|
c == external functions == |
73 |
|
|
|
74 |
|
|
integer ilnblnk |
75 |
|
|
external ilnblnk |
76 |
|
|
|
77 |
|
|
c == end of interface == |
78 |
|
|
|
79 |
|
|
jtlo = mybylo(mythid) |
80 |
|
|
jthi = mybyhi(mythid) |
81 |
|
|
itlo = mybxlo(mythid) |
82 |
|
|
ithi = mybxhi(mythid) |
83 |
|
|
jmin = 1 |
84 |
|
|
jmax = sny |
85 |
|
|
imin = 1 |
86 |
|
|
imax = snx |
87 |
|
|
|
88 |
|
|
c-- Read tiled data. |
89 |
|
|
doglobalread = .false. |
90 |
|
|
ladinit = .false. |
91 |
|
|
|
92 |
|
|
#ifdef ALLOW_MEAN_HFLUX_COST_CONTRIBUTION |
93 |
|
|
|
94 |
|
|
if (optimcycle .ge. 0) then |
95 |
|
|
ilsalt = ilnblnk( hfluxbarfile ) |
96 |
|
|
write(fnamehflux(1:80),'(2a,i10.10)') |
97 |
|
|
& hfluxbarfile(1:ilsalt),'.',optimcycle |
98 |
|
|
endif |
99 |
|
|
|
100 |
heimbach |
1.5 |
do irec = 1, MAX(1,nyearsrec) |
101 |
heimbach |
1.1 |
|
102 |
|
|
c-- Read time averages and the monthly mean data. |
103 |
|
|
call active_read_xy( fnamehflux, tmpfld2d, irec, |
104 |
|
|
& doglobalread, ladinit, |
105 |
|
|
& optimcycle, mythid, |
106 |
|
|
& xx_hflux_mean_dummy ) |
107 |
|
|
|
108 |
heimbach |
1.5 |
sumtot = 0. |
109 |
|
|
fctiletot = 0. |
110 |
heimbach |
1.1 |
do bj = jtlo,jthi |
111 |
|
|
do bi = itlo,ithi |
112 |
|
|
kk = 1 |
113 |
|
|
do j = jmin,jmax |
114 |
|
|
do i = imin,imax |
115 |
|
|
tmpx=tmpfld2d(i,j,bi,bj) |
116 |
heimbach |
1.2 |
if (maskC(i,j,kk,bi,bj) .ne. 0.) then |
117 |
heimbach |
1.5 |
fctiletot = fctiletot |
118 |
|
|
& + tmpx*cos(yc(i,j,bi,bj)*deg2rad) |
119 |
|
|
sumtot = sumtot |
120 |
|
|
& + cos(yc(i,j,bi,bj)*deg2rad) |
121 |
heimbach |
1.4 |
num_hfluxmm(bi,bj) = num_hfluxmm(bi,bj) + 1 |
122 |
heimbach |
1.1 |
endif |
123 |
|
|
enddo |
124 |
|
|
enddo |
125 |
heimbach |
1.5 |
enddo |
126 |
|
|
enddo |
127 |
heimbach |
1.1 |
|
128 |
heimbach |
1.5 |
_GLOBAL_SUM_R8( sumtot , myThid ) |
129 |
|
|
_GLOBAL_SUM_R8( fctiletot , myThid ) |
130 |
jmc |
1.6 |
|
131 |
heimbach |
1.5 |
if (sumtot.eq.0.) sumtot = 1. |
132 |
|
|
|
133 |
|
|
if ( wmean_hflux .NE. 0. ) then |
134 |
|
|
objf_hfluxmm = objf_hfluxmm |
135 |
heimbach |
1.7 |
& + ((fctiletot/sumtot+1.D0)/wmean_hflux)**2 |
136 |
heimbach |
1.5 |
else |
137 |
|
|
objf_hfluxmm = 0. _d 0 |
138 |
|
|
endif |
139 |
|
|
|
140 |
|
|
c-- diagnostic: imbalance per year: |
141 |
|
|
write(standardmessageunit,'(A,I5,2(X,D22.14))') |
142 |
|
|
& ' --> bal_hfluxmm =', irec, |
143 |
|
|
& fctiletot/sumtot, |
144 |
heimbach |
1.7 |
& ((fctiletot/sumtot+1.D0)/wmean_hflux)**2 |
145 |
heimbach |
1.4 |
|
146 |
heimbach |
1.5 |
enddo |
147 |
heimbach |
1.1 |
|
148 |
|
|
#endif |
149 |
|
|
|
150 |
|
|
return |
151 |
|
|
end |
152 |
|
|
|