Exemplo n.º 1
0
int main(int argc, char *argv[])
{
	clock_t tstart, tend;
	double duration;

	int numprocs, rank;
	float *sendbuf, *recvbuf;
	MPI_Comm Comm=MPI_COMM_WORLD;

	bool verb, wantrecord, wantwf, onlyrecord;
	sf_file Ffvel, Ffden, Fbvel, Fbden;
	sf_file Fsrc, Frcd, Fimg1, Fimg2;
	sf_file FGx, FGz, Fsxx, Fsxz, Fszx, Fszz;
	sf_file Ftmpfwf, Ftmpbwf;

	sf_axis at, ax, az, atau;

	int shtbgn, shtinv, shtnmb, shtpad, shtnmb0;
	int snapturn, tmpint;

	float **fvel, **bvel;
	float ***fwf, ***record, **localrec;
	float ***img1, **img2, ***mig1, **mig2;
	float *tmpsxx, *tmpsxz, *tmpszx, *tmpszz;

	sf_init(argc, argv);

	MPI_Init(&argc, &argv);
	MPI_Comm_size(Comm, &numprocs);
	MPI_Comm_rank(Comm, &rank);

	tstart=clock();
	if(rank==0) sf_warning("numprocs=%d", numprocs);

	if(!sf_getbool("verb", &verb)) verb=true;
	if(!sf_getbool("wantrecord", &wantrecord)) wantrecord=false;
	if(!sf_getbool("wantwf", &wantwf)) wantwf=false;
	if(!sf_getbool("onlyrecord", &onlyrecord)) onlyrecord=false;

	Fsrc=sf_input("-input");
	Fimg1=sf_output("-output");
	Fimg2=sf_output("img2");
	Ffvel=sf_input("fvel");
	Ffden=sf_input("fden");
	Fbvel=sf_input("bvel");
	Fbden=sf_input("bden");

	if(wantrecord)
		Frcd=sf_input("record");
	else
		Frcd=sf_output("record");

	if(wantwf){
		Ftmpfwf=sf_output("tmpfwf");
		Ftmpbwf=sf_output("tmpbwf");
	}

	FGx=sf_input("Gx");
	FGz=sf_input("Gz");
	Fsxx=sf_input("sxx");
	Fsxz=sf_input("sxz");
	Fszx=sf_input("szx");
	Fszz=sf_input("szz");
	
	at=sf_iaxa(Fsrc, 1); nt=sf_n(at); dt=sf_d(at);
	if(!sf_getbool("srcdecay", &srcdecay)) srcdecay=true;
	if(!sf_getint("srcrange", &srcrange)) srcrange=3;
	if(!sf_getfloat("srctrunc", &srctrunc)) srctrunc=0.2;
	if(!sf_getfloat("srcalpha", &srcalpha)) srcalpha=0.5;
	wavelet=sf_floatalloc(nt);
	sf_floatread(wavelet, nt, Fsrc);

	if(!sf_getint("pmlsize", &pmlsize)) pmlsize=30;
	if(!sf_getint("nfd", &nfd)) sf_error("Need half of the FD order!");
	if(!sf_getfloat("pmld0", &pmld0)) pmld0=200;

	if(!sf_getint("shtnmb", &shtnmb)) sf_error("Need shot number!");
	if(!sf_getint("shtinv", &shtinv)) sf_error("Need shot interval!");
	if(!sf_getint("shtbgn", &shtbgn)) shtbgn=0;
	shtpad=numprocs-shtnmb%numprocs;
	shtnmb0=shtnmb+shtpad;

	az=sf_iaxa(Ffvel, 1); nzb=sf_n(az);
	ax=sf_iaxa(Ffvel, 2); nxb=sf_n(ax);
	nxzb=nxb*nzb;
	nz=nzb-2*nfd-2*pmlsize;
	nx=nxb-2*nfd-2*pmlsize;

	if(!sf_getint("snapturn", &snapturn)) snapturn=1;
	if(!sf_getint("ginv", &ginv)) ginv=1;
	if(!sf_getint("wfinv", &wfinv)) wfinv=1;
	if(!sf_getint("spz", &spz)) spz=6;
	if(!sf_getint("gp", &gp)) gp=0;
	ng=(nx-1)/ginv+1;
	wfnt=(nt-1)/wfinv+1;
	wfdt=dt*wfinv;

	if(!sf_getint("ntau", &ntau)) ntau=1;
	if(!sf_getfloat("dtau", &dtau)) dtau=wfdt;
	if(!sf_getfloat("tau0", &tau0)) tau0=0;
	atau=sf_iaxa(Fsrc, 1);
	sf_setn(atau, ntau);
	sf_setd(atau, dtau);
	sf_seto(atau, tau0);

	if(!sf_histint(FGx, "n1", &nxz)) sf_error("No n1= in FGx!");
	if(nxz != nxzb) sf_error("Dimension error!");
	if(!sf_histint(FGx, "n2", &lenx)) sf_error("No n2= in FGx!");
	if(!sf_histint(FGz, "n2", &lenz)) sf_error("No n2= in FGz!");
	Gx=sf_floatalloc3(nzb, nxb, lenx);
	Gz=sf_floatalloc3(nzb, nxb, lenz);
	sxx=sf_intalloc(lenx);
	sxz=sf_intalloc(lenx);
	szx=sf_intalloc(lenz);
	szz=sf_intalloc(lenz);
	tmpsxx=sf_floatalloc(lenx);
	tmpsxz=sf_floatalloc(lenx);
	tmpszx=sf_floatalloc(lenz);
	tmpszz=sf_floatalloc(lenz);
	sf_floatread(Gx[0][0], nxzb*lenx, FGx);
	sf_floatread(Gz[0][0], nxzb*lenz, FGz);
	sf_floatread(tmpsxx, lenx, Fsxx);
	sf_floatread(tmpsxz, lenx, Fsxz);
	sf_floatread(tmpszx, lenz, Fszx);
	sf_floatread(tmpszz, lenz, Fszz);
	for (ix=0; ix<lenx; ix++){
		sxx[ix]=(int)tmpsxx[ix];
		sxz[ix]=(int)tmpsxz[ix];
	}
	for (iz=0; iz<lenz; iz++){
		szx[iz]=(int)tmpszx[iz];
		szz[iz]=(int)tmpszz[iz];
	}

	fvel=sf_floatalloc2(nzb, nxb);
	fden=sf_floatalloc2(nzb, nxb);
	fc11=sf_floatalloc2(nzb, nxb);
	bvel=sf_floatalloc2(nzb, nxb);
	bden=sf_floatalloc2(nzb, nxb);
	bc11=sf_floatalloc2(nzb, nxb);
	sf_floatread(fvel[0], nxzb, Ffvel);
	sf_floatread(fden[0], nxzb, Ffden);
	sf_floatread(bvel[0], nxzb, Fbvel);
	sf_floatread(bden[0], nxzb, Fbden);
	for (ix=0; ix<nxb; ix++){
		for (iz=0; iz<nzb; iz++){
			fc11[ix][iz]=fden[ix][iz]*fvel[ix][iz]*fvel[ix][iz];
			bc11[ix][iz]=bden[ix][iz]*bvel[ix][iz]*bvel[ix][iz];
		}
	}

	if(wantrecord){
		/* check record data */
		sf_histint(Frcd, "n1", &tmpint);
		if(tmpint != nt) sf_error("Not matched dimensions!");
		sf_histint(Frcd, "n2", &tmpint);
		if(tmpint != ng) sf_error("Not matched dimensions!");
		sf_histint(Frcd, "n3", &tmpint);
		if(tmpint != shtnmb) sf_error("Not matched dimensions!");
	}

	if(rank==0){
		record=sf_floatalloc3(nt, ng, shtnmb0);
		if(wantrecord){
			sf_floatread(record[0][0], nt*ng*shtnmb, Frcd);
			for(is=shtnmb; is<shtnmb0; is++)
				for(ix=0; ix<ng; ix++)
					for(it=0; it<nt; it++)
						record[is][ix][it]=0.0;
		}
	}

	img1=sf_floatalloc3(nz, nx, ntau);
	mig1=sf_floatalloc3(nz, nx, ntau);
	img2=sf_floatalloc2(nz, nx);
	mig2=sf_floatalloc2(nz, nx);
	zero3(img1, nz, nx, ntau);
	zero2(img2, nz, nx);

	sf_setn(az, nz);
	sf_setn(ax, ng);
	if(!wantrecord){
		sf_oaxa(Frcd, at, 1);
		sf_oaxa(Frcd, ax, 2);
		sf_putint(Frcd, "n3", shtnmb);
		sf_putint(Frcd, "d3", shtinv);
		sf_putint(Frcd, "o3", shtbgn);
	}

	sf_setn(ax, nx);
	if(wantwf){
		sf_setn(at, wfnt);
		sf_setd(at, wfdt);

		sf_oaxa(Ftmpfwf, az, 1);
		sf_oaxa(Ftmpfwf, ax, 2);
		sf_oaxa(Ftmpfwf, at, 3);

		sf_oaxa(Ftmpbwf, az, 1);
		sf_oaxa(Ftmpbwf, ax, 2);
		sf_oaxa(Ftmpbwf, at, 3);
	}

	sf_oaxa(Fimg1, az, 1);
	sf_oaxa(Fimg1, ax, 2);
	sf_oaxa(Fimg1, atau, 3);
	sf_oaxa(Fimg2, az, 1);
	sf_oaxa(Fimg2, ax, 2);

	fwf=sf_floatalloc3(nz, nx, wfnt);
	localrec=sf_floatalloc2(nt, ng);

	if(verb){
		sf_warning("==================================");
		sf_warning("nx=%d nz=%d nt=%d", nx, nz, nt);
		sf_warning("wfnt=%d wfdt=%f wfinv=%d dt=%f", wfnt, wfdt, wfinv, dt);
		sf_warning("nxb=%d nzb=%d pmlsize=%d nfd=%d", nxb, nzb, pmlsize, nfd);
		sf_warning("ntau=%d dtau=%f tau0=%f", ntau, dtau, tau0);
		sf_warning("shtnmb=%d shtbgn=%d shtinv=%d", shtnmb, shtbgn, shtinv);
		sf_warning("lenx=%d lenz=%d spz=%d gp=%d", lenx, lenz, spz, gp);
		sf_warning("==================================");
	}

	init();

	for(iturn=0; iturn*numprocs<shtnmb; iturn++){
		is=iturn*numprocs+rank;
		if(is<shtnmb){
			sf_warning("ishot/nshot: %d/%d", is+1, shtnmb);
			spx=is*shtinv+shtbgn;
			sglfdfor2(fwf, localrec, verb);
		}

		if(wantrecord){
			recvbuf=localrec[0];
			if(rank==0) sendbuf=record[iturn*numprocs][0];
			else sendbuf=NULL;
			MPI_Scatter(sendbuf, ng*nt, MPI_FLOAT, recvbuf, ng*nt, MPI_FLOAT, 0, Comm);
		}else{
			sendbuf=localrec[0];
			if(rank==0) recvbuf=record[iturn*numprocs][0];
			else recvbuf=NULL;
			MPI_Gather(sendbuf, ng*nt, MPI_FLOAT, recvbuf, ng*nt, MPI_FLOAT, 0, Comm);
		}

		if(wantwf && rank==0 && iturn==snapturn-1) wantwf=true;
		else wantwf=false;
		if(wantwf) sf_floatwrite(fwf[0][0], wfnt*nx*nz, Ftmpfwf);

		if(!onlyrecord && is<shtnmb){
			sglfdback2(mig1, mig2, fwf, localrec, verb, wantwf, Ftmpbwf);
			for(itau=0; itau<ntau; itau++){
				for(ix=0; ix<nx; ix++){
					for(iz=0; iz<nz; iz++){
						img1[itau][ix][iz]+=mig1[itau][ix][iz];
					}
				}
			}
			for(ix=0; ix<nx; ix++){
				for(iz=0; iz<nz; iz++){
					img2[ix][iz]+=mig2[ix][iz];
				}
			}
		}
		MPI_Barrier(Comm);
	} //end of iturn

	if(!onlyrecord){
	if(rank==0){
		sendbuf=(float *)MPI_IN_PLACE;
		recvbuf=img1[0][0];
	}else{
		sendbuf=img1[0][0];
		recvbuf=NULL;
	}
	MPI_Reduce(sendbuf, recvbuf, ntau*nx*nz, MPI_FLOAT, MPI_SUM, 0, Comm);

	if(rank==0){
		sendbuf=MPI_IN_PLACE;
		recvbuf=img2[0];
	}else{
		sendbuf=img2[0];
		recvbuf=NULL;
	}
	MPI_Reduce(sendbuf, recvbuf, nx*nz, MPI_FLOAT, MPI_SUM, 0, Comm);
	}

	if(rank==0){
		if(!wantrecord){
			sf_floatwrite(record[0][0], shtnmb*ng*nt, Frcd);
		}
		sf_floatwrite(img1[0][0], ntau*nx*nz, Fimg1);
		sf_floatwrite(img2[0], nx*nz, Fimg2);
	}

	tend=clock();
	duration=(double)(tend-tstart)/CLOCKS_PER_SEC;
	sf_warning(">>The CPU time of sfmpilfdrtm2 is: %f seconds<<", duration);
	MPI_Finalize();
	exit(0);
}
Exemplo n.º 2
0
int main(int argc, char* argv[]) 
{
    clock_t tstart,tend;
    double duration;

    /*flag*/
    bool verb;
    bool wantwf;
    bool wantrecord;

    
    /*I/O*/
    sf_file Ffvel, Ffden, Fbvel, Fbden;
    sf_file Fsrc,/*wave field*/ Frcd/*record*/;
    sf_file Ftmpwf, Ftmpbwf;
    sf_file Fimg1, Fimg2;
    sf_file FGx, FGz, Fsxx, Fsxz, Fszx, Fszz;

    sf_axis at, ax, az;

    /*grid index variables*/
    int nx, nz, nxz, nt, wfnt;
    int ix, iz, it;
    int nxb, nzb;
    float dt, dx, dz, wfdt;
    float ox, oz;

    /*source/geophone location*/
    float slx, slz;
    int   spx, spz;
    float gdep;
    int   gp;
    int   ginter, gn;

    /*SG LFD coefficient*/
    int lenx, lenz;
    int marg;

    /*Modle*/
    float **fvel, **fden, **fc11;
    float **bvel, **bden, **bc11;
    float ***wavefld, **record;
    float **img1, **img2;
    int snpint;

    /*source*/
    bool srcdecay;
    int srcrange;
    float srctrunc;
    
    /*pml boundary*/
    int pmlout, pmld0, decaybegin;
    bool decay, freesurface;

    /*memoray*/
    //float memneed;
    int tmpint;
    //float tmpfloat;

    tstart = clock();
    sf_init(argc, argv);
    if (!sf_getbool("verb", &verb)) verb=false; /*verbosity*/
    if (!sf_getbool("wantwf", &wantwf)) wantwf=false; /*output forward and backward wavefield*/
    if (!sf_getbool("wantrecord", &wantrecord)) wantrecord=true; /*if n, using record data generated by this program */

    /*Set I/O file*/
    Fsrc   = sf_input("in");   /*source wavelet*/
    Ffvel  = sf_input("fvel"); /*forward velocity*/
    Ffden  = sf_input("fden"); /*forward density*/
    Fbvel  = sf_input("bvel"); /*backward velocity*/
    Fbden  = sf_input("bden"); /*backward velocity*/
    if (wantrecord) {
	Frcd   = sf_input("rec");   /*record*/
    } else {
	Frcd   = sf_output("rec");   /*record*/
    }
    Fimg1  = sf_output("out");   /*Imaging*/
    Fimg2  = sf_output("img2");  /*Imaging*/

    if (wantwf) {
	Ftmpwf  = sf_output("tmpwf");/*wavefield snap*/
	Ftmpbwf = sf_output("tmpbwf");
    }

    FGx = sf_input("Gx"); 
    FGz = sf_input("Gz");
    Fsxx = sf_input("sxx");
    Fsxz = sf_input("sxz");
    Fszx = sf_input("szx");
    Fszz = sf_input("szz");
    
    if (SF_FLOAT != sf_gettype(Ffvel)) sf_error("Need float input");
    if (SF_FLOAT != sf_gettype(Ffden)) sf_error("Need float input");
    if (SF_FLOAT != sf_gettype(Fbvel)) sf_error("Need float input");
    if (SF_FLOAT != sf_gettype(Fbden)) sf_error("Need float input");
    if (SF_FLOAT != sf_gettype(Fsrc))  sf_error("Need float input");

   
    /*--- parameters of source ---*/
    srcpar srcp;
    srcp = createsrc();
    at = sf_iaxa(Fsrc, 1); nt = sf_n(at);  dt = sf_d(at);      
    if (!sf_getbool("srcdecay", &srcdecay)) srcdecay=SRCDECAY;
    /*source decay*/
    if (!sf_getint("srcrange", &srcrange)) srcrange=SRCRANGE;
    /*source decay range*/
    if (!sf_getfloat("srctrunc", &srctrunc)) srctrunc=SRCTRUNC;
    /*trunc source after srctrunc time (s)*/
    srcp->nt = nt; srcp->dt = dt; 
    srcp->decay = srcdecay; srcp->range=srcrange; srcp->trunc=srctrunc;
    loadsrc(srcp, Fsrc);

    /*--- parameters of SG LFD Coefficient ---*/
    ax = sf_iaxa(Ffvel, 2); nxb = sf_n(ax); dx = sf_d(ax); ox = sf_o(ax);
    az = sf_iaxa(Ffvel, 1); nzb = sf_n(az); dz = sf_d(az); oz = sf_o(az);

    if (!sf_histint(FGx, "n1", &nxz)) sf_error("No n1= in input");
    if (nxz != nxb*nzb) sf_error (" Need nxz = nxb*nzb");
    if (!sf_histint(FGx,"n2", &lenx)) sf_error("No n2= in input");
    if (!sf_histint(FGz,"n2", &lenz)) sf_error("No n2= in input");
    
    initsglfdcoe(nxb, nzb, lenx, lenz);
    loadcoe(nzb, nxb, FGx, FGz);
    loadschm(Fsxx, Fsxz, Fszx, Fszz);
    marg = getmarg();

    /* pml parameters */
    pmlpar pmlp;
    pmlp = creatpmlpar();
    if (!sf_getint("pmlsize", &pmlout)) pmlout=PMLOUT;
    /* size of PML layer */
    if (!sf_getint("pmld0", &pmld0)) pmld0=PMLD0;
    /* PML parameter */
    if (!sf_getbool("decay",&decay)) decay=DECAY_FLAG;
    /* Flag of decay boundary condtion: 1 = use ; 0 = not use */
    if (!sf_getint("decaybegin",&decaybegin)) decaybegin=DECAY_BEGIN;
    /* Begin time of using decay boundary condition */
    if (!sf_getbool("freesurface", &freesurface)) freesurface=false;
    /*free surface*/
    nx = nxb - 2*pmlout - 2*marg;
    nz = nzb - 2*pmlout - 2*marg;

    pmlp->pmlout =  pmlout;
    pmlp->pmld0 = pmld0;
    pmlp->decay = decay;
    pmlp->decaybegin = decaybegin;
    pmlp->freesurface = freesurface;

    /*Geometry parameters*/
    geopar geop;
    geop = creategeo();
 
    /*source loaction parameters*/
    slx = -1.0; spx = -1;
    slz = -1.0; spz = -1;
    gdep = -1.0; gp = 0;
    
    if (!sf_getfloat("slx", &slx)) ; 
    /*source location x */
    if (!sf_getint("spx", &spx));
    /*source location x (index)*/
    if((slx<0 && spx <0) || (slx>=0 && spx >=0 ))  sf_error("Need src location");
    if (slx >= 0 )    spx = (int)((slx-ox)/dx+0.5);
    
    if (!sf_getfloat("slz", &slz)) ;
    /* source location z */
    if (!sf_getint("spz", &spz)) ;
    /*source location z (index)*/
    if((slz<0 && spz <0) || (slz>=0 && spz >=0 ))  sf_error("Need src location");
    if (slz >= 0 )    spz = (int)((slz-ox)/dz+0.5);
    
    if (!sf_getfloat("gdep", &gdep)) ;
    /* recorder depth on grid*/
    if (!sf_getint("gp", &gp)) ;
    /* recorder depth on index*/
    if ( gdep>=oz) { gp = (int)((gdep-oz)/dz+0.5);}
    if (gp < 0.0) sf_error("gdep need to be >=oz");
    /*source and receiver location*/
    if (!sf_getint("ginter", &ginter)) ginter = 1;
    /*geophone interval*/
    gn = (nx-1)/ginter+1; /*ceil*/
    if (!sf_getint("snapinter", &snpint)) snpint=10;
    /* snap interval */
    
    /*check record data*/
    if (wantrecord){
	sf_histint(Frcd,"n1", &tmpint);
	if (tmpint != nt ) sf_error("Error parameter n1 in record!");
	sf_histint(Frcd,"n2", &tmpint);
	if (tmpint != gn ) sf_error("Error parameter n2 in record!");
    }
    
    geop->nx  = nx;
    geop->nz  = nz;
    geop->nxb = nxb;
    geop->nzb = nzb;
    geop->dx  = dx;
    geop->dz  = dz;
    geop->ox  = ox;
    geop->oz  = oz;
    geop->snpint = snpint;
    geop->spx = spx;
    geop->spz = spz;
    geop->gp = gp;
    geop->gn = gn;
    geop->ginter = ginter;

    /* wavefield and record  */
    wfnt = (int)(nt-1)/snpint+1;
    wfdt = dt*snpint;
    record = sf_floatalloc2(nt, gn);
    wavefld = sf_floatalloc3(nz, nx, wfnt);
    
    /* read model */
    fvel = sf_floatalloc2(nzb, nxb);
    fden = sf_floatalloc2(nzb, nxb);
    fc11 = sf_floatalloc2(nzb, nxb);

    /*image*/
    img1 = sf_floatalloc2(nz, nx);
    img2 = sf_floatalloc2(nz, nx);

    
    sf_floatread(fvel[0], nxz, Ffvel);
    sf_floatread(fden[0], nxz, Ffden);
    for (ix = 0; ix < nxb; ix++) {
	for ( iz= 0; iz < nzb; iz++) {
	    fc11[ix][iz] = fden[ix][iz]*fvel[ix][iz]*fvel[ix][iz];
	    if(fc11[ix][iz] == 0.0) sf_warning("c11=0: ix=%d iz%d", ix, iz);
	}
    }

    bvel = sf_floatalloc2(nzb, nxb);
    bden = sf_floatalloc2(nzb, nxb);
    bc11 = sf_floatalloc2(nzb, nxb);
    
    sf_floatread(bvel[0], nxz, Fbvel);
    sf_floatread(bden[0], nxz, Fbden);
    for (ix = 0; ix < nxb; ix++) {
	for ( iz= 0; iz < nzb; iz++) {
	    bc11[ix][iz] = bden[ix][iz]*bvel[ix][iz]*bvel[ix][iz];
	    if(bc11[ix][iz] == 0.0) sf_warning("c11=0: ix=%d iz%d", ix, iz);
	}
    }
    if (verb) {
	sf_warning("============================");
	sf_warning("nx=%d nz=%d nt=%d", geop->nx, geop->nz, srcp->nt);
	sf_warning("dx=%f dz=%f dt=%f", geop->dx, geop->dz, srcp->dt);
	sf_warning("lenx=%d lenz=%d marg=%d pmlout=%d", lenx, lenz, marg, pmlout);
	sf_warning("srcdecay=%d srcrange=%d",srcp->decay,srcp->range);
	sf_warning("spx=%d spz=%d gp=%d snpint=%d", spx, spz, gp, snpint);
	sf_warning("wfdt=%f wfnt=%d ", wfdt, wfnt);
	sf_warning("============================");
    }

    /* write record */
    sf_setn(ax, gn);
    sf_setn(az, nz);
    
    if(!wantrecord) {
	sf_oaxa(Frcd, at, 1);
	sf_oaxa(Frcd, ax, 2);
    }
    
    /*wavefiel and image*/
    sf_setn(ax,nx);

    if (wantwf) {
	/*write temp wavefield */
	sf_setn(ax, nx);
	sf_setn(at, wfnt);
	sf_setd(at, wfdt);
	
	sf_oaxa(Ftmpwf, az, 1);
	sf_oaxa(Ftmpwf, ax, 2);
	sf_oaxa(Ftmpwf, at, 3);
	
	/*write temp wavefield */
	sf_oaxa(Ftmpbwf, az, 1);
	sf_oaxa(Ftmpbwf, ax, 2);
	sf_oaxa(Ftmpbwf, at, 3);
    }

    /*write image*/
    sf_oaxa(Fimg1, az, 1);
    sf_oaxa(Fimg1, ax, 2);
    sf_oaxa(Fimg2, az, 1);
    sf_oaxa(Fimg2, ax, 2);


    sglfdfor2(wavefld, record, verb, fden, fc11, geop, srcp, pmlp);
    if(wantrecord) {
	sf_floatread(record[0], gn*nt, Frcd);
    }
    sglfdback2(img1, img2, wavefld, record, verb, wantwf, bden, bc11, geop, srcp, pmlp, Ftmpbwf);
    
    if (!wantrecord) {
	for (ix=0; ix<gn; ix++) 
	    sf_floatwrite(record[ix], nt, Frcd);
    }
    
    if (wantwf) {
	for (it=0; it<wfnt; it++)
	    for ( ix=0; ix<nx; ix++)
		sf_floatwrite(wavefld[it][ix], nz, Ftmpwf);
    }

    for (ix=0; ix<nx; ix++) 
	sf_floatwrite(img1[ix], nz, Fimg1);
    for (ix=0; ix<nx; ix++) 
	sf_floatwrite(img2[ix], nz, Fimg2);
      
    freertm();
    tend = clock();
    duration=(double)(tend-tstart)/CLOCKS_PER_SEC;
    sf_warning(">> The CPU time of sfsglfd2 is: %f seconds << ", duration);
    exit(0);

}