GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: phylmd/cltrac.F90 Lines: 0 45 0.0 %
Date: 2023-06-30 12:51:15 Branches: 0 26 0.0 %

Line Branch Exec Source
1
!
2
! $Id $
3
!
4
SUBROUTINE cltrac(dtime,coef,t,tr,flux,paprs,pplay,delp, &
5
                  d_tr,d_tr_dry,flux_tr_dry)                    !jyg
6
7
  USE dimphy
8
  IMPLICIT NONE
9
!======================================================================
10
! Auteur(s): O. Boucher (LOA/LMD) date: 19961127
11
!            inspire de clvent
12
! Objet: diffusion verticale de traceurs avec flux fixe a la surface
13
!        ou/et flux du type c-drag
14
!
15
! Arguments:
16
!-----------
17
! dtime.......input-R- intervalle du temps (en secondes)
18
! coef........input-R- le coefficient d'echange (m**2/s) l>1
19
! t...........input-R- temperature (K)
20
! tr..........input-R- la q. de traceurs
21
! flux........input-R- le flux de traceurs a la surface
22
! paprs.......input-R- pression a inter-couche (Pa)
23
! pplay.......input-R- pression au milieu de couche (Pa)
24
! delp........input-R- epaisseur de couche (Pa)
25
! cdrag.......input-R- cdrag pour le flux de surface (non active)
26
! tr0.........input-R- traceurs a la surface ou dans l'ocean (non active)
27
! d_tr........output-R- le changement de tr
28
! d_tr_dry....output-R- le changement de tr du au depot sec (1st layer)
29
! flux_tr_dry.output-R- depot sec
30
!!! flux_tr..output-R- flux de tr
31
!======================================================================
32
  include "YOMCST.h"
33
!
34
! Entree
35
!
36
  REAL,INTENT(IN)                        :: dtime
37
  REAL,DIMENSION(klon,klev),INTENT(IN)   :: coef
38
  REAL,DIMENSION(klon,klev),INTENT(IN)   :: t, tr
39
  REAL,DIMENSION(klon),INTENT(IN)        :: flux !(at/s/m2)
40
  REAL,DIMENSION(klon,klev+1),INTENT(IN) :: paprs
41
  REAL,DIMENSION(klon,klev),INTENT(IN)   :: pplay, delp
42
!
43
! Sorties
44
!
45
  REAL ,DIMENSION(klon,klev),INTENT(OUT) :: d_tr
46
  REAL ,DIMENSION(klon),INTENT(OUT)       :: d_tr_dry          !jyg
47
  REAL ,DIMENSION(klon),INTENT(OUT)       :: flux_tr_dry       !jyg
48
!  REAL ,DIMENSION(klon,klev),INTENT(OUT) :: flux_tr
49
!
50
! Local
51
!
52
  INTEGER                   :: i, k
53
  REAL,DIMENSION(klon)      :: cdrag, tr0
54
  REAL,DIMENSION(klon,klev) :: zx_ctr
55
  REAL,DIMENSION(klon,klev) :: zx_dtr
56
  REAL,DIMENSION(klon)      :: zx_buf
57
  REAL,DIMENSION(klon,klev) :: zx_coef
58
  REAL,DIMENSION(klon,klev) :: local_tr
59
  REAL,DIMENSION(klon)      :: zx_alf1,zx_alf2,zx_flux
60
61
!======================================================================
62
63
  DO k = 1, klev
64
     DO i = 1, klon
65
        local_tr(i,k) = tr(i,k)
66
     ENDDO
67
  ENDDO
68
69
!======================================================================
70
71
  DO i = 1, klon
72
     zx_alf1(i) = (paprs(i,1)-pplay(i,2))/(pplay(i,1)-pplay(i,2))
73
     zx_alf2(i) = 1.0 - zx_alf1(i)
74
     flux_tr_dry(i) = -flux(i)*dtime                              !jyg
75
     zx_flux(i) =  flux_tr_dry(i)*RG                              !jyg
76
!!     zx_flux(i) =  -flux(i)*dtime*RG                            !jyg
77
! Pour le moment le flux est prescrit cdrag et zx_coef(1) vaut 0
78
     cdrag(i) = 0.0
79
     tr0(i) = 0.0
80
     zx_coef(i,1) = cdrag(i)*dtime*RG
81
     zx_ctr(i,1)=0.
82
     zx_dtr(i,1)=0.
83
  ENDDO
84
85
!======================================================================
86
87
  DO k = 2, klev
88
     DO i = 1, klon
89
        zx_coef(i,k) = coef(i,k)*RG/(pplay(i,k-1)-pplay(i,k))   &
90
             *(paprs(i,k)*2/(t(i,k)+t(i,k-1))/RD)**2
91
        zx_coef(i,k) = zx_coef(i,k)*dtime*RG
92
     ENDDO
93
  ENDDO
94
95
!======================================================================
96
97
  DO i = 1, klon
98
     zx_buf(i) = delp(i,1) + zx_coef(i,1)*zx_alf1(i) + zx_coef(i,2)
99
     !
100
     zx_ctr(i,2) = (local_tr(i,1)*delp(i,1)+                  &
101
          zx_coef(i,1)*tr0(i)-zx_flux(i))/zx_buf(i)
102
     !
103
     zx_dtr(i,2) = (zx_coef(i,2)-zx_alf2(i)*zx_coef(i,1)) /   &
104
          zx_buf(i)
105
     d_tr_dry(i) = -zx_flux(i)/zx_buf(i)                          !jyg
106
  ENDDO
107
108
  DO k = 3, klev
109
     DO i = 1, klon
110
        zx_buf(i) = delp(i,k-1) + zx_coef(i,k)      &
111
             + zx_coef(i,k-1)*(1.-zx_dtr(i,k-1))
112
        zx_ctr(i,k) = (local_tr(i,k-1)*delp(i,k-1)  &
113
             +zx_coef(i,k-1)*zx_ctr(i,k-1) )/zx_buf(i)
114
        zx_dtr(i,k) = zx_coef(i,k)/zx_buf(i)
115
     ENDDO
116
  ENDDO
117
118
  DO i = 1, klon
119
     local_tr(i,klev) = ( local_tr(i,klev)*delp(i,klev) &
120
          +zx_coef(i,klev)*zx_ctr(i,klev) )             &
121
          / ( delp(i,klev) + zx_coef(i,klev)            &
122
          -zx_coef(i,klev)*zx_dtr(i,klev) )
123
  ENDDO
124
125
  DO k = klev-1, 1, -1
126
     DO i = 1, klon
127
        local_tr(i,k) = zx_ctr(i,k+1) + zx_dtr(i,k+1)*local_tr(i,k+1)
128
     ENDDO
129
  ENDDO
130
131
!======================================================================
132
!== flux_tr est le flux de traceur (positif vers bas)
133
!      DO i = 1, klon
134
!         flux_tr(i,1) = zx_coef(i,1)/(RG*dtime)
135
!      ENDDO
136
!      DO k = 2, klev
137
!      DO i = 1, klon
138
!         flux_tr(i,k) = zx_coef(i,k)/(RG*dtime)
139
!     .               * (local_tr(i,k)-local_tr(i,k-1))
140
!      ENDDO
141
!      ENDDO
142
!======================================================================
143
  DO k = 1, klev
144
     DO i = 1, klon
145
        d_tr(i,k) = local_tr(i,k) - tr(i,k)
146
     ENDDO
147
  ENDDO
148
149
END SUBROUTINE cltrac