      program obscur3d
      parameter(nxm=500,nym=500,ncm=10)
      real*4 x(nxm),y(nxm),z(nxm,nym,ncm)
      character*128 fich
      character*1  bid
c
 1    call lifich('Prefix of the .c3d to translate ?',0,fich,lfich)
      open(2,file=fich(1:lfich)//'.c3d.clair',status='old',err=1)
      call lientier('With commentaries (0) or without (1) ?'
     &     ,0,icom)
      read(2,*) nx,ny
      if (nx.eq.0) then
        icoo = ny
        read(2,*) nx,ny
      else
        icoo = 0
      endif
      if (nx.gt.nxm.or.ny.gt.nym) then
        print*,'*** Too many points : nx =',nx,',  ny =',ny
        stop
      endif
      open(1,file=fich(1:lfich)//'.c3d',form='unformatted')
      if (icoo.ne.0) write(1) 0,icoo
      write(1) nx,ny
      if (icom.eq.0) read(2,'(a)') bid
      do i=1,nx
        read(2,*) x(i)
      enddo
      if (icom.eq.0) read(2,'(a)') bid
      do i=1,ny
        read(2,*) y(i)
      enddo
      write(1) (x(i),i=1,nx),(y(j),j=1,ny)
      do k=1,ncm
        do j=1,ny
          if (icom.eq.0) read(2,'(a)',end=1000,err=1000) bid
          do i=1,nx
            read(2,*,end=1000,err=1000) z(i,j,k)
          enddo
        enddo
        write(1) ((z(i,j,k),i=1,nx),j=1,ny)
      enddo
1000  close(1)
      close(2)
      end
      
      
      
