      subroutine znll2c(tavg_zn,tavgzn_c)

      implicit none
      include 'param_c.h'
      real,dimension(jgm,lm)::tavg_zn
      real,dimension(0:im+1,0:jm+1,nm,lm)::tavgzn_c
      real,dimension(0:im+1,0:jm+1,nm)::hphi,vphi
      real,parameter::pihlf=3.1415926*0.5
      integer::i,j,n,it

      open(11,file="../../data_in/cube_grid/hvphi.dat"  &
             ,form="unformatted")
      read(11)hphi,vphi
      close(11)

      hphi=(hphi/pihlf+1.0)*0.5*(jgm-1)+1.0

      do n=1,nm
      do i=0,im+1
      do j=0,jm+1
        it=hphi(i,j,n)
	tavgzn_c(i,j,n,:)=tavg_zn(it,:)+(hphi(i,j,n)-it)  &
                       *(tavg_zn(it+1,:)-tavg_zn(it,:))
      enddo
      enddo
      enddo

      end subroutine znll2c


