Migration from Sourceforge

This commit is contained in:
Anthony Scemama 2014-08-26 15:04:22 +02:00
parent 29a999c0f8
commit 0827fb9f54
32 changed files with 7150 additions and 4 deletions

280
LICENSE Normal file
View File

@ -0,0 +1,280 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

55
Makefile Normal file
View File

@ -0,0 +1,55 @@
# 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
include version
include make.config
.PHONY: default clean distclean 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
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
archive: distclean
git archive --format=tar HEAD > EZFIO.$(VERSION).tar
mkdir EZFIO ; cd EZFIO ; tar -xvf ../EZFIO.$(VERSION).tar
rm EZFIO.$(VERSION).tar
tar -zcvf EZFIO.$(VERSION).tar.gz EZFIO
rm -rf EZFIO
configure: make.config.in configure.ac
autoconf
make.config:
./configure --host=dummy

0
Ocaml/.empty Normal file
View File

0
Python/.empty Normal file
View File

86
README Normal file
View File

@ -0,0 +1,86 @@
======================================================================
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

@ -1,4 +0,0 @@
EZFIO
=====
The Easy Fortran I/O library generator

340
README.rst Normal file
View File

@ -0,0 +1,340 @@
EZFIO
=====
EZFIO is the Easy Fortran I/O library generator. It generates
automatically an I/O library from a simple configuration file. The
produced library contains Fortran subroutines to read/write the data
from/to disk, and to check if the data exists.
A Python and an Ocaml API are also provided.
With EZFIO, the 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.
Download
========
The following packages are needed:
* `IRPF90 <http://irpf90.ups-tlse.fr>`_
* `Python <http://www.python.org>`_
The latest version can be downloaded `here <http://qmcchem.ups-tlse.fr/files/scemama/EZFIO.latest.tar.gz>`_.
Tutorial
========
In this example, we will write a Fortran program which computes
properties of a molecule. The molecule is described as point charges in
the 3D space.
Preparation of the library
--------------------------
Create an empty directory for your project and unpack the ``EZFIO.tar.gz`` file in this directory. This directory now contains:
.. code-block:: bash
$ 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``
containing::
molecule
num_atoms integer
mass real (molecule_num_atoms)
coord real (3,molecule_num_atoms)
properties
mass real = sum(molecule_mass)
center_of_mass real (3)
In this example, ``molecule`` and ``properties`` are containers of data.
Those are defined in the config file by their name at the beginning of a
new line.
Each data contained inside a container is characterized by a triplet
(name,type,dimension), preceded by at least one white space at the
beginning of the line.
If the dimension of an array is a data, the name of the data can be used
as ``<container>_<data>`` in the definition of the dimension. For
example, the dimension (``molecule_num_atoms``) uses the data
``num_atoms`` of container ``molecule``.
Data can also be the result of a simple operation. In that case, the
simple operation is written after an = symbol (as for ``mass`` in the
``properties`` container). In that case, the data is read-only.
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:
.. code-block:: bash
$ make
The ``lib`` directory now contains the shared library
(``libezfio.so``), 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.
Using the produced library
--------------------------
In the following, we will call 'EZFIO file' the main directory
containing the EZFIO data.
All the produced libraries contain the following subroutines:
subroutine ezfio_set_read_only(ro)
If ``ro`` is .True., the read-only attribute is set. It will be
impossible to write to the EZFIO file.
subroutine ezfio_is_read_only(ro)
Returns the value of the read_only attribute to ``ro``.
subroutine ezfio_set_file(filename)
Only one EZFIO can be manipulated at a time. This subroutine selects
which file will be manipulated.
subroutine ezfio_get_filename(fname)
Returns the name of the EZFIO file which is currently manipulated.
For each data, 3 subroutines are created.
<dir> is the name of the container which contains the data and
<data> is the name of the data.
subroutine ezfio_has_<dir>_<data> (has_it)
``has_it`` is .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.
With our example, the library contains the following subroutines:
.. code-block:: fortran
subroutine ezfio_set_read_only(ro)
subroutine ezfio_is_read_only(ro)
subroutine ezfio_set_file(filename)
subroutine ezfio_get_filename(filename)
subroutine ezfio_set_molecule_num_atoms(num_atoms)
subroutine ezfio_get_molecule_num_atoms(num_atoms)
subroutine ezfio_has_molecule_num_atoms(has_it)
subroutine ezfio_set_molecule_mass(mass)
subroutine ezfio_get_molecule_mass(mass)
subroutine ezfio_has_molecule_mass(has_it)
subroutine ezfio_set_molecule_coord(coord)
subroutine ezfio_get_molecule_coord(coord)
subroutine ezfio_has_molecule_coord(has_it)
subroutine ezfio_get_properties_mass(mass)
subroutine ezfio_set_properties_center_of_mass(center_of_mass)
subroutine ezfio_get_properties_center_of_mass(center_of_mass)
subroutine ezfio_has_properties_center_of_mass(has_it)
subroutine ezfio_set_properties_center_of_charge(center_of_charge)
subroutine ezfio_get_properties_center_of_charge(center_of_charge)
subroutine ezfio_has_properties_center_of_charge(has_it)
Note that ``ezfio_get_properties_mass`` has only the ``get`` subroutine
since it is computed data.
In Python
---------
All the subroutines are also produced for Python in the ezfio.py file in
the Python directory. To use them, in your Python script, use:
.. code-block:: python
import sys
EZFIO = "./EZFIO" # Put here the absolute path to the EZFIO directory
sys.path = [ EZFIO+"/Python" ]+sys.path
from ezfio import ezfio
and all the subroutines will be accessible by replacing the first
underscore character of the name of the subroutine by a dot (``ezfio_``
becomes ``ezfio.``).
Let us create the input of our Fortran program with a Python script.
Create a file named ``create_input.py`` with:
.. code-block:: python
#!/usr/bin/python
import sys
EZFIO = "./EZFIO" # Put here the absolute path to the EZFIO directory
sys.path = [ EZFIO+"/Python" ]+sys.path
from ezfio import ezfio
# Water molecule:
# mass, x, y, z
input = """16. 0.000000 0.222396 0.000000
1. 1.436494 -0.889660 0.000000
1. -1.436494 -0.889660 0.000000 """
Molecule = []
for line in input.splitlines():
new_list = map(eval,line.split())
Molecule.append(new_list)
# Create the mass array
mass = map( lambda x: x[0], Molecule )
# print mass
# [16.0, 1.0, 1.0]
# Create the coord array
coord = map( lambda x: (x[1], x[2], x[3]), Molecule )
# print coord
# [(0.0, 0.222396, 0.0), (1.436494, -0.88966, 0.0), (-1.436494, -0.88966, 0.0)]
# Select the EZFIO file
ezfio.set_file("Water")
# Add the arrays to the file
ezfio.molecule_num_atoms = len(Molecule)
ezfio.molecule_mass = mass
ezfio.molecule_coord = coord
# Check that the total charge and mass is correct:
print ezfio.properties_mass # Should give 18.
Execute the script:
.. code-block:: bash
$ python create_input.py
18.0
The printed mass is correct, and a new directory (``Water``) was created with our data:
.. code-block:: bash
$ ls Water/*
Water/ezfio:
creation
Water/molecule:
charge.gz coord.gz mass.gz num_atoms
In Fortran
----------
We will create here a Fortran program which reads the atomic coordinates
and the atomic masses from an EZFIO file, computes the coordinates of
the center of mass, and writes the coordinates of the center of mass to
the EZFIO file.
.. code-block:: fortran
program test
implicit none
integer :: num_atoms
real, allocatable :: mass(:)
real, allocatable :: coord(:,:)
real :: center_of_mass(3)
real :: total_mass
integer :: i,j
! Set which file is read/written
call ezfio_set_file("Water")
! Read the number of atoms
call ezfio_get_molecule_num_atoms(num_atoms)
! Allocate the mass and coord arrays
allocate(mass(num_atoms), coord(3,num_atoms))
! Read the arrays from the file
call ezfio_get_molecule_mass(mass)
call ezfio_get_molecule_coord(coord)
! Check that the read data is correct
print *, 'Data in the EZFIO file:'
do i=1,num_atoms
print *, mass(i), (coord(j,i),j=1,3)
end do
! prints:
! Data in the EZFIO file:
! 16.00000 0.000000 0.2223960 0.000000
! 1.000000 1.436494 -0.8896600 0.000000
! 1.000000 -1.436494 -0.8896600 0.000000
! Perform the calculation of the center of mass
do j=1,3
center_of_mass(j) = 0.
end do
do i=1,num_atoms
do j=1,3
center_of_mass(j) = center_of_mass(j) + mass(i)*coord(j,i)
end do
end do
call ezfio_get_properties_mass(total_mass)
do j=1,3
center_of_mass(j) = center_of_mass(j)/total_mass
end do
deallocate(mass, coord)
! Write the center of mass to the EZFIO file
call ezfio_set_properties_center_of_mass(center_of_mass)
end
A new directory (``properties``) was created with the center_of_mass
file:
.. code-block:: bash
$ ls Water/*
Water/ezfio:
creation
Water/molecule:
charge.gz coord.gz mass.gz num_atoms
Water/properties:
center_of_mass.gz
Compile and run the program using:
.. code-block:: bash
$ $FC -o test test.F90 EZFIO/lib/libezfio.a
$ ./test
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:
.. code-block:: bash
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/EZFIO/lib
$ $FC -o test -L./EZFIO/lib -lezfio

0
config/.empty Normal file
View File

5
config/ezfio.config Normal file
View File

@ -0,0 +1,5 @@
ezfio
creation character*(64)
user character*(64)
library character*(2048)
last_library character*(2048)

3929
configure vendored Executable file

File diff suppressed because it is too large Load Diff

134
configure.ac Normal file
View File

@ -0,0 +1,134 @@
# 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

13
git-tools/commit-msg Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/python
import os,sys
ROOT = os.path.dirname(__file__)+'/../../'
file = open(ROOT+'version','r')
lines = file.readlines()
file.close()
file = open(sys.argv[1],'a')
print >>file, 'Version:'+lines[0].split('=')[1]
file.close()

10
git-tools/install_tools.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
OLD_DIR=$PWD
cd ../.git/hooks/
for i in commit-msg post-commit
do
rm $i
ln -s $OLD_DIR/$i $PWD/$i
done

17
git-tools/post-commit Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/python
import os
ROOT = os.path.dirname(__file__)+'/../../'
file = open(ROOT+'version','r') ;
lines = file.readlines() ;
file.close() ;
v = map(int,lines[0].split('=')[1].split('.'));
v[2] += 1
lines[0] = "VERSION=%d.%d.%d\n"%tuple(v)
file = open(ROOT+'version','w')
file.writelines(lines)
file.close()

0
lib/.empty Normal file
View File

5
make.config.in Normal file
View File

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

59
src/Makefile Normal file
View File

@ -0,0 +1,59 @@
# 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
DEFAULT_TARGET: python
../make.config:
make -C .. make.config
include ../make.config
include irpf90.make
irpf90.make: $(wildcard *.irp.f) ../config/*
$(IRPF90)
include ../version
.PHONY: python static
static: ../lib/libezfio_irp.a ../lib/libezfio.a
../lib/libezfio.a: $(OBJ1)
- bash -c "[[ -e ../libezfio.a ]] && rm ../lib/libezfio.a"
$(AR) cru ../lib/libezfio.a $(OBJ1)
$(RANLIB) ../lib/libezfio.a
../lib/libezfio_irp.a: ../lib/libezfio.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: static
cat ezfio-head.py libezfio_groups-gen.py libezfio_util-gen.py ezfio-tail.py > ../Python/ezfio.py
ezfio.py: python

89
src/create_ocaml.py Executable file
View File

@ -0,0 +1,89 @@
#!/usr/bin/env python
# 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
import re
from read_config import groups
from groups_templates import *
from f_types import t_short, f2ocaml
import os
import sys
def run():
head = []
tail = []
file = open("../version","r")
v = file.readline()
file.close()
v = v.split('=')[1].strip()
l = os.getcwd().replace('/src','')
head += ["""let version = "%s";;"""%(v),
"""let library = "%s";;"""%(l)]
for group in groups.keys():
for var,type,dims,command in groups[group]:
if command is not "":
continue
dims_py = str(dims)
for g in groups.keys():
dims_py = dims_py.replace(g,'self.'+g)
var = var.lower()
group = group.lower()
strdims = tuple(map(lambda x: '('+str(x)+')',dims))
strdims = str(strdims).replace("'","")
if len(dims) == 1:
strdims = strdims[:-2]+")"
dim_max = strdims[1:-1].replace(',','*')
type_set = type
if type.lower().startswith('character'):
type_set = 'character*(*)'
d = { 'type_short': f2ocaml[t_short(type)],
'type': type,
'type_set': type_set,
'var': var,
'group': group,
'dims': strdims}
if dims == ():
tail += ['let get_%(group)s_%(var)s () = read_%(type_short)s "%(group)s" "%(var)s";;' %(d),
'let set_%(group)s_%(var)s = write_%(type_short)s "%(group)s" "%(var)s" ;;' %(d) ,
'let has_%(group)s_%(var)s () = has "%(group)s" "%(var)s" ;;' %(d) ]
else:
tail += ['let get_%(group)s_%(var)s () = read_%(type_short)s_array "%(group)s" "%(var)s";;' %(d),
'let set_%(group)s_%(var)s = write_%(type_short)s_array "%(group)s" "%(var)s";;' %(d) ,
'let has_%(group)s_%(var)s () = has_array "%(group)s" "%(var)s" ;;' %(d) ]
file = open('ezfio.ml','r')
template = file.read()
file.close()
template = template.replace("(*$HEAD*)",'\n'.join(head))
template = template.replace("(*$TAIL*)",'\n'.join(tail))
file = open('../Ocaml/ezfio.ml','w')
file.write(template)
file.close()

256
src/ezfio-head.py Normal file
View File

@ -0,0 +1,256 @@
# 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
import os, sys
import time
import cStringIO as StringIO
from gzip import GzipFile
import tempfile
import threading
def version(x):
b = [int(i) for i in x.split('.')]
return b[2] + b[1]*100 + b[0]*10000
def size(x):
return len(x)
def flatten(l):
res = []
for i in l:
if hasattr(i, "__iter__") and not isinstance(i, basestring):
res.extend(flatten(i))
else:
res.append(i)
return res
def maxval(l):
return reduce(max, l, l[0])
def minval(l):
return reduce(min, l, l[0])
def reshape(l,shape):
l = flatten(l)
for d in shape[:-1]:
buffer = []
buffer2 = []
i=0
while i<len(l):
buffer2.append(l[i])
if len(buffer2) == d:
buffer.append(buffer2)
buffer2 = []
i+=1
l = list(buffer)
return l
def at(array,index):
return array[index-1]
def n_count_ch(array,isize,val):
result = 0
for i in array:
if i == val:
result +=1
return result
n_count_in = n_count_ch
n_count_do = n_count_ch
n_count_lo = n_count_ch
def get_conv(type):
if type in ["do","re"]:
conv = float
elif type in ["in","i8"]:
conv = int
elif type == "lo":
def conv(a):
if a == True:
return 'T'
elif a == False:
return 'F'
elif a.lower() == 't':
return True
elif a.lower() == 'f':
return False
else:
raise TypeError
elif type == "ch":
conv = lambda x: x.strip()
else:
raise TypeError
return conv
class ezfio_obj(object):
def __init__(self,read_only=False):
self._filename = "EZFIO_File"
self.buffer_rank = -1
self.read_only = read_only
self.locks = {}
def acquire_lock(self,var):
locks = self.locks
try:
locks[var].acquire()
except:
locks[var] = threading.Lock()
locks[var].acquire()
def release_lock(self,var):
self.locks[var].release()
def set_read_only(self,v):
self.read_only = v
def get_read_only(self):
return self.read_only
def exists(self,path):
if os.access(path+'/.version',os.F_OK) == 1:
file = open(path+'/.version',"r")
v = file.readline().strip()
file.close()
else:
return False
def mkdir(self,path):
if self.read_only:
self.error('Read-only file.')
if self.exists(path):
self.error('mkdir','Group '+path+' exists')
try:
os.mkdir(path.strip())
except OSError:
pass
file = open(path.strip()+'/.version','w')
print >>file,self.version
file.close()
def error(self,where,txt):
print '------------------------------------------------------------'
print 'EZFIO File : '+self.filename
print 'EZFIO Error in : '+where.strip()
print '------------------------------------------------------------'
print ''
print txt.strip()
print ''
print '------------------------------------------------------------'
raise IOError
def get_filename(self):
if not self.exists(self._filename):
self.mkdir(self._filename)
return self._filename
def set_filename(self,filename):
self._filename = filename
filename = property(fset=set_filename,fget=get_filename)
def set_file(self,filename):
self.filename = filename
if not self.exists(filename):
self.mkdir(filename)
self.mkdir(filename+"/ezfio")
os.system("""
LANG= date > %s/ezfio/creation
echo $USER > %s/ezfio/user
echo %s > %s/ezfio/library"""%(filename,filename,self.LIBRARY,filename))
def open_write_buffer(self,dir,fil,rank):
if self.read_only:
self.error('Read-only file.')
l_filename=dir.strip()+'/'+fil+'.gz'
if self.buffer_rank != -1:
self.error('open_write_buffer','Another buffered file is already open.')
self.buffer_rank = rank
assert (self.buffer_rank > 0)
try:
self.file = GzipFile(filename=l_filename,mode='wb7')
except IOError:
self.error('open_write_buffer','Unable to open buffered file.')
self.file.write("%2d\n"%(rank,))
def open_read_buffer(self,dir,fil,rank):
l_filename=dir.strip()+'/'+fil+'.gz'
if self.buffer_rank != -1:
self.error('open_read_buffer','Another buffered file is already open.')
try:
self.file = GzipFile(filename=l_filename,mode='rb')
except IOError:
self.error('open_read_buffer','Unable to open buffered file.')
try:
rank = eval(self.file.readline())
except IOError:
self.error('open_read_buffer','Unable to read buffered file.')
self.buffer_rank = rank
assert (self.buffer_rank > 0)
return rank
def close_buffer(self):
assert (self.buffer_rank > 0)
self.buffer_rank = -1
self.file.close()
def read_buffer(self,isize):
if self.buffer_rank == -1:
self.error('read_buffer','No buffered file is open.')
indices = []
values = []
for i in xrange(isize):
try:
line = self.file.readline().split()
except:
return indices, values
if len(line) == 0:
return indices, values
indices.append ( [ int(i) for i in line[:-1] ] )
values.append (eval(line[-1]))
return indices, values
def write_buffer(self,indices,values,isize):
if self.read_only:
self.error('Read-only file.')
if self.buffer_rank == -1:
self.error('write_buffer','No buffered file is open.')
for i in xrange(isize):
for j in indices[i]:
self.file.write("%4d "%(j,))
self.file.write("%24.15e\n"%(values[i],))

26
src/ezfio-tail.py Normal file
View File

@ -0,0 +1,26 @@
# 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
ezfio = ezfio_obj()

421
src/ezfio.ml Normal file
View File

@ -0,0 +1,421 @@
(*
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
*)
(*$HEAD*)
(*
Exceptions
==========
*)
exception Read_only of string;;
(*
State variables
===============
*)
let read_only = ref false;;
let ezfio_filename = ref "EZFIO_File";;
(*
Helper functions
=================
*)
let check_readonly =
if !read_only then
raise (Read_only "Read only attribute is set");
;;
let exists path =
let filename = path^"/.version" in
Sys.file_exists filename
;;
let has group name =
let dirname = !ezfio_filename ^ "/" ^ group in
if (exists dirname) then
(Sys.file_exists (dirname ^ "/" ^ name) )
else
false
;;
let has_array group name = has group (name^".gz");;
let mkdir path =
check_readonly;
if (exists path) then
raise (Failure (path^" already exists"));
Unix.mkdir path 0o777;
let out_channel = open_out (path^"/.version") in
Printf.fprintf out_channel "%s\n" version ;
close_out out_channel;
;;
let create_group group =
let dirname = !ezfio_filename ^ "/" ^ group in
if not (exists dirname) then
mkdir dirname;
;;
let split line s =
let rec do_work lst word = function
| 0 -> word::lst
| i ->
begin
match line.[i-1] with
| a when a == s ->
if word <> "" then
do_work (word::lst) "" (i-1)
else
do_work lst "" (i-1)
| a -> do_work lst ( (Char.escaped a)^word) (i-1)
end
in do_work [] "" (String.length line)
;;
let ltrim s =
let rec do_work s l =
match s.[0] with
| '\n'
| ' ' -> do_work (String.sub s 1 (l-1)) (l-1)
| _ -> s
in
do_work s (String.length s)
;;
let rtrim s =
let rec do_work s l =
let newl = l-1 in
match s.[newl] with
| '\n'
| ' ' -> do_work (String.sub s 0 (newl)) (newl)
| _ -> s
in
do_work s (String.length s)
;;
let trim s = ltrim (rtrim s) ;;
let maxval l =
match l with
| [] -> None
| [a] -> Some a
| hd::tail -> Some (List.fold_left max hd tail)
;;
let minval l =
match l with
| [] -> None
| [a] -> Some a
| hd::tail -> Some (List.fold_left min hd tail)
;;
let at arr idx = arr.(idx);;
let size (_) = 0;;
let n_count_ch (str,_,v) =
let rec do_work accu = function
| 0 -> accu
| i ->
let newaccu =
if str.[i-1] == v then accu+1
else accu
in do_work newaccu (i-1)
in do_work 0 (String.length str)
;;
let n_count (l,_,v) =
let rec do_work accu = function
| [] -> accu
| h::tail ->
let newaccu =
if h == v then accu+1
else accu
in do_work newaccu tail
in do_work 0 l
;;
(*
Scalars
=======
*)
(*
Read
----
*)
let read_scalar type_conversion group name =
let in_filename = !ezfio_filename ^ "/" ^ group ^ "/" ^ name in
let in_channel = open_in in_filename in
let trimmed_line = trim (input_line in_channel) in
let result = type_conversion trimmed_line in
begin
close_in in_channel ;
result
end
;;
let fortran_bool_of_string = function
| "T" | "t" -> true
| "F" | "f" -> false
| x -> raise (Failure ("fortran_bool_of_string should be T or F: "^x))
;;
let fortran_string_of_bool = function
| true -> "T\n"
| false-> "F\n"
;;
let read_int = read_scalar int_of_string ;;
let read_float = read_scalar float_of_string ;;
let read_string= read_scalar (fun (x:string) -> x);;
let read_bool = read_scalar fortran_bool_of_string;;
(*
Write
-----
*)
let print_int out_channel i = Printf.fprintf out_channel "%16d\n" i
and print_float out_channel f = Printf.fprintf out_channel "%24.15e\n" f
and print_string out_channel s = Printf.fprintf out_channel "%s\n" s
and print_bool out_channel b = Printf.fprintf out_channel "%s\n" (fortran_string_of_bool b);;
let write_scalar print_fun group name s =
check_readonly;
create_group group;
let out_filename = !ezfio_filename ^ "/" ^ group ^ "/" ^ name in
let out_channel = open_out out_filename in
begin
print_fun out_channel s;
close_out out_channel;
end
;;
let write_int = write_scalar print_int
and write_float = write_scalar print_float
and write_bool = write_scalar print_bool
and write_string = write_scalar print_string
;;
(*
Arrays
======
*)
type 'a ezfio_data =