--- imach/src/imach.c 2015/03/10 20:34:32 1.183 +++ imach/src/imach.c 2015/03/11 11:52:39 1.184 @@ -1,6 +1,9 @@ -/* $Id: imach.c,v 1.183 2015/03/10 20:34:32 brouard Exp $ +/* $Id: imach.c,v 1.184 2015/03/11 11:52:39 brouard Exp $ $State: Exp $ $Log: imach.c,v $ + Revision 1.184 2015/03/11 11:52:39 brouard + Summary: Back from Windows 8. Intel Compiler + Revision 1.183 2015/03/10 20:34:32 brouard Summary: 0.98q0, trying with directest, mnbrak fixed @@ -574,6 +577,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 @@ -656,11 +660,11 @@ typedef struct { #define ODIRSEPARATOR '\\' #endif -/* $Id: imach.c,v 1.183 2015/03/10 20:34:32 brouard Exp $ */ +/* $Id: imach.c,v 1.184 2015/03/11 11:52:39 brouard Exp $ */ /* $State: Exp $ */ char version[]="Imach version 0.98q0, March 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: 1.183 $ $Date: 2015/03/10 20:34:32 $"; +char fullversion[]="$Revision: 1.184 $ $Date: 2015/03/11 11:52:39 $"; char strstart[80]; char optionfilext[10], optionfilefiname[FILENAMELENGTH]; int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ @@ -834,7 +838,11 @@ static int split( char *path, char *dirc 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*/ @@ -1354,7 +1362,7 @@ values at the three points, fa, fb , and (*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 @@ -1635,9 +1643,9 @@ void powell(double p[], double **xi, int 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 */ @@ -5638,7 +5646,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 */ @@ -5827,6 +5844,7 @@ int prevalence_limit(double *p, double * } /* Age */ /* was end of cptcod */ } /* cptcov */ + return 0; } int hPijx(double *p, int bage, int fage){ @@ -5896,6 +5914,7 @@ int hPijx(double *p, int bage, int fage) } /*}*/ } + return 0; } @@ -6006,7 +6025,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){ @@ -6042,9 +6065,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){ @@ -6544,7 +6572,12 @@ Title=%s
Datafile=%s Firstpass=%d La 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'. */ @@ -7341,9 +7374,15 @@ Interval (in months) between two waves: 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");