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

📄 create_t.c

📁 seed格式数据解压程序,地震分析人员必备
💻 C
📖 第 1 页 / 共 2 页
字号:
		top = top + 8;		sprintf( top,"%s", input_time_to_asc(timespan_start));		top = top + 23;		sprintf( top,"%s", input_time_to_asc(timespan_end));		top = top + 23;		length = (int)(top - bottom);		add_event_blks(start, end, &bottom, &top, &length); /* add in event blockettes */#ifdef MALLOC_DEBUG		if( !malloc_verify() ) fprintf( D_OUT,"[create_T] verify 70 failed\n" );#endif/* * figure out how many logical records this time spans will occupy = lr_count * this loop exactly mimics the blockette forming one below. Index blockettes * are made one per station/loc/channel change. Note: this routine actually * only makes the concatenated blockettes here, make_lrec actually splits * them into logical records. size_logrec knows all make_lrec's secrets, * so the counting for both preparation and movement is the same. * * SEED v2.1 note: 074's are individual for each datapiece, not glued * together as 073's are. This results in a *much* larger blockette * than previously. *//* * how many data_pieces will fit, per maximum size blockette */		max_datapieces = (9999-fixed) / peritem;		padded_size = (int)(top - bottom);	/* fixed size of 070 */		length = padded_size;		/* size for actual mvment *//*		add_event_lrecs(start, end, &padded_size); */ /* add in event info */		p = tp->start;			/* 1st lvol node in tspan */		ntotal = tp->count;		/* total number of nodes */		while( ntotal > 0 )		{			pdp = p;			ndp = 0;		/* count datapieces */			if( pdp == NULL )			{				err=error_handler(FATAL,"[create_T] ran out of dp's");			}			if( blockette_type == 73 )/* glue datapieces together */			{				while( pdp != NULL && ntotal > 0 &&					strncmp((char *)&p->scan, 						(char *)&pdp->scan, 5+2+3 ) == 0 )				{					ndp++;	/* count StationLocChannel same */					ntotal--;					pdp = pdp->next;				}			}			else if( blockette_type == 74 )			{				ndp++;				ntotal--;				pdp = pdp->next;			}			if( Debug >= D_MAX ){			  if (pdp != NULL) {			    fprintf( D_OUT,"create_T: ntotal=%d ndp=%d p=%.2s-%.5s-%.2s-%.3s pdp=%.2s-%.5s-%.2s-%.3s \n",				     ntotal, ndp, &p->scan.network, &p->scan.station, &p->scan.location, &p->scan.channel,				     &pdp->scan.network, &pdp->scan.station, &pdp->scan.location, &pdp->scan.channel);			  }			  else {			    fprintf( D_OUT,"create_T: ntotal=%d ndp=%d p=%.2s-%.5s-%.2s-%.3s pdp=NULL \n",				     ntotal, ndp, &p->scan.network, &p->scan.station, &p->scan.location, &p->scan.channel);			  }/* 				fprintf( D_OUT,"create_T: ntotal=%d ndp=%d %.10s %.10s\n", *//* 				ntotal, ndp, &p->scan, &pdp->scan ); */			}			while( ndp > 0 )			{				n = min( max_datapieces, ndp );		/* do it in pieces */				ndp -= n;				lr_count =					size_logrec( fixed+(peritem*n), Lrecl, &padded_size );			}			p = pdp;						/* next chunk */		}/* * make contiguous blockette. length is the size of the header so far. */		where_in_logrec = 1;		p = tp->start;		/* 1st lvol node in tspan */		ntotal = tp->count;	/* total number of nodes */		while( ntotal > 0 )		{			pdp = p;			ndp = 0;	/* count datapieces */			if( pdp == NULL )			{				err=error_handler(FATAL,"[create_T] ran out of dp's");			}			if( blockette_type == 73 )/* glue datapieces together */			{				while( pdp != NULL && ntotal > 0 &&					strncmp((char *)&p->scan, 						(char *)&pdp->scan, 5+2+3 ) == 0 )				{					ndp++;					/* count StationLocChannel same */					ntotal--;					pdp = pdp->next;				}			}			else if( blockette_type == 74 )			{				ndp++;				ntotal--;				pdp = pdp->next;			}			if( Debug >= D_MAX )			  if (pdp != NULL) {			    fprintf( D_OUT,"create_T: ntotal=%d ndp=%d p=%.2s-%.5s-%.2s-%.3s pdp=%.2s-%.5s-%.2s-%.3s \n",				     ntotal, ndp, &p->scan.network, &p->scan.station, &p->scan.location, &p->scan.channel,				     &pdp->scan.network, &pdp->scan.station, &pdp->scan.location, &pdp->scan.channel);			  }			  else {			    fprintf( D_OUT,"create_T: ntotal=%d ndp=%d p=%.2s-%.5s-%.2s-%.3s pdp=NULL \n",				     ntotal, ndp, &p->scan.network, &p->scan.station, &p->scan.location, &p->scan.channel);			  }/* 				fprintf( D_OUT,"create_T: ntotal=%d ndp=%d %.10s %.10s\n", *//* 				ntotal, ndp, &p->scan, &pdp->scan ); */			while( ndp > 0 )			{				n = min( max_datapieces, ndp );	/* do it in pieces */				ndp -= n;				if( blockette_type == 73 )				{					(void)make_room( length, 11, &bottom, &top );					sprintf( top,"073%.4d%.4d", fixed+(peritem*n), n+1 );					top = top + 11;				}				else if( blockette_type == 74)				{if (strncmp(p->scan.channel, "LOG", 3) == 0)        printf("");					(void)make_room( length, 7, &bottom, &top );					sprintf( top,"074%.4d", fixed+(peritem*n) );					top = top + 7;				}				length = (int) (top-bottom);	while( n-- )	/* for each datapiece */	{		nrec = (p->end_offset - p->start_offset) / Lrecl;		if (((p->end_offset - p->start_offset) % Lrecl) != 0)		{			nrec++;			/* compute where in the logical record 			 	 * this record ends		 	 */			where_in_logrec =				(p->end_offset - p->start_offset) % Lrecl/p->lrecl;		}		else			where_in_logrec = 4;				if(blockette_type == 73)											{						(void)make_room( length, peritem, &bottom, &top );						sprintf( top, "%.5s%.2s%.3s%s%.6d01",						p->scan.station, p->scan.location, p->scan.channel,						input_time_to_asc( p->scan.time ), lr_data+lr_count );						top = top + peritem;						lr_data = lr_data + nrec;						length = (int) (top-bottom);						p = p->next;					}		else 		if( blockette_type == 74 )		{/* * for now, do *no* repeat accelerators */			char fmt[200];if (strncmp(p->scan.channel, "LOG", 3) == 0)	printf("");					strcpy( endtime, input_time_to_asc( p->endtime ) );			nacc_ptrs = 0;			(void)make_room( length, peritem, &bottom, &top );			if (SEED_Version >= 23)				strcpy(fmt, "%-5.5s%-2.2s%-3.3s%s%.6d%.2d%s%.6d%.2d%.3d%-2.2s");			else				strcpy(fmt, "%.5s%.2s%.3s%s%.6d%01%s%.6d%.2d%.3d");			sprintf(top, fmt,				p->scan.station, 				p->scan.location, 				p->scan.channel,				input_time_to_asc(p->scan.time), 				lr_data+lr_tspan,				1,				endtime, 				lr_data+lr_tspan+nrec-1, 				where_in_logrec,				nacc_ptrs,				p->scan.network);			top = top + peritem;			lr_data = lr_data + nrec;			length = (int) (top-bottom);			p = p->next;		}	}/* * all data pieces have been recorded, build the trailer (if any). */				if( blockette_type == 73 )				{					(void)make_room( length, 19, &bottom, &top );					sprintf( top, "          ~%.6d01", lr_data+lr_count );					top = top + 11+6+2;					length = (int) (top-bottom);				}			}									/* while ndp > 0 */		}										/* while ntotal > 0 */		err = make_lrec( bottom, 'T', length, &lr_actual );		if( err )			if( err=error_handler( err,"[create_T] make_lrec failed") )				return( err );		if( lr_actual != lr_count )			err=error_handler( MESSAGE,"[create_T] bad timespan size" );		*t_count = *t_count + lr_actual;	/* number of tspan log recs */		if( blockette_type == 73 )			lr_data = lr_data + lr_actual;	/* number of total "written" */		free( bottom );#ifdef MALLOC_DEBUG	if( !malloc_verify() ) fprintf( D_OUT,"[create_T] verify lrec failed\n" );#endif/* * a philosophical problem here: let's say we have a volume span * of 30 days, and a time span of 1 day. Furthermore, our data just * happens to be sparse, only 3 days of the month. Do we put only * 3 tspans on the output, or 30 tspans, only 3 of which have data? * * The information we have is the Tspan list, which has nodes * for tspans which *have data* only, the volume start time, and the * tspan time deltas. * * This implementor chooses the former, but I think some * others might disagree. Thus, we loop here to find the next * timespan interval which has data in it. We find the first * timespan which ends after the start of the next data chunk. */		tp = tp->next;						/* next tspan with data */		if( tp != NULL && tp->count > 0 )		{			xx = tp->start;					/* there must  */			yy = xx->scan;					/* be a better */			test = yy.time;					/* way for this! */			do			{				start = end;				/* next timespan (may be empty) */				end = add_inputtime( end, tspan_break );				if( Debug >= D_MAX )				{					print_time( "create_T: start = ", &start );					print_time( "create_T:   end = ", &end );					print_time( "create_T:  test = ", &test );				}			}			while( cmp_longtime( end, test ) <= 0 );			if( cmp_longtime( start, test ) > 0 )			{				err=error_handler( FATAL,"Create_T holy tspan start>data" );			}		}			}	if( *t_count != lr_tspan )		err=error_handler( MESSAGE,"[create_T] sum of actual != computed" );	if( Debug >= D_MIN ) fprintf( D_OUT,"[create_T] end\n" );#ifdef MALLOC_DEBUG	if( !malloc_verify() ) fprintf( D_OUT,"[create_T] verify exit failed\n" );#endif	return( err );}

⌨️ 快捷键说明

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