Merge pull request #2 from scemama/master

v1.3.0
This commit is contained in:
Anthony Scemama 2015-06-02 16:28:26 +02:00
commit db5d8597ac
22 changed files with 521 additions and 4244 deletions

18
.gitignore vendored
View File

@ -1 +1,19 @@
update.sh
Python/ezfio.py
Ocaml/ezfio.ml
Bash/ezfio.sh
.ninja_deps
.ninja_log
generated.ninja
lib/libezfio.a
lib/libezfio_irp.a
make.config
src/IRPF90_man/
src/IRPF90_temp/
src/irpf90.make
src/irpf90_entities
src/libezfio_groups-gen.py
src/libezfio_util-gen.py
src/*.pyc
src/run
src/tags

0
Bash/.empty Normal file
View File

View File

@ -25,20 +25,17 @@
include version
include make.config
.PHONY: default clean distclean archive configure
.PHONY: default clean veryclean archive configure
default: make.config
- bash -c "[[ -e lib/libezfio.a ]] && rm $$PWD/lib/*"
@echo Compiling library && make -C $$PWD/src static
@echo Building Python module && make -C $$PWD/src python
$(MAKE) -C $$PWD/src
clean:
- bash -c "[[ -e lib/libezfio.a ]] && rm $$PWD/lib/*"
- bash -c "[[ -e Python/ezfio.py ]] && rm $$PWD/Python/*"
- make -C $$PWD/src veryclean
distclean: clean
- rm -rf autom4te.cache config.status config.log make.config
- bash -c "[[ -f lib/libezfio.a ]] && rm $$PWD/lib/*"
- bash -c "[[ -f Python/ezfio.py ]] && rm $$PWD/Python/*"
- bash -c "[[ -f Ocaml/ezfio.ml ]] && rm $$PWD/Ocaml/*"
- bash -c "[[ -f Bash/ezfio.sh ]] && rm $$PWD/Bash/*"
- $(MAKE) -C $$PWD/src veryclean
archive: distclean
git archive --format=tar HEAD > EZFIO.$(VERSION).tar
@ -47,9 +44,12 @@ archive: distclean
tar -zcvf EZFIO.$(VERSION).tar.gz EZFIO
rm -rf EZFIO
configure: make.config.in configure.ac
autoconf
make.config:
./configure --host=dummy
python configure.py
veryclean:
$(MAKE) -C src veryclean
rm -f make.config
rm -f Ocaml/ezfio.ml
rm -f Python/ezfio.py
rm -f lib/{libezfio.a,libezfio_irp.a}

86
README
View File

@ -1,86 +0,0 @@
======================================================================
EZFIO
======================================================================
Author: A. Scemama, LCPQ-IRSAMC, CNRS-Universite Paul Sabatier
scemama@irsamc.ups-tlse.fr
== About EZFIO ==
EZFIO is the Easy Fortran I/O library. With EZFIO, your data is organized
in a file system inside a main directory. This main directory contains
subdirectories, which contain files. Each file corresponds to a data. For
atomic data the file is a plain text file, and for array data the file is a
gzipped text file.
== Building a library ==
Your EZFIO library is built according to the definitions given in the
files of the 'config' directory. A configuration file can be, for example:
---
system
title character*(128)
num_elec integer = system_num_alpha + system_num_beta
num_alpha integer
num_beta integer
geometry
num_atom integer
nuc_energy double precision
label character*(32) (geometry_num_atom)
atomic_number integer (geometry_num_atom)
charge double precision (geometry_num_atom)
coord double precision (3,geometry_num_atom)
---
A subdirectory is defined by its name at the beginning of a new line. The
data contained in this subdirectory is defined by the triplet
(name,type,dimension), leaving at least one white space at the beginning of the
line.
If the dimension of an array is a data defined in the file, its name can be
used as <name of the subdirectory>_<name of the data>. For example, the
dimension '(geometry_num_atom)' uses the data 'num_atom' of subdirectory
'geometry'.
A data can also be the result of a simple operation. In that case, the
simple operation is written after an '=' symbol (as for 'num_elec'). In
that case, the data is read_only.
Once your configuration file is ready, run 'make' and your library will be
built.
== Using the library ==
In the following, we will call 'EZFIO file' the main directory containing the
EZFIO data.
Only one EZFIO file can be manipulated at a time. To select a file, use:
character*(64) :: filename
call ezfio_set_file(filename)
To get the name of the current used EZFIO file, use
character*(64) :: filename
call ezfio_get_filename(filename)
For each data, 3 subroutines are created.
<dir> is the name of the subdirectory which contains the data and
<data> is the name of the data.
* subroutine ezfio_has_<dir>_<data> (result)
sets result to .True. if the data exists in the EZFIO file, .False. otherwise.
* subroutine ezfio_set_<dir>_<data> (source)
writes the source data to the EZFIO file.
* subroutine ezfio_get_<dir>_<data> (destination)
reads the data from the EZFIO file to the destination.
For safety, a read-only attribute can be set to the file by
call ezfio_set_read_only(.True.)
or inquired by
logical :: is_read_only
call ezfio_is_read_only(is_read_only)

View File

@ -19,8 +19,8 @@ The following packages are needed:
* `IRPF90 <http://irpf90.ups-tlse.fr>`_
* `Python <http://www.python.org>`_
* `GNU make <http://www.python.org>`_ or `Ninja <http://github.com/martine/ninja>`_
The latest version can be downloaded `here <http://qmcchem.ups-tlse.fr/files/scemama/EZFIO.latest.tar.gz>`_.
Tutorial
========
@ -39,14 +39,9 @@ Create an empty directory for your project and unpack the ``EZFIO.tar.gz`` file
$ ls
EZFIO/
Get into the ``EZFIO`` directory and run:
.. code-block:: bash
$ ./configure
Now, configure the library to produce the desired suboutines. Get into
the ``config`` directory and create a new file ``test.config``
Get into the ``EZFIO`` directory and configure the library to produce the
desired suboutines. Get into the ``config`` directory and create a new file
``test.config``
containing::
molecule
@ -78,19 +73,27 @@ simple operation is written after an = symbol (as for ``mass`` in the
Once your configuration file is ready, run ``make`` and your library
will be built.
Building the library
--------------------
Now, go back to the EZFIO root directory, and run:
Now, go back to the EZFIO root directory. To build with GNU make, run:
.. code-block:: bash
$ make
The ``lib`` directory now contains the shared library
(``libezfio.so``), the static library (``libezfio.a``), and a static
Or you can use Ninja to build the library:
.. code-block:: bash
$ ninja
The ``lib`` directory now contains the static library ``libezfio.a``, and a static
library for use under the IRPF90 environment (``libezfio_irp.a``).
The ``Python`` directory contains the Python module for the use of the library in Python.
The ``Python``, ``Ocaml`` and ``Bash`` directories contain the binding for these languages.
Using the produced library
--------------------------
@ -219,7 +222,7 @@ Create a file named ``create_input.py`` with:
ezfio.molecule_mass = mass
ezfio.molecule_coord = coord
# Check that the total charge and mass is correct:
# Check that the total mass is correct:
print ezfio.properties_mass # Should give 18.
Execute the script:
@ -235,10 +238,10 @@ The printed mass is correct, and a new directory (``Water``) was created with ou
$ ls Water/*
Water/ezfio:
creation
creation library user
Water/molecule:
charge.gz coord.gz mass.gz num_atoms
coord.gz mass.gz num_atoms
In Fortran
----------
@ -306,6 +309,20 @@ the EZFIO file.
end
Compile the fortran program and link it the ``libezfio.a`` library, and run the
executable.
.. code-block:: bash
$ gfortran test.f90 EZFIO/lib/libezfio.a -o test.x
$ ./test.x
Data in the EZFIO file:
16.0000000 0.00000000 0.222396001 0.00000000
1.00000000 1.43649399 -0.889660001 0.00000000
1.00000000 -1.43649399 -0.889660001 0.00000000
A new directory (``properties``) was created with the center_of_mass
file:
@ -316,25 +333,64 @@ file:
creation
Water/molecule:
charge.gz coord.gz mass.gz num_atoms
coord.gz mass.gz num_atoms
Water/properties:
center_of_mass.gz
Compile and run the program using:
Using Bash
----------
To use EZFIO in Bash, you need to source the ``ezfio.sh`` file:
.. code-block:: bash
$ $FC -o test test.F90 EZFIO/lib/libezfio.a
$ ./test
$ source EZFIO/Bash/ezfio.sh
where ``$FC`` is your fortran compiler, and ``test.F90`` is the file
containing the test example. If you don't have the EZFIO static
library, you can use the shared library as:
The usage of the ``ezfio`` bash command is::
ezfio set_file EZFIO_DIRECTORY
ezfio unset_file
ezfio has DIRECTORY ITEM
ezfio get DIRECTORY ITEM
ezfio set DIRECTORY ITEM VALUE : Scalar values
ezfio set DIRECTORY ITEM : Array values read from stdin
ezfio set_verbose
ezfio unset_verbose
Here is the same script as the Python script, but using Bash (``create_input.sh``):
.. code-block:: bash
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/EZFIO/lib
$ $FC -o test -L./EZFIO/lib -lezfio
#!/bin/bash
source EZFIO/Bash/ezfio.sh
# Select the EZFIO file
ezfio set_file Water
# Set the number of atoms
ezfio set molecule num_atoms 3
# Create the mass array
mass="[16.0, 1.0, 1.0]"
echo $mass | ezfio set molecule mass
# Create the coordinates
cat << EOF | ezfio set molecule coord
[
[ 0.000000, 0.222396, 0.0],
[ 1.436494, -0.889660, 0.0],
[-1.436494, -0.889660, 0.0]
]
EOF
# Check that the total mass is correct:
ezfio get properties mass # Should print 18.

30
build.ninja Normal file
View File

@ -0,0 +1,30 @@
include version
rule build_generated_ninja
command = python $in ninja
description = Creating generated.ninja
generator = 1
rule run_ninja
command = bash -c 'source make.config ; bash -c "$$NINJA -f $in"'
description = Building Fortran library
rule build_archive
command = git archive --format=tar HEAD > EZFIO.${version}.tar && mkdir -p EZFIO && cd EZFIO && tar -xvf ../EZFIO.${version}.tar && cd .. && rm EZFIO.${version}.tar && tar -zcvf EZFIO.${version}.tar.gz EZFIO && rm -rf EZFIO
description = Building archive
rule clean_all
command = bash -c 'source make.config ; bash -c "$$NINJA -f $in -t clean ; $$NINJA -t clean" ; rm -rf src/IRPF90_{temp,man} src/*.pyc'
description = Cleaning directory
build make.config generated.ninja: build_generated_ninja configure.py
build all: run_ninja generated.ninja
default all
build EZFIO.${VERSION}.tar.gz: build_archive
build archive: phony EZFIO.${VERSION}.tar.gz
build clean: clean_all generated.ninja

3929
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,134 +0,0 @@
# EZFIO is an automatic generator of I/O libraries
# Copyright (C) 2009 Anthony SCEMAMA, CNRS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Anthony Scemama
# LCPQ - IRSAMC - CNRS
# Universite Paul Sabatier
# 118, route de Narbonne
# 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
VERSION=[`. version ; echo $VERSION`]
AC_SUBST([VERSION])
AC_REVISION([$Revision: $VERSION $])
AC_PREREQ([2.50])
AC_INIT([EZFIO Library Generator], [], [scemama@irsamc.ups-tlse.fr],[ezfio],[http://ezfio.sourceforge.net])
AC_SYS_LONG_FILE_NAMES
ROOT=`pwd`
AC_SUBST([ROOT])
AC_CONFIG_SRCDIR([src/run.irp.f])
AC_CONFIG_FILES([make.config])
AC_PREFIX_DEFAULT([./])
STATIC_LIB=$ROOT/lib/libezfio.a
AC_PROG_RANLIB
# Test Fortran
# ------------
AC_LANG([Fortran])
AC_PROG_FC([ifort gfortran],[Fortran 90])
AC_PROG_FC_C_O
AC_FC_SRCEXT([F90])
AC_FC_FREEFORM
# Test Python
# ------------
AC_CHECK_PROG([PYTHON],[python],[yes],[no])
if [[ "$PYTHON" = no ]] ; then
AC_MSG_ERROR([Please install Python.])
fi
# Test AR
# -------
if [[ -z "$AR" ]] ; then
AC_CHECK_PROG([AR],[ar],[yes],[no])
if [[ "$AR" = no ]] ; then
AC_MSG_ERROR([ar not found.])
fi
AR=ar
fi
AC_SUBST([AR])
# Test Gzip and zcat
# ------------------
if [[ -z "$HAS_GZIP" ]] ; then
AC_CHECK_PROG([GZIP],[gzip],[yes],[no])
if [[ "$GZIP" = no ]] ; then
HAS_GZIP="-DNO_GZIP"
fi
AC_CHECK_PROG([ZCAT],[zcat],[yes],[no])
if [[ "$ZCAT" = no ]] ; then
HAS_GZIP="-DNO_GZIP"
fi
AC_CHECK_PROG([MKFIFO],[mkfifo],[yes],[no])
if [[ "$MKFIFO" = no ]] ; then
HAS_GZIP="-DNO_GZIP"
fi
fi
AC_SUBST([HAS_GZIP])
# Test IRPF90
# ------------
if [[ -z "$IRPF90" ]] ; then
AC_CHECK_PROG([IRPF90],[irpf90],[yes],[no])
if [[ "$IRPF90" = no ]] ; then
AC_MSG_ERROR([Please install IRPF90:\nhttp://irpf90.ups-tlse.fr])
fi
IRPF90=`which irpf90`
fi
AC_SUBST([IRPF90])
if [[ -z "$FCFLAGS" ]] ; then
case $FC in
ifort*)
FCFLAGS="-O2 -g -ip"
STATIC_FC="-static-intel -static-libgcc -static"
;;
gfortran*)
FCFLAGS="-O2 -g -ffree-line-length-none"
STATIC_FC="-static-libgcc -static"
;;
esac
fi
# Write make.config
LIB="$STATIC_LIB"
FCFLAGS="$FCFLAGS $STATIC_FC"
AC_SUBST([LIB])
# Done
#-----
AC_OUTPUT

132
configure.py Executable file
View File

@ -0,0 +1,132 @@
#!/usr/bin/env python
import os,sys
with open("version",'r') as f:
version = f.read().strip().rsplit('=')[1]
d_default = {
"VERSION" : version,
"IRPF90" : 'irpf90',
"FC" : 'gfortran -g -ffree-line-length-none -fPIC',
"FCFLAGS" : '-O2',
"RANLIB" : 'ranlib',
"AR" : 'ar',
"NINJA" : 'ninja',
"CONFIG_FILES" :
' '.join([ x for x in os.listdir('config') if x != '.empty'])
}
def create_make_config():
if sys.argv[-1] == 'ninja':
fmt = '{0}="{1}"\n'
else:
fmt = '{0}={1}\n'
with open("make.config",'w') as out:
for var,default in d_default.iteritems():
try:
cur = os.environ[var]
except KeyError:
cur = default
out.write(fmt.format(var,cur))
def read_make_config():
result = {}
with open("make.config",'r') as f:
for line in f.readlines():
try:
key, value = line.strip().split('=')
except:
print "Error in make.config:"
print line
sys.exit(1)
result[key] = value
return result
def create_build_ninja():
if "make.config" not in os.listdir(os.getcwd()):
create_make_config()
d = read_make_config()
d["irpf90_files"] = [ "src/{0}".format(x) for x in
"""
IRPF90_temp/build.ninja irpf90.make irpf90_entities
tags libezfio_groups-gen.py libezfio_util-gen.py
""".split() ]
d["irpf90_sources"] = [ "src/{0}".format(x) for x in
"""
libezfio_error.irp.f create_ocaml.py groups_templates.py
libezfio_file.irp.f create_python.py
libezfio_groups.irp.f ezfio-head.py
libezfio_util.irp.f ezfio-tail.py read_config.py
f_types.py test.py groups.py
""".split() ] + [ "make.config" ]
d["irpf90_files"] = ' '.join(d["irpf90_files"])
d["irpf90_sources"] = ' '.join(d["irpf90_sources"])
template = """
rule build_archive
command = git archive --format=tar HEAD > EZFIO.{VERSION}.tar && mkdir -p EZFIO && cd EZFIO && tar -xvf ../EZFIO.{VERSION}.tar && cd .. && rm EZFIO.{VERSION}.tar && tar -zcvf EZFIO.{VERSION}.tar.gz EZFIO && rm -rf EZFIO
description = Building archive
rule build_make_config
command = python configure.py
description = Creating make.config
rule compile_irpf90
command = cd src ; {IRPF90} --ninja
description = Compiling IRPF90
rule build_irpf90_a
command = {NINJA} -C src/IRPF90_temp
description = Compiling Fortran files
rule build_libezfio_a
command = cp src/IRPF90_temp/irpf90.a lib/libezfio.a ; {RANLIB} lib/libezfio.a
description = Building libezfio.a
rule build_libezfio_irp_a
command = cp lib/libezfio.a lib/libezfio_irp.a ; {AR} dv lib/libezfio_irp.a irp_stack.irp.o > /dev/null ; {RANLIB} lib/libezfio_irp.a
description = Building libezfio_irp.a
rule build_python
command = cd src ; python create_python.py
description = Building Python module
rule build_ocaml
command = cd src ; python create_ocaml.py
description = Building Ocaml module
build make.config: build_make_config | configure.py
build {irpf90_files}: compile_irpf90 | {irpf90_sources}
build src/IRPF90_temp/irpf90.a: build_irpf90_a | {irpf90_files}
build lib/libezfio.a: build_libezfio_a | src/IRPF90_temp/irpf90.a
build lib/libezfio_irp.a: build_libezfio_irp_a | lib/libezfio.a
build Python/ezfio.py: build_python | lib/libezfio.a
build Ocaml/ezfio.ml: build_ocaml | lib/libezfio.a
"""
with open('generated.ninja','w') as f:
f.write(template.format(**d))
if __name__ == '__main__':
create_build_ninja()

View File

@ -1,5 +0,0 @@
IRPF90 = @IRPF90@ @HAS_GZIP@
FC = @FC@ -fPIC
FCFLAGS= @FCFLAGS@
RANLIB = @RANLIB@
AR = @AR@

View File

@ -22,38 +22,39 @@
# 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr
DEFAULT_TARGET: python
DEFAULT_TARGET: all
../make.config:
make -C .. make.config
include ../make.config
export
include irpf90.make
irpf90.make: $(wildcard *.irp.f) ../config/*
irpf90.make: $(wildcard *.irp.f) ../config/*
$(IRPF90)
include ../version
.PHONY: python static
.PHONY: static all
static: ../lib/libezfio_irp.a ../lib/libezfio.a
all: static ../Python/ezfio.py ../Ocaml/ezfio.ml
../lib/libezfio.a: $(OBJ1)
- bash -c "[[ -e ../libezfio.a ]] && rm ../lib/libezfio.a"
static: ../lib/libezfio.a ../lib/libezfio_irp.a
../lib/libezfio.a: IRPF90_temp/irpf90.a
rm -f ../lib/libezfio.a
$(AR) cru ../lib/libezfio.a $(OBJ1)
$(RANLIB) ../lib/libezfio.a
../lib/libezfio_irp.a: ../lib/libezfio.a
rm -f ../lib/libezfio_irp.a
cp ../lib/libezfio.a ../lib/libezfio_irp.a
$(AR) dv ../lib/libezfio_irp.a irp_stack.irp.o
$(RANLIB) ../lib/libezfio_irp.a
test: static
ifort -o $@ IRPF90_temp/run.irp.F90 -L../lib/ -lezfio
../Python/ezfio.py:
python create_python.py
python: static
cat ezfio-head.py libezfio_groups-gen.py libezfio_util-gen.py ezfio-tail.py > ../Python/ezfio.py
../Ocaml/ezfio.ml:
python create_ocaml.py
ezfio.py: python

View File

@ -87,3 +87,7 @@ def run():
file.write(template)
file.close()
if __name__ == '__main__':
run()

33
src/create_python.py Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
# EZFIO is an automatic generator of I/O libraries
# Copyright (C) 2009 Anthony SCEMAMA, CNRS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Anthony Scemama
# LCPQ - IRSAMC - CNRS
# Universite Paul Sabatier
# 118, route de Narbonne
# 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr
def run():
with open('../Python/ezfio.py','w') as out:
for f in "ezfio-head.py libezfio_groups-gen.py libezfio_util-gen.py ezfio-tail.py".split():
with open(f,'r') as inp:
out.write(inp.read())
if __name__ == '__main__':
run()

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
# EZFIO is an automatic generator of I/O libraries
# Copyright (C) 2009 Anthony SCEMAMA, CNRS
#

View File

@ -24,3 +24,52 @@
ezfio = ezfio_obj()
def main():
import pprint
import sys
import os
try:
EZFIO_FILE = os.environ["EZFIO_FILE"]
except KeyError:
print "EZFIO_FILE not defined"
return 1
ezfio.set_file(EZFIO_FILE)
command = '_'.join(sys.argv[1:]).lower()
try:
f = getattr(ezfio,command)
except AttributeError:
print "{0} not found".format(command)
return 1
if command.startswith('has'):
if f(): return 0
else : return 1
elif command.startswith('get'):
result = f()
pprint.pprint( result, width=60, depth=3, indent=4 )
return 0
elif command.startswith('set'):
try:
data = eval(sys.stdin.read())
except:
print "Syntax Error"
return 1
f(data)
return 0
else:
return 1
if __name__ == '__main__':
rc = main()
sys.exit(rc)

View File

@ -144,7 +144,3 @@ for group in groups.keys():
print >>file_py, attributes_arr_py%d
file_py.close()
import create_ocaml
create_ocaml.run()

View File

@ -49,6 +49,7 @@ END_PROVIDER
attributes = """
BEGIN_PROVIDER [ %(type)s, %(group)s_%(var)s ]
implicit none
BEGIN_DOC
! %(var)s attribute of group %(group)s
END_DOC
@ -58,23 +59,39 @@ BEGIN_PROVIDER [ %(type)s, %(group)s_%(var)s ]
END_PROVIDER
subroutine ezfio_set_%(group)s_%(var)s(%(var)s)
implicit none
BEGIN_DOC
! Sets the %(group)s/%(var)s attribute
END_DOC
%(type_set)s :: %(var)s
call ezfio_write_%(type_short)s(path_%(group)s,'%(var)s',%(var)s)
FREE %(group)s_%(var)s
end subroutine
subroutine ezfio_get_%(group)s_%(var)s(%(var)s)
implicit none
BEGIN_DOC
! Gets the %(group)s/%(var)s attribute
END_DOC
%(type)s :: %(var)s
%(var)s = %(group)s_%(var)s
end subroutine
subroutine ezfio_has_%(group)s_%(var)s(result)
implicit none
BEGIN_DOC
! True if the %(group)s/%(var)s attribute exists in the EZFIO directory
END_DOC
logical :: result
inquire(file=trim(path_%(group)s)//'/%(var)s',exist=result)
end subroutine
subroutine ezfio_free_%(group)s_%(var)s()
FREE %(group)s_%(var)s
implicit none
BEGIN_DOC
! Frees the memory for %(group)s/%(var)s
END_DOC
FREE %(group)s_%(var)s
end
"""
@ -95,6 +112,10 @@ BEGIN_PROVIDER [ %(type)s, %(group)s_%(var)s, %(dims)s ]
END_PROVIDER
subroutine ezfio_set_%(group)s_%(var)s(%(var)s)
implicit none
BEGIN_DOC
! Sets the %(group)s/%(var)s attribute
END_DOC
%(type_set)s :: %(var)s (*)
integer :: rank, dim_max, i
integer :: dims(10)
@ -107,18 +128,30 @@ subroutine ezfio_set_%(group)s_%(var)s(%(var)s)
end subroutine
subroutine ezfio_get_%(group)s_%(var)s(%(var)s)
implicit none
BEGIN_DOC
! Gets the %(group)s/%(var)s attribute
END_DOC
%(type)s, intent(out) :: %(var)s (*)
character*(1024) :: message
%(var)s(1: %(dim_max)s ) = reshape ( %(group)s_%(var)s, (/ %(dim_max)s /) )
end subroutine
subroutine ezfio_has_%(group)s_%(var)s(result)
implicit none
BEGIN_DOC
! True if the %(group)s/%(var)s attribute exists in the EZFIO directory
END_DOC
logical :: result
inquire(file=trim(path_%(group)s)//'/%(var)s.gz',exist=result)
end subroutine
subroutine ezfio_free_%(group)s_%(var)s()
FREE %(group)s_%(var)s
implicit none
BEGIN_DOC
! Frees the memory for %(group)s/%(var)s
END_DOC
FREE %(group)s_%(var)s
end
"""
@ -131,38 +164,70 @@ BEGIN_PROVIDER [ %(type)s, %(group)s_%(var)s ]
END_PROVIDER
subroutine ezfio_get_%(group)s_%(var)s(%(var)s)
%(type)s, intent(out) :: %(var)s
%(var)s = %(group)s_%(var)s
implicit none
BEGIN_DOC
! Gets the %(group)s/%(var)s attribute
END_DOC
%(type)s, intent(out) :: %(var)s
%(var)s = %(group)s_%(var)s
end
subroutine ezfio_free_%(group)s_%(var)s()
FREE %(group)s_%(var)s
implicit none
BEGIN_DOC
! Frees the memory for %(group)s/%(var)s
END_DOC
FREE %(group)s_%(var)s
end
"""
buffered="""
subroutine ezfio_open_read_%(group)s_%(var)s()
implicit none
BEGIN_DOC
! Opens the read buffer for %(group)s/%(var)s
END_DOC
call ezfio_open_read_buffer(path_%(group)s,'%(var)s',%(dims)s)
end
subroutine ezfio_open_write_%(group)s_%(var)s()
implicit none
BEGIN_DOC
! Opens the write buffer for %(group)s/%(var)s
END_DOC
call ezfio_open_write_buffer(path_%(group)s,'%(var)s',%(dims)s)
end
subroutine ezfio_close_read_%(group)s_%(var)s()
implicit none
BEGIN_DOC
! Closes the read buffer for %(group)s/%(var)s
END_DOC
call ezfio_close_read_buffer(path_%(group)s,'%(var)s')
end
subroutine ezfio_close_write_%(group)s_%(var)s()
implicit none
BEGIN_DOC
! Closes the write buffer for %(group)s/%(var)s
END_DOC
call ezfio_close_write_buffer(path_%(group)s,'%(var)s')
end
subroutine ezfio_has_%(group)s_%(var)s(result)
implicit none
BEGIN_DOC
! If the %(group)s_%(var)s, returns True
END_DOC
logical :: result
inquire(file=trim(path_%(group)s)//'/%(var)s.gz',exist=result)
end subroutine
subroutine ezfio_free_%(group)s_%(var)s()
implicit none
BEGIN_DOC
! Frees the memory for %(group)s/%(var)s
END_DOC
FREE %(group)s_%(var)s
end
"""

View File

@ -24,6 +24,9 @@
subroutine ezfio_error(where,txt)
implicit none
BEGIN_DOC
! Prints an error message
END_DOC
character*(*) :: where
character*(*) :: txt
character*(128) :: fname

View File

@ -23,6 +23,7 @@
! scemama@irsamc.ups-tlse.fr
BEGIN_PROVIDER [ logical, libezfio_read_only ]
implicit none
BEGIN_DOC
! If true, the EZFIO file is read-only
END_DOC
@ -31,18 +32,29 @@ BEGIN_PROVIDER [ logical, libezfio_read_only ]
END_PROVIDER
subroutine ezfio_set_read_only(v)
implicit none
BEGIN_DOC
! If true, sets the EZFIO file in a read-only state
END_DOC
logical :: v
libezfio_read_only = v
TOUCH libezfio_read_only
end subroutine ezfio_set_read_only
subroutine ezfio_is_read_only(v)
implicit none
BEGIN_DOC
! True if the EZFIO file is in a read-only state
END_DOC
logical :: v
v = libezfio_read_only
end subroutine ezfio_is_read_only
integer function char_to_version(v)
implicit none
BEGIN_DOC
! Computes the version number from a string
END_DOC
character*(32), intent(in) :: v
character*(32) :: vnew
integer :: i, j, k
@ -78,6 +90,9 @@ END_PROVIDER
subroutine ezfio_get_filename(fname)
implicit none
BEGIN_DOC
! Returns the name of the EZFIO file
END_DOC
character*(*) :: fname
fname = libezfio_filename
end subroutine
@ -107,6 +122,9 @@ END_PROVIDER
logical function exists(path)
implicit none
BEGIN_DOC
! Returns True if the path exists
END_DOC
character*(*) :: path
character*(32) :: V
inquire(file=trim(path)//'/.version',exist=exists)
@ -124,6 +142,9 @@ end function
subroutine ezfio_set_file(filename_in)
implicit none
BEGIN_DOC
! Sets the file for I/O
END_DOC
character*(*) :: filename_in
@ -153,6 +174,9 @@ end subroutine
subroutine ezfio_finish()
implicit none
BEGIN_DOC
! Close all open buffers
END_DOC
close(libezfio_iunit)
BEGIN_SHELL [ /usr/bin/python ]
import os

View File

@ -35,6 +35,9 @@ END_PROVIDER
logical function ezfio_exists(path)
implicit none
BEGIN_DOC
! Checks if a file path exists
END_DOC
character*(*) :: path
inquire(file=trim(path)//'/.version',exist=ezfio_exists)
if (ezfio_exists) then
@ -47,6 +50,9 @@ end function
subroutine ezfio_mkdir(path)
implicit none
BEGIN_DOC
! Creates a directory
END_DOC
character*(*) :: path
logical :: ezfio_exists
if (libezfio_read_only) then
@ -63,6 +69,9 @@ end subroutine
subroutine libezfio_openz(filename,mode,err)
implicit none
BEGIN_DOC
! Opens a compressed file
END_DOC
character*(*) :: filename, mode
character*(1024) :: fifo
integer :: err
@ -83,6 +92,9 @@ end
subroutine libezfio_closez(filename,mode)
implicit none
BEGIN_DOC
! Closes a compressed file
END_DOC
character*(*) :: filename, mode
character*(1024) :: fifo
fifo = trim(filename)//'.'//PID_str
@ -102,6 +114,9 @@ from f_types import format, t_short
template = """
subroutine ezfio_read_%(type_short)s(dir,fil,dat)
implicit none
BEGIN_DOC
! Reads a %(type_short)s
END_DOC
character*(*), intent(in) :: dir, fil
%(type)s, intent(out) :: dat
character*(1024) :: l_filename
@ -117,6 +132,9 @@ end
subroutine ezfio_write_%(type_short)s(dir,fil,dat)
implicit none
BEGIN_DOC
! Writes a %(type_short)s
END_DOC
character*(*), intent(in) :: dir, fil
%(type)s, intent(in) :: dat
character*(1024) :: l_filename(2)
@ -133,6 +151,9 @@ end
subroutine ezfio_read_array_%(type_short)s(dir,fil,rank,dims,dim_max,dat)
implicit none
BEGIN_DOC
! Reads a %(type_short)s array
END_DOC
character*(*), intent(in) :: dir, fil
integer :: rank
integer :: dims(rank)
@ -182,6 +203,9 @@ end
subroutine ezfio_write_array_%(type_short)s(dir,fil,rank,dims,dim_max,dat)
implicit none
BEGIN_DOC
! Writes a %(type_short)s array
END_DOC
character*(*), intent(in) :: dir, fil
integer, intent(in) :: rank
integer, intent(in) :: dims(rank)
@ -213,6 +237,10 @@ end
template_no_logical = """
integer function n_count_%(type_short)s(array,isize,val)
implicit none
BEGIN_DOC
! Count number of elements of array of type %(type)s
END_DOC
%(type)s, intent(in) :: array(*)
integer, intent(in) :: isize
%(type)s, intent(in) :: val
@ -326,6 +354,7 @@ print >>file_py, """
"""%cwd
file_py.close()
END_SHELL
BEGIN_PROVIDER [ integer, libezfio_buffer_rank ]
@ -337,6 +366,9 @@ END_PROVIDER
subroutine ezfio_open_write_buffer(dir,fil,rank)
implicit none
BEGIN_DOC
! Opens a buffer for writing
END_DOC
character*(*),intent(in) :: dir
character*(*),intent(in) :: fil
integer,intent(in) :: rank
@ -367,6 +399,9 @@ end
subroutine ezfio_open_read_buffer(dir,fil,rank)
implicit none
BEGIN_DOC
! Opens a buffer for reading
END_DOC
character*(*),intent(in) :: dir
character*(*),intent(in) :: fil
integer,intent(in) :: rank
@ -399,6 +434,9 @@ end
subroutine ezfio_close_read_buffer(dir,fil,rank)
implicit none
BEGIN_DOC
! Closes a buffer
END_DOC
character*(*),intent(in) :: dir
character*(*),intent(in) :: fil
integer,intent(in) :: rank
@ -411,6 +449,9 @@ end
subroutine ezfio_close_write_buffer(dir,fil,rank)
implicit none
BEGIN_DOC
! Closes a buffer
END_DOC
character*(*),intent(in) :: dir
character*(*),intent(in) :: fil
integer,intent(in) :: rank
@ -423,6 +464,9 @@ end
subroutine ezfio_read_buffer(indices,values,isize)
implicit none
BEGIN_DOC
! Reads a buffer
END_DOC
integer, intent(inout) :: isize
integer, intent(out) :: indices(*)
@ -444,6 +488,9 @@ end
subroutine ezfio_write_buffer(indices,values,isize)
implicit none
BEGIN_DOC
! Writes a buffer
END_DOC
integer, intent(in) :: isize
integer, intent(in) :: indices(*)

View File

@ -1,28 +0,0 @@
! EZFIO is an automatic generator of I/O libraries
! Copyright (C) 2009 Anthony SCEMAMA, CNRS
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License along
! with this program; if not, write to the Free Software Foundation, Inc.,
! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
!
! Anthony Scemama
! LCPQ - IRSAMC - CNRS
! Universite Paul Sabatier
! 118, route de Narbonne
! 31062 Toulouse Cedex 4
! scemama@irsamc.ups-tlse.fr
program run
! Leave this empty
end

View File

@ -1 +1 @@
VERSION=1.2.1
VERSION=1.3.0