/[lmdze]/trunk/dyn3d/disvert.f
ViewVC logotype

Diff of /trunk/dyn3d/disvert.f

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

revision 76 by guez, Fri Nov 15 18:45:49 2013 UTC revision 78 by guez, Wed Feb 5 17:51:07 2014 UTC
# Line 26  contains Line 26  contains
26      ! should be defined before this procedure is called.      ! should be defined before this procedure is called.
27    
28      use jumble, only: new_unit      use jumble, only: new_unit
29      use nr_util, only: pi      use nr_util, only: pi, assert
30      use unit_nml_m, only: unit_nml      use unit_nml_m, only: unit_nml
31    
32      ! Local:      ! Local:
# Line 41  contains Line 41  contains
41      INTEGER l, unit      INTEGER l, unit
42      REAL alpha, x(llm)      REAL alpha, x(llm)
43    
44      character(len=7):: s_sampling = "tropo"      character(len=7):: vert_sampling = "tropo"
45      ! (other allowed values are "param", "strato1", "strato" and "read")      ! other allowed values are "param", "strato" and "read"
46    
47      real:: h = 7. ! scale height, in km      real:: h = 7. ! scale height, in km
48      ! (used only if "s_sampling" == "param" or "strato1")      ! used only if vert_sampling == "param"
49    
50      ! These variables are used only in the case 's_sampling == "param"':      ! These variables are used only in the case vert_sampling == "param":
51      real:: deltaz = 0.04 ! épaisseur de la première couche      real:: deltaz = 0.04 ! épaisseur de la première couche
52      real:: beta = 1.3 ! facteur d'accroissement en haut      real:: beta = 1.3 ! facteur d'accroissement en haut
53      real:: k0 = 20. ! nombre de couches dans la transition surface      real:: k0 = 20. ! nombre de couches dans la transition surface
54      real:: k1 = 1.2 ! nombre de couches dans la transition haute      real:: k1 = 1.2 ! nombre de couches dans la transition haute
55    
56      REAL ZZ(llm + 1), DZ(llm) ! in km      namelist /disvert_nml/h, deltaz, beta, k0, k1, vert_sampling
   
     namelist /disvert_nml/h, deltaz, beta, k0, k1, s_sampling  
57    
58      !-----------------------------------------------------------------------      !-----------------------------------------------------------------------
59    
# Line 64  contains Line 62  contains
62      forall (l = 1: llm) nivsigs(l) = REAL(l)      forall (l = 1: llm) nivsigs(l) = REAL(l)
63      forall (l = 1: llm + 1) nivsig(l) = REAL(l)      forall (l = 1: llm + 1) nivsig(l) = REAL(l)
64    
     ! Compute "s":  
   
65      print *, "Enter namelist 'disvert_nml'."      print *, "Enter namelist 'disvert_nml'."
66      read(unit=*, nml=disvert_nml)      read(unit=*, nml=disvert_nml)
67      write(unit_nml, nml=disvert_nml)      write(unit_nml, nml=disvert_nml)
68    
69      select case (s_sampling)      select case (vert_sampling)
70      case ("param")      case ("param")
71         s(1) = 1.         s(1) = 1.
72         s(llm+1) = 0.         s(llm+1) = 0.
# Line 79  contains Line 75  contains
75              = cosh((l - 1) / k0) **(- alpha * k0 / h) &              = cosh((l - 1) / k0) **(- alpha * k0 / h) &
76              * exp(- alpha / h * tanh((llm - k1) / k0) &              * exp(- alpha / h * tanh((llm - k1) / k0) &
77              * beta **(l - 1 - (llm - k1)) / log(beta))              * beta **(l - 1 - (llm - k1)) / log(beta))
78           call compute_ab
79      case ("tropo")      case ("tropo")
80         s(1) = 1.         s(1) = 1.
81         s(llm+1) = 0.         s(llm+1) = 0.
# Line 89  contains Line 86  contains
86         DO l = llm, 2, -1         DO l = llm, 2, -1
87            s(l) = s(l+1) + ds(l)            s(l) = s(l+1) + ds(l)
88         ENDDO         ENDDO
     case ("strato1")  
        ! F. Lott 70 niveaux et plus  
        s(1) = 1.  
        s(llm+1) = 0.  
        forall (l = 1: llm) dz(l) = 1.56 + TANH(REAL(l - 12) / 5.) &  
                + TANH(REAL(l - llm) / 10.) / 2.  
   
        zz(1) = 0.  
        DO l = 2, llm + 1  
           zz(l) = zz(l - 1) + dz(l - 1)  
        end DO  
89    
90         s(2:llm) = (exp(- zz(2:llm) / h) - exp(- zz(llm + 1) / h)) &         call compute_ab
             / (1. - exp(- zz(llm + 1) / h))  
91      case ("strato")      case ("strato")
92         ! Recommended by F. Lott for a domain including the stratosphere         ! Recommended by F. Lott for a domain including the stratosphere
93         s(1) = 1.         s(1) = 1.
# Line 115  contains Line 100  contains
100         DO l = llm, 2, -1         DO l = llm, 2, -1
101            s(l) = s(l+1) + ds(l)            s(l) = s(l+1) + ds(l)
102         ENDDO         ENDDO
103    
104           call compute_ab
105      case("read")      case("read")
106           ! Read "ap" and "bp". First line is skipped (title line). "ap"
107           ! should be in Pa. First couple of values should correspond to
108           ! the surface, that is : "bp" should be in descending order.
109         call new_unit(unit)         call new_unit(unit)
110         open(unit, file="hybrid.csv", status="old", action="read", &         open(unit, file="hybrid.csv", status="old", action="read", &
111              position="rewind")              position="rewind")
112         read(unit, fmt=*) ! skip title line         read(unit, fmt=*) ! skip title line
113         do l = 1, llm + 1         do l = 1, llm + 1
114            read(unit, fmt=*) s(l)            read(unit, fmt=*) ap(l), bp(l)
115         end do         end do
116         close(unit)         close(unit)
117         ! Quick check:         ! Quick check:
118         if (s(1) /= 1. .or. s(llm + 1) /= 0. .or. s(1) <= s(2)) then         call assert(ap(1) == 0., ap(llm + 1) == 0., bp(1) == 1., &
119            print *, '"s" should be in descending order, from 1 to 0.'              bp(llm + 1) == 0., "disvert: bad ap or bp values")
           stop 1  
        end if  
120      case default      case default
121         print *, 'Wrong value for "s_sampling"'         print *, 'Wrong value for "vert_sampling"'
122         stop 1         stop 1
123      END select      END select
124    
     ! Calcul de "ap" et "bp" :  
     bp(:llm) = EXP(1. - 1. / s(:llm)**2)  
     bp(llm + 1) = 0.  
     ap = pa * (s - bp)  
   
125      forall (l = 1: llm) presnivs(l) = 0.5 &      forall (l = 1: llm) presnivs(l) = 0.5 &
126           * (ap(l) + bp(l) * preff + ap(l+1) + bp(l+1) * preff)           * (ap(l) + bp(l) * preff + ap(l+1) + bp(l+1) * preff)
127    
128      contains
129    
130        subroutine compute_ab
131    
132          ! Calcul de "ap" et "bp" :
133          bp(:llm) = EXP(1. - 1. / s(:llm)**2)
134          bp(llm + 1) = 0.
135          ap = pa * (s - bp)
136    
137        end subroutine compute_ab
138    
139    END SUBROUTINE disvert    END SUBROUTINE disvert
140    
141  end module disvert_m  end module disvert_m

Legend:
Removed from v.76  
changed lines
  Added in v.78

  ViewVC Help
Powered by ViewVC 1.1.21