6 implicit real*8(a-h,o-z)
7 real*8 ez(4),tha(26),pha(47),thp(25), phcnd(46),thcnd(25)
8 real*8 ftrx(16,25,46),pti(8,25,46),xz(3),athcnd(25),aphcnd(46)
9 real*8 wav(200),sig_hg(10)
12 data ez/0.5d0,0.5d0,0.0d0,0.0d0/
21 open(21,file=
'ocn.dir',status=
'old')
25 len1=
index(infile,
' ')-1
26 len2=
index(outdir,
' ')-1
33 open(unit=3,file=infile(1:len1),status=
'old')
35 read(3,24)iopt,nww,ibgn,iend,isig
38 write(*,*) iopt,nww,ibgn,iend
57 read(3,15)(wav(i),i=1,nww)
59 read(3,16)ntha,(tha(i),i=1,ntha)
61 read(3,35)nsig,(sig_hg(i),i=1,nsig)
64 nphi=180.0d0/dlph+2.0d0+0.01d0
68 call rtang(tha,pha,thcnd,phcnd,thp,dlth,dlph,ntha,nphi,
73 jwave=wav(ii)*1.0d3+0.01
79 v=sig_hg(mm)**2/5.34d-3
82 call riwat(wav(ii),xsal,xr,xi)
88 call convtc(idnint(wav(ii)*1.0d3+0.01),4,xw)
89 write(*,*) wav(ii),
' ',xw,
' ',vc
94 1 outdir(1:len2)//
'/ocn_sumryl_wl'//xw//
'x'//vc//
'.dat',
97 1 outdir(1:len2)//
'/ocn_refl_wl'//xw//
'x'//vc//
'.dat',
98 2 access=
'sequential',form=
'unformatted',
114 write (20) xz,izx,athcnd,aphcnd
119 amuo=dcos(thp(k)*con)
120 call rufocn(ez,thp(k),phip,xr,xi,v,pha,tha,phcnd,
121 1 thcnd,thcel,phcel,opt,ftrx,pti,
pi,con,
122 2 ntha,nphi,iprob,nthcnd,nphcnd)
124 write (20) thetap,ftrx,pti
140 26
format(2e10.3,4f10.4)
144 30
format(1x,2i3,1p8d15.4/1x,6x,1p8d15.4/)
146 500
format(1x,f6.2,1x,f6.2,2x,1p4d11.3,1x,1p3d11.3,1x,1p2d11.3)
148 510
format(
'Cox-Monk Rough Ocean (Wind Direction Independent)'/
149 1
'wind speed (m/sec)'/f10.2)
155 subroutine convtc (num,nchar, loc)
197 integer istart, irem, itemp
212 do 100 i = nchar, istart, -1
214 loc(i) = char(irem - itemp * 10 + ichar(
'0'))
221 if (irem.ne.0) loc(1) =
'*'
227 subroutine probl(zx,zy,v,prob,pi,sig,iprob)
228 implicit real *8(a-h),
real*8(o-z)
243 sigsqx = 0.003d0 + 1.92d-3*v
249 if(dabs(zx ) .lt. 1.0d-06) zx =0.0d0
250 if(dabs(zy ) .lt. 1.0d-06) zy =0.0d0
256 pqr= -dlog( aaa*
pi*sigx*sigy*1.0d-6)
257 eee=(zeta**2 + eata**2 )/aaa
258 if(eee .gt. pqr)
go to 81
261 if(iprob .eq.1)
go to 300
264 c21 = 0.01d0 - 0.0086d0 * v
265 c03 = 0.04d0 - 0.033d0 * v
270 c1 = c21*(zeta**2-1.0d0)*eata *0.5d0
271 c2 = (c03*(eata**3 -3.0d0*eata))/6.0d0
272 c3 = (c40*( zeta**4 - 6.0d0*zeta**2 + 3.0d0))/24.0d0
273 c4 = ( c22*(zeta**2-1.0d0)*(eata**2-1.0d0))/4.0d0
274 c5 = (c04 * (eata**4 - 6.0d0*eata**2 + 3.0d0) )/24.0d0
277 csum = -c1-c2+c3+c4+c5
279 prob1 = dexp(-(zeta**2 + eata**2)/aaa)/( aaa*
pi*sigx*sigy)
280 prob = prob1*(1.0d0+csum)
288 subroutine rufocn(ei,thpd,phpd,xr,xi,v,pha,tha,phcnd,thcnd,
289 1 thcel,phcel,opt, ftrx,pti,pi,con,ntha,nphi,iprob,
292 implicit real*8(a-h),
real*8(o-z)
294 real*8 ftrx(16,25,46),pti(8,25,46),a(6)
295 real*8
ei(4),zint(4,25,46),zmio(4),tha(26),pha(47),thx(15),
296 1 phx(35),
rint(4,25,46),phsl(3),thsl(3),sang(25,46),snside(5),
297 2 phnl(3,3),thnl(3,3),coside(5),side(5),cosang(6),angtri(6),
298 3 tmio(4),xint(4),tzm(4,4),tint(4,4),phcnd(46),apti(4),thcnd(25),
299 4 frac(10),axz(16),amul(2),amulsq(2),xi_hgcnt(25,46)
301 data frac/0.0d0,0.1d0,0.2d0,0.3d0,0.4d0,0.5d0,0.6d0,
313 sinthp=dsqrt(1.0d0-costhp**2)
325 sthcnt=dsqrt(1.0d0-cthcnt**2)
335 thx(i1)=thx(i1-1)+thcel
336 dif1 = dabs(tha(ii+1) - thx(i1) )
337 if(dif1 .lt. 1.0d-6 .or. thx(i1) .gt. tha(ii+1) )
go to 101
349 sphcnt=dsqrt(1.0d0-cphcnt**2)
352 sang3=(dcos(tha(ii)*con)-dcos(tha(ii+1)*con))*
353 1 (pha(jj+1)-pha(jj))*con
369 phx(i2)=phx(i2-1)+phcel
370 dif2 = dabs(pha(jj+1) - phx(i2) )
371 if( dif2 .lt. 1.0d-10 .or. phx(i2) .gt. pha(jj+1) )
goto 104
379 phx(i2+1)=phcntd-phcel/2.0d0
380 phx(i2+2)=phcntd+phcel/2.0d0
381 thx(i1+1)=thcntd-thcel/2.0d0
382 thx(i1+2)=thcntd+thcel/2.0d0
390 if(mmnn .eq.1)
goto 260
407 do 10 i=limth1,limth2
408 thsd = (thx(i)+thx(i+1))/2.0d0
409 if(thx(i) .lt. 0.0d0) thx(i)=0.0d0
411 thsl(2) = thx(i+1)*con
415 sinths=dsqrt(1.0d0-cosths**2)
416 amul(1) = dcos(thsl(1))
417 amul(2) = dcos(thsl(2))
418 amulsq(1) = amul(1) ** 2
419 amulsq(2) = amul(2) ** 2
422 do 11 j=limfi1,limfi2
428 phsd = (phx(j)+phx(j+1))/2.0d0
429 if(phx(j+1) .gt. 180.0d0) phx(j+1)=180.0d0
430 if(phx(j) .lt. 0.0d0)phx(j)=0.0d0
432 phsl(2) = phx(j+1)*con
435 delphi = phsl(2)-phsl(1)
443 if(thpd .gt. 1.0d-3)
go to 74
448 domgan=(dcos(thnl1)-dcos(thnl2) )*(phsl(2)-phsl(1))
449 sang(i,j)=(dcos(thsl(1))-dcos(thsl(2)))*
451 thnl(3,3)=thsl(3)/2.0d0
455 if(thsd .gt.1.0d-3)
go to 75
456 call solidz(thp,php,thsl,phsl,domgan,sang(i,j),con)
466 sang(i,j)=(dcos(thx(i)*con)-dcos(thx(i+1)*con))*
467 1 (phx(j+1)-phx(j))*con
475 if(iy .eq. 3 .and. ix .ne. 3)
go to 32
476 if(ix .eq. 3 .and. iy .ne. 3)
go to 32
478 sthsl=dsqrt(1.0d0-cthsl**2)
482 cos_scat=-costhp*cthsl+sinthp*sthsl*dcos(php-phsl(iy))
484 if(costwo.ge.1.0d0)costwo=1.0d0
485 if(costwo.le. -1.0d0)costwo=-1.0d0
486 sintwo=dsqrt(1.0d0-costwo**2)
487 scath = 0.5d0*dacos(costwo)
489 if(cscath.ge.1.0d0)cscath=1.0d0
490 if(cscath.le. -1.0d0)cscath=-1.0d0
491 sscath=dsqrt(1.0d0-cscath**2)
493 diff =dabs(php-phsl(iy))
494 cons = dabs(dsin(
diff) )
495 if(sintwo.lt.1.0d-10)
goto 37
496 cosai1=(cthsl-costhp*costwo)/(sintwo*sinthp)
498 if(cosai1 .gt. 1.0d0 ) cosai1=1.0d0
500 if(cosai1 .lt. -1.0d0 ) cosai1=-1.0d0
502 costhn=costhp*cscath+sinthp*sscath*cosai1
503 if(costhn.ge.1.0d0)costhn=1.0d0
504 if(costhn.le. -1.0d0)costhn=-1.0d0
505 sinthn=dsqrt(1.0d0-costhn**2)
506 thnl(ix,iy) = dacos(costhn)
508 if(thnl(ix,iy) .lt.1.0d-10 .and. scath .le. thp)
510 if(thnl(ix,iy) .lt.1.0d-10.and. scath .gt.thp)
512 if(thnl(ix,iy).lt. 1.0d-10 )
go to 150
515 if(sinthn.le.0.0d0)
goto 150
516 cosxx=(cscath-costhp*costhn)/( sinthp*sinthn )
518 if(cosxx .gt. 1.0d0) cosxx=1.0d0
519 if(cosxx .lt.-1.0d0) cosxx = -1.0d0
525 call znorml(thnl,phnl,domgan )
526 if(iphsd .eq. 0 .or. iphsd .eq. 180) domgan=2.0d0*domgan
527 if(iphsd .eq. 0 .or. iphsd .eq.180)sang(i,j)=
534 sinphn=dsqrt(1.0d0-cosphn**2)
540 dzxdzy=domgan/cosnnn**3
546 call probl(zx,zy,v,probx,
pi,sig,iprob)
547 call ufunc(
pi,cosths,sig,uuff_ths)
548 call ufunc(
pi,costhp,sig,uuff_thp)
549 prob=probx*uuff_ths*uuff_thp
552 1 alfa_hg,proby,xi_hg)
553 call ufunc(
pi,cthcnt,sig,uuff_thcnt)
554 call ufunc(
pi,costhp,sig,uuff_thp)
555 xi_hg_corr=xi_hg*uuff_thcnt*uuff_thp
556 xi_hgcnt(ii,jj)=xi_hg_corr
567 call zangl(thp,php,ths,phs,thn,phn,xr,xi,zmio,
568 1
ei,cost,thcnt,phcnt,tzm)
576 rint(im,i,j) =(cost/(cosnnn*cosths))*
577 1 prob*dzxdzy*zmio(im)*r2
578 if(im.eq.1 .or. im.eq.2)
rint(im,i,j)=
rint(im,i,j)+
579 1 r1*costhp*sang(i,j)/(2.0d0*
pi)
580 xint(im)=
rint(im,i,j)/sang(i,j)
581 if (ithpd.eq.0)
go to 15
582 if(iphsd.eq.0 .or. iphsd.eq.180)
586 if(mmnn .eq. 1)
go to 26
587 pfluxs=pfluxs+(
rint(1,i,j)+
rint(2,i,j) )*cosths*2.0d0
588 pfluxz=pfluxz+(amulsq(1)-amulsq(2))*delphi*xin
590 cccc = ((cost*prob*dzxdzy)/(cosnnn*cosths*sang3))
593 tint(ij,ik)=tint(ij,ik)+tzm(ij,ik)*cccc
619 zint(im,ii,jj)=zint(im,ii,jj)+
rint(im,i,j)/sang3
629 pti(ij,ii,ll)=apti(ij)
630 pti(ij+4,ii,ll) = zint(ij,ii,jj)
633 ftrx(kk,ii,ll) = tint(ij,ik)*r2
634 if(kk.eq.1 .or.kk.eq.6)ftrx(kk,ii,ll)=ftrx(kk,ii,ll)+
639 a(1)=0.5d0*(ftrx(1,ii,ll)+ftrx(2,ii,ll))
640 a(2)=0.5d0*(ftrx(5,ii,ll)+ftrx(6,ii,ll))
641 a(3)=0.5d0*(ftrx(9,ii,ll)+ftrx(10,ii,ll))
642 a(4)=0.5d0*(ftrx(13,ii,ll)+ftrx(14,ii,ll))
649 refl=pfluxs/dcos(thp)
650 reflz = pfluxz / dcos(thp)
651 azn=zint(1,ii,jj)+zint(2,ii,jj)
654 701
format(
'ii,jj,nmtha,zint,azn,bzn,sang3',3i4/1p7e11.3)
657 if(thcntd .gt. 1.0d-1)
go to 50
659 axz(ib)= (ftrx(ib,ii,1)+ftrx(ib,ii,nmphi))/2.0
663 ftrx(ib,ii,ia)=axz(ib)
665 pti(5,ii,ia)=( ftrx(1,ii,ia)+ftrx(2,ii,ia) )/2.0
666 pti(6,ii,ia)=( ftrx(5,ii,ia)+ftrx(6,ii,ia) )/2.0
667 pti(7,ii,ia)=( ftrx(9,ii,ia)+ftrx(10,ii,ia))/2.0
668 pti(8,ii,ia)=( ftrx(13,ii,ia)+ftrx(14,ii,ia))/2.0
681 1 xi_hgcnt,nthcnd,nphcnd)
687 136
format( /1x,1p11d10.2/ )
688 139
format(1x,
' the avrg.value of stokes parameter for big cell no.',
689 1 5x,i2,
',',i2,
'are')
690 143
format(1x,
' the cosine of',2i2,
' angle is large',1pd15.5)
691 145
format(t2,
'ang',t11,
'mu',t17,
'phi',t25,
'i sub l',t38,
'i sub r',
692 1 t52,
' u',t64,
' v',t76,
'i',t88,
'p',t97,
' pi*i ',t110,
'prob' /)
694 147
format(1x,20x,1p4d12.4)
695 148
format(1x,f5.2,1x,f6.2,1x,1p4d11.3,1p5d12.4 )
696 149
format(1x,
' sea surface reflectivity for solar'
697 1 ,
' zenith angle = ',0pf8.2,
' is =',1p2d12.3/)
698 151
format(f10.1,2f10.3)
699 155
format(1x,
'fraction of incident flux reflected according to
700 1lambert law (in percent)',0pf7.1/
701 2 1x,
'fraction of incident flux reflected according to fresnel
702 3 law (inpercent)',0pf7.1//)
703 180
format(1x,1p8e14.4/1x,1p8e14.4//)
704 200
format(1x,1p10e12.4)
705 500
format(1x,0pf7.2,0pf8.4,0pf7.1,0p2f7.2,1p9e11.4)
706 515
format(t7,
'sza',t15,
'h. ref1')
707 600
format(1x,2i5,1p4e15.4)
713 subroutine rtang(tha,pha,thcnd,phcnd,thp,dlth,dlph,ntha,nphi,
714 1 nthcnd,nphcnd,nthp)
716 implicit real*8 (a-h,o-z)
717 real*8 tha(26),pha(47),thp(25),phcnd(46),thcnd(25)
721 thcnd(i)=(tha(i+1)+tha(i))/2.0d0
726 pha(2)=pha(1)+dlph/2.0d0
730 phcnd(i)=(pha(i+1)+pha(i))/2.0d0
731 if(pha(i+1).gt.180.0d0)pha(i+1)=180.0d0
732 if(phcnd(i).ge.180.0d0)phcnd(i)=180.0d0
739 subroutine rufint(pi,con,amuo,thcnd,phcnd,opt,pti,
740 1 xi_hgcnt,nthcnd,nphcnd)
743 implicit real * 8 (a-h,o-z)
744 real*8 thcnd(25),phcnd(46),xi_hgcnt(25,46)
745 real * 8 pti(8,25,46)
756 amu = dcos(thcnd(i) * con)
758 xin = pti(l,i,j) + pti(l+1,i,j)
761 xinsea = xinpi * dexp(-opt/amuo)
762 xintop = xinsea * dexp(-xpt/amu)
763 if (xin .gt. 1.0d-10) poln=sqrt((pti(l,i,j) - pti(l+1,i,j))
764 1 **2 + pti(l+2,i,j)**2 + pti(l+3,i,j)**2 )
765 if (xin .gt. 1.0d-10) pol = poln/xin
766 if (pti(l,i,j) .gt. pti(l+1,i,j) ) pol = -pol
767 write (7,500) thcnd(i),phcnd(j),(pti(m,i,j),m=l,n),xin,pol,
768 1 xinpi,xi_hgcnt(i,jr)*
pi,xintop
776 500
format(1x,f6.2,1x,f6.2,2x,1p4d11.3,1x,1p3d11.3,1x,1p3d11.3)
783 subroutine solidz(thp,php,thsl,phsl,domgan,domega,con)
784 implicit real * 8(a-h,o-z)
785 real*8 thsl(3),phsl(3)
789 sinthp=dsqrt(1.0d0-costhp**2)
790 costh2=dcos(thsl(2) )
792 sn1=(thp+thsl(2) )/2.0d0
794 sintci=dsqrt(1.0d0-costci**2)
795 chi=0.50d0*dacos(costci)
800 sinchi=dsqrt(1.0d0-coschi**2)
801 cosai=(costh2-costhp*costci)/(sinthp*sintci)
804 sinsn=dsqrt(1.0d0-cossn**2)
806 sinsn1=dsqrt(1.0d0-cossn1**2)
807 coss1=cossn*coschi+sinsn*sinchi*cosai
808 coss2=cossn1* coschi+sinsn1*sinchi*cosai
819 st=dtan(ss/2.0d0)*dtan((ss-s1)/2.0d0)*
820 1 dtan((ss-s2)/2.0d0)*dtan((ss-s3)/2.0d0)
821 se=dsqrt(1.0d0/(1.0d0+st) )
822 domgan=4.0d0*dacos(se)
825 r3=dacos(costh2*costh2)
827 sr=dtan(rr/2.0d0)*dtan((rr-r1)/2.0d0)**2 *
828 1 dtan((rr-r3)/2.0d0)
829 re=dsqrt(1.0d0/(1.0d0+sr) )
830 domega=4.0d0*dacos(
re)
834 126
format(1x,1p10d12.4/)
840 subroutine zangl(thp,php,ths,phs,thn,phn,xr,xi,tmio,ei,cost,
843 implicit real*8(a-h),
real*8(o-z)
844 real*8 zmio(4),
ei(4),tmio(4),z(4,4),t(4,4),tzm(4,4)
850 cost = dcos(thn)*dcos(thp) + dsin(thn)*dsin(thp)*dcos(php-phn)
854 sinsq = (1.0d0-cost**2)
856 a = (xr**2-xi**2 -1.0d0 + cost**2)
857 b = (-2.0d0 * xr * xi)
858 r = dsqrt(a**2 + b**2)
860 xp = dsqrt(2.0d0*r + 2.0d0*a)
861 xmm = (2.0d0*r - 2.0d0*a)
862 if(xmm .lt. 0.0d0 .and. xmm .gt. xzx) xmm=-xmm
864 dnmr1 = (sinsq2 + tmr + cost*sinsq*xp)
865 qrmu = (sinsq2 - tmr)/dnmr1
866 qimu = (cost*sinsq*xm)/dnmr1
867 dnmr2 = (cost**2 + r + cost*xp)
868 rrr = (cost**2 - r)/dnmr2
869 rri = (cost*xm)/dnmr2
870 rer = qrmu*rrr - qimu*rri
871 rei = qimu*rrr + qrmu*rri
872 r11 = rer**2 + rei**2
873 r22 = rrr**2 + rri**2
874 r33 = rer*rrr + rei*rri
875 r34 = rri*rer - rei*rrr
880 costot = dcos(2.0d0*thetac)
881 sintot = dsin(2.0d0*thetac)
884 if(thp .le.1.0d-6 .or. ths .le. 1.0d-6)
go to 65
887 if(cons .lt.1.0d-10)
go to 65
888 cosai1 = (dcos(ths) - dcos(thp)*costot)/(dsin(thp)*sintot)
889 cosai2 = (dcos(thp) - dcos(ths)*costot)/(dsin(ths)*sintot)
896 ssqai1 = dsin(ai1)**2
897 csqai1 = dcos(ai1)**2
898 stoai1 = dsin(2.0d0*ai1)
899 ctoai1 = dcos(2.0d0*ai1)
900 ssqai2 = dsin(ai2)**2
901 csqai2 = dcos(ai2)**2
902 stoai2 = dsin(2.0d0*ai2)
903 ctoai2 = dcos(2.0d0*ai2)
912 rl13 =-0.5d0*r11*stoai1
913 rl23 = 0.5d0*r22*stoai1
922 z(1,1)= csqai2*rl11 + ssqai2*rl21 - 0.5d0*stoai2*rl31
923 z(2,1)= ssqai2*rl11 + csqai2*rl21 + 0.5d0*stoai2*rl31
924 z(3,1) = stoai2*rl11- stoai2*rl21+ ctoai2*rl31
926 z(1,2)= csqai2*rl12 + ssqai2*rl22 - 0.5d0*stoai2*rl32
927 z(2,2)= ssqai2*rl12 + csqai2*rl22 + 0.5d0*stoai2*rl32
928 z(3,2) = stoai2*rl12- stoai2*rl22+ ctoai2*rl32
930 z(1,3)= csqai2*rl13 + ssqai2*rl23 - 0.5d0*stoai2*rl33
931 z(2,3)= ssqai2*rl13 + csqai2*rl23 + 0.5d0*stoai2*rl33
932 z(3,3) = stoai2*rl13- stoai2*rl23+ ctoai2*rl33
934 z(1,4)= csqai2*rl14 + ssqai2*rl24 - 0.5d0*stoai2*rl34
935 z(2,4)= ssqai2*rl14 + csqai2*rl24 + 0.5d0*stoai2*rl34
936 z(3,4) = stoai2*rl14- stoai2*rl24+ ctoai2*rl34
943 if(ths .le.1.0d-6 .or. thcnt .le. 1.0d-6)
go to 75
944 cons = dsin(phcnt-phs)
946 if(cons .lt.1.0d-10)
go to 75
947 thtx = dcos(thcnt)*dcos(ths) + dsin(thcnt)*dsin(ths)*
951 costi1 = (dcos(thcnt)-dcos(ths)*thtx)/(dsin(ths)*thty)
952 costi2 = (dcos(ths) - dcos(thcnt)*thtx) / (dsin(thcnt)*thty)
959 stoti1= dsin(2.0d0*ti1)
960 ctoti1= dcos(2.0d0*ti1)
963 stoti2= dsin(2.0d0*ti2)
964 ctoti2= dcos(2.0d0*ti2)
966 t(1,1)= (csqti2*csqti1 +ssqti2*ssqti1 - 0.5d0*stoti2*stoti1)
967 t(2,1)= (ssqti2*csqti1 +csqti2*ssqti1 + 0.5d0*stoti2*stoti1)
968 t(3,1)=stoti2*csqti1 - stoti2*ssqti1 + ctoti2*stoti1
970 t(1,2)= (csqti2*ssqti1 +ssqti2*csqti1 + 0.5d0*stoti2*stoti1)
971 t(2,2)= (ssqti2*ssqti1 +csqti2*csqti1 - 0.5d0*stoti2*stoti1)
972 t(3,2)=stoti2*ssqti1 - stoti2*csqti1 - ctoti2*stoti1
974 t(1,3)= (-0.5d0*csqti2*stoti1+0.5d0*ssqti2*stoti1-
975 1 0.5d0*stoti2*ctoti1)
976 t(2,3)= (-0.5d0*ssqti2*stoti1+0.5d0*csqti2*stoti1+
977 1 0.5d0*stoti2*ctoti1)
978 t(3,3)= (-0.5d0*stoti2*stoti1-0.5d0*stoti2*stoti1+
988 tzm(i,j) = tzm(i,j) + t(i,k)*z(k,j)
993 tmio(i) = tmio(i) + tzm(i,j)*
ei(j)
1001 subroutine znorml(thnl,phnl,domgan)
1003 implicit real*8(a-h),
real*8(o-z)
1004 real*8 thnl(3,3),phnl(3,3), coside(5),snside(5), cosang(6),
1012 coside(1) = dcos(thnl(1,1))*dcos(thnl(2,1))+dsin(thnl(1,1))*
1013 1 dsin(thnl(2,1))*dcos(phnl(1,1) -phnl(2,1))
1014 coside(2) = dcos(thnl(2,1))*dcos(thnl(2,2))+dsin(thnl(2,1))*
1015 1 dsin(thnl(2,2))*dcos(phnl(2,1) -phnl(2,2))
1016 coside(3) = dcos(thnl(2,2))*dcos(thnl(1,2))+dsin(thnl(2,2))*
1017 1 dsin(thnl(1,2))*dcos(phnl(2,2) -phnl(1,2))
1018 coside(4) = dcos(thnl(1,2))*dcos(thnl(1,1))+dsin(thnl(1,2))*
1019 1 dsin(thnl(1,1))*dcos(phnl(1,2) -phnl(1,1))
1020 coside(5) = dcos(thnl(1,1))*dcos(thnl(2,2))+dsin(thnl(1,1))*
1021 1 dsin(thnl(2,2))*dcos(phnl(1,1) -phnl(2,2))
1023 if(coside(iz) .gt. 1.000000d0)
then
1024 coside(iz)=1.000000d0
1026 if(coside(iz) .lt. -1.000000d0)
then
1027 coside(iz)=-1.000000d0
1029 side(iz) = dacos(coside(iz))
1030 snside(iz)=dsin(side(iz))
1033 36 cosang(k) = 1.0d0
1034 if(side(1).lt.1.0d-10 .or. side(2).lt.1.0d-10) cosang(5)=-1.0d0
1035 if(side(1).lt.1.0d-10 .or. side(2).lt.1.0d-10)
go to 45
1036 cosang(1) = (coside(1) -coside(2)*coside(5))/
1037 1 (snside(2)*snside(5))
1038 cosang(2) = (coside(2) -coside(1)*coside(5))/
1039 1 (snside(1)*snside(5))
1040 cosang(5) = (coside(5) -coside(1)*coside(2))/
1041 1 (snside(1)*snside(2))
1043 if(side(3).lt.1.0d-10 .or. side(4).lt.1.0d-10) cosang(6)=-1.0d0
1044 if(side(3).lt.1.0d-10 .or. side(4).lt.1.0d-10)
go to 55
1045 cosang(3) = (coside(3) -coside(4)*coside(5))/
1046 1 (snside(4)*snside(5))
1047 cosang(4) = (coside(4) -coside(3)*coside(5))/
1048 1 (snside(3)*snside(5))
1049 cosang(6) = (coside(5) -coside(3)*coside(4))/
1050 1 (snside(3)*snside(4))
1054 difabs=dabs(dabs(cosang(iz) ) -1.0d0 )
1055 if(difabs .lt. 1.0d-10 .and. cosang(iz) .gt. 1.0d0)
1057 if(difabs .lt. 1.0d-10 .and. cosang(iz) .lt.aaaaa )
1059 34 angtri(iz)=dacos(cosang(iz))
1061 area1 =(angtri(1)+angtri(2)+angtri(5) -
pi)
1062 area2 =(angtri(3)+angtri(4)+angtri(6) -
pi)
1063 domgan = area1+area2
1064 if(phnl(1,1).lt.1.0d-6)
then
1075 subroutine riwat(wl,xsal,nr,ni)
1077 implicit real*8 (a-h,o-z)
1078 real*8 twl(62),tnr(62),tni(62)
1079 real*8 nr,ni,nrc,nic
1092 s 0.250,0.275,0.300,0.325,0.345,0.375,0.400,0.425,0.445,0.475,
1093 s 0.500,0.525,0.550,0.575,0.600,0.625,0.650,0.675,0.700,0.725,
1094 s 0.750,0.775,0.800,0.825,0.850,0.875,0.900,0.925,0.950,0.975,
1095 s 1.000,1.200,1.400,1.600,1.800,2.000,2.200,2.400,2.600,2.650,
1096 s 2.700,2.750,2.800,2.850,2.900,2.950,3.000,3.050,3.100,3.150,
1097 s 3.200,3.250,3.300,3.350,3.400,3.450,3.500,3.600,3.700,3.800,
1100 s 1.362,1.354,1.349,1.346,1.343,1.341,1.339,1.338,1.337,1.336,
1101 s 1.335,1.334,1.333,1.333,1.332,1.332,1.331,1.331,1.331,1.330,
1102 s 1.330,1.330,1.329,1.329,1.329,1.328,1.328,1.328,1.327,1.327,
1103 s 1.327,1.324,1.321,1.317,1.312,1.306,1.296,1.279,1.242,1.219,
1104 s 1.188,1.157,1.142,1.149,1.201,1.292,1.371,1.426,1.467,1.483,
1105 s 1.478,1.467,1.450,1.432,1.420,1.410,1.400,1.385,1.374,1.364,
1108 s 3.35e-08,2.35e-08,1.60e-08,1.08e-08,6.50e-09,
1109 s 3.50e-09,1.86e-09,1.30e-09,1.02e-09,9.35e-10,
1110 s 1.00e-09,1.32e-09,1.96e-09,3.60e-09,1.09e-08,
1111 s 1.39e-08,1.64e-08,2.23e-08,3.35e-08,9.15e-08,
1112 s 1.56e-07,1.48e-07,1.25e-07,1.82e-07,2.93e-07,
1113 s 3.91e-07,4.86e-07,1.06e-06,2.93e-06,3.48e-06,
1114 s 2.89e-06,9.89e-06,1.38e-04,8.55e-05,1.15e-04,
1115 s 1.10e-03,2.89e-04,9.56e-04,3.17e-03,6.70e-03,
1116 s 1.90e-02,5.90e-02,1.15e-01,1.85e-01,2.68e-01,
1117 s 2.98e-01,2.72e-01,2.40e-01,1.92e-01,1.35e-01,
1118 s 9.24e-02,6.10e-02,3.68e-02,2.61e-02,1.95e-02,
1119 s 1.32e-02,9.40e-03,5.15e-03,3.60e-03,3.40e-03,
1120 s 3.80e-03,4.60e-03/
1122 10
if (wl.lt.twl(i))
goto 20
1131 nr=tnr(i-1)+(wl-twl(i-1))*yr/xwl
1132 ni=tni(i-1)+(wl-twl(i-1))*yi/xwl
1152 nr=nr+nrc*(xsal/34.3)
1153 ni=ni+nic*(xsal/34.3)
1158 subroutine ufunc(pi,xmu,sig,uu)
1159 implicit real*8 (a-h,o-z)
1162 denom = sig*(1.d0-xmu**2)
1163 if (denom .lt. 1e-7)
then
1169 ff1=dexp(-gnusq)/(dsqrt(
pi)*gnu)
1170 ff2=(1.0d0-
erfz(gnu))
1171 ffnu=0.5d0*(ff1-ff2)
1172 uu=1.0d0/(1.0d0+ffnu)
1181 implicit real*8 (a-h,o-z)
1194 implicit real*8 (a-h,o-z)
1196 if(x.lt.0.d0.or.a.le.0.d0) stop
1198 call gser(gamser,a,x,gln)
1201 call gcf(gammcf,a,x,gln)
1209 subroutine gser(gamser,a,x,gln)
1210 implicit real*8 (a-h,o-z)
1227 if(dabs(del).lt.dabs(sum)*eps)
go to 1
1229 stop
'a too large, itmax too small'
1230 1 gamser=sum*dexp(-x+a*dlog(x)-gln)
1235 subroutine gcf(gammcf,a,x,gln)
1236 implicit real*8 (a-h,o-z)
1258 if(dabs((g-gold)/g).lt.eps)
go to 1
1262 stop
'a too large, itmax too small'
1264 gammcf=dexp(-x+a*dlog(x)-gln)*g
1271 implicit real*8 (a-h,o-z)
1272 real*8 cof(6),stp,half,one,fpf,x,tmp,ser
1274 data cof,stp/76.18009173d0,-86.50532033d0,24.01409822d0,
1275 * -1.231739516d0,.120858003d-2,-.536382d-5,2.50662827465d0/
1276 data half,one,fpf/0.5d0,1.0d0,5.5d0/
1281 tmp=(x+half)*log(tmp)-tmp
1292 subroutine probl_hg(pi,xmup,phirpx,xmux,phirx,sig,alfa,prob,
1295 implicit real*8 (a-h,o-z)
1307 cos2chi=-xmup*xmu-dsqrt((1.0d0-xmup**2)*(1.0d0-xmu**2))*
1310 alfa=(1.0d0+cos2chi)/(xmup-xmu)**2
1311 arg_exp=(1.0d0-2.0d0*alfa)/sig**2
1312 exp_term=dexp(arg_exp)
1313 prob=exp_term/(
pi*sig**2)
1315 chii=dacos(cos2chi)/2.0d0
1323 sinthipsq=sinthip**2
1324 sinthimsq=sinthim**2
1325 costhipsq=1.0d0-sinthipsq
1326 costhimsq=1.0d0-sinthimsq
1327 tanthipsq=sinthipsq/costhipsq
1328 tanthimsq=sinthimsq/costhimsq
1329 if(dabs(chii).lt.1.0d-6)
then
1330 rho_pls=((1.0d0-xn1)/(1.0d0+xn1))**2
1332 rho_pls=0.5d0*(tanthimsq/tanthipsq +
1333 1 sinthimsq/sinthipsq)
1335 xi_hg=(rho_pls*alfa**2*prob)/dabs(xmu)
1339 99
format(
'xmup,phirp,xmu,phir,sig',5f10.4)
1341 100
format(
'cos2chi,alfa,sig,arg_exp,exp_term,prob'/1p6e12.4)
1343 101
format(
'sinthipsq,sinthimsq,costhipsq,costhimsq'/1p4e12.4)
1345 102
format(
'tanthipsq,tanthimsq,rho_pls,xi_hg'/1p4e12.4)
1352 subroutine rufint_new (pi,con,amuo,thcnd,phcnd,opt,pti,
1353 1 xi_hgcnt,nthcnd,nphcnd)
1355 implicit real * 8 (a-h,o-z)
1356 real*8 thcnd(25),phcnd(46),xi_hgcnt(25,46)
1357 real * 8 pti(8,25,46)
1364 amu = dcos(thcnd(i)*con)
1366 xin1=pti(1,i,j)+pti(2,i,j)
1367 xin2=pti(5,i,j)+pti(6,i,j)
1369 xi_hgpi=xi_hgcnt(i,jr)*
pi
1371 xin1sea=xin1pi*dexp(-opt/amuo)
1372 xin1top =xin1sea*dexp(-xpt/amu)
1374 xin2sea=xin2pi*dexp(-opt/amuo)
1375 xin2top =xin2sea*dexp(-xpt/amu)
1376 write (7,500) thcnd(i),phcnd(j),xin1pi,xi_hgpi,
1384 100
format(
' the phi I_ZA I_HG',
1385 1
' Avg_I_ZA Avg_I_ZA_Top')
1386 500
format(1x,f6.2,1x,f6.2,2x,1p4d13.4)