subroutine total(iyear,idoy,nscan,skipit) c c*********************************************************************** c c date c september, 2001 c c author c charlie wellemeyer of ssai c c calling routine c oproc c c purpose c total is the version 8 driver for processing one scan of data of c from the level 1 sbuv record and computing the total ozone used c as first guess in the profiling algorithm. c c modification c c variables c name type i/o description c ---- ---- --- ----------- c c arguments c indbuf i*4 i advance scan pointer if indbuf = 2 c back l i descending orbit if true c year i*4 i year of orbit c idoy i*4 i day of year c igmt i*4 i gmt time (seconds) of current scan c ozmin r*4 i/o minimum ozone for the orbit c ozmax r*4 i/o maximum ozone for the orbit c skipit l*4 o logical indicator of no total ozone sol. c error l*4 o indicates fatal processing error c c common/totret/ c i variables for individual scan c c common/contrl/ c lprint(30) l*4 i printout control flags c c common/lpoly/ c iofset i*4 i offset pointer for table interpolation c c subroutines called c name purpose c ---- ------- c scanin loads data from level 1 file, calc interp coeffs c reflec calculates reflectivity and cloud fraction c oznot estimates ozone using b wavelengths c residue calculates residues c aprsbo interpolates a priori from the ozone profile climatology c aprsbt interpolates temperature profile from the climatology c stnp81 interpolates 81 layer standard profile for first guess c getmsr calculates msr part of radfiance and jacobian c delnbyt calculates temperature impact on calculated n-values c blwcld calculates ozone beneath any cloud present c seterr determines if an error flag should be set c lodtoz loads total ozone portion of output buffer c dtailt prints first guess output to the detail unit c c*********************************************************************** c implicit none c logical skipit, badsza, back, maxitr, error logical frstrf, frstoz, prntit integer iyear,algflg,errflg,iplow,iphigh,iter,idoy, 1 i, j, irefl, nscan, iseq integer lyr,ilmda real delr,delntt, aiadj real delnt(8,11), fgprf(11), guesoz, fteran, grref, clref, pref, 1 flg3lm, flg4lm, dndrp, dndrm, dndr331 real eff(11), delns(8), pcfrac, dnd318 real dnd331, refm, pcld real rad(8),radmsr(8),radss(8),dndom(8),dndx(8,11), 1 dndxmsr(8,11),dndxss(8,11) real apprf(11), delshp(11),dxdom(11),s2prf(11),resbst(8) 1 ,aptmp(11) c integer n, nc, ns, nitr, nref parameter (n = 81, nc = 10, ns = 8, nitr = 8, nref = 1410) c include 'contrl.com' include 'totret.com' include 'lpoly.com' include 'prfprm.com' include 'const.com' include 'stndprof.com' c c 13 layer standard temperature profile for test purposes c real stndtmp(13)/242.474,256.982,269.299,266.250,250.695, 1 236.870,226.994,222.376,217.826,216.597, 2 216.515,236.470,269.728/ c data back/.false./ c c -- load in measurement c skipit=.false. call scanin(iyear,idoy,skipit) c if(xlat.lt.xlatlo.or.xlat.gt.xlathi) skipit=.true. if(skipit) go to 500 c c -- we need to start somewhere in the table c if (xlat .le. 45.) then guesoz = 260. else if (xlat .le. 75) then guesoz = 340. else guesoz = 360. end if c c -- the core of the version 8 sbuv algorithm begins here c c -- calculate the terrain factor c fteran = (1.0-pteran)/0.50 c c -- iterate calls to reflec and oznot to determine first guess ozone c frstrf = .true. frstoz = .true. maxitr = .false. skipit = .false. algflg = 0 errflg = 0 ozonin = guesoz irefl = irflo iter = 0 dndrm = 1.0 dndrp = 1.0 print*,'entering total: iyear,idoy,nscan,xlat,xlon' print*,iyear,idoy,nscan,xlat,xlon 200 continue c c -- compute cloud fraction and reflectivity c call reflec(irefl,iozon,iofset,ilat,xlat,isnow,grref,clref, 1 sza12,pcloud,pteran,ozonin,xnvalm,xnvalp,ramcor,fteran, 2 frstrf,lprint,clfrac,ref,pref,iplow,iphigh, 3 pcfrac,dnd331,dndrm,dndrp) c c -- compute ozone using b wavelength (317 nm) c call oznot(iozon,iofset,ilat,xlat,clfrac,ref,grref, 1 clref,pteran,pcloud,xnvalm,ozonin,fteran,ramcor, 2 frstoz,lprint,skipit,iplow,iphigh,dnd318,estozn) c iter = iter + 1 if (iter.eq.1) then ozonin = estozn if (dnd318/dnd331.lt.2.0) then frstrf = .true. frstoz = .true. irefl = irfhi ozonin = guesoz algflg = 1 endif go to 200 endif c if(iter.gt.12.or.estozn.lt.0.0.or.estozn.gt.900.0) then skipit = .true. maxitr = .true. go to 500 endif c if(abs(estozn-ozonin).gt.1.0) then ozonin = estozn go to 200 endif c c -- calculate residues and sensitivities using ozone estimate c -- calculated above c call residue(estozn,ref,xlat,clfrac,grref,clref, 1 pteran,pcloud,pref,pcfrac,iofset,fteran,ramcor, 2 irefl,ilat,isnow,xnvalm,xnvalp,iplow,iphigh, 3 lprint,resn,sens,rsens,radmsr) c c call getmsr to perform table lookup for radiances and sensitivities c call getmsr(estozn,pteran,pcloud,iofset, 1 iplow,iphigh,ramcor,lprint,irefl,ilat,xlat,isnow, 2 fteran,xnvalm,xnvalp,cldfrac,fgprf,dndom,dxdom, 3 dnoutmsr,dnout,dnoutss,krngr_mu,krncl_mu) stp2oz = estozn ozbst = estozn c if(iopts(1)) go to 400 p_cld = pcloud p_terr = pteran c c call aprioz to get 13 layer apriori ozone profile c call aprsbo(xlat, idoy, lprint, qutot_a, qu_a) c c call aprioz to get 13 layer apriori temperature profile c call aprsbt(xlat, idoy, lprint, tu_a) c c for test purposes set apriori temp = stndard temp c c do i=1,13 c tu_a(14-i) = stndtmp(i) c enddo c c define 11 layer apriori ozone profiles for total ozone algorithm c do i=1,11 aptmp(i)=tu_a(14-i) apprf(i)=qu_a(14-i) if(i .eq. 11) apprf(i)=qu_a(1)+qu_a(2)+qu_a(3) enddo c c call stnp81 to get 81 layer first guess ozone profile c call stnp81(ilat, estozn, lprint, q0) c c c call delnbyt to compute temperature adjustments for radms using c the 11 lower layers of fgprf, fgtmp, and qt_a c call delnbyt(dndxmsr,fgprf,fgtmp,aptmp,lprint,delnt) c c adjust msr radiances for apriori temperature profile c do i=1,4 rad_m0(i) = 0.0 enddo do i=5,10 delntt=0.0 do lyr=1,11 delntt=delntt+delnt(i-4,lyr) enddo rad_m0(i) = radmsr(i-4)*(1.0-delntt/43.429448) enddo c c -- call getshp to determine apriori profile shape c call getshp(xlat, idoy, estozn, fgprf, qutot_a, apprf, & lprint, delshp) c c call delnbyt to compute temperature adjustments again for dndx using c the 11 lower layers of fgprf, fgtmp c call delnbyt(dndx,fgprf,fgtmp,aptmp,lprint,delnt) c c -- calculate best ozone c call ozone(iozon,irefl,estozn,xlat,fgprf,fgtmp,dndx, 1 delnt,sens,rsens,dxdom,aptmp,xlon,sza, 2 lprint,delshp,delr,s2prf,eff,stp2oz) c c -- calculate final residues c call resadj(iozon,irefl,resn,sens,rsens,dndx,delnt,fgprf,fgtmp, 1 s2prf,aptmp,ozbst,qutot_a,estozn,delr,lprint,resbst) c ref = ref + delr c do 300 ilmda=1,8 resn(ilmda) = resbst(ilmda) 300 continue c c set aerosol index c aerind=9999.0 if(irefl.ne.irfhi) aerind=-resn(irfhi-4) c c compute step 3 ozone based on regressions of r313 and r360 c ozbst = stp2oz if(.not.iopts(2)) then if(sza12(iozon).le.70.0) then aiadj=f360(1)+f360(2)*pathl(iozon)+f360(3)*pathl(iozon)**2.0 ozbst = stp2oz + aiadj * resn(irfhi-4)/100.0*stp2oz algflg = algflg + 1 endif if(sza12(iozon).gt.70.0) then ozbst = stp2oz + f313 * (resn(imixr-4)-resn(irflo-4)) algflg = algflg + 2 endif c c adjust residues for step 3 ozone change c do i=1,8 resn(i)=resn(i)-sens(i)*(ozbst-stp2oz) enddo endif c c -- calculate ozone below cloud c call blwcld(fgprf,pcloud,clfrac,fteran,lprint,ozcld) c 400 continue c c -- call seterr to set algorithm error flag c 500 continue badsza=.false. !for test purpose only call seterr(irflo,irfhi,iozon,imixr,iozon, 1 algflg,resn,flg3lm,flg4lm,sza,pathl(iozon),back, 2 maxitr,badsza,lprint,skipit,estozn,errflg) c c lod output buffer with first guess information c iseq=nscan+1 call lodtoz(iseq,iyear,idoy,algflg,errflg,eff) c c write detail from first guess retrieval to unit 15 c c fgprf(11),resn(8),sens(8),rsens(8), c qu_a(13),tu_a(13),radmsr(8),rad(8),radss(8),dndom(8), c dndxmsr(8,11),dndx(8,11),dndxss(8,11),kern_mu(10,11),delnt(8), c sza12(12),p_cld,p_terr,cldfrac(10) c prntit = .false. c prntit = .true. if(prntit) then print*,'radss' write(6,'(8f11.7)') (radss(i),i=1,8) print*,'radmsr' write(6,'(8f11.7)') (radmsr(i),i=1,8) print*,'rad' write(6,'(8f11.7)') (rad(i),i=1,8) print*,'rad_m0' write(6,'(6f11.7)') (rad_m0(i),i=5,10) print*,'rad - rad_m0' write(6,'(6f11.7)') (rad(i)-rad_m0(i+4),i=1,6) print*,'nval calc' write(6,'(6f11.3)') (-100.0*log10(rad(i)),i=1,6) print*,'resn' write(6,'(8f11.3)') (resn(i),i=1,8) print*,'nval calc + residue' write(6,'(8f11.3)') (-100.0*log10(rad(i))+resn(i),i=1,8) print*,'xnvalm' write(6,'(6f11.3)') (100.0*xnvalm(i),i=5,10) c print*,'dndxmsr' c write(6,'(8f9.5)') dndxmsr c print*,'dndx' c write(6,'(8f9.5)') dndx c print*,'dndxss' c write(6,'(8f9.5)') dndxss c print*,'iseq =',iseq c stop 1 endif call dtailt(iseq,iyear,idoy,iorbit,igmt,fgprf, 1 resn,sens,rsens,qu_a,tu_a,radmsr,rad,radss, 2 dndom,dndxmsr,dndx,dndxss,delnt,sza12, 3 p_cld,p_terr,cldfrac) c return c end