/[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.15 - (show annotations) (download)
Sat Oct 18 18:15:44 2014 UTC (9 years, 7 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65p, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65g
Changes since 1.14: +4 -3 lines
- add CPP brackets around includes, to omit
  them altogether when they are not used.

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_salt0.F,v 1.14 2012/09/04 15:04:51 gforget Exp $
2 C $Name: $
3
4 #include "ECCO_OPTIONS.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 #ifdef ALLOW_SALT0_COST_CONTRIBUTION
35 #include "EEPARAMS.h"
36 #include "SIZE.h"
37 #include "GRID.h"
38
39 #include "ecco_cost.h"
40 #include "CTRL_SIZE.h"
41 #include "ctrl.h"
42 #include "ctrl_dummy.h"
43 #include "optim.h"
44 #endif
45
46 c == routine arguments ==
47
48 integer myiter
49 _RL mytime
50 integer mythid
51
52 #ifdef ALLOW_SALT0_COST_CONTRIBUTION
53 c == local variables ==
54
55 integer bi,bj
56 integer i,j,k
57 integer itlo,ithi
58 integer jtlo,jthi
59 integer jmin,jmax
60 integer imin,imax
61 integer nrec
62 integer irec
63 integer ilfld
64
65 _RL fctile
66 _RL tmpx
67 _RL lengthscale
68
69 logical doglobalread
70 logical ladinit
71
72 character*(80) fnamefld
73
74 character*(MAX_LEN_MBUF) msgbuf
75
76 c == external functions ==
77
78 integer ilnblnk
79 external ilnblnk
80
81 c == end of interface ==
82
83 jtlo = mybylo(mythid)
84 jthi = mybyhi(mythid)
85 itlo = mybxlo(mythid)
86 ithi = mybxhi(mythid)
87 jmin = 1
88 jmax = sny
89 imin = 1
90 imax = snx
91
92 lengthscale = 1. _d 0
93
94 c-- Read state record from global file.
95 doglobalread = .false.
96 ladinit = .false.
97
98 irec = 1
99
100 if (optimcycle .ge. 0) then
101 ilfld = ilnblnk( xx_salt_file )
102 write(fnamefld(1:80),'(2a,i10.10)')
103 & xx_salt_file(1:ilfld),'.',optimcycle
104 endif
105
106 call active_read_xyz( fnamefld, tmpfld3d, irec, doglobalread,
107 & ladinit, optimcycle, mythid
108 & , xx_salt_dummy )
109
110 c-- Loop over this thread tiles.
111 do bj = jtlo,jthi
112 do bi = itlo,ithi
113
114 c-- Determine the weights to be used.
115
116 fctile = 0. _d 0
117 do k = 1,nr
118 do j = jmin,jmax
119 do i = imin,imax
120 if (_hFacC(i,j,k,bi,bj) .ne. 0.) then
121 tmpx = tmpfld3d(i,j,k,bi,bj)
122 IF ( .NOT.ctrlSmoothCorrel3D ) THEN
123 if ( ABS(R_low(i,j,bi,bj)) .LT. 100. )
124 & tmpx = tmpx*ABS(R_low(i,j,bi,bj))/100.
125 fctile = fctile
126 & + wsaltLev(i,j,k,bi,bj)*cosphi(i,j,bi,bj)
127 & *tmpx*tmpx
128 ELSE !IF ( .NOT.ctrlSmoothCorrel3D ) THEN
129 fctile = fctile + tmpx*tmpx
130 ENDIF !IF ( .NOT.ctrlSmoothCorrel3D ) THEN
131 if ( wsaltLev(i,j,k,bi,bj)*cosphi(i,j,bi,bj).ne.0. )
132 & num_salt0(bi,bj) = num_salt0(bi,bj) + 1. _d 0
133 endif
134 enddo
135 enddo
136 enddo
137
138 objf_salt0(bi,bj) = objf_salt0(bi,bj) + fctile
139
140 enddo
141 enddo
142
143 IF ( .NOT.ctrlSmoothCorrel3D ) THEN
144 #ifdef ALLOW_SMOOTH_IC_COST_CONTRIBUTION
145
146 call active_read_xyz(
147 & fnamefld, tmpfld3d, irec, doglobalread,
148 & ladinit, optimcycle, mythid, xx_salt_dummy )
149
150 _EXCH_XYZ_RL(tmpfld3d, mythid)
151
152 c-- Loop over this thread tiles.
153 do bj = jtlo,jthi
154 do bi = itlo,ithi
155
156 fctile = 0. _d 0
157 do k = 1,nr
158 do j = jmin,jmax
159 do i = imin,imax
160 if (_hFacC(i,j,k,bi,bj) .ne. 0.) then
161 tmpx =
162 & ( tmpfld3d(i+2,j,k,bi,bj)-tmpfld3d(i+1,j,k,bi,bj) )
163 & *maskW(i+1,j,k,bi,bj)*maskW(i+2,j,k,bi,bj)
164 & + ( tmpfld3d(i+1,j,k,bi,bj)-tmpfld3d(i,j,k,bi,bj) )
165 & *maskW(i+1,j,k,bi,bj)
166 & + ( tmpfld3d(i,j+2,k,bi,bj)-tmpfld3d(i,j+1,k,bi,bj) )
167 & *maskS(i,j+1,k,bi,bj)*maskS(i,j+2,k,bi,bj)
168 & + ( tmpfld3d(i,j+1,k,bi,bj)-tmpfld3d(i,j,k,bi,bj) )
169 & *maskS(i,j+1,k,bi,bj)
170 if ( ABS(R_low(i,j,bi,bj)) .LT. 100. )
171 & tmpx = tmpx*ABS(R_low(i,j,bi,bj))/100.
172 fctile = fctile
173 & + wsaltLev(i,j,k,bi,bj)*cosphi(i,j,bi,bj)
174 * *0.0161*lengthscale/4.0
175 & *tmpx*tmpx
176 endif
177 enddo
178 enddo
179 enddo
180
181 objf_salt0smoo(bi,bj) = objf_salt0smoo(bi,bj) + fctile
182
183 enddo
184 enddo
185 #endif
186 ENDIF !IF ( .NOT.ctrlSmoothCorrel3D ) THEN
187
188 #endif
189
190 end

  ViewVC Help
Powered by ViewVC 1.1.22