MAKE_DEPEND=yes
SEPINC = /opt/SEP/SEP6.4.6_INTEL/include
include $(SEPINC)/SEP.top
SRCDIR = ./
BINDIR = /net/koko/gayeni/bin/$(MTYPE)

UPSTEXFLAGS=invras=y
LATOPTS  = style=html

LIBDIR = -L/opt/SEP/SEP6.4.6/lib  -L/net/koko/gayeni/lib/$(MTYPE) -L/opt/intel_fce_80/lib/
#LIBDIR = -L/usr/local/SEP/SEP6.4.2_INTEL/lib 

FFT= -L/opt/FFTW_OLD/lib -lfftw3f -lfftw3f -lfftw3 -lm #-lfftw3f_threads   -lm

UF90DEFINES = -DSEP_OMP -I/opt/FFTW_OLD/include 
UF90FLAGS = -O3 -openmp -CB -axW -openmp -static-libcxa -Bstatic  -I/opt/FFTW_OLD/include # -vec_report3 -quiet
UF90LIBS =  -openmp -lsupersetf90 -lsuperset -lsepauxf90 -lsepmathf90 -lsep2df90 -lsep3df90 -lsep3d -lsepf90 -lsep -lsepgeef90 -openmp $(FFT) 


INCDIR = -I./ -I/opt/intel_fce_80/include/ -I/net/koko/gayeni/include/$(MTYPE)

default: ${BINDIR}/*.x 

B= $(BINDIR)

%.F90:  %.f90s
	ln -s $*.f90s $*.F90


BAY_IT: $B/testfact.x
	$B/testfact.x infile=BAY.H  > BAY_IT.H     iso=n
	$B/testfact.x infile=BAY.H  > BAY_IT_iso.H iso=y
	Grey wantscalebar=y < BAY.H        >/dev/null out=BAY.v
	Grey wantscalebar=y < BAY_IT.H     >/dev/null out=$@.v     polarity=1 
	Grey wantscalebar=y < BAY_IT_iso.H >/dev/null out=$@_sio.v polarity=1 
	Transp < BAY.H       | Reverse | Transp | Grey wantscalebar polarity=-1 max2=450 min2=400 yreverse=1 max2=2100 max1=400 min1=1100 min2=450 crowd1=0.85 crowd2=0.85 polarity=1 title='Topo map   '     >/dev/null out=topo.v
	Transp < BAY_IT.H    | Reverse | Transp | Grey wantscalebar polarity=-1 max2=450 min2=400 yreverse=1 max2=2100 max1=400 min1=1100 min2=450 crowd1=0.85 crowd2=0.85 polarity=1 title='Helix derivative'>/dev/null out=hderiv.v
	Transp < BAY_IT_iso.H| Reverse | Transp | Grey wantscalebar polarity=-1 max2=450 min2=400 yreverse=1 max2=2100 max1=400 min1=1100 min2=450 crowd1=0.85 crowd2=0.85 polarity=1 title='Iso derivative'  >/dev/null out=ideriv.v
	tube ideriv.v hderiv.v topo.v

junk.H: 
	Vel vc=2000 n1=201 d1=10 o1=0 n2=501 d2=10 o2=0 n3=1 d3=10 o3=0     \
                xa1=-0  xb1=5000   z1=300    alfa1=0    vr1=2300    const1=1 \
                xa2=-0  xb2=5000   z2=1000   alfa2=-30    vr2=2600    const2=1 > $@
junk_it.v: $B/testfact.x junk.H
	$B/testfact.x infile=junk.H  > junk_it.H
	Grey wantscalebar=y newclip=1 < junk_it.H >/dev/null out=$@ polarity=-1 
	Grey wantscalebar=y newclip=1 < junk.H    >/dev/null out=junk.v
	tube junk.v junk_it.v

vel.H:
	Cp ../mod2.H $@

vel_it.v: $B/testfact.x vel.H
	Window3d < vel.H j1=2 j2=2 > vel_junk.H	
	$B/testfact.x infile=vel_junk.H  > vel_it.H
	$B/reflectivity.x vel=vel_junk.H > ref_junk.H
	Grey wantscalebar=y newclip=1 < vel_it.H      >/dev/null out=$@ polarity=1 
	Grey wantscalebar=y newclip=1 < vel_junk.H    >/dev/null out=vel_junk.v
	Grey wantscalebar=y newclip=1 < ref_junk.H    >/dev/null out=ref_junk.v
	tube vel_it.v vel_junk.v ref_junk.v

test1:
	make ${BINDIR}/killwave.x ; 
	killwave.x infile=in.H verb=2 verb1=1 nfilt=9 nang=180 dip=dip1.H destroy=n outfile=outfile1.> junk.H ; Grey < outfile1. wantscalebar=y | Tube & 
test2:
	make ${BINDIR}/killwave.x ; 
	killwave.x infile=in.H verb=2 verb1=1 nfilt=9 nang=180 dip=dip1.H destroy=y outfile=outfile2> junk.H ; Grey < outfile2 wantscalebar=y | Tube & 
test3:
	make ${BINDIR}/killwave.x ; 
	killwave.x infile=in.H verb=2 verb1=1 nfilt=9 nang=9  dip=dip1.H destroy=n outfile=outfile3> junk.H ; Grey < outfile3 wantscalebar=y | Tube & 
test4:
	make ${BINDIR}/killwave.x ; 
	killwave.x infile=in.H verb=2 verb1=1 nfilt=9 nang=180 dip=dip2.H destroy=y outfile=outfile4> junk.H ; Grey < outfile4 wantscalebar=y | Tube & 
test5:
	make ${BINDIR}/killwave.x ; 
	killwave.x infile=in.H verb=2 verb1=1 nfilt=9 nang=40 dip=dip1.H destroy=n outfile=outfile5> junk.H ; Grey < outfile5 wantscalebar=y pclip=99.6| Tube & 
test6:
	make ${BINDIR}/killwave.x ; 
	killwave.x infile=in.H verb=2 verb1=1 nfilt=9 nang=40 dip=dip1.H destroy=y outfile=outfile6> junk.H ; Grey < outfile6 wantscalebar=y pclip=99.6| Tube & 
test7:
	make ${BINDIR}/killwave.x ; 
	killwave.x infile=in.H verb=2 verb1=1 nfilt=9 nang=90 dip=dip1.H destroy=n outfile=outfile7 rand_in=y> junk.H ; Grey < outfile7 title='rand/filt' wantscalebar=y pclip=99.6 >/dev/null \
	out=rand_conv_filt.v
test8:
	make ${BINDIR}/killwave.x ; 
	killwave.x infile=in.H verb=2 verb1=1 nfilt=9 nang=90 dip=dip1.H destroy=y outfile=outfile8 rand_in=y> junk.H ; Grey < outfile8 title='rand*filt'  wantscalebar=y pclip=99.6>/dev/null \
	out=rand_deconv_filt.v
test9:
	make ${BINDIR}/killwave.x ; 
	killwave.x infile=in.H verb=2 verb1=1 nfilt=9 nang=90 dip=dip1.H destroy=y outfile=outfile9 rand_in=n> junk.H ; Grey < outfile9 title='infile*filt' wantscalebar=y pclip=99.6 >/dev/null \
	out=in_conv_filt.v
test10:
	make ${BINDIR}/killwave.x ; 
	killwave.x infile=in.H verb=2 verb1=1 nfilt=9 nang=90 dip=dip1.H destroy=n outfile=outfile10 rand_in=n> junk.H ; Grey < outfile10 title='infile/filt' wantscalebar=y pclip=99.6 >/dev/null \
	out=in_deconv_filt.v
test11:
	make ${BINDIR}/killwave.x ; 
	killwave.x infile=cc.H verb=2 verb1=1 nfilt=9 nang=90 dip=dd.H destroy=n eps=0.01 outfile=outfile10 rand_in=n> junk.H ; Grey < outfile10 title='cc/filt' wantscalebar=y pclip=99.6 >/dev/null \
	out=$@.v
	tube $@.v
testfigs:
	Grey < outfile7  title='rand/filt' wantscalebar= y pclip=99.6 >/dev/null out=rand_deconv_filt.v
	Grey < outfile8  title='rand*filt'  wantscalebar= y pclip=99.6>/dev/null out=rand_conv_filt.v
	Grey < outfile9  title='infile*filt' wantscalebar= y pclip=99.6 >/dev/null out=in_conv_filt.v
	Grey < outfile10 title='infile/filt' wantscalebar= y pclip=99.6 >/dev/null out=in_deconv_filt.v
	Grey < dip1.H title='dipfile'  wantscalebar= y pclip=99.6>/dev/null  out=dips.v
	Grey < in.H title='infile'  wantscalebar= y pclip=99.6>/dev/null  out=in.v 
	tube in.v  dips.v rand_deconv_filt.v rand_conv_filt.v in_conv_filt.v  in_deconv_filt.v
	
clean:
	rm -f *.x *.fix.* *.mod *.o .make.dependencies.LINUX

include $(SEPINC)/SEP.bottom
