/[lmdze]/trunk/Sources/dyn3d/fxhyp.f
ViewVC logotype

Diff of /trunk/Sources/dyn3d/fxhyp.f

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 143 by guez, Tue May 26 17:46:03 2015 UTC revision 144 by guez, Wed Jun 10 16:46:46 2015 UTC
# Line 22  contains Line 22  contains
22      use invert_zoom_x_m, only: invert_zoom_x, nmax      use invert_zoom_x_m, only: invert_zoom_x, nmax
23      use nr_util, only: pi, pi_d, twopi, twopi_d, arth      use nr_util, only: pi, pi_d, twopi, twopi_d, arth
24      use principal_cshift_m, only: principal_cshift      use principal_cshift_m, only: principal_cshift
25        use tanh_cautious_m, only: tanh_cautious
26    
27      REAL, intent(out):: xprimm025(:), rlonv(:), xprimv(:) ! (iim + 1)      REAL, intent(out):: xprimm025(:), rlonv(:), xprimv(:) ! (iim + 1)
28      real, intent(out):: rlonu(:), xprimu(:), xprimp025(:) ! (iim + 1)      real, intent(out):: rlonu(:), xprimu(:), xprimp025(:) ! (iim + 1)
# Line 33  contains Line 34  contains
34      DOUBLE PRECISION xtild(0:2 * nmax)      DOUBLE PRECISION xtild(0:2 * nmax)
35      DOUBLE PRECISION fhyp(nmax:2 * nmax), ffdx, beta, Xprimt(0:2 * nmax)      DOUBLE PRECISION fhyp(nmax:2 * nmax), ffdx, beta, Xprimt(0:2 * nmax)
36      DOUBLE PRECISION Xf(0:2 * nmax), xxpr(2 * nmax)      DOUBLE PRECISION Xf(0:2 * nmax), xxpr(2 * nmax)
     DOUBLE PRECISION fa, fb  
37      INTEGER i, is2      INTEGER i, is2
38      DOUBLE PRECISION xmoy, fxm      DOUBLE PRECISION, dimension(nmax + 1:2 * nmax):: xmoy, fxm
39    
40      !----------------------------------------------------------------------      !----------------------------------------------------------------------
41    
# Line 56  contains Line 56  contains
56      else test_grossismx      else test_grossismx
57         dzoom = dzoomx * twopi_d         dzoom = dzoomx * twopi_d
58         xtild = arth(- pi_d, pi_d / nmax, 2 * nmax + 1)         xtild = arth(- pi_d, pi_d / nmax, 2 * nmax + 1)
59           forall (i = nmax + 1:2 * nmax) xmoy(i) = 0.5d0 * (xtild(i-1) + xtild(i))
60    
61         ! Compute fhyp:         ! Compute fhyp:
62         DO i = nmax, 2 * nmax         fhyp(nmax + 1:2 * nmax - 1) = tanh_cautious(taux * (dzoom / 2. &
63            fa = taux * (dzoom / 2. - xtild(i))              - xtild(nmax + 1:2 * nmax - 1)), xtild(nmax + 1:2 * nmax - 1) &
64            fb = xtild(i) * (pi_d - xtild(i))              * (pi_d - xtild(nmax + 1:2 * nmax - 1)))
65           fhyp(nmax) = 1d0
66            IF (200. * fb < - fa) THEN         fhyp(2 * nmax) = -1d0
              fhyp(i) = - 1.  
           ELSE IF (200. * fb < fa) THEN  
              fhyp(i) = 1.  
           ELSE  
              IF (ABS(fa) < 1e-13 .AND. ABS(fb) < 1e-13) THEN  
                 IF (200. * fb + fa < 1e-10) THEN  
                    fhyp(i) = - 1.  
                 ELSE IF (200. * fb - fa < 1e-10) THEN  
                    fhyp(i) = 1.  
                 END IF  
              ELSE  
                 fhyp(i) = TANH(fa / fb)  
              END IF  
           END IF  
67    
68            IF (xtild(i) == 0.) fhyp(i) = 1.         fxm = tanh_cautious(taux * (dzoom / 2. - xmoy), xmoy * (pi_d - xmoy))
           IF (xtild(i) == pi_d) fhyp(i) = -1.  
        END DO  
69    
70         ! Calcul de beta         ! Calcul de beta
71    
72         ffdx = 0.         ffdx = 0.
73    
74         DO i = nmax + 1, 2 * nmax         DO i = nmax + 1, 2 * nmax
75            xmoy = 0.5 * (xtild(i-1) + xtild(i))            ffdx = ffdx + fxm(i) * (xtild(i) - xtild(i-1))
           fa = taux * (dzoom / 2. - xmoy)  
           fb = xmoy * (pi_d - xmoy)  
   
           IF (200. * fb < - fa) THEN  
              fxm = - 1.  
           ELSE IF (200. * fb < fa) THEN  
              fxm = 1.  
           ELSE  
              IF (ABS(fa) < 1e-13 .AND. ABS(fb) < 1e-13) THEN  
                 IF (200. * fb + fa < 1e-10) THEN  
                    fxm = - 1.  
                 ELSE IF (200. * fb - fa < 1e-10) THEN  
                    fxm = 1.  
                 END IF  
              ELSE  
                 fxm = TANH(fa / fb)  
              END IF  
           END IF  
   
           IF (xmoy == 0.) fxm = 1.  
           IF (xmoy == pi_d) fxm = -1.  
   
           ffdx = ffdx + fxm * (xtild(i) - xtild(i-1))  
76         END DO         END DO
77    
78         print *, "ffdx = ", ffdx         print *, "ffdx = ", ffdx
79         beta = (grossismx * ffdx - pi_d) / (ffdx - pi_d)         beta = (pi_d - grossismx * ffdx) / (pi_d - ffdx)
80         print *, "beta = ", beta         print *, "beta = ", beta
81    
82         IF (2. * beta - grossismx <= 0.) THEN         IF (2. * beta - grossismx <= 0.) THEN
# Line 129  contains Line 91  contains
91    
92         ! Calcul de Xf         ! Calcul de Xf
93    
94         DO i = nmax + 1, 2 * nmax         xxpr(nmax + 1:2 * nmax) = beta + (grossismx - beta) * fxm
           xmoy = 0.5 * (xtild(i-1) + xtild(i))  
           fa = taux * (dzoom / 2. - xmoy)  
           fb = xmoy * (pi_d - xmoy)  
   
           IF (200. * fb < - fa) THEN  
              fxm = - 1.  
           ELSE IF (200. * fb < fa) THEN  
              fxm = 1.  
           ELSE  
              fxm = TANH(fa / fb)  
           END IF  
   
           IF (xmoy == 0.) fxm = 1.  
           IF (xmoy == pi_d) fxm = -1.  
           xxpr(i) = beta + (grossismx - beta) * fxm  
        END DO  
   
95         xxpr(:nmax) = xxpr(2 * nmax:nmax + 1:- 1)         xxpr(:nmax) = xxpr(2 * nmax:nmax + 1:- 1)
96    
97         Xf(0) = - pi_d         Xf(0) = - pi_d

Legend:
Removed from v.143  
changed lines
  Added in v.144

  ViewVC Help
Powered by ViewVC 1.1.21