--- imach/src/imach.c 2001/05/02 17:34:41 1.4 +++ imach/src/imach.c 2001/05/02 17:42:45 1.5 @@ -51,6 +51,10 @@ #define FILENAMELENGTH 80 /*#define DEBUG*/ #define windows +#define GLOCK_ERROR_NOPATH -1 /* empty path */ +#define GLOCK_ERROR_GETCWD -2 /* cannot get cwd */ + + #define MAXPARM 30 /* Maximum number of parameters for the optimization */ #define NPARMAX 64 /* (nlstate+ndeath-1)*nlstate*ncovmodel */ @@ -138,6 +142,41 @@ double ftol=FTOL; /* Tolerance for compu double ftolhess; /* Tolerance for computing hessian */ +static int split( char *path, char *dirc, char *name ) +{ + char *s; /* pointer */ + int l1, l2; /* length counters */ + + l1 = strlen( path ); /* length of path */ + if ( l1 == 0 ) return( GLOCK_ERROR_NOPATH ); + s = strrchr( path, '\\' ); /* find last / */ + if ( s == NULL ) { /* no directory, so use current */ +#if defined(__bsd__) /* get current working directory */ + extern char *getwd( ); + + if ( getwd( dirc ) == NULL ) { +#else + extern char *getcwd( ); + + if ( getcwd( dirc, FILENAME_MAX ) == NULL ) { +#endif + return( GLOCK_ERROR_GETCWD ); + } + strcpy( name, path ); /* we've got it */ + } else { /* strip direcotry from path */ + s++; /* after this, the filename */ + l2 = strlen( s ); /* length of filename */ + if ( l2 == 0 ) return( GLOCK_ERROR_NOPATH ); + strcpy( name, s ); /* save file name */ + strncpy( dirc, path, l1 - l2 ); /* now the directory */ + dirc[l1-l2] = 0; /* add zero */ + } + l1 = strlen( dirc ); /* length of directory */ + if ( dirc[l1-1] != '\\' ) { dirc[l1] = '\\'; dirc[l1+1] = 0; } + return( 0 ); /* we're done */ +} + + /******************************************/ void replace(char *s, char*t) @@ -1573,7 +1612,7 @@ int main() int sdeb, sfin; /* Status at beginning and end */ int c, h , cpt,l; int ju,jl, mi; - int i1,j1, k1,jk,aa,bb, stepsize; + int i1,j1, k1,k2,k3,jk,aa,bb, stepsize; int jnais,jdc,jint4,jint1,jint2,jint3,**outcome,**adl,*tab; int hstepm, nhstepm; @@ -1589,8 +1628,9 @@ int main() double ***eij, ***vareij; double **varpl; /* Variances of prevalence limits by age */ double *epj, vepp; - char version[80]="Imach version 0.64, May 2000, INED-EUROREVES "; + char version[80]="Imach version 62c, May 1999, INED-EUROREVES "; char *alph[]={"a","a","b","c","d","e"}, str[4]; + char z[1]="c", occ; #include #include @@ -1606,18 +1646,14 @@ int main() #ifdef windows scanf("%s",pathtot); - cygwin_split_path(pathtot,path,optionfile); - printf("pathtot=%s, path=%s, optionfile=%s\n",pathtot,path,optionfile); - chdir(path); - - /*size=30; - getcwd(pathcd, size); - printf("pathcd=%s, path=%s, optionfile=%s\n",pathcd,path,optionfile); - cutv(path,optionfile,pathtot,'\\'); + getcwd(pathcd, size); + /*cygwin_split_path(pathtot,path,optionfile); + printf("pathtot=%s, path=%s, optionfile=%s\n",pathtot,path,optionfile);*/ + /* cutv(path,optionfile,pathtot,'\\');*/ + +split(pathtot, path,optionfile); chdir(path); replace(pathc,path); - printf("pathtot=%s, path=%s, optionfile=%s\n",pathtot,path,optionfile); - */ #endif #ifdef unix scanf("%s",optionfile); @@ -1805,7 +1841,7 @@ int main() } num[i]=atol(stra); - /*printf("%d %.lf %.lf %.lf %.lf/%.lf %.lf/%.lf %.lf/%.lf %d %.lf/%.lf %d %.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]), (mint[5][i]), (anint[5][i]), (s[5][i]), (mint[6][i]), (anint[6][i]), (s[6][i]));*/ + /*printf("%d %.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]));*/ i=i+1; } @@ -1954,10 +1990,6 @@ Tcode=ivector(1,100); and prints on file fileres'p'. */ freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvar,nbcode, ncodemax); - - /*scanf("%d ",i);*/ - - pmmij= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ oldms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ newms= matrix(1,nlstate+ndeath,1,nlstate+ndeath); /* creation */ @@ -2054,7 +2086,7 @@ Tcode=ivector(1,100); /*------------ gnuplot -------------*/ chdir(pathcd); if((ficgp=fopen("graph.plt","w"))==NULL) { - printf("Problem with file graph.plt");goto end; + printf("Problem with file graph.gp");goto end; } #ifdef windows fprintf(ficgp,"cd \"%s\" \n",pathc); @@ -2126,7 +2158,7 @@ fprintf(ficgp,"\nset out \"v%s%d%d.gif\" /*3eme*/ - for (k1=1; k1<= m ; k1 ++) { + for (k1=1; k1<= m ; k1 ++) { for (cpt=1; cpt<= nlstate ; cpt ++) { k=2+nlstate*(cpt-1); fprintf(ficgp,"set ter gif small size 400,300\nplot [%.f:%.f] \"e%s\" every :::%d::%d u 1:%d t \"e%d1\" w l",agemin,fage,fileres,k1-1,k1-1,k,cpt); @@ -2135,10 +2167,10 @@ fprintf(ficgp,"\nset out \"v%s%d%d.gif\" } fprintf(ficgp,"\nset out \"exp%s%d%d.gif\" \nreplot\n\n",strtok(optionfile, "."),cpt,k1); } - } + } /* CV preval stat */ - for (k1=1; k1<= m ; k1 ++) { + for (k1=1; k1<= m ; k1 ++) { for (cpt=1; cpt
    Imach, Version 0.63
  • Outputs files

    \n + fprintf(fichtm,"
      Imach, Version 0.64a
    • Outputs files

      \n - Observed prevalence in each state: p%s
      \n - Estimated parameters and the covariance matrix: %s
      - Stationary prevalence in each state: pl%s
      @@ -2276,7 +2314,7 @@ interval) in state (%d): v%s%d%d.gif
      - Health life expectancies by age and initial health state (%d): exp%s%d%d.gif
      -",cpt,strtok(optionfile, "."),cpt,j1,strtok(optionfile, "."),cpt,j1); +",cpt,strtok(optionfile, "."),cpt,j1,strtok(optionfile, "."),cpt,j1); } fprintf(fichtm,"\n
      - Total life expectancy by age and health expectancies in states (1) and (2): e%s%d.gif
      @@ -2464,7 +2502,7 @@ fclose(fichtm); fclose(ficrest); fclose(ficpar); free_vector(epj,1,nlstate+1); - /*scanf("%d ",i); */ + /* scanf("%d ",i); */ /*------- Variance limit prevalence------*/