1 | SUBROUTINE vert_regrid_kim(nq,q) |
---|
2 | |
---|
3 | ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
4 | ! |
---|
5 | ! Purpose : * Calculates the zonally averaged upper chemistry fields according |
---|
6 | ! to the new pressure grid - based on interp_vert. |
---|
7 | ! * In case the GCM top is lowered we interpolate upper fields |
---|
8 | ! between the former ones and the GCM top layer zonally averaged. |
---|
9 | ! * In case the GCM top is highered we interpolate tracers on the |
---|
10 | ! GCM grid uppermost layers between the upper chemsitry fields and |
---|
11 | ! the chem. tracers below. |
---|
12 | ! |
---|
13 | ! Author : Jan Vatant d'Ollone (2018) |
---|
14 | ! ------ |
---|
15 | ! |
---|
16 | ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
17 | |
---|
18 | USE comchem_h, ONLY: cnames, rat_mmol, nlaykim_up, preskim, ykim_up |
---|
19 | USE comchem_newstart_h |
---|
20 | USE tracer_h |
---|
21 | USE comvert_mod, ONLY: aps |
---|
22 | |
---|
23 | IMPLICIT NONE |
---|
24 | |
---|
25 | INCLUDE "netcdf.inc" |
---|
26 | |
---|
27 | INCLUDE "dimensions.h" |
---|
28 | |
---|
29 | ! ----------------- |
---|
30 | ! Declarations |
---|
31 | ! ----------------- |
---|
32 | INTEGER, INTENT(IN) :: nq ! Total number of advected fields (tracers) |
---|
33 | |
---|
34 | REAL,DIMENSION(iim+1,jjm+1,llm,nq), INTENT(INOUT) :: q ! Advected fields (kg/kg) on 3D dyn. grid |
---|
35 | |
---|
36 | REAL, DIMENSION(:,:), ALLOCATABLE :: avg_qtop ! Zonally averaged q (mol/mol) on top layer |
---|
37 | |
---|
38 | REAL :: coef, ykimlon |
---|
39 | |
---|
40 | INTEGER :: ngridmx |
---|
41 | |
---|
42 | INTEGER :: ng0, isup |
---|
43 | |
---|
44 | INTEGER :: ln, lo, ilay, ichem, ilon, ilat |
---|
45 | |
---|
46 | LOGICAL :: lowered |
---|
47 | |
---|
48 | ! ----------------------------- |
---|
49 | ! 0. Get useful size of arrays |
---|
50 | ! ----------------------------- |
---|
51 | |
---|
52 | ngridmx = size(ykim_up,DIM=2) |
---|
53 | |
---|
54 | ! ------------------------------------------------------------ |
---|
55 | ! 1. Compute zonal mean of last layer for every chem and lat |
---|
56 | ! and convert it to molar mixing fraction and to physics grid |
---|
57 | ! Preliminary, only in case ceiling has been lowered |
---|
58 | ! ------------------------------------------------------------ |
---|
59 | |
---|
60 | lowered = .FALSE. |
---|
61 | |
---|
62 | IF ( preskim(1) .GT. preskimold(1) ) THEN |
---|
63 | |
---|
64 | lowered = .TRUE. |
---|
65 | |
---|
66 | ALLOCATE(avg_qtop(44,ngridmx)) |
---|
67 | |
---|
68 | DO ichem=1,44 |
---|
69 | avg_qtop(ichem,:)=0.0 |
---|
70 | DO ilon=1,iim |
---|
71 | avg_qtop(ichem,1)=avg_qtop(ichem,1)+q(ilon,1,llm,chimi_indx(ichem)) |
---|
72 | avg_qtop(ichem,ngridmx)=avg_qtop(ichem,ngridmx)+q(ilon,jjm+1,llm,chimi_indx(ichem)) |
---|
73 | DO ilat=2,jjm |
---|
74 | ng0 = iim*(ilat-2)+1 |
---|
75 | avg_qtop(ichem,ng0+1:ng0+iim)=avg_qtop(ichem,ng0+1:ng0+iim)+q(ilon,ilat,llm,chimi_indx(ichem)) |
---|
76 | ENDDO |
---|
77 | ENDDO |
---|
78 | ! mass -> molar mixing ratio to be comparable to ykim_up later |
---|
79 | avg_qtop(ichem,:)=avg_qtop(ichem,:)*rat_mmol(chimi_indx(ichem)) |
---|
80 | ENDDO |
---|
81 | |
---|
82 | ENDIF |
---|
83 | |
---|
84 | ! ------------------------------ |
---|
85 | ! 2. Process upper chem. fields |
---|
86 | ! ------------------------------ |
---|
87 | |
---|
88 | DO ln=1,nlaykim_up |
---|
89 | |
---|
90 | ! Standard case between 2 old upper pressure grid points |
---|
91 | |
---|
92 | DO lo=1,nlaykimold-1 |
---|
93 | |
---|
94 | IF ( ( preskim(ln) .LE. preskimold(lo) ) .AND. & |
---|
95 | ( preskim(ln) .GT. preskimold(lo+1) ) ) THEN |
---|
96 | |
---|
97 | coef = (preskim(ln)-preskimold(lo)) / (preskimold(lo+1)-preskimold(lo)) |
---|
98 | ykim_up(:,:,ln) = (1.0-coef)*ykim_up_oldv(:,:,lo) + coef*ykim_up_oldv(:,:,lo+1) |
---|
99 | |
---|
100 | ENDIF |
---|
101 | |
---|
102 | ENDDO |
---|
103 | |
---|
104 | ! Special cases |
---|
105 | |
---|
106 | IF ( lowered ) THEN |
---|
107 | |
---|
108 | ! If the ceiling of GCM has been lowered we interpolate a zonal mean between new GCM top and former upper fields |
---|
109 | ! NB : We could have kept in memory the former tracers at this altitude and zonally averaged them |
---|
110 | ! but it's certainly useless as we're in newstart and the fields will re-equilibrate |
---|
111 | |
---|
112 | IF ( preskim(ln) .GT. preskimold(1) ) THEN |
---|
113 | DO ichem=1,44 |
---|
114 | coef = ( preskim(ln)-aps(llm) ) / ( preskimold(1)-aps(llm) ) |
---|
115 | ykim_up(ichem,:,ln) = (1.0-coef)*avg_qtop(ichem,:) + coef*ykim_up_oldv(ichem,:,1) |
---|
116 | ENDDO |
---|
117 | ENDIF |
---|
118 | |
---|
119 | ENDIF |
---|
120 | |
---|
121 | IF ( preskim(ln) .LE. preskimold(nlaykimold) ) THEN ! upper ceiling at 1300km can have slight variations |
---|
122 | ykim_up(:,:,ln) = ykim_up_oldv(:,:,lo) |
---|
123 | ENDIF |
---|
124 | |
---|
125 | ENDDO ! do ln=1,nlaykim_up |
---|
126 | |
---|
127 | ! ---------------------------------------------------------------------------- |
---|
128 | ! 3. Correct the 3D advected chem. tracer fields if model ceiling is highered |
---|
129 | ! In this case we interpolate between tracers below and upper_chemistry values |
---|
130 | ! Doing this we convert via rat_mmol ykim_up from molar to mass mixing ratio |
---|
131 | ! ---------------------------------------------------------------------------- |
---|
132 | |
---|
133 | IF ( preskim(1) .LT. preskimold(1) ) THEN |
---|
134 | |
---|
135 | ! We just want to process the concerned upper layers of the GCM |
---|
136 | DO ilay=1,llm |
---|
137 | IF ( aps(ilay) .LT. preskimold(1) ) THEN |
---|
138 | isup = ilay-1 |
---|
139 | EXIT |
---|
140 | ENDIF |
---|
141 | ENDDO |
---|
142 | |
---|
143 | DO ilay=isup+1,llm |
---|
144 | |
---|
145 | coef = ( aps(ilay) - preskim(1) ) / ( aps(isup) - preskim(1) ) |
---|
146 | |
---|
147 | DO ichem=1,44 |
---|
148 | |
---|
149 | ! We need to convert ykim_up on phys grid to q on dyn grid |
---|
150 | ! so we deal with mono-gridpoints for North and South Poles |
---|
151 | |
---|
152 | q(:,1,ilay,chimi_indx(ichem)) = (1.0-coef)*ykim_up(ichem,1,1)/rat_mmol(chimi_indx(ichem)) & |
---|
153 | + coef*q(:,1,isup,chimi_indx(ichem)) |
---|
154 | q(:,jjm+1,ilay,chimi_indx(ichem)) = (1.0-coef)*ykim_up(ichem,ngridmx,1)/rat_mmol(chimi_indx(ichem)) & |
---|
155 | + coef*q(:,jjm+1,isup,chimi_indx(ichem)) |
---|
156 | |
---|
157 | DO ilat=2,jjm |
---|
158 | |
---|
159 | ng0 = iim*(ilat-2)+1 |
---|
160 | |
---|
161 | DO ilon=2,iim |
---|
162 | ! ykim_up and q are shifted one to the other on longitudinal grid |
---|
163 | ykimlon = 0.5*(ykim_up(ichem,ng0+ilon-1,1)+ykim_up(ichem,ng0+ilon,1)) / rat_mmol(chimi_indx(ichem)) |
---|
164 | |
---|
165 | q(ilon,ilat,ilay,chimi_indx(ichem)) = (1.0-coef)*ykimlon + coef*q(ilon,ilat,isup,chimi_indx(ichem)) |
---|
166 | ENDDO |
---|
167 | |
---|
168 | ! Periodicity on longitude at 180 and -180 |
---|
169 | |
---|
170 | ykimlon = 0.5*(ykim_up(ichem,ng0+1,1)+ykim_up(ichem,ng0+iim,1)) / rat_mmol(chimi_indx(ichem)) |
---|
171 | |
---|
172 | q(1,ilat,ilay,chimi_indx(ichem)) = (1.0-coef)*ykimlon + coef*q(1,ilat,isup,chimi_indx(ichem)) |
---|
173 | q(iim+1,ilat,ilay,chimi_indx(ichem)) = q(1,ilat,ilay,chimi_indx(ichem)) |
---|
174 | |
---|
175 | ENDDO ! do ilat=2,jjm |
---|
176 | ENDDO ! do ichem=1,44 |
---|
177 | ENDDO ! do ilay=1,llm |
---|
178 | |
---|
179 | ENDIF |
---|
180 | |
---|
181 | END SUBROUTINE vert_regrid_kim |
---|