BUGSrad
 All Classes Files Functions Variables
driver_read.f90
Go to the documentation of this file.
1 
2 
3 ! CVS: $Id: driver_read.F,v 1.10 2003/11/11 21:55:13 norm Exp $
4 ! CVS: $Name: $
5 
6 
7 !-----------------------------------------------------------------------
8  program driver_read
9 
10  use kinds, only: int_kind, dbl_kind
11  use bugsrad_physconst, only: gravity, cp_dry_air, sol_const
12 
13  implicit none
14 
15 !-----------------------------------------------------------------------
16 ! driver_read is the main routine for running the CSU radiative transfer
17 ! code offline (that is, apart from the CSU GCM). It reads a profile
18 ! from a file and also specifies variables that are not read in. It
19 ! then calls BUGSrad to do the radiative transfer. This driver is not
20 ! used when the code is compiled online with the CSU GCM.
21 
22 ! REFERENCES:
23 ! Phil Partain /wombat (04-04-00).
24 
25 ! MODIFICATIONS:
26 ! * changed declarations to adapt the code from BUGS4 to BUGS5.
27 ! Laura D. Fowler/slikrock (02-01-00).
28 
29 ! SUBROUTINES CALLED:
30 ! bugs_rad :The radiative transfer code
31 
32 ! FUNCTIONS CALLED:
33 ! none.
34 
35 ! INCLUDED COMMON BLOCKS:
36 ! none.
37 
38 ! LOCAL VARIABLES:
39  integer (kind=int_kind):: &
40  nlen,& !Length of total domain.
41  len,& !Length of sub domain.
42  nlm,& !Number of layers.
43  i,l
44 
45  real (kind=dbl_kind), dimension(:), allocatable:: &
46  ts ,& !Surface temperature (K).
47  amu0 ,& !Cosine of solar zenith angle (-).
48  slr ,& !Fraction of daylight (-).
49  alvdr,& !Visible direct surface albedo (-).
50  alndr,& !Near-IR direct surface albedo (-).
51  alvdf,& !Visible diffuse surface albedo (-).
52  alndf,& !Near-IR diffuse surface albedo (-).
53  umco2,& !Col-avg concentration CO2 (ppm).
54  umch4,& !Col-avg concentration CH4 (ppm).
55  umn2o !Col-avg concentration N2O (ppm).
56 
57  real (kind=dbl_kind), dimension(:,:), allocatable:: &
58  pl,& !Layer pressure (hPa).
59  dpl,& !Layer thickness (hPa).
60  tl ,& !Temperature (K).
61  ql ,& !Specific humidity (kg/kg).
62  qcwl ,& !Cloud water mixing ratio (kg/kg).
63  qcil,& !Cloud ice mixing ratio (kg/kg).
64  qrwl,& !Rain mixing ratio (kg/kg).
65  qril,& !Snow mixing ratio (kg/kg).
66  o3l,& !Ozone mixing ratio (kg/kg).
67  acld !Radiative cloud fraction (-).
68 
69  !Note that rain mixing ratio is unused by BUGSrad, but I've put it
70  !into the std_profile.dat file for completeness
71 
72  real (kind=dbl_kind), dimension(:,:), allocatable:: &
73  pl2 !Level pressure (hPa).
74 
75  real (kind=dbl_kind), dimension(:,:), allocatable:: &
76  atl ,& !All-sky LW radiative heating rate (K/s).
77  asl ,& !All-sky SW radiative heating rate (K/s).
78  fulw,& !All-sky LW upwelling flux (W/m^2).
79  fdlw,& !All-sky LW downwelling flux (W/m^2).
80  fusw,& !All-sky SW upwelling flux (W/m^2).
81  fdsw !All-sky SW downwelling flux (W/m^2).
82 
83  !For timing
84  real, dimension(2) :: tarray
85  real :: dtime, elapsed
86 
87  ! For reading the file
88  character(LEN=1) :: l0
89  character(LEN=200) :: line
90 !-----------------------------------------------------------------------
91 
92 !---- 1. READ PROFILE DATA FROM FILE:
93  write(*,*) 'Reading profile data from profile.dat.'
94 ! open(10,file='profile.dat',action='read')
95 
96  l0='#'
97  do while (l0=='#')
98  read(*,"(A)") line
99  read(line(1:1),"(A)") l0
100  enddo
101  read(line,*) nlm
102  nlen = 1 !to do timing tests
103  len = nlen
104 !---- ALLOCATE ARRAYS
105  allocate(ts(nlen) , amu0(nlen) , slr(nlen))
106 
107  allocate(alvdr(nlen) , alndr(nlen) , alvdf(nlen), alndf(nlen))
108  allocate(umco2(nlen), umch4(nlen), umn2o(nlen))
109  allocate(pl(nlen,nlm), dpl(nlen,nlm), tl(nlen,nlm), ql(nlen,nlm), &
110  qcwl(nlen,nlm) , qcil(nlen,nlm), qrwl(nlen,nlm), qril(nlen,nlm), &
111  o3l(nlen,nlm), acld(nlen,nlm))
112 
113  allocate(pl2(nlen,nlm+1))
114 
115  allocate(atl(nlen,nlm), asl(nlen,nlm), fulw(nlen,nlm+1), &
116  fdlw(nlen,nlm+1), fusw(nlen,nlm+1), fdsw(nlen,nlm+1))
117 !----
118  do l=1,nlm
119  l0='#'
120  do while (l0=='#')
121  read(*,"(A)") line
122  read(line(1:1),"(A)") l0
123  enddo
124  read(line,*) i,pl(1,l),pl2(1,l),tl(1,l),ql(1,l),o3l(1,l), &
125  qcwl(1,l), qcil(1,l), qrwl(1,l), qril(1,l), acld(1,l)
126  pl2(1,l) = pl2(1,l)/100. !convert from Pascals to millibars
127  pl(1,l) = pl(1,l)/100. !convert from Pascals to millibars
128  enddo
129  l0='#'
130  do while (l0=='#')
131  read(*,"(A)") line
132  read(line(1:1),"(A)") l0
133  enddo
134  read(line,*) pl2(1,nlm+1),ts(1), amu0(1), alvdr(1), alvdf(1), &
135  alndr(1), alndf(1), umco2(1), umch4(1), umn2o(1)
136  pl2(1,nlm+1) = pl2(1,nlm+1)/100. !convert from Pascals to millibars
137  close(10)
138 
139  do l=1,nlm
140  dpl(1,l) = pl2(1,l+1)-pl2(1,l)
141  enddo
142 
143 ! clouds? Hardcoded here, can read in if you want to.
144 !
145 ! qcwl(1,:) = 0.0
146 ! qcil(1,:) = 0.0
147 ! qril(1,:) = 0.0
148 !
149 ! acld(1,:) = 0.0
150 ! acld(1,8) = 0.2
151 ! acld(1,9) = 0.3
152 ! acld(1,12) = 0.25
153 ! acld(1,13) = 0.25
154 ! acld(1,17) = 0.4
155 ! acld(1,18) = 0.3
156 !
157 ! qcil(1,8) = 0.0003
158 ! qcil(1,9) = 0.0003
159 ! qcil(1,12) = 0.0003
160 ! qcil(1,13) = 0.0003
161 ! qcil(1,17) = 0.0003
162 ! qcil(1,18) = 0.0003
163 !
164 
165 !---- 2. COPY PROFILE TO ALL COLUMNS:
166 ! copy the same column to all columns (only useful if testing multiple
167 ! identical columns for timing, otherwise, it doesn't hurt)
168  do i=1,nlen
169  pl2(i,:) = pl2(1,:)
170  pl(i,:) = pl(1,:)
171  dpl(i,:) = dpl(1,:)
172  tl(i,:) = tl(1,:)
173  ql(i,:) = ql(1,:)
174  o3l(i,:) = o3l(1,:)
175  acld(i,:) = acld(1,:)
176  qcwl(i,:) = qcwl(1,:)
177  qcil(i,:) = qcil(1,:)
178  qril(i,:) = qril(1,:)
179  amu0(i) = amu0(1)
180  alvdr(i) = alvdr(1)
181  alvdf(i) = alvdf(1)
182  alndr(i) = alndr(1)
183  alndf(i) = alndf(1)
184  enddo
185 
186 !---- 3. SPECIFY OTHER VARIABLES:
187 ! amu0(:) = 1.0
188 !
189 ! alvdr(:) = 0.2
190 ! alvdf(:) = 0.2
191 ! alndr(:) = 0.2
192 ! alndf(:) = 0.2
193 
194  slr(:) = 1.0
195 
196 !---- 4. CALL THE RADIATIVE TRANSFER CODE:
197  elapsed = dtime(tarray)
198  call bugs_rad(nlen,len,nlm,pl2,pl,dpl,tl,ql,qcwl,qcil,qril, &
199  o3l,ts,amu0,slr,alvdf,alndf,alvdr,alndr,sol_const, &
200  gravity,cp_dry_air,asl,atl,fdsw,fusw,fdlw,fulw, &
201  acld, umco2, umch4, umn2o)
202  elapsed = dtime(tarray)
203 
204 !---- 5. OUTPUT RESULTS:
205 ! print fluxes in W/m2, heating rates in K/day.
206  print *, "Dtime: ", elapsed
207  print *, " Fluxes Plev SW_DN SW_UP LW_DN LW_UP"
208  print *, " Pa W/m^2 W/m^2 W/m^2 W/m^2"
209  do l=1,nlm+1
210  print '(I4,5(F12.3))',l,pl2(1,l),fdsw(1,l),fusw(1,l), &
211  fdlw(1,l),fulw(1,l)
212  enddo
213  print *, 'Heating Rates Play SW LW'
214  print *, ' Pa K/day K/day'
215  do l=1,nlm
216  print '(I4,6X, F12.3,2(F15.5))', &
217  l,pl(1,l),asl(1,l)*86400.,atl(1,l)*86400. !K/day
218  enddo
219 
220  end program driver_read
221 
222 !-----------------------------------------------------------------------