--- imach096d/src/imach.c 2002/03/01 17:56:23 1.28 +++ imach096d/src/imach.c 2002/03/06 19:02:50 1.29 @@ -1,4 +1,4 @@ -/* $Id: imach.c,v 1.28 2002/03/01 17:56:23 lievre Exp $ +/* $Id: imach.c,v 1.29 2002/03/06 19:02:50 lievre Exp $ Interpolated Markov Chain Short summary of the programme: @@ -1556,16 +1556,22 @@ void evsij(char fileres[], double ***eij for(i=1; i<=nlstate;i++) for(j=1; j<=nlstate;j++) - for (h=0, eij[i][j][(int)age]=0; h<=nhstepm; h++){ - eij[i][j][(int)age] +=p3mat[i][j][h]; + for (h=0, eij[i][j][(int)age]=0; h<=nhstepm-1; h++){ + eij[i][j][(int)age] +=(p3mat[i][j][h]+p3mat[i][j][h+1])/2.0; } hf=1; if (stepm >= YEARM) hf=stepm/YEARM; - fprintf(ficreseij,"%.0f",age ); + for(i=1; i<=nlstate;i++) for(j=1; j<=nlstate;j++){ - fprintf(ficreseij," %.4f", hf*eij[i][j][(int)age]); + if (j==i) eij[i][j][(int)age]= (eij[i][j][(int)age]-0.5*stepm/12./hf); + } + + fprintf(ficreseij,"%3.0f",age ); + for(i=1; i<=nlstate;i++) + for(j=1; j<=nlstate;j++){ + fprintf(ficreseij," %9.4f", hf*eij[i][j][(int)age]); } fprintf(ficreseij,"\n"); free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); @@ -1882,7 +1888,7 @@ fclose(ficresprob); } /******************* Printing html file ***********/ -void printinghtml(char fileres[], char title[], char datafile[], int firstpass, int lastpass, int stepm, int weightopt, char model[],int imx,int jmin, int jmax, double jmeanint,char optionfile[],char optionfilehtm[] ){ +void printinghtml(char fileres[], char title[], char datafile[], int firstpass, int lastpass, int stepm, int weightopt, char model[],int imx,int jmin, int jmax, double jmeanint,char optionfile[],char optionfilehtm[],char rfileres[] ){ int jj1, k1, i1, cpt; FILE *fichtm; /*char optionfilehtm[FILENAMELENGTH];*/ @@ -1893,7 +1899,7 @@ void printinghtml(char fileres[], char t printf("Problem with %s \n",optionfilehtm), exit(0); } - fprintf(fichtm,"
"); @@ -2424,7 +2430,7 @@ int main(int argc, char *argv[]) char optionfile[FILENAMELENGTH], datafile[FILENAMELENGTH], filerespl[FILENAMELENGTH]; char optionfilext[10], optionfilefiname[FILENAMELENGTH], optionfilehtm[FILENAMELENGTH], optionfilegnuplot[FILENAMELENGTH], plotcmd[FILENAMELENGTH]; - char fileres[FILENAMELENGTH], filerespij[FILENAMELENGTH], filereso[FILENAMELENGTH]; + char fileres[FILENAMELENGTH], filerespij[FILENAMELENGTH], filereso[FILENAMELENGTH], rfileres[FILENAMELENGTH]; char filerest[FILENAMELENGTH]; char fileregp[FILENAMELENGTH]; @@ -2456,7 +2462,7 @@ int main(int argc, char *argv[]) double dateprev1, dateprev2,jproj1,mproj1,anproj1,jproj2,mproj2,anproj2; - char version[80]="Imach version 0.7, February 2002, INED-EUROREVES "; + char version[80]="Imach version 0.71, February 2002, INED-EUROREVES "; char *alph[]={"a","a","b","c","d","e"}, str[4]; @@ -2624,12 +2630,17 @@ while((c=getc(ficpar))=='#' && c!= EOF){ printf("\n"); - /*-------- data file ----------*/ - if((ficres =fopen(fileres,"w"))==NULL) { - printf("Problem with resultfile: %s\n", fileres);goto end; + /*-------- Rewriting paramater file ----------*/ + strcpy(rfileres,"r"); /* "Rparameterfile */ + strcat(rfileres,optionfilefiname); /* Parameter file first name*/ + strcat(rfileres,"."); /* */ + strcat(rfileres,optionfilext); /* Other files have txt extension */ + if((ficres =fopen(rfileres,"w"))==NULL) { + printf("Problem writing new parameter file: %s\n", fileres);goto end; } fprintf(ficres,"#%s\n",version); + /*-------- data file ----------*/ if((fic=fopen(datafile,"r"))==NULL) { printf("Problem with datafile: %s\n", datafile);goto end; } @@ -2902,7 +2913,7 @@ printf("Total number of individuals= %d, } /*--------- results files --------------*/ - fprintf(ficres,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncov=%d nlstate=%d ndeath=%d maxwav=%d mle=%d weight=%d\nmodel=%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncov, nlstate, ndeath, maxwav, mle,weightopt,model); + fprintf(ficres,"title=%s datafile=%s lastobs=%d firstpass=%d lastpass=%d\nftol=%e stepm=%d ncov=%d nlstate=%d ndeath=%d maxwav=%d mle= 0 weight=%d\nmodel=%s\n", title, datafile, lastobs, firstpass,lastpass,ftol, stepm, ncov, nlstate, ndeath, maxwav, weightopt,model); jk=1; @@ -3057,7 +3068,7 @@ while((c=getc(ficpar))=='#' && c!= EOF){ /*--------- index.htm --------*/ - printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,model,imx,jmin,jmax,jmean,optionfile,optionfilehtm); + printinghtml(fileres,title,datafile, firstpass, lastpass, stepm, weightopt,model,imx,jmin,jmax,jmean,optionfile,optionfilehtm,rfileres); /*--------------- Prevalence limit --------------*/