source: LMDZ5/trunk/libf/phylmd/climb_wind_mod.F90 @ 2475

Last change on this file since 2475 was 2311, checked in by Ehouarn Millour, 9 years ago

Further modifications to enforce physics/dynamics separation:

  • moved iniprint.h and misc_mod back to dyn3d_common, as these should only be used by dynamics.
  • created print_control_mod in the physics to store flags prt_level, lunout, debug to be local to physics (should be used rather than iniprint.h)
  • created abort_physic.F90 , which does the same job as abort_gcm() did, but should be used instead when in physics.
  • reactivated inifis (turned it into a module, inifis_mod.F90) to initialize physical constants and print_control_mod flags.

EM

  • 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:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 13.0 KB
RevLine 
[782]1!
2MODULE climb_wind_mod
3!
4! Module to solve the verctical diffusion of the wind components "u" and "v".
5!
6  USE dimphy
7
8  IMPLICIT NONE
9
10  SAVE
11  PRIVATE
12 
13  REAL, DIMENSION(:),   ALLOCATABLE  :: alf1, alf2
14  !$OMP THREADPRIVATE(alf1,alf2)
15  REAL, DIMENSION(:,:), ALLOCATABLE  :: Kcoefm
16  !$OMP THREADPRIVATE(Kcoefm)
17  REAL, DIMENSION(:,:), ALLOCATABLE  :: Ccoef_U, Dcoef_U
18  !$OMP THREADPRIVATE(Ccoef_U, Dcoef_U)
19  REAL, DIMENSION(:,:), ALLOCATABLE  :: Ccoef_V, Dcoef_V
20  !$OMP THREADPRIVATE(Ccoef_V, Dcoef_V)
[1067]21  REAL, DIMENSION(:), ALLOCATABLE   :: Acoef_U, Bcoef_U
22  !$OMP THREADPRIVATE(Acoef_U, Bcoef_U)
23  REAL, DIMENSION(:), ALLOCATABLE   :: Acoef_V, Bcoef_V
24  !$OMP THREADPRIVATE(Acoef_V, Bcoef_V)
[782]25  LOGICAL                            :: firstcall=.TRUE.
26  !$OMP THREADPRIVATE(firstcall)
27
28 
[1067]29  PUBLIC :: climb_wind_down, climb_wind_up
[782]30
31CONTAINS
32!
33!****************************************************************************************
34!
35  SUBROUTINE climb_wind_init
36
37    INTEGER             :: ierr
38    CHARACTER(len = 20) :: modname = 'climb_wind_init'   
39
40!****************************************************************************************
41! Allocation of global module variables
42!
43!****************************************************************************************
44
45    ALLOCATE(alf1(klon), stat=ierr)
[2311]46    IF (ierr /= 0) CALL abort_physic(modname,'Pb in allocate alf1',1)
[782]47
48    ALLOCATE(alf2(klon), stat=ierr)
[2311]49    IF (ierr /= 0) CALL abort_physic(modname,'Pb in allocate alf2',1)
[782]50
51    ALLOCATE(Kcoefm(klon,klev), stat=ierr)
[2311]52    IF (ierr /= 0) CALL abort_physic(modname,'Pb in allocate Kcoefm',1)
[782]53
54    ALLOCATE(Ccoef_U(klon,klev), stat=ierr)
[2311]55    IF (ierr /= 0) CALL abort_physic(modname,'Pb in allocate Ccoef_U',1)
[782]56
57    ALLOCATE(Dcoef_U(klon,klev), stat=ierr)
[2311]58    IF (ierr /= 0) CALL abort_physic(modname,'Pb in allocation Dcoef_U',1)
[782]59
60    ALLOCATE(Ccoef_V(klon,klev), stat=ierr)
[2311]61    IF (ierr /= 0) CALL abort_physic(modname,'Pb in allocation Ccoef_V',1)
[782]62
63    ALLOCATE(Dcoef_V(klon,klev), stat=ierr)
[2311]64    IF (ierr /= 0) CALL abort_physic(modname,'Pb in allocation Dcoef_V',1)
[782]65
[1067]66    ALLOCATE(Acoef_U(klon), Bcoef_U(klon), Acoef_V(klon), Bcoef_V(klon), STAT=ierr)
67    IF ( ierr /= 0 )  PRINT*,' pb in allloc Acoef_U and Bcoef_U, ierr=', ierr
68
[782]69    firstcall=.FALSE.
70
71  END SUBROUTINE climb_wind_init
72!
73!****************************************************************************************
74!
[1067]75  SUBROUTINE climb_wind_down(knon, dtime, coef_in, pplay, paprs, temp, delp, u_old, v_old, &
[2159]76!!! nrlmd le 02/05/2011
77       Ccoef_U_out, Ccoef_V_out, Dcoef_U_out, Dcoef_V_out, &
78       Kcoef_m_out, alf_1_out, alf_2_out, &
79!!!
[1067]80       Acoef_U_out, Acoef_V_out, Bcoef_U_out, Bcoef_V_out)
[782]81!
82! This routine calculates for the wind components u and v,
83! recursivly the coefficients C and D in equation
84! X(k) = C(k) + D(k)*X(k-1), X=[u,v], k=[1,klev] is the vertical layer.
85!
86!
[2159]87
[782]88! Input arguments
89!****************************************************************************************
90    INTEGER, INTENT(IN)                      :: knon
91    REAL, INTENT(IN)                         :: dtime
92    REAL, DIMENSION(klon,klev), INTENT(IN)   :: coef_in
93    REAL, DIMENSION(klon,klev), INTENT(IN)   :: pplay ! pres au milieu de couche (Pa)
94    REAL, DIMENSION(klon,klev+1), INTENT(IN) :: paprs ! pression a inter-couche (Pa)
95    REAL, DIMENSION(klon,klev), INTENT(IN)   :: temp  ! temperature
96    REAL, DIMENSION(klon,klev), INTENT(IN)   :: delp
97    REAL, DIMENSION(klon,klev), INTENT(IN)   :: u_old
98    REAL, DIMENSION(klon,klev), INTENT(IN)   :: v_old
99
[1067]100! Output arguments
101!****************************************************************************************
102    REAL, DIMENSION(klon), INTENT(OUT)       :: Acoef_U_out
103    REAL, DIMENSION(klon), INTENT(OUT)       :: Acoef_V_out
104    REAL, DIMENSION(klon), INTENT(OUT)       :: Bcoef_U_out
105    REAL, DIMENSION(klon), INTENT(OUT)       :: Bcoef_V_out
106
[2159]107!!! nrlmd le 02/05/2011
108    REAL, DIMENSION(klon,klev), INTENT(OUT)  :: Ccoef_U_out
109    REAL, DIMENSION(klon,klev), INTENT(OUT)  :: Ccoef_V_out
110    REAL, DIMENSION(klon,klev), INTENT(OUT)  :: Dcoef_U_out
111    REAL, DIMENSION(klon,klev), INTENT(OUT)  :: Dcoef_V_out
112    REAL, DIMENSION(klon,klev), INTENT(OUT)  :: Kcoef_m_out
113    REAL, DIMENSION(klon), INTENT(OUT)       :: alf_1_out
114    REAL, DIMENSION(klon), INTENT(OUT)       :: alf_2_out
115!!!
116
[782]117! Local variables
118!****************************************************************************************
119    REAL, DIMENSION(klon)                    :: u1lay, v1lay
120    INTEGER                                  :: k, i
121
[2159]122! Include
123!****************************************************************************************
124    INCLUDE "YOMCST.h"
125    INCLUDE "compbl.h"   
[782]126
127!****************************************************************************************
128! Initialize module
129    IF (firstcall) CALL climb_wind_init
130
131!****************************************************************************************
132! Calculate the coefficients C and D in : u(k) = C(k) + D(k)*u(k-1)
133!
134!****************************************************************************************
135! - Define alpha (alf1 and alf2)
136    alf1(:) = 1.0
137    alf2(:) = 1.0 - alf1(:)
138
[1067]139! - Calculate the coefficients K
[782]140    Kcoefm(:,:) = 0.0
141    DO k = 2, klev
142       DO i=1,knon
[1067]143          Kcoefm(i,k) = coef_in(i,k)*RG*RG*dtime/(pplay(i,k-1)-pplay(i,k)) &
[782]144               *(paprs(i,k)*2/(temp(i,k)+temp(i,k-1))/RD)**2
145       END DO
146    END DO
147
148! - Calculate the coefficients C and D, component "u"
149    CALL calc_coef(knon, Kcoefm(:,:), delp(:,:), &
150         u_old(:,:), alf1(:), alf2(:),  &
[1067]151         Ccoef_U(:,:), Dcoef_U(:,:), Acoef_U(:), Bcoef_U(:))
[782]152
153! - Calculate the coefficients C and D, component "v"
154    CALL calc_coef(knon, Kcoefm(:,:), delp(:,:), &
155         v_old(:,:), alf1(:), alf2(:),  &
[1067]156         Ccoef_V(:,:), Dcoef_V(:,:), Acoef_V(:), Bcoef_V(:))
[782]157
[1067]158!****************************************************************************************
159! 6)
160! Return the first layer in output variables
161!
162!****************************************************************************************
163    Acoef_U_out = Acoef_U
164    Bcoef_U_out = Bcoef_U
165    Acoef_V_out = Acoef_V
166    Bcoef_V_out = Bcoef_V
167
[2159]168!****************************************************************************************
169! 7)
170! If Pbl is split, return also the other layers in output variables
171!
172!****************************************************************************************
173!!! jyg le 07/02/2012
174       IF (mod(iflag_pbl_split,2) .eq.1) THEN
175!!! nrlmd le 02/05/2011
176    DO k= 1, klev
177      DO i= 1, klon
178        Ccoef_U_out(i,k) = Ccoef_U(i,k)
179        Ccoef_V_out(i,k) = Ccoef_V(i,k)
180        Dcoef_U_out(i,k) = Dcoef_U(i,k)
181        Dcoef_V_out(i,k) = Dcoef_V(i,k)
182        Kcoef_m_out(i,k) = Kcoefm(i,k)
183      ENDDO
184    ENDDO
185    DO i= 1, klon
186      alf_1_out(i)   = alf1(i)
187      alf_2_out(i)   = alf2(i)
188    ENDDO
189!!!     
190       ENDIF  ! (mod(iflag_pbl_split,2) .eq.1)
191!!!
192
[782]193  END SUBROUTINE climb_wind_down
194!
195!****************************************************************************************
196!
[1067]197  SUBROUTINE calc_coef(knon, Kcoef, delp, X, alfa1, alfa2, Ccoef, Dcoef, Acoef, Bcoef)
[782]198!
[1067]199! Find the coefficients C and D in fonction of alfa, K and delp
[782]200!
201! Input arguments
202!****************************************************************************************
203    INTEGER, INTENT(IN)                      :: knon
[1067]204    REAL, DIMENSION(klon,klev), INTENT(IN)   :: Kcoef, delp
[782]205    REAL, DIMENSION(klon,klev), INTENT(IN)   :: X
206    REAL, DIMENSION(klon), INTENT(IN)        :: alfa1, alfa2
207
208! Output arguments
209!****************************************************************************************
[1067]210    REAL, DIMENSION(klon), INTENT(OUT)       :: Acoef, Bcoef
[782]211    REAL, DIMENSION(klon,klev), INTENT(OUT)  :: Ccoef, Dcoef
212 
213! local variables
214!****************************************************************************************
215    INTEGER                                  :: k, i
216    REAL                                     :: buf
217
[1067]218    INCLUDE "YOMCST.h"
[782]219!****************************************************************************************
220!
[1067]221
222! Calculate coefficients C and D at top level, k=klev
[782]223!
224    Ccoef(:,:) = 0.0
225    Dcoef(:,:) = 0.0
226
227    DO i = 1, knon
[1067]228       buf = delp(i,klev) + Kcoef(i,klev)
[782]229
[1067]230       Ccoef(i,klev) = X(i,klev)*delp(i,klev)/buf
[782]231       Dcoef(i,klev) = Kcoef(i,klev)/buf
232    END DO
233   
234!
[1067]235! Calculate coefficients C and D at top level (klev-1) <= k <= 2
[782]236!
237    DO k=(klev-1),2,-1
238       DO i = 1, knon
[1067]239          buf = delp(i,k) + Kcoef(i,k) + Kcoef(i,k+1)*(1.-Dcoef(i,k+1))
[782]240         
[1067]241          Ccoef(i,k) = (X(i,k)*delp(i,k) + Kcoef(i,k+1)*Ccoef(i,k+1))/buf
[782]242          Dcoef(i,k) = Kcoef(i,k)/buf
243       END DO
244    END DO
245
246!
[1067]247! Calculate coeffiecent A and B at surface
248!
[782]249    DO i = 1, knon
[1067]250       buf = delp(i,1) + Kcoef(i,2)*(1-Dcoef(i,2))
251       Acoef(i) = (X(i,1)*delp(i,1) + Kcoef(i,2)*Ccoef(i,2))/buf
252       Bcoef(i) = -RG/buf
[782]253    END DO
254
255  END SUBROUTINE calc_coef
256!
257!****************************************************************************************
258!
259
[1067]260  SUBROUTINE climb_wind_up(knon, dtime, u_old, v_old, flx_u1, flx_v1,  &
[2159]261!!! nrlmd le 02/05/2011
262       Acoef_U_in, Acoef_V_in, Bcoef_U_in, Bcoef_V_in, &
263       Ccoef_U_in, Ccoef_V_in, Dcoef_U_in, Dcoef_V_in, &
264       Kcoef_m_in, &
265!!!
[782]266       flx_u_new, flx_v_new, d_u_new, d_v_new)
267!
[1067]268! Diffuse the wind components from the surface layer and up to the top layer.
269! Coefficents A, B, C and D are known from before. Start values for the diffusion are the
270! momentum fluxes at surface.
[782]271!
[1067]272! u(k=1) = A + B*flx*dtime
273! u(k)   = C(k) + D(k)*u(k-1)  [2 <= k <= klev]
[782]274!
275!****************************************************************************************
276
277! Input arguments
278!****************************************************************************************
279    INTEGER, INTENT(IN)                     :: knon
280    REAL, INTENT(IN)                        :: dtime
281    REAL, DIMENSION(klon,klev), INTENT(IN)  :: u_old
282    REAL, DIMENSION(klon,klev), INTENT(IN)  :: v_old
[1067]283    REAL, DIMENSION(klon), INTENT(IN)       :: flx_u1, flx_v1 ! momentum flux
[782]284
[2159]285!!! nrlmd le 02/05/2011
286    REAL, DIMENSION(klon), INTENT(IN)       :: Acoef_U_in,Acoef_V_in, Bcoef_U_in, Bcoef_V_in
287    REAL, DIMENSION(klon,klev), INTENT(IN)  :: Ccoef_U_in, Ccoef_V_in, Dcoef_U_in, Dcoef_V_in
288    REAL, DIMENSION(klon,klev), INTENT(IN)  :: Kcoef_m_in
289!!!
290
[782]291! Output arguments
292!****************************************************************************************
293    REAL, DIMENSION(klon,klev), INTENT(OUT) :: flx_u_new, flx_v_new
294    REAL, DIMENSION(klon,klev), INTENT(OUT) :: d_u_new, d_v_new
295
296! Local variables
297!****************************************************************************************
298    REAL, DIMENSION(klon,klev)              :: u_new, v_new
299    INTEGER                                 :: k, i
[2159]300
301! Include
302!****************************************************************************************
303    INCLUDE "YOMCST.h"
304    INCLUDE "compbl.h"   
[782]305   
306!
307!****************************************************************************************
308
[2159]309!!! jyg le 07/02/2012
310       IF (mod(iflag_pbl_split,2) .eq.1) THEN
311!!! nrlmd le 02/05/2011
312    DO i = 1, knon
313      Acoef_U(i)=Acoef_U_in(i)
314      Acoef_V(i)=Acoef_V_in(i)
315      Bcoef_U(i)=Bcoef_U_in(i)
316      Bcoef_V(i)=Bcoef_V_in(i)
317    ENDDO
318    DO k = 1, klev
319      DO i = 1, knon
320        Ccoef_U(i,k)=Ccoef_U_in(i,k)
321        Ccoef_V(i,k)=Ccoef_V_in(i,k)
322        Dcoef_U(i,k)=Dcoef_U_in(i,k)
323        Dcoef_V(i,k)=Dcoef_V_in(i,k)
324        Kcoefm(i,k)=Kcoef_m_in(i,k)
325      ENDDO
326    ENDDO
327!!!
328       ENDIF  ! (mod(iflag_pbl_split,2) .eq.1)
329!!!
330
[782]331! Niveau 1
332    DO i = 1, knon
[1067]333       u_new(i,1) = Acoef_U(i) + Bcoef_U(i)*flx_u1(i)*dtime
334       v_new(i,1) = Acoef_V(i) + Bcoef_V(i)*flx_v1(i)*dtime
[782]335    END DO
336
337! Niveau 2 jusqu'au sommet klev
338    DO k = 2, klev
339       DO i=1, knon
340          u_new(i,k) = Ccoef_U(i,k) + Dcoef_U(i,k) * u_new(i,k-1)
341          v_new(i,k) = Ccoef_V(i,k) + Dcoef_V(i,k) * v_new(i,k-1)
342       END DO
343    END DO
344
345!****************************************************************************************
346! Calcul flux
347!
348!== flux_u/v est le flux de moment angulaire (positif vers bas)
349!== dont l'unite est: (kg m/s)/(m**2 s)
350!
351!****************************************************************************************
352!
353    flx_u_new(:,:) = 0.0
354    flx_v_new(:,:) = 0.0
355
[1067]356    flx_u_new(1:knon,1)=flx_u1(1:knon)
357    flx_v_new(1:knon,1)=flx_v1(1:knon)
[782]358
359! Niveau 2->klev
360    DO k = 2, klev
361       DO i = 1, knon
362          flx_u_new(i,k) = Kcoefm(i,k)/RG/dtime * &
363               (u_new(i,k)-u_new(i,k-1))
364         
365          flx_v_new(i,k) = Kcoefm(i,k)/RG/dtime * &
366               (v_new(i,k)-v_new(i,k-1))
367       END DO
368    END DO
369
370!****************************************************************************************
371! Calcul tendances
372!
373!****************************************************************************************
374    d_u_new(:,:) = 0.0
375    d_v_new(:,:) = 0.0
376    DO k = 1, klev
377       DO i = 1, knon
378          d_u_new(i,k) = u_new(i,k) - u_old(i,k)
379          d_v_new(i,k) = v_new(i,k) - v_old(i,k)
380       END DO
381    END DO
382
383  END SUBROUTINE climb_wind_up
384!
385!****************************************************************************************
386!
387END MODULE climb_wind_mod
Note: See TracBrowser for help on using the repository browser.