Diff for /imach/src/imach.c between versions 1.166 and 1.171

version 1.166, 2014/12/22 11:40:47 version 1.171, 2014/12/23 13:26:59
Line 1 Line 1
 /* $Id$  /* $Id$
   $State$    $State$
   $Log$    $Log$
     Revision 1.171  2014/12/23 13:26:59  brouard
     Summary: Back from Visual C
   
     Still problem with utsname.h on Windows
   
     Revision 1.170  2014/12/23 11:17:12  brouard
     Summary: Cleaning some \%% back to %%
   
     The escape was mandatory for a specific compiler (which one?), but too many warnings.
   
     Revision 1.169  2014/12/22 23:08:31  brouard
     Summary: 0.98p
   
     Outputs some informations on compiler used, OS etc. Testing on different platforms.
   
     Revision 1.168  2014/12/22 15:17:42  brouard
     Summary: update
   
     Revision 1.167  2014/12/22 13:50:56  brouard
     Summary: Testing uname and compiler version and if compiled 32 or 64
   
     Testing on Linux 64
   
   Revision 1.166  2014/12/22 11:40:47  brouard    Revision 1.166  2014/12/22 11:40:47  brouard
   *** empty log message ***    *** empty log message ***
   
Line 520 Line 543
   
 #include <limits.h>  #include <limits.h>
 #include <sys/types.h>  #include <sys/types.h>
   
   #if defined(__GNUC__)
   #include <sys/utsname.h> /* Doesn't work on Windows */
   #endif
   
 #include <sys/stat.h>  #include <sys/stat.h>
 #include <errno.h>  #include <errno.h>
 /* extern int errno; */  /* extern int errno; */
Line 538 Line 566
 #include <gsl/gsl_multimin.h>  #include <gsl/gsl_multimin.h>
 #endif  #endif
   
   
 #ifdef NLOPT  #ifdef NLOPT
 #include <nlopt.h>  #include <nlopt.h>
 typedef struct {  typedef struct {
Line 583  typedef struct { Line 612  typedef struct {
 /* $Id$ */  /* $Id$ */
 /* $State$ */  /* $State$ */
   
 char version[]="Imach version 0.99, September 2014,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121)";  char version[]="Imach version 0.98p, December 2014,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015";
 char fullversion[]="$Revision$ $Date$";   char fullversion[]="$Revision$ $Date$"; 
 char strstart[80];  char strstart[80];
 char optionfilext[10], optionfilefiname[FILENAMELENGTH];  char optionfilext[10], optionfilefiname[FILENAMELENGTH];
Line 1495  void powell(double p[], double **xi, int Line 1524  void powell(double p[], double **xi, int
           xi[j][n]=xit[j];      /* and nth direction by the extrapolated */            xi[j][n]=xit[j];      /* and nth direction by the extrapolated */
         }          }
         printf("Gaining to use average direction of P0 P%d instead of biggest increase direction %d :\n",n,ibig);          printf("Gaining to use average direction of P0 P%d instead of biggest increase direction %d :\n",n,ibig);
         fprintf(ficlog,"Gaining to use average direction of P0 P%d instead of biggest increase direction :\n",n,ibig);          fprintf(ficlog,"Gaining to use average direction of P0 P%d instead of biggest increase direction %d :\n",n,ibig);
   
 #ifdef DEBUG  #ifdef DEBUG
         printf("Direction changed  last moved %d in place of ibig=%d, new last is the average:\n",n,ibig);          printf("Direction changed  last moved %d in place of ibig=%d, new last is the average:\n",n,ibig);
Line 1518  double **prevalim(double **prlim, int nl Line 1547  double **prevalim(double **prlim, int nl
 {  {
   /* Computes the prevalence limit in each live state at age x by left multiplying the unit    /* Computes the prevalence limit in each live state at age x by left multiplying the unit
      matrix by transitions matrix until convergence is reached */       matrix by transitions matrix until convergence is reached */
     
   int i, ii,j,k;    int i, ii,j,k;
   double min, max, maxmin, maxmax,sumnew=0.;    double min, max, maxmin, maxmax,sumnew=0.;
   /* double **matprod2(); */ /* test */    /* double **matprod2(); */ /* test */
   double **out, cov[NCOVMAX+1], **pmij();    double **out, cov[NCOVMAX+1], **pmij();
   double **newm;    double **newm;
   double agefin, delaymax=50 ; /* Max number of years to converge */    double agefin, delaymax=50 ; /* Max number of years to converge */
     
   for (ii=1;ii<=nlstate+ndeath;ii++)    for (ii=1;ii<=nlstate+ndeath;ii++)
     for (j=1;j<=nlstate+ndeath;j++){      for (j=1;j<=nlstate+ndeath;j++){
       oldm[ii][j]=(ii==j ? 1.0 : 0.0);        oldm[ii][j]=(ii==j ? 1.0 : 0.0);
     }      }
     
    cov[1]=1.;    cov[1]=1.;
      
  /* Even if hstepm = 1, at least one multiplication by the unit matrix */    /* Even if hstepm = 1, at least one multiplication by the unit matrix */
   for(agefin=age-stepm/YEARM; agefin>=age-delaymax; agefin=agefin-stepm/YEARM){    for(agefin=age-stepm/YEARM; agefin>=age-delaymax; agefin=agefin-stepm/YEARM){
     newm=savm;      newm=savm;
     /* Covariates have to be included here again */      /* Covariates have to be included here again */
Line 1570  double **prevalim(double **prlim, int nl Line 1599  double **prevalim(double **prlim, int nl
       }        }
       maxmin=max-min;        maxmin=max-min;
       maxmax=FMAX(maxmax,maxmin);        maxmax=FMAX(maxmax,maxmin);
     }      } /* j loop */
     if(maxmax < ftolpl){      if(maxmax < ftolpl){
       return prlim;        return prlim;
     }      }
   }    } /* age loop */
     return prlim; /* should not reach here */
 }  }
   
 /*************** transition probabilities ***************/   /*************** transition probabilities ***************/ 
Line 2523  void  freqsummary(char fileres[], int ia Line 2553  void  freqsummary(char fileres[], int ia
   
   first=1;    first=1;
   
   /* for(k1=1; k1<=j ; k1++){   /* Loop on covariates */    /* for(k1=1; k1<=j ; k1++){ */  /* Loop on covariates */
   /*  for(i1=1; i1<=ncodemax[k1];i1++){ /* Now it is 2 */    /*  for(i1=1; i1<=ncodemax[k1];i1++){ */ /* Now it is 2 */
   /*    j1++;    /*    j1++; */
 */  
   for (j1 = 1; j1 <= (int) pow(2,cptcoveff); j1++){    for (j1 = 1; j1 <= (int) pow(2,cptcoveff); j1++){
       /*printf("cptcoveff=%d Tvaraff=%d", cptcoveff,Tvaraff[1]);        /*printf("cptcoveff=%d Tvaraff=%d", cptcoveff,Tvaraff[1]);
         scanf("%d", i);*/          scanf("%d", i);*/
Line 2903  void tricode(int *Tvar, int **nbcode, in Line 2932  void tricode(int *Tvar, int **nbcode, in
 {  {
   /**< Uses cptcovn+2*cptcovprod as the number of covariates */    /**< Uses cptcovn+2*cptcovprod as the number of covariates */
   /*      Tvar[i]=atoi(stre);  find 'n' in Vn and stores in Tvar. If model=V2+V1 Tvar[1]=2 and Tvar[2]=1     /*      Tvar[i]=atoi(stre);  find 'n' in Vn and stores in Tvar. If model=V2+V1 Tvar[1]=2 and Tvar[2]=1 
   /* Boring subroutine which should only output nbcode[Tvar[j]][k]     * Boring subroutine which should only output nbcode[Tvar[j]][k]
    * Tvar[5] in V2+V1+V3*age+V2*V4 is 2 (V2)     * Tvar[5] in V2+V1+V3*age+V2*V4 is 2 (V2)
   /* nbcode[Tvar[j]][1]=      * nbcode[Tvar[j]][1]= 
   */    */
   
   int ij=1, k=0, j=0, i=0, maxncov=NCOVMAX;    int ij=1, k=0, j=0, i=0, maxncov=NCOVMAX;
Line 3333  void varevsij(char optionfilefiname[], d Line 3362  void varevsij(char optionfilefiname[], d
   /* Variance of health expectancies */    /* Variance of health expectancies */
   /*  double **prevalim(double **prlim, int nlstate, double *xp, double age, double **oldm, double ** savm,double ftolpl);*/    /*  double **prevalim(double **prlim, int nlstate, double *xp, double age, double **oldm, double ** savm,double ftolpl);*/
   /* double **newm;*/    /* double **newm;*/
     /* int movingaverage(double ***probs, double bage,double fage, double ***mobaverage, int mobilav)*/
     
     int movingaverage();
   double **dnewm,**doldm;    double **dnewm,**doldm;
   double **dnewmp,**doldmp;    double **dnewmp,**doldmp;
   int i, j, nhstepm, hstepm, h, nstepm ;    int i, j, nhstepm, hstepm, h, nstepm ;
Line 3610  void varevsij(char optionfilefiname[], d Line 3642  void varevsij(char optionfilefiname[], d
 /*   fprintf(ficgp,"\n replot \"%s\"  u 1:(($3+1.96*$4)*%6.3f) t \"95\%% interval\" w l 2 ",fileresprobmorprev,YEARM/estepm); */  /*   fprintf(ficgp,"\n replot \"%s\"  u 1:(($3+1.96*$4)*%6.3f) t \"95\%% interval\" w l 2 ",fileresprobmorprev,YEARM/estepm); */
 /*   fprintf(ficgp,"\n replot \"%s\"  u 1:(($3-1.96*$4)*%6.3f) not w l 2 ",fileresprobmorprev,YEARM/estepm); */  /*   fprintf(ficgp,"\n replot \"%s\"  u 1:(($3-1.96*$4)*%6.3f) not w l 2 ",fileresprobmorprev,YEARM/estepm); */
   fprintf(ficgp,"\n plot \"%s\"  u 1:($3) not w l lt 1 ",subdirf(fileresprobmorprev));    fprintf(ficgp,"\n plot \"%s\"  u 1:($3) not w l lt 1 ",subdirf(fileresprobmorprev));
   fprintf(ficgp,"\n replot \"%s\"  u 1:(($3+1.96*$4)) t \"95\%% interval\" w l lt 2 ",subdirf(fileresprobmorprev));    fprintf(ficgp,"\n replot \"%s\"  u 1:(($3+1.96*$4)) t \"95%% interval\" w l lt 2 ",subdirf(fileresprobmorprev));
   fprintf(ficgp,"\n replot \"%s\"  u 1:(($3-1.96*$4)) not w l lt 2 ",subdirf(fileresprobmorprev));    fprintf(ficgp,"\n replot \"%s\"  u 1:(($3-1.96*$4)) not w l lt 2 ",subdirf(fileresprobmorprev));
   fprintf(fichtm,"\n<br> File (multiple files are possible if covariates are present): <A href=\"%s\">%s</a>\n",subdirf(fileresprobmorprev),subdirf(fileresprobmorprev));    fprintf(fichtm,"\n<br> File (multiple files are possible if covariates are present): <A href=\"%s\">%s</a>\n",subdirf(fileresprobmorprev),subdirf(fileresprobmorprev));
   fprintf(fichtm,"\n<br> Probability is computed over estepm=%d months. <br> <img src=\"%s%s.png\"> <br>\n", estepm,subdirf3(optionfilefiname,"varmuptjgr",digitp),digit);    fprintf(fichtm,"\n<br> Probability is computed over estepm=%d months. <br> <img src=\"%s%s.png\"> <br>\n", estepm,subdirf3(optionfilefiname,"varmuptjgr",digitp),digit);
Line 4031  To be simple, these graphs help to under Line 4063  To be simple, these graphs help to under
           } /* k12 */            } /* k12 */
         } /*l1 */          } /*l1 */
       }/* k1 */        }/* k1 */
       /* } /* loop covariates */        /* } */ /* loop covariates */
   }    }
   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);
Line 4208  void printinggnuplot(char fileres[], cha Line 4240  void printinggnuplot(char fileres[], cha
      fprintf(ficgp,"set xlabel \"Age\" \n\       fprintf(ficgp,"set xlabel \"Age\" \n\
 set ylabel \"Probability\" \n\  set ylabel \"Probability\" \n\
 set ter png small size 320, 240\n\  set ter png small size 320, 240\n\
 plot [%.f:%.f] \"%s\" every :::%d::%d u 1:2 \"\%%lf",ageminpar,fage,subdirf2(fileres,"vpl"),k1-1,k1-1);  plot [%.f:%.f] \"%s\" every :::%d::%d u 1:2 \"%%lf",ageminpar,fage,subdirf2(fileres,"vpl"),k1-1,k1-1);
   
      for (i=1; i<= nlstate ; i ++) {       for (i=1; i<= nlstate ; i ++) {
        if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");         if (i==cpt) fprintf(ficgp," %%lf (%%lf)");
        else        fprintf(ficgp," \%%*lf (\%%*lf)");         else        fprintf(ficgp," %%*lf (%%*lf)");
      }       }
      fprintf(ficgp,"\" t\"Period (stable) prevalence\" w l lt 0,\"%s\" every :::%d::%d u 1:($2+1.96*$3) \"\%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1);       fprintf(ficgp,"\" t\"Period (stable) prevalence\" w l lt 0,\"%s\" every :::%d::%d u 1:($2+1.96*$3) \"%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1);
      for (i=1; i<= nlstate ; i ++) {       for (i=1; i<= nlstate ; i ++) {
        if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");         if (i==cpt) fprintf(ficgp," %%lf (%%lf)");
        else fprintf(ficgp," \%%*lf (\%%*lf)");         else fprintf(ficgp," %%*lf (%%*lf)");
      }        } 
      fprintf(ficgp,"\" t\"95\%% CI\" w l lt 1,\"%s\" every :::%d::%d u 1:($2-1.96*$3) \"\%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1);        fprintf(ficgp,"\" t\"95%% CI\" w l lt 1,\"%s\" every :::%d::%d u 1:($2-1.96*$3) \"%%lf",subdirf2(fileres,"vpl"),k1-1,k1-1); 
      for (i=1; i<= nlstate ; i ++) {       for (i=1; i<= nlstate ; i ++) {
        if (i==cpt) fprintf(ficgp," \%%lf (\%%lf)");         if (i==cpt) fprintf(ficgp," %%lf (%%lf)");
        else fprintf(ficgp," \%%*lf (\%%*lf)");         else fprintf(ficgp," %%*lf (%%*lf)");
      }         }  
      fprintf(ficgp,"\" t\"\" w l lt 1,\"%s\" every :::%d::%d u 1:($%d) t\"Observed prevalence \" w l lt 2",subdirf2(fileres,"p"),k1-1,k1-1,2+4*(cpt-1));       fprintf(ficgp,"\" t\"\" w l lt 1,\"%s\" every :::%d::%d u 1:($%d) t\"Observed prevalence \" w l lt 2",subdirf2(fileres,"p"),k1-1,k1-1,2+4*(cpt-1));
    }     }
Line 4235  plot [%.f:%.f] \"%s\" every :::%d::%d u Line 4267  plot [%.f:%.f] \"%s\" every :::%d::%d u
           
     for (i=1; i<= nlstate+1 ; i ++) {      for (i=1; i<= nlstate+1 ; i ++) {
       k=2*i;        k=2*i;
       fprintf(ficgp,"\"%s\" every :::%d::%d u 1:2 \"\%%lf",subdirf2(fileres,"t"),k1-1,k1-1);        fprintf(ficgp,"\"%s\" every :::%d::%d u 1:2 \"%%lf",subdirf2(fileres,"t"),k1-1,k1-1);
       for (j=1; j<= nlstate+1 ; j ++) {        for (j=1; j<= nlstate+1 ; j ++) {
         if (j==i) fprintf(ficgp," \%%lf (\%%lf)");          if (j==i) fprintf(ficgp," %%lf (%%lf)");
         else fprintf(ficgp," \%%*lf (\%%*lf)");          else fprintf(ficgp," %%*lf (%%*lf)");
       }           }   
       if (i== 1) fprintf(ficgp,"\" t\"TLE\" w l ,");        if (i== 1) fprintf(ficgp,"\" t\"TLE\" w l ,");
       else fprintf(ficgp,"\" t\"LE in state (%d)\" w l ,",i-1);        else fprintf(ficgp,"\" t\"LE in state (%d)\" w l ,",i-1);
       fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2-$3*2) \"\%%lf",subdirf2(fileres,"t"),k1-1,k1-1);        fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2-$3*2) \"%%lf",subdirf2(fileres,"t"),k1-1,k1-1);
       for (j=1; j<= nlstate+1 ; j ++) {        for (j=1; j<= nlstate+1 ; j ++) {
         if (j==i) fprintf(ficgp," \%%lf (\%%lf)");          if (j==i) fprintf(ficgp," %%lf (%%lf)");
         else fprintf(ficgp," \%%*lf (\%%*lf)");          else fprintf(ficgp," %%*lf (%%*lf)");
       }           }   
       fprintf(ficgp,"\" t\"\" w l lt 0,");        fprintf(ficgp,"\" t\"\" w l lt 0,");
       fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2+$3*2) \"\%%lf",subdirf2(fileres,"t"),k1-1,k1-1);        fprintf(ficgp,"\"%s\" every :::%d::%d u 1:($2+$3*2) \"%%lf",subdirf2(fileres,"t"),k1-1,k1-1);
       for (j=1; j<= nlstate+1 ; j ++) {        for (j=1; j<= nlstate+1 ; j ++) {
         if (j==i) fprintf(ficgp," \%%lf (\%%lf)");          if (j==i) fprintf(ficgp," %%lf (%%lf)");
         else fprintf(ficgp," \%%*lf (\%%*lf)");          else fprintf(ficgp," %%*lf (%%*lf)");
       }           }   
       if (i== (nlstate+1)) fprintf(ficgp,"\" t\"\" w l lt 0");        if (i== (nlstate+1)) fprintf(ficgp,"\" t\"\" w l lt 0");
       else fprintf(ficgp,"\" t\"\" w l lt 0,");        else fprintf(ficgp,"\" t\"\" w l lt 0,");
Line 4419  int movingaverage(double ***probs, doubl Line 4451  int movingaverage(double ***probs, doubl
   
   
 /************** Forecasting ******************/  /************** Forecasting ******************/
 prevforecast(char fileres[], double anproj1, double mproj1, double jproj1, double ageminpar, double agemax, double dateprev1, double dateprev2, int mobilav, double bage, double fage, int firstpass, int lastpass, double anproj2, double p[], int cptcoveff){  void prevforecast(char fileres[], double anproj1, double mproj1, double jproj1, double ageminpar, double agemax, double dateprev1, double dateprev2, int mobilav, double bage, double fage, int firstpass, int lastpass, double anproj2, double p[], int cptcoveff){
   /* proj1, year, month, day of starting projection     /* proj1, year, month, day of starting projection 
      agemin, agemax range of age       agemin, agemax range of age
      dateprev1 dateprev2 range of dates during which prevalence is computed       dateprev1 dateprev2 range of dates during which prevalence is computed
Line 4542  prevforecast(char fileres[], double anpr Line 4574  prevforecast(char fileres[], double anpr
 }  }
   
 /************** Forecasting *****not tested NB*************/  /************** Forecasting *****not tested NB*************/
 populforecast(char fileres[], double anpyram,double mpyram,double jpyram,double ageminpar, double agemax,double dateprev1, double dateprev2, int mobilav, double agedeb, double fage, int popforecast, char popfile[], double anpyram1,double p[], int i2){  void populforecast(char fileres[], double anpyram,double mpyram,double jpyram,double ageminpar, double agemax,double dateprev1, double dateprev2, int mobilav, double agedeb, double fage, int popforecast, char popfile[], double anpyram1,double p[], int i2){
       
   int cpt, stepsize, hstepm, nhstepm, j,k,c, cptcod, i,h;    int cpt, stepsize, hstepm, nhstepm, j,k,c, cptcod, i,h;
   int *popage;    int *popage;
Line 5018  int readdata(char datafile[], int firsto Line 5050  int readdata(char datafile[], int firsto
               
       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,"%s.",dummy) != 0){        else  if( (iout=sscanf(strb,"%s.",dummy)) != 0){
         month=99;          month=99;
         year=9999;          year=9999;
       }else{        }else{
Line 5034  int readdata(char datafile[], int firsto Line 5066  int readdata(char datafile[], int firsto
     } /* ENd Waves */      } /* ENd Waves */
           
     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,"%s.",dummy) != 0){      else  if( (iout=sscanf(strb,"%s.",dummy)) != 0){
       month=99;        month=99;
       year=9999;        year=9999;
     }else{      }else{
Line 5049  int readdata(char datafile[], int firsto Line 5081  int readdata(char datafile[], int firsto
     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,"%s.", dummy) != 0){      else  if( (iout=sscanf(strb,"%s.", dummy)) != 0){
       month=99;        month=99;
       year=9999;        year=9999;
     }else{      }else{
Line 5149  void removespace(char *str) { Line 5181  void removespace(char *str) {
   do    do
     while (*p2 == ' ')      while (*p2 == ' ')
       p2++;        p2++;
   while (*p1++ = *p2++);    while (*p1++ == *p2++);
 }  }
   
 int decodemodel ( char model[], int lastobs) /**< This routine decode the model and returns:  int decodemodel ( char model[], int lastobs) /**< This routine decode the model and returns:
Line 5179  int decodemodel ( char model[], int last Line 5211  int decodemodel ( char model[], int last
     cptcovs=j+1-j1; /**<  Number of simple covariates V1+V2*age+V3 +V3*V4=> V1 + V3 =2  */      cptcovs=j+1-j1; /**<  Number of simple covariates V1+V2*age+V3 +V3*V4=> V1 + V3 =2  */
     cptcovt= j+1; /* Number of total covariates in the model V1 + V2*age+ V3 + V3*V4=> 4*/      cptcovt= j+1; /* Number of total covariates in the model V1 + V2*age+ V3 + V3*V4=> 4*/
                   /* including age products which are counted in cptcovage.                    /* including age products which are counted in cptcovage.
                   /* but the covariates which are products must be treated separately: ncovn=4- 2=2 (V1+V3). */                    * but the covariates which are products must be treated separately: ncovn=4- 2=2 (V1+V3). */
     cptcovprod=j1; /**< Number of products  V1*V2 +v3*age = 2 */      cptcovprod=j1; /**< Number of products  V1*V2 +v3*age = 2 */
     cptcovprodnoage=0; /**< Number of covariate products without age: V3*V4 =1  */      cptcovprodnoage=0; /**< Number of covariate products without age: V3*V4 =1  */
     strcpy(modelsav,model);       strcpy(modelsav,model); 
Line 5321  int decodemodel ( char model[], int last Line 5353  int decodemodel ( char model[], int last
     return (1);      return (1);
 }  }
   
 calandcheckages(int imx, int maxwav, double *agemin, double *agemax, int *nberr, int *nbwarn )  int calandcheckages(int imx, int maxwav, double *agemin, double *agemax, int *nberr, int *nbwarn )
 {  {
   int i, m;    int i, m;
   
Line 5332  calandcheckages(int imx, int maxwav, dou Line 5364  calandcheckages(int imx, int maxwav, dou
         s[m][i]=-1;          s[m][i]=-1;
       }        }
       if((int)moisdc[i]==99 && (int)andc[i]==9999 && s[m][i]>nlstate){        if((int)moisdc[i]==99 && (int)andc[i]==9999 && s[m][i]>nlstate){
         *nberr++;          *nberr = *nberr + 1;
         printf("Error! Date of death (month %2d and year %4d) of individual %ld on line %d was unknown, you must set an arbitrary year of death or he/she is skipped and results are biased\n",(int)moisdc[i],(int)andc[i],num[i],i);          printf("Error! Date of death (month %2d and year %4d) of individual %ld on line %d was unknown, you must set an arbitrary year of death or he/she is skipped and results are biased (%d)\n",(int)moisdc[i],(int)andc[i],num[i],i, *nberr);
         fprintf(ficlog,"Error! Date of death (month %2d and year %4d) of individual %ld on line %d was unknown, you must set an arbitrary year of death or he/she is skipped and results are biased\n",(int)moisdc[i],(int)andc[i],num[i],i);          fprintf(ficlog,"Error! Date of death (month %2d and year %4d) of individual %ld on line %d was unknown, you must set an arbitrary year of death or he/she is skipped and results are biased (%d)\n",(int)moisdc[i],(int)andc[i],num[i],i, *nberr);
         s[m][i]=-1;          s[m][i]=-1;
       }        }
       if((int)moisdc[i]==99 && (int)andc[i]!=9999 && s[m][i]>nlstate){        if((int)moisdc[i]==99 && (int)andc[i]!=9999 && s[m][i]>nlstate){
         *nberr++;          (*nberr)++;
         printf("Error! Month of death of individual %ld on line %d was unknown %2d, you should set it otherwise the information on the death is skipped and results are biased.\n",num[i],i,(int)moisdc[i]);           printf("Error! Month of death of individual %ld on line %d was unknown %2d, you should set it otherwise the information on the death is skipped and results are biased.\n",num[i],i,(int)moisdc[i]); 
         fprintf(ficlog,"Error! Month of death of individual %ld on line %d was unknown %f, you should set it otherwise the information on the death is skipped and results are biased.\n",num[i],i,moisdc[i]);           fprintf(ficlog,"Error! Month of death of individual %ld on line %d was unknown %f, you should set it otherwise the information on the death is skipped and results are biased.\n",num[i],i,moisdc[i]); 
         s[m][i]=-1; /* We prefer to skip it (and to skip it in version 0.8a1 too */          s[m][i]=-1; /* We prefer to skip it (and to skip it in version 0.8a1 too */
Line 5351  calandcheckages(int imx, int maxwav, dou Line 5383  calandcheckages(int imx, int maxwav, dou
     for(m=firstpass; (m<= lastpass); m++){      for(m=firstpass; (m<= lastpass); m++){
       if(s[m][i] >0 || s[m][i]==-2 || s[m][i]==-4 || s[m][i]==-5){        if(s[m][i] >0 || s[m][i]==-2 || s[m][i]==-4 || s[m][i]==-5){
         if (s[m][i] >= nlstate+1) {          if (s[m][i] >= nlstate+1) {
           if(agedc[i]>0)            if(agedc[i]>0){
             if((int)moisdc[i]!=99 && (int)andc[i]!=9999)              if((int)moisdc[i]!=99 && (int)andc[i]!=9999){
               agev[m][i]=agedc[i];                agev[m][i]=agedc[i];
           /*if(moisdc[i]==99 && andc[i]==9999) s[m][i]=-1;*/            /*if(moisdc[i]==99 && andc[i]==9999) s[m][i]=-1;*/
             else {              }else {
               if ((int)andc[i]!=9999){                if ((int)andc[i]!=9999){
                 nbwarn++;                  nbwarn++;
                 printf("Warning negative age at death: %ld line:%d\n",num[i],i);                  printf("Warning negative age at death: %ld line:%d\n",num[i],i);
Line 5363  calandcheckages(int imx, int maxwav, dou Line 5395  calandcheckages(int imx, int maxwav, dou
                 agev[m][i]=-1;                  agev[m][i]=-1;
               }                }
             }              }
             } /* agedc > 0 */
         }          }
         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 month */                                   years but with the precision of a month */
Line 5393  calandcheckages(int imx, int maxwav, dou Line 5426  calandcheckages(int imx, int maxwav, dou
   for (i=1; i<=imx; i++)  {    for (i=1; i<=imx; i++)  {
     for(m=firstpass; (m<=lastpass); m++){      for(m=firstpass; (m<=lastpass); m++){
       if (s[m][i] > (nlstate+ndeath)) {        if (s[m][i] > (nlstate+ndeath)) {
         *nberr++;          (*nberr)++;
         printf("Error: on wave %d of individual %d status %d > (nlstate+ndeath)=(%d+%d)=%d\n",m,i,s[m][i],nlstate, ndeath, nlstate+ndeath);               printf("Error: on wave %d of individual %d status %d > (nlstate+ndeath)=(%d+%d)=%d\n",m,i,s[m][i],nlstate, ndeath, nlstate+ndeath);     
         fprintf(ficlog,"Error: on wave %d of individual %d status %d > (nlstate+ndeath)=(%d+%d)=%d\n",m,i,s[m][i],nlstate, ndeath, nlstate+ndeath);               fprintf(ficlog,"Error: on wave %d of individual %d status %d > (nlstate+ndeath)=(%d+%d)=%d\n",m,i,s[m][i],nlstate, ndeath, nlstate+ndeath);     
         return 1;          return 1;
Line 5418  calandcheckages(int imx, int maxwav, dou Line 5451  calandcheckages(int imx, int maxwav, dou
     return (1);      return (1);
 }  }
   
   void syscompilerinfo()
    {
      /* #include "syscompilerinfo.h"*/
      /* #include <gnu/libc-version.h> */ /* Only on gnu */
   #include <stdint.h>
      printf("Compiled with:");fprintf(ficlog,"Compiled with:");
   #if defined(__clang__)
      printf(" Clang/LLVM");fprintf(ficlog," Clang/LLVM"); /* Clang/LLVM. ---------------------------------------------- */
   #endif
   #if defined(__ICC) || defined(__INTEL_COMPILER)
      printf(" Intel ICC/ICPC");fprintf(ficlog," Intel ICC/ICPC");/* Intel ICC/ICPC. ------------------------------------------ */
   #endif
   #if defined(__GNUC__) || defined(__GNUG__)
      printf(" GNU GCC/G++");fprintf(ficlog," GNU GCC/G++");/* GNU GCC/G++. --------------------------------------------- */
   #endif
   #if defined(__HP_cc) || defined(__HP_aCC)
      printf(" Hewlett-Packard C/aC++");fprintf(fcilog," Hewlett-Packard C/aC++"); /* Hewlett-Packard C/aC++. ---------------------------------- */
   #endif
   #if defined(__IBMC__) || defined(__IBMCPP__)
      printf(" IBM XL C/C++"); fprintf(ficlog," IBM XL C/C++");/* IBM XL C/C++. -------------------------------------------- */
   #endif
   #if defined(_MSC_VER)
      printf(" Microsoft Visual Studio");fprintf(ficlog," Microsoft Visual Studio");/* Microsoft Visual Studio. --------------------------------- */
   #endif
   #if defined(__PGI)
      printf(" Portland Group PGCC/PGCPP");fprintf(ficlog," Portland Group PGCC/PGCPP");/* Portland Group PGCC/PGCPP. ------------------------------- */
   #endif
   #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
      printf(" Oracle Solaris Studio");fprintf(ficlog," Oracle Solaris Studio\n");/* Oracle Solaris Studio. ----------------------------------- */
   #endif
      printf(". ");fprintf(ficlog,". ");
      
   // http://stackoverflow.com/questions/4605842/how-to-identify-platform-compiler-from-preprocessor-macros
   #ifdef _WIN32 // note the underscore: without it, it's not msdn official!
       // Windows (x64 and x86)
   #elif __unix__ // all unices, not all compilers
       // Unix
   #elif __linux__
       // linux
   #elif __APPLE__
       // Mac OS, not sure if this is covered by __posix__ and/or __unix__ though...
   #endif
   
   /*  __MINGW32__   */
   /*  __CYGWIN__   */
   /* __MINGW64__  */
   // http://msdn.microsoft.com/en-us/library/b0084kay.aspx
   /* _MSC_VER  //the Visual C++ compiler is 17.00.51106.1, the _MSC_VER macro evaluates to 1700. Type cl /?  */
   /* _MSC_FULL_VER //the Visual C++ compiler is 15.00.20706.01, the _MSC_FULL_VER macro evaluates to 150020706 */
   /* _WIN64  // Defined for applications for Win64. */
   /* _M_X64 // Defined for compilations that target x64 processors. */
   /* _DEBUG // Defined when you compile with /LDd, /MDd, and /MTd. */
   
   #if UINTPTR_MAX == 0xffffffff
      printf(" 32-bit.\n"); fprintf(ficlog," 32-bit.\n");/* 32-bit */
   #elif UINTPTR_MAX == 0xffffffffffffffff
      printf(" 64-bit.\n"); fprintf(ficlog," 64-bit.\n");/* 64-bit */
   #else
      printf(" wtf-bit.\n"); fprintf(ficlog," wtf-bit.\n");/* wtf */
   #endif
   
   /* struct utsname sysInfo;
   
      if (uname(&sysInfo) != -1) {
        printf(" %s %s %s %s %s\n",sysInfo.sysname, sysInfo.nodename, sysInfo.release, sysInfo.version, sysInfo.machine);
        fprintf(ficlog," %s %s %s %s %s\n ",sysInfo.sysname, sysInfo.nodename, sysInfo.release, sysInfo.version, sysInfo.machine);
      }
      else
         perror("uname() error");
             */
   #if defined(__GNUC__)
   # if defined(__GNUC_PATCHLEVEL__)
   #  define __GNUC_VERSION__ (__GNUC__ * 10000 \
                               + __GNUC_MINOR__ * 100 \
                               + __GNUC_PATCHLEVEL__)
   # else
   #  define __GNUC_VERSION__ (__GNUC__ * 10000 \
                               + __GNUC_MINOR__ * 100)
   # endif
      printf("GNU C version %d.\n", __GNUC_VERSION__);
      fprintf(ficlog, "GNU C version %d.\n", __GNUC_VERSION__);
   #endif
   #if defined(_MSC_VER)
      /*printf("Visual C++ compiler: %s \n;", _MSC_FULL_VER);*/
      /*fprintf(ficlog, "Visual C++ compiler: %s \n;", _MSC_FULL_VER);*/
   #endif
      
     /* printf("GNU libc version: %s\n", gnu_get_libc_version()); */
   
    }
   
 /***********************************************/  /***********************************************/
 /**************** Main Program *****************/  /**************** Main Program *****************/
Line 5568  int main(int argc, char *argv[]) Line 5691  int main(int argc, char *argv[])
   strcpy(command,"mkdir ");    strcpy(command,"mkdir ");
   strcat(command,optionfilefiname);    strcat(command,optionfilefiname);
   if((outcmd=system(command)) != 0){    if((outcmd=system(command)) != 0){
     printf("Problem creating directory or it already exists %s%s, err=%d\n",path,optionfilefiname,outcmd);      printf("Directory already exists (or can't create it) %s%s, err=%d\n",path,optionfilefiname,outcmd);
     /* fprintf(ficlog,"Problem creating directory %s%s\n",path,optionfilefiname); */      /* fprintf(ficlog,"Problem creating directory %s%s\n",path,optionfilefiname); */
     /* fclose(ficlog); */      /* fclose(ficlog); */
 /*     exit(1); */  /*     exit(1); */
Line 5595  int main(int argc, char *argv[]) Line 5718  int main(int argc, char *argv[])
  optionfilext=%s\n\   optionfilext=%s\n\
  optionfilefiname='%s'\n",pathimach,pathtot,path,optionfile,optionfilext,optionfilefiname);   optionfilefiname='%s'\n",pathimach,pathtot,path,optionfile,optionfilext,optionfilefiname);
   
     syscompilerinfo();
   
   printf("Local time (at start):%s",strstart);    printf("Local time (at start):%s",strstart);
   fprintf(ficlog,"Local time (at start): %s",strstart);    fprintf(ficlog,"Local time (at start): %s",strstart);
   fflush(ficlog);    fflush(ficlog);

Removed from v.1.166  
changed lines
  Added in v.1.171


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>