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

📄 suread.c

📁 su 的源代码库
💻 C
📖 第 1 页 / 共 2 页
字号:
				"Too many traces for ensemble %ld. Value =%ld. Current count = %d.\n",				parms->iens,parms->ens_value,parms->tr_in_ens);			parms->ens_value=ens;			parms->tr_in_ens=1;			parms->iens++;			ihead[STDHDR(iend_ens)]=LASTTR;			}		else {/***************************************************************************			Next trace part of same ensemble.***************************************************************************/			parms->tr_in_ens++;			ihead[STDHDR(iend_ens)]=NLAST;			}		ihead[STDHDR(ieoj)]=NLAST;	} else {/***************************************************************************		Hit end of file.***************************************************************************/		if(parms->tr_in_ens>globalRuntime->maxdtr) 			fprintf(stderr,			"Too many traces for ensemble %ld.  Current count = %d\n",			parms->ens_value,parms->tr_in_ens);		parms->tr_in_ens=1;		ihead[STDHDR(iend_ens)]=LASTTR;		ihead[STDHDR(ieoj)]=LASTTR;		if(parms->ichoose==0) {			j=pclose(parms->fp);		}else{			j=fclose(parms->fp);		}		exPipeMode();		return;	}	if(parms->tr_in_ens>globalRuntime->maxdtr) goto readnext;	exFlushMode();			return;}FILE *suread_open(int ichoose,char *cmnd,char *datafile,char *cmndfile)/**************************************************************************************return a FILE pointer to input stream whether from Unix command, file, or command fileint ichoose	0	read input pipe		1	read input data file		2	read from input command file (output of suput)char *cmnd	command setting up input pipechar *datafile	input data filechar *cmndfile	name of command file piping output on file descriptor		returned for argument 1 (usually from suput)************************************************************************/{	FILE *fp;	char prog[50];	int pfd[2];	char fdstr[10];	int j,k,l;	if(ichoose==0) {		fprintf(stderr,"\nsuread input pipe: \n%s\n",cmnd);		fp=popen(cmnd,"r");		if(fp==NULL) exErrFatal("Couldn't open input");		return (fp);		}	if(ichoose==1) {		fprintf(stderr,"suread input data file: %s\n",datafile);		fp=fopen(datafile,"r");		if(fp==NULL) exErrFatal("Couldn't open input");		return (fp);		}	fprintf(stderr,"suread input command file: %s\n",cmndfile);	j=0;	k=-1;	while(cmndfile[j]!='\0'){ 		if(cmndfile[j]=='/') k=j; 		j++;		}	k++;	j=0;	do{		prog[j]=cmndfile[j+k];		j++;		}while(cmndfile[j+k]!='\0'); 	if(pipe(pfd)==-1)		{		fprintf(stderr,"Could not open pipe in suread_open\n");		return(NULL);		}	switch(fork()){	case -1: 		fprintf(stderr,"suread_open: Fork failed to create child.\n");		return(NULL);	case 0:		if(close(pfd[0])==-1)			fprintf(stderr,"suread_open: Non-fatal close error in child.\n");/*		fprintf(stderr,"suread_open: File descriptor passed from parent = %d\n",pfd[1]); */		sprintf(fdstr,"%d",pfd[1]);		fprintf(stderr,"suread_open: prog = %s cmndfile = %s \n",prog,cmndfile);		execl(cmndfile,prog,fdstr,NULL);		fprintf(stderr,"suread_open: Failed to execute command file %s \n",prog);		return(NULL);	}	if(close(pfd[1])==-1) 		fprintf(stderr,"suread_open: Non-fatal close error in parent.\n");/*	fprintf(stderr,"suread_open: Parent reads from file descriptor %d\n",pfd[0]); */	fp=fdopen(pfd[0],"r");	return(fp);}void suread_inith(int *ind)/************************************************************************initialize ProMAX trace header values and return indecies for later accessint *ind		returns as array of ProMAX trace header indecies*************************************************************************/{   int j,k;   defStdHdr();   j=0;   while( (sumap[j].suoffs>-1) && (sumap[j].suoffs<240) ) {      if(sumap[j].pkey[0]=='S' && sumap[j].pkey[1]=='U'){        ind[j]=hdrAdd(sumap[j].pkey, sumap[j].desc, 1, (int)sumap[j].ptype);      }else{        hdrAddStd(sumap[j].pkey);        ind[j]=hdrIndex(sumap[j].pkey);      }      j++;	   }   hdrAddStd("TFULL_E");   hdrAddStd("TLIVE_E");}void suread_puth(cwpsegy *tr,int *ihead,float *rhead,int *ind)/************************************************************************move SU header values into ProMAX trace header values cwpsegy *tr		input SU trace header structureint *ihead	output ProMAX integer trace headersfloat *rhead	output ProMAX real trace headersint *ind		input ProMAX  trace header indecies*************************************************************************/{   char *tp = (char *)tr;   int j;   long iv;   float rv;   initStdHdr(ihead,rhead);   j=0;   while( (sumap[j].suoffs>-1) && (sumap[j].suoffs<240) ) {     if(sumap[j].sutype==1) {	iv = *( (long *) (tp + sumap[j].suoffs) );	if(sumap[j].ptype==1)		ihead[ind[j]]=iv;	else		rhead[ind[j]]=iv;	}     else if(sumap[j].sutype==0) {	iv = *( (short *) (tp + sumap[j].suoffs) );	if(sumap[j].ptype==1)		ihead[ind[j]]=iv;	else		rhead[ind[j]]=iv;	}     else if(sumap[j].sutype==3) {	iv = *( (unsigned short *) (tp + sumap[j].suoffs) );	if(sumap[j].ptype==1)		ihead[ind[j]]=iv;	else		rhead[ind[j]]=iv;	}     else if(sumap[j].sutype==2) {	rv = *( (float *) (tp + sumap[j].suoffs) );	if(sumap[j].ptype==1)		ihead[ind[j]]=rv;	else		rhead[ind[j]]=rv;	}     j++;     }    /*  take care of elevation and coordinate scalers */     if(tr->scalel<0) {	rhead[STDHDR(irec_elev)]/=ABS(tr->scalel);	rhead[STDHDR(isou_elev)]/=ABS(tr->scalel);     }     if(tr->scalel>1) {	rhead[STDHDR(irec_elev)]*=tr->scalel;	rhead[STDHDR(isou_elev)]*=tr->scalel;     }     if(tr->scalco<0) {	rhead[STDHDR(irec_x)]/=ABS(tr->scalco);	rhead[STDHDR(irec_y)]/=ABS(tr->scalco);	rhead[STDHDR(isou_x)]/=ABS(tr->scalco);	rhead[STDHDR(isou_y)]/=ABS(tr->scalco);     }     if(tr->scalco>1) {	rhead[STDHDR(irec_x)]*=tr->scalco;	rhead[STDHDR(irec_y)]*=tr->scalco;	rhead[STDHDR(isou_x)]*=tr->scalco;	rhead[STDHDR(isou_y)]*=tr->scalco;     }     rhead[STDHDR(iaoffset)]=sqrt( 		( rhead[STDHDR(irec_x)]- rhead[STDHDR(isou_x)] )*					( rhead[STDHDR(irec_x)]- rhead[STDHDR(isou_x)] ) +					( rhead[STDHDR(irec_y)]- rhead[STDHDR(isou_y)] )*					( rhead[STDHDR(irec_y)]- rhead[STDHDR(isou_y)] ) );     return;}char *suread_stringPrep(char *s)/*************************************************************************************returns properly prepared version of user-entered string for decoding a file name(allows user to get away with hitting a return in field for file name or an extra space)char *s		input string**************************************************************************************/{		int n,j,c;	char *ss;/***********************************	left justify string***********************************/	n=strlen(s);	for(j=0;j<n;j++) {		c=s[j];		if(!isspace(c)) break;		}	n=n-j;	ss=(char *)malloc( (n+1)*sizeof(char));	for(c=0;c<n;c++) ss[c]=s[c+j];	ss[n]='\0';			/****************************************************	convert any remaining white space to nulls****************************************************/	for(j=0;j<n;j++) {		c=ss[j];		if(isspace(c)) ss[j]='\0';	}	return (ss);}

⌨️ 快捷键说明

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