/* $Id$
$State$
$Log$
+ Revision 1.156 2014/08/25 20:10:10 brouard
+ *** empty log message ***
+
Revision 1.155 2014/08/25 18:32:34 brouard
Summary: New compile, minor changes
Author: Brouard
#include <errno.h>
extern int errno;
-#ifdef LINUX
+/* #ifdef LINUX */
+/* #include <time.h> */
+/* #include "timeval.h" */
+/* #else */
+/* #include <sys/time.h> */
+/* #endif */
+
#include <time.h>
-#include "timeval.h"
-#else
-#include <sys/time.h>
-#endif
#ifdef GSL
#include <gsl/gsl_errno.h>
#define AGESUP 130
#define AGEBASE 40
#define AGEGOMP 10. /**< Minimal age for Gompertz adjustment */
-#ifdef UNIX
-#define DIRSEPARATOR '/'
-#define CHARSEPARATOR "/"
-#define ODIRSEPARATOR '\\'
-#else
+#ifdef _WIN32
#define DIRSEPARATOR '\\'
#define CHARSEPARATOR "\\"
#define ODIRSEPARATOR '/'
+#else
+#define DIRSEPARATOR '/'
+#define CHARSEPARATOR "/"
+#define ODIRSEPARATOR '\\'
#endif
/* $Id$ */
/* $State$ */
-char version[]="Imach version 0.98nV, August 2014,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121)";
+char version[]="Imach version 0.98nX, August 2014,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121)";
char fullversion[]="$Revision$ $Date$";
char strstart[80];
char optionfilext[10], optionfilefiname[FILENAMELENGTH];
char optionfilegnuplot[FILENAMELENGTH], optionfilehtm[FILENAMELENGTH], optionfilehtmcov[FILENAMELENGTH] ;
-struct timeval start_time, end_time, curr_time, last_time, forecast_time;
-struct timezone tzp;
-extern int gettimeofday();
-struct tm tmg, tm, tmf, *gmtime(), *localtime();
-long time_value;
-extern long time();
+/* struct timeval start_time, end_time, curr_time, last_time, forecast_time; */
+/* struct timezone tzp; */
+/* extern int gettimeofday(); */
+struct tm tml, *gmtime(), *localtime();
+
+extern time_t time();
+
+struct tm start_time, end_time, curr_time, last_time, forecast_time;
+time_t rstart_time, rend_time, rcurr_time, rlast_time, rforecast_time; /* raw time */
+struct tm tm;
+
char strcurr[80], strfor[80];
char *endptr;
xits=vector(1,n);
*fret=(*func)(p);
for (j=1;j<=n;j++) pt[j]=p[j];
+ rcurr_time = time(NULL);
for (*iter=1;;++(*iter)) {
fp=(*fret);
ibig=0;
del=0.0;
- last_time=curr_time;
- (void) gettimeofday(&curr_time,&tzp);
- printf("\nPowell iter=%d -2*LL=%.12f %ld sec. %ld sec.",*iter,*fret, curr_time.tv_sec-last_time.tv_sec, curr_time.tv_sec-start_time.tv_sec);fflush(stdout);
- fprintf(ficlog,"\nPowell iter=%d -2*LL=%.12f %ld sec. %ld sec.",*iter,*fret, curr_time.tv_sec-last_time.tv_sec, curr_time.tv_sec-start_time.tv_sec); fflush(ficlog);
-/* fprintf(ficrespow,"%d %.12f %ld",*iter,*fret,curr_time.tv_sec-start_time.tv_sec); */
+ rlast_time=rcurr_time;
+ /* (void) gettimeofday(&curr_time,&tzp); */
+ rcurr_time = time(NULL);
+ curr_time = *localtime(&rcurr_time);
+ printf("\nPowell iter=%d -2*LL=%.12f %ld sec. %ld sec.",*iter,*fret, rcurr_time-rlast_time, rcurr_time-rstart_time);fflush(stdout);
+ fprintf(ficlog,"\nPowell iter=%d -2*LL=%.12f %ld sec. %ld sec.",*iter,*fret,rcurr_time-rlast_time, rcurr_time-rstart_time); fflush(ficlog);
+/* fprintf(ficrespow,"%d %.12f %ld",*iter,*fret,curr_time.tm_sec-start_time.tm_sec); */
for (i=1;i<=n;i++) {
printf(" %d %.12f",i, p[i]);
fprintf(ficlog," %d %.12lf",i, p[i]);
fprintf(ficlog,"\n");
fprintf(ficrespow,"\n");fflush(ficrespow);
if(*iter <=3){
- tm = *localtime(&curr_time.tv_sec);
- strcpy(strcurr,asctime(&tm));
+ tml = *localtime(&rcurr_time);
+ strcpy(strcurr,asctime(&tml));
/* asctime_r(&tm,strcurr); */
- forecast_time=curr_time;
+ rforecast_time=rcurr_time;
itmp = strlen(strcurr);
if(strcurr[itmp-1]=='\n') /* Windows outputs with a new line */
strcurr[itmp-1]='\0';
- printf("\nConsidering the time needed for this last iteration #%d: %ld seconds,\n",*iter,curr_time.tv_sec-last_time.tv_sec);
- fprintf(ficlog,"\nConsidering the time needed for this last iteration #%d: %ld seconds,\n",*iter,curr_time.tv_sec-last_time.tv_sec);
+ printf("\nConsidering the time needed for this last iteration #%d: %ld seconds,\n",*iter,rcurr_time-rlast_time);
+ fprintf(ficlog,"\nConsidering the time needed for this last iteration #%d: %ld seconds,\n",*iter,rcurr_time-rlast_time);
for(niterf=10;niterf<=30;niterf+=10){
- forecast_time.tv_sec=curr_time.tv_sec+(niterf-*iter)*(curr_time.tv_sec-last_time.tv_sec);
- tmf = *localtime(&forecast_time.tv_sec);
+ rforecast_time=rcurr_time+(niterf-*iter)*(rcurr_time-rlast_time);
+ forecast_time = *localtime(&rforecast_time);
/* asctime_r(&tmf,strfor); */
- strcpy(strfor,asctime(&tmf));
+ strcpy(strfor,asctime(&forecast_time));
itmp = strlen(strfor);
if(strfor[itmp-1]=='\n')
strfor[itmp-1]='\0';
- printf(" - if your program needs %d iterations to converge, convergence will be \n reached in %s i.e.\n on %s (current time is %s);\n",niterf, asc_diff_time(forecast_time.tv_sec-curr_time.tv_sec,tmpout),strfor,strcurr);
- fprintf(ficlog," - if your program needs %d iterations to converge, convergence will be \n reached in %s i.e.\n on %s (current time is %s);\n",niterf, asc_diff_time(forecast_time.tv_sec-curr_time.tv_sec,tmpout),strfor,strcurr);
+ printf(" - if your program needs %d iterations to converge, convergence will be \n reached in %s i.e.\n on %s (current time is %s);\n",niterf, asc_diff_time(rforecast_time-rcurr_time,tmpout),strfor,strcurr);
+ fprintf(ficlog," - if your program needs %d iterations to converge, convergence will be \n reached in %s i.e.\n on %s (current time is %s);\n",niterf, asc_diff_time(rforecast_time-rcurr_time,tmpout),strfor,strcurr);
}
}
for (i=1;i<=n;i++) {
/* setlocale (LC_MESSAGES, ""); */
/* gettimeofday(&start_time, (struct timezone*)0); */ /* at first time */
- (void) gettimeofday(&start_time,&tzp);
+ rstart_time = time(NULL);
+ /* (void) gettimeofday(&start_time,&tzp);*/
+ start_time = *localtime(&rstart_time);
curr_time=start_time;
- tm = *localtime(&start_time.tv_sec);
- tmg = *gmtime(&start_time.tv_sec);
- strcpy(strstart,asctime(&tm));
+ /*tml = *localtime(&start_time.tm_sec);*/
+ /* strcpy(strstart,asctime(&tml)); */
+ strcpy(strstart,asctime(&start_time));
/* printf("Localtime (at start)=%s",strstart); */
-/* tp.tv_sec = tp.tv_sec +86400; */
-/* tm = *localtime(&start_time.tv_sec); */
+/* tp.tm_sec = tp.tm_sec +86400; */
+/* tm = *localtime(&start_time.tm_sec); */
/* tmg.tm_year=tmg.tm_year +dsign*dyear; */
/* tmg.tm_mon=tmg.tm_mon +dsign*dmonth; */
/* tmg.tm_hour=tmg.tm_hour + 1; */
-/* tp.tv_sec = mktime(&tmg); */
+/* tp.tm_sec = mktime(&tmg); */
/* strt=asctime(&tmg); */
/* printf("Time(after) =%s",strstart); */
/* (void) time (&time_value);
fprintf(ficlog,"Local time (at start): %s",strstart);
fflush(ficlog);
/* (void) gettimeofday(&curr_time,&tzp); */
-/* printf("Elapsed time %d\n", asc_diff_time(curr_time.tv_sec-start_time.tv_sec,tmpout)); */
+/* printf("Elapsed time %d\n", asc_diff_time(curr_time.tm_sec-start_time.tm_sec,tmpout)); */
/* */
strcpy(fileres,"r");
}
printf("See log file on %s\n",filelog);
/* gettimeofday(&end_time, (struct timezone*)0);*/ /* after time */
- (void) gettimeofday(&end_time,&tzp);
- tm = *localtime(&end_time.tv_sec);
- tmg = *gmtime(&end_time.tv_sec);
- strcpy(strtend,asctime(&tm));
+ /*(void) gettimeofday(&end_time,&tzp);*/
+ rend_time = time(NULL);
+ end_time = *localtime(&rend_time);
+ /* tml = *localtime(&end_time.tm_sec); */
+ strcpy(strtend,asctime(&end_time));
printf("Local time at start %s\nLocal time at end %s",strstart, strtend);
fprintf(ficlog,"Local time at start %s\nLocal time at end %s\n",strstart, strtend);
- printf("Total time used %s\n", asc_diff_time(end_time.tv_sec -start_time.tv_sec,tmpout));
+ printf("Total time used %s\n", asc_diff_time(rend_time -rstart_time,tmpout));
- printf("Total time was %ld Sec.\n", end_time.tv_sec -start_time.tv_sec);
- fprintf(ficlog,"Total time used %s\n", asc_diff_time(end_time.tv_sec -start_time.tv_sec,tmpout));
- fprintf(ficlog,"Total time was %ld Sec.\n", end_time.tv_sec -start_time.tv_sec);
+ printf("Total time was %.0lf Sec.\n", difftime(rend_time,rstart_time));
+ fprintf(ficlog,"Total time used %s\n", asc_diff_time(rend_time -rstart_time,tmpout));
+ fprintf(ficlog,"Total time was %.0lf Sec.\n", difftime(rend_time,rstart_time));
/* printf("Total time was %d uSec.\n", total_usecs);*/
/* if(fileappend(fichtm,optionfilehtm)){ */
fprintf(fichtm,"<br>Local time at start %s<br>Local time at end %s<br>\n</body></html>",strstart, strtend);
printf("Current directory %s!\n",pathcd);
/*strcat(plotcmd,CHARSEPARATOR);*/
sprintf(plotcmd,"gnuplot");
-#ifndef UNIX
+#ifdef _WIN32
sprintf(plotcmd,"\"%sgnuplot.exe\"",pathimach);
#endif
if(!stat(plotcmd,&info)){
printf("Error or gnuplot program not found: %s Environment GNUPLOTBIN not set.\n",plotcmd);fflush(stdout);
}else
strcpy(pplotcmd,plotcmd);
-#ifdef UNIX
+#ifdef __unix
strcpy(plotcmd,GNUPLOTPROGRAM);
if(!stat(plotcmd,&info)){
printf("Error gnuplot program not found: %s\n",plotcmd);fflush(stdout);
scanf("%s",z);
/* if (z[0] == 'c') system("./imach"); */
if (z[0] == 'e') {
-#ifdef OSX
+#ifdef _APPLE_
sprintf(pplotcmd, "open %s", optionfilehtm);
+#elif __linux
+ sprintf(pplotcmd, "xdg-open %s", optionfilehtm);
#else
sprintf(pplotcmd, "%s", optionfilehtm);
#endif