Diff for /imach/src/imach.c between versions 1.296 and 1.301

version 1.296, 2019/05/20 13:03:18 version 1.301, 2019/06/04 13:51:20
Line 1 Line 1
 /* $Id$  /* $Id$
   $State$    $State$
   $Log$    $Log$
     Revision 1.301  2019/06/04 13:51:20  brouard
     Summary: Error in 'r'parameter file backcast yearsbproj instead of yearsfproj
   
     Revision 1.300  2019/05/22 19:09:45  brouard
     Summary: version 0.99r19 of May 2019
   
     Revision 1.299  2019/05/22 18:37:08  brouard
     Summary: Cleaned 0.99r19
   
     Revision 1.298  2019/05/22 18:19:56  brouard
     *** empty log message ***
   
     Revision 1.297  2019/05/22 17:56:10  brouard
     Summary: Fix bug by moving date2dmy and nhstepm which gaefin=-1
   
   Revision 1.296  2019/05/20 13:03:18  brouard    Revision 1.296  2019/05/20 13:03:18  brouard
   Summary: Projection syntax simplified    Summary: Projection syntax simplified
   
Line 1111  typedef struct { Line 1126  typedef struct {
 /* $State$ */  /* $State$ */
 #include "version.h"  #include "version.h"
 char version[]=__IMACH_VERSION__;  char version[]=__IMACH_VERSION__;
 char copyright[]="April 2018,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015-2018";  char copyright[]="May 2019,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015-2020";
 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 3046  double **pmij(double **ps, double *cov, Line 3061  double **pmij(double **ps, double *cov,
   sumnew=0.;    sumnew=0.;
   /*for (ii=1;ii<=nlstate+ndeath;ii++){*/    /*for (ii=1;ii<=nlstate+ndeath;ii++){*/
   for (ii=1;ii<=nlstate;ii++){ /* Only on live states */    for (ii=1;ii<=nlstate;ii++){ /* Only on live states */
     /* printf(" agefin=%d, ii=%d, ij=%d, prev=%f\n",(int)agefin,ii, ij, prevacurrent[(int)agefin][ii][ij]);  */      /* printf(" agefin=%d, ii=%d, ij=%d, prev=%f\n",(int)agefin,ii, ij, prevacurrent[(int)agefin][ii][ij]); */
     sumnew+=prevacurrent[(int)agefin][ii][ij];      sumnew+=prevacurrent[(int)agefin][ii][ij];
   }    }
   if(sumnew >0.01){  /* At least some value in the prevalence */    if(sumnew >0.01){  /* At least some value in the prevalence */
Line 4421  void pstamp(FILE *fichier) Line 4436  void pstamp(FILE *fichier)
   fprintf(fichier,"# %s.%s\n#IMaCh version %s, %s\n#%s\n# %s", optionfilefiname,optionfilext,version,copyright, fullversion, strstart);    fprintf(fichier,"# %s.%s\n#IMaCh version %s, %s\n#%s\n# %s", optionfilefiname,optionfilext,version,copyright, fullversion, strstart);
 }  }
   
   void date2dmy(double date,double *day, double *month, double *year){
     double yp=0., yp1=0., yp2=0.;
     
     yp1=modf(date,&yp);/* extracts integral of date in yp  and
                           fractional in yp1 */
     *year=yp;
     yp2=modf((yp1*12),&yp);
     *month=yp;
     yp1=modf((yp2*30.5),&yp);
     *day=yp;
     if(*day==0) *day=1;
     if(*month==0) *month=1;
   }
   
   
   
 /************ Frequencies ********************/  /************ Frequencies ********************/
Line 5189  void prevalence(double ***probs, double Line 5218  void prevalence(double ***probs, double
   
 void  concatwav(int wav[], int **dh, int **bh,  int **mw, int **s, double *agedc, double **agev, int  firstpass, int lastpass, int imx, int nlstate, int stepm)  void  concatwav(int wav[], int **dh, int **bh,  int **mw, int **s, double *agedc, double **agev, int  firstpass, int lastpass, int imx, int nlstate, int stepm)
 {  {
   /* Concatenates waves: wav[i] is the number of effective (useful waves) of individual i.    /* Concatenates waves: wav[i] is the number of effective (useful waves in the sense that a non interview is useless) of individual i.
      Death is a valid wave (if date is known).       Death is a valid wave (if date is known).
      mw[mi][i] is the mi (mi=1 to wav[i])  effective wave of individual i       mw[mi][i] is the mi (mi=1 to wav[i])  effective wave of individual i
      dh[m][i] or dh[mw[mi][i]][i] is the delay between two effective waves m=mw[mi][i]       dh[m][i] or dh[mw[mi][i]][i] is the delay between two effective waves m=mw[mi][i]
      and mw[mi+1][i]. dh depends on stepm.       and mw[mi+1][i]. dh depends on stepm. s[m][i] exists for any wave from firstpass to lastpass
   */    */
   
   int i=0, mi=0, m=0, mli=0;    int i=0, mi=0, m=0, mli=0;
Line 8321  set ter svg size 640, 480\nunset log y\n Line 8350  set ter svg size 640, 480\nunset log y\n
  }/* End movingaverage */   }/* End movingaverage */
     
   
  int date2dmy(double date,double *day, double *month, double *year){  
    double yp=0., yp1=0., yp2=0.;  
      
    yp1=modf(date,&yp);/* extracts integral of date in yp  and  
                           fractional in yp1 */  
    *year=yp;  
    yp2=modf((yp1*12),&yp);  
    *month=yp;  
    yp1=modf((yp2*30.5),&yp);  
    *day=yp;  
    if(*day==0) *day=1;  
    if(*month==0) *month=1;  
    return;  
  }  
     
 /************** Forecasting ******************/  /************** Forecasting ******************/
 /* void prevforecast(char fileres[], double dateintmean, double anprojd, double mprojd, double jprojd, double ageminpar, double agemax, double dateprev1, double dateprev2, int mobilav, double ***prev, double bage, double fage, int firstpass, int lastpass, double anprojf, double p[], int cptcoveff)*/  /* void prevforecast(char fileres[], double dateintmean, double anprojd, double mprojd, double jprojd, double ageminpar, double agemax, double dateprev1, double dateprev2, int mobilav, double ***prev, double bage, double fage, int firstpass, int lastpass, double anprojf, double p[], int cptcoveff)*/
Line 10748  int hPijx(double *p, int bage, int fage) Line 10763  int hPijx(double *p, int bage, int fage)
       /* for (agedeb=fage; agedeb>=bage; agedeb--){ /\* If stepm=6 months *\/ */        /* for (agedeb=fage; agedeb>=bage; agedeb--){ /\* If stepm=6 months *\/ */
       for (agedeb=bage; agedeb<=fage; agedeb++){ /* If stepm=6 months and estepm=24 (2 years) */        for (agedeb=bage; agedeb<=fage; agedeb++){ /* If stepm=6 months and estepm=24 (2 years) */
         /* nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); /\* Typically 20 years = 20*12/6=40 *\/ */          /* nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); /\* Typically 20 years = 20*12/6=40 *\/ */
         nhstepm=(int) rint((agedeb-ageminl)*YEARM/stepm); /* Typically 20 years = 20*12/6=40 */          nhstepm=(int) rint((agedeb-ageminl)*YEARM/stepm+0.1)-1; /* Typically 20 years = 20*12/6=40 or 55*12/24=27.5-1.1=>27 */
         nhstepm = nhstepm/hstepm; /* Typically 40/4=10, because estepm=24 stepm=6 => hstepm=24/6=4 */          nhstepm = nhstepm/hstepm; /* Typically 40/4=10, because estepm=24 stepm=6 => hstepm=24/6=4 or 28*/
                   
         /*        nhstepm=nhstepm*YEARM; aff par mois*/          /*        nhstepm=nhstepm*YEARM; aff par mois*/
                   
Line 12224  Please run with mle=-1 to get a correct Line 12239  Please run with mle=-1 to get a correct
         fputs(line,stdout);          fputs(line,stdout);
         fputs(line,ficparo);          fputs(line,ficparo);
         fputs(line,ficlog);          fputs(line,ficlog);
           fputs(line,ficres);
         continue;          continue;
       }else        }else
         break;          break;
Line 12269  Please run with mle=-1 to get a correct Line 12285  Please run with mle=-1 to get a correct
         fputs(line,stdout);          fputs(line,stdout);
         fputs(line,ficparo);          fputs(line,ficparo);
         fputs(line,ficlog);          fputs(line,ficlog);
           fputs(line,ficres);
         continue;          continue;
       }else        }else
         break;          break;
Line 12294  Please run with mle=-1 to get a correct Line 12311  Please run with mle=-1 to get a correct
         fputs(line,stdout);          fputs(line,stdout);
         fputs(line,ficparo);          fputs(line,ficparo);
         fputs(line,ficlog);          fputs(line,ficlog);
           fputs(line,ficres);
         continue;          continue;
       }else        }else
         break;          break;
Line 12327  Please run with mle=-1 to get a correct Line 12345  Please run with mle=-1 to get a correct
         fputs(line,stdout);          fputs(line,stdout);
         fputs(line,ficparo);          fputs(line,ficparo);
         fputs(line,ficlog);          fputs(line,ficlog);
           fputs(line,ficres);
         continue;          continue;
       }else if(sscanf(line,"prevforecast=%[^\n]\n",modeltemp))        }else if(sscanf(line,"prevforecast=%[^\n]\n",modeltemp))
         parameterline=11;          parameterline=11;
Line 12350  Please run with mle=-1 to get a correct Line 12369  Please run with mle=-1 to get a correct
           prvforecast = 1;            prvforecast = 1;
         }           } 
         else if((num_filled=sscanf(line,"prevforecast=%d yearsfproj=%lf mobil_average=%d\n",&prevfcast,&yrfproj,&mobilavproj)) !=EOF){/* && (num_filled == 3))*/          else if((num_filled=sscanf(line,"prevforecast=%d yearsfproj=%lf mobil_average=%d\n",&prevfcast,&yrfproj,&mobilavproj)) !=EOF){/* && (num_filled == 3))*/
           printf(" Num_filled=%d, yearsfproj=%lf, mobil_average=%d\n",prevfcast,yrfproj,mobilavproj);            printf("prevforecast=%d yearsfproj=%lf mobil_average=%d\n",prevfcast,yrfproj,mobilavproj);
             fprintf(ficlog,"prevforecast=%d yearsfproj=%lf mobil_average=%d\n",prevfcast,yrfproj,mobilavproj);
             fprintf(ficres,"prevforecast=%d yearsfproj=%lf mobil_average=%d\n",prevfcast,yrfproj,mobilavproj);
           prvforecast = 2;            prvforecast = 2;
         }          }
         else {          else {
Line 12371  Please run with mle=-1 to get a correct Line 12392  Please run with mle=-1 to get a correct
           prvbackcast = 1;            prvbackcast = 1;
         }           } 
         else if((num_filled=sscanf(line,"prevbackcast=%d yearsbproj=%lf mobil_average=%d\n",&prevbcast,&yrbproj,&mobilavproj)) ==3){/* && (num_filled == 3))*/          else if((num_filled=sscanf(line,"prevbackcast=%d yearsbproj=%lf mobil_average=%d\n",&prevbcast,&yrbproj,&mobilavproj)) ==3){/* && (num_filled == 3))*/
           printf(" Num_filled=%d, yearsbproj=%lf, mobil_average=%d\n",prevbcast,yrbproj,mobilavproj);            printf("prevbackcast=%d yearsbproj=%lf mobil_average=%d\n",prevbcast,yrbproj,mobilavproj);
             fprintf(ficlog,"prevbackcast=%d yearsbproj=%lf mobil_average=%d\n",prevbcast,yrbproj,mobilavproj);
             fprintf(ficres,"prevbackcast=%d yearsbproj=%lf mobil_average=%d\n",prevbcast,yrbproj,mobilavproj);
           prvbackcast = 2;            prvbackcast = 2;
         }          }
         else {          else {
Line 12380  Please run with mle=-1 to get a correct Line 12403  Please run with mle=-1 to get a correct
           goto end;            goto end;
         }          }
         break;          break;
         /* /\*fscanf(ficpar,"backcast=%d starting-back-date=%lf/%lf/%lf final-back-date=%lf/%lf/%lf mobil_average=%d\n",&backcast,&jback1,&mback1,&anback1,&jback2,&mback2,&anback2,&mobilavproj);*\/ */  
         /* if((num_filled=sscanf(line,"backcast=%d starting-back-date=%lf/%lf/%lf final-back-date=%lf/%lf/%lf mobil_average=%d\n",&backcast,&jback1,&mback1,&anback1,&jback2,&mback2,&anback2,&mobilavproj)) !=EOF){ */  
         /*   if (num_filled != 8) { */  
         /*     printf("Error: Not 8 (data)parameters in line but %d, for example:backcast=1 starting-back-date=1/1/1990 final-back-date=1/1/1970 mobil_average=1\n, your line=%s . Probably you are running an older format.\n",num_filled,line); */  
         /*     fprintf(ficlog,"Error: Not 8 (data)parameters in line but %d, for example:backcast=1 starting-back-date=1/1/1990 final-back-date=1/1/1970 mobil_average=1\n, your line=%s . Probably you are running an older format.\n",num_filled,line); */  
         /*     goto end; */  
         /*   } */  
         /*   printf("backcast=%d starting-back-date=%.lf/%.lf/%.lf final-back-date=%.lf/%.lf/%.lf mobil_average=%d\n",backcast,jback1,mback1,anback1,jback2,mback2,anback2,mobilavproj); */  
         /*   fprintf(ficparo,"backcast=%d starting-back-date=%.lf/%.lf/%.lf final-back-date=%.lf/%.lf/%.lf mobil_average=%d\n",backcast,jback1,mback1,anback1,jback2,mback2,anback2,mobilavproj); */  
         /*   fprintf(ficlog,"backcast=%d starting-back-date=%.lf/%.lf/%.lf final-back-date=%.lf/%.lf/%.lf mobil_average=%d\n",backcast,jback1,mback1,anback1,jback2,mback2,anback2,mobilavproj); */  
         /*   fprintf(ficres,"backcast=%d starting-back-date=%.lf/%.lf/%.lf final-back-date=%.lf/%.lf/%.lf mobil_average=%d\n",backcast,jback1,mback1,anback1,jback2,mback2,anback2,mobilavproj); */  
         /*   /\* day and month of proj2 are not used but only year anproj2.*\/ */  
         /*   dateback1=anback1+(mback1-1)/12.+(jback1-1)/365.; */  
         /*   dateback2=anback2+(mback2-1)/12.+(jback2-1)/365.; */  
         /* } */  
         /* break; */  
       case 13:        case 13:
         if((num_filled=sscanf(line,"result:%[^\n]\n",resultline)) !=EOF){          if((num_filled=sscanf(line,"result:%[^\n]\n",resultline)) !=EOF){
           if (num_filled == 0){            if (num_filled == 0){

Removed from v.1.296  
changed lines
  Added in v.1.301


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