c--- reformat Jmat file generated by calj_det.F (calj_summary1 or 2)
      real(8):: q(3),www
      real(8),allocatable:: x0matinvrc(:,:,:)
      character(30) fname,aaa
      integer(4)::nmbas,ix,iy
      complex(8),allocatable:: x0matinv0(:,:)
      character(300) :: fff
      complex(8)::  img=(0d0,1d0)
      read(5,'(a)') fff
      read(fff,*) fname,nmbas
      allocate(x0matinv0(nmbas,nmbas),x0matinvrc(nmbas,nmbas,2))
      ifmat=1015
      open(ifmat, file=fname)

      do 
       read(ifmat,*,end=1012)
     &  q, (((x0matinvrc(ix,iy,ir),ir=1,2),ix=1,nmbas),iy=1,nmbas) 
       do ix =1,nmbas
       do iy =1,nmbas
         x0matinv0(ix,iy) = x0matinvrc(ix,iy,1)+ img*x0matinvrc(ix,iy,2)
       enddo
       enddo
       write(6,"(3d11.3, 3x, 255d11.3)") 
     &  q, ((x0matinv0(ix,iy),ix=1,nmbas),iy=1,nmbas) 
      enddo
 1012  continue
      end
