GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: dyn3d/addfi.F Lines: 51 56 91.1 %
Date: 2023-06-30 12:51:15 Branches: 45 52 86.5 %

Line Branch Exec Source
1
!
2
! $Id: addfi.F 2598 2016-07-22 09:28:39Z emillour $
3
!
4
288
      SUBROUTINE addfi(pdt, leapf, forward,
5
     S          pucov, pvcov, pteta, pq   , pps ,
6
     S          pdufi, pdvfi, pdhfi,pdqfi, pdpfi  )
7
8
      USE infotrac, ONLY : nqtot
9
      USE control_mod, ONLY : planet_type
10
      IMPLICIT NONE
11
c
12
c=======================================================================
13
c
14
c    Addition of the physical tendencies
15
c
16
c    Interface :
17
c    -----------
18
c
19
c      Input :
20
c      -------
21
c      pdt                    time step of integration
22
c      leapf                  logical
23
c      forward                logical
24
c      pucov(ip1jmp1,llm)     first component of the covariant velocity
25
c      pvcov(ip1ip1jm,llm)    second component of the covariant velocity
26
c      pteta(ip1jmp1,llm)     potential temperature
27
c      pts(ip1jmp1,llm)       surface temperature
28
c      pdufi(ip1jmp1,llm)     |
29
c      pdvfi(ip1jm,llm)       |   respective
30
c      pdhfi(ip1jmp1)         |      tendencies
31
c      pdtsfi(ip1jmp1)        |
32
c
33
c      Output :
34
c      --------
35
c      pucov
36
c      pvcov
37
c      ph
38
c      pts
39
c
40
c
41
c=======================================================================
42
c
43
c-----------------------------------------------------------------------
44
c
45
c    0.  Declarations :
46
c    ------------------
47
c
48
      include "dimensions.h"
49
      include "paramet.h"
50
      include "comgeom.h"
51
c
52
c    Arguments :
53
c    -----------
54
c
55
      REAL,INTENT(IN) :: pdt ! time step for the integration (s)
56
c
57
      REAL,INTENT(INOUT) :: pvcov(ip1jm,llm) ! covariant meridional wind
58
      REAL,INTENT(INOUT) :: pucov(ip1jmp1,llm) ! covariant zonal wind
59
      REAL,INTENT(INOUT) :: pteta(ip1jmp1,llm) ! potential temperature
60
      REAL,INTENT(INOUT) :: pq(ip1jmp1,llm,nqtot) ! tracers
61
      REAL,INTENT(INOUT) :: pps(ip1jmp1) ! surface pressure (Pa)
62
c respective tendencies (.../s) to add
63
      REAL,INTENT(IN) :: pdvfi(ip1jm,llm)
64
      REAL,INTENT(IN) :: pdufi(ip1jmp1,llm)
65
      REAL,INTENT(IN) :: pdqfi(ip1jmp1,llm,nqtot)
66
      REAL,INTENT(IN) :: pdhfi(ip1jmp1,llm)
67
      REAL,INTENT(IN) :: pdpfi(ip1jmp1)
68
c
69
      LOGICAL,INTENT(IN) :: leapf,forward ! not used
70
c
71
c
72
c    Local variables :
73
c    -----------------
74
c
75
      REAL xpn(iim),xps(iim),tpn,tps
76
      INTEGER j,k,iq,ij
77
      REAL,PARAMETER :: qtestw = 1.0e-15
78
      REAL,PARAMETER :: qtestt = 1.0e-40
79
80
      REAL SSUM
81
c
82
c-----------------------------------------------------------------------
83
84
11520
      DO k = 1,llm
85
12243168
         DO j = 1,ip1jmp1
86
12242880
            pteta(j,k)= pteta(j,k) + pdhfi(j,k) * pdt
87
         ENDDO
88
      ENDDO
89
90
11520
      DO  k    = 1, llm
91
370656
       DO  ij   = 1, iim
92
359424
         xpn(ij) = aire(   ij   ) * pteta(  ij    ,k)
93
370656
         xps(ij) = aire(ij+ip1jm) * pteta(ij+ip1jm,k)
94
       ENDDO
95
11232
       tpn      = SSUM(iim,xpn,1)/ apoln
96
11232
       tps      = SSUM(iim,xps,1)/ apols
97
98
382176
       DO ij   = 1, iip1
99
370656
         pteta(   ij   ,k)  = tpn
100
381888
         pteta(ij+ip1jm,k)  = tps
101
       ENDDO
102
      ENDDO
103
c
104
105
11520
      DO k = 1,llm
106
11501856
         DO j = iip2,ip1jm
107
11501568
            pucov(j,k)= pucov(j,k) + pdufi(j,k) * pdt
108
         ENDDO
109
      ENDDO
110
111
11520
      DO k = 1,llm
112
11872512
         DO j = 1,ip1jm
113
11872224
            pvcov(j,k)= pvcov(j,k) + pdvfi(j,k) * pdt
114
         ENDDO
115
      ENDDO
116
117
c
118
313920
      DO j = 1,ip1jmp1
119
313920
         pps(j) = pps(j) + pdpfi(j) * pdt
120
      ENDDO
121
122
288
      if (planet_type=="earth") then
123
      ! earth case, special treatment for first 2 tracers (water)
124
864
       DO iq = 1, 2
125
23328
         DO k = 1,llm
126
24486336
            DO j = 1,ip1jmp1
127
24463296
               pq(j,k,iq)= pq(j,k,iq) + pdqfi(j,k,iq) * pdt
128
24485760
               pq(j,k,iq)= AMAX1( pq(j,k,iq), qtestw )
129
            ENDDO
130
         ENDDO
131
       ENDDO
132
133
1152
       DO iq = 3, nqtot
134
34848
         DO k = 1,llm
135
36729504
            DO j = 1,ip1jmp1
136
36694944
               pq(j,k,iq)= pq(j,k,iq) + pdqfi(j,k,iq) * pdt
137
36728640
               pq(j,k,iq)= AMAX1( pq(j,k,iq), qtestt )
138
            ENDDO
139
         ENDDO
140
       ENDDO
141
      else
142
      ! general case, treat all tracers equally)
143
       DO iq = 1, nqtot
144
         DO k = 1,llm
145
            DO j = 1,ip1jmp1
146
               pq(j,k,iq)= pq(j,k,iq) + pdqfi(j,k,iq) * pdt
147
               pq(j,k,iq)= AMAX1( pq(j,k,iq), qtestt )
148
            ENDDO
149
         ENDDO
150
       ENDDO
151
      endif ! of if (planet_type=="earth")
152
153
154
9504
      DO  ij   = 1, iim
155
9216
        xpn(ij) = aire(   ij   ) * pps(  ij     )
156
9504
        xps(ij) = aire(ij+ip1jm) * pps(ij+ip1jm )
157
      ENDDO
158
288
      tpn      = SSUM(iim,xpn,1)/apoln
159
288
      tps      = SSUM(iim,xps,1)/apols
160
161
9792
      DO ij   = 1, iip1
162
9504
        pps (   ij     )  = tpn
163
9792
        pps ( ij+ip1jm )  = tps
164
      ENDDO
165
166
167
1728
      DO iq = 1, nqtot
168
57888
        DO  k    = 1, llm
169
1853280
          DO  ij   = 1, iim
170
1797120
            xpn(ij) = aire(   ij   ) * pq(  ij    ,k,iq)
171
1853280
            xps(ij) = aire(ij+ip1jm) * pq(ij+ip1jm,k,iq)
172
          ENDDO
173
56160
          tpn      = SSUM(iim,xpn,1)/apoln
174
56160
          tps      = SSUM(iim,xps,1)/apols
175
176
1910880
          DO ij   = 1, iip1
177
1853280
            pq (   ij   ,k,iq)  = tpn
178
1909440
            pq (ij+ip1jm,k,iq)  = tps
179
          ENDDO
180
        ENDDO
181
      ENDDO
182
183
288
      RETURN
184
      END