OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
afrt_rt2_process.f
Go to the documentation of this file.
1 c***********************************************************************
2 c
3 c
4 c radiative transfer program (part 2)
5 c
6 c
7 
8  SUBROUTINE af_rt2_process(odir,ailm,aisd,airh,aitau,aiwnd,airef,
9  1 aitrans,aiset,airh1,airh2,ailm1,ailm2,aisd1,aisd2,aitau1,aitau2,
10  2 aithe01,aithe02,aiwnd1,aiwnd2,anx,anthe0,anwl,anrh,ansd,aiww,akrhum,aiprin,
11  3 aipol,anpass1,anpass2,aicrft,aiactflx,aisurf,aiglint,aiocn,aifoam,
12  4 aiwatr,aiconc,adtheta,adphi,ahcrft,arx,athe0in,awwl,aalbwat,
13  5 aifunc,amfunc,arefr,arefi,armin,armax,adelr,adelx,arg,asig,anpar,
14  6 ar11,ar22,ar33,ar44,areff,aveff,accn,absr,
15  7 asalb,aasf,aqscat,aqext,at,athd,
16  8 axr,axi,av,athcel,aphcel,atxx,apti,awvlth,apsrfc,arrho,
17  9 axozn,atautot,adeltau,atrp,atmp,atap,atcar,atwat,atozn,
18  * ahtlvl,applvl,adtrr,adtmm,adtaa,adtot,ahtdv,apdv,
19  * ataur,ataum,ataua,aifc,anmodl,anolyr,aipsudo,abfr,
20  * otma,otmb,otmc,otmfd,otmfu,otms,otmg,otmh,otmp,otmq,otmt,otmpp,otmqq,
21  * otmrr,otmss,otransm,otmcfd,otmcfu,otmf1,otmf2,oxzeroz,oxzerod,otupz,
22  * otdwnz)
23 c
24 c***********************************************************************
25 c.....include the common and declaration statemnets.....................
26  implicit real*8 (a-h,o-z)
27  include 'afrt_rt2.cmn'
28 c
29  integer*4 ailm,airh,aisd,aitau,aiwnd,aifc,anmodl,anolyr,
30  1 aiww(nwnd),akrhum(nw),aifunc,amfunc,aipsudo
31  integer*4 airef,aiprin,aipol,anpass1,anpass2,ailm1,ailm2,aisd1,aisd2,
32  1 aitau1,aitau2,aithe01,aithe02,aiwind,aifoam,aiwatr,aiconc,
33  2 anx,anthe0,aisza,aksza,aicrft,aiactflx,aisurf,aiglint,aiocn,
34  3 aiwnd1,aiwnd2,aitrans,anwl,anrh,ansd,aiset,airh1,airh2
35  real*8 ar11,ar22,ar33,ar44,areff,aveff,accn,absr,asalb,aasf,
36  1 arefr(nmd),arefi(nmd),armin(nmd),armax(nmd),
37  2 adelr(nmd),adelx(nmd),arg(nmd),asig(nmd),anpar(nmd),
38  3 aqscat,aqext,at(ntf,nstk),athd(ntf),atxx(ntrx,nph,nth,nsz),
39  4 apti(npti,nph,nth,nsz),awvlth,apsrfc,arrho,axozn,
40  5 atautot,adeltau,atrp,atmp,atap,atcar,atwat,atozn,
41  6 ahtlvl(nlyr),applvl(nlyr),adtrr(nlyr),adtmm(nlyr),
42  7 adtaa(nlyr),adtot(nlyr),ahtdv(nlyr),apdv(nlyr),
43  8 ataur(nlyr),ataum(nlyr),ataua(nlyr)
44  real*8 axr,axi,av,athcel,aphcel,xxx,zzz
45  real*8 adtheta,adphi,ahcrft,totl(1000),dtotl(1000)
46  real*8 arx(nph),athe0in(nsz),awwl(nw),aalbwat(nwnd)
47  real*4 abfr(nlyr)
48  real*8 otma(nsz),otmb(nsz),otmc(nsz),otmfd(nsz),otmfu(nsz),otms(nsz),
49  1 otmg(nsz),otmh(nsz),otmp(nsz),otmq(nsz),otmt(nsz),otmpp(nsz),
50  2 otmqq(nsz),otmrr(nsz),otmss(nsz),otransm(nth),otmcfd(nsz),otmcfu(nsz),
51  3 otmf1(nlyr,nsz),otmf2(nlyr),oxzeroz(nstk,nph,nth,nsz),
52  4 oxzerod(nstk,nph,nth,nsz),otupz(nstk,nph,nth,nsz),
53  5 otdwnz(nstk,nph,nth,nsz),oradocn(nph,nth,nsz)
54 c 5 ocrfttup(nph,nth,nsz),
55 c 6 ocrftzu(nph,nth,nsz),ocrfttdn(nph,nth,nsz),
56 c 7 ocrftzd(nph,nth,nsz),osurfzu(nph,nth,nsz),
57 c 8 oradsky(nph,nth,nsz),oraddir(nph,nth,nsz)
58  real*8 glint_tmp(4,2*nsz,nph)
59  real*4 ee(2),qspp(2*nsz)
60  character*255 odir,xname1,xname2
61  character*1 ciconc
62  character*2 ciwind
63  character*2 citau,crh,cset
64  character*2 cisd,cilmd,cwind
65  character*4 cilm
66  logical OK
67 
68  otma(:)=0.0
69  otmb(:)=0.0
70  otmc(:)=0.0
71  otmfd(:)=0.0
72  otmfu(:)=0.0
73  otms(:)=0.0
74  otmg(:)=0.0
75  otmh(:)=0.0
76  otmp(:)=0.0
77  otmq(:)=0.0
78  otmt(:)=0.0
79  otmpp(:)=0.0
80  otmqq(:)=0.0
81  otmrr(:)=0.0
82  otmss(:)=0.0
83  otransm(:)=0.0
84  otmcfd(:)=0.0
85  otmcfu(:)=0.0
86  otmf1(:,:)=0.0
87  otmf2(:)=0.0
88  oxzeroz(:,:,:,:)=0.0
89  oxzerod(:,:,:,:)=0.0
90  oradocn(:,:,:)=0.0
91  otupz(:,:,:,:)=0.0
92  otdwnz(:,:,:,:)=0.0
93 c ocrfttup(:,:,:)=0.0
94 c ocrftzu(:,:,:)=0.0
95 c ocrfttdn(:,:,:)=0.0
96 c ocrftzd(:,:,:)=0.0
97 c osurfzu(:,:,:)=0.0
98 c oradsky(:,:,:)=0.0
99 c oraddir(:,:,:)=0.0
100 c***********************************************************************
101 c
102 c
103 c get the upper and lower indices for wavelength, size dist. and
104 c optical thickness. also, flags for wind speed, foam, water leaving
105 c radiances and chlorophyll conc.
106 c
107  izia=1
108 c iglint=1 !subtract the glint radiance
109  iocn=1 !wind speed in sigma of slope dist.
110 c call inusr
111 
112  ilm = ailm
113  isd = aisd
114  irh = airh
115  itau = aitau
116  iwnd = aiwnd
117  nolyr = anolyr
118  nmodl = anmodl
119  iref = airef
120  itrans = aitrans
121  iset = aiset
122  irh1 = airh1
123  irh2 = airh2
124  ilm1 = ailm1
125  ilm2 = ailm2
126  isd1 = aisd1
127  isd2 = aisd2
128  itau1 = aitau1
129  itau2 = aitau2
130  ithe01 = aithe01
131  ithe02 = aithe02
132  iwnd1 = aiwnd1
133  iwnd2 = aiwnd2
134  nx = anx
135  nthe0 = anthe0
136  nwl = anwl
137  nrh = anrh
138  iww(:) = aiww(:)
139  krhum(:) = akrhum(:)
140  iprin = aiprin
141  ipol = aipol
142  npass1 = anpass1
143  npass2 = anpass2
144  icrft = aicrft
145  iactflx = aiactflx
146  isurf = aisurf
147  iglint = aiglint
148  iocn = aiocn
149  ifoam = aifoam
150  iwatr = aiwatr
151  iconc = aiconc
152  dtheta = adtheta
153  dphi = adphi
154  hcrft = ahcrft
155  rx(:) = arx(:)
156  the0in(:) = athe0in(:)
157  wwl(:) = awwl(:)
158  albwat(:) = aalbwat(:)
159  ifunc = aifunc
160  mfunc = amfunc
161  xrw = axr
162  xiw = axi
163  vz = av
164  mtha = athcel
165  mphi = aphcel
166  r11 = ar11
167  r22 = ar22
168  r33 = ar33
169  r44 = ar44
170  reff = areff
171  veff = aveff
172  ccn = accn
173  bsr = absr
174  salb = asalb
175  asf = aasf
176  qs = aqscat
177  qt = aqext
178  t(:,:) = at(:,:)
179  thd(:) = athd(:)
180  txx(:,:,:,:) = atxx(:,:,:,:)
181 c pti(:,:,:,:) = apti(:,:,:,:)
182  wvlth = awvlth
183  psrfc = apsrfc
184  rho = arrho
185  xozn = axozn
186  tautot = atautot
187  deltau = adeltau
188  nolyr = anolyr
189  tr = atrp
190  tm = atmp
191  ta = atap
192  tcar = atcar
193  twat = atwat
194  tozn = atozn
195  ifc = aifc
196  ht(:) = ahtlvl(:)
197  pl(:) = applvl(:)
198  dtrr(:) = adtrr(:)
199  dtmm(:) = adtmm(:)
200  dtaa(:) = adtaa(:)
201  dtot(:) = adtot(:)
202  htp(:) = ahtdv(:)
203  ppo(:) = apdv(:)
204  taur(:) = ataur(:)
205  taum(:) = ataum(:)
206  tauabs(:) = ataua(:)
207  ipsudo = aipsudo
208  bfr1(:) = abfr(:)
209  do i=1,1915
210  ebfr1(i)=-777.0
211  ebfr2(i)=-777.0
212  ebfr3(i)=-777.0
213  enddo
214  if(iref.lt.2)then
215  iwnd1=1
216  iwnd2=1
217  endif
218  do i=1,nlyr
219  bfr1(i)=-999.9
220  bfr2(i)=-999.9
221  bfr3(i)=-999.9
222  enddo
223 c bfr1(1)=xyear
224 c bfr1(2)=xmonth
225 c bfr1(3)=xday
226 c bfr1(4)=-777.0
227  bfr1(5)=wvlth*1.0d4
228  bfr1(6)=arefr(1)
229  bfr1(7)=arefi(1)
230  bfr1(8)=arg(1)
231  bfr1(9)=asig(1)
232  bfr1(10)=armin(1)
233  bfr1(11)=armax(1)
234  bfr1(12)=adelx(1)
235  bfr1(13)=reff
236  bfr1(14)=r11
237  bfr1(15)=r22
238  bfr1(16)=r33
239  bfr1(17)=r44
240  bfr1(18)=salb
241  bfr1(19)=asf
242  bfr1(20)=qs
243  bfr1(21)=qt
244  bfr1(22)=av
245  bfr1(23)=axr
246  bfr1(24)=axi
247  bfr1(25)=tr
248  bfr1(26)=tm
249  bfr1(27)=ta
250  bfr1(28)=twat
251  bfr1(29)=tautot
252  bfr1(30)=rho
253  bfr1(31)=ccn
254  bfr1(32)=bsr
255  bfr1(33)=float(ipol)
256  bfr1(34)=float(ipsudo)
257  bfr1(41)=dfloat(ifoam)
258  bfr1(42)=dfloat(iwatr)
259 c bfr1(43)=chl(iconc)
260  bfr1(44)=albwat(ilm)
261  bfr1(45)=dfloat(iref)
262  bfr1(46)=psrfc
263  bfr1(47)=dfloat(ifc)
264  bfr1(48)=dfloat(ifunc)
265  bfr1(49)=dfloat(mfunc)
266 
267  bfr1(58)=anpar(1)
268  bfr1(59)=arg(2)
269  bfr1(60)=asig(2)
270  bfr1(61)=anpar(2)
271  bfr1(62)=adelx(2)
272  bfr1(63)=arefr(2)
273  bfr1(64)=arefi(2)
274  bfr1(65)=armin(2)
275  bfr1(66)=armax(2)
276  bfr1(67)=arg(3)
277  bfr1(68)=asig(3)
278  bfr1(69)=anpar(3)
279  bfr1(70)=adelx(3)
280  bfr1(71)=arefr(3)
281  bfr1(72)=arefi(3)
282  bfr1(73)=armin(3)
283  bfr1(74)=armax(3)
284  bfr1(76)=itrans
285 c
286 c write(*,*) ilm, isd, irh, itau, iwnd
287 c
288  len=index(odir,' ')-1
289  call convtc(idnint(awwl(ilm)*1.0d3+0.01),4,cilm)
290 c write(*,*) awwl(ilm),cilm
291  iisd = mod(isd-1,ansd/anrh) + 1
292  call convtc(iisd,2,cisd)
293  call convtc(itau,2,citau)
294  call convtc(iwnd-1,2,ciwind)
295 c call convtc(iconc,1,ciconc)
296 c call convtc(iww(iwind),2,cwind)
297  call convtc(krhum(isd),2,crh)
298  call convtc(iset,2,cset) !iset is passed through the common block zeroa
299 c
300  if(iref.eq.1)ciwind='00'
301  if(iref.eq.0)ciwind='99'
302  if(iset.eq.0)crh='00' !iset is read in sub. inusr and passed through common zeroa
303 c
304  xname1='rt2_wl'//cilm//'x'//ciwind
305  xname2='sd'//cisd//'rh'//crh//'ta'//citau//'_set'//cset
306  nm1=index(xname1,' ')-1
307  nm2=index(xname2,' ')-1
308  open(3,file=
309  1 odir(1:len)//'/'//xname1(1:nm1)//xname2(1:nm2)//'dn.dat',
310  2 status='unknown')
311  open(4,file=
312  1 odir(1:len)//'/'//xname1(1:nm1)//xname2(1:nm2)//'up.dat',
313  2 status='unknown')
314  open(24,file=
315  1 odir(1:len)//'/'//xname1(1:nm1)//xname2(1:nm2)//'.dat',
316  2 access='direct',recl=1915*4,
317  3 form='unformatted',status='unknown',convert='big_endian')
318 c
319  if(icrft.eq.1)then
320  open(13,file=
321  1 odir(1:len)//'/'//xname1(1:nm1)//xname2(1:nm2)//'crftdn.dat',
322  2 status='unknown')
323  open(14,file=
324  1 odir(1:len)//'/'//xname1(1:nm1)//xname2(1:nm2)//'crftup.dat',
325  2 status='unknown')
326  open(15,file=
327  1 odir(1:len)//'/'//xname1(1:nm1)//xname2(1:nm2)//'crft.dat',
328  2 access='direct',recl=1915*4,
329  3 form='unformatted',status='unknown',convert='big_endian')
330  endif
331 c
332  if(iactflx.eq.1)then
333  open(30,file=
334  1 odir(1:len)//'/'//xname1(1:nm1)//xname2(1:nm2)//'flx.dat',
335  2 status='unknown')
336  endif
337 c
338  if(isurf.eq.1)then
339  open(16,file=
340  1 odir(1:len)//'/'//xname1(1:nm1)//xname2(1:nm2)//'surfup.dat',
341  2 status='unknown')
342  if(airef.eq.2)then
343  open(41,file=
344  1 odir(1:len)//'/'//xname1(1:nm1)//xname2(1:nm2)//'dirup.dat',
345  2 status='unknown')
346  open(42,file=
347  1 odir(1:len)//'/'//xname1(1:nm1)//xname2(1:nm2)//'ocnup.dat',
348  2 status='unknown')
349  open(43,file=
350  1 odir(1:len)//'/'//xname1(1:nm1)//xname2(1:nm2)//'skyup.dat',
351  2 status='unknown')
352  endif
353  endif
354 
355  open(53,access='direct',
356 c 1 form='unformatted',status='scratch',recl=18400*96)
357  1 form='unformatted',status='scratch',recl=18400*4)
358  open(54,access='direct',
359  1 form='unformatted',status='scratch',recl=18400*4)
360  open(55,access='direct',
361  1 form='unformatted',status='scratch',recl=18400*4)
362  open(64,access='direct',
363  1 form='unformatted',status='scratch',recl=18400*4)
364  open(65,access='direct',
365  1 form='unformatted',status='scratch',recl=18400*4)
366  open(71,access='direct',
367  1 form='unformatted',status='scratch',recl=18400*4)
368  open(72,access='direct',
369  1 form='unformatted',status='scratch',recl=18400*4)
370 c
371  if(icrft.eq.1)then
372  open(73,access='direct',
373  1 form='unformatted',status='scratch',recl=18400*4)
374  open(74,access='direct',
375  1 form='unformatted',status='scratch',recl=18400*4)
376  endif
377 
378  if(icrft.eq.1)then
379  call crftlvl
380  endif
381  xlam=wvlth
382  alw=albwat(ilm)
383 
384 c loop over solar zenith angle
385  pi=dacos(-1.0d0)
386  conv=pi/180.0d0
387  nmum1=2*nx-2
388  nophi=360.0d0/dphi
389  jpart=nophi/2+1
390  ddphi=dphi*conv
391  const=wvlth**2/(4.0*pi**2*qs)
392  qsqt=qs/qt
393  conr=3.0d0/(8.0d0*pi)
394  nsza=0
395  do ksza=ithe01,ithe02,1
396  isza=ksza-ithe01+1
397  msza(isza)=ksza
398  nsza=nsza+1
399  calb=0.0d0
400  jpass=1
401  do i=1,nmum1
402  c(i)=1.
403  enddo
404  do ij=1,2*nmum1
405  do ik=1,4
406  pp(ij,ik)=0.0d0
407  qq(ij,ik)=0.0d0
408  enddo
409  enddo
410  do i=1,2
411  ei(i)=0.50d0
412  ei(i+2)=0.0d0
413  enddo
414  do i=1,nx
415  j=2*nx-i
416  rmu(i)=rx(i)
417  rmu(j)=180.0-rx(i)
418  enddo
419  rmuo=the0in(ksza)
420  do i=1,nmum1+1
421  cmu(i)=dcos(rmu(i)*conv)
422  enddo
423  do i=1,nmum1
424  xmu = (rmu(i)+rmu(i+1))/2.0d0
425  the(i)=xmu
426  if(i .gt. nx-1)then
427  the(i)=the(nmum1-i+1)
428  endif
429  if(dabs(xmu-rmuo).le.1.0d-3)then
430  amuo=dcos(xmu*conv)
431  kkx=i
432  endif
433  cosmu(i)=dcos(xmu*conv)
434  sinmu(i)=dsin(xmu*conv)
435  enddo
436  do l=1,nophi+1
437  phi(l)=(l-1.0d0)*dphi
438  jphi(l)=phi(l)+0.001
439  enddo
440  do i=1,jpart
441  th=(i-1)*dphi*conv
442  costh(i)=dcos(th)
443  sinth(i)=dsin(th)
444  enddo
445  do i=1,nmum1
446  dcmusq(i)=(cmu(i)**2-cmu(i+1)**2)/2.d0
447  dcmu(i) = cmu(i) - cmu(i+1)
448  enddo
449  if(isza.eq.1)then
450  call hdrmds(ithe01,ithe02,ebfr1)
451  endif
452 c if ipsudo=1 then determine optical path length for
453 c spherical atmosphere
454  if(ipsudo.eq.1)then
455  call spathz(amuo,htp,taur,taum,tauabs,totsp,nmodl)
456  endif
457 c determine an average value of phase matrix in the forward/
458 c backward direction
459  if(ifc.eq.1)then
460  call hump (const,t,pp,nmum1,dphi+0.001d0,rmu,thd,0,nmum1+1)
461  call hump (const,t,qq,nmum1,dphi+0.001d0,rmu,thd,1,nmum1+1)
462  endif
463  if(iref.eq.2)then
464 c read(19)xrw,xiw,vz,mtha,mphi
465  call anglw
466  endif
467 c compute the attenuation parameters
468 c determine the total optical thickness at every level in the atmosphere
469  taupl(1)=0.0d0
470  do i=1,nolyr
471  taupl(i+1)=taupl(i)+dtot(i)
472  enddo
473  totl(1)=1.0d-10
474  efactb(1)=1.0d0
475  if(ipsudo.eq.1)then
476  do i=2,(nolyr+1)
477  call spline(pl(i),ppo,totsp,nmodl,1,totl(i),1,1,vl,vu,e,u)
478  enddo
479  do i=1,nolyr
480  dtotl(i)=totl(i+1)-totl(i)
481  enddo
482 c compute the solar attenuation upto the middle as well as
483 c bottom of the layer
484  do i=1,nolyr
485  efact(i)=dexp(-(0.5d0*dtotl(i)+totl(i)))
486  efactb(i+1)=dexp(-totl(i+1))
487  enddo
488  eo(1)=0.5d0*dexp(-totl(nolyr+1))
489  eo(2)=0.5d0*dexp(-totl(nolyr+1))
490  else
491 c compute the solar attenuation up to the middle as well as
492 c bottom of the layer (plane parallel case)
493  do i=1,nolyr
494  totl(i+1)=totl(i)+dtot(i)
495  efact(i)=dexp(-(0.50d0*dtot(i)+taupl(i))/amuo)
496  efactb(i+1)=dexp(-taupl(i+1)/amuo)
497  enddo
498  eo(1)=0.5d0*dexp(-taupl(nolyr+1)/amuo)
499  eo(2)=0.5d0*dexp(-taupl(nolyr+1)/amuo)
500  endif
501  do i=1,nolyr
502  do j=1,nmum1
503  emdtm(i,j)=dexp(-dtot(i)/dabs(cosmu(j)))
504  emtm(i,j)=dexp(-(totl(i+1)-0.5d0*dtot(i))/dabs(cosmu(j)))
505  enddo
506  enddo
507  do i=1,nolyr+1
508  do j=1,nx-1
509  atnflx(i,j)=dexp(-totl(i)/dabs(cosmu(j)))
510  enddo
511  enddo
512 c compute the scattering phase matrices (rayleigh/aerosol)
513 c compute gamma for molecular depolarization correction
514  if(ipol.eq.1)then
515  gam=rho/(2.0-rho)
516  agm=(1.0-gam)/(1+2.0*gam)
517  bgm=gam/(1.0+2.0*gam)
518  cgm=(1.0-3.0*gam)/(1.0+2.0*gam)
519  endif
520 c compute phase matrices for first scatter
521  kk=kkx
522  do ii=1,nmum1
523  call matrx
524  do i=1,jpart
525  do k=1,32
526  pc(k,i,ii)=p(k,i)
527  enddo
528  enddo
529  enddo
530 c compute phase matrices for second scatter
531  qsp(:)=0.
532  do ii=1,nmum1
533  do kk=1,nmum1
534  call matrx
535  do i=1,jpart
536  do k=1,32
537  ppin(k,i,ii,kk)=p(k,i)
538  enddo
539  enddo
540  enddo
541  if(ifc.ne.0) then
542  ee(1) = 0.5
543  ee(2) = 0.5
544  do k=1,(nx-1)
545  i=ii
546  qspp(i)=0.
547  do m=1,jpart
548  xfot=const*(ee(1)*(ppin(1,m,i,k)+ppin(5,m,i,k))+
549  1 ee(2)*(ppin(2,m,i,k)+ppin(6,m,i,k)))
550  if(m.eq.1.or.m.eq.jpart) then
551  qspp(i)=qspp(i)+xfot
552  else
553  qspp(i)=qspp(i)+2.*xfot
554  endif
555  enddo
556  qsp(k)=qsp(k)+qspp(i)*dcmu(i)*ddphi
557  enddo
558  endif
559  enddo
560  if(ifc .ne. 0) then
561  do i=1,(nx-1)
562  c(i)=1.d0/qsp(i)
563  c(nmum1+1-i)=c(i)
564  enddo
565  endif
566 c begin radiative transfer calculations
567  ibgn=1
568  iend=1
569  if(nsza.eq.1 .and. (iref.eq.0 .or. itrans.eq.1) )then
570  iend=2
571  endif
572 c illumination from the top of the atmosphere(kzz=1)
573 c illumination from the bottom of the atmosphere(kzz=2)
574  do kzz=ibgn,iend,1
575  jpass=1
576  nump=npass1
577  do k=1,2
578  do i=1,nx-1
579  do j=1,jpart
580  d1px(k,i,j)=0.0d0
581  d2px(k,i,j)=0.0d0
582  enddo
583  enddo
584  enddo
585  if(nsza.eq.1 .and. (iref.eq.0 .or. itrans.eq.1) )then
586  nump=npass2
587  endif
588  if(kzz.eq.1)then
589  call single
590  minitr=4
591  endif
592  if(kzz.eq.2 .and. iref.eq.0)then
593  call grefl
594  call snglup
595  minitr=4
596  endif
597  if(kzz.eq.2 .and. itrans.eq.1)then
598  call focn_below
599  call snglup
600  minitr=4
601  endif
602  call getrad
603  do ka=1,nump
604 c initialize the disk units
605  kdx=ka-(ka/2)*2
606  if(kdx.eq.1)then
607  irad=64
608  iwrt=65
609  else
610  irad=65
611  iwrt=64
612  endif
613  if(kzz.eq.1)then
614  call multp1d
615  elseif(kzz.eq.2 .and. iref.eq.0)then
616  call multp2d
617  elseif(kzz.eq.2 .and. itrans.eq.1)then
618  call multp2d_trans
619  endif
620  jpass=jpass+1
621  call getrad
622  call contst
623  call fiotb
624  if(iactflx.eq.1)then
625  call actflx
626  endif
627  if(jpass.ge.minitr)then
628  if(d3.le.0.1 .or. jpass.ge.20) exit
629  endif
630  enddo
631  if(kzz.eq.1 .and. iglint.eq.1)then
632  do k=1,4
633  do i=nx,nmum1
634  do j=1,jpart
635  glint_tmp(k,i,j)=fglint(k,i,j)*
636  1 dexp(-tautot/dabs(cosmu(i)))
637  enddo
638  enddo
639  enddo
640 c if(kzz .eq.2)then
641 c do i=nx,nmum1
642 c call radnce(pi,conv,cosmu,the,fio,i,jpart,jphi)
643 c enddo
644 c endif
645  endif
646  call geocor
647  if(icrft.eq.1)then
648  call crftgcr
649  endif
650  if(iactflx.eq.1)then
651  call actfgrc
652  endif
653  if(isurf.eq.1)then
654  call surfgcr
655  endif
656 c illumination from bottom is done only once
657  if(kzz.eq.2) exit
658  enddo
659  enddo
660  lsza=bfr1(35)+0.001
661  do i=1,lsza,1
662  m=msza(i)
663  otma(i)=the0in(m)
664  otmb(i)=fdirc(m)
665  otmc(i)=sbarz(m)
666  otmfd(i)=fdown(m)
667  otmfu(i)=fup(m)
668  otms(i)=oalb(m)
669  otmg(i)=albtdr(m)
670  otmh(i)=albtdf(m)
671  otmp(i)=albtrf(m)
672  otmq(i)=albwl(m)
673  otmpp(i)=otmq(i)/(otmb(i)+otmfd(i))
674  otmqq(i)=otms(i)-otmpp(i)
675  otmrr(i)=albrdr(m)
676  otmss(i)=albrdf(m)
677  do is=1,jpart
678  do ir=1,(nx-1)
679  do ik=1,nstk
680  oxzerod(ik,is,ir,m) = xzerod(ik,m,ir,is)
681  oxzeroz(ik,is,ir,m) = xzeroz(ik,m,ir,is)
682  enddo
683  enddo
684  enddo
685  enddo
686  m=msza(1)
687  do ir=1,(nx-1)
688  otransm(ir)=xzero_up(m,ir,1)/xzero_btm(m,ir,1)
689  enddo
690 
691 c create output datasets for upwelling and downwelling radiances
692 c leaving the top and bottom of the atmosphere
693  if((iref.eq.1 .or. iref.eq.2) .and. itrans.eq.1)then
694  call outdt_trans(otransm,oxzeroz)
695  endif
696  if(iref.eq.1 .or. iref.eq.2 .or. iref.eq.3)then
697  call outdty(oxzeroz,oxzerod)
698  if(icrft.eq.1)then
699 c call outcrfty(otmcfd,otmcfu,ocrftzu,ocrftzd)
700  endif
701  if(iactflx.eq.1)then
702 c call outactfy(otmf1)
703  endif
704  if(isurf.eq.1)then
705  call outsurfy(osurfzu)
706  if(iref.eq.2)then
707 c call outsurfdir(oraddir)
708  call outsurfocn(oradocn)
709 c call outsurfsky(oradsky)
710  endif
711  endif
712  endif
713 c
714  if(iref.eq.0 .and.itrans.eq.0)then
715  call outdtz(otupz,oxzeroz,otdwnz,oxzerod)
716  if(icrft.eq.1)then
717 c write(*,*)'ready to call outcrftz'
718 c call outcrftz(otmcfd,otmcfu,ocrfttup,ocrftzu,ocrfttdn,ocrftzd)
719  endif
720  if(iactflx.eq.1)then
721 c call outactfz(otmf1,otmf2)
722  endif
723  endif
724 c close the temp files
725 c close (18)
726 c close (19)
727  INQUIRE( unit=53, opened=ok )
728  IF ( ok ) close (53)
729  INQUIRE( unit=54, opened=ok )
730  IF ( ok ) close (54)
731  INQUIRE( unit=55, opened=ok )
732  IF ( ok ) close (55)
733  INQUIRE( unit=64, opened=ok )
734  IF ( ok ) close (64)
735  INQUIRE( unit=65, opened=ok )
736  IF ( ok ) close (65)
737  INQUIRE( unit=71, opened=ok )
738  IF ( ok ) close (71)
739  INQUIRE( unit=72, opened=ok )
740  IF ( ok ) close (72)
741  INQUIRE( unit=73, opened=ok )
742  IF ( ok ) close (73)
743  INQUIRE( unit=74, opened=ok )
744  IF ( ok ) close (74)
745  INQUIRE( unit=3, opened=ok )
746  IF ( ok ) close (3)
747  INQUIRE( unit=4, opened=ok )
748  IF ( ok ) close (4)
749  INQUIRE( unit=6, opened=ok )
750  IF ( ok ) close (6)
751  INQUIRE( unit=13, opened=ok )
752  IF ( ok ) close (13)
753  INQUIRE( unit=14, opened=ok )
754  IF ( ok ) close (14)
755  INQUIRE( unit=15, opened=ok )
756  IF ( ok ) close (15)
757  INQUIRE( unit=16, opened=ok )
758  IF ( ok ) close (16)
759  INQUIRE( unit=24, opened=ok )
760  IF ( ok ) close (24)
761  INQUIRE( unit=30, opened=ok )
762  IF ( ok ) close (30)
763 c**********************************************************************
764 c format statements
765 355 format( t10,'fresnel reflection (by a rough surface)',1x,
766  1 'at the lower boundary '/ t10,'refractive index',t45,'=',1pe15.5,
767  2 '-',1pe15.5,'i' / t10,'velocity',t45,'=', 1pe15.5,'meter/sec'/)
768 c***********************************************************************
769  return
770  end
771 c**********************************************************************
an array had not been initialized Several spelling and grammar corrections were which is read from the appropriate MCF the above metadata values were hard coded A problem calculating the average background DN for SWIR bands when the moon is in the space view port was corrected The new algorithm used to calculate the average background DN for all reflective bands when the moon is in the space view port is now the same as the algorithm employed by the thermal bands For non SWIR changes in the averages are typically less than Also for non SWIR the black body DNs remain a backup in case the SV DNs are not available For SWIR the changes in computed averages were larger because the old which used the black body suffered from contamination by the micron leak As a consequence of the if SV DNs are not available for the SWIR the EV pixels will not be the granule time is used to identify the appropriate tables within the set given for one LUT the first two or last two tables respectively will be used for the interpolation If there is only one LUT in the set of it will be treated as a constant LUT The manner in which Earth View data is checked for saturation was changed Previously the raw Earth View DNs and Space View DNs were checked against the lookup table values contained in the table dn_sat The change made is to check the raw Earth and Space View DNs to be sure they are less than the maximum saturation value and to check the Space View subtracted Earth View dns against a set of values contained in the new lookup table dn_sat_ev The metadata configuration and ASSOCIATEDINSTRUMENTSHORTNAME from the MOD02HKM product The same metatdata with extensions and were removed from the MOD021KM and MOD02OBC products ASSOCIATEDSENSORSHORTNAME was set to MODIS in all products These changes are reflected in new File Specification which users may consult for exact the pow functions were eliminated in Emissive_Cal and Emissive bands replaced by more efficient code Other calculations throughout the code were also made more efficient Aside from a few round off there was no difference to the product The CPU time decreased by about for a day case and for a night case A minor bug in calculating the uncertainty index for emissive bands was corrected The frame index(0-based) was previously being used the frame number(1-based) should have been used. There were only a few minor changes to the uncertainty index(maximum of 1 digit). 3. Some inefficient arrays(Sigma_RVS_norm_sq) were eliminated and some code lines in Preprocess_L1A_Data were moved into Process_OBCEng_Emiss. There were no changes to the product. Required RAM was reduced by 20 MB. Now
subroutine actflx
Definition: actflx.f:2
subroutine multp2d_trans
Definition: multp2d_trans.f:2
subroutine hump(const, t, tp, nm, lp, rmu, thd, ixy, nmu)
Definition: hump.f:2
subroutine focn_below
Definition: focn_below.f:2
subroutine fiotb
Definition: fiotb.f:2
subroutine anglw
Definition: anglw.f:2
subroutine grefl
Definition: grefl.f:2
subroutine ccn(ifunc, irgm)
Definition: phs.f:940
subroutine snglup
Definition: snglup.f:2
subroutine spline(s, x, y, n, in, t, il, iu, vl, vu, e, u)
Definition: phs.f:1348
subroutine spathz(amu0, htp, taur, taum, taua, totsp, nmodl)
Definition: spathz.f:2
subroutine hdrmds(nthe01, nthe02, ebfr1)
Definition: hdrmds.f:2
#define real
Definition: DbAlgOcean.cpp:26
subroutine const(NGAUSS, NMAX, MMAX, P, X, W, AN, ANN, S, SS, NP, EPS)
Definition: ampld.lp.f:924
subroutine multp2d
Definition: multp2d.f:2
subroutine contst
Definition: contst.f:2
subroutine surfgcr
Definition: surfgcr.f:2
subroutine outdtz(otupz, oxzeroz, otdwnz, oxzerod)
Definition: outdtz.f:2
subroutine outsurfy(osurfzu)
Definition: outsurfy.f:2
subroutine geocor
Definition: geocor.f:2
subroutine multp1d
Definition: multp1d.f:2
subroutine matrx
Definition: matrx.f:2
subroutine outdty(oxzeroz, oxzerod)
Definition: outdty.f:2
subroutine outsurfocn(oradocn)
Definition: outsurfocn.f:2
subroutine crftgcr
Definition: crftgcr.f:2
#define pi
Definition: vincenty.c:23
float ei(float x)
subroutine single
Definition: single.f:2
subroutine outdt_trans(transm, oxzeroz)
Definition: outdt_trans.f:2
subroutine crftlvl
Definition: crftlvl.f:2
subroutine getrad
Definition: getrad.f:2
subroutine convtc(num, nchar, loc)
Definition: ocn.f:156
subroutine actfgrc
Definition: actfgrc.f:2
subroutine af_rt2_process(odir, ailm, aisd, airh, aitau, aiwnd, airef, aitrans, aiset, airh1, airh2, ailm1, ailm2, aisd1, aisd2, aitau1, aitau2 aithe01, aithe02, aiwnd1, aiwnd2, anx, anthe0, anwl, anrh, ansd, aiww, ak aipol, anpass1, anpass2, aicrft, aiactflx, aisurf, aiglint, aiocn, aifo aiwatr, aiconc, adtheta, adphi, ahcrft, arx, athe0in, awwl, aalbwat, aifunc, amfunc, arefr, arefi, armin, armax, adelr, adelx, arg, asig, anpa ar11, ar22, ar33, ar44, areff, aveff, accn, absr, asalb, aasf, aqscat, aqext, at, athd, axr, axi, av, athcel, aphcel, atxx, apti, awvlth, apsrfc, arrho, axozn, atautot, adeltau, atrp, atmp, atap, atcar, atwat, atozn, ahtlvl, applvl, adtrr, adtmm, adtaa, adtot, ahtdv, apdv, ataur, ataum, ataua, aifc, anmodl, anolyr, aipsudo, abfr, otma, otmb, otmc, otmfd, otmfu, otms, otmg, otmh, otmp, otmq, otmt, otmpp, otmrr, otmss, otransm, otmcfd, otmcfu, otmf1, otmf2, oxzeroz, oxzerod, o otdwnz)