diff --git a/Makefile b/Makefile index 47d0f30f6..89513427d 100644 --- a/Makefile +++ b/Makefile @@ -26,8 +26,8 @@ install: default if [ -f "utility/w90pov/w90pov" ]; then install -m755 "utility/w90pov/w90pov" "$(DESTDIR)$(PREFIX)/bin/w90pov"; fi; if [ -f "utility/w90vdw/w90vdw.x" ]; then install -m755 "utility/w90vdw/w90vdw.x" "$(DESTDIR)$(PREFIX)/bin/w90vdw.x"; fi; install -d $(DESTDIR)$(PREFIX)/lib/ - if [ -f "libwannier.a" ]; then install -m644 "libwannier.a" "$(DESTDIR)$(PREFIX)/lib/libwannier.a"; fi; - if [ -f "libwannier.a" ]; then $(MAKE) pkgconfig; fi; + if [ -f "$(LIBRARYV2)" ]; then install -m644 "$(LIBRARYV2)" "$(DESTDIR)$(PREFIX)/lib/$(LIBRARYV2)"; fi; + if [ -f "$(LIBRARYV2)" ]; then $(MAKE) pkgconfig; fi; all: wannier lib post w90chk2chk w90pov w90vdw w90spn2spn @@ -92,7 +92,7 @@ clean: cd $(ROOTDIR)/test-suite && ./clean_tests veryclean: clean - cd $(ROOTDIR) && rm -f wannier90.x postw90.x libwannier.a libwan2.a w90chk2chk.x w90spn2spn.x libwan2-extra.a + cd $(ROOTDIR) && rm -f wannier90.x postw90.x libwannier.a w90chk2chk.x w90spn2spn.x libwannier-extra.a cd $(ROOTDIR)/test-suite && ./clean_tests -i thedoc: diff --git a/src/Makefile.2 b/src/Makefile.2 index dc24539e9..046e78f59 100644 --- a/src/Makefile.2 +++ b/src/Makefile.2 @@ -11,21 +11,22 @@ else COMMS = serial endif -# Contains definition of OBJS, OBJS_POST, LIBRARY, DYNLIBRARY -include ../Makefile.header - POSTDIR = ../postw90/ ifeq ($(COMMS),mpi08) +USEMPI=y TEMP1 = -DMPI -DMPI08 TEMP2 = $(MPIF90) else ifeq ($(COMMS),mpih) +USEMPI=y TEMP1 = -DMPI -DMPIH TEMP2 = $(MPIF90) else ifeq ($(COMMS),mpi90) +USEMPI=y TEMP1 = -DMPI -DMPI90 TEMP2 = $(MPIF90) else ifeq ($(COMMS),mpi) +USEMPI=y # default to f90 style "use mpi" TEMP1 = -DMPI -DMPI90 TEMP2 = $(MPIF90) @@ -34,6 +35,8 @@ TEMP1 = TEMP2 = $(F90) endif +# Contains definition of OBJS, OBJS_POST, LIBRARY, DYNLIBRARY +include ../Makefile.header wannier libs dynlibs w90chk2chk w90spn2spn: POSTOPTS = $(TEMP1) wannier libs dynlibs w90chk2chk w90spn2spn: COMPILER = $(TEMP2) @@ -112,7 +115,7 @@ library_extra.o : ../library_extra.F90 c_interface.o : ../c_interface.F90 \ library_interface.o comms.o constants.o error_base.o io.o kmesh.o overlap.o plot.o transport.o \ types.o wannier90_readwrite.o wannier90_types.o wannierise.o - $(COMPILER) $(POSTOPTS) $(FCOPTS) -c ../c_interface.F90 + $(COMPILER) $(POSTOPTS) $(FCOPTS) -c ../c_interface.F90 --std=f2018 constants.o: ../constants.F90 $(COMPILER) $(POSTOPTS) $(FCOPTS) -c ../constants.F90 diff --git a/src/Makefile.header b/src/Makefile.header index 0ddae1ad3..2aada3a22 100644 --- a/src/Makefile.header +++ b/src/Makefile.header @@ -20,8 +20,6 @@ WRAPSRC = ../src/constants.F90 ../src/types.F90 ../src/wannier90_readwrite.F90 \ ../src/library_extra.F90 # ../src/postw90/postw90_types.F90../src/postw90/pw90_library.F90 -LIBRARYV2 = ../../libwan2.a -LIBRARYV2EXTRA = ../../libwan2-extra.a ## Dynamic library section ## Define some defaults (good for linux) if none is defined in the make.inc @@ -30,11 +28,17 @@ LIBRARYV2EXTRA = ../../libwan2-extra.a ## calling it .so and using -shared often works equally well) ## NOTE: if you want to compile the dynamic library, you have to compile ## everything with -fPIC usually, on 64bit systems -DYNLIBRARYEXTENSION ?= so -SHAREDLIBFLAGS ?=-shared -fPIC +SHAREDLIBFLAGS ?=-shared -Wl,-soname,libwannier90.so.4 -fPIC ## Define the filename -DYNLIBBASE = wannier_$(COMMS) -DYNLIBEXTRABASE = wannier-extra_$(COMMS) -DYNLIBRARY = lib$(DYNLIBBASE).$(DYNLIBRARYEXTENSION) -DYNLIBRARYEXTRA = lib$(DYNLIBEXTRABASE).$(DYNLIBRARYEXTENSION) +ifdef USEMPI + LIBSUFFIX=mpi +else + LIBSUFFIX=serial +endif + +DYNLIBBASE = wannier90_$(LIBSUFFIX) +LIBRARYV2 = ../../libwannier90_$(LIBSUFFIX).a +LIBRARYV2EXTRA = ../../libwannier90-extra_$(LIBSUFFIX).a +DYNLIBRARY = libwannier90_$(LIBSUFFIX).so.4 +DYNLIBRARYEXTRA = libwannier90-extra_$(LIBSUFFIX).so.4 diff --git a/src/wannier90.h b/src/wannier90.h index fb8635a94..945a58cc5 100644 --- a/src/wannier90.h +++ b/src/wannier90.h @@ -1,5 +1,5 @@ -#ifndef __wannier90_h__ -#define __wannier90_h__ +#ifndef WANNIER90_H +#define WANNIER90_H #include #include diff --git a/test-suite/libv2-demo2/makefile b/test-suite/libv2-demo2/makefile index 9b176c729..c0f44be5e 100644 --- a/test-suite/libv2-demo2/makefile +++ b/test-suite/libv2-demo2/makefile @@ -1,7 +1,7 @@ include ../../make.inc .cc.o: - $(CXX) -I ../../src -c $< + $(CXX) -g -I ../../src -c $< -fpermissive wannier_c.x : wannier.o ../../libwan2.a - $(CXX) wannier.o ../../libwan2.a $(LIBS) -lgfortran -o $@ + $(CXX) -g wannier.o ../../libwan2.a $(LIBS) -lgfortran -o $@ -fpermissive clean: @rm wannier.o wannier_c.x diff --git a/test-suite/libv2-demo2/test.cc b/test-suite/libv2-demo2/test.cc new file mode 100644 index 000000000..c6db692c7 --- /dev/null +++ b/test-suite/libv2-demo2/test.cc @@ -0,0 +1,4 @@ + +extern "C" { + #include "wannier90.h" +} diff --git a/test-suite/libv2-demo2/wannier.cc b/test-suite/libv2-demo2/wannier.cc index a526427f9..8589d5e50 100644 --- a/test-suite/libv2-demo2/wannier.cc +++ b/test-suite/libv2-demo2/wannier.cc @@ -1,5 +1,9 @@ -#include "wannier90.hh" + +extern "C" { + #include "wannier90.h" +} #include +#include #include #include #include @@ -62,25 +66,29 @@ int main(int argc, char* argv[]) { int nb = nband(filestring); if (nb == 0) nb = nw; // not specified in input + + ///////////// LIBRARY - void* w90glob = w90_create(); // allocate an instance of the library data block + w90_data w90glob; + w90_create(w90glob); - cset_option(w90glob, "kpoints", &kpt[0][0], nk, 3); - cset_option(w90glob, "mp_grid", nkabc); - cset_option(w90glob, "num_bands", nb); - cset_option(w90glob, "num_kpts", nk); - cset_option(w90glob, "num_wann", nw); - cset_option(w90glob, "unit_cell_cart", &uc[0][0], 3, 3); + w90_set_option_double2d(w90glob, "kpoints", &kpt[0][0], nk, 3); + w90_set_option_int1d(w90glob, "mp_grid", nkabc, 3); + w90_set_option_int(w90glob, "num_bands", nb); + w90_set_option_int(w90glob, "num_kpts", nk); + w90_set_option_int(w90glob, "num_wann", nw); + w90_set_option_double2d(w90glob, "unit_cell_cart", &uc[0][0], 3, 3); int ierr; - cinput_setopt(w90glob, root.c_str(), ierr); // process necessary library options - assert(ierr == 0); - cinput_reader(w90glob, ierr); // process any other options + w90_input_setopt(w90glob, root.c_str(), ierr); // process necessary library options + + w90_input_reader_c(w90glob, ierr); // process any other options assert(ierr == 0); int nnfd; - cget_nn(w90glob, nnfd); // return number of NN in FD scheme + w90_get_nn_c(w90glob, &nnfd); // return number of NN in FD scheme + cout << nnfd <* umat = new complex[nw * nw * nk]; double* edata = new double[nb * nk]; - cset_m_local(w90glob, mdata); // m matrix - cset_u_matrix(w90glob, umat); // results returned here - cset_u_opt(w90glob, adata); // initial projections - cset_eigval(w90glob, edata); // contains eigenvalues + w90_set_m_local_c(w90glob, mdata); // m matrix + w90_set_u_matrix_c(w90glob, umat); // results returned here + w90_set_u_opt_c(w90glob, adata); // initial projections + w90_set_eigval_c(w90glob, edata); // contains eigenvalues fn = root + ".mmn"; readm(fn, nnkp, gkpb, nk, nb, nnfd, mdata); @@ -134,15 +142,17 @@ int main(int argc, char* argv[]) { fn = root + ".eig"; if (filesystem::exists(fn)) reade(fn, nk, nb, edata); - cdisentangle(w90glob, ierr); - cproject(w90glob, ierr); + w90_disentangle_c(w90glob, ierr); + w90_project_overlap_c(w90glob, ierr); assert(ierr == 0); - cwannierise(w90glob, ierr); + w90_wannierise_c(w90glob, ierr); assert(ierr == 0); - // cget_centres(w90glob, wannier_ctr); - // cget_spreads(w90glob, wannier_spr); + double wannier_ctr[nw]; + double wannier_spr[nw]; + w90_get_centres_c(w90glob, wannier_ctr); + w90_get_spreads_c(w90glob, wannier_spr); w90_delete(w90glob); return 0;