source: LMDZ6/branches/Amaury_dev/libf/dyn3d_common/exner_hyb_m.F90 @ 5127

Last change on this file since 5127 was 5119, checked in by abarral, 3 months ago

enforce PRIVATE by default in several modules, expose PUBLIC as needed
move eigen.f90 to obsolete/
(lint) aslong the way

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1module exner_hyb_m
2
3  IMPLICIT NONE
4
5CONTAINS
6
7  SUBROUTINE exner_hyb( ngrid, ps, p, pks, pk, pkf )
8
9    !     Auteurs :  P.Le Van  , Fr. Hourdin  .
10    !    ..........
11
12    !    ....  ngrid, ps,p             sont des argum.d'entree  au sous-prog ...
13    !    ....  pks,pk,pkf   sont des argum.de sortie au sous-prog ...
14
15    !   ************************************************************************
16    !    Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des
17    !    couches .   Pk(l) sera calcule aux milieux  des couches l ,entre les
18    !    pressions p(l) et p(l+1) ,definis aux interfaces des llm couches .
19    !   ************************************************************************
20    !  .. N.B : Au sommet de l'atmosphere,  p(llm+1) = 0. , et ps et pks sont
21    !    la pression et la fonction d'Exner  au  sol  .
22
23    !                                 -------- z
24    !    A partir des relations  ( 1 ) p*dz(pk) = kappa *pk*dz(p)      et
25    !                            ( 2 ) pk(l) = alpha(l)+ beta(l)*pk(l-1)
26    !    ( voir note de Fr.Hourdin )  ,
27
28    !    on determine successivement , du haut vers le bas des couches, les
29    !    coef. alpha(llm),beta(llm) .,.,alpha(l),beta(l),,,alpha(2),beta(2),
30    !    puis pk(ij,1). Ensuite ,on calcule,du bas vers le haut des couches, 
31    !     pk(ij,l)  donne  par la relation (2),  pour l = 2 a l = llm .
32
33
34
35    USE comconst_mod, ONLY: jmp1, cpp, kappa, r
36    USE comvert_mod, ONLY: preff
37    USE lmdz_filtreg, ONLY: filtreg
38   
39    IMPLICIT NONE
40   
41    include "dimensions.h"
42    include "paramet.h"
43    include "comgeom.h"
44
45    INTEGER  ngrid
46    REAL p(ngrid,llmp1),pk(ngrid,llm)
47    REAL, optional:: pkf(ngrid,llm)
48    REAL ps(ngrid),pks(ngrid), alpha(ngrid,llm),beta(ngrid,llm)
49
50    !    .... variables locales   ...
51
52    INTEGER l, ij
53    REAL unpl2k,dellta
54
55    logical,save :: firstcall=.TRUE.
56    CHARACTER(LEN=*),parameter :: modname="exner_hyb"
57
58    ! Sanity check
59    IF (firstcall) THEN
60       ! sanity checks for Shallow Water case (1 vertical layer)
61       IF (llm==1) THEN
62          IF (kappa/=1) THEN
63             CALL abort_gcm(modname, &
64                  "kappa!=1 , but running in Shallow Water mode!!",42)
65          endif
66          IF (cpp/=r) THEN
67             CALL abort_gcm(modname, &
68                  "cpp!=r , but running in Shallow Water mode!!",42)
69          endif
70       endif ! of if (llm.EQ.1)
71
72       firstcall=.FALSE.
73    endif ! of if (firstcall)
74
75    ! Specific behaviour for Shallow Water (1 vertical layer) case:
76    IF (llm==1) THEN
77       ! Compute pks(:),pk(:),pkf(:)
78
79       DO   ij  = 1, ngrid
80          pks(ij) = (cpp/preff) * ps(ij)
81          pk(ij,1) = .5*pks(ij)
82       ENDDO
83
84       IF (present(pkf)) THEN
85          pkf = pk
86          CALL filtreg ( pkf, jmp1, llm, 2, 1, .TRUE., 1 )
87       end if
88
89       ! our work is done, exit routine
90       RETURN
91    endif ! of if (llm.EQ.1)
92
93    ! General case:
94
95    unpl2k    = 1.+ 2.* kappa
96
97    !     -------------
98    !     Calcul de pks
99    !     -------------
100
101    DO   ij  = 1, ngrid
102       pks(ij) = cpp * ( ps(ij)/preff ) ** kappa
103    ENDDO
104
105    !    .... Calcul des coeff. alpha et beta  pour la couche l = llm ..
106
107    DO     ij      = 1, ngrid
108       alpha(ij,llm) = 0.
109       beta (ij,llm) = 1./ unpl2k
110    ENDDO
111
112    !     ... Calcul des coeff. alpha et beta  pour l = llm-1  a l = 2 ...
113
114    DO l = llm -1 , 2 , -1
115
116       DO ij = 1, ngrid
117          dellta = p(ij,l)* unpl2k + p(ij,l+1)* ( beta(ij,l+1)-unpl2k )
118          alpha(ij,l)  = - p(ij,l+1) / dellta * alpha(ij,l+1)
119          beta (ij,l)  =   p(ij,l  ) / dellta   
120       ENDDO
121    ENDDO
122
123    !  ***********************************************************************
124    !     .....  Calcul de pk pour la couche 1 , pres du sol  ....
125
126    DO   ij   = 1, ngrid
127       pk(ij,1) = ( p(ij,1)*pks(ij) - 0.5*alpha(ij,2)*p(ij,2) )  / &
128            (  p(ij,1)* (1.+kappa) + 0.5*( beta(ij,2)-unpl2k )* p(ij,2) )
129    ENDDO
130
131    !    ..... Calcul de pk(ij,l) , pour l = 2 a l = llm  ........
132
133    DO l = 2, llm
134       DO   ij   = 1, ngrid
135          pk(ij,l) = alpha(ij,l) + beta(ij,l) * pk(ij,l-1)
136       ENDDO
137    ENDDO
138
139    IF (present(pkf)) THEN
140       !    calcul de pkf
141       pkf = pk
142       CALL filtreg ( pkf, jmp1, llm, 2, 1, .TRUE., 1 )
143    end if
144
145  END SUBROUTINE exner_hyb
146
147END MODULE exner_hyb_m
Note: See TracBrowser for help on using the repository browser.