//=================================================== file = busyhour.c ===== //= Program to extract busy hours from a series X of size N = //=========================================================================== //= Notes: = //= 1) Input from input file "in.dat" to stdin (see example below) = //= * Comments are bounded by "&" characters at the beginning and = //= end of the comment block = //= 2) Output is to stdout = //= 3) Specify in #define the intial offset (in number of values), the = //= number of values in busy hour, and the number of values between = //= each busy hour = //=-------------------------------------------------------------------------= //= Example "in.dat" file (OFFSET is 2, BUSY is 3, and INTERVAL is 4): = //= = //= & Sample series of data which can be integers or reals. & = //= & There are 11 values in this file. & = //= 50 = //= 42 = //= 48 = //= 61 = //= 60 = //= 53 = //= 39 = //= 54 = //= 42 = //= 59 = //= 53 = //= 14 = //= 44 = //=-------------------------------------------------------------------------= //= Example output (for above "in.dat"): = //= = //= c:\work\busyhour < in.dat = //= ---------------------------------------------- busyhour.c ----- = //= 48 = //= 61 = //= 60 = //= 59 = //= 53 = //= 14 = //= --------------------------------------------------------------- = //=-------------------------------------------------------------------------= //= Build: bcc32 busyhour.c = //=-------------------------------------------------------------------------= //= Execute: busyhour < in.dat = //=-------------------------------------------------------------------------= //= Author: Ken Christensen = //= University of South Florida = //= WWW: http://www.csee.usf.edu/~christen = //= Email: christen@csee.usf.edu = //=-------------------------------------------------------------------------= //= History: KJC (05/23/18) - Genesis = //=========================================================================== //----- Include files ------------------------------------------------------- #include // Needed for printf() and feof() #include // Needed for exit() and atof() #include // Needed for strcmp() //----- Defines ------------------------------------------------------------- #define MAX_SIZE 10000000 // Maximum size of time series data array #define OFFSET 2 // Offset in values to first busy hour #define BUSY 3 // Number of values in busy hour #define INTERVAL 4 // Number of values between each busy hour //----- Globals ------------------------------------------------------------- double *X; // Time series read from "in.dat" int N; // Number of values in "in.dat" //----- Function prototypes ------------------------------------------------- void load_X_array(void); // Load X array //=========================================================================== //= Main program = //=========================================================================== void main(void) { int i, j; // Loop counters // Malloc space for X X = (double *) malloc(sizeof(double) * MAX_SIZE); if (X == NULL) { printf("*** ERROR - Could not malloc() enough space \n"); exit(1); } // Load the series X printf("---------------------------------------------- busyhour.c -----\n"); load_X_array(); // Loop to extract busy hour values and output them in a series for(i=OFFSET; i= MAX_SIZE) { printf("*** ERROR - greater than %ld data values \n", MAX_SIZE); exit(1); } } // End-of-file escape end: return; }