      subroutine cornermod(xa,ya,za)

      implicit none
      include 'param_o.h'  
!----------------------------------------------------------------------
      integer,parameter::kstrd=4, lstrd = kstrd, km = (im - 1) * kstrd+1

      real,dimension(1-kstrd:km+kstrd,1-lstrd:km+lstrd,nm)::xa,ya,za
      real,dimension(3)::aint
      real::pp1,pp2,pp3,app1,app2,app3,xtmp,ytmp,ztmp,p2p3,ralpha

      call parallelpt(xa(5,1,1),ya(5,1,1),za(5,1,1),   &
                      xa(5,5,1),ya(5,5,1),za(5,5,1),   &
		      xa(1,5,1),ya(1,5,1),za(1,5,1),   &
		      xtmp,ytmp,ztmp)

      pp3=sqrt((xa(5,5,1)-xtmp)**2+(ya(5,5,1)-ytmp)**2 &
              +(za(5,5,1)-ztmp)**2)
      p2p3=sqrt((xa(5,5,1)-xa(1,1,1))**2+(ya(5,5,1)-ya(1,1,1))**2 &
               +(za(5,5,1)-za(1,1,1))**2)
      ralpha=pp3/p2p3

      pp1=sqrt((xa(km-4,1,4)-xtmp)**2+(ya(km-4,1,4)-ytmp)**2   &
               +(za(km-4,1,4)-ztmp)**2)
      pp2=sqrt((xa(1,1,1)-xtmp)**2+(ya(1,1,1)-ytmp)**2         &
               +(za(1,1,1)-ztmp)**2)
      pp3=sqrt((xa(5,5,1)-xtmp)**2+(ya(5,5,1)-ytmp)**2         &
               +(za(5,5,1)-ztmp)**2)

      app1=-2.*asin(pp1*0.5)
      app2=2.*asin(pp2*0.5)
      app3=2.*asin(pp3*0.5)

      aint(1)=app2*app3/((app1-app2)*(app1-app3))
      aint(2)=app1*app3/((app2-app1)*(app2-app3))
      aint(3)=app1*app2/((app3-app1)*(app3-app2))

      open(11,file='interpco.dat',   &
         form='unformatted')
      write(11)ralpha,aint
      close(11)

      end subroutine cornermod

