⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sumigprespmaster.c

📁 su 的源代码库
💻 C
📖 第 1 页 / 共 2 页
字号:
	memcpy( (void *) p[ix], (const void *) tr.data,nt*FSIZE);        nx = 0;	while(gettr(&tr)){			int igx;			if(tr.sx!=oldsx){ fseek(stdin,(long)(-240-nt*4),SEEK_CUR); break;}			igx=tr.gx/dx;			memcpy( (void *) p[igx], (const void *) tr.data,nt*FSIZE);                  			if(gxmin>tr.gx)gxmin=tr.gx;			if(gxmax<tr.gx)gxmax=tr.gx;			nx++;			oldsx=tr.sx;			}	warn("\nnx= %d",nx);	warn("sx %f , gxmin %f  gxmax %f",sx,gxmin,gxmax);	/*transform the shot gather from time to frequency domain*/        pfa2rc(1,1,ntfft,nxo,p[0],cp[0]);	/*compute the most left and right index for the migrated section*/ 	ix1=sx/dx;	ix2=gxmin/dx;	ix3=gxmax/dx;        	if(ix1>=ix3)ix3=ix1;	if(ix1<=ix2)ix2=ix1;	il=ix2;	ir=ix3;	ix2-=lpad;	ix3+=rpad;	if(ix2<0)ix2=0;	if(ix3>nxo-1)ix3=nxo-1;	/*the total traces to be migrated*/	nx=ix3-ix2+1;	/*allocate space*/        cq = alloc2complex(nx,nw);	cq1 = alloc2complex(nx,nw);	/*transpose the frequency domain data from data[ix][iw] to data[iw][ix] and	apply a Hamming at the same time*/	for (ix=0; ix<nx; ix++)	for (iw=0; iw<nw; iw++){		float tmpp=0.0,tmppp=0.0;		if(iw<nf1||iw>nf4)	cq[iw][ix]=cmplx(0.0,0.0);	else{		if(iw>=nf1&&iw<=nf2){tmpp=PI/(nf2-nf1);tmppp=tmpp*(iw-nf1)-PI;tmpp=0.54+0.46*cos(tmppp);		cq[iw][ix]=crmul(cp[ix+ix2][iw],tmpp);}		else{			if(iw>=nf3&&iw<=nf4){tmpp=PI/(nf4-nf3);tmppp=tmpp*(iw-nf3);tmpp=0.54+0.46*cos(tmppp);			cq[iw][ix]=crmul(cp[ix+ix2][iw],tmpp);}			else			{cq[iw][ix]=cp[ix+ix2][iw];}		}	}	cq[iw][ix]=cp[ix+ix2][iw];	cq1[iw][ix]=cmplx(0.0,0.0);	}	ix=sx/dx-ifx;	warn("ix %d",ix);	for(iw=0;iw<nw;iw++){	cq1[iw][ix-ix2]=wlsp[iw];	}	free2float(p);	free2complex(cp);	free1float(wl);	free1complex(wlsp);	/*if the horizontal spacing interval is in feet, convert it to meter*/ 	if(!flag)	dx*=0.3048;	/*start of the timing function*/	time(&t1);	/* send local parameters to all slaves*/	pvm_initsend(PvmDataDefault);	ix=15;	rc=pvm_pkint(&ix,1,1);	rc=pvm_pkint(&ntfft,1,1);        rc=pvm_pkint(&ix2,1,1);        rc=pvm_pkint(&ix3,1,1);	rc=pvm_pkint(&isx,1,1);	rc=pvm_pkint(&il,1,1);	rc=pvm_pkint(&ir,1,1);        rc=pvm_pkfloat(&dx,1,1);        rc=pvm_pkfloat(&dz,1,1);        rc=pvm_pkfloat(&dw,1,1);	rc=pvm_pkfloat(&dt,1,1);	msgtype=PARA_MSGTYPE;	task=NTASKS;	rc=pvm_mcast(tids,task,msgtype);		/* send all the frequency to slaves*/	count=NTASKS*5; /*count is the number of frequency components in a shot			gather*/         	nw=truenw;        	nw1=nw/(count);	if(nw1==0)nw1=1;	total=count=ceil(nw*1.0/nw1);	/* if it is the first shot gather, send equal data to all the slaves, then for	the following shot gathers, only send data when slave requests*/	if(nxshot==tshot){	for(i=0;i<NTASKS;i++){ 	float *tmpp;	float fw1;	int nww,byte,nwww;			        pvm_initsend(PvmDataDefault);	nww=nf1+i*nw1;fw1=fw+nww*dw;	nwww=nw1;        byte=UnDone;        rc=pvm_pkint(&byte,1,1);        rc=pvm_pkfloat(&fw1,1,1);        rc=pvm_pkint(&nwww,1,1);   	rc=pvm_pkfloat((float *)cq[nww],nx*nwww*2,1);        rc=pvm_pkfloat((float *)cq1[nww],nx*nwww*2,1);	msgtype=DATA_MSGTYPE;	pvm_send(tids[i],msgtype);	}	count-=NTASKS;	}	while(count){	int tid0,bufid;	float *tmpp;	float fw1;	int nww,byte,nwww;  	int i;  	i=total-count;        	msgtype=COM_MSGTYPE;	bufid=pvm_recv(-1,msgtype);	rc=pvm_upkint(&tid0,1,1);	pvm_freebuf(bufid);                pvm_initsend(PvmDataDefault);        nww=nf1+i*nw1;fw1=fw+nww*dw;        if(i==total-1)nwww=nw-nw1*i;        else nwww=nw1;	byte=UnDone;        rc=pvm_pkint(&byte,1,1);        rc=pvm_pkfloat(&fw1,1,1);        rc=pvm_pkint(&nwww,1,1);        rc=pvm_pkfloat((float *)cq[nww],nx*nwww*2,1);        rc=pvm_pkfloat((float *)cq1[nww],nx*nwww*2,1);        msgtype=DATA_MSGTYPE;        pvm_send(tid0,msgtype);        count--;	}	ix=Done;                pvm_initsend(PvmDataDefault);        rc=pvm_pkint(&ix,1,1);        msgtype=DATA_MSGTYPE;        pvm_mcast(tids,task,msgtype);	free2complex(cq);	free2complex(cq1);	time(&t2);	warn("\n %d shot been finished in %f seconds, Ntask=%d",nxshot,difftime(t2,t1),NTASKS);	nxshot--;                       	if(nxshot)goto loop;		/*when all the shot gathers done, send signal to all slaves to request the								partial imaging*/	ix=FinalDone;        pvm_initsend(PvmDataDefault);        rc=pvm_pkint(&ix,1,1);        msgtype=PARA_MSGTYPE;        pvm_mcast(tids,task,msgtype);        	/*allocate space for the final image*/        cresult = alloc2float(nz,nxo);	for(ix=0;ix<nxo;ix++)        for(iz=0;iz<nz;iz++)        { cresult[ix][iz]=0.0;	}	result_tmp= alloc2float(nz,nxo);		/*receive partial image from all the slaves*/	msgtype=RESULT_MSGTYPE;	i=0;	while(i<NTASKS){	int bufid;	bufid=pvm_recv(-1,msgtype);	rc=pvm_upkfloat(result_tmp[0],nxo*nz,1);	pvm_freebuf(bufid);	for(ix=0;ix<nxo;ix++)	for(iz=0;iz<nz;iz++)	{	cresult[ix][iz]+=result_tmp[ix][iz];		}	i=i+1;	warn("\n i=%d been received",i);	}	/*send signal to all slaves to kill themselves*/	pvm_initsend(PvmDataDefault);	pvm_mcast(tids,task,COM_MSGTYPE);	/*output the final image*/        for(ix=0; ix<nxo; ix++){                tr.ns = nz ;                tr.dt = dz*1000000.0 ;		tr.d2 = dx;		tr.offset = 0;		tr.cdp = tr.tracl = ix;                memcpy( (void *) tr.data, (const void *) cresult[ix],nz*FSIZE);                puttr(&tr);        }        pvm_exit();                    return EXIT_SUCCESS;                                }                                                                float * ricker(float Freq,float dt,int *Npoint)/*The function to make a Ricker wavelet.input:Freq --> the peak frequency for the Ricker wavelet;dt --> time sampling interval;output: Npoint --> length of the wavelet in points;a pointer containing the wavelet itself;*/{	int i,j,k;/* they are the dummy counter*/	float Alobe,Bpar,Coef,t,u,u2,*Amp;	int Np1,N;  	if(Freq==0.0)Freq=30.0;	if(dt==0.0)dt=0.004;	Bpar=sqrt(6.0)/(PI*Freq);	N=ceil(1.35*Bpar/dt);	Np1=N;	*Npoint=2*N+1;                	Amp=alloc1float(*Npoint);	Amp[Np1]=1.0;	for(i=1;i<=N;i++){		t=dt*(float)i;		u=2.0*sqrt(6.0)*t/Bpar;		Amp[Np1+i]=Amp[Np1-i]=0.5*(2.0-u*u)*exp(-u*u/4.0);	}	return Amp; }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -