/[MITgcm]/MITgcm/pkg/ecco/cost_salt0.F
ViewVC logotype

Contents of /MITgcm/pkg/ecco/cost_salt0.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.10 - (show annotations) (download)
Tue Apr 28 18:13:28 2009 UTC (15 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint61n, checkpoint61o, checkpoint61m, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint61z, checkpoint61x, checkpoint61y
Changes since 1.9: +2 -2 lines
change macros (EXCH & GLOBAL_SUM/MAX) sufix _R4/_R8 to _RS/_RL
 when applied to _RS/_RL variable

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

  ViewVC Help
Powered by ViewVC 1.1.22