--- imach/src/imach.c 2006/01/25 20:38:18 1.111 +++ imach/src/imach.c 2006/02/27 12:17:45 1.115 @@ -1,6 +1,21 @@ -/* $Id: imach.c,v 1.111 2006/01/25 20:38:18 brouard Exp $ +/* $Id: imach.c,v 1.115 2006/02/27 12:17:45 brouard Exp $ $State: Exp $ $Log: imach.c,v $ + Revision 1.115 2006/02/27 12:17:45 brouard + (Module): One freematrix added in mlikeli! 0.98c + + Revision 1.114 2006/02/26 12:57:58 brouard + (Module): Some improvements in processing parameter + filename with strsep. + + 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 @@ -289,11 +304,11 @@ extern int errno; #define ODIRSEPARATOR '/' #endif -/* $Id: imach.c,v 1.111 2006/01/25 20:38:18 brouard Exp $ */ +/* $Id: imach.c,v 1.115 2006/02/27 12:17:45 brouard Exp $ */ /* $State: Exp $ */ -char version[]="Imach version 0.98b, January 2006, INED-EUROREVES "; -char fullversion[]="$Revision: 1.111 $ $Date: 2006/01/25 20:38:18 $"; +char version[]="Imach version 0.98c, February 2006, INED-EUROREVES "; +char fullversion[]="$Revision: 1.115 $ $Date: 2006/02/27 12:17:45 $"; int erreur, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ int nvar; int cptcovn=0, cptcovage=0, cptcoveff=0,cptcov; @@ -1656,6 +1671,7 @@ void mlikeli(FILE *ficres,double p[], in powell(p,xi,npar,ftol,&iter,&fret,func); + free_matrix(xi,1,npar,1,npar); fclose(ficrespow); printf("\n#Number of iterations = %d, -2 Log likelihood = %.12f\n",iter,func(p)); fprintf(ficlog,"\n#Number of iterations = %d, -2 Log likelihood = %.12f \n",iter,func(p)); @@ -3231,6 +3247,8 @@ To be simple, these graphs help to under } 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(doldm,1,(nlstate)*(nlstate+ndeath),1,(nlstate)*(nlstate+ndeath)); + free_matrix(dnewm,1,(nlstate)*(nlstate+ndeath),1,npar); free_vector(xp,1,npar); fclose(ficresprob); fclose(ficresprobcov); @@ -4131,6 +4149,7 @@ int main(int argc, char *argv[]) char line[MAXLINE], linepar[MAXLINE]; char path[MAXLINE],pathc[MAXLINE],pathcd[MAXLINE],pathtot[MAXLINE],model[MAXLINE]; char pathr[MAXLINE], pathimach[MAXLINE]; + char **bp, *tok, *val; /* pathtot */ int firstobs=1, lastobs=10; int sdeb, sfin; /* Status at beginning and end */ int c, h , cpt,l; @@ -4208,7 +4227,17 @@ int main(int argc, char *argv[]) printf("\n%s\n%s",version,fullversion); if(argc <=1){ printf("\nEnter the parameter file name: "); - scanf("%s",pathtot); + fgets(pathr,FILENAMELENGTH,stdin); + i=strlen(pathr); + if(pathr[i-1]=='\n') + pathr[i-1]='\0'; + for (tok = pathr; tok != NULL; ){ + printf("Pathr |%s|\n",pathr); + while ((val = strsep(&tok, "\"" )) != NULL && *val == '\0'); + printf("val= |%s| pathr=%s\n",val,pathr); + strcpy (pathtot, val); + if(pathr[0] == '\0') break; /* Un peu sale */ + } } else{ strcpy(pathtot,argv[1]); @@ -4625,6 +4654,7 @@ int main(int argc, char *argv[]) i=i+1; } /* End loop reading data */ + fclose(fic); /* printf("ii=%d", ij); scanf("%d",i);*/ imx=i-1; /* Number of individuals */ @@ -4722,8 +4752,7 @@ int main(int argc, char *argv[]) printf("cptcovprod=%d ", cptcovprod); fprintf(ficlog,"cptcovprod=%d ", cptcovprod); - scanf("%d ",i); - fclose(fic);*/ + scanf("%d ",i);*/ /* if(mle==1){*/ if (weightopt != 1) { /* Maximisation without weights*/ @@ -5607,11 +5636,11 @@ Interval (in months) between two waves: free_ma3x(probs,1,AGESUP,1,NCOVMAX, 1,NCOVMAX); } /* mle==-3 arrives here for freeing */ + free_matrix(prlim,1,nlstate,1,nlstate); free_matrix(pmmij,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(savms, 1,nlstate+ndeath,1,nlstate+ndeath); - free_matrix(covar,0,NCOVMAX,1,n); free_matrix(matcov,1,npar,1,npar); /*free_vector(delti,1,npar);*/ @@ -5626,7 +5655,8 @@ Interval (in months) between two waves: free_ivector(Tage,1,15); free_ivector(Tcode,1,100); - + free_imatrix(nbcode,0,NCOVMAX,0,NCOVMAX); + free_imatrix(codtab,1,100,1,10); fflush(fichtm); fflush(ficgp); @@ -5664,7 +5694,7 @@ Interval (in months) between two waves: /*strcat(plotcmd,CHARSEPARATOR);*/ sprintf(plotcmd,"gnuplot"); #ifndef UNIX - sprintf(plotcmd,"\"%swgnuplot.exe\"",pathimach); + sprintf(plotcmd,"\"%sgnuplot.exe\"",pathimach); #endif if(!stat(plotcmd,&info)){ printf("Error gnuplot program not found: %s\n",plotcmd);fflush(stdout);