mirror of
https://gitlab.com/scemama/eplf
synced 2025-01-02 17:45:54 +01:00
Improved input files. Work to do
This commit is contained in:
parent
b92517db0b
commit
ba98fcf957
132
configure.ac
132
configure.ac
@ -34,8 +34,12 @@ AC_PREREQ([2.50])
|
||||
AC_INIT([EPLF], [], [scemama@irsamc.ups-tlse.fr],[eplf],[http://eplf.sourceforge.net])
|
||||
|
||||
AC_SYS_LONG_FILE_NAMES
|
||||
ROOT=`pwd`
|
||||
AC_SUBST([ROOT])
|
||||
|
||||
EPLF_PATH=`pwd`
|
||||
AC_SUBST(EPLF_PATH)
|
||||
|
||||
EXE=$EPLF_PATH/bin/eplf
|
||||
AC_SUBST(EXE)
|
||||
|
||||
AC_CONFIG_SRCDIR([src/main.irp.f])
|
||||
AC_CONFIG_FILES([make.config])
|
||||
@ -45,6 +49,103 @@ AC_PROG_LN_S
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_CC
|
||||
|
||||
|
||||
# Check for wget
|
||||
AC_CHECK_PROGS([WGET],[wget],[])
|
||||
|
||||
######################################################
|
||||
# Define download function
|
||||
AC_DEFUN([AC_DOWNLOAD],[{
|
||||
# AC_DOWNLOAD ( VARIABLE, name, url )
|
||||
WHERE=
|
||||
if [[ ! -z $WGET ]] ; then
|
||||
echo ""
|
||||
echo "**************************"
|
||||
echo $2 is not installed
|
||||
echo "**************************"
|
||||
echo "Do you want to download it?"
|
||||
select x in yes no
|
||||
do
|
||||
if [[ ! -z $x ]] ; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ $x == yes ]] ; then
|
||||
if [[ ! -d "Downloads" ]] ; then
|
||||
mkdir $EPLF_PATH/Downloads
|
||||
fi
|
||||
cd $EPLF_PATH/Downloads
|
||||
mkdir $EPLF_PATH/Downloads/tmp
|
||||
cd $EPLF_PATH/Downloads/tmp
|
||||
wget -nc "$3" && WHERE=`ls -tr | tail -1`
|
||||
mv * $EPLF_PATH/Downloads
|
||||
cd $EPLF_PATH/Downloads
|
||||
rm -rf tmp
|
||||
cd $EPLF_PATH
|
||||
fi
|
||||
if [[ ! -z $WHERE ]] ; then
|
||||
echo $2 was downloaded to Downloads/$WHERE.
|
||||
$1=1
|
||||
else
|
||||
AC_MSG_ERROR([$2 should be installed. You can download it at
|
||||
$3])
|
||||
fi
|
||||
else
|
||||
AC_MSG_ERROR([Please download $2 at
|
||||
$3])
|
||||
fi
|
||||
}])
|
||||
|
||||
######################################################
|
||||
# Check for python
|
||||
AC_CHECK_PROGS([PYTHON],[python],[])
|
||||
if [[ -z $PYTHON ]] ; then
|
||||
AC_MSG_ERROR([Python should be installed:
|
||||
http://www.python.org])
|
||||
fi
|
||||
|
||||
######################################################
|
||||
# IRPF90 compiler
|
||||
AC_CHECK_PROGS([IRPF90],[irpf90],[])
|
||||
if [[ -z $IRPF90 ]] ; then
|
||||
AC_DOWNLOAD([IRPF90],[IRPF90],[http://sourceforge.net/projects/irpf90/files/latest])
|
||||
AC_MSG_ERROR([Install IRPF90 and run this configure script again.])
|
||||
fi
|
||||
|
||||
######################################################
|
||||
# EZFIO
|
||||
EZFIO=`ls EZFIO*.tar.gz`
|
||||
if [[ -z $EZFIO ]] ; then
|
||||
AC_DOWNLOAD([EZFIO],[EZFIO],[http://sourceforge.net/projects/ezfio/files/latest])
|
||||
if [[ -z $EZFIO ]] ; then
|
||||
AC_MSG_ERROR([Download EZFIO.tar.gz into $PWD and run this configure script again.])
|
||||
fi
|
||||
mv Downloads/EZFIO*.tar.gz .
|
||||
fi
|
||||
|
||||
######################################################
|
||||
# Check for MPI
|
||||
EPLF_HAS_MPI=0
|
||||
if [[ -z "$STATIC" ]] ; then
|
||||
AC_CHECK_PROGS([MPIRUN],[mpirun mpiexec],[])
|
||||
if [[ ! -z $MPIRUN ]] ; then
|
||||
MPIRUN=`which $MPIRUN`
|
||||
fi
|
||||
|
||||
AC_CHECK_PROGS([MPIFC],[mpif90],[])
|
||||
if [[ -z $MPIFC ]] ; then
|
||||
echo "**************************"
|
||||
echo "Warning: MPI not found. You can get OpenMPI at:"
|
||||
echo "http://www.open-mpi.org/software/ompi/v1.4/downloads/openmpi-1.4.1.tar.gz"
|
||||
echo "**************************"
|
||||
else
|
||||
EPLF_HAS_MPI=1
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([EPLF_HAS_MPI])
|
||||
|
||||
|
||||
|
||||
# Test if Static zlib is present
|
||||
# ------------------------------
|
||||
|
||||
@ -52,15 +153,6 @@ AC_CHECK_LIB([z],[gzclose],[STATIC=1],[STATIC=0],[-static])
|
||||
STATIC_LIB="../EZFIO/lib/libezfio_irp.a"
|
||||
SHARED_LIB="-L../EZFIO/lib -lezfio"
|
||||
|
||||
# Test IRPF90
|
||||
# ------------
|
||||
|
||||
AC_CHECK_PROG([IRPF90],[irpf90],[yes],[no])
|
||||
if [[ $IRPF90 = no ]] ; then
|
||||
AC_MSG_ERROR([Please install IRPF90:\nhttp://irpf90.sourceforge.net])
|
||||
fi
|
||||
IRPF90=`which irpf90`
|
||||
|
||||
# Test Fortran
|
||||
# ------------
|
||||
|
||||
@ -101,7 +193,7 @@ else
|
||||
=====================================================
|
||||
|
||||
Using shared library. Add
|
||||
$ROOT/EZFIO/lib/
|
||||
$EPLF_PATH/EZFIO/lib/
|
||||
to the LD_LIBRARY_PATH environment variable.
|
||||
|
||||
=====================================================
|
||||
@ -109,6 +201,22 @@ else
|
||||
fi
|
||||
AC_SUBST([LIB])
|
||||
|
||||
cd $EPLF_PATH
|
||||
echo "export EPLF_PATH=$EPLF_PATH" > $HOME/.eplfrc
|
||||
echo "export LD_LIBRARY_PATH=\$EPLF_PATH/EZFIO/lib/:\$LD_LIBRARY_PATH" >> $HOME/.qmcchemrc
|
||||
echo "export PATH=\$PATH:\$EPLF_PATH/bin/" >> $HOME/.eplfrc
|
||||
echo "export PATH=\$PATH:\$EPLF_PATH/scripts/" >> $HOME/.eplfrc
|
||||
echo "export EPLF_HAS_MPI=$EPLF_HAS_MPI" >> $HOME/.eplfrc
|
||||
echo "export EPLF_MPIRUN=$MPIRUN" >> $HOME/.eplfrc
|
||||
echo "************************************"
|
||||
echo "To finish the installation:"
|
||||
echo "1) Add the following line to your $HOME/.basrhc file:"
|
||||
echo ". $HOME/.eplfrc"
|
||||
echo "2) Execute"
|
||||
echo ". $HOME/.eplfrc"
|
||||
echo "make"
|
||||
echo "************************************"
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
|
||||
|
@ -53,6 +53,7 @@ grid_data
|
||||
density_lapl real (grid_num_x,grid_num_y,grid_num_z)
|
||||
|
||||
compute
|
||||
nproc integer
|
||||
eplf logical
|
||||
eplf_grad logical
|
||||
eplf_lapl logical
|
||||
|
@ -39,8 +39,6 @@ class GeometryEditor(Editor):
|
||||
print >>file, "# Geometry : %s"%(inp.name)
|
||||
print >>file, "###########################"
|
||||
print >>file, ""
|
||||
has_fitcusp = False
|
||||
has_label = False
|
||||
fields = "Charge X Y Z"
|
||||
format = "%10.1f "+"%10.6f "*3
|
||||
fields = fields.split()
|
||||
@ -66,9 +64,76 @@ class GeometryEditor(Editor):
|
||||
coord[2].append(float(line[-1]))
|
||||
inp.coord = coord
|
||||
|
||||
class GridEditor(Editor):
|
||||
def action(self):
|
||||
self.origin= self.inp.origin
|
||||
self.opposite = self.inp.opposite
|
||||
self.step_size = self.inp.step_size
|
||||
self.point_num = self.inp.point_num
|
||||
if self.origin is None:
|
||||
self.origin = [ 0., 0., 0. ]
|
||||
for l in xrange(3):
|
||||
self.origin[l] = self.inp.nucl_coord[l][1]
|
||||
for i in self.inp.nucl_coord[l]:
|
||||
self.origin[l] = min(self.origin[l],i)
|
||||
self.origin[l] -= 4.
|
||||
if self.opposite is None:
|
||||
self.opposite = [ 0., 0., 0. ]
|
||||
for l in xrange(3):
|
||||
self.opposite[l] = self.inp.nucl_coord[l][1]
|
||||
for i in self.inp.nucl_coord[l]:
|
||||
self.opposite[l] = max(self.opposite[l],i)
|
||||
self.opposite[l] += 4.
|
||||
if self.step_size is None:
|
||||
self.step_size = [ 0., 0., 0. ]
|
||||
for l in xrange(3):
|
||||
self.step_size[l] = (self.opposite[l] - self.origin[l])/float(self.point_num[l])
|
||||
|
||||
self.inp.point_num = self.point_num
|
||||
self.inp.origin = self.origin
|
||||
self.inp.opposite = self.opposite
|
||||
self.inp.step_size = self.step_size
|
||||
edit_temp_file(self.inp,self.write_grid_file,self.read_grid_file)
|
||||
|
||||
def write_grid_file(self,file,inp):
|
||||
print >>file, "###########################"
|
||||
print >>file, "# Grid : %s"%(inp.name)
|
||||
print >>file, "###########################"
|
||||
print >>file, ""
|
||||
print >>file, "# Number of points along x, y, z"
|
||||
print >>file, "%d %d %d"%tuple(self.point_num)
|
||||
print >>file, ""
|
||||
print >>file, "# Coordinates of the origin (x,y,z)"
|
||||
print >>file, "%f %f %f"%tuple(self.origin)
|
||||
print >>file, ""
|
||||
print >>file, "# Coordinates of the opposite point (x,y,z)"
|
||||
print >>file, "%f %f %f"%tuple(self.opposite)
|
||||
print >>file, ""
|
||||
print >>file, "# Step sizes (x,y,z)"
|
||||
print >>file, "%f %f %f"%tuple(self.step_size)
|
||||
|
||||
def read_grid_file(self,file,inp):
|
||||
lines = file.readlines()
|
||||
lines = filter(lambda x: len(x.strip())>0,lines)
|
||||
lines = filter(lambda x: not x.startswith("#"),lines)
|
||||
|
||||
buffer = lines.pop(0).split()
|
||||
self.inp.point_num = map(int,buffer)
|
||||
|
||||
buffer = lines.pop(0).split()
|
||||
self.inp.origin = map(float,buffer)
|
||||
|
||||
buffer = lines.pop(0).split()
|
||||
self.inp.opposite = map(float,buffer)
|
||||
|
||||
buffer = lines.pop(0).split()
|
||||
self.inp.step_size = self.step_size
|
||||
|
||||
|
||||
|
||||
def edit(x,inp):
|
||||
d = { "geometry": GeometryEditor,
|
||||
"grid_parameters": GridEditor,
|
||||
}
|
||||
d[x](inp,x.replace("_"," ")).edit()
|
||||
|
||||
@ -139,6 +204,28 @@ def edit_temp_file(input_file,write_file,read_file,saved_file=None):
|
||||
|
||||
os.remove(filename)
|
||||
|
||||
|
||||
def build_script(inp):
|
||||
grid = "${EPLF_PATH}/bin/to_cube %s"%(inp.name)
|
||||
run_script = "run_"+inp.name
|
||||
file = open(run_script,'w')
|
||||
buffer = """
|
||||
#!/bin/bash
|
||||
source ${HOME}/.eplfrc
|
||||
$RUNCOMMAND
|
||||
$RUNGRID
|
||||
""".lstrip()
|
||||
command = "${EPLF_PATH}/bin/eplf %s"%(inp.name)
|
||||
if inp.has_mpi:
|
||||
command = "${MPIRUN} -np %d "%(inp.nproc)+command
|
||||
grid = "${MPIRUN} -np 1 "+command
|
||||
buffer = buffer.replace("$RUNCOMMAND",command)
|
||||
buffer = buffer.replace("$RUNGRID",grid)
|
||||
print >>file, buffer
|
||||
file.close()
|
||||
os.chmod(run_script,0744)
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) not in [2,3]:
|
||||
print "Syntax : %s <EZFIO_File> [input_file]"%(sys.argv[0])
|
||||
@ -149,5 +236,6 @@ def main():
|
||||
else:
|
||||
saved_file = None
|
||||
edit_temp_file(inp,write_main_file,read_main_file,saved_file)
|
||||
build_script(inp)
|
||||
|
||||
main()
|
||||
|
@ -6,10 +6,10 @@ import os
|
||||
geom_data = """
|
||||
nucl_charge nucl_coord
|
||||
""".split()
|
||||
ro_data = """det_num nucl_num mo_num ao_num
|
||||
ro_data = """det_num nucl_num mo_num ao_num has_mpi
|
||||
""".split()
|
||||
rw_data = """
|
||||
point_num step_size origin opposite
|
||||
point_num step_size origin opposite nproc
|
||||
compute_elf compute_eplf compute_density
|
||||
compute_elf_grad compute_eplf_grad compute_density_grad
|
||||
compute_elf_lapl compute_eplf_lapl compute_density_lapl
|
||||
@ -60,9 +60,18 @@ class InputFile(object):
|
||||
raise InputFileExn("This directory is not a EZFIO file.")
|
||||
os.chdir(wd)
|
||||
ezfio.set_filename(name)
|
||||
self.name = name
|
||||
l = len(name)
|
||||
while name[l-1] == '/':
|
||||
l -= 1
|
||||
self.name = name[:l]
|
||||
|
||||
# Read-only values
|
||||
def get_has_mpi(self):
|
||||
if os.getenv("EPLF_HAS_MPI","1") == "1":
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_det_num(self):
|
||||
if ezfio.has_determinants_det_num():
|
||||
return ezfio.get_determinants_det_num()
|
||||
@ -168,10 +177,9 @@ class InputFile(object):
|
||||
if len(value) != 3:
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
if not isinstance(i,list):
|
||||
if not isinstance(i,float):
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
for j in i:
|
||||
for j in value:
|
||||
try:
|
||||
float(j)
|
||||
except:
|
||||
@ -191,16 +199,28 @@ class InputFile(object):
|
||||
if len(value) != 3:
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
if not isinstance(i,list):
|
||||
if not isinstance(i,float):
|
||||
raise InputFileExn("Wrong type")
|
||||
for i in value:
|
||||
for j in i:
|
||||
for j in value:
|
||||
try:
|
||||
float(j)
|
||||
except:
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_grid_opposite(value)
|
||||
|
||||
def get_nproc(self):
|
||||
if ezfio.has_compute_nproc():
|
||||
return ezfio.get_compute_nproc()
|
||||
else:
|
||||
return 1
|
||||
|
||||
def set_nproc(self,value):
|
||||
if not isinstance(value,int):
|
||||
raise InputFileExn("Wrong type")
|
||||
if value < 1:
|
||||
raise InputFileExn("Wrong type")
|
||||
ezfio.set_compute_nproc(value)
|
||||
|
||||
def get_compute_elf(self):
|
||||
if ezfio.has_compute_elf():
|
||||
return ezfio.get_compute_elf()
|
||||
|
Loading…
Reference in New Issue
Block a user