1       subroutine readin(ilm,irh,isd,itau)
 
    7       implicit real*8 (a-h,o-z)
 
    8       include 
'common_all.cmn' 
   11       real*8 xzx(3),athcnd(25),aphcnd(46),ftrx(16,25,46),
 
   17       character*2 citau,crh,cset
 
   18       character*2 cisd,cilmd,cwind
 
   20       character*90 xname1,xname2,xname3,xname4,xname5,file_name
 
   21       character*90 xname4a,xname5a,xname6
 
   24       len1=
index(dir1,
' ')-1
 
   25       len2=
index(dir2,
' ')-1
 
   26       len3=
index(dir3,
' ')-1
 
   27       len4=
index(dir4,
' ')-1
 
   28       len5=
index(dir5,
' ')-1
 
   31          iwl=wwl(ilm)*1.0d3+0.01d0
 
   35       call convtc(idnint(wwl(ilm)*1.0d3+0.01),4,cilm)
 
   36       write(*,*) wwl(ilm),cilm
 
   39       call convtc(iwind-1,2,ciwind)
 
   41       call convtc(iww(iwind),2,cwind)
 
   42       call convtc(krhum(irh),2,crh)
 
   45       if(iref.eq.1)ciwind=
'00' 
   46       if(iref.eq.0)ciwind=
'99' 
   49       xname1=
'rt2_wl'//cilm//
'x'//ciwind
 
   50       xname2=
'sd'//cisd//
'rh'//crh//
'ta'//citau//
'_set'//cset
 
   52       xname4a=
'rt1_'//
'wl'//cilm//
'sd'//cisd//
'rh'//crh//
'ta'//citau
 
   53       nm4a=
index(xname4a,
' ')-1
 
   54       xname4=xname4a(1:nm4a)//
'_set'//cset
 
   55       xname5a=
'rt1_sp'//
'wl'//cilm//
'sd'//cisd//
'rh'//crh//
'ta'//citau
 
   56       nm5a=
index(xname5a,
' ')-1
 
   57       xname5=xname5a(1:nm5a)//
'_set'//cset
 
   60       nm1=
index(xname1,
' ')-1
 
   61       nm2=
index(xname2,
' ')-1
 
   63       nm4=
index(xname4,
' ')-1
 
   64       nm5=
index(xname5,
' ')-1
 
   68       if (num_arg .lt. 1) 
then 
   71         call getarg(1, file_name)
 
   75      1     dir3(1:len3)//
'/'//xname1(1:nm1)//xname2(1:nm2)//
'dn.dat',
 
   78      1     dir3(1:len3)//
'/'//xname1(1:nm1)//xname2(1:nm2)//
'up.dat',
 
   80       open(6,file=file_name,status=
'unknown')
 
   81       open(21,file=dir1(1:len1)//
'/'//xname4(1:nm4)//
'.dat',
 
   84      1 dir3(1:len3)//
'/'//xname1(1:nm1)//xname2(1:nm2)//
'.dat',
 
   85      2 access=
'direct',recl=1915*4,
 
   86      3 form=
'unformatted',status=
'unknown')
 
   88       open(53,access=
'direct',
 
   89      1     form=
'unformatted',status=
'scratch',recl=18400*4) 
 
   90       open(54,access=
'direct',
 
   91      1     form=
'unformatted',status=
'scratch',recl=18400*4)
 
   92       open(55,access=
'direct',
 
   93      1     form=
'unformatted',status=
'scratch',recl=18400*4)
 
   94       open(64,access=
'direct',
 
   95      1     form=
'unformatted',status=
'scratch',recl=18400*4) 
 
   96       open(65,access=
'direct',
 
   97      1     form=
'unformatted',status=
'scratch',recl=18400*4) 
 
   98       open(71,access=
'direct',
 
   99      1     form=
'unformatted',status=
'scratch',recl=18400*4) 
 
  100       open(72,access=
'direct',
 
  101      1     form=
'unformatted',status=
'scratch',recl=18400*4) 
 
  105      1     dir3(1:len3)//
'/'//xname1(1:nm1)//xname2(1:nm2)//
'crftdn.dat' 
  108      1     dir3(1:len3)//
'/'//xname1(1:nm1)//xname2(1:nm2)//
'crftup.dat' 
  111      1 dir3(1:len3)//
'/'//xname1(1:nm1)//xname2(1:nm2)//
'crft.dat',
 
  112      2 access=
'direct',recl=1915*4,
 
  113      3 form=
'unformatted',status=
'unknown')
 
  114       open(73,access=
'direct',
 
  115      1     form=
'unformatted',status=
'scratch',recl=18400*4)
 
  116       open(74,access=
'direct',
 
  117      1     form=
'unformatted',status=
'scratch',recl=18400*4)
 
  122      1     dir3(1:len3)//
'/'//xname1(1:nm1)//xname2(1:nm2)//
'flx.dat',
 
  128      1     dir3(1:len3)//
'/'//xname1(1:nm1)//xname2(1:nm2)//
'surfup.dat' 
  132      1     dir3(1:len3)//
'/'//xname1(1:nm1)//xname2(1:nm2)//
'dirup.dat',
 
  135      1     dir3(1:len3)//
'/'//xname1(1:nm1)//xname2(1:nm2)//
'ocnup.dat',
 
  138      1     dir3(1:len3)//
'/'//xname1(1:nm1)//xname2(1:nm2)//
'skyup.dat',
 
  150        read(21,126)wvlth,psrfc,rho,xozn,tautot,deltau,nolyr
 
  152        read(21,126)tr,tm,ta,tcar,twat,tozn,ifc
 
  157           read(21,128)ht(i+1),pl(i+1),dtrr(i),dtmm(i),dtaa(i),dtot(i)
 
  164      1           dir1(1:len1)//
'/'//xname5(1:nm5)//
'.dat',
 
  170                read(2,150)htp(i),ppo(i),taur(i),taum(i),tauabs(i)
 
  184          xname6=
'phs_twl'//cilm//
'sd'//cisd//
'rh'//crh//
'_set'//cset
 
  185          nm6=
index(xname6,
' ')-1
 
  188      1        dir2(1:len2)//
'/'//xname6(1:nm6)//
'.dat',
 
  193          read (5,1125) ifunc,mfunc
 
  196            read (5,1100) wvlth2,refr1,refi1
 
  198            read (5,1100) rmin1,rmax1
 
  200            read (5,1100) delr1,delx1
 
  202            read (5,1100) 
rc,cc,xnu       
 
  203          elseif(ifunc.eq.2)
then 
  205            read (5,1100) wvlth2,refr1,refi1
 
  207            read (5,1100) rmin1,rmax1
 
  209            read (5,1100) delr1,delx1
 
  211            read (5,1100) xalf,xgam,xa,xb 
 
  212          elseif(ifunc.eq.3)
then 
  214            read (5,1100) wvlth2,refr1,refi1
 
  216            read (5,1100) rmin1,rmax1
 
  218            read (5,1100) delr1,delx1
 
  220            read (5,1100) rg1,sig1,xnum1
 
  221          elseif(ifunc.eq.4)
then 
  223            read (5,1100) wvlth2,refr1,refi1,refr2,refi2
 
  225            read (5,1100) rmin1,rmax1,rmin2,rmax2
 
  227            read (5,1100) delr1,delx1,delr2,delx2
 
  229            read (5,1100) rg1,sig1,xnum1,rg2,sig2,xnum2
 
  230          elseif(ifunc.eq.5)
then 
  232            read (5,1100) wvlth2,refr1,refi1,refr2,refi2,refr3,refi3
 
  234            read (5,1100) rmin1,rmax1,rmin2,rmax2,rmin3,rmax3
 
  236            read (5,1100) delr1,delx1,delr2,delx2,delr3,delx3
 
  238            read (5,1130) rg1,sig1,xnum1,rg2,sig2,xnum2,rg3,sig3,xnum3 
 
  241          read (5,1100) r11,r22,r33,r44,reff,veff
 
  243          read (5,1095) 
ccn,bsr,salb,asf,qs,qt
 
  249          if(dw .ge.2.0e-8)
then 
  251              write(*,*) 
"Wavelength mismatch ",dw,wvlth,wvlth2
 
  257             read(5,1120)(t(i,j),j=1,4),thd(i)
 
  263      1     access=
'sequential',form=
'unformatted',status=
'scratch')
 
  265      1     access=
'sequential',form=
'unformatted',status=
'scratch')
 
  272      1     dir4(1:len4)//
'/'//
'rufrtwl'//cilm//
'x'//cwind//
'solz00.dat',
 
  273      2     access=
'sequential',form=
'unformatted',status=
'old')
 
  277           read (20) xzx,izx,athcnd,aphcnd
 
  279      1     dir4(1:len4)//
'/'//
'ocn_refl_wl'//cilm//
'x'//cwind//
'.dat' 
  284 901       
format(
'xzx',3f8.3)
 
  285 902       
format(
'izx',2i5)
 
  286 903       
format(
'athcnd',10f7.1)
 
  287 904       
format(
'aphcnd',10f7.1)
 
  290           write (19) (xzx(i),i=1,3),mtha,mphi
 
  293              read (20) thetap,ftrx,ptix
 
  299                       txx(i,k,l,j)=ftrx(i,j,k)
 
  314          open(17,file=dir0(1:len0)//
'/'//
'brdf.dat',
 
  318          read(17,*)nsolbrdf,nthbrdf,nphbrdf,nwbrdf
 
  320             read(17,160)solbrdf(is)
 
  322             read(17,165)(wbrdf(i),i=1,nwbrdf)
 
  323 165         
format(t22,f5.1,t35,f5.1,t48,f5.1,t61,f5.1,
 
  329                diffwbrdf=dabs(wvlth*1.0d7-wbrdf(i)) 
 
  330                if(diffwbrdf.lt.0.1d-3)mwbrdf=i
 
  344                   read(17,170)thbrdf(k),phbrdf(j),
 
  345      1                        (brdfy(l),l=1,nwbrdf)
 
  346 170               
format(f6.2,2x,f6.2,10d13.4)
 
  347                   brdfx(is,k,m)=brdfy(mwbrdf)
 
  356       if(ipol.eq.0)rho=0.0d0
 
  397       bfr1(34)=float(ipsudo)
 
  398       bfr1(41)=dfloat(ifoam)
 
  399       bfr1(42)=dfloat(iwatr)
 
  402       bfr1(45)=dfloat(iref)
 
  405       bfr1(48)=dfloat(ifunc)
 
  406       bfr1(49)=dfloat(mfunc)
 
  407       goto(210,220,230,230,230),ifunc
 
  421       if(ifunc.eq.3)
goto 260
 
  430       if(ifunc.eq.4)
goto 260
 
  443  100  
format(2i4,1x,1p6e11.3)                                           
 
  445  126  
format(6d12.4,i4)
 
  446  128  
format(4x,6d12.4)
 
  448  150  
format(5x,1p6e12.4)                                               
 
  449   195 
format (1x,
'xzx',1p10d11.2)
 
  450   196 
format (1x,
'izx',2i5)
 
  451   197 
format (1x,
'athcnd',1p10d11.2)
 
  452   198 
format (1x,
'aphcnd',1p10d11.2)
 
  453   199 
format (1x,
'thetap',1p10d11.2)
 
  454   200 
format (1x,
'ftrx',1p10d11.2)
 
  456   201 
format (1x,
'pti',1p10d11.2)
 
  457   505 
format (1x,
'end of file encountered , check the program')
 
  459  1095 
format(1p4e11.3,1p2e12.4)
 
  460  1100 
format(1p7e11.3)
 
  461  1105     
format(1x,
'input wavelength and phase matrix wavelength' 
  462      1       
' do not match.'/1x,
'input wavelength=',1pe12.4,
 
  463      2         
'phase matrix wavelength=',1pe12.4)
 
  464  1120 
format(1p2d18.12,1p2d19.12,0pf6.2)
 
  465  1125 
format(i5,11x,i5)