]> henry.ined.fr Git - .git/commitdiff
Summary: Back from Windows 8. Intel Compiler
authorN. Brouard <brouard@ined.fr>
Wed, 11 Mar 2015 11:52:39 +0000 (11:52 +0000)
committerN. Brouard <brouard@ined.fr>
Wed, 11 Mar 2015 11:52:39 +0000 (11:52 +0000)
src/imach.c

index 3c3d531bfb1ef2204b9039b446264f0fdbe4433c..755114ffb4df6a9f1e14cca6cd73dfdf4fbae79f 100644 (file)
@@ -1,6 +1,14 @@
 /* $Id$
   $State$
   $Log$
+  Revision 1.183  2015/03/10 20:34:32  brouard
+  Summary: 0.98q0, trying with directest, mnbrak fixed
+
+  We use directest instead of original Powell test; probably no
+  incidence on the results, but better justifications;
+  We fixed Numerical Recipes mnbrak routine which was wrong and gave
+  wrong results.
+
   Revision 1.182  2015/02/12 08:19:57  brouard
   Summary: Trying to keep directest which seems simpler and more general
   Author: Nicolas Brouard
 
 #define POWELL /* Instead of NLOPT */
 /* #define POWELLORIGINAL */ /* Don't use Directest to decide new direction but original Powell test */
+/* #define MNBRAKORIGINAL */ /* Don't use mnbrak fix */
 
 #include <math.h>
 #include <stdio.h>
@@ -826,7 +835,11 @@ static     int split( char *path, char *dirc, char *name, char *ext, char *finame )
       printf("Warning you should use %s as a separator\n",DIRSEPARATOR);*/
     /* get current working directory */
     /*    extern  char* getcwd ( char *buf , int len);*/
-    if ( getcwd( dirc, FILENAME_MAX ) == NULL ) {
+#ifdef WIN32
+    if (_getcwd( dirc, FILENAME_MAX ) == NULL ) {
+#else
+       if (getcwd(dirc, FILENAME_MAX) == NULL) {
+#endif
       return( GLOCK_ERROR_GETCWD );
     }
     /* got dirc from getcwd*/
@@ -1346,7 +1359,7 @@ values at the three points, fa, fb , and fc such that fa > fb and fb < fc.
         (*cx=10.098840694817, *fc=298946.631474258087),  (*u=9.852501168332, fu=298948.773013752128, fparabu=298945.434711494134) */
       /* In that case, there is no bracket in the output! Routine is wrong with many consequences.*/
 #endif 
-#ifdef MNBRAKORI
+#ifdef MNBRAKORIGINAL
 #else
       if (fu > *fc) {
 #ifdef DEBUG
@@ -1627,9 +1640,9 @@ void powell(double p[], double **xi, int n, double ftol, int *iter, double *fret
       if (t < 0.0) { /* Then we use it for new direction */
 #else
       if (directest*t < 0.0) { /* Contradiction between both tests */
-      printf("directest= %.12lf, t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt);
+      printf("directest= %.12lf, t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt,del);
       printf("f1-2f2+f3= %.12lf, f1-f2-del= %.12lf, f1-f3= %.12lf\n",fp-2.0*(*fret)+fptt, fp -(*fret) -del, fp-fptt);
-      fprintf(ficlog,"directest= %.12lf, t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt);
+      fprintf(ficlog,"directest= %.12lf, t= %.12lf, f1= %.12lf,f2= %.12lf,f3= %.12lf, del= %.12lf\n",directest, t, fp,(*fret),fptt, del);
       fprintf(ficlog,"f1-2f2+f3= %.12lf, f1-f2-del= %.12lf, f1-f3= %.12lf\n",fp-2.0*(*fret)+fptt, fp -(*fret) -del, fp-fptt);
     } 
       if (directest < 0.0) { /* Then we use it for new direction */
@@ -5630,7 +5643,16 @@ BOOL IsWow64()
 void syscompilerinfo()
  {
    /* #include "syscompilerinfo.h"*/
-
+       /* command line Intel compiler 64bit windows:
+       /GS /W3 /Gy /Zc:wchar_t /Zi /O2 /Fd"x64\Release\vc120.pdb" /D "WIN32" 
+       /D "NDEBUG" /D "_CONSOLE" /D "_LIB" /D "_UNICODE" /D "UNICODE" /Qipo 
+       /Zc:forScope /Oi /MD /Fa"x64\Release\" /EHsc /nologo 
+       /Fo"x64\Release\" /Qprof-dir "x64\Release\" /Fp"x64\Release\IMaCh.pch" */
+       /*
+       /GS /W3 /Gy /Zc:wchar_t /Zi /O3 /Fd"x64\Release\vc120.pdb" /D "WIN32" 
+       /D "NDEBUG" /D "_CONSOLE" /D "_LIB" /D "_UNICODE" /D "UNICODE" /Qipo 
+       /Zc:forScope /Oi /MD /Fa"x64\Release\" /EHsc /nologo /Qparallel 
+       /Fo"x64\Release\" /Qprof-dir "x64\Release\" /Fp"x64\Release\IMaCh.pch" */
 #if defined __INTEL_COMPILER
 #if defined(__GNUC__)
        struct utsname sysInfo;  /* For Intel on Linux and OS/X */
@@ -5819,6 +5841,7 @@ int prevalence_limit(double *p, double **prlim, double ageminpar, double agemaxp
        } /* Age */
        /* was end of cptcod */
     } /* cptcov */
+       return 0;
 }
 
 int hPijx(double *p, int bage, int fage){
@@ -5888,6 +5911,7 @@ int hPijx(double *p, int bage, int fage){
       }
       /*}*/
     }
+       return 0;
 }
 
 
@@ -5998,7 +6022,11 @@ int main(int argc, char *argv[])
 
   nberr=0; /* Number of errors and warnings */
   nbwarn=0;
+#ifdef WIN32
+  _getcwd(pathcd, size);
+#else
   getcwd(pathcd, size);
+#endif
 
   printf("\n%s\n%s",version,fullversion);
   if(argc <=1){
@@ -6034,9 +6062,14 @@ int main(int argc, char *argv[])
   /* Split argv[1]=pathtot, parameter file name to get path, optionfile, extension and name */
   split(pathtot,path,optionfile,optionfilext,optionfilefiname);
   printf("\npathtot=%s,\npath=%s,\noptionfile=%s \noptionfilext=%s \noptionfilefiname=%s\n",pathtot,path,optionfile,optionfilext,optionfilefiname);
+#ifdef WIN32
+  _chdir(path); /* Can be a relative path */
+  if(_getcwd(pathcd,MAXLINE) > 0) /* So pathcd is the full path */
+#else
   chdir(path); /* Can be a relative path */
-  if(getcwd(pathcd,MAXLINE) > 0) /* So pathcd is the full path */
-    printf("Current directory %s!\n",pathcd);
+  if (getcwd(pathcd, MAXLINE) > 0) /* So pathcd is the full path */
+#endif
+  printf("Current directory %s!\n",pathcd);
   strcpy(command,"mkdir ");
   strcat(command,optionfilefiname);
   if((outcmd=system(command)) != 0){
@@ -6536,7 +6569,12 @@ Title=%s <br>Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s<br
 
   strcpy(pathr,path);
   strcat(pathr,optionfilefiname);
+#ifdef WIN32
+  _chdir(optionfilefiname); /* Move to directory named optionfile */
+#else
   chdir(optionfilefiname); /* Move to directory named optionfile */
+#endif
+         
   
   /* Calculates basic frequencies. Computes observed prevalence at single age
      and prints on file fileres'p'. */
@@ -7333,9 +7371,15 @@ Interval (in months) between two waves: Min=%d Max=%d Mean=%.2lf<br>\n",\
 
 
    printf("Before Current directory %s!\n",pathcd);
+#ifdef WIN32
+   if (_chdir(pathcd) != 0)
+          printf("Can't move to directory %s!\n",path);
+   if(_getcwd(pathcd,MAXLINE) > 0)
+#else
    if(chdir(pathcd) != 0)
-    printf("Can't move to directory %s!\n",path);
-  if(getcwd(pathcd,MAXLINE) > 0)
+          printf("Can't move to directory %s!\n", path);
+   if (getcwd(pathcd, MAXLINE) > 0)
+#endif 
     printf("Current directory %s!\n",pathcd);
   /*strcat(plotcmd,CHARSEPARATOR);*/
   sprintf(plotcmd,"gnuplot");