--- imach/src/imach.c 2017/07/17 08:53:49 1.277 +++ imach/src/imach.c 2017/07/19 14:09:02 1.278 @@ -1,6 +1,9 @@ -/* $Id: imach.c,v 1.277 2017/07/17 08:53:49 brouard Exp $ +/* $Id: imach.c,v 1.278 2017/07/19 14:09:02 brouard Exp $ $State: Exp $ $Log: imach.c,v $ + Revision 1.278 2017/07/19 14:09:02 brouard + Summary: Bug for mobil_average=0 and prevforecast fixed(?) + Revision 1.277 2017/07/17 08:53:49 brouard Summary: BOM files can be read now @@ -1034,12 +1037,12 @@ typedef struct { #define ODIRSEPARATOR '\\' #endif -/* $Id: imach.c,v 1.277 2017/07/17 08:53:49 brouard Exp $ */ +/* $Id: imach.c,v 1.278 2017/07/19 14:09:02 brouard Exp $ */ /* $State: Exp $ */ #include "version.h" char version[]=__IMACH_VERSION__; char copyright[]="February 2016,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015-2018"; -char fullversion[]="$Revision: 1.277 $ $Date: 2017/07/17 08:53:49 $"; +char fullversion[]="$Revision: 1.278 $ $Date: 2017/07/19 14:09:02 $"; char strstart[80]; char optionfilext[10], optionfilefiname[FILENAMELENGTH]; int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ @@ -7945,8 +7948,8 @@ set ter svg size 640, 480\nunset log y\n double *agemingoodr, *agemaxgoodr; - /* modcovmax=2*cptcoveff;/\* Max number of modalities. We suppose */ - /* a covariate has 2 modalities, should be equal to ncovcombmax *\/ */ + /* modcovmax=2*cptcoveff; Max number of modalities. We suppose */ + /* a covariate has 2 modalities, should be equal to ncovcombmax */ sumnewp = vector(1,ncovcombmax); sumnewm = vector(1,ncovcombmax); @@ -8270,11 +8273,11 @@ set ter svg size 640, 480\nunset log y\n for(j=1; j<=nlstate+ndeath;j++) { ppij=0.; for(i=1; i<=nlstate;i++) { - /* if (mobilav>=1) */ - ppij=ppij+p3mat[i][j][h]*prev[(int)agec][i][k]; - /* else { */ /* even if mobilav==-1 we use mobaverage */ - /* ppij=ppij+p3mat[i][j][h]*probs[(int)(agec)][i][k]; */ - /* } */ + if (mobilav>=1) + ppij=ppij+p3mat[i][j][h]*prev[(int)agec][i][k]; + else { /* even if mobilav==-1 we use mobaverage, probs may not sums to 1 */ + ppij=ppij+p3mat[i][j][h]*probs[(int)(agec)][i][k]; + } fprintf(ficresf," %.3f", p3mat[i][j][h]); } /* end i */ fprintf(ficresf," %.3f", ppij); @@ -10842,7 +10845,20 @@ int main(int argc, char *argv[]) fflush(ficlog); goto end; } + /*-------- Rewriting parameter 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", rfileres);goto end; + fprintf(ficlog,"Problem writing new parameter file: %s\n", rfileres);goto end; + fflush(ficlog); + goto end; + } + fprintf(ficres,"#IMaCh %s\n",version); + /* Reads comments: lines beginning with '#' */ numlinepar=0; /* Is it a BOM UTF-8 Windows file? */ @@ -10874,6 +10890,7 @@ int main(int argc, char *argv[]) numlinepar++; fputs(line,stdout); fputs(line,ficparo); + fputs(line,ficres); fputs(line,ficlog); continue; }else @@ -10894,6 +10911,7 @@ int main(int argc, char *argv[]) numlinepar++; fputs(line,stdout); fputs(line,ficparo); + fputs(line,ficres); fputs(line,ficlog); continue; }else @@ -10916,6 +10934,7 @@ int main(int argc, char *argv[]) numlinepar++; fputs(line,stdout); fputs(line,ficparo); + fputs(line,ficres); fputs(line,ficlog); continue; }else @@ -11177,16 +11196,6 @@ Please run with mle=-1 to get a correct fflush(ficlog); - /*-------- Rewriting parameter 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", rfileres);goto end; - fprintf(ficlog,"Problem writing new parameter file: %s\n", rfileres);goto end; - } - fprintf(ficres,"#%s\n",version); } /* End of mle != -3 */ /* Main data