Skip to content
Snippets Groups Projects
Verified Commit 36db88c5 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

qmc_sequence MEX: use the Fortran version of John Burkardt’s code (instead of C++)

Incidentally, this greatly diminishes the compilation time of the MEX.
parent 85351d75
Branches
Tags
No related merge requests found
...@@ -307,10 +307,9 @@ Copyright: 2005-2011 Ondra Kamenik ...@@ -307,10 +307,9 @@ Copyright: 2005-2011 Ondra Kamenik
2019-2020 Dynare Team 2019-2020 Dynare Team
License: GPL-3+ License: GPL-3+
Files: mex/sources/sobol/sobol.hh mex/sources/sobol/initialize_v_array.hh Files: mex/sources/sobol/sobol.f08
mex/sources/sobol/initialize_v_array.inc Copyright: 2004-2009 John Burkardt
Copyright: 2009 John Burkardt 2023 Dynare Team
2010-2017 Dynare Team
License: LGPL-3+ License: LGPL-3+
Files: macOS/brewfiles/* Files: macOS/brewfiles/*
......
dnl Copyright © 2009-2021 Dynare Team dnl Copyright © 2009-2023 Dynare Team
dnl dnl
dnl This file is part of Dynare. dnl This file is part of Dynare.
dnl dnl
...@@ -37,6 +37,7 @@ case ${MATLAB_ARCH} in ...@@ -37,6 +37,7 @@ case ${MATLAB_ARCH} in
MATLAB_LDFLAGS_NOMAP="-shared -Wl,--no-undefined -Wl,-rpath-link,$MATLAB/bin/glnxa64 -L$MATLAB/bin/glnxa64" MATLAB_LDFLAGS_NOMAP="-shared -Wl,--no-undefined -Wl,-rpath-link,$MATLAB/bin/glnxa64 -L$MATLAB/bin/glnxa64"
MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,--version-script,$MATLAB/extern/lib/glnxa64/mexFunction.map" MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,--version-script,$MATLAB/extern/lib/glnxa64/mexFunction.map"
MATLAB_LIBS="-lmx -lmex -lmat -lm -lmwlapack -lmwblas" MATLAB_LIBS="-lmx -lmex -lmat -lm -lmwlapack -lmwblas"
FORTRAN_LIBS_FOR_CXXLINK="-lgfortran -lquadmath"
ax_mexopts_ok="yes" ax_mexopts_ok="yes"
;; ;;
win64) win64)
...@@ -64,6 +65,7 @@ case ${MATLAB_ARCH} in ...@@ -64,6 +65,7 @@ case ${MATLAB_ARCH} in
# Should come by the end of the link command # Should come by the end of the link command
# (otherwise it will have to be enclosed within --whole-archive). # (otherwise it will have to be enclosed within --whole-archive).
OPENMP_LIBS="-Wl,-Bstatic -lgomp -Wl,-Bdynamic" OPENMP_LIBS="-Wl,-Bstatic -lgomp -Wl,-Bdynamic"
FORTRAN_LIBS_FOR_CXXLINK="-Wl,-Bstatic -lgfortran -Wl,-Bdynamic" # libquadmath is already in MATLAB_LDFLAGS_NOMAP
ax_mexopts_ok="yes" ax_mexopts_ok="yes"
;; ;;
maci64) maci64)
...@@ -77,6 +79,7 @@ case ${MATLAB_ARCH} in ...@@ -77,6 +79,7 @@ case ${MATLAB_ARCH} in
# to avoid linking against the HDF5 shipped by MATLAB (which would # to avoid linking against the HDF5 shipped by MATLAB (which would
# otherwise override the HDF5 from Homebrew) # otherwise override the HDF5 from Homebrew)
MATLAB_LIBS="-L$MATLAB/bin/maci64 -lmx -lmex -lmat -lmwlapack -lmwblas" MATLAB_LIBS="-L$MATLAB/bin/maci64 -lmx -lmex -lmat -lmwlapack -lmwblas"
FORTRAN_LIBS_FOR_CXXLINK="-lgfortran -lquadmath"
ax_mexopts_ok="yes" ax_mexopts_ok="yes"
;; ;;
*) *)
...@@ -132,4 +135,5 @@ AC_SUBST([MATLAB_FCFLAGS]) ...@@ -132,4 +135,5 @@ AC_SUBST([MATLAB_FCFLAGS])
AC_SUBST([MATLAB_LDFLAGS]) AC_SUBST([MATLAB_LDFLAGS])
AC_SUBST([MATLAB_LIBS]) AC_SUBST([MATLAB_LIBS])
AC_SUBST([OPENMP_LIBS]) AC_SUBST([OPENMP_LIBS])
AC_SUBST([FORTRAN_LIBS_FOR_CXXLINK])
]) ])
...@@ -39,6 +39,9 @@ CXXFLAGS=$($MKOCTFILE -p CXXFLAGS) ...@@ -39,6 +39,9 @@ CXXFLAGS=$($MKOCTFILE -p CXXFLAGS)
# is undesirable for generic LDFLAGS. # is undesirable for generic LDFLAGS.
LDFLAGS=$($MKOCTFILE --link-stand-alone -p LDFLAGS) LDFLAGS=$($MKOCTFILE --link-stand-alone -p LDFLAGS)
FORTRAN_LIBS_FOR_CXXLINK="-lgfortran -lquadmath"
AC_SUBST([FORTRAN_LIBS_FOR_CXXLINK])
AC_CANONICAL_HOST AC_CANONICAL_HOST
OCTAVE_VERSION=$($MKOCTFILE -v 2>&1 | sed 's/mkoctfile, version //') OCTAVE_VERSION=$($MKOCTFILE -v 2>&1 | sed 's/mkoctfile, version //')
......
...@@ -4,12 +4,15 @@ TOPDIR = $(top_srcdir)/../../sources/sobol ...@@ -4,12 +4,15 @@ TOPDIR = $(top_srcdir)/../../sources/sobol
qmc_sequence_CPPFLAGS = $(AM_CPPFLAGS) -I$(TOPDIR) qmc_sequence_CPPFLAGS = $(AM_CPPFLAGS) -I$(TOPDIR)
qmc_sequence_CXXFLAGS = $(AM_CXXFLAGS) -fopenmp qmc_sequence_CXXFLAGS = $(AM_CXXFLAGS) -fopenmp
qmc_sequence_LDADD = $(OPENMP_LIBS) qmc_sequence_LDADD = $(OPENMP_LIBS) $(FORTRAN_LIBS_FOR_CXXLINK)
nodist_qmc_sequence_SOURCES = qmc_sequence.cc nodist_qmc_sequence_SOURCES = qmc_sequence.cc sobol.f08
BUILT_SOURCES = $(nodist_qmc_sequence_SOURCES) BUILT_SOURCES = $(nodist_qmc_sequence_SOURCES)
CLEANFILES = $(nodist_qmc_sequence_SOURCES) CLEANFILES = $(nodist_qmc_sequence_SOURCES)
%.cc: $(TOPDIR)/%.cc %.cc: $(TOPDIR)/%.cc
$(LN_S) -f $< $@ $(LN_S) -f $< $@
%.f08: $(TOPDIR)/%.f08
$(LN_S) -f $< $@
template<typename T>
int
initialize_v_array(int dim_max, int log_max, T **v)
/*
** This function initializes the v array used in the sobol routine.
**
** Original files downloaded from http://people.sc.fsu.edu/~burkardt/cpp_src/sobol/ (version 17-Feb-2009 09:46)
**
** Copyright © 2009 John Burkardt
** Copyright © 2010-2017 Dynare Team
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
{
#include "initialize_v_array.inc"
return 1;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment