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

📄 init_once.c

📁 seed格式数据解压程序,地震分析人员必备
💻 C
字号:
/*===========================================================================*//* DMC interim out |        init_once.c                    | Main            *//*===========================================================================*//*	Name:		init_once.c	Purpose:	initialize everything which need be done once per program run	Usage:		err = init_once( out_dev, request_name, volume_break,				tspan_break, ofile, ifile, start, next_volume, next_tspan,				count )	Input:		char *out_dev		name of output file	Output:			Externals:	Header_path	Warnings:		Errors:			Fatals:	Called by:		Calls to:		Algorithm:		Notes:			Problems:		References:		Language:		Author:		03/??/89	Mark Wiederspahn	Revisions:	mm/dd/yy  pgmr name  change			06/22/89	mw fix improper timespan start			19aug89		mw add multiple header directories code					see also main.c for explaination.*/#include "output.h"extern int counter_x;struct input_time find_first_req();int init_once( out_dev, request_name, volume_break, tspan_break,	ofile, ifile, start, next_volume, next_tspan, count )char		*out_dev;			/* name of output file */char		*request_name;			/* name of input file */FILE		**ofile;			/* file ptr for output */FILE		**ifile;			/* file ptr for input */struct	input_time	volume_break;		/* time size of a volume */struct	input_time	*tspan_break;		/* time size of a tspan */struct	input_time	*start;			/* time of start of volume */struct	input_time	*next_volume;		/* time of end of 1st volume */struct	input_time	*next_tspan;		/* time of end of 1st tspan */int			*count;			/* how many requests? */{	struct	io_buf	buf;			/* for logrec open */	int			err;		/* return status */	struct	DMC_request	first;		/* first request */	char		msg[MSGLENGTH+1];	/* debugging notices */	int		l;	if( Debug >= D_MIN ) fprintf( D_OUT,"[init_once] start\n" );	init_logrec();				/* init data structures */	if( (*ofile = fopen( out_dev,"a+" )) == NULL )	{		if( (err=error_handler( FATAL,"[init_once] output file open" )) )			return( err );	}	setbuf( *ofile, NULL );			/* do not buffer output file */	buf = open_logrec( *ofile, Lrecl, Precl, &err );	if( err )		return( error_handler( FATAL,"[init_once] open_logrec" ) );	if( Debug >= D_SOME )	{		sprintf( msg,"[init_once] outputfile %s open\n", out_dev );		fprintf( D_OUT, msg );	}	if( open_DMC_request(request_name, ifile, count) < 0 )	{		if( (err=error_handler( FATAL,"[init_once] request file open" )) )			return( err );	}	if( Debug >= D_SOME )	{		sprintf( msg,"[init_once] request file %s has %d requests\n",			request_name, *count );		fprintf( D_OUT, msg );	}	if(get_DMC_request(*ifile, &first) < 0 )	{		if( (err=error_handler( FATAL,"[init_once] get_DMC_request no data" )) )			return( err );	}	rewind( *ifile );/* * determine the headers directory for the first request - it might not * be the same as the default header path. */	l = strlen( Header_path );	if( strlen( first.entry.superfile ) != 0 )	{			strncpy( Header_path+l-6, first.entry.superfile, 6 );	}	if( Debug >= D_MIN )	{			 fprintf( D_OUT, "[init_once] HDR <%.6s> %s\n",				first.entry.superfile, Header_path );	}	/* find the earliest time  - h file is unsorted by time */		*start = find_first_req(*ifile, count);	counter_x = *count;	rewind(*ifile);/* * get the first time in the request file, and round down to the lower * chunk of the smallest non-zero element in "volume_break". For example, * if volume break is "0000,002,00:00:00.0000" (translated to internal) * then given a first time of "1988,265,00:01:00.0000" we should set the * first "next_volume" to "1988,267,00:00:00.0000". */	if( Debug >= D_SOME )	{		sprintf( msg,"[init_once] first time is %d %d %d %d %d\n",			start->year, start->day, start->hour,			start->minute, start->second );		fprintf( D_OUT, msg );	}	if( volume_break.fracsec == 0 )	{		start->fracsec = 0;		if( volume_break.second == 0 )		{			start->second = 0;			if( volume_break.minute == 0 )			{				start->minute = 0;				if( volume_break.hour == 0 )				{					start->hour = 0;					if( volume_break.day == 0 )					{						start->day = 0;					}				}			}		}	}	*next_volume = add_inputtime( *start, volume_break );	if( cmp_longtime( *start,*next_volume ) == 0 )			next_volume->year = 9999;				/* one volume */	if( Debug > D_SOME )	{		sprintf( msg,"[init_once] first vol_break is %d %d %d %d %d\n",			next_volume->year, next_volume->day, next_volume->hour,			next_volume->minute, next_volume->second );		fprintf( D_OUT, msg );	}	*next_tspan = add_inputtime( *start, *tspan_break );	if( cmp_longtime( *start,*next_tspan ) == 0 )	{			next_tspan->year = 9999;				/* one tspan */			tspan_break->year = 9999;	}	if( Debug > D_SOME )	{		sprintf( msg,"[init_once] first tspan_break is %d %d %d %d %d\n",			next_tspan->year, next_tspan->day, next_tspan->hour,			next_volume->minute, next_tspan->second );		fprintf( D_OUT, msg );	}	if( Debug > D_MIN ) fprintf( D_OUT,"[init_once] end\n" );}/* ---------------------------------------------------------------------- */struct input_time find_first_req(fptr, count_reqs)FILE *fptr;int *count_reqs;{	struct input_time req_time;	struct input_time time_tmp;	int n;	char buf[DMC_request_reclen + 1];	struct DMC_request eptr;	int status;	req_time.year = 9999;	req_time.day = 366;	*count_reqs = 0;	while ((status = get_DMC_request(fptr, &eptr)) != -1)	{			time_tmp = asc_to_input_time(eptr.reqstart);			if (cmp_time(req_time, time_tmp) > 0)				req_time = time_tmp;		*count_reqs += 1;	}		return req_time;	}/* ---------------------------------------------------------------------- */

⌨️ 快捷键说明

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