]> henry.ined.fr Git - .git/commitdiff
Summary: Merging with Visual C after suppressing some warnings for unused variables...
authorN. Brouard <brouard@ined.fr>
Tue, 16 Dec 2014 10:52:11 +0000 (10:52 +0000)
committerN. Brouard <brouard@ined.fr>
Tue, 16 Dec 2014 10:52:11 +0000 (10:52 +0000)
* imach.c (Module): Merging 1.61 to 1.162

src/imach.c

index 1aaee1b376b3a54309ed9e9d61998753ead7cbed..b0aa4a00626fa095fe803df6ce576dea25ac5822 100644 (file)
@@ -1,6 +1,9 @@
 /* $Id$
   $State$
   $Log$
+  Revision 1.163  2014/12/16 10:30:11  brouard
+  * imach.c (Module): Merging 1.61 to 1.162
+
   Revision 1.162  2014/09/25 11:43:39  brouard
   Summary: temporary backup 0.99!
 
@@ -554,7 +557,7 @@ typedef struct {
 #define YEARM 12. /**< Number of months per year */
 #define AGESUP 130
 #define AGEBASE 40
-#define AGEGOMP 10. /**< Minimal age for Gompertz adjustment */
+#define AGEGOMP 10 /**< Minimal age for Gompertz adjustment */
 #ifdef _WIN32
 #define DIRSEPARATOR '\\'
 #define CHARSEPARATOR "\\"
@@ -1146,7 +1149,7 @@ double brent(double ax, double bx, double cx, double (*f)(double), double tol,
   int iter; 
   double a,b,d,etemp;
   double fu=0,fv,fw,fx;
-  double ftemp;
+  double ftemp=0.;
   double p,q,r,tol1,tol2,u,v,w,x,xm; 
   double e=0.0; 
  
@@ -1380,8 +1383,8 @@ void powell(double p[], double **xi, int n, double ftol, int *iter, double *fret
       for (j=1;j<=n;j++) xit[j]=xi[j][i]; 
       fptt=(*fret); 
 #ifdef DEBUG
-      printf("fret=%lf \n",*fret);
-      fprintf(ficlog,"fret=%lf \n",*fret);
+         printf("fret=%lf, %lf, %lf \n", *fret, *fret, *fret);
+         fprintf(ficlog, "fret=%lf, %lf, %lf \n", *fret, *fret, *fret);
 #endif
       printf("%d",i);fflush(stdout);
       fprintf(ficlog,"%d",i);fflush(ficlog);
@@ -1478,6 +1481,8 @@ void powell(double p[], double **xi, int n, double ftol, int *iter, double *fret
        fprintf(ficlog,"Gaining to use average direction of P0 P%d instead of biggest increase direction :\n",n,ibig);
 
 #ifdef DEBUG
+       printf("Direction changed  last moved %d in place of ibig=%d, new last is the average:\n",n,ibig);
+       fprintf(ficlog,"Direction changed  last moved %d in place of ibig=%d, new last is the average:\n",n,ibig);
        for(j=1;j<=n;j++){
          printf(" %.12e",xit[j]);
          fprintf(ficlog," %.12e",xit[j]);
@@ -1574,7 +1579,7 @@ double **pmij(double **ps, double *cov, int ncovmodel, double *x, int nlstate )
   */
   double s1, lnpijopii;
   /*double t34;*/
-  int i,j,j1, nc, ii, jj;
+  int i,j, nc, ii, jj;
 
     for(i=1; i<= nlstate; i++){
       for(j=1; j<i;j++){
@@ -2213,7 +2218,7 @@ void hesscov(double **matcov, double p[], int npar, double delti[], double ftolh
 {
   double  **a,**y,*x,pd;
   double **hess;
-  int i, j,jk;
+  int i, j;
   int *indx;
 
   double hessii(double p[], double delta, int theta, double delti[],double (*func)(double []),int npar);
@@ -2347,7 +2352,7 @@ double hessii(double x[], double delta, int theta, double delti[], double (*func
        k=kmax;
       }
       else if((k1 >khi/nkhif) || (k2 >khi/nkhif)){ /* Keeps lastvalue before 3.84/2 KHI2 5% 1d.f. */
-       k=kmax; l=lmax*10.;
+       k=kmax; l=lmax*10;
       }
       else if((k1 >khi/nkhi) || (k2 >khi/nkhi)){ 
        delts=delt;
@@ -2362,7 +2367,7 @@ double hessii(double x[], double delta, int theta, double delti[], double (*func
 double hessij( double x[], double delti[], int thetai,int thetaj,double (*func)(double []),int npar)
 {
   int i;
-  int l=1, l1, lmax=20;
+  int l=1, lmax=20;
   double k1,k2,k3,k4,res,fx;
   double p2[MAXPARM+1];
   int k;
@@ -2477,7 +2482,7 @@ void pstamp(FILE *fichier)
 void  freqsummary(char fileres[], int iagemin, int iagemax, int **s, double **agev, int nlstate, int imx, int *Tvaraff, int **nbcode, int *ncodemax,double **mint,double **anint, char strstart[])
 {  /* Some frequencies */
   
-  int i, m, jk, k1,i1, j1, bool, z1,j;
+  int i, m, jk, j1, bool, z1,j;
   int first;
   double ***freq; /* Frequencies */
   double *pp, **prop;
@@ -2658,10 +2663,10 @@ void prevalence(double ***probs, double agemin, double agemax, int **s, double *
      We still use firstpass and lastpass as another selection.
   */
  
-  int i, m, jk, k1, i1, j1, bool, z1,j;
-  double ***freq; /* Frequencies */
-  double *pp, **prop;
-  double pos,posprop; 
+  int i, m, jk, j1, bool, z1,j;
+
+  double **prop;
+  double posprop; 
   double  y2; /* in fractional years */
   int iagemin, iagemax;
   int first; /** to stop verbosity which is redirected to log file */
@@ -2752,7 +2757,7 @@ void  concatwav(int wav[], int **dh, int **bh,  int **mw, int **s, double *agedc
   int j, k=0,jk, ju, jl;
   double sum=0.;
   first=0;
-  jmin=1e+5;
+  jmin=100000;
   jmax=-1;
   jmean=0.;
   for(i=1; i<=imx; i++){
@@ -2992,7 +2997,7 @@ void evsij(double ***eij, double x[], int nlstate, int stepm, int bage, int fage
 
 {
   /* Health expectancies, no variances */
-  int i, j, nhstepm, hstepm, h, nstepm, k, cptj, cptj2, i2, j2;
+  int i, j, nhstepm, hstepm, h, nstepm;
   int nhstepma, nstepma; /* Decreasing with age */
   double age, agelim, hf;
   double ***p3mat;
@@ -3314,7 +3319,7 @@ void varevsij(char optionfilefiname[], double ***vareij, double **matcov, double
   double **dnewm,**doldm;
   double **dnewmp,**doldmp;
   int i, j, nhstepm, hstepm, h, nstepm ;
-  int k, cptcode;
+  int k;
   double *xp;
   double **gp, **gm;  /* for var eij */
   double ***gradg, ***trgradg; /*for var eij */
@@ -3614,10 +3619,9 @@ void varprevlim(char fileres[], double **varpl, double **matcov, double x[], dou
 {
   /* Variance of prevalence limit */
   /*  double **prevalim(double **prlim, int nlstate, double *xp, double age, double **oldm, double **savm,double ftolpl);*/
-  double **newm;
+
   double **dnewm,**doldm;
   int i, j, nhstepm, hstepm;
-  int k, cptcode;
   double *xp;
   double *gp, *gm;
   double **gradg, **trgradg;
@@ -3696,9 +3700,9 @@ void varprevlim(char fileres[], double **varpl, double **matcov, double x[], dou
 /************ Variance of one-step probabilities  ******************/
 void varprob(char optionfilefiname[], double **matcov, double x[], double delti[], int nlstate, double bage, double fage, int ij, int *Tvar, int **nbcode, int *ncodemax, char strstart[])
 {
-  int i, j=0,  i1, k1, l1, t, tj;
+  int i, j=0,  k1, l1, tj;
   int k2, l2, j1,  z1;
-  int k=0,l, cptcode;
+  int k=0, l;
   int first=1, first1, first2;
   double cv12, mu1, mu2, lc1, lc2, v12, v21, v11, v22,v1,v2, c12, tnalp;
   double **dnewm,**doldm;
@@ -3706,7 +3710,7 @@ void varprob(char optionfilefiname[], double **matcov, double x[], double delti[
   double *gp, *gm;
   double **gradg, **trgradg;
   double **mu;
-  double age,agelim, cov[NCOVMAX+1];
+  double age, cov[NCOVMAX+1];
   double std=2.0; /* Number of standard deviation wide of confidence ellipsoids */
   int theta;
   char fileresprob[FILENAMELENGTH];
@@ -4078,7 +4082,7 @@ fprintf(fichtm," \n<ul><li><b>Graphs</b></li><p>");
 <img src=\"%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<=nlstate;cpt++){
-        fprintf(fichtm,"<br>- Convergence from each state (1 to %d) to period (stable) prevalence in state %d <a href=\"%s%d_%d.png\">%s%d_%d.png</a><br> \
+        fprintf(fichtm,"<br>- Convergence from cross-sectional prevalence in each state (1 to %d) to period (stable) prevalence in specific state %d <a href=\"%s%d_%d.png\">%s%d_%d.png</a><br> \
 <img src=\"%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++) {
@@ -4164,7 +4168,7 @@ true period expectancies (those weighted with period prevalences are also\
 void printinggnuplot(char fileres[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){
 
   char dirfileres[132],optfileres[132];
-  int m0,cpt=0,k1=0,i=0,k=0,j=0,jk=0,k2=0,k3=0,ij=0,l=0;
+  int cpt=0,k1=0,i=0,k=0,j=0,jk=0,k2=0,k3=0,ij=0,l=0;
   int ng=0;
 /*   if((ficgp=fopen(optionfilegnuplot,"a"))==NULL) { */
 /*     printf("Problem with file %s",optionfilegnuplot); */
@@ -4350,7 +4354,7 @@ plot [%.f:%.f]  ", ageminpar, agemaxpar);
        } /* end k2 */
      } /* end jk */
    } /* end ng */
- avoid:
+ /* avoid: */
    fflush(ficgp); 
 }  /* end gnuplot */
 
@@ -4404,8 +4408,7 @@ prevforecast(char fileres[], double anproj1, double mproj1, double jproj1, doubl
      dateprev1 dateprev2 range of dates during which prevalence is computed
      anproj2 year of en of projection (same day and month as proj1).
   */
-  int yearp, stepsize, hstepm, nhstepm, j, k, c, cptcod, i, h, i1;
-  int *popage;
+  int yearp, stepsize, hstepm, nhstepm, j, k, cptcod, i, h, i1;
   double agec; /* generic age */
   double agelim, ppij, yp,yp1,yp2,jprojmean,mprojmean,anprojmean;
   double *popeffectif,*popcount;
@@ -4699,8 +4702,8 @@ void prwizard(int ncovmodel, int nlstate, int ndeath,  char model[], FILE *ficpa
 
   /* Wizard to print covariance matrix template */
 
-  char ca[32], cb[32], cc[32];
-  int i,j, k, l, li, lj, lk, ll, jj, npar, itimes;
+  char ca[32], cb[32];
+  int i,j, k, li, lj, lk, ll, jj, npar, itimes;
   int numlinepar;
 
   printf("# Parameters nlstate*nlstate*ncov a12*1 + b12 * age + ...\n");
@@ -4921,7 +4924,7 @@ fprintf(fichtm,"<ul><li><h4>Life table</h4>\n <br>");
 void printinggnuplotmort(char fileres[], char optionfilefiname[], double ageminpar, double agemaxpar, double fage , char pathc[], double p[]){
 
   char dirfileres[132],optfileres[132];
-  int m,cpt,k1,i,k,j,jk,k2,k3,ij,l;
+
   int ng;
 
 
@@ -4946,10 +4949,10 @@ int readdata(char datafile[], int firstobs, int lastobs, int *imax)
   /*-------- data file ----------*/
   FILE *fic;
   char dummy[]="                         ";
-  int i, j, n;
+  int i=0, j=0, n=0;
   int linei, month, year,iout;
   char line[MAXLINE], linetmp[MAXLINE];
-  char stra[80], strb[80];
+  char stra[MAXLINE], strb[MAXLINE];
   char *stratrunc;
   int lstra;
 
@@ -4977,9 +4980,7 @@ int readdata(char datafile[], int firstobs, int lastobs, int *imax)
       continue;
     }
     trimbb(linetmp,line); /* Trims multiple blanks in line */
-    for (j=0; line[j]!='\0';j++){
-      line[j]=linetmp[j];
-    }
+    strcpy(line, linetmp);
   
 
     for (j=maxwav;j>=1;j--){
@@ -5118,7 +5119,7 @@ int readdata(char datafile[], int firstobs, int lastobs, int *imax)
   fclose(fic);
  
   return (0);
-  endread:
+  /* endread: */
     printf("Exiting readdata: ");
     fclose(fic);
     return (1);
@@ -5149,7 +5150,7 @@ int decodemodel ( char model[], int lastobs) /**< This routine decode the model
  */
 {
   int i, j, k, ks;
-  int i1, j1, k1, k2;
+  int  j1, k1, k2;
   char modelsav[80];
   char stra[80], strb[80], strc[80], strd[80],stre[80];
 
@@ -5298,7 +5299,7 @@ int decodemodel ( char model[], int lastobs) /**< This routine decode the model
 
 
   return (0); /* with covar[new additional covariate if product] and Tage if age */ 
-  endread:
+  /*endread:*/
     printf("Exiting decodemodel: ");
     return (1);
 }
@@ -5395,7 +5396,7 @@ calandcheckages(int imx, int maxwav, double *agemin, double *agemax, int *nberr,
   fprintf(ficlog,"Total number of individuals= %d, Agemin = %.2f, Agemax= %.2f\n\n", imx, *agemin, *agemax); 
 
   return (0);
-  endread:
+ /* endread:*/
     printf("Exiting calandcheckages: ");
     return (1);
 }
@@ -5415,38 +5416,35 @@ int main(int argc, char *argv[])
   double ssval;
 #endif
   int movingaverage(double ***probs, double bage,double fage, double ***mobaverage, int mobilav);
-  int i,j, k, n=MAXN,iter,m,size=100,cptcode, cptcod;
-  int linei, month, year,iout;
-  int jj, ll, li, lj, lk, imk;
+  int i,j, k, n=MAXN,iter=0,m,size=100, cptcod;
+
+  int jj, ll, li, lj, lk;
   int numlinepar=0; /* Current linenumber of parameter file */
   int itimes;
   int NDIM=2;
   int vpopbased=0;
 
-  char ca[32], cb[32], cc[32];
+  char ca[32], cb[32];
   /*  FILE *fichtm; *//* Html File */
   /* FILE *ficgp;*/ /*Gnuplot File */
   struct stat info;
-  double agedeb, agefin,hf;
+  double agedeb;
   double ageminpar=1.e20,agemin=1.e20, agemaxpar=-1.e20, agemax=-1.e20;
 
-  double fret;
-  double **xi,tmp,delta;
 
   double dum; /* Dummy variable */
   double ***p3mat;
   double ***mobaverage;
-  int *indx;
-  char line[MAXLINE], linepar[MAXLINE];
+
+  char line[MAXLINE];
   char path[MAXLINE],pathc[MAXLINE],pathcd[MAXLINE],pathtot[MAXLINE],model[MAXLINE];
   char pathr[MAXLINE], pathimach[MAXLINE]; 
-  char **bp, *tok, *val; /* pathtot */
+  char *tok, *val; /* pathtot */
   int firstobs=1, lastobs=10;
-  int sdeb, sfin; /* Status at beginning and end */
-  int c,  h , cpt,l;
-  int ju,jl, mi;
-  int i1,j1, jk,aa,bb, stepsize, ij;
-  int jnais,jdc,jint4,jint1,jint2,jint3,*tab; 
+  int c,  h , cpt;
+  int jl;
+  int i1, j1, jk, stepsize;
+  int *tab; 
   int mobilavproj=0 , prevfcast=0 ; /* moving average of prev, If prevfcast=1 prevalence projection */
   int mobilav=0,popforecast=0;
   int hstepm, nhstepm;
@@ -5455,7 +5453,7 @@ int main(int argc, char *argv[])
   double jprev1=1, mprev1=1,anprev1=2000,jprev2=1, mprev2=1,anprev2=2000;
   double jpyram=1, mpyram=1,anpyram=2000,jpyram1=1, mpyram1=1,anpyram1=2000;
 
-  double bage, fage, age, agelim, agebase;
+  double bage=0, fage=110, age, agelim, agebase;
   double ftolpl=FTOL;
   double **prlim;
   double ***param; /* Matrix of parameters */
@@ -5466,19 +5464,18 @@ int main(int argc, char *argv[])
   double ***eij, ***vareij;
   double **varpl; /* Variances of prevalence limits by age */
   double *epj, vepp;
-  double kk1, kk2;
+
   double dateprev1, dateprev2,jproj1=1,mproj1=1,anproj1=2000,jproj2=1,mproj2=1,anproj2=2000;
   double **ximort;
   char *alph[]={"a","a","b","c","d","e"}, str[4]="1234";
   int *dcwave;
 
-  char z[1]="c", occ;
+  char z[1]="c";
 
   /*char  *strt;*/
   char strtend[80];
 
-  long total_usecs;
+
 /*   setlocale (LC_ALL, ""); */
 /*   bindtextdomain (PACKAGE, LOCALEDIR); */
 /*   textdomain (PACKAGE); */
@@ -5749,7 +5746,7 @@ run imach with mle=-1 to get a correct template of the parameter file.\n",numlin
     for(i=1; i <=nlstate; i++){
       for(j=1; j <=nlstate+ndeath-1; j++){
        fscanf(ficpar,"%1d%1d",&i1,&j1);
-       if ((i1-i)*(j1-j)!=0){
+       if ( (i1-i) * (j1-j) != 0){
          printf("Error in line parameters number %d, %1d%1d instead of %1d%1d \n",numlinepar, i,j, i1, j1);
          exit(1);
        }
@@ -6784,7 +6781,7 @@ Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf<br>\n",\
     if (mobilav!=0) free_ma3x(mobaverage,1, AGESUP,1,NCOVMAX, 1,NCOVMAX);
     free_ma3x(probs,1,AGESUP,1,NCOVMAX, 1,NCOVMAX);
   }  /* mle==-3 arrives here for freeing */
- endfree:
+ /* endfree:*/
     free_matrix(prlim,1,nlstate,1,nlstate); /*here or after loop ? */
     free_matrix(pmmij,1,nlstate+ndeath,1,nlstate+ndeath);
     free_matrix(oldms, 1,nlstate+ndeath,1,nlstate+ndeath);