/****************************************************************/ /* b2afout.C */ /* K.Hayashi */ /****************************************************************/ #include #include #include #include #include #include #include #include # define O_RDONLY 0000000 /* Open for reading only */ # define O_WRONLY 0000001 /* Open for writing only */ # define O_RDWR 0000002 /* Open for reading or writing */ # define O_ACCMODE 0000003 /* Mask for file access modes */ # define O_CREAT 0000400 /* Open with file c reate (uses third open arg) */ #define sec_DAY 86400 void opf(void); int handle, ifc,tst,tend; char sfn[30],sfnp[30],fno[30]; unsigned char buf[sec_DAY*6]; FILE *outpath; main(char argc, char **argv) { char input,fout[3]; char shfn[]="shplotp2",sbfn[]="sbplotp2"; unsigned char *j, ea; int i,ii,tfn,ix,iy,iz,ttsc; int sx,sy,sz; double fx,fy,fz,fmi; if(argc<2){ printf("Read binary file[xxx] of HDZ and create ascii file from start(h1) to end(h2)\n"); printf("Input: [#1file name] Start time 1 [hh] End time 2[hh]\n"); printf("data files are assumed in the \"./work\" directory\n"); exit(0); } sprintf(sfn,"%s",argv[1]); tst = atoi(argv[2]); tend = atoi(argv[3]); printf("sfn=%s star(h)=%d end(h)=%d \n", sfn, tst, tend); opf(); ttsc=(tend-tst)*3600; for (ifc=0;ifc %s ", fno); /* fmi=M_PI*argmg/180.0;a */ /* printf("%d %d %d %lf %f %d\n",ix,iy,iz,fmi,argmg,tfn);*/ /* fx= cos(fmi)*(double)ix+sin(fmi)*(double)iy; fy=-sin(fmi)*(double)ix+cos(fmi)*(double)iy; fz=(double)iz; fprintf(outpath,"%9.2f %9.2f %9.2f \x0d\n",fx,fy,fz); */ close(outpath); close(handle); printf("out file %s was closed\n",fno); } void opf() { short ch,dy,dm,dm1,dd; char ay[3],am[3],ad[3],stn[4],sfnw[30]; short mnn[13]={31,31,29,31,30,31,30,31,31,30,31,30,31}; strcpy(sfnw,"work/"); strcat(sfnw,sfn); if ((handle= open(sfnw, O_RDONLY)) == -1){ printf( "Could not find \"%s\" \n", sfn); exit(1); } printf("open %s",sfn); strcpy(sfnp,sfn); printf("\nsfn=%s>> ",sfn); strncpy(ay,sfn,2);dy=atoi(ay); mnn[2]=29-(dy%4+3)/4; strncpy(am,sfn+3,2);dm=atoi(am); strncpy(ad,sfn+5,2);dd=atoi(ad); strncpy(stn,sfn+8,4); sprintf(fno,"%02d%02d%02da%02d-%02ds.%s",dy,dm,dd,tst,tend,stn); outpath=fopen(fno,"wt"); dm1=dm+dd/mnn[dm]; dd=1+dd%mnn[dm]; dm=dm1; if(dm>=13){dy++;dm=1;dd=1;} sprintf(sfn,"%02d_%02d%02dm.%s",dy,dm,dd,stn); } A