#include "stdio.h" #include "string.h" #include "astring.h" #include "stdlib.h" #include "flatfile.h" #include "misc.h" void main(int argc, char *argv[]) { FILE *fpout; char line[80], stat[4], sdate[24], edate[24], qdate[24], uname[100]; char input_v[20], datafile[80], temp[100], *filelist, master[100]; char snhrqd[10]; long sloc; float mlat, cutlat; int found, done, strl, pos; cutlat = 60.0; if (argc >= 2) { strcpy(sdate,argv[1]); } else { printf("Enter start date : "); gets(sdate); } if (argc >= 3) { strcpy(edate,argv[2]); } else { printf("Enter end date : "); gets(edate); } strl = strlen(edate); if (strl < 10) { strcat(edate," 23:59:59.000"); } if (argc >= 4) { strcpy(qdate,argv[3]); } else { printf("Enter start time of quiet day (ex 02-nov-93 10:00) : "); gets(qdate); } if (argc >=5) { strcpy(snhrqd,argv[4]); } else { printf("Enter number of quiet hours to average over : "); gets(snhrqd); } fpout = fopen("mean_input","w"); fprintf(fpout,"%s\n",sdate); fprintf(fpout,"%s\n",edate); fprintf(fpout,"m\n"); fprintf(fpout,"%s\n",qdate); fprintf(fpout,"%s\n",snhrqd); fclose(fpout); fpout = fopen("curve_input","w"); fprintf(fpout,"%s\n",sdate); fprintf(fpout,"%s\n",edate); fprintf(fpout,"c\n"); fprintf(fpout,"%s\n",qdate); fprintf(fpout,"%s\n",snhrqd); fclose(fpout); fpout = fopen("process","w"); fprintf(fpout,"#!/bin/sh\n"); fprintf(fpout,"\n"); filelist = spawn("ls *.hed"); done = 0; while (!done) { pos = strpos(filelist,"\n"); if (pos > 0) { strcpy(datafile,strmid(filelist,0,strpos(filelist,"\n"))); filelist = filelist + strpos(filelist,"\n")+1; strl = strlen(filelist); if (strl < 4) done = 1; } else { done = 1; } printf("file ---%s---\n",datafile); strcpy(stat,mkupper(strmid(datafile,0,3))); strcpy(input_v, "mean_input"); strcpy(temp,strmid(datafile,0,strpos(datafile,".hed"))); printf("%s\n",temp); fprintf(fpout,"echo ---- remca %s ------\n",mklower(stat)); fprintf(fpout,"mkremca_hr %s %s.remca < %s\n", temp,strmid(temp,0,7),input_v); fprintf(fpout,"echo ---- done with %s ------\n",mklower(stat)); } close(fpout); system("chmod a+x process"); /* system("process"); system("/bin/rm mean_input curve_input process");*/ }