Skip to content

Commit

Permalink
updates scotch dependencies for compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpeter committed Jun 1, 2016
1 parent e63f726 commit e4a83c5
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 84 deletions.
11 changes: 5 additions & 6 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ MPI_INCLUDES = @MPI_INCLUDES@
####
#######################################

@COND_SCOTCH_TRUE@SCOTCH=yes
@COND_SCOTCH_FALSE@SCOTCH=no

USE_BUNDLED_SCOTCH = @USE_BUNDLED_SCOTCH@

SCOTCH_DIR = @SCOTCH_DIR@
Expand All @@ -95,11 +98,7 @@ SCOTCH_LIBDIR = @SCOTCH_LIBDIR@
SCOTCH_INC = -I${SCOTCH_INCDIR}
SCOTCH_LIBS = -L${SCOTCH_LIBDIR} -lscotch -lscotcherr

@COND_MPI_TRUE@F90 += @FC_DEFINE@USE_SCOTCH $(SCOTCH_INC)

## scotch libraries
@COND_MPI_TRUE@MPILIBS += ${SCOTCH_LIBS}
@COND_MPI_FALSE@MPILIBS +=
SCOTCH_FLAGS = @FC_DEFINE@USE_SCOTCH $(SCOTCH_INC)

#######################################
####
Expand Down Expand Up @@ -242,7 +241,7 @@ clean:
endif

realclean: clean
ifeq (${SCOTCH_BUNDLED},1)
ifeq (${USE_BUNDLED_SCOTCH},1)
@echo "cleaning bundled Scotch in directory: ${SCOTCH_DIR}/src"
$(MAKE) -C ${SCOTCH_DIR}/src realclean
endif
Expand Down
106 changes: 65 additions & 41 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,8 @@ SCOTCH_LIBDIR
SCOTCH_INCLUDEDIR
SCOTCH_DIR
USE_BUNDLED_SCOTCH
COND_SCOTCH_FALSE
COND_SCOTCH_TRUE
PTHREAD_CFLAGS
PTHREAD_LIBS
PTHREAD_CC
Expand Down Expand Up @@ -689,14 +691,14 @@ COND_CUDA5_FALSE
COND_CUDA5_TRUE
COND_CUDA_FALSE
COND_CUDA_TRUE
COND_MPI_FALSE
COND_MPI_TRUE
COND_VECTORIZATION_FALSE
COND_VECTORIZATION_TRUE
COND_DEBUG_FALSE
COND_DEBUG_TRUE
CUSTOM_MPI_TYPE
CUSTOM_REAL
COND_MPI_FALSE
COND_MPI_TRUE
host_os
host_vendor
host_cpu
Expand Down Expand Up @@ -746,10 +748,10 @@ SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
with_mpi
enable_double_precision
enable_debug
enable_vectorization
with_mpi
with_cuda
with_scotch_dir
with_scotch_includedir
Expand Down Expand Up @@ -1408,7 +1410,7 @@ Optional Features:
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-mpi build parallel version [default=yes]
--with-mpi build parallel version [default=no]
--with-cuda build CUDA GPU enabled version [default=no]
--with-scotch-dir=DIR define the root path to Scotch (e.g. /opt/scotch/)
--with-scotch-includedir=DIR
Expand Down Expand Up @@ -2540,27 +2542,6 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac

# 'configure' options

###
### MPI
###


# Check whether --with-mpi was given.
if test "${with_mpi+set}" = set; then :
withval=$with_mpi; want_mpi="$withval"
else
want_mpi=no
fi

if test "$want_mpi" = yes; then
COND_MPI_TRUE=
COND_MPI_FALSE='#'
else
COND_MPI_TRUE='#'
COND_MPI_FALSE=
fi


###
### precision
###
Expand Down Expand Up @@ -2635,6 +2616,27 @@ else
fi


###
### MPI
###


# Check whether --with-mpi was given.
if test "${with_mpi+set}" = set; then :
withval=$with_mpi; want_mpi="$withval"
else
want_mpi=no
fi

if test "$want_mpi" = yes; then
COND_MPI_TRUE=
COND_MPI_FALSE='#'
else
COND_MPI_TRUE='#'
COND_MPI_FALSE=
fi


###
### CUDA
###
Expand Down Expand Up @@ -5865,6 +5867,7 @@ if test "x${scotch_usable}" = "xyes"; then

$as_echo "#define HAVE_SCOTCH 1" >>confdefs.h

want_scotch=yes
USE_BUNDLED_SCOTCH=0
SCOTCH_DIR="${ac_scotch_dir}"
SCOTCH_LIBDIR="${ac_scotch_lib_dir}"
Expand Down Expand Up @@ -6452,27 +6455,44 @@ ac_compiler_gnu=$ac_cv_fc_compiler_gnu




# scotch only needed with mpi support
if test "$want_mpi" = yes; then
want_scotch=yes
#daniel: scotch bundle
# uses bundled scotch: current version pointed to by symbolic link scotch/
USE_BUNDLED_SCOTCH=1

SCOTCH_DIR="$srcdir/src/meshfem2D/scotch"
SCOTCH_LIBDIR="${SCOTCH_DIR}/lib"
SCOTCH_INCLUDEDIR="${SCOTCH_DIR}/include"
else
# no mpi support, scotch not needed
want_scotch=no
USE_BUNDLED_SCOTCH=0
fi # want_mpi

#daniel: scotch bundle
# uses bundled scotch: current version pointed to by symbolic link scotch/
USE_BUNDLED_SCOTCH=1
fi
LDFLAGS=${ac_save_ldflags}

SCOTCH_DIR="$srcdir/src/meshfem2D/scotch"
SCOTCH_LIBDIR="${SCOTCH_DIR}/lib"
SCOTCH_INCLUDEDIR="${SCOTCH_DIR}/include"
if test "$want_scotch" = yes; then
COND_SCOTCH_TRUE=
COND_SCOTCH_FALSE='#'
else
COND_SCOTCH_TRUE='#'
COND_SCOTCH_FALSE=
fi

else
if test "$want_scotch" = yes; then :

# no mpi support, scotch not needed
USE_BUNDLED_SCOTCH=0
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: SCOTCH is enabled" >&5
$as_echo "SCOTCH is enabled" >&6; }

fi # want_mpi
else

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: SCOTCH is not enabled" >&5
$as_echo "SCOTCH is not enabled" >&6; }

fi
LDFLAGS=${ac_save_ldflags}


############################################################
Expand Down Expand Up @@ -7623,10 +7643,6 @@ LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs
if test -z "${COND_MPI_TRUE}" && test -z "${COND_MPI_FALSE}"; then
as_fn_error $? "conditional \"COND_MPI\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${COND_DEBUG_TRUE}" && test -z "${COND_DEBUG_FALSE}"; then
as_fn_error $? "conditional \"COND_DEBUG\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
Expand All @@ -7635,6 +7651,10 @@ if test -z "${COND_VECTORIZATION_TRUE}" && test -z "${COND_VECTORIZATION_FALSE}"
as_fn_error $? "conditional \"COND_VECTORIZATION\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${COND_MPI_TRUE}" && test -z "${COND_MPI_FALSE}"; then
as_fn_error $? "conditional \"COND_MPI\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${COND_CUDA_TRUE}" && test -z "${COND_CUDA_FALSE}"; then
as_fn_error $? "conditional \"COND_CUDA\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
Expand All @@ -7655,6 +7675,10 @@ if test -z "${COND_CUDA_PLUS_TRUE}" && test -z "${COND_CUDA_PLUS_FALSE}"; then
as_fn_error $? "conditional \"COND_CUDA_PLUS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${COND_SCOTCH_TRUE}" && test -z "${COND_SCOTCH_FALSE}"; then
as_fn_error $? "conditional \"COND_SCOTCH\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
case $FC_MODINC in #(
*\ ) FC_MODINC=$FC_MODINC'${ac_empty}' ;;
esac
Expand Down
55 changes: 30 additions & 25 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ AC_CANONICAL_HOST

# 'configure' options

###
### MPI
###

AC_ARG_WITH([mpi],
[AC_HELP_STRING([--with-mpi],
[build parallel version @<:@default=yes@:>@])],
[want_mpi="$withval"],
[want_mpi=no])
AM_CONDITIONAL([COND_MPI], [test "$want_mpi" = yes])

###
### precision
###
Expand Down Expand Up @@ -88,6 +77,17 @@ else
fi
AM_CONDITIONAL([COND_VECTORIZATION], [test x"$want_vec" != xno])

###
### MPI
###

AC_ARG_WITH([mpi],
[AC_HELP_STRING([--with-mpi],
[build parallel version @<:@default=no@:>@])],
[want_mpi="$withval"],
[want_mpi=no])
AM_CONDITIONAL([COND_MPI], [test "$want_mpi" = yes])

###
### CUDA
###
Expand Down Expand Up @@ -226,6 +226,7 @@ fi
AC_MSG_CHECKING([whether Scotch is usable])
if test "x${scotch_usable}" = "xyes"; then
AC_DEFINE([HAVE_SCOTCH],[1],[defined if Scotch is installed])
want_scotch=yes
USE_BUNDLED_SCOTCH=0
SCOTCH_DIR="${ac_scotch_dir}"
SCOTCH_LIBDIR="${ac_scotch_lib_dir}"
Expand All @@ -244,28 +245,32 @@ else
fi
ACX_PTHREAD(AC_MSG_RESULT([pthread found]), AC_MSG_ERROR([pthread not found]))


# scotch only needed with mpi support
if test "$want_mpi" = yes; then

#daniel: scotch bundle
# uses bundled scotch: current version pointed to by symbolic link scotch/
USE_BUNDLED_SCOTCH=1

SCOTCH_DIR="$srcdir/src/meshfem2D/scotch"
SCOTCH_LIBDIR="${SCOTCH_DIR}/lib"
SCOTCH_INCLUDEDIR="${SCOTCH_DIR}/include"

want_scotch=yes
#daniel: scotch bundle
# uses bundled scotch: current version pointed to by symbolic link scotch/
USE_BUNDLED_SCOTCH=1

SCOTCH_DIR="$srcdir/src/meshfem2D/scotch"
SCOTCH_LIBDIR="${SCOTCH_DIR}/lib"
SCOTCH_INCLUDEDIR="${SCOTCH_DIR}/include"
else

# no mpi support, scotch not needed
USE_BUNDLED_SCOTCH=0

# no mpi support, scotch not needed
want_scotch=no
USE_BUNDLED_SCOTCH=0
fi # want_mpi

fi
LDFLAGS=${ac_save_ldflags}

AM_CONDITIONAL([COND_SCOTCH], [test "$want_scotch" = yes])
AS_IF([test "$want_scotch" = yes],[
AC_MSG_RESULT([SCOTCH is enabled])
],[
AC_MSG_RESULT([SCOTCH is not enabled])
])


############################################################
# influential environment variables
Expand Down
35 changes: 23 additions & 12 deletions src/meshfem2D/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,17 @@ meshfem2D_SHARED_OBJECTS = \
$O/param_reader.cc.o \
$(EMPTY_MACRO)

$(SCOTCH_INCDIR)/scotchf.h: scotch_library
scotch_library:
ifeq ($(USE_BUNDLED_SCOTCH),1)
@echo "Using bundled Scotch"
$(MAKE) -C "$(SCOTCH_DIR)/src"
else
@echo "Not using bundled Scotch"
# default mesher flags
FCFLAGS_f90_MESH = $(FCFLAGS_f90)
MPILIBS_MESH = $(MPILIBS)

# only mesher needs scotch for compilation of parallel version
ifeq ($(SCOTCH),yes)
FCFLAGS_f90_MESH += $(SCOTCH_FLAGS)
## scotch libraries
MPILIBS_MESH = $(MPILIBS) $(SCOTCH_LIBS)
endif


#######################################

####
Expand All @@ -109,9 +110,19 @@ $E/xmeshfem2D: $(meshfem2D_OBJECTS) $(meshfem2D_SHARED_OBJECTS)
@echo ""
@echo "building xmeshfem2D"
@echo ""
$(FCLINK) -o ${E}/xmeshfem2D $(meshfem2D_OBJECTS) $(meshfem2D_SHARED_OBJECTS) $(MPILIBS)
$(FCLINK) -o ${E}/xmeshfem2D $(meshfem2D_OBJECTS) $(meshfem2D_SHARED_OBJECTS) $(MPILIBS_MESH)
@echo ""

# target for SCOTCH
$(SCOTCH_INCDIR)/scotchf.h: scotch_library
scotch_library:
ifeq ($(USE_BUNDLED_SCOTCH),1)
@echo "Using bundled Scotch"
$(MAKE) -C "$(SCOTCH_DIR)/src"
else
@echo "Not using bundled Scotch"
endif


#######################################

Expand All @@ -132,10 +143,10 @@ endif
####

$O/%.mesh_module.o: $S/%.f90 ${SETUP}/constants.h
${F90} ${FCFLAGS_f90} -c -o $@ $<
${F90} ${FCFLAGS_f90_MESH} -c -o $@ $<

$O/%.mesh.o: $S/%.f90 ${SETUP}/constants.h $O/meshfem2D_par.mesh_module.o
${F90} ${FCFLAGS_f90} -c -o $@ $<
${F90} ${FCFLAGS_f90_MESH} -c -o $@ $<

$O/%.mesh.o: $S/%.F90 ${SETUP}/constants.h $O/meshfem2D_par.mesh_module.o
${F90} ${FCFLAGS_f90} -c -o $@ $<
${F90} ${FCFLAGS_f90_MESH} -c -o $@ $<
1 change: 1 addition & 0 deletions src/specfem2D/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ endif

# mostly as example how to specify special dependencies
# the general dependency on the specfem module is handled by the rules below

$O/specfem2D.spec.o: $O/specfem2D_par.spec_module.o


Expand Down

0 comments on commit e4a83c5

Please sign in to comment.