From 1e45ae61fecc65adf3608eaa18d8ac0e93ec33a8 Mon Sep 17 00:00:00 2001 From: "N. Brouard" Date: Wed, 11 Mar 2015 11:52:39 +0000 Subject: [PATCH] Summary: Back from Windows 8. Intel Compiler --- src/imach.c | 62 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/src/imach.c b/src/imach.c index 3c3d531..755114f 100644 --- a/src/imach.c +++ b/src/imach.c @@ -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 @@ -566,6 +574,7 @@ #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 #include @@ -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
Datafile=%s Firstpass=%d Lastpass=%d Stepm=%d Weight=%d Model=%s
\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"); -- 2.43.0