2 ! ======================================================================================
3 ! This file was generated by the version 5.3.6 of DFT on 08/15/2010. The differentiation
4 ! transforming system(DFT) was jointly developed and sponsored by LASG of IAP(1998-2010)
5 ! and LSEC of ICMSEC, AMSS(2001-2003)
6 ! The copyright of the DFT system was declared by Walls at LASG, 1998-2010
7 ! ======================================================================================
9 MODULE g_module_sfs_nba
11 USE module_configure, ONLY : grid_config_rec_type
12 USE module_sfs_nba, ONLY : c1, c2, c3, ce, cb, cs ! Added by Ning Pan, 2010-08-18
16 ! REAL :: c1,c2,c3,ce,cb,cs ! Remarked by Ning Pan, 2010-08-18
20 ! Remarked by Ning Pan, 2010-08-18
21 ! SUBROUTINE g_calc_mij_constants()
25 ! REAL :: Tmpv1,g_Tmpv1
34 ! cs =((8.0 *(1.0+cb))/(27.0 *pi**2))**0.5
36 ! c1 =((960.0**0.5) *cb)/(7.0 *(1.0+cb) *sk)
40 ! ce =((8.0 *pi/27.0)**(1.0/3.0)) *cs**(4.0/3.0)
42 ! c3 =((27.0/(8.0 *pi))**(1.0/3.0)) *cs**(2.0/3.0)
45 ! END SUBROUTINE g_calc_mij_constants
47 SUBROUTINE g_calc_smnsmn(smnsmn,g_smnsmn,s11,g_s11,s22,g_s22,s33, &
48 g_s33,s12,g_s12,s13,g_s13,s23,g_s23,config_flags,ids,ide,jds,jde,kds,kde, &
49 ims,ime,jms,jme,kms,kme,ips,ipe,jps,jpe,kps,kpe,its,ite,jts,jte,kts,kte)
53 REAL :: Tmpv1,g_Tmpv1,Tmpv2,g_Tmpv2,Tmpv3,g_Tmpv3
54 REAL,DIMENSION(ims:ime,kms:kme,jms:jme) :: smnsmn,g_smnsmn
56 REAL,DIMENSION(ims:ime,kms:kme,jms:jme) :: s11,g_s11,s22,g_s22,s33,g_s33, &
57 s12,g_s12,s13,g_s13,s23,g_s23
58 TYPE(grid_config_rec_type) :: config_flags
59 INTEGER :: ids,ide,jds,jde,kds,kde,ims,ime,jms,jme,kms,kme,ips,ipe,jps,jpe,kps,kpe, &
60 its,ite,jts,jte,kts,kte
62 INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf
74 IF( config_flags%open_xs .or. config_flags%specified .or. &
75 config_flags%nested) i_start =max(ids+1,its)
77 IF( config_flags%open_xe .or. config_flags%specified .or. &
78 config_flags%nested) i_end =min(ide-2,ite)
80 IF( config_flags%open_ys .or. config_flags%specified .or. &
81 config_flags%nested) j_start =max(jds+1,jts)
83 IF( config_flags%open_ye .or. config_flags%specified .or. &
84 config_flags%nested) j_end =min(jde-2,jte)
86 IF( config_flags%periodic_x ) i_start =its
88 IF( config_flags%periodic_x ) i_end =min(ite,ide-1)
94 g_Tmpv1 =2.0*s11(i,k,j)*g_s11(i,k,j)
95 Tmpv1 =s11(i,k,j)*s11(i,k,j)
97 g_Tmpv2 =2.0*s22(i,k,j)*g_s22(i,k,j)
98 Tmpv2 =s22(i,k,j)*s22(i,k,j)
100 g_Tmpv3 =2.0*s33(i,k,j)*g_s33(i,k,j)
101 Tmpv3 =s33(i,k,j)*s33(i,k,j)
103 g_smnsmn(i,k,j) =0.25*(g_Tmpv1 +g_Tmpv2 +g_Tmpv3)
104 smnsmn(i,k,j) =0.25*(Tmpv1 +Tmpv2 +Tmpv3)
114 g_tmp =0.125*(g_s12(i,k,j) +g_s12(i,k,j+1) +g_s12(i+1,k,j) +g_s12(i+1,k,j+1))
115 tmp =0.125*(s12(i,k,j) +s12(i,k,j+1) +s12(i+1,k,j) +s12(i+1,k,j+1))
117 g_Tmpv1 =2.0*tmp*g_tmp +2.0*g_tmp*tmp
120 g_smnsmn(i,k,j) =g_smnsmn(i,k,j) +g_Tmpv1
121 smnsmn(i,k,j) =smnsmn(i,k,j) +Tmpv1
131 g_tmp =0.125*(g_s13(i,k+1,j) +g_s13(i,k,j) +g_s13(i+1,k+1,j) +g_s13(i+1,k,j))
132 tmp =0.125*(s13(i,k+1,j) +s13(i,k,j) +s13(i+1,k+1,j) +s13(i+1,k,j))
134 g_Tmpv1 =2.0*tmp*g_tmp +2.0*g_tmp*tmp
137 g_smnsmn(i,k,j) =g_smnsmn(i,k,j) +g_Tmpv1
138 smnsmn(i,k,j) =smnsmn(i,k,j) +Tmpv1
148 g_tmp =0.125*(g_s23(i,k+1,j) +g_s23(i,k,j) +g_s23(i,k+1,j+1) +g_s23(i,k,j+1))
149 tmp =0.125*(s23(i,k+1,j) +s23(i,k,j) +s23(i,k+1,j+1) +s23(i,k,j+1))
151 g_Tmpv1 =2.0*tmp*g_tmp +2.0*g_tmp*tmp
154 g_smnsmn(i,k,j) =g_smnsmn(i,k,j) +g_Tmpv1
155 smnsmn(i,k,j) =smnsmn(i,k,j) +Tmpv1
163 END SUBROUTINE g_calc_smnsmn
165 SUBROUTINE g_calc_mii(m11,g_m11,m22,g_m22,m33,g_m33,s11,g_s11,s22, &
166 g_s22,s33,g_s33,s12,g_s12,s13,g_s13,s23,g_s23,r12,g_r12,r13, &
167 g_r13,r23,g_r23,smnsmn,g_smnsmn,tke,g_tke,rdzw,g_rdzw,dx,dy, &
168 config_flags,ids,ide,jds,jde,kds,kde,ims,ime,jms,jme,kms,kme,ips,ipe,jps,jpe,kps,kpe, &
169 its,ite,jts,jte,kts,kte)
173 REAL :: Tmpv1,g_Tmpv1,Tmpv2,g_Tmpv2,Tmpv3,g_Tmpv3,Tmpv4,g_Tmpv4,Tmpv5, &
174 g_Tmpv5,Tmpv6,g_Tmpv6,Tmpv7,g_Tmpv7,Tmpv8,g_Tmpv8
177 REAL,DIMENSION(ims:ime,kms:kme,jms:jme) :: m11,g_m11,m22,g_m22,m33,g_m33
179 REAL,DIMENSION(ims:ime,kms:kme,jms:jme) :: s11,g_s11,s22,g_s22,s33,g_s33, &
180 s12,g_s12,s13,g_s13,s23,g_s23,r12,g_r12,r13,g_r13,r23,g_r23,smnsmn, &
181 g_smnsmn,tke,g_tke,rdzw,g_rdzw
184 TYPE(grid_config_rec_type) :: config_flags
185 INTEGER :: ids,ide,jds,jde,kds,kde,ims,ime,jms,jme,kms,kme,ips,ipe,jps,jpe,kps,kpe, &
186 its,ite,jts,jte,kts,kte
188 REAL,DIMENSION(its-1:ite+1,kms:kme,jts-1:jte+1) :: ss11,g_ss11,ss22,g_ss22, &
189 ss33,g_ss33,ss12,g_ss12,ss13,g_ss13,ss23,g_ss23,rr12,g_rr12,rr13, &
192 REAL,DIMENSION(its-1:ite+1,kms:kme,jts-1:jte+1) :: ss12c,g_ss12c,rr12c,g_rr12c, &
193 ss13c,g_ss13c,rr13c,g_rr13c,ss23c,g_ss23c,rr23c,g_rr23c
194 REAL :: delta,g_delta,a,g_a,b,g_b
195 INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf,is_ext,js_ext
209 IF( config_flags%open_xs .OR. config_flags%specified .OR. &
210 config_flags%nested) i_start =max(ids+1,its)
212 IF( config_flags%open_xe .OR. config_flags%specified .OR. &
213 config_flags%nested) i_end =min(ide-1,ite)
215 IF( config_flags%open_ys .OR. config_flags%specified .OR. &
216 config_flags%nested) j_start =max(jds+1,jts)
218 IF( config_flags%open_ye .OR. config_flags%specified .OR. &
219 config_flags%nested) j_end =min(jde-1,jte)
221 IF( config_flags%periodic_x ) i_start =its
223 IF( config_flags%periodic_x ) i_end =ite
229 i_start =i_start-is_ext
231 j_start =j_start-js_ext
233 DO j =j_start,j_end+1
235 DO i =i_start,i_end+1
237 g_ss11(i,k,j) =g_s11(i,k,j)/2.0
238 ss11(i,k,j) =s11(i,k,j)/2.0
240 g_ss22(i,k,j) =g_s22(i,k,j)/2.0
241 ss22(i,k,j) =s22(i,k,j)/2.0
243 g_ss33(i,k,j) =g_s33(i,k,j)/2.0
244 ss33(i,k,j) =s33(i,k,j)/2.0
246 g_ss12(i,k,j) =g_s12(i,k,j)/2.0
247 ss12(i,k,j) =s12(i,k,j)/2.0
249 g_ss13(i,k,j) =g_s13(i,k,j)/2.0
250 ss13(i,k,j) =s13(i,k,j)/2.0
252 g_ss23(i,k,j) =g_s23(i,k,j)/2.0
253 ss23(i,k,j) =s23(i,k,j)/2.0
255 g_rr12(i,k,j) =g_r12(i,k,j)/2.0
256 rr12(i,k,j) =r12(i,k,j)/2.0
258 g_rr13(i,k,j) =g_r13(i,k,j)/2.0
259 rr13(i,k,j) =r13(i,k,j)/2.0
261 g_rr23(i,k,j) =g_r23(i,k,j)/2.0
262 rr23(i,k,j) =r23(i,k,j)/2.0
268 DO j =j_start,j_end+1
269 DO i =i_start,i_end+1
290 g_ss12c(i,k,j) =0.25*(g_ss12(i,k,j) +g_ss12(i,k,j+1) +g_ss12(i+1,k,j) &
292 ss12c(i,k,j) =0.25*(ss12(i,k,j) +ss12(i,k,j+1) +ss12(i+1,k,j) +ss12(i+1,k,j+1))
294 g_rr12c(i,k,j) =0.25*(g_rr12(i,k,j) +g_rr12(i,k,j+1) +g_rr12(i+1,k,j) &
296 rr12c(i,k,j) =0.25*(rr12(i,k,j) +rr12(i,k,j+1) +rr12(i+1,k,j) +rr12(i+1,k,j+1))
298 g_ss13c(i,k,j) =0.25*(g_ss13(i,k+1,j) +g_ss13(i,k,j) +g_ss13(i+1,k+1,j) &
300 ss13c(i,k,j) =0.25*(ss13(i,k+1,j) +ss13(i,k,j) +ss13(i+1,k+1,j) +ss13(i+1,k,j))
302 g_rr13c(i,k,j) =0.25*(g_rr13(i,k+1,j) +g_rr13(i,k,j) +g_rr13(i+1,k+1,j) &
304 rr13c(i,k,j) =0.25*(rr13(i,k+1,j) +rr13(i,k,j) +rr13(i+1,k+1,j) +rr13(i+1,k,j))
306 g_ss23c(i,k,j) =0.25*(g_ss23(i,k+1,j) +g_ss23(i,k,j) +g_ss23(i,k+1,j+1) &
308 ss23c(i,k,j) =0.25*(ss23(i,k+1,j) +ss23(i,k,j) +ss23(i,k+1,j+1) +ss23(i,k,j+1))
310 g_rr23c(i,k,j) =0.25*(g_rr23(i,k+1,j) +g_rr23(i,k,j) +g_rr23(i,k+1,j+1) &
312 rr23c(i,k,j) =0.25*(rr23(i,k+1,j) +rr23(i,k,j) +rr23(i,k+1,j+1) +rr23(i,k,j+1))
318 IF( config_flags%sfs_opt .EQ. 1 ) THEN
324 g_delta =0.33333333*(-dx *dy*g_rdzw(i,k,j)/(rdzw(i,k,j)*rdzw(i,k,j))) &
325 *(dx *dy/rdzw(i,k,j))**(0.33333333 -1.0)
326 delta =(dx *dy/rdzw(i,k,j))**0.33333333
328 g_a =-1.0*2.0*(cs*g_delta)*(cs*delta)
329 a =-1.0*(cs*delta)**2
331 g_Tmpv1 =2.0*sqrt(2.0*smnsmn(i,k,j))*g_ss11(i,k,j) +2.0*g_Sqrt(2.0* &
332 g_smnsmn(i,k,j), 2.0*smnsmn(i,k,j))*ss11(i,k,j)
333 Tmpv1 =2.0*sqrt(2.0*smnsmn(i,k,j))*ss11(i,k,j)
335 g_Tmpv2 =2.0*ss11(i,k,j)*g_ss11(i,k,j)
336 Tmpv2 =ss11(i,k,j)*ss11(i,k,j)
338 g_Tmpv3 =2.0*ss12c(i,k,j)*g_ss12c(i,k,j)
339 Tmpv3 =ss12c(i,k,j)*ss12c(i,k,j)
341 g_Tmpv4 =2.0*ss13c(i,k,j)*g_ss13c(i,k,j)
342 Tmpv4 =ss13c(i,k,j)*ss13c(i,k,j)
344 g_Tmpv5 =ss12c(i,k,j)*g_rr12c(i,k,j) +g_ss12c(i,k,j)*rr12c(i,k,j)
345 Tmpv5 =ss12c(i,k,j)*rr12c(i,k,j)
347 g_Tmpv6 =ss13c(i,k,j)*g_rr13c(i,k,j) +g_ss13c(i,k,j)*rr13c(i,k,j)
348 Tmpv6 =ss13c(i,k,j)*rr13c(i,k,j)
350 g_Tmpv7 =a*(g_Tmpv1 +c1*(g_Tmpv2 +g_Tmpv3 +g_Tmpv4 -(g_smnsmn(i,k, &
351 j)/3.0)) +c2*(-2.0*(g_Tmpv5 +g_Tmpv6))) +g_a*(Tmpv1 +c1*(Tmpv2 +Tmpv3 + &
352 Tmpv4 -smnsmn(i,k,j)/3.0) +c2*(-2.0*(Tmpv5 +Tmpv6)))
353 Tmpv7 =a*(Tmpv1 +c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33(i,k,j)*ss33(i,k,j)
499 g_Tmpv3 =2.0*ss13c(i,k,j)*g_ss13c(i,k,j)
500 Tmpv3 =ss13c(i,k,j)*ss13c(i,k,j)
502 g_Tmpv4 =2.0*ss23c(i,k,j)*g_ss23c(i,k,j)
503 Tmpv4 =ss23c(i,k,j)*ss23c(i,k,j)
505 g_Tmpv5 =ss13c(i,k,j)*g_rr13c(i,k,j) +g_ss13c(i,k,j)*rr13c(i,k,j)
506 Tmpv5 =ss13c(i,k,j)*rr13c(i,k,j)
508 g_Tmpv6 =ss23c(i,k,j)*g_rr23c(i,k,j) +g_ss23c(i,k,j)*rr23c(i,k,j)
509 Tmpv6 =ss23c(i,k,j)*rr23c(i,k,j)
511 g_Tmpv7 =b*(c1*(g_Tmpv2 +g_Tmpv3 +g_Tmpv4 -(g_smnsmn(i,k,j)/3.0)) &
512 +c2*(2.0*(g_Tmpv5 +g_Tmpv6))) +g_b*(c1*(Tmpv2 +Tmpv3 +Tmpv4 -smnsmn(i,k,j) &
513 /3.0) +c2*(2.0*(Tmpv5 +Tmpv6)))
514 Tmpv7 =b*(c1*(Tmpv2 +Tmpv3 +Tmpv4 -smnsmn(i,k,j)/3.0) +c2*(2.0*(Tmpv5 +Tmpv6)))
516 g_Tmpv8 =a*(g_Tmpv1 +g_Tmpv7) +g_a*(Tmpv1 +Tmpv7)
517 Tmpv8 =a*(Tmpv1 +Tmpv7)
519 g_m33(i,k,j) =g_Tmpv8
528 END SUBROUTINE g_calc_mii
530 SUBROUTINE g_calc_m12(m12,g_m12,s11,g_s11,s22,g_s22,s12,g_s12,s13, &
531 g_s13,s23,g_s23,r12,g_r12,r13,g_r13,r23,g_r23,smnsmn,g_smnsmn,tke, &
532 g_tke,rdzw,g_rdzw,dx,dy,config_flags,ids,ide,jds,jde,kds,kde,ims,ime,jms,jme, &
533 kms,kme,ips,ipe,jps,jpe,kps,kpe,its,ite,jts,jte,kts,kte)
537 REAL :: Tmpv1,g_Tmpv1,Tmpv2,g_Tmpv2,Tmpv3,g_Tmpv3,Tmpv4,g_Tmpv4,Tmpv5, &
538 g_Tmpv5,Tmpv6,g_Tmpv6,Tmpv7,g_Tmpv7,Tmpv8,g_Tmpv8,Tmpv9,g_Tmpv9, &
542 REAL,DIMENSION(ims:ime,kms:kme,jms:jme) :: m12,g_m12
544 REAL,DIMENSION(ims:ime,kms:kme,jms:jme) :: s11,g_s11,s22,g_s22,s12,g_s12, &
545 s13,g_s13,s23,g_s23,r12,g_r12,r13,g_r13,r23,g_r23,smnsmn,g_smnsmn, &
546 tke,g_tke,rdzw,g_rdzw
549 TYPE(grid_config_rec_type) :: config_flags
550 INTEGER :: ids,ide,jds,jde,kds,kde,ims,ime,jms,jme,kms,kme,ips,ipe,jps,jpe,kps,kpe, &
551 its,ite,jts,jte,kts,kte
553 REAL,DIMENSION(its-1:ite+1,kms:kme,jts-1:jte+1) :: ss11,g_ss11,ss22,g_ss22, &
554 ss12,g_ss12,ss13,g_ss13,ss23,g_ss23,rr12,g_rr12,rr13,g_rr13,rr23,g_rr23
556 REAL,DIMENSION(its-1:ite+1,kms:kme,jts-1:jte+1) :: tked,g_tked,ss11d,g_ss11d, &
557 ss22d,g_ss22d,ss13d,g_ss13d,ss23d,g_ss23d,rr13d,g_rr13d,rr23d,g_rr23d, &
559 REAL :: delta,g_delta,a,g_a,b,g_b
560 INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf,je_ext,ie_ext
572 IF( config_flags%open_xs .OR. config_flags%specified .OR. &
573 config_flags%nested ) i_start =max(ids+1,its)
575 IF( config_flags%open_xe .OR. config_flags%specified .OR. &
576 config_flags%nested ) i_end =min(ide-1,ite)
578 IF( config_flags%open_ys .OR. config_flags%specified .OR. &
579 config_flags%nested ) j_start =max(jds+1,jts)
581 IF( config_flags%open_ye .OR. config_flags%specified .OR. &
582 config_flags%nested ) j_end =min(jde-1,jte)
584 IF( config_flags%periodic_x ) i_start =its
586 IF( config_flags%periodic_x ) i_end =ite
596 DO j =j_start-1,j_end
598 DO i =i_start-1,i_end
600 g_ss11(i,k,j) =g_s11(i,k,j)/2.0
601 ss11(i,k,j) =s11(i,k,j)/2.0
603 g_ss22(i,k,j) =g_s22(i,k,j)/2.0
604 ss22(i,k,j) =s22(i,k,j)/2.0
606 g_ss12(i,k,j) =g_s12(i,k,j)/2.0
607 ss12(i,k,j) =s12(i,k,j)/2.0
609 g_ss13(i,k,j) =g_s13(i,k,j)/2.0
610 ss13(i,k,j) =s13(i,k,j)/2.0
612 g_ss23(i,k,j) =g_s23(i,k,j)/2.0
613 ss23(i,k,j) =s23(i,k,j)/2.0
615 g_rr12(i,k,j) =g_r12(i,k,j)/2.0
616 rr12(i,k,j) =r12(i,k,j)/2.0
618 g_rr13(i,k,j) =g_r13(i,k,j)/2.0
619 rr13(i,k,j) =r13(i,k,j)/2.0
621 g_rr23(i,k,j) =g_r23(i,k,j)/2.0
622 rr23(i,k,j) =r23(i,k,j)/2.0
628 DO j =j_start-1,j_end
629 DO i =i_start-1,i_end
650 g_tked(i,k,j) =0.25*(g_tke(i-1,k,j) +g_tke(i,k,j) +g_tke(i-1,k,j-1) &
652 tked(i,k,j) =0.25*(tke(i-1,k,j) +tke(i,k,j) +tke(i-1,k,j-1) +tke(i,k,j-1))
654 g_smnsmnd(i,k,j) =0.25*(g_smnsmn(i-1,k,j) +g_smnsmn(i,k,j) +g_smnsmn(i-1, &
655 k,j-1) +g_smnsmn(i,k,j-1))
656 smnsmnd(i,k,j) =0.25*(smnsmn(i-1,k,j) +smnsmn(i,k,j) +smnsmn(i-1,k,j-1) +smnsmn(i,k,j-1))
658 g_ss11d(i,k,j) =0.25*(g_ss11(i-1,k,j) +g_ss11(i,k,j) +g_ss11(i-1,k,j-1) &
660 ss11d(i,k,j) =0.25*(ss11(i-1,k,j) +ss11(i,k,j) +ss11(i-1,k,j-1) +ss11(i,k,j-1))
662 g_ss22d(i,k,j) =0.25*(g_ss22(i-1,k,j) +g_ss22(i,k,j) +g_ss22(i-1,k,j-1) &
664 ss22d(i,k,j) =0.25*(ss22(i-1,k,j) +ss22(i,k,j) +ss22(i-1,k,j-1) +ss22(i,k,j-1))
666 g_ss13d(i,k,j) =0.25*(g_ss13(i,k+1,j) +g_ss13(i,k+1,j-1) +g_ss13(i,k,j) &
668 ss13d(i,k,j) =0.25*(ss13(i,k+1,j) +ss13(i,k+1,j-1) +ss13(i,k,j) +ss13(i,k,j-1))
670 g_rr13d(i,k,j) =0.25*(g_rr13(i,k+1,j) +g_rr13(i,k+1,j-1) +g_rr13(i,k,j) &
672 rr13d(i,k,j) =0.25*(rr13(i,k+1,j) +rr13(i,k+1,j-1) +rr13(i,k,j) +rr13(i,k,j-1))
674 g_ss23d(i,k,j) =0.25*(g_ss23(i,k+1,j) +g_ss23(i-1,k+1,j) +g_ss23(i,k,j) &
676 ss23d(i,k,j) =0.25*(ss23(i,k+1,j) +ss23(i-1,k+1,j) +ss23(i,k,j) +ss23(i-1,k,j))
678 g_rr23d(i,k,j) =0.25*(g_rr23(i,k+1,j) +g_rr23(i-1,k+1,j) +g_rr23(i,k,j) &
680 rr23d(i,k,j) =0.25*(rr23(i,k+1,j) +rr23(i-1,k+1,j) +rr23(i,k,j) +rr23(i-1,k,j))
686 IF( config_flags%sfs_opt .EQ. 1 ) THEN
692 g_delta =0.33333333*(-dx *dy*g_rdzw(i,k,j)/(rdzw(i,k,j)*rdzw(i,k,j))) &
693 *(dx *dy/rdzw(i,k,j))**(0.33333333 -1.0)
694 delta =(dx *dy/rdzw(i,k,j))**0.33333333
696 g_a =-1.0*2.0*(cs*g_delta)*(cs*delta)
697 a =-1.0*(cs*delta)**2
699 g_Tmpv1 =2.0*sqrt(2.0*smnsmnd(i,k,j))*g_ss12(i,k,j) +2.0*g_Sqrt(2.0* &
700 g_smnsmnd(i,k,j), 2.0*smnsmnd(i,k,j))*ss12(i,k,j)
701 Tmpv1 =2.0*sqrt(2.0*smnsmnd(i,k,j))*ss12(i,k,j)
703 g_Tmpv2 =ss11d(i,k,j)*g_ss12(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**(0.33333333 -1.0)
744 delta =(dx *dy/rdzw(i,k,j))**0.33333333
746 g_a =-1.0 *ce*g_delta
752 g_Tmpv1 =2.0*sqrt(tked(i,k,j))*g_s12(i,k,j) +2.0*g_Sqrt(g_tked(i,k,j) &
753 , tked(i,k,j))*s12(i,k,j)
754 Tmpv1 =2.0*sqrt(tked(i,k,j))*s12(i,k,j)
756 g_Tmpv2 =ss11d(i,k,j)*g_ss12(i,k,j) +g_ss11d(i,k,j)*ss12(i,k,j)
757 Tmpv2 =ss11d(i,k,j)*ss12(i,k,j)
759 g_Tmpv3 =ss22d(i,k,j)*g_ss12(i,k,j) +g_ss22d(i,k,j)*ss12(i,k,j)
760 Tmpv3 =ss22d(i,k,j)*ss12(i,k,j)
762 g_Tmpv4 =ss13d(i,k,j)*g_ss23d(i,k,j) +g_ss13d(i,k,j)*ss23d(i,k,j)
763 Tmpv4 =ss13d(i,k,j)*ss23d(i,k,j)
765 g_Tmpv5 =ss11d(i,k,j)*g_rr12(i,k,j) +g_ss11d(i,k,j)*rr12(i,k,j)
766 Tmpv5 =ss11d(i,k,j)*rr12(i,k,j)
768 g_Tmpv6 =ss13d(i,k,j)*g_rr23d(i,k,j) +g_ss13d(i,k,j)*rr23d(i,k,j)
769 Tmpv6 =ss13d(i,k,j)*rr23d(i,k,j)
771 g_Tmpv7 =ss22d(i,k,j)*g_rr12(i,k,j) +g_ss22d(i,k,j)*rr12(i,k,j)
772 Tmpv7 =ss22d(i,k,j)*rr12(i,k,j)
774 g_Tmpv8 =ss23d(i,k,j)*g_rr13d(i,k,j) +g_ss23d(i,k,j)*rr13d(i,k,j)
775 Tmpv8 =ss23d(i,k,j)*rr13d(i,k,j)
777 g_Tmpv9 =b*(c1*(g_Tmpv2 +g_Tmpv3 +g_Tmpv4) +c2*(g_Tmpv5 -g_Tmpv6 - &
778 g_Tmpv7 -g_Tmpv8)) +g_b*(c1*(Tmpv2 +Tmpv3 +Tmpv4) +c2*(Tmpv5 -Tmpv6 -Tmpv7 -Tmpv8))
779 Tmpv9 =b*(c1*(Tmpv2 +Tmpv3 +Tmpv4) +c2*(Tmpv5 -Tmpv6 -Tmpv7 -Tmpv8))
781 g_Tmpv10 =a*(g_Tmpv1 +g_Tmpv9) +g_a*(Tmpv1 +Tmpv9)
782 Tmpv10 =a*(Tmpv1 +Tmpv9)
784 g_m12(i,k,j) =g_Tmpv10
793 END SUBROUTINE g_calc_m12
795 SUBROUTINE g_calc_m13(m13,g_m13,s11,g_s11,s33,g_s33,s12,g_s12,s13, &
796 g_s13,s23,g_s23,r12,g_r12,r13,g_r13,r23,g_r23,smnsmn,g_smnsmn,tke, &
797 g_tke,rdzw,g_rdzw,dx,dy,fnm,fnp,config_flags,ids,ide,jds,jde,kds,kde,ims,ime, &
798 jms,jme,kms,kme,ips,ipe,jps,jpe,kps,kpe,its,ite,jts,jte,kts,kte)
802 REAL :: Tmpv1,g_Tmpv1,Tmpv2,g_Tmpv2,Tmpv3,g_Tmpv3,Tmpv4,g_Tmpv4,Tmpv5, &
803 g_Tmpv5,Tmpv6,g_Tmpv6,Tmpv7,g_Tmpv7,Tmpv8,g_Tmpv8,Tmpv9,g_Tmpv9, &
807 REAL,DIMENSION(ims:ime,kms:kme,jms:jme) :: m13,g_m13
809 REAL,DIMENSION(ims:ime,kms:kme,jms:jme) :: s11,g_s11,s33,g_s33,s12,g_s12, &
810 s13,g_s13,s23,g_s23,r12,g_r12,r13,g_r13,r23,g_r23,smnsmn,g_smnsmn, &
811 tke,g_tke,rdzw,g_rdzw
815 REAL,DIMENSION(kms:kme) :: fnm,fnp
816 TYPE(grid_config_rec_type) :: config_flags
817 INTEGER :: ids,ide,jds,jde,kds,kde,ims,ime,jms,jme,kms,kme,ips,ipe,jps,jpe,kps,kpe, &
818 its,ite,jts,jte,kts,kte
820 REAL,DIMENSION(its-1:ite+1,kms:kme,jts-1:jte+1) :: ss11,g_ss11,ss33,g_ss33, &
821 ss12,g_ss12,ss13,g_ss13,ss23,g_ss23,rr12,g_rr12,rr13,g_rr13,rr23,g_rr23
823 REAL,DIMENSION(its-1:ite+1,kms:kme,jts-1:jte+1) :: tkee,g_tkee,ss11e,g_ss11e, &
824 ss33e,g_ss33e,ss12e,g_ss12e,ss23e,g_ss23e,rr12e,g_rr12e,rr23e,g_rr23e, &
826 REAL :: delta,g_delta,a,g_a,b,g_b
827 INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf,ie_ext
837 j_end =min(jte,jde-1)
839 IF( config_flags%open_xs .OR. config_flags%specified .OR. &
840 config_flags%nested) i_start =max(ids+1,its)
842 IF( config_flags%open_xe .OR. config_flags%specified .OR. &
843 config_flags%nested) i_end =min(ide-1,ite)
845 IF( config_flags%open_ys .OR. config_flags%specified .OR. &
846 config_flags%nested) j_start =max(jds+1,jts)
848 IF( config_flags%open_ye .OR. config_flags%specified .OR. &
849 config_flags%nested) j_end =min(jde-2,jte)
851 IF( config_flags%periodic_x ) i_start =its
853 IF( config_flags%periodic_x ) i_end =ite
859 DO j =j_start,j_end+1
861 DO i =i_start-1,i_end
863 g_ss11(i,k,j) =g_s11(i,k,j)/2.0
864 ss11(i,k,j) =s11(i,k,j)/2.0
866 g_ss33(i,k,j) =g_s33(i,k,j)/2.0
867 ss33(i,k,j) =s33(i,k,j)/2.0
869 g_ss12(i,k,j) =g_s12(i,k,j)/2.0
870 ss12(i,k,j) =s12(i,k,j)/2.0
872 g_ss13(i,k,j) =g_s13(i,k,j)/2.0
873 ss13(i,k,j) =s13(i,k,j)/2.0
875 g_ss23(i,k,j) =g_s23(i,k,j)/2.0
876 ss23(i,k,j) =s23(i,k,j)/2.0
878 g_rr12(i,k,j) =g_r12(i,k,j)/2.0
879 rr12(i,k,j) =r12(i,k,j)/2.0
881 g_rr13(i,k,j) =g_r13(i,k,j)/2.0
882 rr13(i,k,j) =r13(i,k,j)/2.0
884 g_rr23(i,k,j) =g_r23(i,k,j)/2.0
885 rr23(i,k,j) =r23(i,k,j)/2.0
895 g_tkee(i,k,j) =0.5*(fnm(k)*(g_tke(i,k,j) +g_tke(i-1,k,j)) +fnp(k) &
896 *(g_tke(i,k-1,j) +g_tke(i-1,k-1,j)))
897 tkee(i,k,j) =0.5*(fnm(k)*(tke(i,k,j) +tke(i-1,k,j)) +fnp(k)*(tke(i,k-1,j) +tke(i-1,k-1,j)))
899 g_smnsmne(i,k,j) =0.5*(fnm(k)*(g_smnsmn(i,k,j) +g_smnsmn(i-1,k,j)) +fnp(k) &
900 *(g_smnsmn(i,k-1,j) +g_smnsmn(i-1,k-1,j)))
901 smnsmne(i,k,j) =0.5*(fnm(k)*(smnsmn(i,k,j) +smnsmn(i-1,k,j)) +fnp(k)*(smnsmn(i,k-1,j) &
904 g_ss11e(i,k,j) =0.5*(fnm(k)*(g_ss11(i,k,j) +g_ss11(i-1,k,j)) +fnp(k) &
905 *(g_ss11(i,k-1,j) +g_ss11(i-1,k-1,j)))
906 ss11e(i,k,j) =0.5*(fnm(k)*(ss11(i,k,j) +ss11(i-1,k,j)) +fnp(k)*(ss11(i,k-1,j) &
909 g_ss33e(i,k,j) =0.5*(fnm(k)*(g_ss33(i,k,j) +g_ss33(i-1,k,j)) +fnp(k) &
910 *(g_ss33(i,k-1,j) +g_ss33(i-1,k-1,j)))
911 ss33e(i,k,j) =0.5*(fnm(k)*(ss33(i,k,j) +ss33(i-1,k,j)) +fnp(k)*(ss33(i,k-1,j) &
914 g_ss12e(i,k,j) =0.5*(fnm(k)*(g_ss12(i,k,j) +g_ss12(i,k,j+1)) +fnp(k) &
915 *(g_ss12(i,k-1,j) +g_ss12(i,k-1,j+1)))
916 ss12e(i,k,j) =0.5*(fnm(k)*(ss12(i,k,j) +ss12(i,k,j+1)) +fnp(k)*(ss12(i,k-1,j) &
919 g_rr12e(i,k,j) =0.5*(fnm(k)*(g_rr12(i,k,j) +g_rr12(i,k,j+1)) +fnp(k) &
920 *(g_rr12(i,k-1,j) +g_rr12(i,k-1,j+1)))
921 rr12e(i,k,j) =0.5*(fnm(k)*(rr12(i,k,j) +rr12(i,k,j+1)) +fnp(k)*(rr12(i,k-1,j) &
924 g_ss23e(i,k,j) =0.25*(g_ss23(i,k,j) +g_ss23(i,k,j+1) +g_ss23(i-1,k,j) &
926 ss23e(i,k,j) =0.25*(ss23(i,k,j) +ss23(i,k,j+1) +ss23(i-1,k,j) +ss23(i-1,k,j+1))
928 g_rr23e(i,k,j) =0.25*(g_rr23(i,k,j) +g_rr23(i,k,j+1) +g_rr23(i-1,k,j) &
930 rr23e(i,k,j) =0.25*(rr23(i,k,j) +rr23(i,k,j+1) +rr23(i-1,k,j) +rr23(i-1,k,j+1))
936 IF( config_flags%sfs_opt .EQ. 1 ) THEN
942 g_delta =0.33333333*(-dx *dy*g_rdzw(i,k,j)/(rdzw(i,k,j)*rdzw(i,k,j))) &
943 *(dx *dy/rdzw(i,k,j))**(0.33333333 -1.0)
944 delta =(dx *dy/rdzw(i,k,j))**0.33333333
946 g_a =-1.0*2.0*(cs*g_delta)*(cs*delta)
947 a =-1.0*(cs*delta)**2
949 g_Tmpv1 =2.0*sqrt(2.0*smnsmne(i,k,j))*g_ss13(i,k,j) +2.0*g_Sqrt(2.0* &
950 g_smnsmne(i,k,j), 2.0*smnsmne(i,k,j))*ss13(i,k,j)
951 Tmpv1 =2.0*sqrt(2.0*smnsmne(i,k,j))*ss13(i,k,j)
953 g_Tmpv2 =ss11e(i,k,j)*g_ss13(i,k,j) +g_ss11e(i,k,j)*ss13(i,k,j)
954 Tmpv2 =ss11e(i,k,j)*ss13(i,k,j)
956 g_Tmpv3 =ss12e(i,k,j)*g_ss23e(i,k,j) +g_ss12e(i,k,j)*ss23e(i,k,j)
957 Tmpv3 =ss12e(i,k,j)*ss23e(i,k,j)
959 g_Tmpv4 =ss13(i,k,j)*g_ss33e(i,k,j) +g_ss13(i,k,j)*ss33e(i,k,j)
960 Tmpv4 =ss13(i,k,j)*ss33e(i,k,j)
962 g_Tmpv5 =ss11e(i,k,j)*g_rr13(i,k,j) +g_ss11e(i,k,j)*rr13(i,k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23,r12,g_r12,r13,g_r13,r23,g_r23,smnsmn,g_smnsmn,tke, &
1047 g_tke,rdzw,g_rdzw,dx,dy,fnm,fnp,config_flags,ids,ide,jds,jde,kds,kde,ims,ime, &
1048 jms,jme,kms,kme,ips,ipe,jps,jpe,kps,kpe,its,ite,jts,jte,kts,kte)
1052 REAL :: Tmpv1,g_Tmpv1,Tmpv2,g_Tmpv2,Tmpv3,g_Tmpv3,Tmpv4,g_Tmpv4,Tmpv5, &
1053 g_Tmpv5,Tmpv6,g_Tmpv6,Tmpv7,g_Tmpv7,Tmpv8,g_Tmpv8,Tmpv9,g_Tmpv9, &
1057 REAL,DIMENSION(ims:ime,kms:kme,jms:jme) :: m23,g_m23
1059 REAL,DIMENSION(ims:ime,kms:kme,jms:jme) :: s22,g_s22,s33,g_s33,s12,g_s12, &
1060 s13,g_s13,s23,g_s23,r12,g_r12,r13,g_r13,r23,g_r23,smnsmn,g_smnsmn, &
1061 tke,g_tke,rdzw,g_rdzw
1065 REAL,DIMENSION(kms:kme) :: fnm,fnp
1066 TYPE(grid_config_rec_type) :: config_flags
1067 INTEGER :: ids,ide,jds,jde,kds,kde,ims,ime,jms,jme,kms,kme,ips,ipe,jps,jpe,kps,kpe, &
1068 its,ite,jts,jte,kts,kte
1070 REAL,DIMENSION(its-1:ite+1,kms:kme,jts-1:jte+1) :: ss22,g_ss22,ss33,g_ss33, &
1071 ss12,g_ss12,ss13,g_ss13,ss23,g_ss23,rr12,g_rr12,rr13,g_rr13,rr23,g_rr23
1073 REAL,DIMENSION(its-1:ite+1,kms:kme,jts-1:jte+1) :: tkef,g_tkef,ss22f,g_ss22f, &
1074 ss33f,g_ss33f,ss12f,g_ss12f,ss13f,g_ss13f,rr12f,g_rr12f,rr13f,g_rr13f, &
1076 REAL :: delta,g_delta,a,g_a,b,g_b
1077 INTEGER :: i,j,k,i_start,i_end,j_start,j_end,ktf,je_ext
1083 i_end =min(ite,ide-1)
1089 IF( config_flags%open_xs .OR. config_flags%specified .OR. &
1090 config_flags%nested) i_start =max(ids+1,its)
1092 IF( config_flags%open_xe .OR. config_flags%specified .OR. &
1093 config_flags%nested) i_end =min(ide-2,ite)
1095 IF( config_flags%open_ys .OR. config_flags%specified .OR. &
1096 config_flags%nested) j_start =max(jds+1,jts)
1098 IF( config_flags%open_ye .OR. config_flags%specified .OR. &
1099 config_flags%nested) j_end =min(jde-1,jte)
1101 IF( config_flags%periodic_x ) i_start =its
1103 IF( config_flags%periodic_x ) i_end =min(ite,ide-1)
1109 DO j =j_start-1,j_end
1111 DO i =i_start,i_end+1
1113 g_ss22(i,k,j) =g_s22(i,k,j)/2.0
1114 ss22(i,k,j) =s22(i,k,j)/2.0
1116 g_ss33(i,k,j) =g_s33(i,k,j)/2.0
1117 ss33(i,k,j) =s33(i,k,j)/2.0
1119 g_ss12(i,k,j) =g_s12(i,k,j)/2.0
1120 ss12(i,k,j) =s12(i,k,j)/2.0
1122 g_ss13(i,k,j) =g_s13(i,k,j)/2.0
1123 ss13(i,k,j) =s13(i,k,j)/2.0
1125 g_ss23(i,k,j) =g_s23(i,k,j)/2.0
1126 ss23(i,k,j) =s23(i,k,j)/2.0
1128 g_rr12(i,k,j) =g_r12(i,k,j)/2.0
1129 rr12(i,k,j) =r12(i,k,j)/2.0
1131 g_rr13(i,k,j) =g_r13(i,k,j)/2.0
1132 rr13(i,k,j) =r13(i,k,j)/2.0
1134 g_rr23(i,k,j) =g_r23(i,k,j)/2.0
1135 rr23(i,k,j) =r23(i,k,j)/2.0
1145 g_tkef(i,k,j) =0.5*(fnm(k)*(g_tke(i,k,j) +g_tke(i,k,j-1)) +fnp(k) &
1146 *(g_tke(i,k-1,j) +g_tke(i,k-1,j-1)))
1147 tkef(i,k,j) =0.5*(fnm(k)*(tke(i,k,j) +tke(i,k,j-1)) +fnp(k)*(tke(i,k-1,j) +tke(i,k-1,j-1)))
1149 g_smnsmnf(i,k,j) =0.5*(fnm(k)*(g_smnsmn(i,k,j) +g_smnsmn(i,k,j-1)) +fnp(k) &
1150 *(g_smnsmn(i,k-1,j) +g_smnsmn(i,k-1,j-1)))
1151 smnsmnf(i,k,j) =0.5*(fnm(k)*(smnsmn(i,k,j) +smnsmn(i,k,j-1)) +fnp(k)*(smnsmn(i,k-1,j) &
1152 +smnsmn(i,k-1,j-1)))
1154 g_ss22f(i,k,j) =0.5*(fnm(k)*(g_ss22(i,k,j) +g_ss22(i,k,j-1)) +fnp(k) &
1155 *(g_ss22(i,k-1,j) +g_ss22(i,k-1,j-1)))
1156 ss22f(i,k,j) =0.5*(fnm(k)*(ss22(i,k,j) +ss22(i,k,j-1)) +fnp(k)*(ss22(i,k-1,j) &
1159 g_ss33f(i,k,j) =0.5*(fnm(k)*(g_ss33(i,k,j) +g_ss33(i,k,j-1)) +fnp(k) &
1160 *(g_ss33(i,k-1,j) +g_ss33(i,k-1,j-1)))
1161 ss33f(i,k,j) =0.5*(fnm(k)*(ss33(i,k,j) +ss33(i,k,j-1)) +fnp(k)*(ss33(i,k-1,j) &
1164 g_ss12f(i,k,j) =0.5*(fnm(k)*(g_ss12(i,k,j) +g_ss12(i+1,k,j)) +fnp(k) &
1165 *(g_ss12(i,k-1,j) +g_ss12(i+1,k-1,j)))
1166 ss12f(i,k,j) =0.5*(fnm(k)*(ss12(i,k,j) +ss12(i+1,k,j)) +fnp(k)*(ss12(i,k-1,j) &
1169 g_rr12f(i,k,j) =0.5*(fnm(k)*(g_rr12(i,k,j) +g_rr12(i+1,k,j)) +fnp(k) &
1170 *(g_rr12(i,k-1,j) +g_rr12(i+1,k-1,j)))
1171 rr12f(i,k,j) =0.5*(fnm(k)*(rr12(i,k,j) +rr12(i+1,k,j)) +fnp(k)*(rr12(i,k-1,j) &
1174 g_ss13f(i,k,j) =0.25*(g_ss13(i,k,j) +g_ss13(i,k,j-1) +g_ss13(i+1,k,j-1) &
1176 ss13f(i,k,j) =0.25*(ss13(i,k,j) +ss13(i,k,j-1) +ss13(i+1,k,j-1) +ss13(i+1,k,j))
1178 g_rr13f(i,k,j) =0.25*(g_rr13(i,k,j) +g_rr13(i,k,j-1) +g_rr13(i+1,k,j-1) &
1180 rr13f(i,k,j) =0.25*(rr13(i,k,j) +rr13(i,k,j-1) +rr13(i+1,k,j-1) +rr13(i+1,k,j))
1186 IF( config_flags%sfs_opt .EQ. 1 ) THEN
1192 g_delta =0.33333333*(-dx *dy*g_rdzw(i,k,j)/(rdzw(i,k,j)*rdzw(i,k,j))) &
1193 *(dx *dy/rdzw(i,k,j))**(0.33333333 -1.0)
1194 delta =(dx *dy/rdzw(i,k,j))**0.33333333
1196 g_a =-1.0*2.0*(cs*g_delta)*(cs*delta)
1197 a =-1.0*(cs*delta)**2
1199 g_Tmpv1 =2.0*sqrt(2.0*smnsmnf(i,k,j))*g_ss23(i,k,j) +2.0*g_Sqrt(2.0* &
1200 g_smnsmnf(i,k,j), 2.0*smnsmnf(i,k,j))*ss23(i,k,j)
1201 Tmpv1 =2.0*sqrt(2.0*smnsmnf(i,k,j))*ss23(i,k,j)
1203 g_Tmpv2 =ss12f(i,k,j)*g_ss13f(i,k,j) +g_ss12f(i,k,j)*ss13f(i,k,j)
1204 Tmpv2 =ss12f(i,k,j)*ss13f(i,k,j)
1206 g_Tmpv3 =ss22f(i,k,j)*g_ss23(i,k,j) +g_ss22f(i,k,j)*ss23(i,k,j)
1207 Tmpv3 =ss22f(i,k,j)*ss23(i,k,j)
1209 g_Tmpv4 =ss23(i,k,j)*g_ss33f(i,k,j) +g_ss23(i,k,j)*ss33f(i,k,j)
1210 Tmpv4 =ss23(i,k,j)*ss33f(i,k,j)
1212 g_Tmpv5 =ss12f(i,k,j)*g_rr13f(i,k,j) +g_ss12f(i,k,j)*rr13f(i,k,j)
1213 Tmpv5 =ss12f(i,k,j)*rr13f(i,k,j)
1215 g_Tmpv6 =ss22f(i,k,j)*g_rr23(i,k,j) +g_ss22f(i,k,j)*rr23(i,k,j)
1216 Tmpv6 =ss22f(i,k,j)*rr23(i,k,j)
1218 g_Tmpv7 =ss13f(i,k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k,j)
1263 Tmpv4 =ss23(i,k,j)*ss33f(i,k,j)
1265 g_Tmpv5 =ss12f(i,k,j)*g_rr13f(i,k,j) +g_ss12f(i,k,j)*rr13f(i,k,j)
1266 Tmpv5 =ss12f(i,k,j)*rr13f(i,k,j)
1268 g_Tmpv6 =ss22f(i,k,j)*g_rr23(i,k,j) +g_ss22f(i,k,j)*rr23(i,k,j)
1269 Tmpv6 =ss22f(i,k,j)*rr23(i,k,j)
1271 g_Tmpv7 =ss13f(i,k,j)*g_rr12f(i,k,j) +g_ss13f(i,k,j)*rr12f(i,k,j)
1272 Tmpv7 =ss13f(i,k,j)*rr12f(i,k,j)
1274 g_Tmpv8 =ss33f(i,k,j)*g_rr23(i,k,j) +g_ss33f(i,k,j)*rr23(i,k,j)
1275 Tmpv8 =ss33f(i,k,j)*rr23(i,k,j)
1277 g_Tmpv9 =b*(c1*(g_Tmpv2 +g_Tmpv3 +g_Tmpv4) +c2*(g_Tmpv5 +g_Tmpv6 + &
1278 g_Tmpv7 -g_Tmpv8)) +g_b*(c1*(Tmpv2 +Tmpv3 +Tmpv4) +c2*(Tmpv5 +Tmpv6 +Tmpv7 -Tmpv8))
1279 Tmpv9 =b*(c1*(Tmpv2 +Tmpv3 +Tmpv4) +c2*(Tmpv5 +Tmpv6 +Tmpv7 -Tmpv8))
1281 g_Tmpv10 =a*(g_Tmpv1 +g_Tmpv9) +g_a*(Tmpv1 +Tmpv9)
1282 Tmpv10 =a*(Tmpv1 +Tmpv9)
1284 g_m23(i,k,j) =g_Tmpv10
1293 END SUBROUTINE g_calc_m23
1295 END MODULE g_module_sfs_nba
1297 ! REAL Function g_Sqrt(g_x,x)
1302 ! g_Sqrt =0.5*g_x/sqrt(x)
1305 ! Print*,'g_Sqrt is incorrectly evaluated by 0!'
1306 ! Print*,'Aborted from calc_m23'