1 | !$Id: photo_interp.F90 104 2008-12-23 10:28:51Z acosce $ |
---|
2 | !! ========================================================================= |
---|
3 | !! INCA - INteraction with Chemistry and Aerosols |
---|
4 | !! |
---|
5 | !! Copyright Laboratoire des Sciences du Climat et de l'Environnement (LSCE) |
---|
6 | !! Unite mixte CEA-CNRS-UVSQ |
---|
7 | !! |
---|
8 | !! Contributors to this INCA subroutine: |
---|
9 | !! |
---|
10 | !! Stacy Walters, NCAR, stacy@ucar.edu |
---|
11 | !! |
---|
12 | !! Anne Cozic, LSCE, anne.cozic@cea.fr |
---|
13 | !! Yann Meurdesoif, LSCE, yann.meurdesoif@cea.fr |
---|
14 | !! |
---|
15 | !! This software is a computer program whose purpose is to simulate the |
---|
16 | !! atmospheric gas phase and aerosol composition. The model is designed to be |
---|
17 | !! used within a transport model or a general circulation model. This version |
---|
18 | !! of INCA was designed to be coupled to the LMDz GCM. LMDz-INCA accounts |
---|
19 | !! for emissions, transport (resolved and sub-grid scale), photochemical |
---|
20 | !! transformations, and scavenging (dry deposition and washout) of chemical |
---|
21 | !! species and aerosols interactively in the GCM. Several versions of the INCA |
---|
22 | !! model are currently used depending on the envisaged applications with the |
---|
23 | !! chemistry-climate model. |
---|
24 | !! |
---|
25 | !! This software is governed by the CeCILL license under French law and |
---|
26 | !! abiding by the rules of distribution of free software. You can use, |
---|
27 | !! modify and/ or redistribute the software under the terms of the CeCILL |
---|
28 | !! license as circulated by CEA, CNRS and INRIA at the following URL |
---|
29 | !! "http://www.cecill.info". |
---|
30 | !! |
---|
31 | !! As a counterpart to the access to the source code and rights to copy, |
---|
32 | !! modify and redistribute granted by the license, users are provided only |
---|
33 | !! with a limited warranty and the software's author, the holder of the |
---|
34 | !! economic rights, and the successive licensors have only limited |
---|
35 | !! liability. |
---|
36 | !! |
---|
37 | !! In this respect, the user's attention is drawn to the risks associated |
---|
38 | !! with loading, using, modifying and/or developing or reproducing the |
---|
39 | !! software by the user in light of its specific status of free software, |
---|
40 | !! that may mean that it is complicated to manipulate, and that also |
---|
41 | !! therefore means that it is reserved for developers and experienced |
---|
42 | !! professionals having in-depth computer knowledge. Users are therefore |
---|
43 | !! encouraged to load and test the software's suitability as regards their |
---|
44 | !! requirements in conditions enabling the security of their systems and/or |
---|
45 | !! data to be ensured and, more generally, to use and operate it in the |
---|
46 | !! same conditions as regards security. |
---|
47 | !! |
---|
48 | !! The fact that you are presently reading this means that you have had |
---|
49 | !! knowledge of the CeCILL license and that you accept its terms. |
---|
50 | !! ========================================================================= |
---|
51 | |
---|
52 | #include <inca_define.h> |
---|
53 | |
---|
54 | SUBROUTINE PHOTO_INTERP( & |
---|
55 | zin ,& |
---|
56 | sin ,& |
---|
57 | vin ,& |
---|
58 | albin ,& |
---|
59 | t500in ,& |
---|
60 | t200in ,& |
---|
61 | ajout ) |
---|
62 | !---------------------------------------------------------------------- |
---|
63 | ! ... Loglinear interpolation for the photodissociation rates |
---|
64 | ! Note: this subroutine computes photorates for a vertical |
---|
65 | ! column at a given longitude and latitude |
---|
66 | ! This routine uses a six parameter table via a Taylor |
---|
67 | ! series expansion. |
---|
68 | ! Stacy Walters, Sep 30, 1996. Changed code to strictly limit |
---|
69 | ! the 200mb and 500mb temperature interpolation to the table |
---|
70 | ! endpoints; i.e. no extrapolation beyond the table is allowed. |
---|
71 | !---------------------------------------------------------------------- |
---|
72 | |
---|
73 | USE PHT_TABLES |
---|
74 | USE INCA_DIM |
---|
75 | |
---|
76 | IMPLICIT NONE |
---|
77 | |
---|
78 | !---------------------------------------------------------------------- |
---|
79 | ! ... Dummy arguments |
---|
80 | !---------------------------------------------------------------------- |
---|
81 | REAL, INTENT(in) :: zin(PLEV) ! pressure in millibars |
---|
82 | REAL, INTENT(in) :: sin ! secant solar zenith angle |
---|
83 | REAL, INTENT(in) :: vin(PLEV) ! o3 column density |
---|
84 | REAL, INTENT(in) :: albin(PLEV) ! surface albedo |
---|
85 | REAL, INTENT(in) :: t500in ! temp on 500mb surface |
---|
86 | REAL, INTENT(in) :: t200in ! temp on 200mb surface |
---|
87 | REAL, INTENT(out) :: ajout(jdim,PLEV) ! photodissociation rates |
---|
88 | |
---|
89 | !---------------------------------------------------------------------- |
---|
90 | ! ... Local variables |
---|
91 | !---------------------------------------------------------------------- |
---|
92 | INTEGER :: i, iz, is, iv, ial, nn, it500, it200 |
---|
93 | INTEGER :: i1, i2 |
---|
94 | INTEGER :: k |
---|
95 | INTEGER :: izl |
---|
96 | INTEGER :: index0 |
---|
97 | INTEGER :: base_ind |
---|
98 | INTEGER :: indv0(7,PLEV) |
---|
99 | INTEGER, DIMENSION(PLEV) :: altind, ratind, albind |
---|
100 | REAL :: v3std |
---|
101 | REAL :: psum |
---|
102 | REAL :: dels(6) |
---|
103 | REAL, DIMENSION(PLEV) :: v3rat, wght0, wght1, wght2, wght3, wght4 |
---|
104 | INTEGER :: first_level |
---|
105 | |
---|
106 | !---------------------------------------------------------------------- |
---|
107 | ! ... Find the zenith angle index ( same for all levels ) |
---|
108 | !---------------------------------------------------------------------- |
---|
109 | DO is = 1,zangdim |
---|
110 | IF( vsec(is) > sin ) THEN |
---|
111 | EXIT |
---|
112 | END IF |
---|
113 | END DO |
---|
114 | is = MAX( MIN( is,zangdim ) - 1,1 ) |
---|
115 | dels(2) = (sin - vsec(is)) * delang(is) |
---|
116 | |
---|
117 | !---------------------------------------------------------------------- |
---|
118 | ! ... Find the 500mb temp index ( same for all levels ) |
---|
119 | !---------------------------------------------------------------------- |
---|
120 | DO it500 = 1,t500dim |
---|
121 | IF( t500(it500) > t500in ) THEN |
---|
122 | EXIT |
---|
123 | END IF |
---|
124 | END DO |
---|
125 | it500 = MAX( MIN( it500,t500dim ) - 1,1 ) |
---|
126 | dels(5) = (t500in - t500(it500)) * delt500(it500) |
---|
127 | dels(5) = MAX( MIN( dels(5),1. ),0. ) |
---|
128 | |
---|
129 | !---------------------------------------------------------------------- |
---|
130 | ! ... Find the 200mb temp index ( same for all levels ) |
---|
131 | !---------------------------------------------------------------------- |
---|
132 | it200 = 1 |
---|
133 | dels(6) = (t200in - t200(it200)) * delt200(it200) |
---|
134 | dels(6) = MAX( MIN( dels(6),1. ),0. ) |
---|
135 | |
---|
136 | base_ind = is * offset(2) + it500 * offset(5) & |
---|
137 | + it200 * offset(6) - offset(7) |
---|
138 | |
---|
139 | izl = 1 |
---|
140 | DO k = PLEV,1,-1 |
---|
141 | !---------------------------------------------------------------------- |
---|
142 | ! ... Find albedo indicies |
---|
143 | !---------------------------------------------------------------------- |
---|
144 | DO ial = 1,albdim |
---|
145 | IF( albev(ial) > albin(k) ) THEN |
---|
146 | EXIT |
---|
147 | END IF |
---|
148 | END DO |
---|
149 | albind(k) = MAX( MIN( ial,albdim ) - 1,1 ) |
---|
150 | !---------------------------------------------------------------------- |
---|
151 | ! ... Find level indicies |
---|
152 | !---------------------------------------------------------------------- |
---|
153 | DO iz = izl,altdim |
---|
154 | IF( zz(iz) > zin(k) ) THEN |
---|
155 | izl = iz |
---|
156 | EXIT |
---|
157 | END IF |
---|
158 | END DO |
---|
159 | altind(k) = MAX( MIN( iz,altdim ) - 1,1 ) |
---|
160 | !---------------------------------------------------------------------- |
---|
161 | ! ... Find o3 ratio indicies |
---|
162 | !---------------------------------------------------------------------- |
---|
163 | i = MAX( MIN( altmxdim-1,INT( zin(k) ) ),0 ) |
---|
164 | v3std = vo3(i) + (zin(k) - FLOAT(i)) * (vo3(i+1) - vo3(i)) |
---|
165 | v3rat(k) = vin(k) / v3std |
---|
166 | DO iv = 1,o3ratdim |
---|
167 | IF( xv3(iv) > v3rat(k) ) THEN |
---|
168 | EXIT |
---|
169 | END IF |
---|
170 | END DO |
---|
171 | ratind(k) = MAX( MIN( iv,o3ratdim ) - 1,1 ) |
---|
172 | END DO |
---|
173 | |
---|
174 | |
---|
175 | !!! patch pour le 79 niveau - Fixed a bug in the last level (at 80km) |
---|
176 | !!! we put the last 3 level to the value of the fourth one |
---|
177 | !!! Anne et Didier 24 mai 2017 |
---|
178 | IF (PLEV .EQ. 79) THEN |
---|
179 | DO k = 1,3 |
---|
180 | iz = altind(4) |
---|
181 | iv = ratind(4) |
---|
182 | ial = albind(4) |
---|
183 | index0 = base_ind + ial * offset(4) & |
---|
184 | + iv * offset(3) + iz * offset(1) |
---|
185 | |
---|
186 | dels(1) = (zin(4) - zz(iz)) * delz(iz) |
---|
187 | dels(3) = (v3rat(4) - xv3(iv)) * delv(iv) |
---|
188 | dels(4) = (albin(4) - albev(ial)) * delalb(ial) |
---|
189 | |
---|
190 | !---------------------------------------------------------------------- |
---|
191 | ! ... Compute the weigths |
---|
192 | !---------------------------------------------------------------------- |
---|
193 | wght0(k) = 1. - SUM( dels ) |
---|
194 | wght1(k) = dels(1) |
---|
195 | wght3(k) = dels(3) |
---|
196 | wght4(k) = dels(4) |
---|
197 | |
---|
198 | !---------------------------------------------------------------------- |
---|
199 | ! ... Compute the indicies into ajl |
---|
200 | !---------------------------------------------------------------------- |
---|
201 | indv0(1,k) = index0 |
---|
202 | indv0(2,k) = index0 + offset(1) |
---|
203 | indv0(3,k) = index0 + offset(2) |
---|
204 | indv0(4,k) = index0 + offset(3) |
---|
205 | indv0(5,k) = index0 + offset(4) |
---|
206 | indv0(6,k) = index0 + offset(5) |
---|
207 | indv0(7,k) = index0 + offset(6) |
---|
208 | END DO |
---|
209 | first_level=4 |
---|
210 | ELSE |
---|
211 | first_level=1 |
---|
212 | ENDIF |
---|
213 | |
---|
214 | DO k = first_level,PLEV |
---|
215 | iz = altind(k) |
---|
216 | iv = ratind(k) |
---|
217 | ial = albind(k) |
---|
218 | index0 = base_ind + ial * offset(4) & |
---|
219 | + iv * offset(3) + iz * offset(1) |
---|
220 | |
---|
221 | dels(1) = (zin(k) - zz(iz)) * delz(iz) |
---|
222 | dels(3) = (v3rat(k) - xv3(iv)) * delv(iv) |
---|
223 | dels(4) = (albin(k) - albev(ial)) * delalb(ial) |
---|
224 | |
---|
225 | !---------------------------------------------------------------------- |
---|
226 | ! ... Compute the weigths |
---|
227 | !---------------------------------------------------------------------- |
---|
228 | wght0(k) = 1. - SUM( dels ) |
---|
229 | wght1(k) = dels(1) |
---|
230 | wght3(k) = dels(3) |
---|
231 | wght4(k) = dels(4) |
---|
232 | |
---|
233 | !---------------------------------------------------------------------- |
---|
234 | ! ... Compute the indicies into ajl |
---|
235 | !---------------------------------------------------------------------- |
---|
236 | indv0(1,k) = index0 |
---|
237 | indv0(2,k) = index0 + offset(1) |
---|
238 | indv0(3,k) = index0 + offset(2) |
---|
239 | indv0(4,k) = index0 + offset(3) |
---|
240 | indv0(5,k) = index0 + offset(4) |
---|
241 | indv0(6,k) = index0 + offset(5) |
---|
242 | indv0(7,k) = index0 + offset(6) |
---|
243 | END DO |
---|
244 | |
---|
245 | DO is = 1,jdim*PLEV |
---|
246 | k = MOD( is-1,PLEV ) + 1 |
---|
247 | nn = (is - 1)/PLEV + 1 |
---|
248 | psum = wght0(k) * ajl(indv0(1,k)+nn) & |
---|
249 | + wght1(k) * ajl(indv0(2,k)+nn) & |
---|
250 | + dels(2) * ajl(indv0(3,k)+nn) & |
---|
251 | + wght3(k) * ajl(indv0(4,k)+nn) & |
---|
252 | + wght4(k) * ajl(indv0(5,k)+nn) & |
---|
253 | + dels(5) * ajl(indv0(6,k)+nn) & |
---|
254 | + dels(6) * ajl(indv0(7,k)+nn) |
---|
255 | ajout(nn,k) = EXP( psum ) |
---|
256 | |
---|
257 | |
---|
258 | END DO |
---|
259 | |
---|
260 | |
---|
261 | END SUBROUTINE PHOTO_INTERP |
---|