10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-12-21 11:53:30 +01:00

Added scripts

This commit is contained in:
Anthony Scemama 2015-12-20 01:09:14 +01:00
parent 99e4ad9e12
commit 6eb9a00101
11 changed files with 371 additions and 16 deletions

View File

@ -37,15 +37,48 @@ Warnings:
Requirements Requirements
------------ ------------
* Ninja building system (replacement for GNU make) * [Ninja build tool](http://github.com/martine/ninja)
* EZFIO library generator * [Ocaml compiler with Opam and Core library](http://github.com/ocaml)
* ZeroMQ library * [ZeroMQ high performance communication library](http://www.zeromq.org)
* ZeroMQ Fortran77 binding * [F77_ZMQ ZeroMQ Fortran interface](http://github.com/scemama/f77_zmq/)
* IRPF90 Fortran code generator * [IRPF90 Fortran code generator](http://irpf90.ups-tlse.fr)
* OCaml compiler * [EZFIO Easy Fortran I/O library generator](http://github.com/scemama/EZFIO)
* Fortran compiler (Intel Fortran recommended) * GNU C++ Compiler (g++) for ZeroMQ
* Python >= 2.6 for install scripts
* Bash
* Fortran compiler, Intel Fortran recommended
* Lapack library, Intel MKL recommended
Most of the dependencies are open-source will be downloaded automatically.
The Fortran and C++ compilers, Python and Bash interpreters and the Lapack
library need to be installed manually by the user.
Installation
------------
This script will first download the [Ninja](http://github.com/martine/ninja)
build tool, and will then run Ninja using the ``install/build.ninja`` file.
The configuration script will work in the ``install`` directory. It will first
download into the ``install/Downloads`` directory everything that needs to be
installed. The building of the dependencies takes place in the ``install/_build``
directory, and the packages that are being installed can be followed by looking
at the log files in this directory. When a package was successfully installed,
a ``*.ok`` file is created and the log file is deleted.
Before using or compiling QMC=Chem, environment variables need to be loaded. The
environment variables are located in the ``qmcchemrc`` file:
```bash
$ source qmcchemrc
```
To compile the program, run
```bash
$ ninja
```
All the dependencies will be downloaded automatically
Example of a QMC=Chem calculation Example of a QMC=Chem calculation
--------------------------------- ---------------------------------

91
build.ninja Normal file
View File

@ -0,0 +1,91 @@
rule compile_ezfio
command = ./scripts/compile_ezfio.sh
description = Compiling the EZFIO library
pool = console
rule build_properties_config
command = bash -c "source qmcchemrc ; exec python ./scripts/create_properties_ezfio.py"
pool = console
rule compile_irpf90
command = ./scripts/compile_irpf90.sh
description = Compiling IRPF90
pool = console
rule compile_src
command = ./scripts/compile_src.sh
description = Compiling src
pool = console
rule create_archive
command = git archive --format tar.gz HEAD --prefix "QmcChem/" -7 -o qmcchem.tar.gz
description = Creating archive
pool = console
rule compile_ocaml_dep
command = scripts/compile_ocaml_dep.sh
description = Finding dependencies in OCaml files
pool = console
rule compile_ocaml
command = scripts/compile_ocaml.sh $target
description = Compiling OCaml tools
pool = console
rule copy_to_bin
command = bash -c "cp $in $out ; touch $out"
description = Copying $in into bin/
pool = console
rule clean
command = ./scripts/clean.sh
pool = console
# put all files of PROPERTIES here
# --------------------------------
build ezfio_config/properties.config: build_properties_config | src/PROPERTIES/density.irp.f src/PROPERTIES/properties.irp.f src/PROPERTIES/properties_energy.irp.f src/PROPERTIES/voronoi.irp.f src/PROPERTIES/properties_general.irp.f scripts/create_properties_python.py || src/IRPF90_temp/build.ninja
# EZFIO
# -----
build lib/libezfio.a lib/libezfio_irp.a EZFIO/lib/libezfio.a EZFIO/lib/libezfio_irp.a EZFIO/Ocaml/ezfio.ml EZFIO/Python/ezfio.py: compile_ezfio | ezfio_config/qmc.config ezfio_config/properties.config make.config scripts/create_properties_ezfio.py || src/tags src/irpf90_entities src/irpf90.make src/IRPF90_temp/build.ninja
# Fortran executables
# -------------------
build always: phony
build src/tags src/irpf90_entities src/irpf90.make src/IRPF90_temp/build.ninja: compile_irpf90 | make.config always
build src/MAIN/qmc src/MAIN/qmc_nozmq src/MAIN/qmc_create_walkers src/MAIN/qmcchem_info: compile_src | lib/libezfio.a lib/libezfio_irp.a src/tags || src/irpf90_entities src/irpf90.make src/IRPF90_temp/build.ninja
# Archive
# -------
build qmcchem.tar.gz: create_archive
# Ocaml
# -----
build ocaml/generated.ninja : compile_ocaml_dep | always
build ocaml/qmcchem : compile_ocaml | ocaml/generated.ninja EZFIO/Ocaml/ezfio.ml
target = qmcchem
# Copy binaries in bin
# --------------------
build bin/qmc: copy_to_bin src/MAIN/qmc
build bin/qmcchem_info: copy_to_bin src/MAIN/qmcchem_info
build bin/qmc_create_walkers: copy_to_bin src/MAIN/qmc_create_walkers
build bin/qmc_nozmq: copy_to_bin src/MAIN/qmc_nozmq
build bin/qmcchem: copy_to_bin ocaml/qmcchem
default bin/qmc bin/qmcchem_info bin/qmc_create_walkers bin/qmc_nozmq bin/qmcchem
# Clean
# -----
build clean: clean

View File

@ -6,7 +6,8 @@ then
exit -1 exit -1
fi fi
cd ${QMCCHEM_PATH}/ocaml cd ${QMCCHEM_PATH}/ocaml || exit -1
cp ${QMCCHEM_PATH}/EZFIO/Ocaml/ezfio.ml . || exit -1
LSMD5_FILE=${QMCCHEM_PATH}/ocaml/.ls_md5 LSMD5_FILE=${QMCCHEM_PATH}/ocaml/.ls_md5
FILES="*.ml *.mli" FILES="*.ml *.mli"
@ -19,6 +20,7 @@ then
REF=$(cat ${LSMD5_FILE}) REF=$(cat ${LSMD5_FILE})
fi fi
if [[ ${MD5} != ${REF} ]] if [[ ${MD5} != ${REF} ]]
then then
echo ${MD5} > ${LSMD5_FILE} echo ${MD5} > ${LSMD5_FILE}

21
scripts/clean.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
# This script is supposed to run in $QMCCHEM_PATH
ninja -C ocaml clean
if [[ -d src/IRPF90_temp ]]
then
ninja -C src/IRPF90_temp -t clean
fi
ninja -t clean
rm -f ocaml/qmcchem ocaml/.ls_md5 ocaml/generated.ninja
rm -f EZFIO/Ocaml/ezfio.ml
cd src
rm -rf tags irpf90_entities irpf90.make IRPF90_temp IRPF90_man .ls_md5
cd MAIN
rm -f qmc qmcchem_info qmc_create_walkers
cd ../..

18
scripts/compile_ezfio.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
if [[ ! -f qmcchemrc ]]
then
echo "Error: qmcchemrc not found"
exit -1
fi
source make.config
source qmcchemrc
FCFLAGS="${FCFLAGS} -fPIC"
export IRPF90 FC FCFLAGS AR RANLIB
cd EZFIO
rm -f make.config
${NINJA} || exit -1
cp lib/libezfio{,_irp}.a ${QMCCHEM_PATH}/lib/ || exit 1

49
scripts/compile_irpf90.sh Executable file
View File

@ -0,0 +1,49 @@
#!/bin/bash
if [[ -z ${QMCCHEM_PATH} ]]
then
echo "Error: qmcchemrc not loaded"
exit -1
fi
cd ${QMCCHEM_PATH}/src
LSMD5_FILE=${QMCCHEM_PATH}/src/.ls_md5
FILES="*.f *.f90 *.F *.py */*.f */*.f90 */*.F */*.py"
MD5=$(ls -ltr --full-time ${FILES} 2>/dev/null | md5sum | cut -d ' ' -f 1)
REF=0
if [[ -f ${LSMD5_FILE} ]]
then
REF=$(cat ${LSMD5_FILE})
fi
if [[ ${MD5} != ${REF} ]]
then
echo ${MD5} > ${LSMD5_FILE}
echo Running IRPF90
source ${QMCCHEM_PATH}/make.config
LIB="${LIB} ${QMCCHEM_PATH}/lib/libezfio_irp.a ${QMCCHEM_PATH}/lib/libf77zmq.a ${QMCCHEM_PATH}/lib/libzmq.a -lstdc++ -lrt"
SRC="${SRC} ZMQ/f77_zmq_module.f90"
OBJ="${OBJ} IRPF90_temp/ZMQ/f77_zmq_module.o"
INCLUDES="${INCLUDES} -I AO -I SAMPLING -I TOOLS -I JASTROW -I TESTING -I MAIN -I PROPERTIES -I ZMQ"
IRPF90_FLAGS="${IRPF90_FLAGS} --ninja"
# Check IRPF90 version
if [[ $( ${IRPF90} -v | python -c "import sys ; print float(sys.stdin.read().rsplit('.',1)[0]) >= 1.6") == False ]]
then
echo "IRPF90 version >= 1.6 required"
exit -1
fi
export IRPF90 IRPF90_FLAGS INCLUDES LIB SRC OBJ
exec ${IRPF90} ${IRPF90_FLAGS} ${INCLUDES} || exit -1
fi

13
scripts/compile_ocaml.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
if [[ -z ${QMCCHEM_PATH} ]]
then
echo "Error: qmcchemrc not loaded"
exit -1
fi
cd ${QMCCHEM_PATH}/ocaml || exit -1
cp ${QMCCHEM_PATH}/EZFIO/Ocaml/ezfio.ml . || exit -1
exec ninja -f generated.ninja ${@}

39
scripts/compile_ocaml_dep.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
if [[ -z ${QMCCHEM_PATH} ]]
then
echo "Error: qmcchemrc not loaded"
exit -1
fi
cd ${QMCCHEM_PATH}/ocaml || exit -1
LSMD5_FILE=${QMCCHEM_PATH}/ocaml/.ls_md5
FILES="*.ml *.mli"
MD5=$(ls -ltr --full-time ${FILES} 2>/dev/null | md5sum | cut -d ' ' -f 1)
REF=0
if [[ -f ${LSMD5_FILE} ]]
then
REF=$(cat ${LSMD5_FILE})
fi
if [[ ${MD5} != ${REF} ]]
then
echo ${MD5} > ${LSMD5_FILE}
echo Finding dependencies in OCaml files
python ./ninja_ocaml.py
if [[ ! -f qptypes_generator ]]
then
ninja -f generated.ninja qptypes_generator
fi
if [[ ! -f Qptypes.ml ]]
then
./qptypes_generator
python ./ninja_ocaml.py
fi
fi

11
scripts/compile_src.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
if [[ -z ${QMCCHEM_PATH} ]]
then
echo "Error: qmcchemrc not loaded"
exit -1
fi
cd ${QMCCHEM_PATH}/src/IRPF90_temp || exit -1
exec ninja ${@}

View File

@ -0,0 +1,81 @@
#!/usr/bin/python
import string
import os
import sys
root = os.environ['QMCCHEM_PATH']
os.chdir(root+'/src/')
sys.path.insert(0,'./')
properties = []
dims = {}
files = filter(lambda x: x.startswith("PROPERTIES") and \
x.endswith("irp.f"), os.listdir(os.getcwd()))
files = map(lambda x: 'PROPERTIES/'+x, filter(lambda x: x.endswith("irp.f"), os.listdir(os.getcwd()+'/PROPERTIES')))
#files = filter(lambda x: x.endswith("irp.f"), os.listdir(os.getcwd()))
for filename in files:
lines = []
check_dims = False
file = open(filename,'r')
lines += file.readlines()
file.close()
for i,line in enumerate(lines):
if line.startswith("! PROPERTIES"):
lines = lines[i:]
break
for line in map(lambda x: x.lower(),lines):
if line.lstrip().startswith('begin_provider'):
check_dims = False
buffer = line
buffer = buffer.split('[')[1]
buffer = buffer.split(']')[0]
buffer = buffer.split(',')
if (len(buffer) == 2):
buffer.append("")
else:
buffer = [ buffer[0], buffer[1], ','.join(buffer[2:]) ]
check_dims = True
buffer = map(string.strip,buffer)
properties.append(buffer)
current_prop = buffer[1]
elif check_dims:
if 'dimensions :' in line:
dims[current_prop] = line.split(':')[1].strip()
import numerical_derivatives as deriv
properties += map(lambda x: ["double precision", "d_var_"+x.lower(), "(size_d_var_"+x.lower()+")"], deriv.vectors)
properties += map(lambda x: ["double precision", "d_var_"+x.lower(), "(7)"], deriv.scalars)
def sq(item):
return [item[0], item[1]+"_2", item[2]]
properties_with_square = properties + map(sq,properties)
for p in [ properties, properties_with_square ]:
def c(x,y):
if x[1] > y[1]: return 1
if x[1] == y[1]: return 0
if x[1] < y[1]: return -1
p.sort(c)
def touch_all():
print "TOUCH",
for p in properties:
print "calc_"+p[1],
print ""
with open(root+'/scripts/properties.py','w') as f:
print >>f,'properties = ',properties
print >>f,'dims = ',dims

View File

@ -13,15 +13,12 @@ program qmcchem_info
endif endif
print *, 'Number of determinants : ', det_num print *, 'Number of determinants : ', det_num
print *, 'Number of unique alpha/beta determinants : ', det_alpha_num, det_beta_num print *, 'Number of unique alpha/beta determinants : ', det_alpha_num, det_beta_num
! print *, 'Number of vectors in SVD : ', psi_svd_size
print *, 'Closed-shell MOs : ', mo_closed_num print *, 'Closed-shell MOs : ', mo_closed_num
print *, 'Number of MOs in determinants : ', num_present_mos print *, 'Number of MOs in determinants : ', num_present_mos
! print *, 'do SVD? : ', do_det_svd ! print *, 'Det alpha norm:'
! print *, 'det_coef matrix is sparse : ', det_coef_matrix_is_sparse ! print *, det_alpha_norm
print *, 'Det alpha norm:' ! print *, 'Det beta norm:'
print *, det_alpha_norm ! print *, det_beta_norm
print *, 'Det beta norm:'
print *, det_beta_norm
call step1 call step1
call cpu_time (cpu0) call cpu_time (cpu0)
call step2(imax) call step2(imax)