source: trunk/LMDZ.MARS/libf/phymars/lwxd.F @ 3807

Last change on this file since 3807 was 3757, checked in by emillour, 6 weeks ago

Mars PCM:
More code tidying: puting routines in modules and modernizing some old
constructs. Tested to not change results with respect to previous version.
EM

File size: 9.4 KB
Line 
1      module lwxd_mod
2     
3      implicit none
4     
5      contains
6     
7      subroutine lwxd (ig0,kdlon,kflev,emis
8     .                ,aer_t,co2_u,co2_up)
9
10c----------------------------------------------------------------------
11c     LWXD   computes transmission function and exchange coefficiants
12c                        for distant layers
13c                          (co2 / aerosols)
14c                       (bands 1 and 2 of co2)
15c----------------------------------------------------------------------
16
17c              |---|---|---|---|---|---|---|---|
18c   kflev+1    |   |   |   |   |   |   |   | 0 |  (space)
19c              |---|---|---|---|---|---|---|---|
20c    kflev     |   |***|***|***|***|   | 0 |   |
21c              |---|---|---|---|---|---|---|---|
22c     ...      |   |***|***|***|   | 0 |   |   |
23c              |---|---|---|---|---|---|---|---|
24c      4       |   |***|***|   | 0 |   |***|   |
25c              |---|---|---|---|---|---|---|---|
26c      3       |   |***|   | 0 |   |***|***|   |
27c              |---|---|---|---|---|---|---|---|
28c      2       |   |   | 0 |   |   |***|***|   |
29c              |---|---|---|---|---|---|---|---|
30c      1       |   | 0 |   |   |***|***|***|   |
31c              |---|---|---|---|---|---|---|---|
32c      0       | 0 |   |   |***|***|***|***|   |  (ground)
33c              |---|---|---|---|---|---|---|---|
34c                0   1   2   3   4  ...  k |k+1
35c             (ground)                    (space)
36
37c  (*)  xi computed in this subroutine
38c----------------------------------------------------------------------
39
40      use dimradmars_mod, only: ndlon, nuco2, nflev, ndlo2
41      use yomlw_h, only: nlaylte, xi, xi_emis
42      use callkeys_mod, only: callemis
43      use lwtt_mod, only: lwtt
44      implicit none
45
46c----------------------------------------------------------------------
47c         0.1   arguments
48c               ---------
49c                                                            inputs:
50c                                                            -------
51      integer,intent(in) :: ig0
52      integer,intent(in) :: kdlon      ! part of ngrid
53      integer,intent(in) :: kflev      ! part of nalyer
54 
55      real,intent(in) :: emis (ndlo2) ! surface emissivity
56      real,intent(in) :: aer_t (ndlo2,nuco2,kflev+1) ! transmission (aer)
57      real,intent(in) :: co2_u (ndlo2,nuco2,kflev+1) ! absorber amounts (co2)
58      real,intent(in) :: co2_up (ndlo2,nuco2,kflev+1) ! idem scaled by the pressure (co2)
59
60c----------------------------------------------------------------------
61c         0.2   local arrays
62c               ------------
63
64      integer ja,jl,jk,jkk
65      real zu (ndlon,nuco2)
66      real zup (ndlon,nuco2)
67      real zt_co2 (ndlon,nuco2)
68      real zt_aer (ndlon,nuco2)
69
70      real ksi (ndlon,nuco2,0:nflev+1,0:nflev+1)
71      real ksi_emis (ndlon,nuco2,0:nflev+1,0:nflev+1)
72      real trans (ndlon,nuco2,0:nflev+1,0:nflev+1)
73      real trans_emis (ndlon,nuco2,0:nflev+1,0:nflev+1)
74
75c----------------------------------------------------------------------
76      ksi_emis(:,:,:,:)=0
77c----------------------------------------------------------------------
78c         1.0   Transmission functions
79c               ----------------------
80
81c----------------------------------------------------------------------
82c        1.1   Direct transmission
83c              -------------------
84
85      do jk = 1 , nlaylte+1
86        do jkk = jk , nlaylte+1
87
88          do ja = 1 , nuco2
89            do jl = 1 , kdlon
90c                                                                   co2
91c                                                                   ---
92              zu(jl,ja) =  co2_u(jl,ja,jk)  - co2_u(jl,ja,jkk)
93              zup(jl,ja) = co2_up(jl,ja,jk) - co2_up(jl,ja,jkk)
94c                                                                   aer
95c                                                                   ---
96              zt_aer(jl,ja)= aer_t(jl,ja,jk)
97     .                      /aer_t(jl,ja,jkk)
98
99            enddo
100          enddo
101
102          call lwtt(kdlon,zu,zup,nuco2,zt_co2)
103c                                                            co2 and aer
104c                                                            -----------
105          do ja = 1 , nuco2
106            do jl = 1 , kdlon
107              trans(jl,ja,jk,jkk) = zt_co2(jl,ja) * zt_aer(jl,ja)
108            enddo
109          enddo
110c                                                       trans reciprocity
111c                                                       -----------------
112          do ja = 1 , nuco2
113            do jl = 1 , kdlon
114              trans(jl,ja,jkk,jk) = trans(jl,ja,jk,jkk)
115c           if (trans(jl,ja,jk,jkk) .LT. 0 ) then
116c           print*,'trans bande',ja,jk,jkk,trans(jl,ja,jk,jkk)
117c           endif
118c           if (trans(jl,ja,jk,jkk) .GT. 1) then
119c           print*,'trans bande',ja,jk,jkk,trans(jl,ja,jk,jkk)
120c           trans(jl,ja,jk,jkk)=1
121c           print*,'trans bande',ja,jk,jkk,trans(jl,ja,jk,jkk)
122c           endif
123
124            enddo
125          enddo
126     
127        enddo
128      enddo
129
130c----------------------------------------------------------------------
131c         1.2   Transmission with reflexion
132c               ---------------------------
133
134      do jk = 1 , nlaylte+1
135        do jkk = jk , nlaylte+1
136
137      if (callemis) then
138          do ja = 1 , nuco2
139            do jl = 1 , kdlon
140c                                                                   co2
141c                                                                   ---
142              zu(jl,ja)  = 2 * co2_u(jl,ja,1)  - co2_u(jl,ja,jk)
143     .                                         - co2_u(jl,ja,jkk)
144              zup(jl,ja) = 2 * co2_up(jl,ja,1) - co2_up(jl,ja,jk)
145     .                                         - co2_up(jl,ja,jkk)
146c                                                                   aer
147c                                                                   ---
148                zt_aer(jl,ja)  = aer_t(jl,ja,1)
149     .                         * aer_t(jl,ja,1)
150     .                         / aer_t(jl,ja,jk)
151     .                         / aer_t(jl,ja,jkk)
152            enddo
153          enddo
154
155          call lwtt(kdlon,zu,zup,nuco2,zt_co2)
156c                                                            co2 and aer
157c                                                            -----------
158          do ja = 1 , nuco2
159            do jl = 1 , kdlon
160              trans_emis(jl,ja,jk,jkk) = zt_co2(jl,ja)
161     .                                 * zt_aer(jl,ja)
162            enddo
163          enddo
164
165      else
166
167          do ja = 1 , nuco2
168            do jl = 1 , kdlon
169              trans_emis(jl,ja,jk,jkk) = 1.
170            enddo
171          enddo
172
173      endif
174c                                                       trans reciprocity
175c                                                       -----------------
176          do ja = 1 , nuco2
177            do jl = 1 , kdlon
178              trans_emis(jl,ja,jkk,jk) = trans_emis(jl,ja,jk,jkk)
179c         if (trans_emis(jl,ja,jk,jkk) .LT. 0
180c    .                .OR.  trans_emis(jl,ja,jk,jkk) .GT. 1) then
181c     print*,'trans_emis bande',ja,jk,jkk,trans_emis(jl,ja,jk,jkk)
182c         endif
183            enddo
184          enddo
185
186        enddo
187      enddo
188
189c----------------------------------------------------------------------
190c         2.0   Exchange Coefficiants
191c               ---------------------
192
193      do jk = 1 , nlaylte-2
194        do jkk = jk+2 , nlaylte
195          do ja = 1 , nuco2
196            do jl = 1 , kdlon
197
198      ksi(jl,ja,jk,jkk) =
199     .            trans(jl,ja,jk+1,jkk)   - trans(jl,ja,jk,jkk)
200     .          - trans(jl,ja,jk+1,jkk+1) + trans(jl,ja,jk,jkk+1)
201
202      ksi_emis(jl,ja,jk,jkk) =
203     .   trans_emis(jl,ja,jk,jkk)   - trans_emis(jl,ja,jk+1,jkk)
204     . - trans_emis(jl,ja,jk,jkk+1) + trans_emis(jl,ja,jk+1,jkk+1)
205
206c       if (ksi(jl,ja,jk,jkk) .LT. 0 ) then
207c           print*,'ksi bande',ja,jk,jkk,ksi(jl,ja,jk,jkk)
208c           ksi(jl,ja,jk,jkk)=0
209c           print*,'ksi bande',ja,jk,jkk,ksi(jl,ja,jk,jkk)
210c       endif
211c       if (ksi(jl,ja,jk,jkk) .GT. 1) then
212c           print*,'ksi bande',ja,jk,jkk,ksi(jl,ja,jk,jkk)
213c           ksi(jl,ja,jk,jkk)=1
214c           print*,'ksi bande',ja,jk,jkk,ksi(jl,ja,jk,jkk)
215c       endif
216
217c       if (ksi_emis(jl,ja,jk,jkk) .LT. 0
218c    .                .OR.  ksi_emis(jl,ja,jk,jkk) .GT. 1) then
219c     print*,'ksi_emis bande',ja,jk,jkk,ksi_emis(jl,ja,jk,jkk)
220c       endif
221
222      xi(ig0+jl,ja,jk,jkk) = ksi(jl,ja,jk,jkk)
223     .      + ksi_emis(jl,ja,jk,jkk) * (1 - emis(jl))
224
225c                                                        ksi reciprocity
226c                                                        ---------------
227      ksi(jl,ja,jkk,jk)      = ksi(jl,ja,jk,jkk)
228      ksi_emis(jl,ja,jkk,jk) = ksi_emis(jl,ja,jk,jkk)
229      xi(ig0+jl,ja,jkk,jk)   = xi(ig0+jl,ja,jk,jkk)
230
231            enddo
232          enddo
233        enddo
234      enddo
235
236c----------------------------------------------------------------------
237c         2.1   Save xi_emis for neighbours (lwxn.F)
238c               -----------------------------------
239
240      do jk = 1 , nlaylte-1
241        do ja = 1 , nuco2
242          do jl = 1 , kdlon
243
244c     ksi_emis(jl,ja,jk,jk+1) =
245c    .   trans_emis(jl,ja,jk,jk+1)   - trans_emis(jl,ja,jk+1,jk+1)
246c    . - trans_emis(jl,ja,jk,jk+2) + trans_emis(jl,ja,jk+1,jk+2)
247
248      xi_emis(ig0+jl,ja,jk) =
249     .                 ksi_emis(jl,ja,jk,jk+1) * (1-emis(jl))
250
251          enddo
252        enddo
253      enddo
254
255c----------------------------------------------------------------------
256      end subroutine lwxd
257     
258      end module lwxd_mod
Note: See TracBrowser for help on using the repository browser.