#include #define LDPAR 250 FILE *fp1, *fp2; main() { /* INT */ int ss, niter, npar, jter, iter, nc; char hfile[40], simfile[40], s[]=" "; /*DOUBLE */ double thetai[LDPAR],gc[LDPAR], pri, wtlog, pdat, priorc; ss=scanf("%s", &hfile); if (ss!=1) {printf("error reading file name\n"); return -1;} fp1=fopen(hfile,"r"); if (fp1==NULL) {printf("failure to open file %s for input\n", hfile); return -1;} ss=scanf("%s", &hfile); if (ss!=1) {printf("error reading file name\n"); return -1;} fp2=fopen(hfile,"w"); if (fp2==NULL) {printf("failure to open file %s for output\n", hfile); return -1;} ss=fscanf(fp1,"%d %d", &niter, &npar); if (ss != 2) {printf("read error, first record of \ninput simulation "); printf("file %s", hfile); return -1;} if ((niter <= 0) || (npar<=0)) { printf("illegal first record of input simulation"); printf("file %s %16d%16d", hfile, niter, npar); return -1; } if (npar > LDPAR) { printf("input simulation file %s \n ", hfile); printf("%16d parameters exceed limit of %16d \n", npar, LDPAR); return -1; } for (iter=1; iter <= niter; iter++) { if (readrec(npar,&jter,&wtlog,&pri,&pdat,&thetai)) return 1; client(npar,thetai,pri,&nc,gc,&priorc); if (iter == 1) { if ((nc<1) || (nc > LDPAR)) { printf("Client's function of interest %5d",nc); printf(" not in range 1 to %5d",LDPAR); } fprintf(fp2, "%16d%16d\n", niter, nc); } wtlog=wtlog+priorc-pri; pri=priorc; writerec(npar,iter,wtlog,pri,pdat,gc); } fclose(fp1); fclose(fp2); return 1; } //main