--- imach/src/imach.c 2002/02/20 17:19:10 1.19 +++ imach/src/imach.c 2002/02/20 17:22:01 1.20 @@ -1318,7 +1318,7 @@ void prevalence(int agemin, int agemax, if ((k2>=dateprev1) && (k2<=dateprev2)) { if(agev[m][i]==0) agev[m][i]=agemax+1; if(agev[m][i]==1) agev[m][i]=agemax+2; - freq[s[m][i]][s[m+1][i]][(int)(agev[m][i]+1-1/12.)] += weight[i]; + freq[s[m][i]][s[m+1][i]][(int)(agev[m][i]+1-((int)calagedate %12)/12.)] += weight[i]; freq[s[m][i]][s[m+1][i]][(int)(agemax+3+1)] += weight[i]; } } @@ -2876,7 +2876,10 @@ fclose(fichtm); mprojmean=yp; yp1=modf((yp2*30.5),&yp); jprojmean=yp; - fprintf(ficresf,"Estimated date of observed prevalence: %.lf/%.lf/%.lf ",jprojmean,mprojmean,anprojmean); + if(jprojmean==0) jprojmean=1; + if(mprojmean==0) jprojmean=1; + + fprintf(ficresf,"# Estimated date of observed prevalence: %.lf/%.lf/%.lf ",jprojmean,mprojmean,anprojmean); if (popforecast==1) { if((ficpop=fopen(popfile,"r"))==NULL) { @@ -2908,10 +2911,10 @@ fclose(fichtm); for(j=1; j<=nlstate+ndeath;j++) fprintf(ficresf," P.%d",j); if (popforecast==1) fprintf(ficresf," [Population]"); - for (cpt=0; cpt<=1;cpt++) { + for (cpt=0; cpt<=5;cpt++) { fprintf(ficresf,"\n"); - fprintf(ficresf,"\nForecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt); - for (agedeb=(fage-(1/12.)); agedeb>=(bage-(1/12.)); agedeb--){ /* If stepm=6 months */ + fprintf(ficresf,"\n# Forecasting at date %.lf/%.lf/%.lf ",jproj1,mproj1,anproj1+cpt); + for (agedeb=(fage-((int)calagedate %12/12.)); agedeb>=(bage-((int)calagedate %12)/12.); agedeb--){ /* If stepm=6 months */ nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); nhstepm = nhstepm/hstepm; /*printf("agedeb=%.lf stepm=%d hstepm=%d nhstepm=%d \n",agedeb,stepm,hstepm,nhstepm);*/ @@ -2921,18 +2924,17 @@ fclose(fichtm); hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k); for (h=0; h<=nhstepm; h++){ - if (h==(int) (calagedate+12*cpt)) { - fprintf(ficresf,"h=%d ", h); - fprintf(ficresf,"\n %f %f ",agedeb,agedeb+h*hstepm/YEARM*stepm); + if (h==(int) (calagedate+YEARM*cpt)) { + fprintf(ficresf,"\n %.f ",agedeb+h*hstepm/YEARM*stepm); } for(j=1; j<=nlstate+ndeath;j++) { kk1=0.;kk2=0; for(i=1; i<=nlstate;i++) { if (mobilav==1) - kk1=kk1+p3mat[i][j][h]*mobaverage[(int)agedeb][i][cptcod]; + kk1=kk1+p3mat[i][j][h]*mobaverage[(int)agedeb+1][i][cptcod]; else { kk1=kk1+p3mat[i][j][h]*probs[(int)(agedeb+1)][i][cptcod]; - /* fprintf(ficresf," p3=%.3f p=%.3f ", p3mat[i][j][h],probs[(int)(agedeb)+1][i][cptcod]);*/ + /* fprintf(ficresf," p3=%.3f p=%.3f ", p3mat[i][j][h], probs[(int)(agedeb)+1][i][cptcod]);*/ } if (popforecast==1) kk2=kk1*popeffectif[(int)agedeb];