#include #include #include #include #include int main() { int i,l,s,m,yy,mm,r; float v,wv; float *tmpa,*tmpb; char x1_fn[99],x2_fn[80],out_fn[80]; FILE *x1_ptr,*x2_ptr,*out_ptr; tmpa = (float *) malloc(3001*sizeof(float)); tmpb = (float *) malloc(3001*sizeof(float)); sprintf(x1_fn,"../../factor/factor4resp50reg_Tans93_cs2.txt"); if ((x1_ptr=fopen(x1_fn, "r")) == NULL) { printf("\n Unable to open file1, exitting program ...\n\n"); exit(0); } for (i=0;i<3000;i++) fscanf(x1_ptr,"%d\t%d\t%d\t%f\n",&yy,&mm,&r,&tmpb[i]); fclose(x1_ptr); sprintf(x2_fn,"response_73stn.bin"); if ((x2_ptr=fopen(x2_fn, "rb")) == NULL) { printf("\n Unable to open file2, exitting program ...\n\n"); exit(0); } sprintf(out_fn,"../response_Tans03_cs2.bin"); if ((out_ptr=fopen(out_fn, "wb")) == NULL) { printf("\n Unable to open outp file, exitting program ...\n\n"); exit(0); } printf("processing ... \n"); for (s=1;s<=73;s++) { // printf("processing %d \n",s); for (m=1;m<=42;m++) { for (l=1;l<=3000;l++) { fread(&v,sizeof(float),1,x2_ptr); wv=v*(tmpb[l-1]); fwrite(&wv,sizeof(float),1,out_ptr); } fread(&v,sizeof(float),1,x2_ptr); wv=0.3; fwrite(&wv,sizeof(float),1,out_ptr); } }// end of s fclose(out_ptr); fclose(x2_ptr); return 1; }