subroutine splotA4_RC(pname,X,Y1,append)
integer :: Ny1,Ny2,Ny3,Ny4
integer :: i1,i2,i3,i4
character(len=*) :: pname
complex(8),dimension(:,:,:,:) :: Y1
real(8),dimension(size(Y1,4)) :: X
logical,optional :: append
logical :: check,append_
append_=.false.;if(present(append))append_=append
if(append_)then
inquire(file=reg(pname),exist=check)
open(free_unit(unit),file=reg(pname),position="append")
if(check)write(unit,*)
else
open(free_unit(unit),file=reg(pname))
endif
!
!
Ny1=size(Y1,1)
Ny2=size(Y1,2)
Ny3=size(Y1,3)
Ny4=size(Y1,4)
!
do i1=1,Ny1
do i2=1,Ny2
do i3=1,Ny3
do i4=1,Ny4
write(unit,*)X(i4),dimag(Y1(i1,i2,i3,i4)),dreal(Y1(i1,i2,i3,i4))
enddo
write(unit,*)""
enddo
enddo
enddo
close(unit)
end subroutine splotA4_RC