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

version 1.172, 2014/12/27 12:07:47 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
     *** empty log message ***
   
     Revision 1.175  2015/01/03 16:33:42  brouard
     *** empty log message ***
   
     Revision 1.174  2015/01/03 16:15:49  brouard
     Summary: Still in cross-compilation
   
     Revision 1.173  2015/01/03 12:06:26  brouard
     Summary: trying to detect cross-compilation
   
   Revision 1.172  2014/12/27 12:07:47  brouard    Revision 1.172  2014/12/27 12:07:47  brouard
   Summary: Back from Visual Studio and Intel, options for compiling for Windows XP    Summary: Back from Visual Studio and Intel, options for compiling for Windows XP
   
Line 617  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 2259  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 5492  BOOL IsWow64() Line 5516  BOOL IsWow64()
         return bIsWow64 != FALSE;          return bIsWow64 != FALSE;
 }  }
 #endif  #endif
   
 void syscompilerinfo()  void syscompilerinfo()
  {   {
    /* #include "syscompilerinfo.h"*/     /* #include "syscompilerinfo.h"*/
    /* #include <gnu/libc-version.h> */ /* Only on gnu */  
   #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 */
   #endif
      struct utsname sysInfo;
      int cross = CROSS;
      if (cross){
              printf("Cross-");
              fprintf(ficlog, "Cross-");
      }
   #endif
   
 #include <stdint.h>  #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 5522  void syscompilerinfo() Line 5564  void syscompilerinfo()
 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)  #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
    printf(" Oracle Solaris Studio");fprintf(ficlog," Oracle Solaris Studio\n");/* Oracle Solaris Studio. ----------------------------------- */     printf(" Oracle Solaris Studio");fprintf(ficlog," Oracle Solaris Studio\n");/* Oracle Solaris Studio. ----------------------------------- */
 #endif  #endif
    printf(". ");fprintf(ficlog,". ");     printf(" for ");fprintf(ficlog," for ");
         
 // http://stackoverflow.com/questions/4605842/how-to-identify-platform-compiler-from-preprocessor-macros  // 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!  #ifdef _WIN32 // note the underscore: without it, it's not msdn official!
     // Windows (x64 and x86)      // Windows (x64 and x86)
      printf("Windows (x64 and x86) ");fprintf(ficlog,"Windows (x64 and x86) ");
 #elif __unix__ // all unices, not all compilers  #elif __unix__ // all unices, not all compilers
     // Unix      // Unix
      printf("Unix ");fprintf(ficlog,"Unix ");
 #elif __linux__  #elif __linux__
     // linux      // linux
      printf("linux ");fprintf(ficlog,"linux ");
 #elif __APPLE__  #elif __APPLE__
     // Mac OS, not sure if this is covered by __posix__ and/or __unix__ though...      // Mac OS, not sure if this is covered by __posix__ and/or __unix__ though..
      printf("Mac OS ");fprintf(ficlog,"Mac OS ");
 #endif  #endif
   
 /*  __MINGW32__   */  /*  __MINGW32__   */
Line 5546  void syscompilerinfo() Line 5592  void syscompilerinfo()
 /* _DEBUG // Defined when you compile with /LDd, /MDd, and /MTd. */  /* _DEBUG // Defined when you compile with /LDd, /MDd, and /MTd. */
   
 #if UINTPTR_MAX == 0xffffffff  #if UINTPTR_MAX == 0xffffffff
    printf(" 32-bit.\n"); fprintf(ficlog," 32-bit.\n");/* 32-bit */     printf(" 32-bit"); fprintf(ficlog," 32-bit");/* 32-bit */
 #elif UINTPTR_MAX == 0xffffffffffffffff  #elif UINTPTR_MAX == 0xffffffffffffffff
    printf(" 64-bit.\n"); fprintf(ficlog," 64-bit.\n");/* 64-bit */     printf(" 64-bit"); fprintf(ficlog," 64-bit");/* 64-bit */
 #else  #else
    printf(" wtf-bit.\n"); fprintf(ficlog," wtf-bit.\n");/* wtf */     printf(" wtf-bit"); fprintf(ficlog," wtf-bit");/* wtf */
 #endif  #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__)
 # if defined(__GNUC_PATCHLEVEL__)  # if defined(__GNUC_PATCHLEVEL__)
 #  define __GNUC_VERSION__ (__GNUC__ * 10000 \  #  define __GNUC_VERSION__ (__GNUC__ * 10000 \
Line 5571  void syscompilerinfo() Line 5608  void syscompilerinfo()
 #  define __GNUC_VERSION__ (__GNUC__ * 10000 \  #  define __GNUC_VERSION__ (__GNUC__ * 10000 \
                             + __GNUC_MINOR__ * 100)                              + __GNUC_MINOR__ * 100)
 # endif  # endif
    printf("GNU C version %d.\n", __GNUC_VERSION__);     printf(" using GNU C version %d.\n", __GNUC_VERSION__);
    fprintf(ficlog, "GNU C version %d.\n", __GNUC_VERSION__);     fprintf(ficlog, " using GNU C version %d.\n", __GNUC_VERSION__);
   
      if (uname(&sysInfo) != -1) {
        printf("Running on: %s %s %s %s %s\n",sysInfo.sysname, sysInfo.nodename, sysInfo.release, sysInfo.version, sysInfo.machine);
        fprintf(ficlog,"Running on: %s %s %s %s %s\n ",sysInfo.sysname, sysInfo.nodename, sysInfo.release, sysInfo.version, sysInfo.machine);
      }
      else
         perror("uname() error");
      //#ifndef __INTEL_COMPILER 
   #if !defined (__INTEL_COMPILER) && !defined(__APPLE__)
      printf("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()
    //   {     //   {
 #if defined(_MSC_VER)  #if defined(_MSC_VER)
    if (IsWow64())     if (IsWow64()){
            printf("The process is running under WOW64.\n");             printf("The program (probably compiled for 32bit) is running under WOW64 (64bit) emulation.\n");
    else             fprintf(ficlog, "The program (probably compiled for 32bit) is running under WOW64 (64bit) emulation.\n");
            printf("The process is not running under WOW64.\n");     }
      else{
              printf("The process 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();
    //   }     //   }
   
 #endif  #endif
         
   /* printf("GNU libc version: %s\n", gnu_get_libc_version()); */  
   
  }   }
   
   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 6722  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 6730  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.172  
changed lines
  Added in v.1.180


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