ADflow  v1.0
ADflow is a finite volume RANS solver tailored for gradient-based aerodynamic design optimization.
sa_fast_b.f90
Go to the documentation of this file.
1 ! generated by tapenade (inria, ecuador team)
2 ! tapenade 3.16 (develop) - 22 aug 2023 15:51
3 !
4 ! this module contains the source code related to the sa turbulence
5 ! model. it is slightly more modularized than the original which makes
6 ! performing reverse mode ad simplier.
7 module sa_fast_b
8  use constants
9  implicit none
10  real(kind=realtype) :: cv13, kar2inv, cw36, cb3inv
11  real(kind=realtype), dimension(:, :, :), allocatable :: qq
12  real(kind=realtype), dimension(:, :, :), pointer :: ddw, ww, ddvt
13  real(kind=realtype), dimension(:, :), pointer :: rrlv
14  real(kind=realtype), dimension(:, :), pointer :: dd2wall
15 
16 contains
17 ! differentiation of sasource in reverse (adjoint) mode (with options noisize i4 dr8 r8):
18 ! gradient of useful results: *w *rlv *scratch
19 ! with respect to varying inputs: *w *rlv *scratch
20 ! rw status of diff variables: *w:incr *rlv:incr *scratch:in-out
21 ! plus diff mem management of: w:in rlv:in scratch:in
22  subroutine sasource_fast_b()
23 !
24 ! source terms.
25 ! determine the source term and its derivative w.r.t. nutilde
26 ! for all internal cells of the block.
27 ! remember that the sa field variable nutilde = w(i,j,k,itu1)
28  use blockpointers
29  use constants
30  use paramturb
31  use section
32  use inputphysics
33  use inputdiscretization, only : approxsa
34  use flowvarrefstate
35  implicit none
36 ! local parameters
37  real(kind=realtype), parameter :: f23=two*third
38 ! local variables.
39  integer(kind=inttype) :: i, j, k, nn, ii
40  real(kind=realtype) :: fv1, fv2, ft2
41  real(kind=realtype) :: fv1d, fv2d, ft2d
42  real(kind=realtype) :: ss, sst, nu, dist2inv, chi, chi2, chi3
43  real(kind=realtype) :: ssd, sstd, nud, chid, chi2d, chi3d
44  real(kind=realtype) :: rr, gg, gg6, termfw, fwsa, term1, term2
45  real(kind=realtype) :: rrd, ggd, gg6d, termfwd, fwsad, term1d, &
46 & term2d
47  real(kind=realtype) :: dfv1, dfv2, dft2, drr, dgg, dfw
48  real(kind=realtype) :: uux, uuy, uuz, vvx, vvy, vvz, wwx, wwy, wwz
49  real(kind=realtype) :: uuxd, uuyd, uuzd, vvxd, vvyd, vvzd, wwxd, &
50 & wwyd, wwzd
51  real(kind=realtype) :: div2, fact, sxx, syy, szz, sxy, sxz, syz
52  real(kind=realtype) :: div2d, sxxd, syyd, szzd, sxyd, sxzd, syzd
53  real(kind=realtype) :: vortx, vorty, vortz
54  real(kind=realtype) :: vortxd, vortyd, vortzd
55  real(kind=realtype) :: omegax, omegay, omegaz
56  real(kind=realtype) :: strainmag2, strainprod, vortprod
57  real(kind=realtype) :: strainmag2d, strainprodd, vortprodd
58  real(kind=realtype), parameter :: xminn=1.e-10_realtype
59  intrinsic mod
60  intrinsic sqrt
61  intrinsic exp
62  intrinsic min
63  intrinsic max
64  real(kind=realtype) :: y1
65  real(kind=realtype) :: y1d
66  real(kind=realtype) :: min1
67  real(kind=realtype) :: min1d
68  real(kind=realtype) :: temp
69  real(kind=realtype) :: tempd
70  real(kind=realtype) :: temp0
71  real(kind=realtype) :: tempd0
72  integer :: branch
73 ! set model constants
74  cv13 = rsacv1**3
75  kar2inv = one/rsak**2
76  cw36 = rsacw3**6
77 ! determine the non-dimensional wheel speed of this block.
78  omegax = timeref*sections(sectionid)%rotrate(1)
79  omegay = timeref*sections(sectionid)%rotrate(2)
80  omegaz = timeref*sections(sectionid)%rotrate(3)
81 ! create switches to production term depending on the variable that
82 ! should be used
83  if (turbprod .eq. katolaunder) then
84  stop
85  else
86  strainmag2d = 0.0_8
87  ssd = 0.0_8
88 !$bwd-of ii-loop
89  do ii=0,nx*ny*nz-1
90  i = mod(ii, nx) + 2
91  j = mod(ii/nx, ny) + 2
92  k = ii/(nx*ny) + 2
93 ! compute the gradient of u in the cell center. use is made
94 ! of the fact that the surrounding normals sum up to zero,
95 ! such that the cell i,j,k does not give a contribution.
96 ! the gradient is scaled by the factor 2*vol.
97  uux = w(i+1, j, k, ivx)*si(i, j, k, 1) - w(i-1, j, k, ivx)*si(i-&
98 & 1, j, k, 1) + w(i, j+1, k, ivx)*sj(i, j, k, 1) - w(i, j-1, k, &
99 & ivx)*sj(i, j-1, k, 1) + w(i, j, k+1, ivx)*sk(i, j, k, 1) - w(i&
100 & , j, k-1, ivx)*sk(i, j, k-1, 1)
101  uuy = w(i+1, j, k, ivx)*si(i, j, k, 2) - w(i-1, j, k, ivx)*si(i-&
102 & 1, j, k, 2) + w(i, j+1, k, ivx)*sj(i, j, k, 2) - w(i, j-1, k, &
103 & ivx)*sj(i, j-1, k, 2) + w(i, j, k+1, ivx)*sk(i, j, k, 2) - w(i&
104 & , j, k-1, ivx)*sk(i, j, k-1, 2)
105  uuz = w(i+1, j, k, ivx)*si(i, j, k, 3) - w(i-1, j, k, ivx)*si(i-&
106 & 1, j, k, 3) + w(i, j+1, k, ivx)*sj(i, j, k, 3) - w(i, j-1, k, &
107 & ivx)*sj(i, j-1, k, 3) + w(i, j, k+1, ivx)*sk(i, j, k, 3) - w(i&
108 & , j, k-1, ivx)*sk(i, j, k-1, 3)
109 ! idem for the gradient of v.
110  vvx = w(i+1, j, k, ivy)*si(i, j, k, 1) - w(i-1, j, k, ivy)*si(i-&
111 & 1, j, k, 1) + w(i, j+1, k, ivy)*sj(i, j, k, 1) - w(i, j-1, k, &
112 & ivy)*sj(i, j-1, k, 1) + w(i, j, k+1, ivy)*sk(i, j, k, 1) - w(i&
113 & , j, k-1, ivy)*sk(i, j, k-1, 1)
114  vvy = w(i+1, j, k, ivy)*si(i, j, k, 2) - w(i-1, j, k, ivy)*si(i-&
115 & 1, j, k, 2) + w(i, j+1, k, ivy)*sj(i, j, k, 2) - w(i, j-1, k, &
116 & ivy)*sj(i, j-1, k, 2) + w(i, j, k+1, ivy)*sk(i, j, k, 2) - w(i&
117 & , j, k-1, ivy)*sk(i, j, k-1, 2)
118  vvz = w(i+1, j, k, ivy)*si(i, j, k, 3) - w(i-1, j, k, ivy)*si(i-&
119 & 1, j, k, 3) + w(i, j+1, k, ivy)*sj(i, j, k, 3) - w(i, j-1, k, &
120 & ivy)*sj(i, j-1, k, 3) + w(i, j, k+1, ivy)*sk(i, j, k, 3) - w(i&
121 & , j, k-1, ivy)*sk(i, j, k-1, 3)
122 ! and for the gradient of w.
123  wwx = w(i+1, j, k, ivz)*si(i, j, k, 1) - w(i-1, j, k, ivz)*si(i-&
124 & 1, j, k, 1) + w(i, j+1, k, ivz)*sj(i, j, k, 1) - w(i, j-1, k, &
125 & ivz)*sj(i, j-1, k, 1) + w(i, j, k+1, ivz)*sk(i, j, k, 1) - w(i&
126 & , j, k-1, ivz)*sk(i, j, k-1, 1)
127  wwy = w(i+1, j, k, ivz)*si(i, j, k, 2) - w(i-1, j, k, ivz)*si(i-&
128 & 1, j, k, 2) + w(i, j+1, k, ivz)*sj(i, j, k, 2) - w(i, j-1, k, &
129 & ivz)*sj(i, j-1, k, 2) + w(i, j, k+1, ivz)*sk(i, j, k, 2) - w(i&
130 & , j, k-1, ivz)*sk(i, j, k-1, 2)
131  wwz = w(i+1, j, k, ivz)*si(i, j, k, 3) - w(i-1, j, k, ivz)*si(i-&
132 & 1, j, k, 3) + w(i, j+1, k, ivz)*sj(i, j, k, 3) - w(i, j-1, k, &
133 & ivz)*sj(i, j-1, k, 3) + w(i, j, k+1, ivz)*sk(i, j, k, 3) - w(i&
134 & , j, k-1, ivz)*sk(i, j, k-1, 3)
135 ! compute the components of the stress tensor.
136 ! the combination of the current scaling of the velocity
137 ! gradients (2*vol) and the definition of the stress tensor,
138 ! leads to the factor 1/(4*vol).
139  fact = fourth/vol(i, j, k)
140  if (turbprod .eq. strain) then
141  sxx = two*fact*uux
142  syy = two*fact*vvy
143  szz = two*fact*wwz
144  sxy = fact*(uuy+vvx)
145  sxz = fact*(uuz+wwx)
146  syz = fact*(vvz+wwy)
147 ! compute 2/3 * divergence of velocity squared
148  div2 = f23*(sxx+syy+szz)**2
149 ! compute strain production term
150  strainmag2 = two*(sxy**2+sxz**2+syz**2) + sxx**2 + syy**2 + &
151 & szz**2
152  strainprod = two*strainmag2 - div2
153  ss = sqrt(strainprod)
154  call pushcontrol2b(0)
155  else if (turbprod .eq. vorticity) then
156 ! compute the three components of the vorticity vector.
157 ! substract the part coming from the rotating frame.
158  vortx = two*fact*(wwy-vvz) - two*omegax
159  vorty = two*fact*(uuz-wwx) - two*omegay
160  vortz = two*fact*(vvx-uuy) - two*omegaz
161 ! compute the vorticity production term
162  vortprod = vortx**2 + vorty**2 + vortz**2
163 ! first take the square root of the production term to
164 ! obtain the correct production term for spalart-allmaras.
165 ! we do this to avoid if statements.
166  ss = sqrt(vortprod)
167  call pushcontrol2b(1)
168  else
169  call pushcontrol2b(2)
170  end if
171 ! compute the laminar kinematic viscosity, the inverse of
172 ! wall distance squared, the ratio chi (ratio of nutilde
173 ! and nu) and the functions fv1 and fv2. the latter corrects
174 ! the production term near a viscous wall.
175  nu = rlv(i, j, k)/w(i, j, k, irho)
176  dist2inv = one/d2wall(i, j, k)**2
177  chi = w(i, j, k, itu1)/nu
178  chi2 = chi*chi
179  chi3 = chi*chi2
180  fv1 = chi3/(chi3+cv13)
181  fv2 = one - chi/(one+chi*fv1)
182 ! the function ft2, which is designed to keep a laminar
183 ! solution laminar. when running in fully turbulent mode
184 ! this function should be set to 0.0.
185  if (useft2sa) then
186  ft2 = rsact3*exp(-(rsact4*chi2))
187 myintptr = myintptr + 1
188  myintstack(myintptr) = 0
189  else
190  ft2 = zero
191 myintptr = myintptr + 1
192  myintstack(myintptr) = 1
193  end if
194 ! correct the production term to account for the influence
195 ! of the wall.
196  sst = ss + w(i, j, k, itu1)*fv2*kar2inv*dist2inv
197 ! add rotation term (userotationsa defined in inputparams.f90)
198  if (userotationsa) then
199  y1 = sqrt(two*strainmag2)
200  if (zero .gt. y1) then
201  min1 = y1
202 myintptr = myintptr + 1
203  myintstack(myintptr) = 0
204  else
205  min1 = zero
206 myintptr = myintptr + 1
207  myintstack(myintptr) = 1
208  end if
209  sst = sst + rsacrot*min1
210 myintptr = myintptr + 1
211  myintstack(myintptr) = 1
212  else
213 myintptr = myintptr + 1
214  myintstack(myintptr) = 0
215  end if
216  if (sst .lt. xminn) then
217  sst = xminn
218 myintptr = myintptr + 1
219  myintstack(myintptr) = 0
220  else
221 myintptr = myintptr + 1
222  myintstack(myintptr) = 1
223  sst = sst
224  end if
225 ! compute the function fw. the argument rr is cut off at 10
226 ! to avoid numerical problems. this is ok, because the
227 ! asymptotical value of fw is then already reached.
228  rr = w(i, j, k, itu1)*kar2inv*dist2inv/sst
229  if (rr .gt. 10.0_realtype) then
230  rr = 10.0_realtype
231 myintptr = myintptr + 1
232  myintstack(myintptr) = 0
233  else
234 myintptr = myintptr + 1
235  myintstack(myintptr) = 1
236  rr = rr
237  end if
238  gg = rr + rsacw2*(rr**6-rr)
239  gg6 = gg**6
240  termfw = ((one+cw36)/(gg6+cw36))**sixth
241  fwsa = gg*termfw
242 ! compute the source term; some terms are saved for the
243 ! linearization. the source term is stored in dvt.
244  if (approxsa) then
245 myintptr = myintptr + 1
246  myintstack(myintptr) = 0
247  term1 = zero
248  else
249  term1 = rsacb1*(one-ft2)*ss
250 myintptr = myintptr + 1
251  myintstack(myintptr) = 1
252  end if
253  term2 = dist2inv*(kar2inv*rsacb1*((one-ft2)*fv2+ft2)-rsacw1*fwsa&
254 & )
255  temp = w(i, j, k, itu1)
256  tempd0 = w(i, j, k, itu1)*scratchd(i, j, k, idvt)
257  wd(i, j, k, itu1) = wd(i, j, k, itu1) + (term1+term2*temp)*&
258 & scratchd(i, j, k, idvt) + term2*tempd0
259  scratchd(i, j, k, idvt) = 0.0_8
260  term1d = tempd0
261  term2d = temp*tempd0
262  tempd0 = kar2inv*rsacb1*dist2inv*term2d
263  fwsad = -(rsacw1*dist2inv*term2d)
264  ft2d = (1.0-fv2)*tempd0
265  fv2d = (one-ft2)*tempd0
266 branch = myintstack(myintptr)
267  myintptr = myintptr - 1
268  if (branch .ne. 0) then
269  ft2d = ft2d - ss*rsacb1*term1d
270  ssd = ssd + (one-ft2)*rsacb1*term1d
271  end if
272  termfwd = gg*fwsad
273  temp0 = (one+cw36)/(cw36+gg6)
274  if (temp0 .le. 0.0_8 .and. (sixth .eq. 0.0_8 .or. sixth .ne. int&
275 & (sixth))) then
276  gg6d = 0.0_8
277  else
278  gg6d = -(temp0*sixth*temp0**(sixth-1)*termfwd/(cw36+gg6))
279  end if
280  ggd = termfw*fwsad + 6*gg**5*gg6d
281  rrd = (6*rr**5*rsacw2-rsacw2+1.0)*ggd
282 branch = myintstack(myintptr)
283  myintptr = myintptr - 1
284  if (branch .eq. 0) rrd = 0.0_8
285  tempd0 = kar2inv*dist2inv*rrd/sst
286  wd(i, j, k, itu1) = wd(i, j, k, itu1) + tempd0
287  sstd = -(w(i, j, k, itu1)*tempd0/sst)
288 branch = myintstack(myintptr)
289  myintptr = myintptr - 1
290  if (branch .eq. 0) sstd = 0.0_8
291 branch = myintstack(myintptr)
292  myintptr = myintptr - 1
293  if (branch .ne. 0) then
294  min1d = rsacrot*sstd
295 branch = myintstack(myintptr)
296  myintptr = myintptr - 1
297  if (branch .eq. 0) then
298  y1d = min1d
299  else
300  y1d = 0.0_8
301  end if
302  if (.not.two*strainmag2 .eq. 0.0_8) strainmag2d = strainmag2d &
303 & + two*y1d/(2.0*sqrt(two*strainmag2))
304  end if
305  ssd = ssd + sstd
306  tempd0 = kar2inv*dist2inv*sstd
307  wd(i, j, k, itu1) = wd(i, j, k, itu1) + fv2*tempd0
308  fv2d = fv2d + w(i, j, k, itu1)*tempd0
309 branch = myintstack(myintptr)
310  myintptr = myintptr - 1
311  if (branch .eq. 0) then
312  chi2d = -(rsact4*exp(-(rsact4*chi2))*rsact3*ft2d)
313  else
314  chi2d = 0.0_8
315  end if
316  tempd = -(fv2d/(one+chi*fv1))
317  chid = tempd
318  tempd0 = -(chi*tempd/(one+chi*fv1))
319  fv1d = chi*tempd0
320  tempd = fv1d/(cv13+chi3)
321  chi3d = (1.0-chi3/(cv13+chi3))*tempd
322  chi2d = chi2d + chi*chi3d
323  chid = chid + fv1*tempd0 + chi2*chi3d + 2*chi*chi2d
324  wd(i, j, k, itu1) = wd(i, j, k, itu1) + chid/nu
325  nud = -(w(i, j, k, itu1)*chid/nu**2)
326  temp = w(i, j, k, irho)
327  rlvd(i, j, k) = rlvd(i, j, k) + nud/temp
328  wd(i, j, k, irho) = wd(i, j, k, irho) - rlv(i, j, k)*nud/temp**2
329  call popcontrol2b(branch)
330  if (branch .eq. 0) then
331  if (strainprod .eq. 0.0_8) then
332  strainprodd = 0.0_8
333  else
334  strainprodd = ssd/(2.0*sqrt(strainprod))
335  end if
336  strainmag2d = strainmag2d + two*strainprodd
337  div2d = -strainprodd
338  tempd = two*strainmag2d
339  sxyd = 2*sxy*tempd
340  sxzd = 2*sxz*tempd
341  syzd = 2*syz*tempd
342  tempd = 2*(sxx+syy+szz)*f23*div2d
343  sxxd = 2*sxx*strainmag2d + tempd
344  syyd = 2*syy*strainmag2d + tempd
345  szzd = 2*szz*strainmag2d + tempd
346  vvzd = fact*syzd
347  wwyd = fact*syzd
348  uuzd = fact*sxzd
349  wwxd = fact*sxzd
350  uuyd = fact*sxyd
351  vvxd = fact*sxyd
352  wwzd = two*fact*szzd
353  vvyd = two*fact*syyd
354  uuxd = two*fact*sxxd
355  strainmag2d = 0.0_8
356  ssd = 0.0_8
357  else
358  if (branch .eq. 1) then
359  if (vortprod .eq. 0.0_8) then
360  vortprodd = 0.0_8
361  else
362  vortprodd = ssd/(2.0*sqrt(vortprod))
363  end if
364  vortxd = 2*vortx*vortprodd
365  vortyd = 2*vorty*vortprodd
366  vortzd = 2*vortz*vortprodd
367  tempd = two*fact*vortzd
368  vvxd = tempd
369  uuyd = -tempd
370  tempd = two*fact*vortyd
371  uuzd = tempd
372  wwxd = -tempd
373  tempd = two*fact*vortxd
374  wwyd = tempd
375  vvzd = -tempd
376  ssd = 0.0_8
377  else
378  wwxd = 0.0_8
379  wwyd = 0.0_8
380  vvxd = 0.0_8
381  vvzd = 0.0_8
382  uuyd = 0.0_8
383  uuzd = 0.0_8
384  end if
385  wwzd = 0.0_8
386  vvyd = 0.0_8
387  uuxd = 0.0_8
388  end if
389  wd(i, j, k-1, ivz) = wd(i, j, k-1, ivz) - sk(i, j, k-1, 3)*wwzd &
390 & - sk(i, j, k-1, 2)*wwyd - sk(i, j, k-1, 1)*wwxd
391  wd(i, j-1, k, ivz) = wd(i, j-1, k, ivz) - sj(i, j-1, k, 3)*wwzd &
392 & - sj(i, j-1, k, 2)*wwyd - sj(i, j-1, k, 1)*wwxd
393  wd(i, j, k+1, ivz) = wd(i, j, k+1, ivz) + sk(i, j, k, 3)*wwzd + &
394 & sk(i, j, k, 2)*wwyd + sk(i, j, k, 1)*wwxd
395  wd(i, j+1, k, ivz) = wd(i, j+1, k, ivz) + sj(i, j, k, 3)*wwzd + &
396 & sj(i, j, k, 2)*wwyd + sj(i, j, k, 1)*wwxd
397  wd(i-1, j, k, ivz) = wd(i-1, j, k, ivz) - si(i-1, j, k, 3)*wwzd &
398 & - si(i-1, j, k, 2)*wwyd - si(i-1, j, k, 1)*wwxd
399  wd(i+1, j, k, ivz) = wd(i+1, j, k, ivz) + si(i, j, k, 3)*wwzd + &
400 & si(i, j, k, 2)*wwyd + si(i, j, k, 1)*wwxd
401  wd(i, j, k-1, ivy) = wd(i, j, k-1, ivy) - sk(i, j, k-1, 3)*vvzd &
402 & - sk(i, j, k-1, 2)*vvyd - sk(i, j, k-1, 1)*vvxd
403  wd(i, j-1, k, ivy) = wd(i, j-1, k, ivy) - sj(i, j-1, k, 3)*vvzd &
404 & - sj(i, j-1, k, 2)*vvyd - sj(i, j-1, k, 1)*vvxd
405  wd(i, j, k+1, ivy) = wd(i, j, k+1, ivy) + sk(i, j, k, 3)*vvzd + &
406 & sk(i, j, k, 2)*vvyd + sk(i, j, k, 1)*vvxd
407  wd(i, j+1, k, ivy) = wd(i, j+1, k, ivy) + sj(i, j, k, 3)*vvzd + &
408 & sj(i, j, k, 2)*vvyd + sj(i, j, k, 1)*vvxd
409  wd(i-1, j, k, ivy) = wd(i-1, j, k, ivy) - si(i-1, j, k, 3)*vvzd &
410 & - si(i-1, j, k, 2)*vvyd - si(i-1, j, k, 1)*vvxd
411  wd(i+1, j, k, ivy) = wd(i+1, j, k, ivy) + si(i, j, k, 3)*vvzd + &
412 & si(i, j, k, 2)*vvyd + si(i, j, k, 1)*vvxd
413  wd(i, j, k-1, ivx) = wd(i, j, k-1, ivx) - sk(i, j, k-1, 3)*uuzd &
414 & - sk(i, j, k-1, 2)*uuyd - sk(i, j, k-1, 1)*uuxd
415  wd(i, j-1, k, ivx) = wd(i, j-1, k, ivx) - sj(i, j-1, k, 3)*uuzd &
416 & - sj(i, j-1, k, 2)*uuyd - sj(i, j-1, k, 1)*uuxd
417  wd(i, j, k+1, ivx) = wd(i, j, k+1, ivx) + sk(i, j, k, 3)*uuzd + &
418 & sk(i, j, k, 2)*uuyd + sk(i, j, k, 1)*uuxd
419  wd(i, j+1, k, ivx) = wd(i, j+1, k, ivx) + sj(i, j, k, 3)*uuzd + &
420 & sj(i, j, k, 2)*uuyd + sj(i, j, k, 1)*uuxd
421  wd(i-1, j, k, ivx) = wd(i-1, j, k, ivx) - si(i-1, j, k, 3)*uuzd &
422 & - si(i-1, j, k, 2)*uuyd - si(i-1, j, k, 1)*uuxd
423  wd(i+1, j, k, ivx) = wd(i+1, j, k, ivx) + si(i, j, k, 3)*uuzd + &
424 & si(i, j, k, 2)*uuyd + si(i, j, k, 1)*uuxd
425  end do
426  end if
427  end subroutine sasource_fast_b
428 
429  subroutine sasource()
430 !
431 ! source terms.
432 ! determine the source term and its derivative w.r.t. nutilde
433 ! for all internal cells of the block.
434 ! remember that the sa field variable nutilde = w(i,j,k,itu1)
435  use blockpointers
436  use constants
437  use paramturb
438  use section
439  use inputphysics
440  use inputdiscretization, only : approxsa
441  use flowvarrefstate
442  implicit none
443 ! local parameters
444  real(kind=realtype), parameter :: f23=two*third
445 ! local variables.
446  integer(kind=inttype) :: i, j, k, nn, ii
447  real(kind=realtype) :: fv1, fv2, ft2
448  real(kind=realtype) :: ss, sst, nu, dist2inv, chi, chi2, chi3
449  real(kind=realtype) :: rr, gg, gg6, termfw, fwsa, term1, term2
450  real(kind=realtype) :: dfv1, dfv2, dft2, drr, dgg, dfw
451  real(kind=realtype) :: uux, uuy, uuz, vvx, vvy, vvz, wwx, wwy, wwz
452  real(kind=realtype) :: div2, fact, sxx, syy, szz, sxy, sxz, syz
453  real(kind=realtype) :: vortx, vorty, vortz
454  real(kind=realtype) :: omegax, omegay, omegaz
455  real(kind=realtype) :: strainmag2, strainprod, vortprod
456  real(kind=realtype), parameter :: xminn=1.e-10_realtype
457  intrinsic mod
458  intrinsic sqrt
459  intrinsic exp
460  intrinsic min
461  intrinsic max
462  real(kind=realtype) :: y1
463  real(kind=realtype) :: min1
464 ! set model constants
465  cv13 = rsacv1**3
466  kar2inv = one/rsak**2
467  cw36 = rsacw3**6
468  cb3inv = one/rsacb3
469 ! determine the non-dimensional wheel speed of this block.
470  omegax = timeref*sections(sectionid)%rotrate(1)
471  omegay = timeref*sections(sectionid)%rotrate(2)
472  omegaz = timeref*sections(sectionid)%rotrate(3)
473 ! create switches to production term depending on the variable that
474 ! should be used
475  if (turbprod .eq. katolaunder) then
476  print*, 'katolaunder production term not supported for sa'
477  stop
478  else
479 !$ad ii-loop
480  do ii=0,nx*ny*nz-1
481  i = mod(ii, nx) + 2
482  j = mod(ii/nx, ny) + 2
483  k = ii/(nx*ny) + 2
484 ! compute the gradient of u in the cell center. use is made
485 ! of the fact that the surrounding normals sum up to zero,
486 ! such that the cell i,j,k does not give a contribution.
487 ! the gradient is scaled by the factor 2*vol.
488  uux = w(i+1, j, k, ivx)*si(i, j, k, 1) - w(i-1, j, k, ivx)*si(i-&
489 & 1, j, k, 1) + w(i, j+1, k, ivx)*sj(i, j, k, 1) - w(i, j-1, k, &
490 & ivx)*sj(i, j-1, k, 1) + w(i, j, k+1, ivx)*sk(i, j, k, 1) - w(i&
491 & , j, k-1, ivx)*sk(i, j, k-1, 1)
492  uuy = w(i+1, j, k, ivx)*si(i, j, k, 2) - w(i-1, j, k, ivx)*si(i-&
493 & 1, j, k, 2) + w(i, j+1, k, ivx)*sj(i, j, k, 2) - w(i, j-1, k, &
494 & ivx)*sj(i, j-1, k, 2) + w(i, j, k+1, ivx)*sk(i, j, k, 2) - w(i&
495 & , j, k-1, ivx)*sk(i, j, k-1, 2)
496  uuz = w(i+1, j, k, ivx)*si(i, j, k, 3) - w(i-1, j, k, ivx)*si(i-&
497 & 1, j, k, 3) + w(i, j+1, k, ivx)*sj(i, j, k, 3) - w(i, j-1, k, &
498 & ivx)*sj(i, j-1, k, 3) + w(i, j, k+1, ivx)*sk(i, j, k, 3) - w(i&
499 & , j, k-1, ivx)*sk(i, j, k-1, 3)
500 ! idem for the gradient of v.
501  vvx = w(i+1, j, k, ivy)*si(i, j, k, 1) - w(i-1, j, k, ivy)*si(i-&
502 & 1, j, k, 1) + w(i, j+1, k, ivy)*sj(i, j, k, 1) - w(i, j-1, k, &
503 & ivy)*sj(i, j-1, k, 1) + w(i, j, k+1, ivy)*sk(i, j, k, 1) - w(i&
504 & , j, k-1, ivy)*sk(i, j, k-1, 1)
505  vvy = w(i+1, j, k, ivy)*si(i, j, k, 2) - w(i-1, j, k, ivy)*si(i-&
506 & 1, j, k, 2) + w(i, j+1, k, ivy)*sj(i, j, k, 2) - w(i, j-1, k, &
507 & ivy)*sj(i, j-1, k, 2) + w(i, j, k+1, ivy)*sk(i, j, k, 2) - w(i&
508 & , j, k-1, ivy)*sk(i, j, k-1, 2)
509  vvz = w(i+1, j, k, ivy)*si(i, j, k, 3) - w(i-1, j, k, ivy)*si(i-&
510 & 1, j, k, 3) + w(i, j+1, k, ivy)*sj(i, j, k, 3) - w(i, j-1, k, &
511 & ivy)*sj(i, j-1, k, 3) + w(i, j, k+1, ivy)*sk(i, j, k, 3) - w(i&
512 & , j, k-1, ivy)*sk(i, j, k-1, 3)
513 ! and for the gradient of w.
514  wwx = w(i+1, j, k, ivz)*si(i, j, k, 1) - w(i-1, j, k, ivz)*si(i-&
515 & 1, j, k, 1) + w(i, j+1, k, ivz)*sj(i, j, k, 1) - w(i, j-1, k, &
516 & ivz)*sj(i, j-1, k, 1) + w(i, j, k+1, ivz)*sk(i, j, k, 1) - w(i&
517 & , j, k-1, ivz)*sk(i, j, k-1, 1)
518  wwy = w(i+1, j, k, ivz)*si(i, j, k, 2) - w(i-1, j, k, ivz)*si(i-&
519 & 1, j, k, 2) + w(i, j+1, k, ivz)*sj(i, j, k, 2) - w(i, j-1, k, &
520 & ivz)*sj(i, j-1, k, 2) + w(i, j, k+1, ivz)*sk(i, j, k, 2) - w(i&
521 & , j, k-1, ivz)*sk(i, j, k-1, 2)
522  wwz = w(i+1, j, k, ivz)*si(i, j, k, 3) - w(i-1, j, k, ivz)*si(i-&
523 & 1, j, k, 3) + w(i, j+1, k, ivz)*sj(i, j, k, 3) - w(i, j-1, k, &
524 & ivz)*sj(i, j-1, k, 3) + w(i, j, k+1, ivz)*sk(i, j, k, 3) - w(i&
525 & , j, k-1, ivz)*sk(i, j, k-1, 3)
526 ! compute the components of the stress tensor.
527 ! the combination of the current scaling of the velocity
528 ! gradients (2*vol) and the definition of the stress tensor,
529 ! leads to the factor 1/(4*vol).
530  fact = fourth/vol(i, j, k)
531  if (turbprod .eq. strain) then
532  sxx = two*fact*uux
533  syy = two*fact*vvy
534  szz = two*fact*wwz
535  sxy = fact*(uuy+vvx)
536  sxz = fact*(uuz+wwx)
537  syz = fact*(vvz+wwy)
538 ! compute 2/3 * divergence of velocity squared
539  div2 = f23*(sxx+syy+szz)**2
540 ! compute strain production term
541  strainmag2 = two*(sxy**2+sxz**2+syz**2) + sxx**2 + syy**2 + &
542 & szz**2
543  strainprod = two*strainmag2 - div2
544  ss = sqrt(strainprod)
545  else if (turbprod .eq. vorticity) then
546 ! compute the three components of the vorticity vector.
547 ! substract the part coming from the rotating frame.
548  vortx = two*fact*(wwy-vvz) - two*omegax
549  vorty = two*fact*(uuz-wwx) - two*omegay
550  vortz = two*fact*(vvx-uuy) - two*omegaz
551 ! compute the vorticity production term
552  vortprod = vortx**2 + vorty**2 + vortz**2
553 ! first take the square root of the production term to
554 ! obtain the correct production term for spalart-allmaras.
555 ! we do this to avoid if statements.
556  ss = sqrt(vortprod)
557  end if
558 ! compute the laminar kinematic viscosity, the inverse of
559 ! wall distance squared, the ratio chi (ratio of nutilde
560 ! and nu) and the functions fv1 and fv2. the latter corrects
561 ! the production term near a viscous wall.
562  nu = rlv(i, j, k)/w(i, j, k, irho)
563  dist2inv = one/d2wall(i, j, k)**2
564  chi = w(i, j, k, itu1)/nu
565  chi2 = chi*chi
566  chi3 = chi*chi2
567  fv1 = chi3/(chi3+cv13)
568  fv2 = one - chi/(one+chi*fv1)
569 ! the function ft2, which is designed to keep a laminar
570 ! solution laminar. when running in fully turbulent mode
571 ! this function should be set to 0.0.
572  if (useft2sa) then
573  ft2 = rsact3*exp(-(rsact4*chi2))
574  else
575  ft2 = zero
576  end if
577 ! correct the production term to account for the influence
578 ! of the wall.
579  sst = ss + w(i, j, k, itu1)*fv2*kar2inv*dist2inv
580 ! add rotation term (userotationsa defined in inputparams.f90)
581  if (userotationsa) then
582  y1 = sqrt(two*strainmag2)
583  if (zero .gt. y1) then
584  min1 = y1
585  else
586  min1 = zero
587  end if
588  sst = sst + rsacrot*min1
589  end if
590  if (sst .lt. xminn) then
591  sst = xminn
592  else
593  sst = sst
594  end if
595 ! compute the function fw. the argument rr is cut off at 10
596 ! to avoid numerical problems. this is ok, because the
597 ! asymptotical value of fw is then already reached.
598  rr = w(i, j, k, itu1)*kar2inv*dist2inv/sst
599  if (rr .gt. 10.0_realtype) then
600  rr = 10.0_realtype
601  else
602  rr = rr
603  end if
604  gg = rr + rsacw2*(rr**6-rr)
605  gg6 = gg**6
606  termfw = ((one+cw36)/(gg6+cw36))**sixth
607  fwsa = gg*termfw
608 ! compute the source term; some terms are saved for the
609 ! linearization. the source term is stored in dvt.
610  if (approxsa) then
611  term1 = zero
612  else
613  term1 = rsacb1*(one-ft2)*ss
614  end if
615  term2 = dist2inv*(kar2inv*rsacb1*((one-ft2)*fv2+ft2)-rsacw1*fwsa&
616 & )
617  scratch(i, j, k, idvt) = (term1+term2*w(i, j, k, itu1))*w(i, j, &
618 & k, itu1)
619  end do
620  end if
621  end subroutine sasource
622 
623 ! differentiation of saviscous in reverse (adjoint) mode (with options noisize i4 dr8 r8):
624 ! gradient of useful results: *w *rlv *scratch
625 ! with respect to varying inputs: *w *rlv *scratch
626 ! rw status of diff variables: *w:incr *rlv:incr *scratch:in-out
627 ! plus diff mem management of: w:in rlv:in scratch:in
628  subroutine saviscous_fast_b()
629 !
630 ! viscous term.
631 ! determine the viscous contribution to the residual
632 ! for all internal cells of the block.
633  use blockpointers
634  use paramturb
635  implicit none
636 ! local variables.
637  integer(kind=inttype) :: i, j, k, nn, ii
638  real(kind=realtype) :: nu
639  real(kind=realtype) :: nud
640  real(kind=realtype) :: fv1, fv2, ft2
641  real(kind=realtype) :: voli, volmi, volpi, xm, ym, zm, xp, yp, zp
642  real(kind=realtype) :: xa, ya, za, ttm, ttp, cnud, cam, cap
643  real(kind=realtype) :: cnudd, camd, capd
644  real(kind=realtype) :: nutm, nutp, num, nup, cdm, cdp
645  real(kind=realtype) :: nutmd, nutpd, numd, nupd, cdmd, cdpd
646  real(kind=realtype) :: c1m, c1p, c10, b1, c1, d1, qs
647  real(kind=realtype) :: c1md, c1pd, c10d
648  intrinsic mod
649  intrinsic max
650  real(kind=realtype) :: temp
651  real(kind=realtype) :: temp0
652  real(kind=realtype) :: tempd
653  real(kind=realtype) :: tempd0
654  integer :: branch
655 ! set model constants
656  cb3inv = one/rsacb3
657 !$bwd-of ii-loop
658  do ii=0,nx*ny*nz-1
659  i = mod(ii, nx) + 2
660  j = mod(ii/nx, ny) + 2
661  k = ii/(nx*ny) + 2
662 ! compute the metrics in xi-direction, i.e. along the
663 ! line i = constant.
664  voli = one/vol(i, j, k)
665  volmi = two/(vol(i, j, k)+vol(i-1, j, k))
666  volpi = two/(vol(i, j, k)+vol(i+1, j, k))
667  xm = si(i-1, j, k, 1)*volmi
668  ym = si(i-1, j, k, 2)*volmi
669  zm = si(i-1, j, k, 3)*volmi
670  xp = si(i, j, k, 1)*volpi
671  yp = si(i, j, k, 2)*volpi
672  zp = si(i, j, k, 3)*volpi
673  xa = half*(si(i, j, k, 1)+si(i-1, j, k, 1))*voli
674  ya = half*(si(i, j, k, 2)+si(i-1, j, k, 2))*voli
675  za = half*(si(i, j, k, 3)+si(i-1, j, k, 3))*voli
676  ttm = xm*xa + ym*ya + zm*za
677  ttp = xp*xa + yp*ya + zp*za
678 ! computation of the viscous terms in xi-direction; note
679 ! that cross-derivatives are neglected, i.e. the mesh is
680 ! assumed to be orthogonal.
681 ! furthermore, the grad(nu)**2 has been rewritten as
682 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
683 ! the second derivative in xi-direction is constructed as
684 ! the central difference of the first order derivatives, i.e.
685 ! d^2/dxi^2 = d/dxi (d/dxi i+1/2 - d/dxi i-1/2).
686 ! in this way the metric can be taken into account.
687 ! compute the diffusion coefficients multiplying the nodes
688 ! i+1, i and i-1 in the second derivative. make sure that
689 ! these coefficients are nonnegative.
690  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
691  cam = ttm*cnud
692  cap = ttp*cnud
693  nutm = half*(w(i-1, j, k, itu1)+w(i, j, k, itu1))
694  nutp = half*(w(i+1, j, k, itu1)+w(i, j, k, itu1))
695  nu = rlv(i, j, k)/w(i, j, k, irho)
696  num = half*(rlv(i-1, j, k)/w(i-1, j, k, irho)+nu)
697  nup = half*(rlv(i+1, j, k)/w(i+1, j, k, irho)+nu)
698  cdm = (num+(one+rsacb2)*nutm)*ttm*cb3inv
699  cdp = (nup+(one+rsacb2)*nutp)*ttp*cb3inv
700  if (cdm + cam .lt. zero) then
701  c1m = zero
702 myintptr = myintptr + 1
703  myintstack(myintptr) = 0
704  else
705  c1m = cdm + cam
706 myintptr = myintptr + 1
707  myintstack(myintptr) = 1
708  end if
709  if (cdp + cap .lt. zero) then
710  c1p = zero
711 myintptr = myintptr + 1
712  myintstack(myintptr) = 0
713  else
714  c1p = cdp + cap
715 myintptr = myintptr + 1
716  myintstack(myintptr) = 1
717  end if
718  c10 = c1m + c1p
719 ! update the residual for this cell and store the possible
720 ! coefficients for the matrix in b1, c1 and d1.
721  c10d = -(w(i, j, k, itu1)*scratchd(i, j, k, idvt))
722  c1md = w(i-1, j, k, itu1)*scratchd(i, j, k, idvt) + c10d
723  wd(i-1, j, k, itu1) = wd(i-1, j, k, itu1) + c1m*scratchd(i, j, k, &
724 & idvt)
725  c1pd = w(i+1, j, k, itu1)*scratchd(i, j, k, idvt) + c10d
726  wd(i+1, j, k, itu1) = wd(i+1, j, k, itu1) + c1p*scratchd(i, j, k, &
727 & idvt)
728  wd(i, j, k, itu1) = wd(i, j, k, itu1) - c10*scratchd(i, j, k, idvt&
729 & )
730 branch = myintstack(myintptr)
731  myintptr = myintptr - 1
732  if (branch .eq. 0) then
733  cdpd = 0.0_8
734  capd = 0.0_8
735  else
736  cdpd = c1pd
737  capd = c1pd
738  end if
739 branch = myintstack(myintptr)
740  myintptr = myintptr - 1
741  if (branch .eq. 0) then
742  cdmd = 0.0_8
743  camd = 0.0_8
744  else
745  cdmd = c1md
746  camd = c1md
747  end if
748  cnudd = ttp*capd + ttm*camd
749  tempd = ttp*cb3inv*cdpd
750  nupd = tempd
751  nutpd = (one+rsacb2)*tempd
752  tempd = ttm*cb3inv*cdmd
753  numd = tempd
754  nutmd = (one+rsacb2)*tempd
755  temp0 = w(i+1, j, k, irho)
756  tempd0 = half*nupd/temp0
757  nud = half*nupd + half*numd
758  rlvd(i+1, j, k) = rlvd(i+1, j, k) + tempd0
759  wd(i+1, j, k, irho) = wd(i+1, j, k, irho) - rlv(i+1, j, k)*tempd0/&
760 & temp0
761  temp0 = w(i-1, j, k, irho)
762  tempd0 = half*numd/temp0
763  rlvd(i-1, j, k) = rlvd(i-1, j, k) + tempd0
764  wd(i-1, j, k, irho) = wd(i-1, j, k, irho) - rlv(i-1, j, k)*tempd0/&
765 & temp0
766  temp0 = w(i, j, k, irho)
767  rlvd(i, j, k) = rlvd(i, j, k) + nud/temp0
768  wd(i, j, k, irho) = wd(i, j, k, irho) - rlv(i, j, k)*nud/temp0**2
769  wd(i+1, j, k, itu1) = wd(i+1, j, k, itu1) + half*nutpd
770  wd(i, j, k, itu1) = wd(i, j, k, itu1) + half*nutpd + half*nutmd - &
771 & rsacb2*cb3inv*cnudd
772  wd(i-1, j, k, itu1) = wd(i-1, j, k, itu1) + half*nutmd
773  end do
774 !$bwd-of ii-loop
775  do ii=0,nx*ny*nz-1
776  i = mod(ii, nx) + 2
777  j = mod(ii/nx, ny) + 2
778  k = ii/(nx*ny) + 2
779 ! compute the metrics in eta-direction, i.e. along the
780 ! line j = constant.
781  voli = one/vol(i, j, k)
782  volmi = two/(vol(i, j, k)+vol(i, j-1, k))
783  volpi = two/(vol(i, j, k)+vol(i, j+1, k))
784  xm = sj(i, j-1, k, 1)*volmi
785  ym = sj(i, j-1, k, 2)*volmi
786  zm = sj(i, j-1, k, 3)*volmi
787  xp = sj(i, j, k, 1)*volpi
788  yp = sj(i, j, k, 2)*volpi
789  zp = sj(i, j, k, 3)*volpi
790  xa = half*(sj(i, j, k, 1)+sj(i, j-1, k, 1))*voli
791  ya = half*(sj(i, j, k, 2)+sj(i, j-1, k, 2))*voli
792  za = half*(sj(i, j, k, 3)+sj(i, j-1, k, 3))*voli
793  ttm = xm*xa + ym*ya + zm*za
794  ttp = xp*xa + yp*ya + zp*za
795 ! computation of the viscous terms in eta-direction; note
796 ! that cross-derivatives are neglected, i.e. the mesh is
797 ! assumed to be orthogonal.
798 ! furthermore, the grad(nu)**2 has been rewritten as
799 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
800 ! the second derivative in eta-direction is constructed as
801 ! the central difference of the first order derivatives, i.e.
802 ! d^2/deta^2 = d/deta (d/deta j+1/2 - d/deta j-1/2).
803 ! in this way the metric can be taken into account.
804 ! compute the diffusion coefficients multiplying the nodes
805 ! j+1, j and j-1 in the second derivative. make sure that
806 ! these coefficients are nonnegative.
807  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
808  cam = ttm*cnud
809  cap = ttp*cnud
810  nutm = half*(w(i, j-1, k, itu1)+w(i, j, k, itu1))
811  nutp = half*(w(i, j+1, k, itu1)+w(i, j, k, itu1))
812  nu = rlv(i, j, k)/w(i, j, k, irho)
813  num = half*(rlv(i, j-1, k)/w(i, j-1, k, irho)+nu)
814  nup = half*(rlv(i, j+1, k)/w(i, j+1, k, irho)+nu)
815  cdm = (num+(one+rsacb2)*nutm)*ttm*cb3inv
816  cdp = (nup+(one+rsacb2)*nutp)*ttp*cb3inv
817  if (cdm + cam .lt. zero) then
818  c1m = zero
819 myintptr = myintptr + 1
820  myintstack(myintptr) = 0
821  else
822  c1m = cdm + cam
823 myintptr = myintptr + 1
824  myintstack(myintptr) = 1
825  end if
826  if (cdp + cap .lt. zero) then
827  c1p = zero
828 myintptr = myintptr + 1
829  myintstack(myintptr) = 0
830  else
831  c1p = cdp + cap
832 myintptr = myintptr + 1
833  myintstack(myintptr) = 1
834  end if
835  c10 = c1m + c1p
836 ! update the residual for this cell and store the possible
837 ! coefficients for the matrix in b1, c1 and d1.
838  c10d = -(w(i, j, k, itu1)*scratchd(i, j, k, idvt))
839  c1md = w(i, j-1, k, itu1)*scratchd(i, j, k, idvt) + c10d
840  wd(i, j-1, k, itu1) = wd(i, j-1, k, itu1) + c1m*scratchd(i, j, k, &
841 & idvt)
842  c1pd = w(i, j+1, k, itu1)*scratchd(i, j, k, idvt) + c10d
843  wd(i, j+1, k, itu1) = wd(i, j+1, k, itu1) + c1p*scratchd(i, j, k, &
844 & idvt)
845  wd(i, j, k, itu1) = wd(i, j, k, itu1) - c10*scratchd(i, j, k, idvt&
846 & )
847 branch = myintstack(myintptr)
848  myintptr = myintptr - 1
849  if (branch .eq. 0) then
850  cdpd = 0.0_8
851  capd = 0.0_8
852  else
853  cdpd = c1pd
854  capd = c1pd
855  end if
856 branch = myintstack(myintptr)
857  myintptr = myintptr - 1
858  if (branch .eq. 0) then
859  cdmd = 0.0_8
860  camd = 0.0_8
861  else
862  cdmd = c1md
863  camd = c1md
864  end if
865  cnudd = ttp*capd + ttm*camd
866  tempd = ttp*cb3inv*cdpd
867  nupd = tempd
868  nutpd = (one+rsacb2)*tempd
869  tempd = ttm*cb3inv*cdmd
870  numd = tempd
871  nutmd = (one+rsacb2)*tempd
872  temp0 = w(i, j+1, k, irho)
873  tempd0 = half*nupd/temp0
874  nud = half*nupd + half*numd
875  rlvd(i, j+1, k) = rlvd(i, j+1, k) + tempd0
876  wd(i, j+1, k, irho) = wd(i, j+1, k, irho) - rlv(i, j+1, k)*tempd0/&
877 & temp0
878  temp0 = w(i, j-1, k, irho)
879  tempd0 = half*numd/temp0
880  rlvd(i, j-1, k) = rlvd(i, j-1, k) + tempd0
881  wd(i, j-1, k, irho) = wd(i, j-1, k, irho) - rlv(i, j-1, k)*tempd0/&
882 & temp0
883  temp0 = w(i, j, k, irho)
884  rlvd(i, j, k) = rlvd(i, j, k) + nud/temp0
885  wd(i, j, k, irho) = wd(i, j, k, irho) - rlv(i, j, k)*nud/temp0**2
886  wd(i, j+1, k, itu1) = wd(i, j+1, k, itu1) + half*nutpd
887  wd(i, j, k, itu1) = wd(i, j, k, itu1) + half*nutpd + half*nutmd - &
888 & rsacb2*cb3inv*cnudd
889  wd(i, j-1, k, itu1) = wd(i, j-1, k, itu1) + half*nutmd
890  end do
891 !$bwd-of ii-loop
892  do ii=0,nx*ny*nz-1
893  i = mod(ii, nx) + 2
894  j = mod(ii/nx, ny) + 2
895  k = ii/(nx*ny) + 2
896 ! compute the metrics in zeta-direction, i.e. along the
897 ! line k = constant.
898  voli = one/vol(i, j, k)
899  volmi = two/(vol(i, j, k)+vol(i, j, k-1))
900  volpi = two/(vol(i, j, k)+vol(i, j, k+1))
901  xm = sk(i, j, k-1, 1)*volmi
902  ym = sk(i, j, k-1, 2)*volmi
903  zm = sk(i, j, k-1, 3)*volmi
904  xp = sk(i, j, k, 1)*volpi
905  yp = sk(i, j, k, 2)*volpi
906  zp = sk(i, j, k, 3)*volpi
907  xa = half*(sk(i, j, k, 1)+sk(i, j, k-1, 1))*voli
908  ya = half*(sk(i, j, k, 2)+sk(i, j, k-1, 2))*voli
909  za = half*(sk(i, j, k, 3)+sk(i, j, k-1, 3))*voli
910  ttm = xm*xa + ym*ya + zm*za
911  ttp = xp*xa + yp*ya + zp*za
912 ! ttm and ttp ~ 1/deltax^2
913 ! computation of the viscous terms in zeta-direction; note
914 ! that cross-derivatives are neglected, i.e. the mesh is
915 ! assumed to be orthogonal.
916 ! furthermore, the grad(nu)**2 has been rewritten as
917 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
918 ! the second derivative in zeta-direction is constructed as
919 ! the central difference of the first order derivatives, i.e.
920 ! d^2/dzeta^2 = d/dzeta (d/dzeta k+1/2 - d/dzeta k-1/2).
921 ! in this way the metric can be taken into account.
922 ! compute the diffusion coefficients multiplying the nodes
923 ! k+1, k and k-1 in the second derivative. make sure that
924 ! these coefficients are nonnegative.
925  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
926  cam = ttm*cnud
927  cap = ttp*cnud
928 ! compute nutilde at the faces
929  nutm = half*(w(i, j, k-1, itu1)+w(i, j, k, itu1))
930  nutp = half*(w(i, j, k+1, itu1)+w(i, j, k, itu1))
931 ! compute nu at the faces
932  nu = rlv(i, j, k)/w(i, j, k, irho)
933  num = half*(rlv(i, j, k-1)/w(i, j, k-1, irho)+nu)
934  nup = half*(rlv(i, j, k+1)/w(i, j, k+1, irho)+nu)
935  cdm = (num+(one+rsacb2)*nutm)*ttm*cb3inv
936  cdp = (nup+(one+rsacb2)*nutp)*ttp*cb3inv
937  if (cdm + cam .lt. zero) then
938  c1m = zero
939 myintptr = myintptr + 1
940  myintstack(myintptr) = 0
941  else
942  c1m = cdm + cam
943 myintptr = myintptr + 1
944  myintstack(myintptr) = 1
945  end if
946  if (cdp + cap .lt. zero) then
947  c1p = zero
948 myintptr = myintptr + 1
949  myintstack(myintptr) = 0
950  else
951  c1p = cdp + cap
952 myintptr = myintptr + 1
953  myintstack(myintptr) = 1
954  end if
955  c10 = c1m + c1p
956 ! update the residual for this cell and store the possible
957 ! coefficients for the matrix in b1, c1 and d1.
958  c10d = -(w(i, j, k, itu1)*scratchd(i, j, k, idvt))
959  c1md = w(i, j, k-1, itu1)*scratchd(i, j, k, idvt) + c10d
960  wd(i, j, k-1, itu1) = wd(i, j, k-1, itu1) + c1m*scratchd(i, j, k, &
961 & idvt)
962  c1pd = w(i, j, k+1, itu1)*scratchd(i, j, k, idvt) + c10d
963  wd(i, j, k+1, itu1) = wd(i, j, k+1, itu1) + c1p*scratchd(i, j, k, &
964 & idvt)
965  wd(i, j, k, itu1) = wd(i, j, k, itu1) - c10*scratchd(i, j, k, idvt&
966 & )
967 branch = myintstack(myintptr)
968  myintptr = myintptr - 1
969  if (branch .eq. 0) then
970  cdpd = 0.0_8
971  capd = 0.0_8
972  else
973  cdpd = c1pd
974  capd = c1pd
975  end if
976 branch = myintstack(myintptr)
977  myintptr = myintptr - 1
978  if (branch .eq. 0) then
979  cdmd = 0.0_8
980  camd = 0.0_8
981  else
982  cdmd = c1md
983  camd = c1md
984  end if
985  cnudd = ttp*capd + ttm*camd
986  tempd = ttp*cb3inv*cdpd
987  nupd = tempd
988  nutpd = (one+rsacb2)*tempd
989  tempd = ttm*cb3inv*cdmd
990  numd = tempd
991  nutmd = (one+rsacb2)*tempd
992  temp0 = w(i, j, k+1, irho)
993  tempd0 = half*nupd/temp0
994  nud = half*nupd + half*numd
995  rlvd(i, j, k+1) = rlvd(i, j, k+1) + tempd0
996  wd(i, j, k+1, irho) = wd(i, j, k+1, irho) - rlv(i, j, k+1)*tempd0/&
997 & temp0
998  temp = w(i, j, k-1, irho)
999  tempd = half*numd/temp
1000  rlvd(i, j, k-1) = rlvd(i, j, k-1) + tempd
1001  wd(i, j, k-1, irho) = wd(i, j, k-1, irho) - rlv(i, j, k-1)*tempd/&
1002 & temp
1003  temp = w(i, j, k, irho)
1004  rlvd(i, j, k) = rlvd(i, j, k) + nud/temp
1005  wd(i, j, k, irho) = wd(i, j, k, irho) - rlv(i, j, k)*nud/temp**2
1006  wd(i, j, k+1, itu1) = wd(i, j, k+1, itu1) + half*nutpd
1007  wd(i, j, k, itu1) = wd(i, j, k, itu1) + half*nutpd + half*nutmd - &
1008 & rsacb2*cb3inv*cnudd
1009  wd(i, j, k-1, itu1) = wd(i, j, k-1, itu1) + half*nutmd
1010  end do
1011  end subroutine saviscous_fast_b
1012 
1013  subroutine saviscous()
1014 !
1015 ! viscous term.
1016 ! determine the viscous contribution to the residual
1017 ! for all internal cells of the block.
1018  use blockpointers
1019  use paramturb
1020  implicit none
1021 ! local variables.
1022  integer(kind=inttype) :: i, j, k, nn, ii
1023  real(kind=realtype) :: nu
1024  real(kind=realtype) :: fv1, fv2, ft2
1025  real(kind=realtype) :: voli, volmi, volpi, xm, ym, zm, xp, yp, zp
1026  real(kind=realtype) :: xa, ya, za, ttm, ttp, cnud, cam, cap
1027  real(kind=realtype) :: nutm, nutp, num, nup, cdm, cdp
1028  real(kind=realtype) :: c1m, c1p, c10, b1, c1, d1, qs
1029  intrinsic mod
1030  intrinsic max
1031 ! set model constants
1032  cv13 = rsacv1**3
1033  kar2inv = one/rsak**2
1034  cw36 = rsacw3**6
1035  cb3inv = one/rsacb3
1036 !$ad ii-loop
1037 !
1038 ! viscous terms in k-direction.
1039 !
1040  do ii=0,nx*ny*nz-1
1041  i = mod(ii, nx) + 2
1042  j = mod(ii/nx, ny) + 2
1043  k = ii/(nx*ny) + 2
1044 ! compute the metrics in zeta-direction, i.e. along the
1045 ! line k = constant.
1046  voli = one/vol(i, j, k)
1047  volmi = two/(vol(i, j, k)+vol(i, j, k-1))
1048  volpi = two/(vol(i, j, k)+vol(i, j, k+1))
1049  xm = sk(i, j, k-1, 1)*volmi
1050  ym = sk(i, j, k-1, 2)*volmi
1051  zm = sk(i, j, k-1, 3)*volmi
1052  xp = sk(i, j, k, 1)*volpi
1053  yp = sk(i, j, k, 2)*volpi
1054  zp = sk(i, j, k, 3)*volpi
1055  xa = half*(sk(i, j, k, 1)+sk(i, j, k-1, 1))*voli
1056  ya = half*(sk(i, j, k, 2)+sk(i, j, k-1, 2))*voli
1057  za = half*(sk(i, j, k, 3)+sk(i, j, k-1, 3))*voli
1058  ttm = xm*xa + ym*ya + zm*za
1059  ttp = xp*xa + yp*ya + zp*za
1060 ! ttm and ttp ~ 1/deltax^2
1061 ! computation of the viscous terms in zeta-direction; note
1062 ! that cross-derivatives are neglected, i.e. the mesh is
1063 ! assumed to be orthogonal.
1064 ! furthermore, the grad(nu)**2 has been rewritten as
1065 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
1066 ! the second derivative in zeta-direction is constructed as
1067 ! the central difference of the first order derivatives, i.e.
1068 ! d^2/dzeta^2 = d/dzeta (d/dzeta k+1/2 - d/dzeta k-1/2).
1069 ! in this way the metric can be taken into account.
1070 ! compute the diffusion coefficients multiplying the nodes
1071 ! k+1, k and k-1 in the second derivative. make sure that
1072 ! these coefficients are nonnegative.
1073  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
1074  cam = ttm*cnud
1075  cap = ttp*cnud
1076 ! compute nutilde at the faces
1077  nutm = half*(w(i, j, k-1, itu1)+w(i, j, k, itu1))
1078  nutp = half*(w(i, j, k+1, itu1)+w(i, j, k, itu1))
1079 ! compute nu at the faces
1080  nu = rlv(i, j, k)/w(i, j, k, irho)
1081  num = half*(rlv(i, j, k-1)/w(i, j, k-1, irho)+nu)
1082  nup = half*(rlv(i, j, k+1)/w(i, j, k+1, irho)+nu)
1083  cdm = (num+(one+rsacb2)*nutm)*ttm*cb3inv
1084  cdp = (nup+(one+rsacb2)*nutp)*ttp*cb3inv
1085  if (cdm + cam .lt. zero) then
1086  c1m = zero
1087  else
1088  c1m = cdm + cam
1089  end if
1090  if (cdp + cap .lt. zero) then
1091  c1p = zero
1092  else
1093  c1p = cdp + cap
1094  end if
1095  c10 = c1m + c1p
1096 ! update the residual for this cell and store the possible
1097 ! coefficients for the matrix in b1, c1 and d1.
1098  scratch(i, j, k, idvt) = scratch(i, j, k, idvt) + c1m*w(i, j, k-1&
1099 & , itu1) - c10*w(i, j, k, itu1) + c1p*w(i, j, k+1, itu1)
1100  end do
1101 !$ad ii-loop
1102 !
1103 ! viscous terms in j-direction.
1104 !
1105  do ii=0,nx*ny*nz-1
1106  i = mod(ii, nx) + 2
1107  j = mod(ii/nx, ny) + 2
1108  k = ii/(nx*ny) + 2
1109 ! compute the metrics in eta-direction, i.e. along the
1110 ! line j = constant.
1111  voli = one/vol(i, j, k)
1112  volmi = two/(vol(i, j, k)+vol(i, j-1, k))
1113  volpi = two/(vol(i, j, k)+vol(i, j+1, k))
1114  xm = sj(i, j-1, k, 1)*volmi
1115  ym = sj(i, j-1, k, 2)*volmi
1116  zm = sj(i, j-1, k, 3)*volmi
1117  xp = sj(i, j, k, 1)*volpi
1118  yp = sj(i, j, k, 2)*volpi
1119  zp = sj(i, j, k, 3)*volpi
1120  xa = half*(sj(i, j, k, 1)+sj(i, j-1, k, 1))*voli
1121  ya = half*(sj(i, j, k, 2)+sj(i, j-1, k, 2))*voli
1122  za = half*(sj(i, j, k, 3)+sj(i, j-1, k, 3))*voli
1123  ttm = xm*xa + ym*ya + zm*za
1124  ttp = xp*xa + yp*ya + zp*za
1125 ! computation of the viscous terms in eta-direction; note
1126 ! that cross-derivatives are neglected, i.e. the mesh is
1127 ! assumed to be orthogonal.
1128 ! furthermore, the grad(nu)**2 has been rewritten as
1129 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
1130 ! the second derivative in eta-direction is constructed as
1131 ! the central difference of the first order derivatives, i.e.
1132 ! d^2/deta^2 = d/deta (d/deta j+1/2 - d/deta j-1/2).
1133 ! in this way the metric can be taken into account.
1134 ! compute the diffusion coefficients multiplying the nodes
1135 ! j+1, j and j-1 in the second derivative. make sure that
1136 ! these coefficients are nonnegative.
1137  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
1138  cam = ttm*cnud
1139  cap = ttp*cnud
1140  nutm = half*(w(i, j-1, k, itu1)+w(i, j, k, itu1))
1141  nutp = half*(w(i, j+1, k, itu1)+w(i, j, k, itu1))
1142  nu = rlv(i, j, k)/w(i, j, k, irho)
1143  num = half*(rlv(i, j-1, k)/w(i, j-1, k, irho)+nu)
1144  nup = half*(rlv(i, j+1, k)/w(i, j+1, k, irho)+nu)
1145  cdm = (num+(one+rsacb2)*nutm)*ttm*cb3inv
1146  cdp = (nup+(one+rsacb2)*nutp)*ttp*cb3inv
1147  if (cdm + cam .lt. zero) then
1148  c1m = zero
1149  else
1150  c1m = cdm + cam
1151  end if
1152  if (cdp + cap .lt. zero) then
1153  c1p = zero
1154  else
1155  c1p = cdp + cap
1156  end if
1157  c10 = c1m + c1p
1158 ! update the residual for this cell and store the possible
1159 ! coefficients for the matrix in b1, c1 and d1.
1160  scratch(i, j, k, idvt) = scratch(i, j, k, idvt) + c1m*w(i, j-1, k&
1161 & , itu1) - c10*w(i, j, k, itu1) + c1p*w(i, j+1, k, itu1)
1162  end do
1163 !$ad ii-loop
1164 !
1165 ! viscous terms in i-direction.
1166 !
1167  do ii=0,nx*ny*nz-1
1168  i = mod(ii, nx) + 2
1169  j = mod(ii/nx, ny) + 2
1170  k = ii/(nx*ny) + 2
1171 ! compute the metrics in xi-direction, i.e. along the
1172 ! line i = constant.
1173  voli = one/vol(i, j, k)
1174  volmi = two/(vol(i, j, k)+vol(i-1, j, k))
1175  volpi = two/(vol(i, j, k)+vol(i+1, j, k))
1176  xm = si(i-1, j, k, 1)*volmi
1177  ym = si(i-1, j, k, 2)*volmi
1178  zm = si(i-1, j, k, 3)*volmi
1179  xp = si(i, j, k, 1)*volpi
1180  yp = si(i, j, k, 2)*volpi
1181  zp = si(i, j, k, 3)*volpi
1182  xa = half*(si(i, j, k, 1)+si(i-1, j, k, 1))*voli
1183  ya = half*(si(i, j, k, 2)+si(i-1, j, k, 2))*voli
1184  za = half*(si(i, j, k, 3)+si(i-1, j, k, 3))*voli
1185  ttm = xm*xa + ym*ya + zm*za
1186  ttp = xp*xa + yp*ya + zp*za
1187 ! computation of the viscous terms in xi-direction; note
1188 ! that cross-derivatives are neglected, i.e. the mesh is
1189 ! assumed to be orthogonal.
1190 ! furthermore, the grad(nu)**2 has been rewritten as
1191 ! div(nu grad(nu)) - nu div(grad nu) to enhance stability.
1192 ! the second derivative in xi-direction is constructed as
1193 ! the central difference of the first order derivatives, i.e.
1194 ! d^2/dxi^2 = d/dxi (d/dxi i+1/2 - d/dxi i-1/2).
1195 ! in this way the metric can be taken into account.
1196 ! compute the diffusion coefficients multiplying the nodes
1197 ! i+1, i and i-1 in the second derivative. make sure that
1198 ! these coefficients are nonnegative.
1199  cnud = -(rsacb2*w(i, j, k, itu1)*cb3inv)
1200  cam = ttm*cnud
1201  cap = ttp*cnud
1202  nutm = half*(w(i-1, j, k, itu1)+w(i, j, k, itu1))
1203  nutp = half*(w(i+1, j, k, itu1)+w(i, j, k, itu1))
1204  nu = rlv(i, j, k)/w(i, j, k, irho)
1205  num = half*(rlv(i-1, j, k)/w(i-1, j, k, irho)+nu)
1206  nup = half*(rlv(i+1, j, k)/w(i+1, j, k, irho)+nu)
1207  cdm = (num+(one+rsacb2)*nutm)*ttm*cb3inv
1208  cdp = (nup+(one+rsacb2)*nutp)*ttp*cb3inv
1209  if (cdm + cam .lt. zero) then
1210  c1m = zero
1211  else
1212  c1m = cdm + cam
1213  end if
1214  if (cdp + cap .lt. zero) then
1215  c1p = zero
1216  else
1217  c1p = cdp + cap
1218  end if
1219  c10 = c1m + c1p
1220 ! update the residual for this cell and store the possible
1221 ! coefficients for the matrix in b1, c1 and d1.
1222  scratch(i, j, k, idvt) = scratch(i, j, k, idvt) + c1m*w(i-1, j, k&
1223 & , itu1) - c10*w(i, j, k, itu1) + c1p*w(i+1, j, k, itu1)
1224  end do
1225  end subroutine saviscous
1226 
1227 ! differentiation of saresscale in reverse (adjoint) mode (with options noisize i4 dr8 r8):
1228 ! gradient of useful results: *dw
1229 ! with respect to varying inputs: *dw *scratch
1230 ! rw status of diff variables: *dw:in-out *scratch:out
1231 ! plus diff mem management of: dw:in scratch:in
1232  subroutine saresscale_fast_b()
1233 !
1234 ! multiply the residual by the volume and store this in dw; this
1235 ! * is done for monitoring reasons only. the multiplication with the
1236 ! * volume is present to be consistent with the flow residuals; also
1237 ! the negative value is taken, again to be consistent with the
1238 ! * flow equations. also multiply by iblank so that no updates occur
1239 ! in holes or the overset boundary.
1240  use blockpointers
1241  implicit none
1242 ! local variables
1243  integer(kind=inttype) :: i, j, k, ii
1244  real(kind=realtype) :: rblank
1245  intrinsic mod
1246  intrinsic real
1247  intrinsic max
1248  real(realtype) :: x1
1249  if (associated(scratchd)) scratchd = 0.0_8
1250 !$bwd-of ii-loop
1251  do ii=0,nx*ny*nz-1
1252  i = mod(ii, nx) + 2
1253  j = mod(ii/nx, ny) + 2
1254  k = ii/(nx*ny) + 2
1255  x1 = real(iblank(i, j, k), realtype)
1256  if (x1 .lt. zero) then
1257  rblank = zero
1258  else
1259  rblank = x1
1260  end if
1261  scratchd(i, j, k, idvt) = scratchd(i, j, k, idvt) - volref(i, j, k&
1262 & )*rblank*dwd(i, j, k, itu1)
1263  dwd(i, j, k, itu1) = 0.0_8
1264  end do
1265  end subroutine saresscale_fast_b
1266 
1267  subroutine saresscale()
1268 !
1269 ! multiply the residual by the volume and store this in dw; this
1270 ! * is done for monitoring reasons only. the multiplication with the
1271 ! * volume is present to be consistent with the flow residuals; also
1272 ! the negative value is taken, again to be consistent with the
1273 ! * flow equations. also multiply by iblank so that no updates occur
1274 ! in holes or the overset boundary.
1275  use blockpointers
1276  implicit none
1277 ! local variables
1278  integer(kind=inttype) :: i, j, k, ii
1279  real(kind=realtype) :: rblank
1280  intrinsic mod
1281  intrinsic real
1282  intrinsic max
1283  real(realtype) :: x1
1284 !$ad ii-loop
1285  do ii=0,nx*ny*nz-1
1286  i = mod(ii, nx) + 2
1287  j = mod(ii/nx, ny) + 2
1288  k = ii/(nx*ny) + 2
1289  x1 = real(iblank(i, j, k), realtype)
1290  if (x1 .lt. zero) then
1291  rblank = zero
1292  else
1293  rblank = x1
1294  end if
1295  dw(i, j, k, itu1) = -(volref(i, j, k)*scratch(i, j, k, idvt)*&
1296 & rblank)
1297  end do
1298  end subroutine saresscale
1299 
1300 end module sa_fast_b
1301 
real(kind=realtype), dimension(:, :, :, :), pointer wd
integer(kind=inttype) nx
integer(kind=inttype) ny
real(kind=realtype), dimension(:, :, :, :), pointer w
real(kind=realtype), dimension(:, :, :, :), pointer scratch
real(kind=realtype), dimension(:, :, :), pointer d2wall
integer(kind=inttype), dimension(:, :, :), pointer iblank
real(kind=realtype), dimension(:, :, :), pointer rlv
real(kind=realtype), dimension(:, :, :, :), pointer si
real(kind=realtype), dimension(:, :, :), pointer volref
real(kind=realtype), dimension(:, :, :, :), pointer sj
integer(kind=inttype) sectionid
real(kind=realtype), dimension(:, :, :, :), pointer scratchd
real(kind=realtype), dimension(:, :, :, :), pointer dw
real(kind=realtype), dimension(:, :, :, :), pointer sk
real(kind=realtype), dimension(:, :, :), pointer rlvd
real(kind=realtype), dimension(:, :, :), pointer vol
integer(kind=inttype) nz
real(kind=realtype), dimension(:, :, :, :), pointer dwd
integer(kind=inttype), parameter strain
Definition: constants.F90:137
real(kind=realtype), parameter zero
Definition: constants.F90:71
integer, parameter idvt
Definition: constants.F90:51
real(kind=realtype), parameter third
Definition: constants.F90:81
integer, parameter itu1
Definition: constants.F90:40
integer, parameter irho
Definition: constants.F90:34
integer(kind=inttype), parameter vorticity
Definition: constants.F90:137
integer, parameter ivx
Definition: constants.F90:35
integer(kind=inttype), dimension(32) myintstack
Definition: constants.F90:299
integer(kind=inttype) myintptr
Definition: constants.F90:300
real(kind=realtype), parameter one
Definition: constants.F90:72
real(kind=realtype), parameter half
Definition: constants.F90:80
integer(kind=inttype), parameter katolaunder
Definition: constants.F90:137
integer, parameter ivz
Definition: constants.F90:37
real(kind=realtype), parameter two
Definition: constants.F90:73
real(kind=realtype), parameter fourth
Definition: constants.F90:82
integer, parameter ivy
Definition: constants.F90:36
real(kind=realtype), parameter sixth
Definition: constants.F90:83
real(kind=realtype) timeref
logical useft2sa
Definition: inputParam.F90:587
integer(kind=inttype) turbprod
Definition: inputParam.F90:584
logical userotationsa
Definition: inputParam.F90:587
real(kind=realtype), parameter rsacw1
Definition: paramTurb.F90:18
real(kind=realtype), parameter rsak
Definition: paramTurb.F90:13
real(kind=realtype), parameter rsact4
Definition: paramTurb.F90:25
real(kind=realtype), parameter rsacrot
Definition: paramTurb.F90:26
real(kind=realtype), parameter rsacb2
Definition: paramTurb.F90:15
real(kind=realtype), parameter rsact3
Definition: paramTurb.F90:24
real(kind=realtype), parameter rsacw3
Definition: paramTurb.F90:21
real(kind=realtype), parameter rsacw2
Definition: paramTurb.F90:20
real(kind=realtype), parameter rsacv1
Definition: paramTurb.F90:17
real(kind=realtype), parameter rsacb3
Definition: paramTurb.F90:16
real(kind=realtype), parameter rsacb1
Definition: paramTurb.F90:14
real(kind=realtype) cb3inv
Definition: sa_fast_b.f90:10
real(kind=realtype), dimension(:, :), pointer dd2wall
Definition: sa_fast_b.f90:14
subroutine saviscous()
Definition: sa_fast_b.f90:1014
real(kind=realtype), dimension(:, :, :), allocatable qq
Definition: sa_fast_b.f90:11
real(kind=realtype) cw36
Definition: sa_fast_b.f90:10
real(kind=realtype), dimension(:, :, :), pointer ww
Definition: sa_fast_b.f90:12
subroutine saresscale()
Definition: sa_fast_b.f90:1268
real(kind=realtype), dimension(:, :, :), pointer ddvt
Definition: sa_fast_b.f90:12
subroutine saresscale_fast_b()
Definition: sa_fast_b.f90:1233
subroutine sasource()
Definition: sa_fast_b.f90:430
real(kind=realtype) kar2inv
Definition: sa_fast_b.f90:10
real(kind=realtype) cv13
Definition: sa_fast_b.f90:10
real(kind=realtype), dimension(:, :, :), pointer ddw
Definition: sa_fast_b.f90:12
subroutine sasource_fast_b()
Definition: sa_fast_b.f90:23
subroutine saviscous_fast_b()
Definition: sa_fast_b.f90:629
real(kind=realtype), dimension(:, :), pointer rrlv
Definition: sa_fast_b.f90:13
type(sectiontype), dimension(:), allocatable sections
Definition: section.f90:46
Definition: SST.F90:1