From a5bd9c218bd74591a27b94ac4c34b7040afdbb19 Mon Sep 17 00:00:00 2001 From: Pierre-Francois Loos Date: Tue, 13 Oct 2020 13:44:24 +0200 Subject: [PATCH] ninja --- GoDuck | Bin 3342232 -> 3342232 bytes input/methods | 10 +- libxc-tools/install_libxc.sh | 7 +- scan_w.sh | 119 ----------- src/ADC/Makefile | 6 +- src/AOtoMO/Makefile | 6 +- src/BasCor/Makefile | 6 +- src/CC/Makefile | 6 +- src/CI/Makefile | 6 +- src/HF/Makefile | 6 +- src/LR/linear_response_ph.f90 | 88 -------- src/MBPT/Makefile | 6 +- src/MC/Makefile | 6 +- src/MP/Makefile | 6 +- src/Makefile | 66 +----- src/Makefile.common | 12 -- src/Makefile.include | 44 ---- src/QuAcK/Makefile | 3 - src/QuAcK/QuAcK.f90 | 24 ++- src/QuAcK/read_methods.f90 | 10 +- src/RPA/Makefile | 6 +- src/eDFT/Makefile | 3 - src/eDFT/eDFT.f90 | 11 + src/make_ninja.py | 224 +++++++++++++++++++++ src/{libnumgrid => numgrid}/numgrid.f90 | 0 src/{libnumgrid => numgrid}/obj/.gitignore | 0 src/utils/Makefile | 6 +- utils/install_numgrid.sh | 10 + 28 files changed, 323 insertions(+), 374 deletions(-) delete mode 100755 scan_w.sh delete mode 100644 src/LR/linear_response_ph.f90 delete mode 100644 src/Makefile.common delete mode 100644 src/Makefile.include delete mode 100644 src/QuAcK/Makefile delete mode 100644 src/eDFT/Makefile create mode 100755 src/make_ninja.py rename src/{libnumgrid => numgrid}/numgrid.f90 (100%) rename src/{libnumgrid => numgrid}/obj/.gitignore (100%) create mode 100755 utils/install_numgrid.sh diff --git a/GoDuck b/GoDuck index 50582358d6e681231cb552fa3c6c8affd65861d0..8fd6ace0acbef002494ad952e94dd9a76ff9eb9c 100755 GIT binary patch delta 630 zcmXYrJ7^S96o#3-`$%@27~hF;V|;tgI!3LOuwcKeU}K6!1cTLRBQ_c~5&6MlOd%%D z${Ns0WFeJ0MHmEM2*aX6ita|UcDSr6){(H{3&3~!W)VU1@87O3tLmmYT zU=T&P*aQzl*oWmnQX6GnT?@T#Q{ZW+|dPKE?daWsZLKR2a^eI&))O+pRH^x0* zL|lDK4W$-4GjaNX{EX20NAiRsH`T2v!<4+7Q0p`OvIF54>RK0krH&)*)Hf>Gw*H;` z0XzGHeEV+oC)Kjz+~1VgHvK~l>#Bb#$*3iL&2_k266%ff!m!ZnBv*<;t7o{Mw{(`f zo>1!?FBF8z7dROd>RsZEeeKKai;LC*?x=_QMEfc?azf?nT*(LpH@GA&3U6{Es(Oq2 z%1~6D+n5}iXHQgIzGK#!ZS|0s9ijDm>}7@A`&_eo>kqhLX>G}T$xO7G`huN(%)X-{ n?ZRcgSQP3#<3`@l-C%`v$~wn%e4XPulR77KPR7B?DgXR`$#@0J delta 630 zcmXYsJ7^S96o#3-`$%>&F}@Sy#u%UHtYg$l2@Cei3O1%#BqCUiX~agCNko6J7#Dmp zD{DY2g@shY6k!?#5rzc|E8}8mv07M4T=mYmTm10xfA`#TZ|h%TwRG;lLIw(1ten&MvBE z<4Ux!NXz3woom#cOet)vP^_M&a+L;C>S0RHsa8;rH3cuJVu?*&QDs)hewTJ{{@jbI z@5xun*5{HBZZ2cR#BWCtH zx#rx)52|IQvwu-+Z1S6Y(^dacoKa(Xn{9EgB-Eeb=7dmVo-0M6jdMK68#>QDN2q;) zn+2irC5}gh`b#{#uXB}M>B3EqyCOT++0U7Q8(cAKy_;N;E(~sQEV6o=2P&nox-y)c zUS&tBsC;*LZB!3<&60tw2kc~p>_=S7C`W&%{)Bx)o6piGrCqzFHyHbZT}vof% h{%iL0Dc$$hS*NUXLdVrPsWY#0O6PRst)Fo({s+Sz-HQMK diff --git a/input/methods b/input/methods index 52dabfe..932ce94 100644 --- a/input/methods +++ b/input/methods @@ -1,13 +1,13 @@ -# RHF UHF MOM - T F F +# RHF UHF KS MOM + F T F F # MP2* MP3 MP2-F12 F F F # CCD CCSD CCSD(T) - T F F + F F F # drCCD rCCD lCCD pCCD - F F F T + F F F F # CIS* CIS(D) CID CISD - F F F F + T F F F # RPA* RPAx* ppRPA F F F # G0F2 evGF2 G0F3 evGF3 diff --git a/libxc-tools/install_libxc.sh b/libxc-tools/install_libxc.sh index 02277d4..0462915 100755 --- a/libxc-tools/install_libxc.sh +++ b/libxc-tools/install_libxc.sh @@ -1,8 +1,9 @@ #!/bin/bash -git clone --single-branch --branch master https://gitlab.com/libxc/libxc.git -cd libxc -autoreconf -i +###git clone --single-branch --branch master https://gitlab.com/libxc/libxc.git +tar -xzvf libxc-5.0.0.tar.gz +cd libxc-5.0.0 +###autoreconf -i ./configure --prefix=$QUACK_ROOT make make check diff --git a/scan_w.sh b/scan_w.sh deleted file mode 100755 index e79e50a..0000000 --- a/scan_w.sh +++ /dev/null @@ -1,119 +0,0 @@ -#! /bin/bash - -MOL=$1 -BASIS=$2 - -w_start=0.00 -w_end=1.05 -dw=0.05 - -w1=0.00 - -XF=$3 -CF=$4 - -# for H -#aw1="1.49852 7.79815 25.1445" -#aw2="0.424545 -0.0382349 -0.32472" - - -# for He -#aw1="0.429447 0.053506 -0.339391" -#aw2="0.254939 -0.0893396 0.00765453" - -# for H2 -aw1="0.445525 0.0901503 -0.286898" -aw2="0.191734 -0.0364788 -0.017035" - -# for Li -#aw1="0.055105 -0.00943825 -0.0267771" -#aw2="0.0359827 0.0096623 -0.0173542" - -# for Li+ -#aw1="0.503566, 0.137076, -0.348529" -#aw2="0.0553828, 0.00830375, -0.0234602" - - -# for B -#aw1="0.052676 -0.00624118 -0.000368825" -#aw2="0.0385558 -0.0015764 -0.000894297" - -# for O -#aw1="-0.0187067 -0.0141017 -0.0100849" -#aw2="0.00544868 -0.0000118236 -0.000163245" - -# for Al -#aw1="-0.00201219 -0.00371002 -0.00212719" -#aw2="-0.00117715 0.00188738 -0.000414761" - -# for Be -#aw1="0.0663282, -0.0117682, -0.0335909" -#aw2="0.0479262, 0.00966351, -0.0208712" - - -DATA=${MOL}_${BASIS}_${XF}_${CF}_${w2}.dat -rm $DATA -touch $DATA - -for w2 in $(seq $w_start $dw $w_end) -do - ## w2=${w1} - echo "# Restricted or unrestricted KS calculation" > input/dft - echo " eDFT-UKS" >> input/dft - echo "# exchange rung:" >> input/dft - echo "# Hartree = 0" >> input/dft - echo "# LDA = 1: RS51,RMFL20" >> input/dft - echo "# GGA = 2: RB88" >> input/dft - echo "# Hybrid = 4" >> input/dft - echo "# Hartree-Fock = 666" >> input/dft - echo " 1 $XF " >> input/dft - echo "# correlation rung: " >> input/dft - echo "# Hartree = 0" >> input/dft - echo "# LDA = 1: RVWN5,RMFL20" >> input/dft - echo "# GGA = 2: " >> input/dft - echo "# Hybrid = 4: " >> input/dft - echo "# Hartree-Fock = 666" >> input/dft - echo " 0 $CF " >> input/dft - echo "# quadrature grid SG-n" >> input/dft - echo " 1" >> input/dft - echo "# Number of states in ensemble (nEns)" >> input/dft - echo " 3" >> input/dft - echo "# occupation numbers of orbitals nO and nO+1" >> input/dft - echo " 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 " >> input/dft - echo " 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 " >> input/dft - echo " " >> input/dft - echo " 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 " >> input/dft - echo " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 " >> input/dft - echo " " >> input/dft - echo " 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 " >> input/dft - echo " 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 " >> input/dft - echo "# Ensemble weights: wEns(1),...,wEns(nEns-1)" >> input/dft - echo " ${w1} ${w2} " >> input/dft - echo "# Ncentered ? 0 for NO " >> input/dft - echo " 0 " >> input/dft - echo "# Parameters for CC weight-dependent exchange functional" >> input/dft - echo ${aw1} >> input/dft - echo ${aw2} >> input/dft - echo "# choice of UCC exchange coefficient : 1 for Cx1, 2 for Cx2, 3 for Cx1*Cx2" >> input/dft - echo "2" >> input/dft - echo "# GOK-DFT: maxSCF thresh DIIS n_diis guess_type ortho_type" >> input/dft - echo " 1000 0.00001 T 5 1 1" >> input/dft - OUTPUT=${MOL}_${BASIS}_${XF}_${CF}_${w2}.out - ./GoXC $MOL $BASIS > ${OUTPUT} - Ew=`grep "Ensemble energy:" ${OUTPUT} | cut -d":" -f 2 | sed 's/au//'` - E0=`grep "Individual energy state 1:" ${OUTPUT} | cut -d":" -f 2 | sed 's/au//'` - E1=`grep "Individual energy state 2:" ${OUTPUT} | cut -d":" -f 2 | sed 's/au//'` - E2=`grep "Individual energy state 3:" ${OUTPUT} | cut -d":" -f 2 | sed 's/au//'` - IP=`grep "Ionization Potential" ${OUTPUT} | grep " au" | tail -1 | cut -d":" -f 2 | sed 's/au//'` - EA=`grep "Electronic Affinity" ${OUTPUT} | grep " au" | tail -1 | cut -d":" -f 2 | sed 's/au//'` - FG=`grep "Fundamental Gap" ${OUTPUT} | grep " au" | tail -1 | cut -d":" -f 2 | sed 's/au//'` - Ex=`grep "Exchange energy:" ${OUTPUT} | cut -d":" -f 2 | sed 's/au//'` - HOMOa=`grep "HOMO a energy:" ${OUTPUT} | cut -d":" -f 2 | sed 's/eV//'` - LUMOa=`grep "LUMO a energy:" ${OUTPUT} | cut -d":" -f 2 | sed 's/eV//'` - HOMOb=`grep "HOMO a energy:" ${OUTPUT} | cut -d":" -f 2 | sed 's/eV//'` - LUMOb=`grep "LUMO b energy:" ${OUTPUT} | cut -d":" -f 2 | sed 's/eV//'` - - echo $w1 $w2 $Ew $E0 $E1 $E2 $IP $EA $FG $Ex $HOMOa $LUMOa $HOMOb $LUMOb - echo $w1 $w2 $Ew $E0 $E1 $E2 $IP $EA $FG $Ex $HOMOa $LUMOa $HOMOb $LUMOb >> ${DATA} -done - diff --git a/src/ADC/Makefile b/src/ADC/Makefile index d729abe..6858635 100644 --- a/src/ADC/Makefile +++ b/src/ADC/Makefile @@ -1,3 +1,3 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=ADC.a -include $(QUACK_ROOT)/src/Makefile.include +default: + ninja + make -C .. diff --git a/src/AOtoMO/Makefile b/src/AOtoMO/Makefile index 496724d..6858635 100644 --- a/src/AOtoMO/Makefile +++ b/src/AOtoMO/Makefile @@ -1,3 +1,3 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=AOtoMO.a -include $(QUACK_ROOT)/src/Makefile.include +default: + ninja + make -C .. diff --git a/src/BasCor/Makefile b/src/BasCor/Makefile index f5f92a6..6858635 100644 --- a/src/BasCor/Makefile +++ b/src/BasCor/Makefile @@ -1,3 +1,3 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=BasCor.a -include $(QUACK_ROOT)/src/Makefile.include +default: + ninja + make -C .. diff --git a/src/CC/Makefile b/src/CC/Makefile index 59bdcb4..6858635 100644 --- a/src/CC/Makefile +++ b/src/CC/Makefile @@ -1,3 +1,3 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=CC.a -include $(QUACK_ROOT)/src/Makefile.include +default: + ninja + make -C .. diff --git a/src/CI/Makefile b/src/CI/Makefile index 0c8379f..6858635 100644 --- a/src/CI/Makefile +++ b/src/CI/Makefile @@ -1,3 +1,3 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=CI.a -include $(QUACK_ROOT)/src/Makefile.include +default: + ninja + make -C .. diff --git a/src/HF/Makefile b/src/HF/Makefile index 273c893..6858635 100644 --- a/src/HF/Makefile +++ b/src/HF/Makefile @@ -1,3 +1,3 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=HF.a -include $(QUACK_ROOT)/src/Makefile.include +default: + ninja + make -C .. diff --git a/src/LR/linear_response_ph.f90 b/src/LR/linear_response_ph.f90 deleted file mode 100644 index 3183188..0000000 --- a/src/LR/linear_response_ph.f90 +++ /dev/null @@ -1,88 +0,0 @@ -subroutine linear_response_ph(ispin,dRPA,TDA,BSE,nBas,nC,nO,nV,nR,nS,e,ERI,rho,Ec_phRPA,Omega,XpY) - -! Compute the p-h channel of the linear response - - implicit none - include 'parameters.h' - -! Input variables - - logical,intent(in) :: dRPA,TDA,BSE - integer,intent(in) :: ispin,nBas,nC,nO,nV,nR,nS - double precision,intent(in) :: e(nBas),ERI(nBas,nBas,nBas,nBas),rho(nBas,nBas,nS) - -! Local variables - - double precision,external :: trace_matrix - double precision,allocatable :: A(:,:),B(:,:),M(:,:),w(:) - -! Output variables - - double precision,intent(out) :: Ec_phRPA - double precision,intent(out) :: Omega(nS),XpY(nS,nS) - - -! Memory allocation - - allocate(A(nS,nS),B(nS,nS),M(2*nS,2*nS),w(2*nS)) - -! Build A and B matrices - - call linear_response_A_matrix(ispin,dRPA,nBas,nC,nO,nV,nR,nS,e,ERI,A) - if(BSE) call Bethe_Salpeter_A_matrix(nBas,nC,nO,nV,nR,nS,ERI,Omega,rho,A) - -! Tamm-Dancoff approximation - - B(:,:) = 0d0 - if(.not. TDA) then - - call linear_response_B_matrix(ispin,dRPA,nBas,nC,nO,nV,nR,nS,ERI,B) - if(BSE) call Bethe_Salpeter_B_matrix(nBas,nC,nO,nV,nR,nS,ERI,Omega,rho,B) - - endif - -!------------------------------------------------------------------------ -! Solve the p-h eigenproblem -!------------------------------------------------------------------------ -! -! | +A +B | | X Y | | w 0 | | X Y | -! | | | | = | | | | -! | -B -A | | Y X | | 0 -w | | Y X | -! - -! Diagonal blocks - - M(1:nS,1:nS) = +A(1:nS,1:nS) - M(nS+1:2*nS,nS+1:2*nS) = -A(1:nS,1:nS) - - -! Off-diagonal blocks - - M(1:nS,nS+1:2*nS) = -B(1:nS,1:nS) - M(nS+1:2*nS,1:nS) = +B(1:nS,1:nS) - -! Diagonalize the p-h matrix - - call diagonalize_matrix(2*nS,M(:,:),w(:)) - - Omega(1:nS) = w(nS+1:2*nS) - -! Build X+Y - - XpY(1:nS,1:nS) = M(nS+1:2*nS,1:nS) + M(nS+1:2*nS,nS+1:2*nS) - - call DA(nS,1d0/sqrt(Omega),XpY) - -! print*,'X+Y' -! call matout(nS,nS,XpY) - -! print*,'RPA excitations' - call matout(2*nS,1,w(:)) - -! Compute the RPA correlation energy - - Ec_phRPA = 0.5d0*(sum(Omega) - trace_matrix(nS,A)) - - print*,'Ec_phRPA = ',Ec_phRPA - -end subroutine linear_response_ph diff --git a/src/MBPT/Makefile b/src/MBPT/Makefile index 0901b11..6858635 100644 --- a/src/MBPT/Makefile +++ b/src/MBPT/Makefile @@ -1,3 +1,3 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=MBPT.a -include $(QUACK_ROOT)/src/Makefile.include +default: + ninja + make -C .. diff --git a/src/MC/Makefile b/src/MC/Makefile index a4d87f5..6858635 100644 --- a/src/MC/Makefile +++ b/src/MC/Makefile @@ -1,3 +1,3 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=MC.a -include $(QUACK_ROOT)/src/Makefile.include +default: + ninja + make -C .. diff --git a/src/MP/Makefile b/src/MP/Makefile index 2c6b1ea..6858635 100644 --- a/src/MP/Makefile +++ b/src/MP/Makefile @@ -1,3 +1,3 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=MP.a -include $(QUACK_ROOT)/src/Makefile.include +default: + ninja + make -C .. diff --git a/src/Makefile b/src/Makefile index 8a1ec60..53955c4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,62 +1,14 @@ +.SECONDARY: + QUACK_ROOT=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))/..)) export QUACK_ROOT -SDIR=$(QUACK_ROOT)/src -ALL_DIRS=$(patsubst %/,%,$(wildcard */)) +default: build.ninja + python3 make_ninja.py + ninja -# Rules for Modules -################### - -MOD_DIRS=libnumgrid - - -# Rules for Libraries -##################### - -LDIR =$(QUACK_ROOT)/lib -LIB_DIRS=$(filter-out $(MAIN_DIRS), $(ALL_DIRS)) - -FORCE: - -$(SDIR)/%/Makefile: FORCE - @(echo QUACK_ROOT=$(QUACK_ROOT) > $@) - @(echo TARGET=$*.a >> $@) - @(echo 'include $$(QUACK_ROOT)/src/Makefile.include' >> $@) - -$(LDIR)/%.a: FORCE $(SDIR)/%/Makefile $(MOD_DIRS) - $(MAKE) -C $(SDIR)/$* lib - - - -# Rules for executables -####################### - -MAIN_DIRS=QuAcK eDFT - -BDIR=$(QUACK_ROOT)/bin -ALL_EXEC=$(patsubst %, $(BDIR)/%, $(MAIN_DIRS) ) - -$(BDIR)/%: $(patsubst %,$(LDIR)/%.a,$(LIB_DIRS)) $(SDIR)/%/Makefile - $(MAKE) -C $* $@ - - - - -# Rules for both -################ - -default: $(ALL_EXEC) $(wildcard $(SDIR)/*/Makefile) - -debug: - DEBUG=1 $(MAKE) default - -.DEFAULT_GOAL := default -.PHONY: default debug -.PRECIOUS: $(wildcard $(LDIR)/*.a) $(wildcard $(SDIR)/*/Makefile) -.PRECIOUS: /Users/loos/Dropbox/quack/lib/CI.a /Users/loos/Dropbox/quack/lib/CC.a /Users/loos/Dropbox/quack/lib/ADC.a /Users/loos/Dropbox/quack/lib/MP.a /Users/loos/Dropbox/quack/lib/libnumgrid.a /Users/loos/Dropbox/quack/lib/utils.a /Users/loos/Dropbox/quack/lib/HF.a /Users/loos/Dropbox/quack/lib/LR.a /Users/loos/Dropbox/quack/lib/AOtoMO.a /Users/loos/Dropbox/quack/lib/BasCor.a /Users/loos/Dropbox/quack/lib/RPA.a /Users/loos/Dropbox/quack/lib/MC.a /Users/loos/Dropbox/quack/lib/MBPT.a - -clean: - rm -f -- $(patsubst %/,$(LDIR)/%.a,$(wildcard */)) ; \ - rm -f -- $(ALL_EXEC) ; \ - for i in $(MAIN_DIRS) $(LIB_DIRS) ; do rm -f -- $$i/obj/* ; done +clean: build.ninja + python3 make_ninja.py + ninja -t clean + for i in */ ; do ninja -t clean ; done diff --git a/src/Makefile.common b/src/Makefile.common deleted file mode 100644 index d29dc6a..0000000 --- a/src/Makefile.common +++ /dev/null @@ -1,12 +0,0 @@ -IDIR =$(QUACK_ROOT)/include - -FC = gfortran -I$(IDIR) -J$(IDIR) -#FC = ifort -I$(IDIR) -module $(IDIR) -AR = libtool - -ifeq ($(DEBUG),1) -FFLAGS = -Wall -g -msse4.2 -fcheck=all -Waliasing -Wampersand -Wconversion -Wsurprising -Wintrinsics-std -Wno-tabs -Wintrinsic-shadow -Wline-truncation -Wreal-q-constant -else -FFLAGS = -Wall -Wno-unused -Wno-unused-dummy-argument -O3 -endif - diff --git a/src/Makefile.include b/src/Makefile.include deleted file mode 100644 index 9b95409..0000000 --- a/src/Makefile.include +++ /dev/null @@ -1,44 +0,0 @@ -BDIR =$(QUACK_ROOT)/bin -LDIR =$(QUACK_ROOT)/lib -IDIR =$(QUACK_ROOT)/include -ODIR = obj -SDIR =. -include $(QUACK_ROOT)/src/Makefile.common - -LIBS = $(filter-out $(LDIR)/$(TARGET), $(wildcard $(LDIR)/*.a)) -LIBS += -lblas -llapack -lc++ - -SRCF90 = $(wildcard *.f90) - -SRC = $(wildcard *.f) - -OBJ = $(patsubst %.f90,$(ODIR)/%.o,$(SRCF90)) $(patsubst %.f,$(ODIR)/%.o,$(SRC)) - -FORCE: - -$(ODIR)/%.o: %.f90 - $(FC) -c -o $@ $< $(FFLAGS) - -$(ODIR)/%.o: %.f - $(FC) -c -o $@ $< $(FFLAGS) - -$(LDIR)/$(TARGET): $(patsubst %,$(LDIR)/%,$(DEPEND)) $(OBJ) - $(AR) -static -o $@ $^ - if [[ $(echo *.mod).x != ".x" ]] ; then mv -f *.mod $(IDIR) ; fi - -debug: - DEBUG=1 $(MAKE) $(LDIR)/$(TARGET) - -clean: - rm -f $(ODIR)/*.o $(LDIR)/$(TARGET) - -$(BDIR)/%: $(OBJ) FORCE - $(FC) -o $@ $(FFLAGS) $(LIBS) $(OBJ) - -default: - $(MAKE) -C $(QUACK_ROOT)/src - -lib: $(LDIR)/$(TARGET) - -.DEFAULT_GOAL := default -.PHONY: lib default diff --git a/src/QuAcK/Makefile b/src/QuAcK/Makefile deleted file mode 100644 index bd7e38f..0000000 --- a/src/QuAcK/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=QuAcK.a -include $(QUACK_ROOT)/src/Makefile.include diff --git a/src/QuAcK/QuAcK.f90 b/src/QuAcK/QuAcK.f90 index 4f0b700..09ea252 100644 --- a/src/QuAcK/QuAcK.f90 +++ b/src/QuAcK/QuAcK.f90 @@ -6,6 +6,7 @@ program QuAcK logical :: doSph logical :: unrestricted = .false. logical :: doRHF,doUHF,doMOM + logical :: doKS logical :: doMP2,doMP3,doMP2F12 logical :: doCCD,doCCSD,doCCSDT logical :: do_drCCD,do_rCCD,do_lCCD,do_pCCD @@ -75,6 +76,7 @@ program QuAcK double precision :: start_QuAcK ,end_QuAcK ,t_QuAcK double precision :: start_int ,end_int ,t_int double precision :: start_HF ,end_HF ,t_HF + double precision :: start_KS ,end_KS ,t_KS double precision :: start_MOM ,end_MOM ,t_MOM double precision :: start_AOtoMO ,end_AOtoMO ,t_AOtoMO double precision :: start_CCD ,end_CCD ,t_CCD @@ -151,7 +153,7 @@ program QuAcK ! Which calculations do you want to do? - call read_methods(doRHF,doUHF,doMOM, & + call read_methods(doRHF,doUHF,doKS,doMOM, & doMP2,doMP3,doMP2F12, & doCCD,doCCSD,doCCSDT, & do_drCCD,do_rCCD,do_lCCD,do_pCCD, & @@ -245,7 +247,6 @@ program QuAcK else -! call system('./GoQCaml') call read_integrals(nBas,S,T,V,Hc,ERI_AO) call read_dipole_integrals(nBas,dipole_int) @@ -288,7 +289,7 @@ program QuAcK end if !------------------------------------------------------------------------ -! Compute RHF energy +! Compute UHF energy !------------------------------------------------------------------------ if(doUHF) then @@ -307,6 +308,23 @@ program QuAcK end if +!------------------------------------------------------------------------ +! Compute KS energy +!------------------------------------------------------------------------ + + if(doKS) then + + call cpu_time(start_KS) +! call KS(maxSCF_HF,thresh_HF,n_diis_HF,guess_type,nNuc,ZNuc,rNuc,ENuc, & +! nBas,nO,S,T,V,Hc,ERI_AO,dipole_int,X,EUHF,eHF,cHF,PHF) + call cpu_time(end_KS) + + t_KS = end_KS - start_KS + write(*,'(A65,1X,F9.3,A8)') 'Total CPU time for KS = ',t_KS,' seconds' + write(*,*) + + end if + !------------------------------------------------------------------------ ! Maximum overlap method !------------------------------------------------------------------------ diff --git a/src/QuAcK/read_methods.f90 b/src/QuAcK/read_methods.f90 index 3b4770b..7914233 100644 --- a/src/QuAcK/read_methods.f90 +++ b/src/QuAcK/read_methods.f90 @@ -1,4 +1,4 @@ -subroutine read_methods(doRHF,doUHF,doMOM, & +subroutine read_methods(doRHF,doUHF,doKS,doMOM, & doMP2,doMP3,doMP2F12, & doCCD,doCCSD,doCCSDT, & do_drCCD,do_rCCD,do_lCCD,do_pCCD, & @@ -15,7 +15,7 @@ subroutine read_methods(doRHF,doUHF,doMOM, & ! Input variables - logical,intent(out) :: doRHF,doUHF,doMOM + logical,intent(out) :: doRHF,doUHF,doKS,doMOM logical,intent(out) :: doMP2,doMP3,doMP2F12 logical,intent(out) :: doCCD,doCCSD,doCCSDT logical,intent(out) :: do_drCCD,do_rCCD,do_lCCD,do_pCCD @@ -38,6 +38,7 @@ subroutine read_methods(doRHF,doUHF,doMOM, & doRHF = .false. doUHF = .false. + doKS = .false. doMOM = .false. doMP2 = .false. @@ -80,10 +81,11 @@ subroutine read_methods(doRHF,doUHF,doMOM, & ! Read mean-field methods read(1,*) - read(1,*) answer1,answer2,answer3 + read(1,*) answer1,answer2,answer3,answer4 if(answer1 == 'T') doRHF = .true. if(answer2 == 'T') doUHF = .true. - if(answer3 == 'T') doMOM = .true. + if(answer3 == 'T') doKS = .true. + if(answer4 == 'T') doMOM = .true. ! Read MPn methods diff --git a/src/RPA/Makefile b/src/RPA/Makefile index f64de04..6858635 100644 --- a/src/RPA/Makefile +++ b/src/RPA/Makefile @@ -1,3 +1,3 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=RPA.a -include $(QUACK_ROOT)/src/Makefile.include +default: + ninja + make -C .. diff --git a/src/eDFT/Makefile b/src/eDFT/Makefile deleted file mode 100644 index 17de0e7..0000000 --- a/src/eDFT/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=eDFT.a -include $(QUACK_ROOT)/src/Makefile.include diff --git a/src/eDFT/eDFT.f90 b/src/eDFT/eDFT.f90 index 11cda87..e25365e 100644 --- a/src/eDFT/eDFT.f90 +++ b/src/eDFT/eDFT.f90 @@ -2,6 +2,8 @@ program eDFT ! exchange-correlation density-functional theory calculations + use xc_f90_lib_m + implicit none include 'parameters.h' @@ -63,6 +65,8 @@ program eDFT double precision,allocatable :: occnum(:,:,:) integer :: Cx_choice + integer :: i, vmajor, vminor, vmicro + ! Hello World write(*,*) @@ -71,6 +75,13 @@ program eDFT write(*,*) '******************************************' write(*,*) +! Libxc version + + call xc_f90_version(vmajor, vminor, vmicro) + write(*,'("Libxc version: ",I1,".",I1,".",I1)') vmajor, vminor, vmicro + + call xcinfo() + !------------------------------------------------------------------------ ! Read input information !------------------------------------------------------------------------ diff --git a/src/make_ninja.py b/src/make_ninja.py new file mode 100755 index 0000000..ead8133 --- /dev/null +++ b/src/make_ninja.py @@ -0,0 +1,224 @@ +#!/usr/bin/env python3 +import os +import sys + +if "QUACK_ROOT" not in os.environ: + os.chdir("..") + print("") + print("Please set the QUACK_ROOT environment variable, for example:") + print("") + print("$ export QUACK_ROOT={0}".format(os.getcwd())) + print("") + sys.exit(1) + +QUACK_ROOT=os.environ["QUACK_ROOT"] + +compile_gfortran_mac = """ +FC = gfortran +AR = libtool +FFLAGS = -I$IDIR -J$IDIR -Wall -Wno-unused -Wno-unused-dummy-argument -O3 +CC = gcc +CXX = g++ +LAPACK=-lblas -llapack +STDCXX=-lc++ +""" + +compile_gfortran_mac_debug = """ +FC = gfortran -I$IDIR -J$IDIR +AR = libtool +FFLAGS = -I$IDIR -J$IDIR -Wall -g -msse4.2 -fcheck=all -Waliasing -Wampersand -Wconversion -Wsurprising -Wintrinsics-std -Wno-tabs -Wintrinsic-shadow -Wline-truncation -Wreal-q-constant +CC = gcc +CXX = g++ +LAPACK=-lblas -llapack +STDCXX=-lc++ +""" + + +# TODO Change compiler here +# -------------------------- + +compiler = compile_gfortran_mac +#compiler = compile_gfortran_mac_debug + +header = """# +# This file was automatically generated. Do not modify this file. +# To change compiling options, make the modifications in +# {0}/src/make_ninja.py +# + +QUACK_ROOT={0} +IDIR=$QUACK_ROOT/include +LDIR=$QUACK_ROOT/lib +BDIR=$QUACK_ROOT/bin +SDIR=$QUACK_ROOT/src + +""".format(QUACK_ROOT) + +rule_fortran = """ +rule fc + command = $FC $FFLAGS -c $in -o $out && (mv -f *.mod $IDIR &> /dev/null || :) + +""" + +rule_build_lib = """ +rule build_lib + command = $AR -static $in -o $out + description = Linking $out + +""" + +rule_build_exe = """ + +LIBS = $LDIR/libxcf90.a $LDIR/libxc.a $LDIR/libslatec.a $LDIR/libnumgrid.a $LAPACK $STDCXX + +rule build_exe + command = $FC $in $LIBS -o $out + pool = console + description = Linking $out + +rule build_lib + command = cd $dir ; ninja $out + pool = console + description = Compiling $out + +""" + +rule_slatec = """ +rule make_slatec + command = cd $QUACK_ROOT/slatec/src ; make static ; cp static/libslatec.a $LDIR + pool = console + description = Building Slatec + +build $LDIR/libslatec.a: make_slatec +""" + +rule_git_clone = """ +rule git_clone + command = cd $QUACK_ROOT ; git clone $url + pool = console + description = Cloning $in + +""" + +build_numgrid = """ +rule make_numgrid + command = cd $QUACK_ROOT/utils ; LDIR="$LDIR" SDIR="$SDIR" CC="$CC" CXX="$CXX" FC="$FC" ./install_numgrid.sh + description = Building numgrid + pool = console + +build $LDIR/libnumgrid.a: make_numgrid +""" + + +build_in_lib_dir = "\n".join([ + header, + compiler, + rule_fortran, + rule_build_lib, +]) + + +build_in_exe_dir = "\n".join([ + header, + compiler, + rule_fortran, + rule_build_exe, +]) + +build_main = "\n".join([ + header, + compiler, + rule_git_clone, + build_numgrid, + rule_slatec, +]) + +exe_dirs = [ "QuAcK", "eDFT" ] +lib_dirs = list(filter(lambda x: os.path.isdir(x) and \ + x not in exe_dirs, os.listdir("."))) + +def create_ninja_in_libdir(directory): + def write_rule(f, source_file, replace): + obj_file = os.path.join("obj", source_file.replace(replace, ".o")) + f.write("build {0}: fc {1}\n".format(obj_file,source_file)) + return obj_file + + with open(os.path.join(directory, "build.ninja"),"w") as f: + f.write(build_in_lib_dir) + objects = [] + for filename in os.listdir(directory): + for suffix in [".f", ".f90"]: + if filename.endswith(suffix): + obj_file = write_rule(f, filename, suffix) + objects.append(obj_file) + objects = " ".join(objects) + f.write("build $LDIR/{0}.a: build_lib {1}\n".format(directory,objects)) + f.write("default $LDIR/{0}.a\n".format(directory)) + + +def create_ninja_in_exedir(directory): + def write_rule(f, source_file, replace): + obj_file = os.path.join("obj", source_file.replace(replace, ".o")) + f.write("build {0}: fc {1}\n".format(obj_file,source_file)) + return obj_file + + with open(os.path.join(directory, "build.ninja"),"w") as f: + f.write(build_in_exe_dir) + objects = [] + for filename in os.listdir(directory): + for suffix in [".f", ".f90"]: + if filename.endswith(suffix): + obj_file = write_rule(f, filename, suffix) + objects.append(obj_file) + objects = " ".join(objects) + for libname in lib_dirs: + f.write("build $LDIR/{0}.a: build_lib\n dir = $SDIR/{0}\n".format(libname)) + libs = " ".join([ "$LDIR/{0}.a".format(x) for x in lib_dirs]) + f.write("build $BDIR/{0}: build_exe {1} {2}\n".format(directory,libs,objects)) + f.write("default $BDIR/{0}\n".format(directory)) + + +def create_main_ninja(): + + libs = " ".join([ "$LDIR/{0}.a".format(x) for x in lib_dirs]) + with open("build.ninja","w") as f: + f.write(build_main) + f.write(""" +rule build_exe + command = cd $SDIR/$dir ; ninja $out + pool = console + +rule build_lib + command = cd $dir ; ninja $out + pool = console + description = Compiling $out + +""") + for exe_dir in exe_dirs: + f.write("build $BDIR/{0}: build_exe {1} $LDIR/libnumgrid.a $LDIR/libslatec.a\n".format(exe_dir,libs)) + f.write(" dir = {0} \n".format(exe_dir) ) + for libname in lib_dirs: + f.write("build $LDIR/{0}.a: build_lib\n dir = $SDIR/{0}\n".format(libname)) + f.write("build all: phony $BDIR/QuAcK $BDIR/eDFT\n") + f.write("default all\n") + +def create_makefile(directory): + with open(os.path.join(directory, "Makefile"),"w") as f: + f.write("""default: + ninja + make -C .. +""") + +def main(): + for lib_dir in lib_dirs: + create_ninja_in_libdir(lib_dir) + create_makefile(lib_dir) + + for exe_dir in exe_dirs: + create_ninja_in_exedir(exe_dir) + create_makefile(lib_dir) + + create_main_ninja() + +if __name__ == '__main__': + main() diff --git a/src/libnumgrid/numgrid.f90 b/src/numgrid/numgrid.f90 similarity index 100% rename from src/libnumgrid/numgrid.f90 rename to src/numgrid/numgrid.f90 diff --git a/src/libnumgrid/obj/.gitignore b/src/numgrid/obj/.gitignore similarity index 100% rename from src/libnumgrid/obj/.gitignore rename to src/numgrid/obj/.gitignore diff --git a/src/utils/Makefile b/src/utils/Makefile index a400790..6858635 100644 --- a/src/utils/Makefile +++ b/src/utils/Makefile @@ -1,3 +1,3 @@ -QUACK_ROOT=/Users/loos/Dropbox/quack -TARGET=utils.a -include $(QUACK_ROOT)/src/Makefile.include +default: + ninja + make -C .. diff --git a/utils/install_numgrid.sh b/utils/install_numgrid.sh new file mode 100755 index 0000000..0fe411f --- /dev/null +++ b/utils/install_numgrid.sh @@ -0,0 +1,10 @@ +#!/bin/bash -x + +git clone https://github.com/dftlibs/numgrid.git +cd numgrid +./setup --fc="$FC" --cc="$CC" --cxx="$CXX" +cd build +make +cp lib/libnumgrid.a $LDIR/ +cp ..//numgrid/numgrid.f90 $SDIR/numgrid/ +