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

📄 diff.junk

📁 seismic software,very useful
💻 JUNK
字号:
5a6,7> #include <assert.h>> #include <pthread.h>6a9,13> #ifndef WORDS_BIGENDIAN> #include "ttc_byteswap.h"> #endif> > 122a130,152> /* This structure is used to pass arguments to compress_ttc through the> pthreads call. */> typedef struct> {>   float *data;>   int *num_points;>   float ratio;>   float null_value;>   int thread_number;>   unsigned char *work_space;>   long long  work_bytes;>   unsigned char *buffer;> } compress_ttc_call_struct;> > /* This function is used to call compress_ttc from a thread.  */> void compress_ttc_pt(void *call_struct)> {>  compress_ttc_call_struct *tmp = (compress_ttc_call_struct*)call_struct;> >  compress_ttc(tmp->buffer, tmp->data, tmp->num_points, tmp->ratio, tmp->null_value, tmp->thread_number, tmp->work_space, tmp->work_bytes);> }> > /* multiple-cpu ray tracing subroutine */243a274> 	ghed gh;283,287c314,317< 	ttc_data *result;< 	long long out_bytes;< 	float compress, null=999999.;<  	int num_points[3],nxyzot;< 	float *in_data;--->   long long out_bytes;>   float compress, null=999999.;>   int num_points[3],nxyzot;>   long long work_bytes;289c319,325< 				   --->   float *in_data;> > /* These variables are associated with setting up the threads. */>   int thread_count;>   pthread_t thread_id[MAXCPUS];>   compress_ttc_call_struct call_struct[MAXCPUS];>   pthread_attr_t attr;291,293c327,329< 	/* hook up getpar to handle the parameters */< 	initargs(argc,argv);< 	requestdoc(1);---> /* hook up getpar to handle the parameters */> initargs(argc,argv);> requestdoc(1);330a367> 	assert(ncpu<=MAXCPUS);332c369<     if(!getenv("PARALLEL")) {--->         if(!getenv("PARALLEL")) {335,336c372,373< 				/* free(envs); */<     }---> 		/* free(envs); */>         }491a529,531> /* Set up pthreads */>      	pthread_attr_init(&attr);> 	pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);493a534> if(compress<=1. && compress!=0.) err(" compress=%f must be => 1. \n",compress);500c541,552< 			in_data = (float *)malloc(num_points[0]*num_points[1]*num_points[2]*sizeof(float));---> 		work_bytes = compress_ttc_bytes(num_points,1);> > 	/*> 		fprintf(stderr," compression used \n");> 		fprintf(stderr,"num_points[0] = %d\n",num_points[0]);> 		fprintf(stderr,"num_points[1] = %d\n",num_points[1]);> 		fprintf(stderr,"num_points[2] = %d\n",num_points[2]);> 		fprintf(stderr,"compress = %f\n",compress);> 		fprintf(stderr,"null = %f\n",null);> 		fprintf(stderr,"out_bytes = %lld\n",out_bytes);> 	*/> 526a579> 545c598,609< 				fwrite(&out_bytes, sizeof(long long), 1, tfp);---> #ifndef WORDS_BIGENDIAN>   				/* Swap bytes before writing. */>     				ttc_byteswap64(out_bytes);> #endif> >       				fwrite(&out_bytes, sizeof(long long), 1, tfp);> > #ifndef WORDS_BIGENDIAN>   				/* Swap bytes back after writing. */> 	  			ttc_byteswap64(out_bytes);> #endif> 772,780c836,846< 	/* allocate velocity derivative arrays for ray tracing */< 	/* memory for this vt group of arrys: 7*nzyxt*ncpu*sizeof(float) bytes */<   	vt = ealloc1float(nzyxt*ncpu);<  	vxxt = ealloc1float(nzyxt*ncpu);< 	vxyt = ealloc1float(nzyxt*ncpu);< 	vxzt = ealloc1float(nzyxt*ncpu);< 	vyyt = ealloc1float(nzyxt*ncpu);< 	vyzt = ealloc1float(nzyxt*ncpu);< 	vzzt = ealloc1float(nzyxt*ncpu);---> /* allocate velocity derivative arrays for ray tracing */> /* memory for this vt group of arrys: 7*nzyxt*ncpu*sizeof(float) bytes */> 	if(compress<=1.) { >   		vt = ealloc1float(nzyxt*ncpu);>  		vxxt = ealloc1float(nzyxt*ncpu);> 		vxyt = ealloc1float(nzyxt*ncpu);> 		vxzt = ealloc1float(nzyxt*ncpu);> 		vyyt = ealloc1float(nzyxt*ncpu);> 		vyzt = ealloc1float(nzyxt*ncpu);> 		vzzt = ealloc1float(nzyxt*ncpu);> 	}			805c871<     i2 = 2;--->     	i2 = 2;1017a1084> 	fprintf(jpfp,"compress = %f\n",compress);1018a1086,1093> 	if(compress>1) {> 		fprintf(jpfp,"num_points[0] = %d\n",num_points[0]);> 		fprintf(jpfp,"num_points[1] = %d\n",num_points[1]);> 		fprintf(jpfp,"num_points[2] = %d\n",num_points[2]);> 		fprintf(jpfp,"null = %f\n",null);> 		fprintf(jpfp,"out_bytes = %lld\n",out_bytes);> 	}> 	1025d1099< 1033a1108> 1067a1143,1155> > /* allocate velocity derivative arrays for ray tracing */> /* memory for this vt group of arrys: 7*nzyxt*ncpu*sizeof(float) bytes */> 	if(compress>1.0) {>   		vt = ealloc1float(nzyxt*ncpu);>  		vxxt = ealloc1float(nzyxt*ncpu);> 		vxyt = ealloc1float(nzyxt*ncpu);> 		vxzt = ealloc1float(nzyxt*ncpu);> 		vyyt = ealloc1float(nzyxt*ncpu);> 		vyzt = ealloc1float(nzyxt*ncpu);> 		vzzt = ealloc1float(nzyxt*ncpu);> 	}> 1073c1161<        xsp,ysp,azhnp,azhxp,fxtp,fytp,nxtp,nytp,&nzyxt,--->        	   xsp,ysp,azhnp,azhxp,fxtp,fytp,nxtp,nytp,&nzyxt,1093a1182,1191> 	/* free memory */> 	if(compress>1.0) {>   		free1float(vt);>  		free1float(vxxt);>  		free1float(vxyt);>  		free1float(vxzt);>  		free1float(vyyt);>  		free1float(vyzt);>  		free1float(vzzt);> 	}1129a1228,1242> > 		/* Set up some thread structures. */> 		in_data = (float *)emalloc(nxyzot*np*sizeof(float));> 		for(ip=0; ip<np; ip++)> 		{> 		call_struct[ip].data = in_data > 			+ num_points[0]*num_points[1]*num_points[2]*ip;> 		call_struct[ip].num_points = num_points;> 		call_struct[ip].ratio = compress;> 		call_struct[ip].null_value = null;> 		call_struct[ip].thread_number = ip;> 		call_struct[ip].buffer = (unsigned char *)emalloc(out_bytes);> 		call_struct[ip].work_bytes=work_bytes;> 		call_struct[ip].work_space=(unsigned char *)emalloc(work_bytes);> 		}1140c1253< 						nzo);---> 						nzo*sizeof(float));1143a1257> 			/* compress the travel time */1145,1147c1259< 	result = compress_ttc(in_data+ip*nxyzot,num_points,compress,null);< 				write_ttc(result, tfp);< 				free_ttc(result);---> 	pthread_create(&thread_id[ip], &attr, compress_ttc_pt, (void *)(&call_struct[ip]));1148a1261,1276> 			/* join the threads, write results to outfile */> 			for (ip=0;ip<np;ip++) {> 			pthread_join(thread_id[ip], NULL);> 			/* Write the compressed data to the output stream. */> 			fwrite(call_struct[ip].buffer,1,out_bytes,tfp);> 			}> > 		  	/* Flush the output stream. */> 		    	fflush(tfp);> >        			/* Free the compressed data structure's memory. */> 			for (ip=0;ip<np;ip++) {>  				free(call_struct[ip].buffer);> 	 			free(call_struct[ip].work_space);> 			}> 	 		free(in_data);1150c1278<       		fflush(tfp);---> 1248c1376< 	    	truncate64(tofile[iev],(off64_t)isize);---> 	    	truncate64(tofile[iev],isize);1261c1389< 	    				truncate64(tfile,(off64_t)isize);---> 	    				truncate64(tfile,isize);1268c1396,1397< 			fwrite(&ugh,1,100,tfp);---> 			usghed2ghed(&ugh, &gh);> 			fwrite(&gh,1,100,tfp);1287,1293c1416,1424<  	free1float(vt);<    	free1float(vxxt);<  	free1float(vxyt);<  	free1float(vxzt);<  	free1float(vyyt);<  	free1float(vyzt);<  	free1float(vzzt);---> 	if(compress<1.0) {>  		free1float(vt);>    		free1float(vxxt);>  		free1float(vxyt);>  		free1float(vxzt);>  		free1float(vyyt);>  		free1float(vyzt);>  		free1float(vzzt);> 	}

⌨️ 快捷键说明

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