#define DEBUG
#define BINDIR /r3/martin/bin/MTYPE
#define ULTIMOD Ultiall

#include <SEP.defs>


#define RebuildableFortran  ( cando %.f and exist %.f )
#define RebuildableFortran  (not {{cake  -q junk.f }}) and exist junk.f

%.fclean&: if     RebuildableFortran
	@-/bin/rm %.f
	
%.fclean&: if not RebuildableFortran
	@echo %.f not removed since it cannot be rebuilt

#define RebuildableCMFortran  cando %.fcm and exist %.fcm 
#define RebuildableCMFortran (not {{ cake -q %.fcm  }}) and exist %.fcm 

%.fcmclean&: if     RebuildableCMFortran
	@-/bin/rm %.fcm
	
%.fcmclean&: if not RebuildableCMFortran
	@echo %.fcm not removed since it cannot be rebuilt
	

alliso&: homoiso.h wavelet.vert 
	Scale <homoiso.h >homoviscoiso.h dscale=0.0
	time BINDIR/Ultiall visco=0  type=2 modeling=1 moduli=homoiso.h viscomoduli=homoviscoiso.h par=parfile  <wavelet.vert >junk zseis=zseis.iso xseis=xseis.iso nt=400
$	time BINDIR/Ultiall  type=2 modeling=1 moduli=homoiso.h par=parfile  <wavelet.vert >junk zseis=zseis.iso.all xseis=xseis.iso.all nt=400
$	time BINDIR/Ultimod  type=2 modeling=1 moduli=homoiso.h viscomoduli=homoviscoiso.h par=parfile  <wavelet.vert >junk zseis=zseis.iso xseis=xseis.iso nt=400
$	Scale <homoiso.h >homoviscoiso.h dscale=0.005
	Scale <homoiso.h >homoviscoiso.h dscale=0.05
	time BINDIR/Ultiall visco=1 type=2 modeling=1 moduli=homoiso.h viscomoduli=homoviscoiso.h par=parfile  <wavelet.vert >junk zseis=zseis.viscoiso xseis=xseis.viscoiso nt=400

viscoiso&: homoiso.h wavelet.vert 
	Scale <homoiso.h >homoviscoiso.h dscale=0.0
$	time BINDIR/Ultivisco visco=1  type=4 modeling=1 moduli=homoiso.h viscomoduli=homoviscoiso.h par=parfile  <wavelet.vert >junk zseis=zseis.iso xseis=xseis.iso nt=400
	time BINDIR/Ultimod  type=4 modeling=1 moduli=homoiso.h viscomoduli=homoviscoiso.h par=parfile  <wavelet.vert >junk zseis=zseis.iso xseis=xseis.iso nt=400
$	Scale <homoiso.h >homoviscoiso.h dscale=0.005
	Scale <homoiso.h >homoviscoiso.h dscale=0.05
	time BINDIR/Ultivisco visco=1 type=4 modeling=1 moduli=homoiso.h viscomoduli=homoviscoiso.h par=parfile  <wavelet.vert >junk zseis=zseis.viscoiso xseis=xseis.viscoiso nt=400

rho&: wavelet.vert
	echo "d1=0.002" >> wavelet.vert
$						blows up     (all neg. blow up too)
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=-1  >jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=1  >jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.01  >jJrho 
$
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.001  >jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.0007  >jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.00055>jJrho 
$
$ this blows up since,  0.00075 ca 0.0008 = 0.002/2.5  = dt/rho0 = rho1
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.00075 >jJrho 
$ok for higher order ..
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.00065 >jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.00055 >jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.00054 >jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.00053 >jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.0005>jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.0004>jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.00025>jJrho 
	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.0001>jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0.00001>jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=1.e-8 >jJrho 
$	Window f3=4 n3=1 <homoiso.h |Scale dscale=0. >jJrho 
	Scale <jJrho dscale=0. >jnull
	Cat jJrho jnull jJrho >rho.H
	time BINDIR/Ultiall viscorho=1 type=4 modeling=1 moduli=homoiso.h  density=rho.H par=parfile  <wavelet.vert >junk zseis=zseis.rhoiso xseis=xseis.rhoiso nt=400
$        time BINDIR/Ultiall  type=4 modeling=1 moduli=homoiso.h par=parfile  <wavelet.vert >junk zseis=zseis.iso xseis=xseis.iso nt=400
	Window f1=90 n1=1 <xseis.iso >j1
	Window f1=90 n1=1 <xseis.rhoiso >j2
	Merge j1 j2 axis=2 space=n |Graph |Tube

/* make a two component source */
wavelet.vert:
	Wavelet n1=128 d1=0.004 domain=time wavelet=ricker1 tdelay=0.080 fund=15 fhigh=30. | Scale dscale=1000000. >junk
	Spike n1=128 n2=1 n3=1 d1=0.004 k1=-1 k2=-1 k3=-1 >junk2
	Merge junk junk2 space=n axis=2 >wavelet.vert

wavelet.vert60:
	Wavelet n1=128 d1=0.004 domain=time wavelet=ricker1 tdelay=0.040 fund=30 fhigh=60. | Scale dscale=1000000. >junk
	Spike n1=128 n2=1 n3=1 d1=0.004 k1=-1 k2=-1 k3=-1 >junk2
	Merge junk junk2 space=n axis=2 >wavelet.vert60

homoiso.h:
	Geninput nx=208 nz=208 dx=40. dz=40.  symmetry=2 vp=4.0 vs=2.3  rho=2.5   >homoiso.h

homoisorho.h:
	Window f3=4 n3=1 <homoiso.h >rho.h
	Window f3=0 n3=4 <homoiso.h >rest.h
	Window f2=0   n2=104 <rho.h >junk1
	Window f2=104 n2=104 <rho.h >junk2
	Scale <junk2 dscale=0.9 >junk3
	Merge junk1 junk3 axis=2 space=n >rhonew.h
	Merge rest.h rhonew.h axis=3 space=n > homoisorho.h

homoisoc.h:
	Window f3=4 n3=1 <homoiso.h >rho.h
	Window f3=0 n3=4 <homoiso.h >rest.h
	Window f2=0   n2=104 <rest.h >junk1
	Window f2=104 n2=104 <rest.h >junk2
	Scale <junk2 dscale=0.8 >junk3
	Merge junk1 junk3 axis=2 space=n >new.h
	Merge new.h rho.h axis=3 space=n > homoisoc.h


layer.h: 
	Geninput nx=208 nz=50 dx=40. dz=15. symmetry=2 vp=4.0 vs=3.3  rho=2.5   >junk1
	Geninput nx=208 nz=50 dx=40. dz=15. symmetry=2 c11=34.3 c13=10.7 c33=22.7 c44=5.4 c66=10.6 rho=2.5 >junk0
	Geninput nx=208 nz=50 dx=40. dz=15. symmetry=2 vp=3.0 vs=2.0  rho=2.5     >junk3
	Geninput nx=208 nz=50 dx=40. dz=15. symmetry=2 c11=34.3 c13=10.7 c33=22.7 c44=5.4 c66=10.6 rho=2.5 >junk2
	Geninput nx=208 nz=8 dx=40. dz=15.  symmetry=2 vp=4.0 vs=2.3  rho=2.5     >junk4
	Merge junk0 junk1 junk2 junk3 junk4 space=n axis=2 |Transp plane=12 >layer.h


clean&:
	-RM_CMD *.x *.o  a.out core junk*

%.T:	
	Taplot <% gainpanel=every  >%.T

#include <SEP.obj.rules>
#include <SEP.prog.rules>
#include <SEP.idoc.rules>
