diff --git a/src/nwdft/libxc/GNUmakefile b/src/nwdft/libxc/GNUmakefile index 1d28614f91..9324840c8d 100644 --- a/src/nwdft/libxc/GNUmakefile +++ b/src/nwdft/libxc/GNUmakefile @@ -13,10 +13,13 @@ LIBRARY = libnwdft.a LIB_INCLUDES = -I../include ifdef USE_LIBXC LIB_DEFINES += -DXC_MAJOR_VERSION=$(shell grep XC_MAJOR_VERSION ../../libext/libxc/install/include/xc_version.h |cut -d " " -f 3) +LIB_DEFINES += -DLIBXC_NP_SIZE=$(shell ./libxc_findsizenp.sh ../../libext/libxc/install/include) LIB_INCLUDES += -I../../libext/libxc/install/include endif ifdef LIBXC_INCLUDE -LIB_DEFINES += -DXC_MAJOR_VERSION=$(shell grep XC_MAJOR_VERSION $(LIBXC_INCLUDE)/xc_version.h |cut -d " " -f 3) +LIB_DEFINES += -DXC_MAJOR_VERSION=$(shell grep XC_MAJOR_VE +RSION $(LIBXC_INCLUDE)/xc_version.h |cut -d " " -f 3) +LIB_DEFINES += -DLIBXC_NP_SIZE=$(shell ./libxc_findsizenp.sh $(LIBXC_INCLUDE)) LIB_INCLUDES += -I$(LIBXC_INCLUDE) endif LIB_INCLUDES += -I. diff --git a/src/nwdft/libxc/libxc_findsizenp.sh b/src/nwdft/libxc/libxc_findsizenp.sh new file mode 100755 index 0000000000..185d296148 --- /dev/null +++ b/src/nwdft/libxc/libxc_findsizenp.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +npstring=$(egrep np "$1"/xc.h|head -1) +np_array=($npstring) +count=-1 +sizenp_string=' ' +for substring in "${np_array[@]}"; do + [[ $substring == "np," ]] && sizenp_string=${np_array[$count]} && break + ((++count)) +done +if [[ "$sizenp_string" == 'int' ]]; then + size_np=4 +elif [[ "$sizenp_string" == 'size_t' ]]; then + size_np=8 +else + echo "unexpected sizenp_string $sizenp_string" + exit 1 +fi +echo $size_np diff --git a/src/nwdft/libxc/nwchem_libxc_compute.F b/src/nwdft/libxc/nwchem_libxc_compute.F index f7ac9abe65..0db19ba582 100644 --- a/src/nwdft/libxc/nwchem_libxc_compute.F +++ b/src/nwdft/libxc/nwchem_libxc_compute.F @@ -63,10 +63,12 @@ logical gga,mgga,dolap logical,external :: nwchem_libxc_family -#if XC_MAJOR_VERSION > 5 +#if LIBXC_NP_SIZE == 4 + integer*4 nqs +#elif LIBXC_NP_SIZE == 8 integer(c_size_t) :: nqs -#else - integer*4 :: nqs +#elif +#error "unexpected value for LIBXC_NP_SIZE" #endif #ifdef USE_LIBXC type(xc_f03_func_t) :: xcfunc