Further steps to OS independence (at least Linux, Mac OS X, Cygwin) of musrfit

This commit is contained in:
Bastian M. Wojek 2010-01-10 12:52:14 +00:00
parent 8782cbba25
commit ed7a15f025
11 changed files with 113 additions and 30 deletions

View File

@ -19,6 +19,7 @@ MUSR_LIBRARY_NAME=PMusr
LEM_LIBRARY_NAME=TLemRunHeader
PSIBIN_LIBRARY_NAME=Class_MuSR_PSI
MUD_LIBRARY_NAME=mud
CUBA_LIBRARY_NAME=cuba
dnl -----------------------------------------------
dnl Optional plug-ins
@ -105,6 +106,7 @@ AC_SUBST(MUSR_LIBRARY_NAME)
AC_SUBST(LEM_LIBRARY_NAME)
AC_SUBST(PSIBIN_LIBRARY_NAME)
AC_SUBST(MUD_LIBRARY_NAME)
AC_SUBST(CUBA_LIBRARY_NAME)
PSIBIN_VERSION=$PSIBIN_MAJOR_VERSION.$PSIBIN_MINOR_VERSION.$PSIBIN_MICRO_VERSION
PSIBIN_RELEASE=$PSIBIN_MAJOR_VERSION.$PSIBIN_MINOR_VERSION
@ -499,6 +501,7 @@ LOCAL_LIB_LDFLAGS=
case "$host" in
*-*-cygwin)
ARCH=CYGWIN
LOCAL_BIN_CXXFLAGS="${LOCAL_BIN_CXXFLAGS}"
LOCAL_LIB_CXXFLAGS="${LOCAL_BIN_CXXFLAGS} -D_DLL"
LOCAL_PSIBIN_LIB_CXXFLAGS="${LOCAL_LIB_CXXFLAGS} -D_WIN32GCC"
@ -507,8 +510,11 @@ case "$host" in
LOCAL_BIN_LDFLAGS="${LOCAL_BIN_LDFLAGS} -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc"
LOCAL_LIB_LDFLAGS="-no-undefined ${LOCAL_BIN_LDFLAGS} -Wl,--export-all-symbols"
;;
*-*-darwin*)
ARCH=DARWIN
;;
*)
LOCAL_PSIBIN_LIB_CXXFLAGS="${LOCAL_LIB_CXXFLAGS} -D__linux__"
ARCH=OTHERUNIX
;;
esac
@ -547,6 +553,9 @@ dnl -----------------------------------------------
dnl Specify the files that are going to be created by configure
dnl -----------------------------------------------
AM_CONDITIONAL([IS_DARWIN], [test "${ARCH}" = "DARWIN"])
AM_CONDITIONAL([IS_CYGWIN], [test "${ARCH}" = "CYGWIN"])
AM_CONDITIONAL([BUILD_CUBALIB], [test "${BUILD_CUBA}" = "1"])
AM_CONDITIONAL([BUILD_BMWLIBS], [test "${BUILD_BMW_LIBS}" = "1"])
AM_CONDITIONAL([BUILD_ASLIBS], [test "${BUILD_AS_LIBS}" = "1"])

View File

@ -92,15 +92,15 @@ class TMCIntegrator {
virtual ~TMCIntegrator();
void SetParameters(const std::vector<double> &par) const { fPar=par; }
virtual double FuncAtX(double *) const = 0;
double IntegrateFunc(unsigned int, double *, double *);
double IntegrateFunc(size_t, double *, double *);
protected:
mutable vector<double> fPar;
private:
static double FuncAtXgsl(double *, unsigned int, void *);
static double FuncAtXgsl(double *, size_t, void *);
ROOT::Math::GSLMCIntegrator *fMCIntegrator;
mutable double (*fFunc)(double *, unsigned int, void *);
mutable double (*fFunc)(double *, size_t, void *);
};
inline TMCIntegrator::TMCIntegrator() : fFunc(0) {
@ -116,12 +116,12 @@ inline TMCIntegrator::~TMCIntegrator(){
fFunc=0;
}
inline double TMCIntegrator::FuncAtXgsl(double *x, unsigned int dim, void *obj)
inline double TMCIntegrator::FuncAtXgsl(double *x, size_t dim, void *obj)
{
return ((TMCIntegrator*)obj)->FuncAtX(x);
}
inline double TMCIntegrator::IntegrateFunc(unsigned int dim, double *x1, double *x2)
inline double TMCIntegrator::IntegrateFunc(size_t dim, double *x1, double *x2)
{
fFunc = &TMCIntegrator::FuncAtXgsl;
return fMCIntegrator->Integral(fFunc, dim, x1, x2, (this));

View File

@ -46,3 +46,19 @@ libPNL_PippardFitter_la_LDFLAGS = -version-info $(PLUGIN_LIBRARY_VERSION) -relea
## pkgconfigdir = $(libdir)/pkgconfig
## pkgconfig_DATA = PNL_PippardFitter.pc
## However, create some symbolic links to the shared library
## in order to unify the function call on different operating systems
if IS_DARWIN
install-exec-hook:
$(LN_S) $(libdir)/libPNL_PippardFitter.dylib $(libdir)/libPNL_PippardFitter.so
uninstall-hook:
rm -f $(libdir)/libPNL_PippardFitter.so
endif
if IS_CYGWIN
install-exec-hook:
$(LN_S) $(libdir)/libPNL_PippardFitter.dll.a $(libdir)/libPNL_PippardFitter.so
uninstall-hook:
rm -f $(libdir)/libPNL_PippardFitter.so
endif

View File

@ -63,3 +63,19 @@ libTFitPofB_la_LDFLAGS = -version-info $(PLUGIN_LIBRARY_VERSION) -release $(PLUG
## pkgconfigdir = $(libdir)/pkgconfig
## pkgconfig_DATA = PTFitPofB.pc
## However, create some symbolic links to the shared library
## in order to unify the function call on different operating systems
if IS_DARWIN
install-exec-hook:
$(LN_S) $(libdir)/libTFitPofB.dylib $(libdir)/libTFitPofB.so
uninstall-hook:
rm -f $(libdir)/libTFitPofB.so
endif
if IS_CYGWIN
install-exec-hook:
$(LN_S) $(libdir)/libTFitPofB.dll.a $(libdir)/libTFitPofB.so
uninstall-hook:
rm -f $(libdir)/libTFitPofB.so
endif

View File

@ -36,7 +36,7 @@
#include <string>
using namespace std;
#include <fftw3.h>
#include "fftw3.h"
//--------------------
// Base class for any kind of vortex symmetry

View File

@ -33,7 +33,7 @@
#define _TPofTCalc_H_
#include "TPofBCalc.h"
#include <fftw3.h>
#include "fftw3.h"
#include <string>
#define PI 3.14159265358979323846

View File

@ -18,7 +18,7 @@ dict_cpp_sources = \
include_HEADERS = $(h_sources)
noinst_HEADERS = $(h_linkdef) $(dict_h_sources)
INCLUDES = -I$(top_srcdir)/src/include $(TFITPOFB_CFLAGS) $(PMUSR_CFLAGS) $(ROOT_CFLAGS)
INCLUDES = -I$(top_srcdir)/src/include $(TFITPOFB_CFLAGS) $(PMUSR_CFLAGS) $(ROOT_CFLAGS) $(FFTW3_CFLAGS)
AM_CXXFLAGS = $(LOCAL_LIB_CXXFLAGS)
BUILT_SOURCES = $(dict_cpp_sources) $(dict_h_sources)
@ -38,3 +38,19 @@ libCalcMeanFieldsLEM_la_LDFLAGS = -version-info $(PLUGIN_LIBRARY_VERSION) -relea
## pkgconfigdir = $(libdir)/pkgconfig
## pkgconfig_DATA = CalcMeanFieldsLEM.pc
## However, create some symbolic links to the shared library
## in order to unify the function call on different operating systems
if IS_DARWIN
install-exec-hook:
$(LN_S) $(libdir)/libCalcMeanFieldsLEM.dylib $(libdir)/libCalcMeanFieldsLEM.so
uninstall-hook:
rm -f $(libdir)/libCalcMeanFieldsLEM.so
endif
if IS_CYGWIN
install-exec-hook:
$(LN_S) $(libdir)/libCalcMeanFieldsLEM.dll.a $(libdir)/libCalcMeanFieldsLEM.so
uninstall-hook:
rm -f $(libdir)/libCalcMeanFieldsLEM.so
endif

View File

@ -40,3 +40,19 @@ libGapIntegrals_la_LDFLAGS = -version-info $(PLUGIN_LIBRARY_VERSION) -release $(
## pkgconfigdir = $(libdir)/pkgconfig
## pkgconfig_DATA = GapIntegrals.pc
## However, create some symbolic links to the shared library
## in order to unify the function call on different operating systems
if IS_DARWIN
install-exec-hook:
$(LN_S) $(libdir)/libGapIntegrals.dylib $(libdir)/libGapIntegrals.so
uninstall-hook:
rm -f $(libdir)/libGapIntegrals.so
endif
if IS_CYGWIN
install-exec-hook:
$(LN_S) $(libdir)/libGapIntegrals.dll.a $(libdir)/libGapIntegrals.so
uninstall-hook:
rm -f $(libdir)/libGapIntegrals.so
endif

View File

@ -40,3 +40,19 @@ libLFRelaxation_la_LDFLAGS = -version-info $(PLUGIN_LIBRARY_VERSION) -release $(
## pkgconfigdir = $(libdir)/pkgconfig
## pkgconfig_DATA = LFRelaxation.pc
## However, create some symbolic links to the shared library
## in order to unify the function call on different operating systems
if IS_DARWIN
install-exec-hook:
$(LN_S) $(libdir)/libLFRelaxation.dylib $(libdir)/libLFRelaxation.so
uninstall-hook:
rm -f $(libdir)/libLFRelaxation.so
endif
if IS_CYGWIN
install-exec-hook:
$(LN_S) $(libdir)/libLFRelaxation.dll.a $(libdir)/libLFRelaxation.so
uninstall-hook:
rm -f $(libdir)/libLFRelaxation.so
endif

View File

@ -132,7 +132,7 @@ double TLFStatLorKT::operator()(double t, const vector<double> &par) const {
// LF Dynamic Gaussian KT
TLFDynGssKT::TLFDynGssKT() : fCalcNeeded(true), fFirstCall(true), fWisdom("/home/l_wojek/analysis/WordsOfWisdom.dat"), fNSteps(524288), fDt(0.00004), fCounter(0) {
TLFDynGssKT::TLFDynGssKT() : fCalcNeeded(true), fFirstCall(true), fWisdom("WordsOfWisdom.dat"), fNSteps(524288), fDt(0.00004), fCounter(0) {
// Calculate d_omega and C for given NFFT and dt
fDw = PI/fNSteps/fDt;
fC = 2.0*gsl_sf_log(double(fNSteps))/(double(fNSteps-1)*fDt);
@ -228,11 +228,11 @@ double TLFDynGssKT::operator()(double t, const vector<double> &par) const {
if(fCalcNeeded) {
double t1,t2;
/* double t1,t2;
// get start time
struct timeval tv_start, tv_stop;
gettimeofday(&tv_start, 0);
*/
double tt(0.),sigsqtsq(0.);
if(fabs(par[0])<0.00135538817) {
@ -262,10 +262,10 @@ double TLFDynGssKT::operator()(double t, const vector<double> &par) const {
fFFTtime[i]=(1.0-(coeff1*(1.0-exp(-0.5*sigsq*tt*tt)*gsl_sf_cos(omegaL*tt)))+(coeff2*totoIntegrale))*exp(mcplusnu*tt)*fDt;
}
}
/*
gettimeofday(&tv_stop, 0);
t1 = (tv_stop.tv_sec - tv_start.tv_sec)*1000.0 + (tv_stop.tv_usec - tv_start.tv_usec)/1000.0;
*/
// Transform to frequency domain
fftw_execute(fFFTplanFORW);
@ -291,11 +291,11 @@ double TLFDynGssKT::operator()(double t, const vector<double> &par) const {
// }
fCalcNeeded=false;
fCounter++;
/*
gettimeofday(&tv_stop, 0);
t2 = (tv_stop.tv_sec - tv_start.tv_sec)*1000.0 + (tv_stop.tv_usec - tv_start.tv_usec)/1000.0;
cout << "# Calculation times: " << t1 << " (ms), " << t2 << " (ms)" << endl;
*/
}
// return fFFTtime[int(t/fDt)];
return fDw*exp(fC*t)/PI*fFFTtime[int(t/fDt)];
@ -303,7 +303,7 @@ double TLFDynGssKT::operator()(double t, const vector<double> &par) const {
// LF Dynamic Lorentz KT
TLFDynLorKT::TLFDynLorKT() : fCalcNeeded(true), fFirstCall(true), fWisdom("/home/l_wojek/analysis/WordsOfWisdom.dat"), fNSteps(524288), fDt(0.000040), fCounter(0), fL1(0.0), fL2(0.0) {
TLFDynLorKT::TLFDynLorKT() : fCalcNeeded(true), fFirstCall(true), fWisdom("WordsOfWisdom.dat"), fNSteps(524288), fDt(0.000040), fCounter(0), fL1(0.0), fL2(0.0) {
// Calculate d_omega and C for given NFFT and dt
fDw = TMath::Pi()/fNSteps/fDt;
fC = 2.0*TMath::Log(double(fNSteps))/(double(fNSteps-1)*fDt);
@ -329,8 +329,8 @@ TLFDynLorKT::TLFDynLorKT() : fCalcNeeded(true), fFirstCall(true), fWisdom("/home
fFFTtime = (double *)malloc(sizeof(double) * fNSteps);
fFFTfreq = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * (fNSteps/2+1));
fFFTplanFORW = fftw_plan_dft_r2c_1d(fNSteps, fFFTtime, fFFTfreq, FFTW_EXHAUSTIVE);
fFFTplanBACK = fftw_plan_dft_c2r_1d(fNSteps, fFFTfreq, fFFTtime, FFTW_EXHAUSTIVE);
fFFTplanFORW = fftw_plan_dft_r2c_1d(fNSteps, fFFTtime, fFFTfreq, FFTW_ESTIMATE);
fFFTplanBACK = fftw_plan_dft_c2r_1d(fNSteps, fFFTfreq, fFFTtime, FFTW_ESTIMATE);
}
TLFDynLorKT::~TLFDynLorKT() {

View File

@ -38,17 +38,11 @@
using namespace std;
//#include <gsl/gsl_math.h>
//#include <gsl/gsl_sf_exp.h>
//#include <gsl/gsl_sf_log.h>
//#include <gsl/gsl_sf_trig.h>
//#include <gsl/gsl_sf_bessel.h>
#include "/usr/include/gsl/gsl_math.h"
#include "/usr/include/gsl/gsl_sf_exp.h"
#include "/usr/include/gsl/gsl_sf_log.h"
#include "/usr/include/gsl/gsl_sf_trig.h"
#include "/usr/include/gsl/gsl_sf_bessel.h"
#include "gsl/gsl_math.h"
#include "gsl/gsl_sf_exp.h"
#include "gsl/gsl_sf_log.h"
#include "gsl/gsl_sf_trig.h"
#include "gsl/gsl_sf_bessel.h"
//#include "TMath.h"