diff --git a/configure.ac b/configure.ac index 7ac99c5..a97dc38 100644 --- a/configure.ac +++ b/configure.ac @@ -154,23 +154,45 @@ else fi AM_CONDITIONAL([WITH_GDAL], test "x$with_gdal" != "xno") - +#SWIG #------------------------------------------------------------------------------------- -AC_ARG_VAR([SWIG],[path to swig, python api generator]) -AC_PATH_PROG([SWIG],[swig],[]) -if test "x$SWIG" = "x"; then - AC_MSG_ERROR([swig is not found, set SWIG variable!]) -fi -SWIG_VERSION=`$SWIG -version|grep ersion|cut -d ' ' -f 3` -SWIG_VERSION_MAJOR=`echo $SWIG_VERSION|cut -d . -f1` -if test "x$SWIG_VERSION_MAJOR" != "x3"; then - AC_MSG_ERROR([swig is too old should be at least 3.0, set SWIG variable for custom location!]) -fi -AC_MSG_NOTICE([swig version: $SWIG_VERSION]) +AC_ARG_WITH(swig, + AS_HELP_STRING([--with-swig=], + [Specify path to SWIG executable. ] + [If set will (re)generate python API, otherwise will try to use previously generated sources. ] + [Note that github repository do not track them.]),) +#only developers/advanced user should call swig +#the public source code releases should come with swig generated files +if test -n "$with_swig"; then + SWIG=$with_swig + AC_PATH_PROG([SWIG],[swig],[]) + if test "x$SWIG" = "x"; then + AC_MSG_ERROR([swig is not found, set SWIG variable!]) + fi + SWIG_VERSION=`$SWIG -version|grep ersion|cut -d ' ' -f 3` + SWIG_VERSION_MAJOR=`echo $SWIG_VERSION|cut -d . -f1` + if test "x$SWIG_VERSION_MAJOR" != "x3"; then + AC_MSG_ERROR([swig is too old should be at least 3.0, set SWIG variable for custom location!]) + fi + AC_MSG_NOTICE([swig: $SWIG]) + AC_MSG_NOTICE([swig version: $SWIG_VERSION]) +else + #check for swig generated files presence + AC_CHECK_FILE($srcdir/src/main/cxxtitan_wrap.cxx, + AC_MSG_NOTICE([found cxxtitan_wrap.cxx]), + AC_MSG_FAILURE([Couldn't find SWIG generated python API sources.] + [Set --with-swig to SWIG to regenerate interface.]) + ) + AC_CHECK_FILE($srcdir/src/main/cxxtitan.py, + AC_MSG_NOTICE([found cxxtitan_wrap.cxx]), + AC_MSG_FAILURE([Couldn't find SWIG generated python API sources.] + [Set --with-swig to SWIG to regenerate interface.]) + ) +fi +AM_CONDITIONAL([WITH_SWIG], test "x$with_swig" != "xno") #------------------------------------------------------------------------------------- AC_CHECK_LIB(m,matherr) -AC_CHECK_LIB(nsl, inet_ntoa) ## Checks for header files #===================================================================================== diff --git a/src/header/hd5calls.h b/src/header/hd5calls.h index 10677c2..a9d254b 100644 --- a/src/header/hd5calls.h +++ b/src/header/hd5calls.h @@ -26,6 +26,7 @@ const int XDMF_NEW = 0; const int XDMF_OLD = 1; const int XDMF_CLOSE = 2; +#define __STDC_FORMAT_MACROS #include @@ -97,7 +98,6 @@ hid_t GH5_createdataset(hid_t gid, hid_t spcid, const char *dsetname, unsigned t -#ifdef __cplusplus #include #include @@ -422,5 +422,4 @@ inline void TiH5_readArray2DDataSet__(const H5::Group &group, double *value, con -#endif #endif diff --git a/src/header/sfc.h b/src/header/sfc.h index f1b30f9..4534c49 100644 --- a/src/header/sfc.h +++ b/src/header/sfc.h @@ -152,11 +152,11 @@ inline SFC_Key sfc_key_read_from_space(const unsigned readspace[],int & pos) } #else #include -#include #define __STDC_FORMAT_MACROS #include typedef uint64_t SFC_Key; + inline void fprintf_sfc_key(FILE *fout, const SFC_Key& obj) { fprintf(fout,"%" PRIu64 "\n",obj); diff --git a/src/main/Makefile.am b/src/main/Makefile.am index f35ec01..e751bea 100644 --- a/src/main/Makefile.am +++ b/src/main/Makefile.am @@ -16,13 +16,14 @@ titan_LDADD = ../preproc/libtitan_preprocess.a ../gisapi/libgisapi.a ../adapt/li ../datstr/libdatstr.a ../geoflow/libgeoflow.a ../useful/libuseful.a \ ../repartition/librepartition.a ../tecplot/libtecplot.a \ ../vectordatapreproc/libvectordatpreproc.a \ - -L@PYTHON_ROOT@/lib -lpython@PYTHON_VERSION@ -lutil + -L@PYTHON_ROOT@/lib -lpython@PYTHON_VERSION@ #titan_simulation_CXXFLAGS = -fpic +if WITH_SWIG cxxtitan_wrap.cxx:cxxtitan.i ../header/properties.h ../header/titan_simulation.h ../preproc/preproc.h @SWIG@ $(CPPFLAGS) -c++ -v -python -o $(srcdir)/cxxtitan_wrap.cxx -oh $(srcdir)/cxxtitan.py $(srcdir)/cxxtitan.i - +endif pyfilesdir=$(pythondir)/titan diff --git a/src/main/cxxtitan.i b/src/main/cxxtitan.i index c607880..334441f 100644 --- a/src/main/cxxtitan.i +++ b/src/main/cxxtitan.i @@ -15,7 +15,9 @@ */ %module cxxtitan - +%begin %{ +#define __STDC_FORMAT_MACROS +%} %{ #include "../header/constant.h" #include "../header/properties.h" diff --git a/src/main/titan.C b/src/main/titan.C index 2c9bf6e..e68d141 100644 --- a/src/main/titan.C +++ b/src/main/titan.C @@ -23,6 +23,7 @@ #endif #include +#include #include #include "../header/ticore/omp_mpi.hpp" @@ -45,6 +46,7 @@ extern "C" void init_cxxtitan(); int main(int argc, char *argv[]) { + printf("Titan2d\n"); int myid, master, numprocs; int namelen; @@ -55,12 +57,33 @@ int main(int argc, char *argv[]) //set program full name int i; char executable[1028]; + char python_home[1028]; char buffer[1028]; i = readlink("/proc/self/exe", executable, 1028); executable[i] = '\0'; Py_SetProgramName(executable); - + +//#define MAKE_PORTABLE +#ifdef MAKE_PORTABLE + strncpy(python_home,executable,1028); + printf("%s\n",python_home); + int count=0; + for(i=strlen(python_home);i>=0;--i) + { + if(python_home[i]=='/') + { + python_home[i]='\0'; + ++count; + if(count==2)break; + } + } + + printf("%s\n",python_home); + sprintf(python_home+strlen(python_home),"/lib/python"); + printf("%s\n",python_home); + Py_SetPythonHome(python_home); +#endif Py_Initialize(); if(myid == 0) diff --git a/src/main/titan_simulation.C b/src/main/titan_simulation.C index ab84fdf..3dbca2d 100644 --- a/src/main/titan_simulation.C +++ b/src/main/titan_simulation.C @@ -612,8 +612,8 @@ void cxxTitanSimulation::save_restart_file() xmdf<<"\t\t\t\t\n"; } xmdf<<"\t\t\t\n"; -#endif xmdf<<"\t\t\n"; +#endif //Geometry xmdf<<"\t\t\n";