version 1.105, 2006/01/05 20:23:19
|
version 1.108, 2006/01/19 18:05:42
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.108 2006/01/19 18:05:42 lievre |
|
Gnuplot problem appeared... |
|
To be fixed |
|
|
|
Revision 1.107 2006/01/19 16:20:37 brouard |
|
Test existence of gnuplot in imach path |
|
|
|
Revision 1.106 2006/01/19 13:24:36 brouard |
|
Some cleaning and links added in html output |
|
|
Revision 1.105 2006/01/05 20:23:19 lievre |
Revision 1.105 2006/01/05 20:23:19 lievre |
*** empty log message *** |
*** empty log message *** |
|
|
Line 221
|
Line 231
|
#include <math.h> |
#include <math.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
|
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
|
#include <sys/types.h> |
|
#include <sys/stat.h> |
|
#include <errno.h> |
|
extern int errno; |
|
|
/* #include <sys/time.h> */ |
/* #include <sys/time.h> */ |
#include <time.h> |
#include <time.h> |
#include "timeval.h" |
#include "timeval.h" |
Line 231
|
Line 247
|
/* #define _(String) gettext (String) */ |
/* #define _(String) gettext (String) */ |
|
|
#define MAXLINE 256 |
#define MAXLINE 256 |
|
|
#define GNUPLOTPROGRAM "gnuplot" |
#define GNUPLOTPROGRAM "gnuplot" |
/*#define GNUPLOTPROGRAM "..\\gp37mgw\\wgnuplot"*/ |
/*#define GNUPLOTPROGRAM "..\\gp37mgw\\wgnuplot"*/ |
#define FILENAMELENGTH 132 |
#define FILENAMELENGTH 132 |
/*#define DEBUG*/ |
|
/*#define windows*/ |
|
#define GLOCK_ERROR_NOPATH -1 /* empty path */ |
#define GLOCK_ERROR_NOPATH -1 /* empty path */ |
#define GLOCK_ERROR_GETCWD -2 /* cannot get cwd */ |
#define GLOCK_ERROR_GETCWD -2 /* cannot get cwd */ |
|
|
Line 253
|
Line 269
|
#define AGEGOMP 10. /* Minimal age for Gompertz adjustment */ |
#define AGEGOMP 10. /* Minimal age for Gompertz adjustment */ |
#ifdef UNIX |
#ifdef UNIX |
#define DIRSEPARATOR '/' |
#define DIRSEPARATOR '/' |
|
#define CHARSEPARATOR "/" |
#define ODIRSEPARATOR '\\' |
#define ODIRSEPARATOR '\\' |
#else |
#else |
#define DIRSEPARATOR '\\' |
#define DIRSEPARATOR '\\' |
|
#define CHARSEPARATOR "\\" |
#define ODIRSEPARATOR '/' |
#define ODIRSEPARATOR '/' |
#endif |
#endif |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* $State$ */ |
/* $State$ */ |
|
|
char version[]="Imach version 0.98, September 2005, INED-EUROREVES "; |
char version[]="Imach version 0.98a, January 2006, INED-EUROREVES "; |
char fullversion[]="$Revision$ $Date$"; |
char fullversion[]="$Revision$ $Date$"; |
int erreur, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ |
int erreur, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ |
int nvar; |
int nvar; |
Line 384 double ftolhess; /* Tolerance for comput
|
Line 402 double ftolhess; /* Tolerance for comput
|
/**************** split *************************/ |
/**************** split *************************/ |
static int split( char *path, char *dirc, char *name, char *ext, char *finame ) |
static int split( char *path, char *dirc, char *name, char *ext, char *finame ) |
{ |
{ |
/* From a file name with full path (either Unix or Windows) we extract the directory (dirc) |
/* From a file name with (full) path (either Unix or Windows) we extract the directory (dirc) |
the name of the file (name), its extension only (ext) and its first part of the name (finame) |
the name of the file (name), its extension only (ext) and its first part of the name (finame) |
*/ |
*/ |
char *ss; /* pointer */ |
char *ss; /* pointer */ |
Line 393 static int split( char *path, char *dirc
|
Line 411 static int split( char *path, char *dirc
|
l1 = strlen(path ); /* length of path */ |
l1 = strlen(path ); /* length of path */ |
if ( l1 == 0 ) return( GLOCK_ERROR_NOPATH ); |
if ( l1 == 0 ) return( GLOCK_ERROR_NOPATH ); |
ss= strrchr( path, DIRSEPARATOR ); /* find last / */ |
ss= strrchr( path, DIRSEPARATOR ); /* find last / */ |
if ( ss == NULL ) { /* no directory, so use current */ |
if ( ss == NULL ) { /* no directory, so determine current directory */ |
|
strcpy( name, path ); /* we got the fullname name because no directory */ |
/*if(strrchr(path, ODIRSEPARATOR )==NULL) |
/*if(strrchr(path, ODIRSEPARATOR )==NULL) |
printf("Warning you should use %s as a separator\n",DIRSEPARATOR);*/ |
printf("Warning you should use %s as a separator\n",DIRSEPARATOR);*/ |
/* get current working directory */ |
/* get current working directory */ |
Line 401 static int split( char *path, char *dirc
|
Line 420 static int split( char *path, char *dirc
|
if ( getcwd( dirc, FILENAME_MAX ) == NULL ) { |
if ( getcwd( dirc, FILENAME_MAX ) == NULL ) { |
return( GLOCK_ERROR_GETCWD ); |
return( GLOCK_ERROR_GETCWD ); |
} |
} |
strcpy( name, path ); /* we've got it */ |
/* got dirc from getcwd*/ |
|
printf(" DIRC = %s \n",dirc); |
} else { /* strip direcotry from path */ |
} else { /* strip direcotry from path */ |
ss++; /* after this, the filename */ |
ss++; /* after this, the filename */ |
l2 = strlen( ss ); /* length of filename */ |
l2 = strlen( ss ); /* length of filename */ |
Line 409 static int split( char *path, char *dirc
|
Line 429 static int split( char *path, char *dirc
|
strcpy( name, ss ); /* save file name */ |
strcpy( name, ss ); /* save file name */ |
strncpy( dirc, path, l1 - l2 ); /* now the directory */ |
strncpy( dirc, path, l1 - l2 ); /* now the directory */ |
dirc[l1-l2] = 0; /* add zero */ |
dirc[l1-l2] = 0; /* add zero */ |
|
printf(" DIRC2 = %s \n",dirc); |
} |
} |
|
/* We add a separator at the end of dirc if not exists */ |
l1 = strlen( dirc ); /* length of directory */ |
l1 = strlen( dirc ); /* length of directory */ |
/*#ifdef windows |
if( dirc[l1-1] != DIRSEPARATOR ){ |
if ( dirc[l1-1] != '\\' ) { dirc[l1] = '\\'; dirc[l1+1] = 0; } |
dirc[l1] = DIRSEPARATOR; |
#else |
dirc[l1+1] = 0; |
if ( dirc[l1-1] != '/' ) { dirc[l1] = '/'; dirc[l1+1] = 0; } |
printf(" DIRC3 = %s \n",dirc); |
#endif |
} |
*/ |
|
ss = strrchr( name, '.' ); /* find last / */ |
ss = strrchr( name, '.' ); /* find last / */ |
if (ss >0){ |
if (ss >0){ |
ss++; |
ss++; |
Line 426 static int split( char *path, char *dirc
|
Line 447 static int split( char *path, char *dirc
|
strncpy( finame, name, l1-l2); |
strncpy( finame, name, l1-l2); |
finame[l1-l2]= 0; |
finame[l1-l2]= 0; |
} |
} |
|
|
return( 0 ); /* we're done */ |
return( 0 ); /* we're done */ |
} |
} |
|
|
Line 2556 void varevsij(char optionfilefiname[], d
|
Line 2578 void varevsij(char optionfilefiname[], d
|
} |
} |
fprintf(ficresprobmorprev,"\n"); |
fprintf(ficresprobmorprev,"\n"); |
fprintf(ficgp,"\n# Routine varevsij"); |
fprintf(ficgp,"\n# Routine varevsij"); |
fprintf(fichtm, "#Local time at start: %s", strstart); |
/* fprintf(fichtm, "#Local time at start: %s", strstart);*/ |
fprintf(fichtm,"\n<li><h4> Computing probabilities of dying over estepm months as a weighted average (i.e global mortality independent of initial healh state)</h4></li>\n"); |
fprintf(fichtm,"\n<li><h4> Computing probabilities of dying over estepm months as a weighted average (i.e global mortality independent of initial healh state)</h4></li>\n"); |
fprintf(fichtm,"\n<br>%s <br>\n",digitp); |
fprintf(fichtm,"\n<br>%s <br>\n",digitp); |
/* } */ |
/* } */ |
Line 3199 void printinghtml(char fileres[], char t
|
Line 3221 void printinghtml(char fileres[], char t
|
double jprev2, double mprev2,double anprev2){ |
double jprev2, double mprev2,double anprev2){ |
int jj1, k1, i1, cpt; |
int jj1, k1, i1, cpt; |
|
|
fprintf(fichtm,"<ul><li><h4>Result files (first order: no variance)</h4>\n \ |
fprintf(fichtm,"<ul><li><a href='#firstorder'>Result files (first order: no variance)</a>\n \ |
|
<li><a href='#secondorder'>Result files (second order (variance)</a>\n \ |
|
</ul>"); |
|
fprintf(fichtm,"<ul><li><h4><a name='firstorder'>Result files (first order: no variance)</a></h4>\n \ |
- Observed prevalence in each state (during the period defined between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf): <a href=\"%s\">%s</a> <br>\n ", |
- Observed prevalence in each state (during the period defined between %.lf/%.lf/%.lf and %.lf/%.lf/%.lf): <a href=\"%s\">%s</a> <br>\n ", |
jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,subdirf2(fileres,"p"),subdirf2(fileres,"p")); |
jprev1, mprev1,anprev1,jprev2, mprev2,anprev2,subdirf2(fileres,"p"),subdirf2(fileres,"p")); |
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
Line 3250 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
Line 3275 fprintf(fichtm," \n<ul><li><b>Graphs</b>
|
|
|
|
|
fprintf(fichtm,"\ |
fprintf(fichtm,"\ |
\n<br><li><h4> Result files (second order: variances)</h4>\n\ |
\n<br><li><h4> <a name='secondorder'>Result files (second order: variances)</a></h4>\n\ |
- Parameter file with estimated parameters and covariance matrix: <a href=\"%s\">%s</a> <br>\n", rfileres,rfileres); |
- Parameter file with estimated parameters and covariance matrix: <a href=\"%s\">%s</a> <br>\n", rfileres,rfileres); |
|
|
fprintf(fichtm," - Variance of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
fprintf(fichtm," - Variance of one-step probabilities: <a href=\"%s\">%s</a> <br>\n", |
Line 4009 void printinghtmlmort(char fileres[], ch
|
Line 4034 void printinghtmlmort(char fileres[], ch
|
|
|
fprintf(fichtm,"<ul><li><h4>Life table</h4>\n <br>"); |
fprintf(fichtm,"<ul><li><h4>Life table</h4>\n <br>"); |
|
|
fprintf(fichtm,"\nAge lx qx dx Lx Tx e(x)<br>"); |
fprintf(fichtm,"\nAge l<inf>x</inf> q<inf>x</inf> d(x,x+1) L<inf>x</inf> T<inf>x</inf> e<infx</inf><br>"); |
|
|
for (k=agegomp;k<(agemortsup-2);k++) |
for (k=agegomp;k<(agemortsup-2);k++) |
fprintf(fichtm,"%d %.0lf %lf %.0lf %.0lf %.0lf %lf<br>\n",k,lsurv[k],p[1]*exp(p[2]*(k-agegomp)),(p[1]*exp(p[2]*(k-agegomp)))*lsurv[k],lpop[k],tpop[k],tpop[k]/lsurv[k]); |
fprintf(fichtm,"%d %.0lf %lf %.0lf %.0lf %.0lf %lf<br>\n",k,lsurv[k],p[1]*exp(p[2]*(k-agegomp)),(p[1]*exp(p[2]*(k-agegomp)))*lsurv[k],lpop[k],tpop[k],tpop[k]/lsurv[k]); |
Line 4060 int main(int argc, char *argv[])
|
Line 4085 int main(int argc, char *argv[])
|
char ca[32], cb[32], cc[32]; |
char ca[32], cb[32], cc[32]; |
/* FILE *fichtm; *//* Html File */ |
/* FILE *fichtm; *//* Html File */ |
/* FILE *ficgp;*/ /*Gnuplot File */ |
/* FILE *ficgp;*/ /*Gnuplot File */ |
|
struct stat info; |
double agedeb, agefin,hf; |
double agedeb, agefin,hf; |
double ageminpar=1.e20,agemin=1.e20, agemaxpar=-1.e20, agemax=-1.e20; |
double ageminpar=1.e20,agemin=1.e20, agemaxpar=-1.e20, agemax=-1.e20; |
|
|
Line 4160 int main(int argc, char *argv[])
|
Line 4186 int main(int argc, char *argv[])
|
printf("pathtot=%s, path=%s, optionfile=%s\n",pathtot,path,optionfile);*/ |
printf("pathtot=%s, path=%s, optionfile=%s\n",pathtot,path,optionfile);*/ |
/* cutv(path,optionfile,pathtot,'\\');*/ |
/* cutv(path,optionfile,pathtot,'\\');*/ |
|
|
|
/* Split argv[0], imach program to get pathimach */ |
|
printf("\nargv[0]=%s argv[1]=%s, \n",argv[0],argv[1]); |
split(argv[0],pathimach,optionfile,optionfilext,optionfilefiname); |
split(argv[0],pathimach,optionfile,optionfilext,optionfilefiname); |
|
printf("\nargv[0]=%s pathimach=%s, \noptionfile=%s \noptionfilext=%s \noptionfilefiname=%s\n",argv[0],pathimach,optionfile,optionfilext,optionfilefiname); |
/* strcpy(pathimach,argv[0]); */ |
/* strcpy(pathimach,argv[0]); */ |
|
/* Split argv[1]=pathtot, parameter file name to get path, optionfile, extension and name */ |
split(pathtot,path,optionfile,optionfilext,optionfilefiname); |
split(pathtot,path,optionfile,optionfilext,optionfilefiname); |
printf("pathimach=%s, pathtot=%s,\npath=%s,\noptionfile=%s \noptionfilext=%s \noptionfilefiname=%s\n",pathimach,pathtot,path,optionfile,optionfilext,optionfilefiname); |
printf("\npathtot=%s,\npath=%s,\noptionfile=%s \noptionfilext=%s \noptionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname); |
chdir(path); |
chdir(path); |
strcpy(command,"mkdir "); |
strcpy(command,"mkdir "); |
strcat(command,optionfilefiname); |
strcat(command,optionfilefiname); |
Line 4504 int main(int argc, char *argv[])
|
Line 4534 int main(int argc, char *argv[])
|
if (s[4][i]==9) s[4][i]=-1; |
if (s[4][i]==9) s[4][i]=-1; |
printf("%ld %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]), (mint[3][i]), (anint[3][i]), (s[3][i]), (mint[4][i]), (anint[4][i]), (s[4][i]));}*/ |
printf("%ld %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d %.lf/%.lf %d\n",num[i],(covar[1][i]), (covar[2][i]), (weight[i]), (moisnais[i]), (annais[i]), (moisdc[i]), (andc[i]), (mint[1][i]), (anint[1][i]), (s[1][i]), (mint[2][i]), (anint[2][i]), (s[2][i]), (mint[3][i]), (anint[3][i]), (s[3][i]), (mint[4][i]), (anint[4][i]), (s[4][i]));}*/ |
|
|
for (i=1; i<=imx; i++) |
/* for (i=1; i<=imx; i++) */ |
|
|
/*if ((s[3][i]==3) || (s[4][i]==3)) weight[i]=0.08; |
/*if ((s[3][i]==3) || (s[4][i]==3)) weight[i]=0.08; |
else weight[i]=1;*/ |
else weight[i]=1;*/ |
|
|
/* Calculation of the number of parameter from char model*/ |
/* Calculation of the number of parameters from char model */ |
Tvar=ivector(1,15); /* stores the number n of the covariates in Vm+Vn at 1 and m at 2 */ |
Tvar=ivector(1,15); /* stores the number n of the covariates in Vm+Vn at 1 and m at 2 */ |
Tprod=ivector(1,15); |
Tprod=ivector(1,15); |
Tvaraff=ivector(1,15); |
Tvaraff=ivector(1,15); |
Line 4638 int main(int argc, char *argv[])
|
Line 4668 int main(int argc, char *argv[])
|
} |
} |
} |
} |
else if(s[m][i] !=9){ /* Standard case, age in fractional |
else if(s[m][i] !=9){ /* Standard case, age in fractional |
years but with the precision of a |
years but with the precision of a month */ |
month */ |
|
agev[m][i]=(mint[m][i]/12.+1./24.+anint[m][i])-(moisnais[i]/12.+1./24.+annais[i]); |
agev[m][i]=(mint[m][i]/12.+1./24.+anint[m][i])-(moisnais[i]/12.+1./24.+annais[i]); |
if((int)mint[m][i]==99 || (int)anint[m][i]==9999) |
if((int)mint[m][i]==99 || (int)anint[m][i]==9999) |
agev[m][i]=1; |
agev[m][i]=1; |
Line 5523 lsurv=vector(1,AGESUP);
|
Line 5552 lsurv=vector(1,AGESUP);
|
/*------ End -----------*/ |
/*------ End -----------*/ |
|
|
chdir(path); |
chdir(path); |
|
#ifndef UNIX |
|
/* strcpy(plotcmd,"\""); */ |
|
#endif |
|
strcpy(plotcmd,pathimach); |
|
/*strcat(plotcmd,CHARSEPARATOR);*/ |
|
strcat(plotcmd,GNUPLOTPROGRAM); |
|
#ifndef UNIX |
|
strcat(plotcmd,".exe"); |
|
/* strcat(plotcmd,"\"");*/ |
|
#endif |
|
if(stat(plotcmd,&info)){ |
|
printf("Error gnuplot program not found: %s\n",plotcmd);fflush(stdout); |
|
} |
|
|
|
#ifndef UNIX |
strcpy(plotcmd,"\""); |
strcpy(plotcmd,"\""); |
|
#endif |
strcat(plotcmd,pathimach); |
strcat(plotcmd,pathimach); |
strcat(plotcmd,GNUPLOTPROGRAM); |
strcat(plotcmd,GNUPLOTPROGRAM); |
|
#ifndef UNIX |
|
strcat(plotcmd,".exe"); |
strcat(plotcmd,"\""); |
strcat(plotcmd,"\""); |
|
#endif |
strcat(plotcmd," "); |
strcat(plotcmd," "); |
strcat(plotcmd,optionfilegnuplot); |
strcat(plotcmd,optionfilegnuplot); |
printf("Starting graphs with: %s",plotcmd);fflush(stdout); |
printf("Starting graphs with: %s",plotcmd);fflush(stdout); |
|
|
if((outcmd=system(plotcmd)) != 0){ |
if((outcmd=system(plotcmd)) != 0){ |
printf(" Problem with gnuplot\n"); |
printf("\n Problem with gnuplot\n"); |
} |
} |
printf(" Wait..."); |
printf(" Wait..."); |
while (z[0] != 'q') { |
while (z[0] != 'q') { |