Diff for /imach/src/imach.c between versions 1.176 and 1.180

version 1.176, 2015/01/03 16:45:04 version 1.180, 2015/02/11 17:33:45
Line 1 Line 1
 /* $Id$  /* $Id$
   $State$    $State$
   $Log$    $Log$
     Revision 1.180  2015/02/11 17:33:45  brouard
     Summary: Finishing move from main to function (hpijx and prevalence_limit)
   
     Revision 1.179  2015/01/04 09:57:06  brouard
     Summary: back to OS/X
   
     Revision 1.178  2015/01/04 09:35:48  brouard
     *** empty log message ***
   
     Revision 1.177  2015/01/03 18:40:56  brouard
     Summary: Still testing ilc32 on OSX
   
   Revision 1.176  2015/01/03 16:45:04  brouard    Revision 1.176  2015/01/03 16:45:04  brouard
   *** empty log message ***    *** empty log message ***
   
Line 629  typedef struct { Line 641  typedef struct {
 /* $Id$ */  /* $Id$ */
 /* $State$ */  /* $State$ */
   
 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 version[]="Imach version 0.98p, FĂ©vrier 2015,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 2271  void mlikeli(FILE *ficres,double p[], in Line 2283  void mlikeli(FILE *ficres,double p[], in
 #endif  #endif
   free_matrix(xi,1,npar,1,npar);    free_matrix(xi,1,npar,1,npar);
   fclose(ficrespow);    fclose(ficrespow);
   printf("\n#Number of iterations & function calls = %d & %d, -2 Log likelihood = %.12f\n",iter, countcallfunc,func(p));    printf("#Number of iterations & function calls = %d & %d, -2 Log likelihood = %.12f\n",iter, countcallfunc,func(p));
   fprintf(ficlog,"\n#Number of iterations & function calls = %d & %d, -2 Log likelihood = %.12f\n",iter, countcallfunc,func(p));    fprintf(ficlog,"#Number of iterations & function calls = %d & %d, -2 Log likelihood = %.12f\n",iter, countcallfunc,func(p));
   fprintf(ficres,"\n#Number of iterations & function calls = %d & %d, -2 Log likelihood = %.12f\n",iter, countcallfunc,func(p));    fprintf(ficres,"#Number of iterations & function calls = %d & %d, -2 Log likelihood = %.12f\n",iter, countcallfunc,func(p));
   
 }  }
   
Line 5504  BOOL IsWow64() Line 5516  BOOL IsWow64()
         return bIsWow64 != FALSE;          return bIsWow64 != FALSE;
 }  }
 #endif  #endif
   
 void syscompilerinfo()  void syscompilerinfo()
  {   {
    /* #include "syscompilerinfo.h"*/     /* #include "syscompilerinfo.h"*/
 #if defined(__GNUC__)   
   #if defined __INTEL_COMPILER
   #if defined(__GNUC__)
           struct utsname sysInfo;  /* For Intel on Linux and OS/X */
   #endif
   #elif defined(__GNUC__) 
   #ifndef  __APPLE__
 #include <gnu/libc-version.h>  /* Only on gnu */  #include <gnu/libc-version.h>  /* Only on gnu */
 struct utsname sysInfo;  
 #endif  #endif
      struct utsname sysInfo;
 #include <stdint.h>  
    int cross = CROSS;     int cross = CROSS;
    if (cross){     if (cross){
      printf("Cross-");             printf("Cross-");
      fprintf(ficlog,"Cross-");             fprintf(ficlog, "Cross-");
    }     }
   #endif
   
   #include <stdint.h>
   
    printf("Compiled with:");fprintf(ficlog,"Compiled with:");     printf("Compiled with:");fprintf(ficlog,"Compiled with:");
 #if defined(__clang__)  #if defined(__clang__)
    printf(" Clang/LLVM");fprintf(ficlog," Clang/LLVM"); /* Clang/LLVM. ---------------------------------------------- */     printf(" Clang/LLVM");fprintf(ficlog," Clang/LLVM"); /* Clang/LLVM. ---------------------------------------------- */
Line 5596  struct utsname sysInfo; Line 5617  struct utsname sysInfo;
    }     }
    else     else
       perror("uname() error");        perror("uname() error");
      //#ifndef __INTEL_COMPILER 
   #if !defined (__INTEL_COMPILER) && !defined(__APPLE__)
    printf("GNU libc version: %s\n", gnu_get_libc_version());      printf("GNU libc version: %s\n", gnu_get_libc_version()); 
    fprintf(ficlog,"GNU libc version: %s\n", gnu_get_libc_version());      fprintf(ficlog,"GNU libc version: %s\n", gnu_get_libc_version());
   #endif
 #endif  #endif
   
    //   void main()     //   void main()
Line 5610  struct utsname sysInfo; Line 5633  struct utsname sysInfo;
    }     }
    else{     else{
            printf("The process is not running under WOW64 (i.e probably on a 64bit Windows).\n");             printf("The process is not running under WOW64 (i.e probably on a 64bit Windows).\n");
            frintf(ficlog,"The programm is not running under WOW64 (i.e probably on a 64bit Windows).\n");             fprintf(ficlog,"The programm is not running under WOW64 (i.e probably on a 64bit Windows).\n");
    }     }
    //      printf("\nPress Enter to continue...");     //      printf("\nPress Enter to continue...");
    //      getchar();     //      getchar();
Line 5621  struct utsname sysInfo; Line 5644  struct utsname sysInfo;
   
  }   }
   
   int prevalence_limit(double *p, double **prlim, double ageminpar, double agemaxpar){
     /*--------------- Prevalence limit  (period or stable prevalence) --------------*/
     int i, j, k, i1 ;
     double ftolpl = 1.e-10;
     double age, agebase, agelim;
   
       strcpy(filerespl,"pl");
       strcat(filerespl,fileres);
       if((ficrespl=fopen(filerespl,"w"))==NULL) {
         printf("Problem with period (stable) prevalence resultfile: %s\n", filerespl);return 1;
         fprintf(ficlog,"Problem with period (stable) prevalence resultfile: %s\n", filerespl);return 1;
       }
       printf("Computing period (stable) prevalence: result on file '%s' \n", filerespl);
       fprintf(ficlog,"Computing period (stable) prevalence: result on file '%s' \n", filerespl);
       pstamp(ficrespl);
       fprintf(ficrespl,"# Period (stable) prevalence \n");
       fprintf(ficrespl,"#Age ");
       for(i=1; i<=nlstate;i++) fprintf(ficrespl,"%d-%d ",i,i);
       fprintf(ficrespl,"\n");
     
       /* prlim=matrix(1,nlstate,1,nlstate);*/ /* back in main */
   
       agebase=ageminpar;
       agelim=agemaxpar;
   
       i1=pow(2,cptcoveff);
       if (cptcovn < 1){i1=1;}
   
       for(cptcov=1,k=0;cptcov<=i1;cptcov++){
       /* for(cptcov=1,k=0;cptcov<=1;cptcov++){ */
         //for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){
           k=k+1;
           /* to clean */
           //printf("cptcov=%d cptcod=%d codtab=%d\n",cptcov, cptcod,codtab[cptcod][cptcov]);
           fprintf(ficrespl,"\n#******");
           printf("\n#******");
           fprintf(ficlog,"\n#******");
           for(j=1;j<=cptcoveff;j++) {
             fprintf(ficrespl," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
             printf(" V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
             fprintf(ficlog," V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
           }
           fprintf(ficrespl,"******\n");
           printf("******\n");
           fprintf(ficlog,"******\n");
   
           fprintf(ficrespl,"#Age ");
           for(j=1;j<=cptcoveff;j++) {
             fprintf(ficrespl,"V%d %d",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
           }
           for(i=1; i<=nlstate;i++) fprintf(ficrespl,"%d-%d ",i,i);
           fprintf(ficrespl,"\n");
           
           for (age=agebase; age<=agelim; age++){
           /* for (age=agebase; age<=agebase; age++){ */
             prevalim(prlim, nlstate, p, age, oldm, savm,ftolpl,k);
             fprintf(ficrespl,"%.0f ",age );
             for(j=1;j<=cptcoveff;j++)
               fprintf(ficrespl,"%d %d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
             for(i=1; i<=nlstate;i++)
               fprintf(ficrespl," %.5f", prlim[i][i]);
             fprintf(ficrespl,"\n");
           } /* Age */
           /* was end of cptcod */
       } /* cptcov */
   }
   
   int hPijx(double *p, int bage, int fage){
       /*------------- h Pij x at various ages ------------*/
   
     int stepsize;
     int agelim;
     int hstepm;
     int nhstepm;
     int h, i, i1, j, k;
   
     double agedeb;
     double ***p3mat;
   
       strcpy(filerespij,"pij");  strcat(filerespij,fileres);
       if((ficrespij=fopen(filerespij,"w"))==NULL) {
         printf("Problem with Pij resultfile: %s\n", filerespij); return 1;
         fprintf(ficlog,"Problem with Pij resultfile: %s\n", filerespij); return 1;
       }
       printf("Computing pij: result on file '%s' \n", filerespij);
       fprintf(ficlog,"Computing pij: result on file '%s' \n", filerespij);
     
       stepsize=(int) (stepm+YEARM-1)/YEARM;
       /*if (stepm<=24) stepsize=2;*/
   
       agelim=AGESUP;
       hstepm=stepsize*YEARM; /* Every year of age */
       hstepm=hstepm/stepm; /* Typically 2 years, = 2/6 months = 4 */ 
   
       /* hstepm=1;   aff par mois*/
       pstamp(ficrespij);
       fprintf(ficrespij,"#****** h Pij x Probability to be in state j at age x+h being in i at x ");
       i1= pow(2,cptcoveff);
      for(cptcov=1,k=0;cptcov<=i1;cptcov++){
         /*for(cptcod=1;cptcod<=ncodemax[cptcov];cptcod++){*/
           k=k+1; 
       /* for (k=1; k <= (int) pow(2,cptcoveff); k++){*/
           fprintf(ficrespij,"\n#****** ");
           for(j=1;j<=cptcoveff;j++) 
             fprintf(ficrespij,"V%d=%d ",Tvaraff[j],nbcode[Tvaraff[j]][codtab[k][j]]);
           fprintf(ficrespij,"******\n");
           
           for (agedeb=fage; agedeb>=bage; agedeb--){ /* If stepm=6 months */
             nhstepm=(int) rint((agelim-agedeb)*YEARM/stepm); /* Typically 20 years = 20*12/6=40 */ 
             nhstepm = nhstepm/hstepm; /* Typically 40/4=10 */
   
             /*      nhstepm=nhstepm*YEARM; aff par mois*/
   
             p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
             oldm=oldms;savm=savms;
             hpxij(p3mat,nhstepm,agedeb,hstepm,p,nlstate,stepm,oldm,savm, k);  
             fprintf(ficrespij,"# Cov Agex agex+h hpijx with i,j=");
             for(i=1; i<=nlstate;i++)
               for(j=1; j<=nlstate+ndeath;j++)
                 fprintf(ficrespij," %1d-%1d",i,j);
             fprintf(ficrespij,"\n");
             for (h=0; h<=nhstepm; h++){
               /*agedebphstep = agedeb + h*hstepm/YEARM*stepm;*/
               fprintf(ficrespij,"%d %3.f %3.f",k, agedeb, agedeb + h*hstepm/YEARM*stepm );
               for(i=1; i<=nlstate;i++)
                 for(j=1; j<=nlstate+ndeath;j++)
                   fprintf(ficrespij," %.5f", p3mat[i][j][h]);
               fprintf(ficrespij,"\n");
             }
             free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);
             fprintf(ficrespij,"\n");
           }
         /*}*/
       }
   }
   
   
 /***********************************************/  /***********************************************/
 /**************** Main Program *****************/  /**************** Main Program *****************/
 /***********************************************/  /***********************************************/
Line 6750  Interval (in months) between two waves: Line 6910  Interval (in months) between two waves:
   
   
     /*--------------- Prevalence limit  (period or stable prevalence) --------------*/      /*--------------- Prevalence limit  (period or stable prevalence) --------------*/
 #include "prevlim.h"  /* Use ficrespl, ficlog */      /*#include "prevlim.h"*/  /* Use ficrespl, ficlog */
       prlim=matrix(1,nlstate,1,nlstate);
       prevalence_limit(p, prlim,  ageminpar, agemaxpar);
     fclose(ficrespl);      fclose(ficrespl);
   
 #ifdef FREEEXIT2  #ifdef FREEEXIT2
Line 6758  Interval (in months) between two waves: Line 6920  Interval (in months) between two waves:
 #endif  #endif
   
     /*------------- h Pij x at various ages ------------*/      /*------------- h Pij x at various ages ------------*/
 #include "hpijx.h"      /*#include "hpijx.h"*/
       hPijx(p, bage, fage);
     fclose(ficrespij);      fclose(ficrespij);
   
   /*-------------- Variance of one-step probabilities---*/    /*-------------- Variance of one-step probabilities---*/

Removed from v.1.176  
changed lines
  Added in v.1.180


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