--- imach/src/imach.c 2014/06/10 21:23:15 1.145
+++ imach/src/imach.c 2014/08/25 20:10:10 1.156
@@ -1,6 +1,49 @@
-/* $Id: imach.c,v 1.145 2014/06/10 21:23:15 brouard Exp $
+/* $Id: imach.c,v 1.156 2014/08/25 20:10:10 brouard Exp $
$State: Exp $
$Log: imach.c,v $
+ Revision 1.156 2014/08/25 20:10:10 brouard
+ *** empty log message ***
+
+ Revision 1.155 2014/08/25 18:32:34 brouard
+ Summary: New compile, minor changes
+ Author: Brouard
+
+ Revision 1.154 2014/06/20 17:32:08 brouard
+ Summary: Outputs now all graphs of convergence to period prevalence
+
+ Revision 1.153 2014/06/20 16:45:46 brouard
+ Summary: If 3 live state, convergence to period prevalence on same graph
+ Author: Brouard
+
+ Revision 1.152 2014/06/18 17:54:09 brouard
+ Summary: open browser, use gnuplot on same dir than imach if not found in the path
+
+ Revision 1.151 2014/06/18 16:43:30 brouard
+ *** empty log message ***
+
+ Revision 1.150 2014/06/18 16:42:35 brouard
+ Summary: If gnuplot is not in the path try on same directory than imach binary (OSX)
+ Author: brouard
+
+ Revision 1.149 2014/06/18 15:51:14 brouard
+ Summary: Some fixes in parameter files errors
+ Author: Nicolas Brouard
+
+ Revision 1.148 2014/06/17 17:38:48 brouard
+ Summary: Nothing new
+ Author: Brouard
+
+ Just a new packaging for OS/X version 0.98nS
+
+ Revision 1.147 2014/06/16 10:33:11 brouard
+ *** empty log message ***
+
+ Revision 1.146 2014/06/16 10:20:28 brouard
+ Summary: Merge
+ Author: Brouard
+
+ Merge, before building revised version.
+
Revision 1.145 2014/06/10 21:23:15 brouard
Summary: Debugging with valgrind
Author: Nicolas Brouard
@@ -477,11 +520,11 @@ extern int errno;
#define ODIRSEPARATOR '/'
#endif
-/* $Id: imach.c,v 1.145 2014/06/10 21:23:15 brouard Exp $ */
+/* $Id: imach.c,v 1.156 2014/08/25 20:10:10 brouard Exp $ */
/* $State: Exp $ */
-char version[]="Imach version 0.98nR2, January 2014,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121)";
-char fullversion[]="$Revision: 1.145 $ $Date: 2014/06/10 21:23:15 $";
+char version[]="Imach version 0.98nV, August 2014,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121)";
+char fullversion[]="$Revision: 1.156 $ $Date: 2014/08/25 20:10:10 $";
char strstart[80];
char optionfilext[10], optionfilefiname[FILENAMELENGTH];
int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */
@@ -3859,13 +3902,13 @@ fprintf(fichtm," \n
- Graphs
before but expressed in per year i.e. quasi incidences if stepm is small and probabilities too: %s%d_2.png
\
",stepm,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1,subdirf2(optionfilefiname,"pe"),jj1);
/* Period (stable) prevalence in each health state */
- for(cpt=1; cpt- Period (stable) prevalence in each health state : %s%d_%d.png
\
-",subdirf2(optionfilefiname,"p"),cpt,jj1,subdirf2(optionfilefiname,"p"),cpt,jj1,subdirf2(optionfilefiname,"p"),cpt,jj1);
+ for(cpt=1; cpt<=nlstate;cpt++){
+ fprintf(fichtm,"
- Convergence from each state (1 to %d) to period (stable) prevalence in state %d %s%d_%d.png
\
+",nlstate, cpt, subdirf2(optionfilefiname,"p"),cpt,jj1,subdirf2(optionfilefiname,"p"),cpt,jj1,subdirf2(optionfilefiname,"p"),cpt,jj1);
}
for(cpt=1; cpt<=nlstate;cpt++) {
- fprintf(fichtm,"\n
- Life expectancy by health state (%d) at initial age and its decomposition into health expectancies : %s%d%d.png
\
-",cpt,subdirf2(optionfilefiname,"exp"),cpt,jj1,subdirf2(optionfilefiname,"exp"),cpt,jj1,subdirf2(optionfilefiname,"exp"),cpt,jj1);
+ fprintf(fichtm,"\n
- Life expectancy by health state (%d) at initial age and its decomposition into health expectancies in each alive state (1 to %d) : %s%d%d.png
\
+",cpt,nlstate,subdirf2(optionfilefiname,"exp"),cpt,jj1,subdirf2(optionfilefiname,"exp"),cpt,jj1,subdirf2(optionfilefiname,"exp"),cpt,jj1);
}
} /* end i1 */
}/* End k1 */
@@ -3961,6 +4004,7 @@ void printinggnuplot(char fileres[], cha
strcpy(dirfileres,optionfilefiname);
strcpy(optfileres,"vpl");
/* 1eme*/
+ fprintf(ficgp,"\n# 1st: Period (stable) prevalence with CI: 'vpl' files\n");
for (cpt=1; cpt<= nlstate ; cpt ++) {
for (k1=1; k1<= m ; k1 ++) { /* plot [100000000000000000000:-100000000000000000000] "mysbiaspar/vplrmysbiaspar.txt to check */
fprintf(ficgp,"\nset out \"%s%d_%d.png\" \n",subdirf2(optionfilefiname,"v"),cpt,k1);
@@ -3988,7 +4032,7 @@ plot [%.f:%.f] \"%s\" every :::%d::%d u
}
}
/*2 eme*/
-
+ fprintf(ficgp,"\n# 2nd: Total life expectancy with CI: 't' files\n");
for (k1=1; k1<= m ; k1 ++) {
fprintf(ficgp,"\nset out \"%s%d.png\" \n",subdirf2(optionfilefiname,"e"),k1);
fprintf(ficgp,"set ylabel \"Years\" \nset ter png small size 320, 240\nplot [%.f:%.f] ",ageminpar,fage);
@@ -4045,28 +4089,29 @@ plot [%.f:%.f] \"%s\" every :::%d::%d u
}
/* CV preval stable (period) */
- for (k1=1; k1<= m ; k1 ++) {
- for (cpt=1; cpt<=nlstate ; cpt ++) {
+ for (k1=1; k1<= m ; k1 ++) { /* For each multivariate if any */
+ for (cpt=1; cpt<=nlstate ; cpt ++) { /* For each life state */
k=3;
+ fprintf(ficgp,"\n#\n#\n#CV preval stable (period): 'pij' files, cov=%d state=%d",k1, cpt);
fprintf(ficgp,"\nset out \"%s%d_%d.png\" \n",subdirf2(optionfilefiname,"p"),cpt,k1);
fprintf(ficgp,"set xlabel \"Age\" \nset ylabel \"Probability\" \n\
set ter png small size 320, 240\n\
unset log y\n\
-plot [%.f:%.f] \"%s\" u ($1==%d ? ($3):1/0):($%d/($%d",ageminpar,agemaxpar,subdirf2(fileres,"pij"),k1,k+cpt+1,k+1);
-
- for (i=1; i< nlstate ; i ++)
- fprintf(ficgp,"+$%d",k+i+1);
- fprintf(ficgp,")) t\"prev(%d,%d)\" w l",cpt,cpt+1);
-
- l=3+(nlstate+ndeath)*cpt;
- fprintf(ficgp,",\"%s\" u ($1==%d ? ($3):1/0):($%d/($%d",subdirf2(fileres,"pij"),k1,l+cpt+1,l+1);
- for (i=1; i< nlstate ; i ++) {
- l=3+(nlstate+ndeath)*cpt;
- fprintf(ficgp,"+$%d",l+i+1);
- }
- fprintf(ficgp,")) t\"prev(%d,%d)\" w l\n",cpt+1,cpt+1);
- }
- }
+plot [%.f:%.f] ", ageminpar, agemaxpar);
+ for (i=1; i<= nlstate ; i ++){
+ if(i==1)
+ fprintf(ficgp,"\"%s\"",subdirf2(fileres,"pij"));
+ else
+ fprintf(ficgp,", '' ");
+ l=(nlstate+ndeath)*(i-1)+1;
+ fprintf(ficgp," u ($1==%d ? ($3):1/0):($%d/($%d",k1,k+l+(cpt-1),k+l);
+ for (j=1; j<= (nlstate-1) ; j ++)
+ fprintf(ficgp,"+$%d",k+l+j);
+ fprintf(ficgp,")) t \"prev(%d,%d)\" w l",i,cpt);
+ } /* nlstate */
+ fprintf(ficgp,"\n");
+ } /* end cpt state*/
+ } /* end covariate */
/* proba elementaires */
for(i=1,jk=1; i <=nlstate; i++){
@@ -5137,7 +5182,7 @@ calandcheckages(int imx, int maxwav, dou
}
else if(agev[m][i] >*agemax){
*agemax=agev[m][i];
- printf(" Max anint[%d][%d]=%.0f annais[%d]=%.0f, agemax=%.2f\n",m,i,anint[m][i], i,annais[i], *agemax);
+ /* printf(" Max anint[%d][%d]=%.0f annais[%d]=%.0f, agemax=%.2f\n",m,i,anint[m][i], i,annais[i], *agemax);*/
}
/*agev[m][i]=anint[m][i]-annais[i];*/
/* agev[m][i] = age[i]+2*m;*/
@@ -5299,6 +5344,9 @@ int main(int argc, char *argv[])
i=strlen(pathr);
if(pathr[i-1]=='\n')
pathr[i-1]='\0';
+ i=strlen(pathr);
+ if(pathr[i-1]==' ') /* This may happen when dragging on oS/X! */
+ pathr[i-1]='\0';
for (tok = pathr; tok != NULL; ){
printf("Pathr |%s|\n",pathr);
while ((val = strsep(&tok, "\"" )) != NULL && *val == '\0');
@@ -5354,7 +5402,7 @@ int main(int argc, char *argv[])
path=%s \n\
optionfile=%s\n\
optionfilext=%s\n\
- optionfilefiname=%s\n",pathimach,pathtot,path,optionfile,optionfilext,optionfilefiname);
+ optionfilefiname='%s'\n",pathimach,pathtot,path,optionfile,optionfilext,optionfilefiname);
printf("Local time (at start):%s",strstart);
fprintf(ficlog,"Local time (at start): %s",strstart);
@@ -5370,10 +5418,11 @@ int main(int argc, char *argv[])
/*---------arguments file --------*/
if((ficpar=fopen(optionfile,"r"))==NULL) {
- printf("Problem with optionfile %s\n",optionfile);
- fprintf(ficlog,"Problem with optionfile %s\n",optionfile);
+ printf("Problem with optionfile '%s' with errno='%s'\n",optionfile,strerror(errno));
+ fprintf(ficlog,"Problem with optionfile '%s' with errno='%s'\n",optionfile,strerror(errno));
fflush(ficlog);
- goto end;
+ /* goto end; */
+ exit(70);
}
@@ -6624,9 +6673,9 @@ Interval (in months) between two waves:
sprintf(plotcmd,"\"%sgnuplot.exe\"",pathimach);
#endif
if(!stat(plotcmd,&info)){
- printf("Error gnuplot program not found: %s\n",plotcmd);fflush(stdout);
+ printf("Error or gnuplot program not found: %s\n",plotcmd);fflush(stdout);
if(!stat(getenv("GNUPLOTBIN"),&info)){
- printf("Error gnuplot program not found: %s Environment GNUPLOTBIN not set.\n",plotcmd);fflush(stdout);
+ printf("Error or gnuplot program not found: %s Environment GNUPLOTBIN not set.\n",plotcmd);fflush(stdout);
}else
strcpy(pplotcmd,plotcmd);
#ifdef UNIX
@@ -6643,17 +6692,26 @@ Interval (in months) between two waves:
printf("Starting graphs with: %s\n",plotcmd);fflush(stdout);
if((outcmd=system(plotcmd)) != 0){
- printf("\n Problem with gnuplot\n");
+ printf("gnuplot command might not be in your path: %s, err=%d\n", plotcmd, outcmd);
+ printf("\n Trying if gnuplot resides on the same directory that IMaCh\n");
+ sprintf(plotcmd,"%sgnuplot %s", pathimach, optionfilegnuplot);
+ if((outcmd=system(plotcmd)) != 0)
+ printf("\n Still a problem with gnuplot command %s, err=%d\n", plotcmd, outcmd);
}
- printf(" Wait...");
+ printf(" Successul, please wait...");
while (z[0] != 'q') {
/* chdir(path); */
- printf("\nType e to edit output files, g to graph again and q for exiting: ");
+ printf("\nType e to edit results with your browser, g to graph again and q for exit: ");
scanf("%s",z);
/* if (z[0] == 'c') system("./imach"); */
if (z[0] == 'e') {
- printf("Starting browser with: %s",optionfilehtm);fflush(stdout);
- system(optionfilehtm);
+#ifdef OSX
+ sprintf(pplotcmd, "open %s", optionfilehtm);
+#else
+ sprintf(pplotcmd, "%s", optionfilehtm);
+#endif
+ printf("Starting browser with: %s",pplotcmd);fflush(stdout);
+ system(pplotcmd);
}
else if (z[0] == 'g') system(plotcmd);
else if (z[0] == 'q') exit(0);