version 1.110, 2006/01/25 00:51:50
|
version 1.113, 2006/02/24 14:20:24
|
Line 1
|
Line 1
|
/* $Id$ |
/* $Id$ |
$State$ |
$State$ |
$Log$ |
$Log$ |
|
Revision 1.113 2006/02/24 14:20:24 brouard |
|
(Module): Memory leaks checks with valgrind and: |
|
datafile was not closed, some imatrix were not freed and on matrix |
|
allocation too. |
|
|
|
Revision 1.112 2006/01/30 09:55:26 brouard |
|
(Module): Back to gnuplot.exe instead of wgnuplot.exe |
|
|
|
Revision 1.111 2006/01/25 20:38:18 brouard |
|
(Module): Lots of cleaning and bugs added (Gompertz) |
|
(Module): Comments can be added in data file. Missing date values |
|
can be a simple dot '.'. |
|
|
Revision 1.110 2006/01/25 00:51:50 brouard |
Revision 1.110 2006/01/25 00:51:50 brouard |
(Module): Lots of cleaning and bugs added (Gompertz) |
(Module): Lots of cleaning and bugs added (Gompertz) |
|
|
Line 287 extern int errno;
|
Line 300 extern int errno;
|
/* $Id$ */ |
/* $Id$ */ |
/* $State$ */ |
/* $State$ */ |
|
|
char version[]="Imach version 0.98a, January 2006, INED-EUROREVES "; |
char version[]="Imach version 0.98b, 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 332 FILE *ficresvpl;
|
Line 345 FILE *ficresvpl;
|
char fileresvpl[FILENAMELENGTH]; |
char fileresvpl[FILENAMELENGTH]; |
char title[MAXLINE]; |
char title[MAXLINE]; |
char optionfile[FILENAMELENGTH], datafile[FILENAMELENGTH], filerespl[FILENAMELENGTH]; |
char optionfile[FILENAMELENGTH], datafile[FILENAMELENGTH], filerespl[FILENAMELENGTH]; |
char optionfilext[10], optionfilefiname[FILENAMELENGTH], plotcmd[FILENAMELENGTH]; |
char optionfilext[10], optionfilefiname[FILENAMELENGTH], plotcmd[FILENAMELENGTH], pplotcmd[FILENAMELENGTH]; |
char tmpout[FILENAMELENGTH], tmpout2[FILENAMELENGTH]; |
char tmpout[FILENAMELENGTH], tmpout2[FILENAMELENGTH]; |
char command[FILENAMELENGTH]; |
char command[FILENAMELENGTH]; |
int outcmd=0; |
int outcmd=0; |
Line 2205 void concatwav(int wav[], int **dh, int
|
Line 2218 void concatwav(int wav[], int **dh, int
|
if(mi==0){ |
if(mi==0){ |
nbwarn++; |
nbwarn++; |
if(first==0){ |
if(first==0){ |
printf("Warning! None valid information for:%ld line=%d (skipped) and may be others, see log file\n",num[i],i); |
printf("Warning! No valid information for individual %ld line=%d (skipped) and may be others, see log file\n",num[i],i); |
first=1; |
first=1; |
} |
} |
if(first==1){ |
if(first==1){ |
fprintf(ficlog,"Warning! None valid information for:%ld line=%d (skipped)\n",num[i],i); |
fprintf(ficlog,"Warning! No valid information for individual %ld line=%d (skipped)\n",num[i],i); |
} |
} |
} /* end mi==0 */ |
} /* end mi==0 */ |
} /* End individuals */ |
} /* End individuals */ |
Line 3226 To be simple, these graphs help to under
|
Line 3239 To be simple, these graphs help to under
|
} |
} |
free_ma3x(varpij,1,nlstate,1,nlstate+ndeath,(int) bage, (int)fage); |
free_ma3x(varpij,1,nlstate,1,nlstate+ndeath,(int) bage, (int)fage); |
free_matrix(mu,1,(nlstate+ndeath)*(nlstate+ndeath),(int) bage, (int)fage); |
free_matrix(mu,1,(nlstate+ndeath)*(nlstate+ndeath),(int) bage, (int)fage); |
|
free_matrix(doldm,1,(nlstate)*(nlstate+ndeath),1,(nlstate)*(nlstate+ndeath)); |
|
free_matrix(dnewm,1,(nlstate)*(nlstate+ndeath),1,npar); |
free_vector(xp,1,npar); |
free_vector(xp,1,npar); |
fclose(ficresprob); |
fclose(ficresprob); |
fclose(ficresprobcov); |
fclose(ficresprobcov); |
Line 4109 int main(int argc, char *argv[])
|
Line 4124 int main(int argc, char *argv[])
|
int NDIM=2; |
int NDIM=2; |
|
|
char ca[32], cb[32], cc[32]; |
char ca[32], cb[32], cc[32]; |
|
char dummy[]=" "; |
/* FILE *fichtm; *//* Html File */ |
/* FILE *fichtm; *//* Html File */ |
/* FILE *ficgp;*/ /*Gnuplot File */ |
/* FILE *ficgp;*/ /*Gnuplot File */ |
struct stat info; |
struct stat info; |
Line 4510 int main(int argc, char *argv[])
|
Line 4526 int main(int argc, char *argv[])
|
|
|
i=1; |
i=1; |
linei=0; |
linei=0; |
while ((fgets(line, MAXLINE, fic) != NULL) &&((i >= firstobs) && (i <=lastobs))) { |
while ((fgets(line, MAXLINE, fic) != NULL) &&((i >= firstobs) && (i <=lastobs))) { |
linei=linei+1; |
linei=linei+1; |
for(j=strlen(line); j>=0;j--){ /* Untabifies line */ |
for(j=strlen(line); j>=0;j--){ /* Untabifies line */ |
if(line[j] == '\t') |
if(line[j] == '\t') |
line[j] = ' '; |
line[j] = ' '; |
} |
} |
for(j=strlen(line)-1; (line[j]==' ')||(line[j]==10)||(line[j]==13);j--){ |
for(j=strlen(line)-1; (line[j]==' ')||(line[j]==10)||(line[j]==13);j--){ |
; |
; |
}; |
}; |
line[j+1]=0; /* Trims blanks at end of line */ |
line[j+1]=0; /* Trims blanks at end of line */ |
if(line[0]=='#'){ |
if(line[0]=='#'){ |
fprintf(ficlog,"Comment line\n%s\n",line); |
fprintf(ficlog,"Comment line\n%s\n",line); |
printf("Comment line\n%s\n",line); |
printf("Comment line\n%s\n",line); |
continue; |
continue; |
} |
} |
for (j=maxwav;j>=1;j--){ |
|
cutv(stra, strb,line,' '); |
|
errno=0; |
|
lval=strtol(strb,&endptr,10); |
|
/* if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))*/ |
|
if( strb[0]=='\0' || (*endptr != '\0')){ |
|
printf("Error reading data around '%d' at line number %d %s for individual %d\nShould be a status of wave %d. Setting maxwav=%d might be wrong. Exiting.\n",lval, i,line,linei,j,maxwav); |
|
exit(1); |
|
} |
|
s[j][i]=lval; |
|
|
|
strcpy(line,stra); |
for (j=maxwav;j>=1;j--){ |
cutv(stra, strb,line,' '); |
|
if(iout=sscanf(strb,"%d/%d",&month, &year) != 0){ |
|
} |
|
else if(iout=sscanf(strb,".") != 0){ |
|
month=99; |
|
year=9999; |
|
}else{ |
|
printf("Error reading data around '%s'.at line number %ld %s for individual %d\nShould be a year of exam at wave %d. Exiting.\n",strb, i,line,linei,j); |
|
exit(1); |
|
} |
|
anint[j][i]= (double) year; |
|
mint[j][i]= (double)month; |
|
strcpy(line,stra); |
|
} /* ENd Waves */ |
|
|
|
cutv(stra, strb,line,' '); |
cutv(stra, strb,line,' '); |
if(iout=sscanf(strb,"%d/%d",&month, &year) != 0){ |
errno=0; |
} |
lval=strtol(strb,&endptr,10); |
else if(iout=sscanf(strb,".") != 0){ |
/* if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))*/ |
month=99; |
if( strb[0]=='\0' || (*endptr != '\0')){ |
year=9999; |
printf("Error reading data around '%d' at line number %d %s for individual %d, '%s'\nShould be a status of wave %d. Setting maxwav=%d might be wrong. Exiting.\n", strb, linei,i,line,j,maxwav); |
}else{ |
|
printf("Error reading data around '%s'.at line number %ld %s for individual %d\nShould be a year of exam at wave %d. Exiting.\n",strb, i,line,linei,j); |
|
exit(1); |
exit(1); |
} |
} |
andc[i]=(double) year; |
s[j][i]=lval; |
moisdc[i]=(double) month; |
|
strcpy(line,stra); |
strcpy(line,stra); |
|
cutv(stra, strb,line,' '); |
cutv(stra, strb,line,' '); |
|
if(iout=sscanf(strb,"%d/%d",&month, &year) != 0){ |
if(iout=sscanf(strb,"%d/%d",&month, &year) != 0){ |
} |
} |
else if(iout=sscanf(strb,".") != 0){ |
else if(iout=sscanf(strb,"%s.") != 0){ |
month=99; |
month=99; |
year=9999; |
year=9999; |
}else{ |
}else{ |
printf("Error reading data around '%s'.at line number %ld %s for individual %d\nShould be a year of exam at wave %d. Exiting.\n",strb, i,line,linei,j); |
printf("Error reading data around '%s' at line number %ld %s for individual %d, '%s'\nShould be a date of interview (mm/yyyy or .) at wave %d. Exiting.\n",strb, linei,i, line,j); |
exit(1); |
exit(1); |
} |
} |
annais[i]=(double)(year); |
anint[j][i]= (double) year; |
moisnais[i]=(double)(month); |
mint[j][i]= (double)month; |
strcpy(line,stra); |
strcpy(line,stra); |
|
} /* ENd Waves */ |
|
|
|
cutv(stra, strb,line,' '); |
|
if(iout=sscanf(strb,"%d/%d",&month, &year) != 0){ |
|
} |
|
else if(iout=sscanf(strb,"%s.",dummy) != 0){ |
|
month=99; |
|
year=9999; |
|
}else{ |
|
printf("Error reading data around '%s' at line number %ld %s for individual %d, '%s'\nShould be a date of death (mm/yyyy or .). Exiting.\n",strb, linei,i,line); |
|
exit(1); |
|
} |
|
andc[i]=(double) year; |
|
moisdc[i]=(double) month; |
|
strcpy(line,stra); |
|
|
|
cutv(stra, strb,line,' '); |
|
if(iout=sscanf(strb,"%d/%d",&month, &year) != 0){ |
|
} |
|
else if(iout=sscanf(strb,"%s.") != 0){ |
|
month=99; |
|
year=9999; |
|
}else{ |
|
printf("Error reading data around '%s' at line number %ld %s for individual %d, '%s'\nShould be a date of birth (mm/yyyy or .). Exiting.\n",strb, linei,i,line,j); |
|
exit(1); |
|
} |
|
annais[i]=(double)(year); |
|
moisnais[i]=(double)(month); |
|
strcpy(line,stra); |
|
|
|
cutv(stra, strb,line,' '); |
|
errno=0; |
|
lval=strtol(strb,&endptr,10); |
|
if( strb[0]=='\0' || (*endptr != '\0')){ |
|
printf("Error reading data around '%d' at line number %ld %s for individual %d\nShould be a weight. Exiting.\n",lval, i,line,linei); |
|
exit(1); |
|
} |
|
weight[i]=(double)(lval); |
|
strcpy(line,stra); |
|
|
|
for (j=ncovcol;j>=1;j--){ |
cutv(stra, strb,line,' '); |
cutv(stra, strb,line,' '); |
errno=0; |
errno=0; |
lval=strtol(strb,&endptr,10); |
lval=strtol(strb,&endptr,10); |
if( strb[0]=='\0' || (*endptr != '\0')){ |
if( strb[0]=='\0' || (*endptr != '\0')){ |
printf("Error reading data around '%d' at line number %ld %s for individual %d\nShould be a weight. Exiting.\n",lval, i,line,linei); |
printf("Error reading data around '%d' at line number %ld %s for individual %d, '%s'\nShould be a covar (meaning 0 for the reference or 1). Exiting.\n",lval, linei,i, line); |
exit(1); |
exit(1); |
} |
} |
weight[i]=(double)(lval); |
if(lval <-1 || lval >1){ |
strcpy(line,stra); |
printf("Error reading data around '%d' at line number %ld %s for individual %d, '%s'\nShould be a value of the %d covar (meaning 0 for the reference or 1. IMaCh does not build design variables, do it your self). Exiting.\n",lval,linei, i,line,j); |
|
exit(1); |
for (j=ncovcol;j>=1;j--){ |
|
cutv(stra, strb,line,' '); |
|
errno=0; |
|
lval=strtol(strb,&endptr,10); |
|
if( strb[0]=='\0' || (*endptr != '\0')){ |
|
printf("Error reading data around '%d' at line number %ld %s for individual %d\nShould be a covar (meaning 0 for the reference or 1). Exiting.\n",lval, i,line,linei); |
|
exit(1); |
|
} |
|
if(lval <-1 || lval >1){ |
|
printf("Error reading data around '%d' at line number %ld %s for individual %d\nShould be a value of the %d covar (meaning 0 for the reference or 1. IMaCh does not build design variables, do it your self). Exiting.\n",lval,i,line,linei,j); |
|
exit(1); |
|
} |
|
covar[j][i]=(double)(lval); |
|
strcpy(line,stra); |
|
} |
|
lstra=strlen(stra); |
|
|
|
if(lstra > 9){ /* More than 2**32 or max of what printf can write with %ld */ |
|
stratrunc = &(stra[lstra-9]); |
|
num[i]=atol(stratrunc); |
|
} |
} |
else |
covar[j][i]=(double)(lval); |
num[i]=atol(stra); |
strcpy(line,stra); |
/*if((s[2][i]==2) && (s[3][i]==-1)&&(s[4][i]==9)){ |
} |
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])); ij=ij+1;}*/ |
lstra=strlen(stra); |
|
|
i=i+1; |
if(lstra > 9){ /* More than 2**32 or max of what printf can write with %ld */ |
|
stratrunc = &(stra[lstra-9]); |
|
num[i]=atol(stratrunc); |
|
} |
|
else |
|
num[i]=atol(stra); |
|
/*if((s[2][i]==2) && (s[3][i]==-1)&&(s[4][i]==9)){ |
|
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])); ij=ij+1;}*/ |
|
|
|
i=i+1; |
} /* End loop reading data */ |
} /* End loop reading data */ |
|
fclose(fic); |
/* printf("ii=%d", ij); |
/* printf("ii=%d", ij); |
scanf("%d",i);*/ |
scanf("%d",i);*/ |
imx=i-1; /* Number of individuals */ |
imx=i-1; /* Number of individuals */ |
Line 4715 int main(int argc, char *argv[])
|
Line 4733 int main(int argc, char *argv[])
|
printf("cptcovprod=%d ", cptcovprod); |
printf("cptcovprod=%d ", cptcovprod); |
fprintf(ficlog,"cptcovprod=%d ", cptcovprod); |
fprintf(ficlog,"cptcovprod=%d ", cptcovprod); |
|
|
scanf("%d ",i); |
scanf("%d ",i);*/ |
fclose(fic);*/ |
|
|
|
/* if(mle==1){*/ |
/* if(mle==1){*/ |
if (weightopt != 1) { /* Maximisation without weights*/ |
if (weightopt != 1) { /* Maximisation without weights*/ |
Line 4981 Interval (in months) between two waves:
|
Line 4998 Interval (in months) between two waves:
|
ximort[i][j]=(i == j ? 1.0 : 0.0); |
ximort[i][j]=(i == j ? 1.0 : 0.0); |
} |
} |
|
|
p[1]=0.1; p[NDIM]=0.1; |
p[1]=0.0268; p[NDIM]=0.083; |
/*printf("%lf %lf", p[1], p[2]);*/ |
/*printf("%lf %lf", p[1], p[2]);*/ |
|
|
|
|
Line 5600 Interval (in months) between two waves:
|
Line 5617 Interval (in months) between two waves:
|
free_ma3x(probs,1,AGESUP,1,NCOVMAX, 1,NCOVMAX); |
free_ma3x(probs,1,AGESUP,1,NCOVMAX, 1,NCOVMAX); |
|
|
} /* mle==-3 arrives here for freeing */ |
} /* mle==-3 arrives here for freeing */ |
|
free_matrix(prlim,1,nlstate,1,nlstate); |
free_matrix(pmmij,1,nlstate+ndeath,1,nlstate+ndeath); |
free_matrix(pmmij,1,nlstate+ndeath,1,nlstate+ndeath); |
free_matrix(oldms, 1,nlstate+ndeath,1,nlstate+ndeath); |
free_matrix(oldms, 1,nlstate+ndeath,1,nlstate+ndeath); |
free_matrix(newms, 1,nlstate+ndeath,1,nlstate+ndeath); |
free_matrix(newms, 1,nlstate+ndeath,1,nlstate+ndeath); |
free_matrix(savms, 1,nlstate+ndeath,1,nlstate+ndeath); |
free_matrix(savms, 1,nlstate+ndeath,1,nlstate+ndeath); |
|
|
free_matrix(covar,0,NCOVMAX,1,n); |
free_matrix(covar,0,NCOVMAX,1,n); |
free_matrix(matcov,1,npar,1,npar); |
free_matrix(matcov,1,npar,1,npar); |
/*free_vector(delti,1,npar);*/ |
/*free_vector(delti,1,npar);*/ |
Line 5619 Interval (in months) between two waves:
|
Line 5636 Interval (in months) between two waves:
|
free_ivector(Tage,1,15); |
free_ivector(Tage,1,15); |
free_ivector(Tcode,1,100); |
free_ivector(Tcode,1,100); |
|
|
|
free_imatrix(nbcode,0,NCOVMAX,0,NCOVMAX); |
|
free_imatrix(codtab,1,100,1,10); |
fflush(fichtm); |
fflush(fichtm); |
fflush(ficgp); |
fflush(ficgp); |
|
|
Line 5654 Interval (in months) between two waves:
|
Line 5672 Interval (in months) between two waves:
|
/*------ End -----------*/ |
/*------ End -----------*/ |
|
|
chdir(path); |
chdir(path); |
#ifndef UNIX |
|
/* strcpy(plotcmd,"\""); */ |
|
#endif |
|
strcpy(plotcmd,pathimach); |
|
/*strcat(plotcmd,CHARSEPARATOR);*/ |
/*strcat(plotcmd,CHARSEPARATOR);*/ |
strcat(plotcmd,GNUPLOTPROGRAM); |
sprintf(plotcmd,"gnuplot"); |
#ifndef UNIX |
#ifndef UNIX |
strcat(plotcmd,".exe"); |
sprintf(plotcmd,"\"%sgnuplot.exe\"",pathimach); |
/* strcat(plotcmd,"\"");*/ |
|
#endif |
#endif |
if(stat(plotcmd,&info)){ |
if(!stat(plotcmd,&info)){ |
printf("Error gnuplot program not found: %s\n",plotcmd);fflush(stdout); |
printf("Error 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); |
#ifndef UNIX |
}else |
strcpy(plotcmd,"\""); |
strcpy(pplotcmd,plotcmd); |
#endif |
#ifdef UNIX |
strcat(plotcmd,pathimach); |
strcpy(plotcmd,GNUPLOTPROGRAM); |
strcat(plotcmd,GNUPLOTPROGRAM); |
if(!stat(plotcmd,&info)){ |
#ifndef UNIX |
printf("Error gnuplot program not found: %s\n",plotcmd);fflush(stdout); |
strcat(plotcmd,".exe"); |
}else |
strcat(plotcmd,"\""); |
strcpy(pplotcmd,plotcmd); |
#endif |
#endif |
strcat(plotcmd," "); |
}else |
strcat(plotcmd,optionfilegnuplot); |
strcpy(pplotcmd,plotcmd); |
printf("Starting graphs with: %s",plotcmd);fflush(stdout); |
|
|
sprintf(plotcmd,"%s %s",pplotcmd, optionfilegnuplot); |
|
printf("Starting graphs with: %s\n",plotcmd);fflush(stdout); |
|
|
if((outcmd=system(plotcmd)) != 0){ |
if((outcmd=system(plotcmd)) != 0){ |
printf("\n Problem with gnuplot\n"); |
printf("\n Problem with gnuplot\n"); |