/[lmdze]/trunk/phylmd/readsulfate_preind.f
ViewVC logotype

Contents of /trunk/phylmd/readsulfate_preind.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 108 - (show annotations)
Tue Sep 16 14:00:41 2014 UTC (9 years, 7 months ago) by guez
File size: 6353 byte(s)
Imported writefield from LMDZ. Close at the end of gcm the files which
were created by writefiled (not done in LMDZ).

Removed procedures for the output of Grads files. Removed calls to
dump2d. In guide, replaced calls to wrgrads by calls to writefield.

In vlspltqs, removed redundant programming of saturation
pressure. Call foeew from module FCTTRE instead.

Bug fix in interpre: size of w exceeding size of correponding actual
argument wg in advtrac.

In leapfrog, call guide until the end of the run, instead of six hours
before the end.

Bug fix in readsulfate_preind: type of arguments.

1 module readsulfate_preind_m
2
3 IMPLICIT none
4
5 contains
6
7 SUBROUTINE readsulfate_preind(r_day, first, pi_sulfate)
8
9 ! Read in /calculate pre-industrial values of sulfate
10
11 use dimens_m
12 use dimphy
13 use temps
14 use SUPHEC_M
15 use chem
16 use getso4fromfile_m, only: getso4fromfile
17
18 ! Content:
19 ! --------
20 ! This routine reads in monthly mean values of sulfate aerosols and
21 ! returns a linearly interpolated daily-mean field.
22 !
23 ! It does so for the preindustriel values of the sulfate, to a large part
24 ! analogous to the routine readsulfate.
25 !
26 ! Only Pb: Variables must be saved and don t have to be overwritten!
27 !
28 ! Author:
29 ! -------
30 ! Johannes Quaas (quaas@lmd.jussieu.fr)
31 ! 26/06/01
32 !
33 ! Input:
34 ! ------
35 real, intent(in):: r_day ! Day of integration
36 LOGICAL, intent(in):: first ! First timestep
37 ! (and therefore initialization necessary)
38 !
39 ! Output:
40 ! -------
41 real pi_sulfate (klon, klev) ! Number conc. sulfate (monthly mean data,
42 ! from file)
43 !
44 ! Local Variables:
45 ! ----------------
46 INTEGER i, ig, k, it
47 INTEGER j, iday, ny, iyr
48 parameter (ny=jjm+1)
49
50 INTEGER im, day1, day2, im2
51 double precision pi_so4_1(iim, jjm+1, klev, 12)
52
53 double precision pi_so4(klon, klev, 12) ! SO4 in right dimension
54 SAVE pi_so4
55 double precision pi_so4_out(klon, klev)
56 SAVE pi_so4_out
57
58 CHARACTER(len=4) cyear
59 LOGICAL lnewday
60
61
62
63 iday = INT(r_day)
64
65 ! Get the year of the run
66 iyr = iday/360
67
68 ! Get the day of the actual year:
69 iday = iday-iyr*360
70
71 ! 0.02 is about 0.5/24, namly less than half an hour
72 lnewday = (r_day-FLOAT(iday).LT.0.02)
73
74 ! ---------------------------------------------
75 ! All has to be done only, if a new day begins!
76 ! ---------------------------------------------
77
78 IF (lnewday.OR.first) THEN
79 im = iday/30 +1 ! the actual month
80
81 ! annee_ref is the initial year (defined in temps.h)
82 iyr = iyr + annee_ref
83
84
85 IF (first) THEN
86 cyear='.nat'
87 CALL getso4fromfile(cyear,pi_so4_1)
88
89 ! Transform the horizontal 2D-field into the physics-field
90 ! (Also the levels and the latitudes have to be inversed)
91
92 ! Initialize field
93 DO it=1,12
94 DO k=1,klev
95 DO i=1,klon
96 pi_so4(i,k,it)=0.
97 ENDDO
98 ENDDO
99 ENDDO
100
101 write (*,*) 'preind: finished reading', FLOAT(iim)
102 DO it=1,12
103 DO k=1, klev
104 ! a) at the poles, use the zonal mean:
105 DO i=1,iim
106 ! North pole
107 pi_so4(1,k,it)=pi_so4(1,k,it)+pi_so4_1(i,jjm+1,klev+1-k,it)
108 ! South pole
109 pi_so4(klon,k,it)=pi_so4(klon,k,it)+pi_so4_1(i,1,klev+1-k,it)
110 ENDDO
111 pi_so4(1,k,it)=pi_so4(1,k,it)/FLOAT(iim)
112 pi_so4(klon,k,it)=pi_so4(klon,k,it)/FLOAT(iim)
113
114 ! b) the values between the poles:
115 ig=1
116 DO j=2,jjm
117 DO i=1,iim
118 ig=ig+1
119 if (ig.gt.klon) write (*,*) 'shit'
120 pi_so4(ig,k,it) = pi_so4_1(i,jjm+1-j,klev+1-k,it)
121 ENDDO
122 ENDDO
123 IF (ig.NE.klon-1) STOP 'Error in readsulfate (var conversion)'
124 ENDDO ! Loop over k (vertical)
125 ENDDO ! Loop over it (months)
126
127 ENDIF ! Had to read new data?
128
129
130 ! Interpolate to actual day:
131 IF (iday.LT.im*30-15) THEN
132 ! in the first half of the month use month before and actual month
133 im2=im-1
134 day1 = im2*30+15
135 day2 = im2*30-15
136 IF (im2.LE.0) THEN
137 ! the month is january, thus the month before december
138 im2=12
139 ENDIF
140 DO k=1,klev
141 DO i=1,klon
142 pi_sulfate(i,k) = pi_so4(i,k,im2) &
143 - FLOAT(iday-day2)/FLOAT(day1-day2) &
144 * (pi_so4(i,k,im2) - pi_so4(i,k,im))
145 IF (pi_sulfate(i,k).LT.0.) THEN
146 IF (iday-day2.LT.0.) write(*,*) 'iday-day2',iday-day2
147 IF (pi_so4(i,k,im2) - pi_so4(i,k,im).LT.0.) &
148 write(*,*) 'pi_so4(i,k,im2) - pi_so4(i,k,im)', &
149 pi_so4(i,k,im2) - pi_so4(i,k,im)
150 IF (day1-day2.LT.0.) write(*,*) 'day1-day2',day1-day2
151 stop 'pi_sulfate'
152 endif
153 ENDDO
154 ENDDO
155 ELSE
156 ! the second half of the month
157 im2=im+1
158 day1 = im*30+15
159 IF (im2.GT.12) THEN
160 ! the month is december, the following thus january
161 im2=1
162 ENDIF
163 day2 = im*30-15
164
165 DO k=1,klev
166 DO i=1,klon
167 pi_sulfate(i,k) = pi_so4(i,k,im2) &
168 - FLOAT(iday-day2)/FLOAT(day1-day2) &
169 * (pi_so4(i,k,im2) - pi_so4(i,k,im))
170 IF (pi_sulfate(i,k).LT.0.) THEN
171 IF (iday-day2.LT.0.) write(*,*) 'iday-day2',iday-day2
172 IF (pi_so4(i,k,im2) - pi_so4(i,k,im).LT.0.) &
173 write(*,*) 'pi_so4(i,k,im2) - pi_so4(i,k,im)', &
174 pi_so4(i,k,im2) - pi_so4(i,k,im)
175 IF (day1-day2.LT.0.) write(*,*) 'day1-day2',day1-day2
176 stop 'pi_sulfate'
177 endif
178 ENDDO
179 ENDDO
180 ENDIF
181
182
183 !JLD ! The sulfate concentration [molec cm-3] is read in.
184 !JLD ! Convert it into mass [ug SO4/m3]
185 !JLD ! masse_so4 in [g/mol], n_avogadro in [molec/mol]
186 DO k=1,klev
187 DO i=1,klon
188 !JLD pi_sulfate(i,k) = pi_sulfate(i,k)*masse_so4
189 !JLD . /n_avogadro*1.e+12
190 pi_so4_out(i,k) = pi_sulfate(i,k)
191 ENDDO
192 ENDDO
193
194 ELSE ! If no new day, use old data:
195 DO k=1,klev
196 DO i=1,klon
197 pi_sulfate(i,k) = pi_so4_out(i,k)
198 ENDDO
199 ENDDO
200 ENDIF ! Was this the beginning of a new day?
201
202 END SUBROUTINE readsulfate_preind
203
204 end module readsulfate_preind_m

  ViewVC Help
Powered by ViewVC 1.1.21