Compare commits

...

84 Commits

Author SHA1 Message Date
Anthony Scemama beac615343 Merge branch 'master' of gitlab.com:scemama/irpf90 2024-04-22 11:02:59 +02:00
Anthony Scemama 01899b41b2 Fixed type 2024-04-22 11:02:00 +02:00
Anthony Scemama 451c93a52c Fixed type 2024-04-22 10:58:25 +02:00
Anthony Scemama 76946321d6 Updated regexp for type 2024-04-22 10:44:50 +02:00
Anthony Scemama ba1a2837aa Fix for sphinx functions 2024-03-20 16:05:42 +01:00
Anthony Scemama 4ab1b175fc Updated python -> python3 2023-10-19 17:50:35 +02:00
Anthony Scemama 0007f72f67 Merge branch 'set_parameters' into 'master'
I need to setup my params differently. This is one idea but it requires extra import

See merge request scemama/irpf90!25
2022-11-28 08:07:00 +00:00
Otto Kohulak a885761ea2 Merge branch 'master' into set_parameters 2022-10-21 08:18:44 +02:00
Otto Kohulak 152c69c754 Draft: I need to setup my params differently. This is one idea but it requires extra import 2022-10-20 15:53:38 +02:00
Anthony Scemama 34ca9a7852 Merge branch 'fix_indent_preprocesor_macros' into 'master'
Fix irpf90_indent now does not produce white space lines

See merge request scemama/irpf90!24
2022-10-18 13:12:16 +00:00
Otto Kohulak d1e475dc22 Fix irpf90_indent now does not produce white space lines
Fix C preprocessor macros are now never indented
Fix !$omp directive are now never indeted
2022-10-18 14:06:45 +02:00
Anthony Scemama 088c6fdc04 Merge branch 'fix_indent' into 'master'
Fix indent if line starts with &

See merge request scemama/irpf90!23
2022-10-18 09:47:34 +00:00
Ot(t)o Kohulák c938931e5e Fix indent if line starts with & 2022-10-17 07:21:29 +02:00
Anthony Scemama ab88cc01a6 Fixed regexp for strings with double quotes 2022-01-11 22:44:18 +01:00
Anthony Scemama 33ca5e1018 Shorten lines in ninja file 2021-05-19 18:36:43 +02:00
Anthony Scemama 132a4a1661 increase version 2020-12-06 20:58:38 +01:00
Anthony Scemama 2027274583 Replace AR by ARCHIVE 2020-12-06 20:48:35 +01:00
Anthony Scemama da3ee8864a Version 2.0.4 2020-12-06 16:59:38 +01:00
Anthony Scemama 22115cd6a5 Install vim and emacs 2020-12-06 16:53:01 +01:00
Anthony Scemama bcc208624b Merge branch 'master' of gitlab.com:scemama/irpf90 2020-12-06 16:47:00 +01:00
Anthony Scemama a13a4a0741 Fixed AR with ninja 2020-12-06 16:46:56 +01:00
Anthony Scemama c9809ddae3 Merge branch 'irpemacs' into 'master'
Added basic Emacs support

See merge request scemama/irpf90!22
2020-12-06 14:46:10 +00:00
Lorentz Panadestein b6acbe76ef Added basic Emacs support 2020-12-06 14:46:10 +00:00
Anthony Scemama f1c8d20fa8 Fixed codelet bug 2020-12-02 10:22:39 +01:00
Pierre-Francois Loos bccb9adbe6 Fixed ar for MacOS 2020-11-13 17:06:10 +01:00
Anthony Scemama cc61d6271b Fixed irpman in pip 2020-11-10 22:58:41 +01:00
Anthony Scemama 97a3fe9985 Update version 2020-11-07 14:38:43 +01:00
Anthony Scemama cfeeb46c65 Merge branch 'master' of gitlab.com:scemama/irpf90 2020-11-07 14:36:44 +01:00
Anthony Scemama 6b95e780bb Merge branch 'revert-f0cd410d' into 'master'
Revert "Add the creation of Emacs TAGS file"

See merge request scemama/irpf90!21
2020-07-20 05:44:26 +00:00
Anthony Scemama 7605ce9452 Revert "Add the creation of Emacs TAGS file"
This reverts commit f0cd410d49
2020-07-20 05:43:57 +00:00
Anthony Scemama e5af6c693a Comment out emacs tags 2020-05-28 17:49:05 +02:00
Anthony Scemama f0cd410d49 Add the creation of Emacs TAGS file 2020-05-27 23:12:49 +02:00
Anthony Scemama e5e4330ee7 Fixed vim bug 2020-04-22 22:09:50 +02:00
Anthony Scemama 50cc3413e4 Merge branch 'Python3' 2020-03-17 16:29:04 +01:00
Anthony Scemama 4cde057ea2 Fixed UnicodeError 2020-03-17 11:32:10 +01:00
Anthony Scemama 199d035364 Bug in Ninja file 2020-03-17 10:36:08 +01:00
Anthony Scemama 1e1b217938 Fixed pip setup 2020-02-19 16:25:31 +01:00
Anthony Scemama 6b78eb52f5 Update pip file 2020-02-19 15:10:32 +01:00
Anthony Scemama 5fda8abb51 Fixed bug with subst 2020-01-27 19:23:50 +01:00
Anthony Scemama 8b773a9d45 Compiles with Python3 2020-01-27 18:43:22 +01:00
Anthony Scemama 2ea0e86564 Switched to Python3 2020-01-27 18:22:35 +01:00
Anthony Scemama 02a5f1c3d9 Removed Cython 2019-10-21 13:57:59 +02:00
Anthony Scemama b4cfdc96a1 Updated version number 2019-02-06 11:20:05 +01:00
Anthony Scemama e0f8e66e7e Cleaned irp_stack 2019-02-06 11:19:26 +01:00
Anthony Scemama 002db06d15 stack_index 2019-02-05 15:58:44 +01:00
Anthony Scemama fa84676fd0 Modified pip setup 2019-01-23 21:07:36 +01:00
Anthony Scemama f9c0bff633 Added rst generation in man directory 2019-01-17 20:51:45 +01:00
Anthony Scemama 03e3117a73 Fixed $SHELL 2019-01-09 00:44:17 +01:00
Anthony Scemama 5412e3e2f9 Cleaned bash/zsh completion 2019-01-08 23:23:51 +01:00
Anthony Scemama 405629b7e9 Handle program differently 2018-12-14 09:50:27 +01:00
Anthony Scemama 18c236a710 Copy irpf90.vim instead of symlink 2018-11-28 10:17:26 +01:00
Anthony Scemama 7582204c82 Removed conceal in vim 2018-11-28 10:11:31 +01:00
Anthony Scemama 8361bf1304 Better error handling when ',' is missing. 2018-11-20 14:45:20 +01:00
Anthony Scemama 1b97fa4599 More Python2 2018-04-27 15:18:22 +02:00
Anthony Scemama abc3d5d1bc Update version 1.7.1 2018-04-27 14:57:10 +02:00
Anthony Scemama 7197e6f324 Changed python to python2 2018-04-27 14:33:57 +02:00
Anthony Scemama eec23e88c0 Fixed assert 2017-09-18 15:19:59 +02:00
Anthony Scemama cd4be303cc Fixed regexp 2017-09-18 15:14:18 +02:00
Anthony Scemama de308abded Fix #9: Warning message for duplicate providers 2016-12-14 11:42:25 +01:00
Anthony Scemama 42b03f768a Forgot important files in git 2016-06-15 19:33:36 +02:00
Anthony Scemama 0c693a294a PIP 2016-06-10 18:07:16 +02:00
Anthony Scemama 1c1f989f36 Corrected irp_stack bug 2016-05-29 16:05:46 +02:00
Anthony Scemama 12ee88261a Update in vim file 2016-02-11 11:32:33 +01:00
Anthony Scemama 0b4916d82f Updated utf8 vim file 2016-02-09 01:40:46 +01:00
Anthony Scemama 1db52faf70 Improved Vim file (utf8) 2016-02-09 01:38:07 +01:00
Anthony Scemama f68f16fcc3 Added irp_rdtsc to ninja 2015-12-02 16:20:50 +01:00
Anthony Scemama 3729312876 Corrected bug with += in strings 2015-11-26 16:50:03 +01:00
Anthony Scemama e7f9ec3075 Solves #7 : intrinsic ALL() in ASSERT() 2015-09-22 22:07:11 +02:00
Anthony Scemama 73da2b3cff Use -include in makefile 2015-07-09 16:46:33 +02:00
Anthony Scemama 5d7562fd0a build.ninja is back into IRPF90_temp 2015-06-10 12:10:14 +02:00
Anthony Scemama 4dbab0e6fe repaired version 2015-06-05 18:41:19 +02:00
Anthony Scemama 1d80734cd6 moved build.ninja 2015-06-05 18:32:38 +02:00
Anthony Scemama c95acf33e4 Updated irpman 2015-06-03 23:29:08 +02:00
Anthony Scemama c63d209b92 Corrected wrong -I flags 2015-06-03 15:20:44 +02:00
Anthony Scemama 309507d67a Works with ninja and irpf90.a 2015-06-01 16:37:02 +02:00
Anthony Scemama 452b20c40b Less printing 2015-06-01 14:56:41 +02:00
Anthony Scemama ab735fc6a3 Introduced irpf90.a 2015-06-01 14:44:54 +02:00
Anthony Scemama 9a8335fee3 Cleaned ninja 2015-06-01 14:21:41 +02:00
Anthony Scemama 59c1dc363a Improved ninja 2015-05-28 01:29:01 +02:00
Anthony Scemama fd4f8ebe53 Changed version 2015-05-28 01:17:54 +02:00
Anthony Scemama 9067b3a494 Added support for Ninja 2015-05-28 00:52:33 +02:00
Anthony Scemama d2085a7c35 version 2015-05-22 10:06:01 +02:00
Anthony Scemama a985d7577a Corrected bug with gfortran 2015-05-22 10:05:04 +02:00
Anthony Scemama 864647f0c7 Fixed irp_checkpoint.o in Makefile 2015-04-13 11:18:32 +02:00
59 changed files with 1937 additions and 573 deletions

View File

@ -8,12 +8,16 @@ Dependencies
------------
- GNU make (>= 3.81 recommended)
- Python > 2.3
- Python >2.6
- Any Fortran 90 compiler (Intel recommended)
Installing IRPF90
-----------------
``pip install irpf90``
or
``${IRPF90_HOME}`` is the location of your irpf90 directory::
``` bash

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA

View File

@ -27,22 +27,22 @@
# Define auto-completion for bash
case "$0" in
*bash*)
_irpman_complete()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "`[[ -f tags ]] && cat tags | cut -d' ' -f 1`" -- "$cur" ) )
} && complete -F _irpman_complete irpman
*irpman)
if [[ -z $1 ]] ; then
if [[ $(ps -p $$ -ocomm=) == "zsh" ]]
then
source $(dirname $0)/../irpman-completions.bash
else
echo "To activate auto-completion in bash/zsh:"
echo "source " $0
fi
else
exec python3 $(dirname $0)/../src/irpman.py $1
fi
;;
*)
if [[ -z $1 ]] ; then
echo "To activate auto-completion in bash:"
echo "source " $0
else
python $(dirname $0)/../src/irpman.py $1
fi
source $(dirname ${BASH_SOURCE[0]})/../irpman-completions.bash
;;
esac

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA

View File

@ -1,6 +1,7 @@
IRPF90 = python ../src/irpf90.py -I input -a -d
FC = ifort -profile-functions
IRPF90 = python3 ../src/irpf90.py -I input
FC = ifort
FCFLAGS= -O2
NINJA =
SRC=
OBJ=

38
src/cython_setup.py → irpman-completions.bash Executable file → Normal file
View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/bin/bash
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -24,29 +24,17 @@
# 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import os
to_remove = """cython_setup.py version.py command_line.py""".split()
ext_modules = []
files = os.listdir('.')
for file in to_remove:
files.remove(file)
for file in files:
if file.endswith(".py"):
module = file.split('.')[0]
ext_modules += [ Extension(module,[file]) ]
setup(
name = 'IRPF90 extensions',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
if [[ $(ps -p $$ -ocomm=) == "zsh" ]]
then
autoload bashcompinit
bashcompinit
fi
_irpman_complete()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "`[[ -f tags ]] && cat tags | cut -d' ' -f 1`" -- "$cur" ) )
} && complete -F _irpman_complete irpman

View File

@ -3,7 +3,7 @@ RST2MAN=rst2man -d -t
default: man1/irpman.1.gz man1/irpf90.1.gz
options.rst: ../src/command_line.py
python ../src/command_line.py > options.rst
python3 ../src/command_line.py > options.rst
man1/irpf90.1.gz: irpf90.rst options.rst
rm -f $@ ; $(RST2MAN) --title="IRP Fortran 90" irpf90.rst man1/irpf90.1 ; gzip man1/irpf90.1

Binary file not shown.

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys, os
wd = os.path.abspath(os.path.dirname(__file__))

280
pip/LICENSE.txt 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

2
pip/MANIFEST.in Normal file
View File

@ -0,0 +1,2 @@
include irpf90 README.md irpman irp_indent

52
pip/README.md Normal file
View File

@ -0,0 +1,52 @@
IRPF90
======
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/scemama/irpf90?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
IRPF90 is a Fortran90 preprocessor written in Python for programming using the Implicit Reference to Parameters (IRP) method. It simplifies the development of large fortran codes in the field of scientific high performance computing.
Dependencies
------------
- GNU make (>= 3.81 recommended)
- Python >2.6
- Any Fortran 90 compiler (Intel recommended)
Installing IRPF90
-----------------
``pip install irpf90``
or
``${IRPF90_HOME}`` is the location of your irpf90 directory::
``` bash
cd ${IRPF90_HOME}
make
cat << EOF >> ${HOME}/.bash_profile
export PYTHONPATH=${IRPF90_HOME}/src:${PYTHONPATH}
export PATH=${IRPF90_HOME}/bin:${PATH}
export MANPATH=${IRPF90_HOME}/man:${MANPATH}
EOF
source ${HOME}/.bash_profile
```
Using IRPF90
------------
In an empty directory, run:
``` bash
irpf90 --init
```
This command creates a new Makefile suitable for most irpf90 projects.
Now you can start to program using irpf90.
Web Site
--------
http://irpf90.ups-tlse.fr

32
pip/irpf90 Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
#
# 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 main():
import irpf90_libs.irpf90
irpf90_libs.irpf90.main()
main()

32
pip/irpf90_indent Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
#
# 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 main():
import irpf90_libs.irpf90_indent
irpf90_libs.irpf90_indent.main()
main()

1
pip/irpf90_libs Symbolic link
View File

@ -0,0 +1 @@
../src

64
pip/irpman Executable file
View File

@ -0,0 +1,64 @@
#!/bin/bash
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
#
# 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
# Define auto-completion for bash
function run ()
{
cat << EOF | exec python3 - $@
import sys, os
from irpf90_libs.irpf90_t import mandir
filename = sys.argv[1].lower()+".l"
if filename not in os.listdir(mandir):
print("%s does not exist"%(sys.argv[1]))
sys.exit(-1)
os.system("man ./"+mandir+sys.argv[1].lower()+".l")
EOF
}
case "$0" in
*irpman)
if [[ -z $1 ]] ; then
echo "To activate auto-completion in bash:"
echo "source " $0
else
run $@
fi
;;
*)
_irpman_complete()
{
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "`[[ -f tags ]] && cat tags | cut -d' ' -f 1`" -- "$cur" ) )
} && complete -F _irpman_complete irpman
;;
esac

2
pip/setup.cfg Normal file
View File

@ -0,0 +1,2 @@
[metadata]
description-file = README.md

30
pip/setup.py Normal file
View File

@ -0,0 +1,30 @@
import sys
import setuptools
import version
with open("README.md", "r") as fh:
long_description = fh.read()
v = version.version
setuptools.setup(
name = 'irpf90',
version = v,
scripts = ["irpf90", "irpman", "irpf90_indent"],
author = 'Anthony Scemama',
author_email = 'scemama@irsamc.ups-tlse.fr',
description = 'IRPF90 is a Fortran90 preprocessor written in Python for programming using the Implicit Reference to Parameters (IRP) method. It simplifies the development of large fortran codes in the field of scientific high performance computing.',
long_description=long_description,
long_description_content_type="text/markdown",
url="https://irpf90.ups-tlse.fr",
download_url = f'https://gitlab.com/scemama/irpf90/-/archive/v{v}/irpf90-v{v}.tar.gz',
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Fortran",
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
"Operating System :: POSIX :: Linux",
],
keywords = ['programming', 'fortran', 'IRP'],
)

1
pip/version.py Symbolic link
View File

@ -0,0 +1 @@
../src/version.py

View File

@ -1,21 +1,14 @@
PYTHON=python
PYVERSION=$(shell $(PYTHON) -c "import sys; print(sys.version[:3])")
HAS_CYTHON=$(shell bash -c "which cython &> /dev/null && echo 1 || echo 0")
ifneq ($(HAS_CYTHON),0)
all: exe vim emacs
../bin/irpf90: irpf90.so
rm ../bin/irpf90 ; cd ../bin ; ln -s ../src/irpf90_python.exe irpf90
exe: ../bin/irpf90
irpf90.so : $(wildcard *.py) irpf90.c
./cython_setup.py build_ext --inplace
vim:
python3 vim.py
irpf90.c: irpf90.py
cython --embed irpf90.py
emacs:
python3 emacs.py
else
../bin/irpf90: irpf90_python.exe
rm ../bin/irpf90 ; cd ../bin ; ln -s ../src/irpf90_python.exe irpf90
endif
clean:
rm -f *.c *.so *.pyc *.pyo 2>/dev/null

4
src/__init__.py Normal file
View File

@ -0,0 +1,4 @@
# For relative imports to work in Python 3.6
import os, sys
sys.path = [ os.path.dirname(os.path.realpath(__file__)) ] + sys.path

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -36,10 +36,10 @@ FILENAME=irpdir+'irp_checkpoint.irp.F90'
def create():
out_write = [ "subroutine irp_checkpoint_write" ]
l = variables.keys()
l = list(variables.keys())
l.sort
main_modules = filter(lambda x: modules[x].is_main, modules)
for m in filter(lambda x: not modules[x].is_main, modules):
main_modules = [x for x in modules if modules[x].is_main]
for m in [x for x in modules if not modules[x].is_main]:
out_write += [ " use %s"%(modules[m].name) ]
out_write += [ " implicit none" ]
out_write += [ " integer, parameter :: iunit = %d"%(CHECKPOINT_UNIT_NUMBER) ]

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -39,6 +39,7 @@ options['D'] = [ 'define' , 'Defines a variable identified by the IRP_IF s
options['g'] = [ 'profile' , 'Activates profiling of the code.', 0 ]
options['h'] = [ 'help' , 'Print this help', 0 ]
options['I'] = [ 'include' , 'Include directory', 1 ]
options['j'] = [ 'ninja' , 'Use Ninja instead of make', 0 ]
options['i'] = [ 'init' , 'Initialize current directory. Creates a default Makefile and the temporary working directories.', 0 ]
options['l'] = [ 'align' , 'Align arrays using compiler directives and sets the $IRP_ALIGN variable. For example, --align=32 aligns all arrays on a 32 byte boundary.', 1 ]
options['m'] = [ 'memory' , 'Print memory allocations/deallocations.', 0 ]
@ -49,6 +50,7 @@ options['r'] = [ 'no_directives', 'Ignore all compiler directives !DEC$ and !DIR
options['s'] = [ 'substitute' , 'Substitute values in do loops for generating specific optimized code.', 1 ]
options['t'] = [ 'touch' , 'Display which entities are touched when touching the variable given as an argument.', 1 ]
options['v'] = [ 'version' , 'Prints version of irpf90', 0 ]
options['w'] = [ 'warnings' , 'Activate Warnings', 0 ]
options['z'] = [ 'openmp' , 'Activate for OpenMP code', 0 ]
class CommandLine(object):
@ -74,7 +76,7 @@ class CommandLine(object):
for o,a in self.opts:
if o in [ "-I", '--'+options['I'][0] ]:
if len(a) < 1:
print "Error: -I option needs a directory"
print("Error: -I option needs a directory")
if a[-1] != '/':
a = a+'/'
self._include_dir.append(a)
@ -114,12 +116,12 @@ class CommandLine(object):
elif len(buffer) == 3:
self._codelet = [buffer[0], int(buffer[2]), buffer[1], filename]
else:
print """
print("""
Error in codelet definition. Use:
--codelet=provider:NMAX
or
--codelet=provider:precondition:NMAX
"""
""")
sys.exit(1)
return self._codelet
codelet = property(fget=codelet)
@ -160,6 +162,15 @@ or
return self._coarray
coarray = property(fget=coarray)
def warnings(self):
if '_warnings' not in self.__dict__:
self._warnings= False
for o,a in self.opts:
if o in [ "-w", '--'+options['w'][0] ]:
self._warnings= True
return self._warnings
do_warnings = property(fget=warnings)
def openmp(self):
if '_openmp' not in self.__dict__:
self._openmp = False
@ -169,6 +180,15 @@ or
return self._openmp
do_openmp = property(fget=openmp)
def ninja(self):
if '_ninja' not in self.__dict__:
self._ninja = False
for o,a in self.opts:
if o in [ "-j", '--'+options['j'][0] ]:
self._ninja = True
return self._ninja
do_ninja = property(fget=ninja)
def directives(self):
if '_directives' not in self.__dict__:
self._directives = True
@ -189,11 +209,11 @@ Options:
"""
t = t.replace("$EXE",self.executable_name)
t = t.replace("$DESCR",description)
print t
print(t)
print_options()
print ""
print "Version : ", version
print ""
print("")
print("Version : ", version)
print("")
def opts(self):
if self._opts is None:
@ -208,10 +228,10 @@ Options:
try:
self._opts, args = getopt.getopt(self.argv[1:], optlist[0], optlist[1])
except getopt.GetoptError, err:
except getopt.GetoptError as err:
# print help information and exit:
self.usage()
print str(err) # will print something like "option -a not recognized"
print(str(err)) # will print something like "option -a not recognized"
sys.exit(2)
return self._opts
@ -228,9 +248,9 @@ def do_$LONG(self):
return self._do_$LONG
do_$LONG = property(fget=do_$LONG)
"""
for short in options:
long = options[short][0]
exec t.replace("$LONG",long).replace("$SHORT",short) #in locals()
for short_opt in options:
long_opt = options[short_opt][0]
exec(t.replace("$LONG",long_opt).replace("$SHORT",short_opt)) #in locals()
def do_run(self):
if '_do_run' not in self.__dict__:
@ -247,16 +267,16 @@ do_$LONG = property(fget=do_$LONG)
command_line = CommandLine()
def print_options():
keys = options.keys()
keys = list(options.keys())
keys.sort()
import subprocess
for k in keys:
description = options[k][1]
p1 = subprocess.Popen(["fold", "-s", "-w", "40"],stdout=subprocess.PIPE,stdin=subprocess.PIPE)
p1 = subprocess.Popen(["fold", "-s", "-w", "40"],stdout=subprocess.PIPE,stdin=subprocess.PIPE, encoding='utf8')
description = p1.communicate(description)[0]
description = description.replace('\n','\n'.ljust(27))
print ("-%s, --%s"%(k,options[k][0])).ljust(25), description+'\n'
print "\n"
print(("-%s, --%s"%(k,options[k][0])).ljust(25), description+'\n')
print("\n")
if __name__ == '__main__':
print_options()

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -34,12 +34,13 @@ from util import *
def do_print_short(file,var):
"""Makes a short print, as in irpf90_entities"""
assert type(var) == Variable
print >>file, "%s : %s :: %s %s"%( \
print("%s : %s :: %s %s"%( \
var.line.filename[0].ljust(35),
var.type.ljust(30),
var.name.ljust(25),
build_dim(var.dim) )
build_dim(var.dim) ), file=file)
######################################################################
def process_doc(file,line):
@ -47,13 +48,13 @@ def process_doc(file,line):
line = line.strip()
if line == "":
line = ".br"
print >>file, line
print(line, file=file)
######################################################################
def process_deps(file,l):
assert type(l) == list
for v in l:
print >>file, "%s\n.br"%(v,)
print("%s\n.br"%(v,), file=file)
######################################################################
def process_types(file,var):
@ -64,7 +65,7 @@ def process_types(file,var):
var = variables[var]
Type = var.type
dim = build_dim(var.dim)
print >>file, "%s\t:: %s\t%s"%(Type,name,dim)
print("%s\t:: %s\t%s"%(Type,name,dim), file=file)
######################################################################
def do_print(var):
@ -72,37 +73,106 @@ def do_print(var):
filename = var.line.filename[0]
name = var.name
file = open("%s%s.l"%(mandir,var.name), "w")
print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name)
print('.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name), file=file)
if var.same_as != var.name:
var = variables[var.same_as]
print >>file, ".SH Declaration"
print >>file, ".nf"
print(".SH Declaration", file=file)
print(".nf", file=file)
process_types(file,var)
print >>file, ".ni"
print(".ni", file=file)
if var.doc != []:
print >>file, ".SH Description"
print(".SH Description", file=file)
for l in var.doc:
process_doc(file,l)
print >>file, ".SH File\n.P"
print >>file, filename
print(".SH File\n.P", file=file)
print(filename, file=file)
if var.needs != []:
var.needs.sort()
print >>file, ".SH Needs"
print(".SH Needs", file=file)
process_deps(file,var.needs)
if var.needed_by != []:
var.needed_by.sort()
print >>file, ".SH Needed by"
print(".SH Needed by", file=file)
process_deps(file,var.needed_by)
print >>file, ".SH Instability factor"
print(".SH Instability factor", file=file)
fo = len(var.children)
fi = len(var.parents)
print >>file, "%5.1f %%"%(100.* (fi / (fi+fo+.000001) ))
print >>file, ".br"
print("%5.1f %%"%(100.* (fi / (fi+fo+.000001) )), file=file)
print(".br", file=file)
file.close()
######################################################################
def do_print_rst(var):
"""Print providers in a format suitable for sphinx"""
assert type(var) == Variable
filename = var.line.filename[0]
name = var.name
file = open("%s%s.rst"%(mandir,var.name), "w")
print(".. c:var:: %s\n"%(var.name.lower()), file=file)
print("", file=file)
print(" File : :file:`"+filename+"`", file=file)
print("", file=file)
print(" .. code:: fortran", file=file)
print("", file=file)
if var.same_as != var.name:
var = variables[var.same_as]
for v in [var.name] + var.others:
name = v
v = variables[v]
Type = v.type
dim = build_dim(v.dim)
print(" %s\t:: %s\t%s"%(Type,name,dim), file=file)
print("", file=file)
print("", file=file)
if var.doc != []:
d = []
for text in var.doc:
text_old = None
while text_old != text:
text_old = text
text = text.replace("$",":math:`",1).replace("$","` ",1)
d.append(text)
loop = True
while loop:
maxlen=0
for l in d:
ll = len(l)
maxlen = max(ll,maxlen)
if ll > 0 and l[0] != ' ':
loop = False
break
loop = loop and maxlen > 0
if loop:
d = [ l[1:] for l in d ]
for line in d:
print(" "+line, file=file)
print("", file=file)
if var.needs != []:
var.needs.sort()
print(" Needs:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in var.needs:
print(" * :c:data:`%s`"%(variables[v].same_as.lower(),), file=file)
print("", file=file)
if var.needed_by != []:
var.needed_by.sort()
print(" Needed by:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in var.needed_by:
print(" * :c:data:`%s`"%(variables[v].same_as.lower(),), file=file)
print("", file=file)
file.close()
######################################################################
def process_declaration_subroutine(file, sub):
print >>file, sub.line.text.split('!')[0].strip()
print(sub.line.text.split('!')[0].strip(), file=file)
# for line in sub.text:
######################################################################
@ -111,38 +181,116 @@ def do_print_subroutines(sub):
filename = sub.line.filename
name = sub.name
file = open("%s%s.l"%(mandir,sub.name), "w")
print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name)
print >>file, ".SH Declaration"
print >>file, ".nf"
print('.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name), file=file)
print(".SH Declaration", file=file)
print(".nf", file=file)
process_declaration_subroutine(file,sub)
print >>file, ".ni"
print(".ni", file=file)
if sub.doc != []:
print >>file, ".SH Description"
print(".SH Description", file=file)
for l in sub.doc:
process_doc(file,l)
print >>file, ".SH File\n.P"
print >>file, filename
print(".SH File\n.P", file=file)
print(filename, file=file)
if sub.needs != []:
sub.needs.sort()
print >>file, ".SH Needs"
print(".SH Needs", file=file)
process_deps(file,sub.needs)
if sub.called_by != []:
sub.called_by.sort()
print >>file, ".SH Called by"
print(".SH Called by", file=file)
process_deps(file,sub.called_by)
if sub.calls != []:
sub.calls.sort()
print >>file, ".SH Calls"
print(".SH Calls", file=file)
process_deps(file,sub.calls)
if sub.touches != []:
sub.touches.sort()
print >>file, ".SH Touches"
print(".SH Touches", file=file)
process_deps(file,sub.touches)
print >>file, ".SH Instability factor"
print(".SH Instability factor", file=file)
fo = len(sub.needs)+len(sub.calls)+len(sub.touches)
fi = len(sub.called_by)
print >>file, "%5.1f %%"%(100.* (fi / (fi+fo+.000001) ))
print >>file, ".br"
print("%5.1f %%"%(100.* (fi / (fi+fo+.000001) )), file=file)
print(".br", file=file)
file.close()
######################################################################
def do_print_subroutines_rst(sub):
"""Print subroutines in a format suitable for sphinx"""
assert type(sub) == Sub
filename = sub.line.filename
name = sub.name
file = open("%s%s.rst"%(mandir,sub.name), "w")
print(".. c:macro:: %s:\n"%(sub.name.lower()), file=file)
print("", file=file)
print(" File : :file:`"+filename+"`", file=file)
print("", file=file)
print(" .. code:: fortran", file=file)
print("", file=file)
print(" "+sub.line.text.split('!')[0].strip(), file=file)
print("", file=file)
print("", file=file)
if sub.doc != []:
d = list(sub.doc)
loop = True
while loop:
maxlen=0
for l in d:
ll = len(l)
maxlen = max(ll,maxlen)
if ll > 0 and l[0] != ' ':
loop = False
break
loop = loop and maxlen > 0
if loop:
d = [ l[1:] for l in d ]
for l in d:
print(" "+l, file=file)
print("", file=file)
if sub.needs != []:
sub.needs.sort()
print(" Needs:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in sub.needs:
print(" * :c:data:`%s`"%(variables[v].same_as.lower(),), file=file)
print("", file=file)
if sub.called_by != []:
sub.called_by.sort()
print(" Called by:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in sub.called_by:
if v in subroutines:
print(" * :c:func:`%s`"%(v.lower(),), file=file)
elif v in variables:
print(" * :c:data:`%s`"%(variables[v.lower()].same_as.lower(),), file=file)
print("", file=file)
if sub.calls != []:
sub.calls.sort()
print(" Calls:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in sub.calls:
print(" * :c:func:`%s`"%(v.lower(),), file=file)
print("", file=file)
if sub.touches != []:
sub.touches.sort()
print(" Touches:", file=file)
print("", file=file)
print(" .. hlist::", file=file)
print(" :columns: 3", file=file)
print("", file=file)
for v in sub.touches:
print(" * :c:data:`%s`"%(variables[v.lower()].same_as.lower(),), file=file)
print("", file=file)
file.close()
######################################################################
@ -151,34 +299,60 @@ def run():
import os,sys
pid1 = os.fork()
if pid1 == 0:
for v in variables.values():
for v in list(variables.values()):
do_print(v)
for s in subroutines.values():
do_print_rst(v)
for s in list(subroutines.values()):
do_print_subroutines(s)
do_print_subroutines_rst(s)
sys.exit(0)
pid2 = os.fork()
if pid2 == 0:
tags = []
l = variables.keys()
l = list(variables.keys())
file = open("irpf90_entities","w")
l.sort()
for v in l:
do_print_short(file,variables[v])
line = variables[v].line
# tags.append( '%s\t%s\t/%s/;"\n'%(v,line.filename[0],line.text.split('!')[0].strip()) )
tags.append( '%s\t%s\t%d\n'%(v,line.filename[0],line.i) )
file.close()
l = subroutines.keys()
l = list(subroutines.keys())
for v in l:
line = subroutines[v].line
# tags.append('%s\t%s\t/%s/;"\n'%(v,line.filename,line.text.split('!')[0].strip()))
tags.append('%s\t%s\t%d\n'%(v,line.filename,line.i))
tags.sort()
file = open("tags","w")
for line in tags:
file.write(line)
file.close()
# # Create emacs tags
# tags = {}
# l = list(variables.keys())
# for v in l:
# line = variables[v].line
# if line.filename[0] not in tags:
# tags[line.filename[0]] = []
# tags[line.filename[0]].append( (v,line) )
# l = list(subroutines.keys())
# for v in l:
# line = subroutines[v].line
# if line.filename not in tags:
# tags[line.filename] = []
# tags[line.filename].append( (v,line) )
#
# file = open("TAGS","w")
# for f in tags:
# tags[f].sort()
# text = ""
# for v, line in tags[f]:
# text += "%s\x7f%s\x01%d,0\n"%(line.text.split('!')[0].rstrip(),v,line.i)
# file.write("\x0c\n%s,%d\n"%(f, len(text)))
# file.write(text)
# file.close()
sys.exit(0)
os.waitpid(pid1,0)

72
src/emacs.py Normal file
View File

@ -0,0 +1,72 @@
"""
IRPF90 is a Fortran90 preprocessor written in Python for programming using
the Implicit Reference to Parameters (IRP) method.
Copyright (C) 2009 Anthony SCEMAMA
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.
This script handles the files needed to use the IRPF90 Emacs mode. This
config used the emacs package `use-package`
(https://jwiegley.github.io/use-package/).
The user is responsible for its installing and configuring it.
Contributed by Ramon L. Panades-Barrueta (https://tinyurl.com/y6qvjmxg ).
"""
import os
import shutil
def install():
"""Installs the irp-mode in Emacs"""
# Check user Emacs config
emacs_init = [*map(lambda x: os.environ["HOME"] + x,
["/.emacs.d/inil.el", "/.emacs"])]
emacs_dir = os.environ["HOME"] + "/.emacs.d"
os.makedirs(f"{emacs_dir}/lib", exist_ok=True)
emacs = emacs_init[0] if os.access(
emacs_init[0], os.F_OK) else emacs_init[1]
# Add support for irp-mode and Yasnippets
with open(emacs, "a") as emfil:
emfil.write("\n")
emfil.write(";; Use Yasnippets\n")
emfil.write("(use-package yasnippet\n")
emfil.write(" :ensure t\n")
emfil.write(" :config\n")
emfil.write(" (yas-global-mode 1))\n")
emfil.write("\n")
emfil.write(";; Use irp-mode\n")
emfil.write("(use-package irp-mode\n")
emfil.write(r""" :mode ("\\.irp.f\\'")""")
emfil.write(f"""\n :load-path "{emacs_dir}/lib")\n""")
# Copy irp-mode files
workd = os.path.abspath(os.path.dirname(__file__))
with open(f"{workd}/irp-mode.el", 'r') as f_in:
with open(f"{emacs_dir}/lib/irp-mode.el", 'w') as f_out:
f_out.write(f_in.read())
# Snippets
os.makedirs(f"{emacs_dir}/snippets/irp-mode/", exist_ok=True)
snips = os.listdir(f"{workd}/irp_snippets")
for fil in snips:
shutil.copy(f"{workd}/irp_snippets/{fil}",
f"{emacs_dir}/snippets/irp-mode/")
if __name__ == "__main__":
install()

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -27,32 +27,36 @@
import sys
from irpf90_t import *
from command_line import command_line
do_warnings = command_line.do_warnings
######################################################################
def fail(line,message):
print """
print("""
Error:
-----
"""
print message, '\n'
""")
print(message, '\n')
if line is not None:
assert isinstance(line,Line)
print "file %s ; line %d :\n %s"%(line.filename,line.i,line.text)
print("file %s ; line %d :\n %s"%(line.filename,line.i,line.text))
sys.exit(1)
######################################################################
def warn(line,message):
if not command_line.do_warnings:
return
if line is not None:
assert isinstance(line,Line)
print """
print("""
Warning:
-------
"""
print message, '\n'
print "file %s, line %d:\n %s"%(line.filename,line.i,line.text)
""")
print(message, '\n')
print("file %s, line %d:\n %s"%(line.filename,line.i,line.text))
else:
print "Warning: %s"%(message)
print("Warning: %s"%(message))
######################################################################

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
# Copyright (C) 2009 Anthony SCEMAMA
#
# 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
@ -20,8 +20,8 @@
# Anthony Scemama
# LCPQ - IRSAMC - CNRS
# Universite Paul Sabatier
# 118, route de Narbonne
# 31062 Toulouse Cedex 4
# 118, route de Narbonne
# 31062 Toulouse Cedex 4
# scemama@irsamc.ups-tlse.fr
@ -61,13 +61,13 @@ def init():
# Create makefile
makefile.create()
# Copy current files in the irpdir
for dir in ['./']+command_line.include_dir:
try:
os.stat(dir)
except:
print dir,'not in dir'
print(dir,'not in dir')
continue
for filename in os.listdir(dir):
filename = dir+filename
@ -75,14 +75,18 @@ def init():
try:
file = open(filename,"r")
except IOError:
print "Warning : Unable to read file %s."%(filename)
if command_line.do_warnings:
print("Warning : Unable to read file %s."%(filename))
else:
buffer = file.read()
file.close()
if not util.same_file(irpf90_t.irpdir+filename,buffer):
file = open(irpf90_t.irpdir+filename,"w")
file.write(buffer)
try:
buffer = file.read()
file.close()
if not util.same_file(irpf90_t.irpdir+filename,buffer):
file = open(irpf90_t.irpdir+filename,"w")
file.write(buffer)
file.close()
except UnicodeError:
pass
initialized = True

41
src/irp-mode.el Normal file
View File

@ -0,0 +1,41 @@
;;; irp-mode.el --- A major mode for dealing with IRPF90 files
;;; Commentary:
;; An attempt to support Scemama's IRPF90 in Emacs
;;; Code:
;; Define IRPF90 extended FORTRAN syntax
(defvar irp-font-lock-keywords)
(setq irp-font-lock-keywords
(let* (
;; Define different keywords
(x-keywords '("BEGIN_PROVIDER" "END_PROVIDER" "ASSERT"
"FREE" "PROVIDE" "BEGIN_TEMPLATE"
"END_TEMPLATE" "BEGIN_SHELL"
"END_SHELL" "IRP_IF" "IRP_ELSE"))
(x-types '("double precision" "integer"))
(x-comments '("BEGIN_DOC" "END_DOC"))
;; Generate regex
(x-keywords-regexp (regexp-opt x-keywords 'words))
(x-types-regexp (regexp-opt x-types 'words))
(x-comments-regexp (regexp-opt x-comments 'words)))
`(
(,x-types-regexp . font-lock-type-face)
(,x-keywords-regexp . font-lock-preprocessor-face)
(,x-comments-regexp . font-lock-comment-face)
)))
;;;###autoload
(define-derived-mode irp-mode f90-mode "irp mode"
"Major mode for editing IRPF90 files."
:syntax-table nil
:abbrev-table nil
(font-lock-add-keywords nil irp-font-lock-keywords))
(provide 'irp-mode)
;;; irp-mode.el ends here

5
src/irp_snippets/irp_as Normal file
View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: ASSERT
# key: ass
# --
ASSERT ($0)

7
src/irp_snippets/irp_doc Normal file
View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: BEGIN_DOC ... END_DOC
# key: bc
# --
BEGIN_DOC
! $0
END_DOC

View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: BEGIN_PROVIDER ... END_PROVIDER
# key: bp
# --
BEGIN_PROVIDER [${1:integer}, ${2:var}]
$0
END_PROVIDER

8
src/irp_snippets/irp_sh Normal file
View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# -*- mode: snippet -*-
# name: BEGIN_SHELL ... END_SHELL
# key: bsh
# --
BEGIN_SHELL [ ${1:/bin/bash} ]
$0
END_SHELL

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -28,7 +28,6 @@
import util
from command_line import command_line
do_assert = command_line.do_assert
do_debug = command_line.do_debug
do_openmp = command_line.do_openmp
do_memory = command_line.do_memory
@ -42,52 +41,25 @@ def create():
txt = """
module irp_stack_mod
integer, parameter :: STACKMAX=1000
character*(128),allocatable :: irp_stack(:,:)
double precision,allocatable :: irp_cpu(:,:)
integer,allocatable :: stack_index(:)
character*(128),allocatable :: irp_stack(:)
double precision,allocatable :: irp_cpu(:)
integer :: stack_index
logical :: alloc = .False.
integer :: nthread
character*(128) :: white = ''
end module
subroutine irp_enter(irp_where)
use irp_stack_mod
integer :: ithread
character*(*) :: irp_where
"""
if not do_openmp:
txt += """
ithread = 0
"""
else:
txt += """
integer, external :: omp_get_thread_num
integer, external :: omp_get_num_threads
ithread = omp_get_thread_num()
"""
txt += "$1"
if do_memory:
txt+="""
if (.not.alloc) then
"""
if do_openmp:
txt += """
!$OMP PARALLEL
!$OMP SINGLE
nthread = omp_get_num_threads()
!$OMP END SINGLE
!$OMP END PARALLEL
"""
else:
txt += """
nthread = 1
"""
txt += """
print *, 'Allocating irp_stack(',STACKMAX,',',nthread,')'
print *, 'Allocating irp_cpu(',STACKMAX,',',nthread,')'
print *, 'Allocating stack_index(',nthread,')'
print *, 'Allocating irp_stack(',STACKMAX+1,')'
print *, 'Allocating irp_cpu(',STACKMAX+1,')'
endif"""
txt +="""
$2
@ -95,42 +67,14 @@ end subroutine
subroutine irp_enter_f(irp_where)
use irp_stack_mod
integer :: ithread
character*(*) :: irp_where
"""
if do_openmp:
txt += """
integer, external :: omp_get_thread_num
integer, external :: omp_get_num_threads
ithread = omp_get_thread_num()
"""
else:
txt += """
ithread = 0
"""
txt += """
$1
"""
if do_memory:
txt+="""
if (.not.alloc) then
"""
if do_openmp:
txt += """
!$OMP PARALLEL
!$OMP SINGLE
nthread = omp_get_num_threads()
!$OMP END SINGLE
!$OMP END PARALLEL
"""
else:
txt += """
nthread = 1
"""
txt +="""
print *, 'Allocating irp_stack(',STACKMAX,',',nthread,')'
print *, 'Allocating irp_cpu(',STACKMAX,',',nthread,')'
print *, 'Allocating stack_index(',nthread,')'
print *, 'Allocating irp_stack(',STACKMAX+1,')'
print *, 'Allocating irp_cpu(',STACKMAX+1,')'
endif
"""
txt += """
@ -140,66 +84,27 @@ end subroutine
subroutine irp_leave (irp_where)
use irp_stack_mod
character*(*) :: irp_where
integer :: ithread
double precision :: cpu
"""
if do_openmp:
txt += """
integer, external :: omp_get_thread_num
ithread = omp_get_thread_num()
"""
else:
txt += """
ithread = 0
"""
txt += """
$3
$4
end subroutine
"""
# $1
if do_assert or do_debug:
if do_debug:
s = """
if (.not.alloc) then
"""
if do_openmp:
s += """
!$OMP PARALLEL
!$OMP SINGLE
nthread = omp_get_num_threads()
!$OMP END SINGLE
!$OMP END PARALLEL
!$OMP CRITICAL
if (.not.alloc) then
allocate(irp_stack(0:STACKMAX,nthread))
allocate(irp_cpu(0:STACKMAX,nthread))
allocate(stack_index(nthread))
allocate(irp_stack(0:STACKMAX))
allocate(irp_cpu(0:STACKMAX))
stack_index = 0
alloc = .True.
endif
!$OMP END CRITICAL
endif
stack_index(ithread+1) = mod(stack_index(ithread+1)+1,STACKMAX)
irp_stack(stack_index(ithread+1),ithread+1) = irp_where"""
else:
s += """
nthread = 1
if (.not.alloc) then
allocate(irp_stack(0:STACKMAX,1))
allocate(irp_cpu(0:STACKMAX,1))
allocate(stack_index(2))
stack_index = 0
alloc = .True.
endif
endif
stack_index(1) = mod(stack_index(1)+1,STACKMAX)
irp_stack(stack_index(1),1) = irp_where"""
stack_index = min(stack_index+1,STACKMAX)
irp_stack(stack_index) = irp_where"""
if do_memory:
txt+="""
print *, 'Allocating irp_stack(',STACKMAX,','nthread,')'
print *, 'Allocating irp_cpu(',STACKMAX,','nthread,')'
print *, 'Allocating stack_index(',nthread,')'"""
print *, 'Allocating irp_stack(',STACKMAX+1,')'
print *, 'Allocating irp_cpu(',STACKMAX+1,')' """
else:
s = ""
txt = txt.replace("$1",s)
@ -207,8 +112,8 @@ end subroutine
# $2
if do_debug:
txt = txt.replace("$2","""
print *, ithread, ':', white(1:stack_index(ithread+1))//'-> ', trim(irp_where)
call cpu_time(irp_cpu(stack_index(ithread+1),ithread+1))""")
print *, white(1:stack_index)//'-> ', trim(irp_where)
call cpu_time(irp_cpu(stack_index))""")
else:
txt = txt.replace("$2","")
@ -216,47 +121,35 @@ end subroutine
if do_debug:
txt = txt.replace("$3","""
call cpu_time(cpu)
print *, ithread, ':', white(1:stack_index(ithread+1))//'<- ', &
trim(irp_stack(stack_index(ithread+1),ithread+1)), &
cpu-irp_cpu(stack_index(ithread+1),ithread+1)""")
print *, white(1:stack_index)//'<- ', &
trim(irp_stack(stack_index)), &
cpu-irp_cpu(stack_index)""")
else:
txt = txt.replace("$3","")
# $4
if do_debug or do_assert:
if do_debug:
txt = txt.replace("$4","""
stack_index(ithread+1) = stack_index(ithread+1)-1""")
stack_index = max(0,stack_index-1)""")
else:
txt = txt.replace("$4","")
txt += """
subroutine irp_trace
use irp_stack_mod
integer :: ithread
integer :: i
"""
if do_openmp:
txt += """
!$ integer, external :: omp_get_thread_num
!$ ithread = omp_get_thread_num()
"""
else:
txt += """
ithread = 0
"""
txt += """
if (.not.alloc) return
print *, 'Stack trace: ', ithread
print *, 'Stack trace: '
print *, '-------------------------'
do i=1,stack_index(ithread+1)
print *, trim(irp_stack(i,ithread+1))
do i=1,stack_index
print *, trim(irp_stack(i))
enddo
print *, '-------------------------'
end subroutine
"""
txt = txt.split('\n')
txt = map(lambda x: x+"\n",txt)
txt = [x+"\n" for x in txt]
if not util.same_file(FILENAME, txt):
file = open(FILENAME,'w')
file.writelines(txt)

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python
#cscs /usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -27,27 +26,24 @@
import vim
import os,sys
try:
wd = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0,(wd+"/../src/"))
except:
pass
sys.setcheckinterval(1000)
import vim
import os,sys
from command_line import command_line
def main():
vim.install()
if command_line.do_help:
command_line.usage()
if command_line.do_version:
from version import version
print version
print(version)
from init import init
if command_line.do_init:
@ -59,26 +55,21 @@ def main():
for filename,text in preprocessed_text:
if filename in command_line.preprocessed:
for line in text:
print line.text
print(line.text)
if command_line.do_touch:
from variables import variables
for var in command_line.touched:
if var not in variables:
print "%s is not an IRP entity"%(var,)
print("%s is not an IRP entity"%(var,))
else:
print "Touching %s invalidates the following entities:"%(var,)
print("Touching %s invalidates the following entities:"%(var,))
parents = variables[var].parents
parents.sort()
for x in parents:
print "- %s"%(x,)
print("- %s"%(x,))
if command_line.do_codelet:
import profile
profile.build_rdtsc()
import codelet
codelet.run()
if not command_line.do_run:
return
@ -91,8 +82,14 @@ def main():
import makefile
makefile.create()
if command_line.do_codelet:
import profile
profile.build_rdtsc()
import codelet
codelet.run()
from modules import modules, write_module
for m in modules.keys():
for m in list(modules.keys()):
write_module(modules[m])
makefile.run()

View File

@ -2,9 +2,8 @@
" Language: IRPF90
" Version: 0.1
" URL:
" Last Change: 2011 Nov. 9
" Last Change: 2018 Nov. 28
" Maintainer:
" Usage: Do :help irpf90-syntax from Vim
" Credits:
" Version 0.1 was based on the fortran 95 syntax file by Ajit J. Thakkar
@ -373,4 +372,120 @@ map K :call ReadMan()<CR>
set equalprg=irpf90_indent
"if exists('g:no_irpf90_conceal') || !has('conceal') || &enc != 'utf-8'
" finish
"endif
"syntax match irpf90NiceOperator "<-" conceal cchar=←
"iab ← <-
"syntax match irpf90NiceOperator "->" conceal cchar=→
"iab → ->
"syntax match irpf90NiceOperator "==" conceal cchar=≡
"iab ≡ ==
"syntax match irpf90NiceOperator "\.eq\." conceal cchar=≡
"syntax match irpf90NiceOperator "/=" conceal cchar=≠
"iab ≠ /=
"syntax match irpf90NiceOperator "\.ne\." conceal cchar=≠
"syntax match irpf90NiceOperator "\.or\." conceal cchar=
"iab .or.
"syntax match irpf90NiceOperator "\.and\." conceal cchar=∧
"iab ∧ .and.
"syntax match irpf90NiceOperator "*" conceal cchar=×
"iab × *
"
"let s:extraConceal = 1
"" Some windows font don't support some of the characters,
"" so if they are the main font, we don't load them :)
"if has("win32")
" let s:incompleteFont = [ 'Consolas'
" \ , 'Lucida Console'
" \ , 'Courier New'
" \ ]
" let s:mainfont = substitute( &guifont, '^\([^:,]\+\).*', '\1', '')
" for s:fontName in s:incompleteFont
" if s:mainfont ==? s:fontName
" let s:extraConceal = 0
" break
" endif
" endfor
"endif
"
"if s:extraConceal
" syntax match irpf90NiceOperator "<=" conceal cchar=≤
" syntax match irpf90NiceOperator "\.le\." conceal cchar=≤
" iab ≤ <=
" syntax match irpf90NiceOperator ">=" conceal cchar=≥
" syntax match irpf90NiceOperator "\.ge\." conceal cchar=≥
" iab ≥ >=
" syntax match irpf90NiceOperator "\.lt\." conceal cchar=<
" syntax match irpf90NiceOperator "\.gt\." conceal cchar=>
" syntax match irpf90NiceOperator "=>" conceal cchar=⇒
" iab ⇒ =>
" syntax match irpf90NiceOperator "\:\:" conceal cchar=∷
" iab ∷ ::
" syntax match irpf90NiceOperator "++" conceal cchar=⧺
" iab ⧺ ++
" syntax match irpf90NiceOperator "\<lapl_" conceal cchar=Δ
" syntax match irpf90NiceOperator "\C\<Delta\>" conceal cchar=Δ
" iab Δ Delta
" syntax match irpf90NiceOperator "\C\<Lambda\>" conceal cchar=Λ
" iab Λ Lambda
" syntax match irpf90NiceOperator "\C\<Pi\>" conceal cchar=Π
" iab Π Pi
" syntax match irpf90NiceOperator "\C\<Sigma\>" conceal cchar=Σ
" iab Σ Sigma
" syntax match irpf90NiceOperator "\C\<Psi\>" conceal cchar=Ψ
" iab Ψ Psi
" syntax match irpf90NiceOperator "\C\<Omega\>" conceal cchar=Ω
" iab Ω Omega
" syntax match irpf90NiceOperator "\C\<alpha\>" conceal cchar=α
" iab α alpha
" syntax match irpf90NiceOperator "\C\<beta\>" conceal cchar=β
" iab β beta
" syntax match irpf90NiceOperator "\C\<gamma\>" conceal cchar=γ
" iab γ gamma
" syntax match irpf90NiceOperator "\C\<delta\>" conceal cchar=δ
" iab δ delta
" syntax match irpf90NiceOperator "\C\<epsilon\>" conceal cchar=ε
" iab ε epsilon
" syntax match irpf90NiceOperator "\C\<zeta\>" conceal cchar=ζ
" iab ζ zeta
" syntax match irpf90NiceOperator "\C\<theta\>" conceal cchar=θ
" iab θ theta
" syntax match irpf90NiceOperator "\C\<eta\>" conceal cchar=η
" iab η eta
" syntax match irpf90NiceOperator "\C\<lambda\>" conceal cchar=λ
" iab λ lambda
" syntax match irpf90NiceOperator "\C\<mu\>" conceal cchar=μ
" iab μ mu
" syntax match irpf90NiceOperator "\C\<nu\>" conceal cchar=ν
" iab ν nu
" syntax match irpf90NiceOperator "\C\<pi\>" conceal cchar=π
" iab π pi
" syntax match irpf90NiceOperator "\C\<rho\>" conceal cchar=ρ
" iab ρ rho
" syntax match irpf90NiceOperator "\C\<sigma\>" conceal cchar=σ
" iab σ sigma
" syntax match irpf90NiceOperator "\C\<tau\>" conceal cchar=τ
" iab τ tau
" syntax match irpf90NiceOperator "\C\<phi\>" conceal cchar=φ
" iab φ phi
" syntax match irpf90NiceOperator "\C\<nabla\>" conceal cchar=∇
" iab ∇ nabla
" syntax match irpf90NiceOperator "\C\<grad_" conceal cchar=∇
" iab ∇ grad_o
" syntax match irpf90NiceOperator "\C\<chi\>" conceal cchar=χ
" iab χ chi
" syntax match irpf90NiceOperator "\C\<psi\>" conceal cchar=ψ
" iab ψ psi
" syntax match irpf90NiceOperator "\C\<omega\>" conceal cchar=ω
" iab ω omega
"endif
"
"hi link irpf90NiceOperator Operator
"hi! link Conceal Operator
"setlocal conceallevel=2
" vim: set fenc=utf-8:
" vim: ts=8 tw=132

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -26,10 +26,21 @@
import sys
import os
import re
LENMAX = 70
tabn = 2
#copy of locals without "import copy"
locals_ = {x: y for x, y in locals().items()}
for key, value in locals_.items():
try:
val = os.environ["IRPF90_INDENT_"+key.upper()]
locals()[key] = type(locals_[key])(val)
except:
pass
tab = " "*tabn
class Grep(object):
@ -106,6 +117,14 @@ class Grep(object):
def declaration(self,string):
return re.match(self.re_declaration,string) is not None
re_preprocessor = re.compile(r"^\s*#.*$")
def preprocessor(self,string):
return re.match(self.re_preprocessor,string) is not None
re_omppragma = re.compile(r"^\s*!\$omp\s.*$")
def omppragma(self,string):
return re.match(self.re_omppragma,string) is not None
grep = Grep()
class indent(object):
@ -119,10 +138,12 @@ class indent(object):
return l.strip().ljust(n) + ' :: '+ r.strip()
def format_continuation(self,string,n):
buffer = string.split('&')
buffer = string.split('&', 1)
if len(buffer) == 1:
l = buffer[0]
return l
elif buffer[0].strip() == "":
return self.format_continuation(buffer[1], n)
else:
l, r = buffer
return l.strip().ljust(69-len(n)) + '&'+ r.strip()
@ -165,25 +186,38 @@ class indent(object):
for i in range(len(self.text)):
prevline = line
line = self.text[i].strip()
if line == "":
print("")
continue
if grep.preprocessor(line):
print(line.lstrip())
continue
if grep.omppragma(line):
print(line.lstrip())
continue
if grep.continuation(line):
line = self.format_continuation(line,k)
if grep.continuation(prevline):
print k+2*tab+self.format_continuation(line,k+2*tab)
print(k+2*tab+self.format_continuation(line,k+2*tab))
continue
if grep.begin_subroutine(line):
print line
print(line)
k = indent0+tab
continue
if grep.begin_function(line):
print line
print(line)
k = indent0+tab
continue
if grep.begin_program(line):
print line
print(line)
k = indent0+tab
continue
@ -191,76 +225,76 @@ class indent(object):
if line[0] != '&':
k = indent0+tab
if grep.begin_provider(self.text[i+1].strip()):
print " "+line
print(" "+line)
else:
print line
print(line)
else:
print line
print(line)
continue
if grep.declaration(line):
print k+self.format_declaration(line,30)
print(k+self.format_declaration(line,30))
continue
if grep.begin_do(line):
print k+line
print(k+line)
k += tab
continue
if grep.begin_if(line):
print k+line
print(k+line)
k += tab
continue
if grep.xelse(line):
print k[:-tabn]+line
print(k[:-tabn]+line)
continue
if grep.begin_select(line):
print k+line
print(k+line)
k += 2*tab
continue
if grep.case(line):
print k[:-tabn]+line
print(k[:-tabn]+line)
continue
if grep.end_do(line):
k = k[:-tabn]
print k+line
print(k+line)
continue
if grep.end_if(line):
k = k[:-tabn]
print k+line
print(k+line)
continue
if grep.end_select(line):
k = k[:-2*tabn]
print k+line
print(k+line)
continue
if grep.end_subroutine(line):
print line
print(line)
k = indent0
continue
if grep.end_function(line):
print line
print(line)
k = indent0
continue
if grep.end_provider(line):
print line
print(line)
k = indent0
continue
if grep.end_program(line):
print line
print(line)
k = indent0
continue
print k+line
print(k+line)
def main():

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -29,7 +29,7 @@ from zlib import crc32
irpdir = "IRPF90_temp/"
mandir = "IRPF90_man/"
irp_id = abs(crc32(os.getcwd()))
irp_id = abs(crc32(os.getcwd().encode()))
class Line(object):
@ -391,11 +391,11 @@ def create_irpf90_files():
import os
def is_irpf90_file(filename):
return filename.endswith(".irp.f") and not filename.startswith('.')
result = filter ( is_irpf90_file, os.listdir(os.getcwd()) )
result = list(filter ( is_irpf90_file, os.listdir(os.getcwd()) ))
for dir in command_line.include_dir:
try:
os.stat(dir)
result += map(lambda x: dir+x, filter ( is_irpf90_file, os.listdir(dir) ) )
result += [dir+x for x in list(filter ( is_irpf90_file, os.listdir(dir) ))]
except:
continue
if command_line.do_codelet:

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -32,7 +32,7 @@ wd = os.path.abspath(os.path.dirname(__file__))
from irpf90_t import mandir
filename = sys.argv[1].lower()+".l"
if filename not in os.listdir(mandir):
print "%s does not exist"%(sys.argv[1])
print("%s does not exist"%(sys.argv[1]))
sys.exit(-1)
os.system("man ./"+mandir+sys.argv[1].lower()+".l")

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -34,7 +34,7 @@ FILENAME=irpdir+'irp_locks.irp.F90'
def create():
out = []
l = variables.keys()
l = list(variables.keys())
l.sort
for v in l:
var = variables[v]
@ -47,7 +47,7 @@ def create():
out += [ " call irp_lock_%s(.True.)"%v ]
out += [ " call irp_lock_%s(.False.)"%v ]
out += [ "end subroutine" ]
out = map(lambda x: "%s\n"%(x),out)
out = ["%s\n"%(x) for x in out]
if not same_file(FILENAME,out):
file = open(FILENAME,'w')
file.writelines(out)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -35,6 +35,15 @@ FILENAME = "Makefile"
FILENAME_GITIGNORE = ".gitignore"
IRPF90_MAKE = "irpf90.make"
if sys.platform in ["linux", "linux2"]:
ARCHIVE = "ar crs"
elif sys.platform == "darwin":
ARCHIVE = "libtool -static -o"
else:
print("Unknown platform. Only Linux and Darwin are supported.")
sys.exit(-1)
######################################################################
def create():
has_makefile = True
@ -47,17 +56,21 @@ def create():
file = open(FILENAME,"w")
t = """IRPF90 = irpf90 #-a -d
FC = gfortran
FCFLAGS= -O2 -ffree-line-length-none
FCFLAGS= -O2 -ffree-line-length-none -I .
NINJA = ninja
ARCHIVE= %s
RANLIB = ranlib
SRC=
OBJ=
LIB=
include %s
-include %s
export
%s: $(filter-out %s%%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile
\t$(IRPF90)
"""%(IRPF90_MAKE,IRPF90_MAKE,irpdir)
"""%(ARCHIVE,IRPF90_MAKE,IRPF90_MAKE,irpdir)
file.write(t)
file.close()
create_gitignore()
@ -77,10 +90,15 @@ def create_gitignore():
file.close()
######################################################################
def run():
def run_ninja():
import ninja
ninja.run()
######################################################################
def run_make():
from modules import modules
mod = []
for m in modules.values():
for m in list(modules.values()):
mod.append(m)
file = open(IRPF90_MAKE,'w')
@ -91,7 +109,7 @@ def run():
result += "\n"
result += "SRC += %sirp_stack.irp.F90"%(irpdir)
result += " %sirp_touches.irp.F90"%(irpdir)
result += " %sirp_checkpoint.irp.F90"%(irpdir)
# result += " %sirp_checkpoint.irp.F90"%(irpdir)
if command_line.do_openmp:
result += " %sirp_locks.irp.F90"%(irpdir)
if command_line.do_profile:
@ -99,87 +117,97 @@ def run():
for m in mod:
result += " %s%s.irp.F90"%(irpdir,m.filename)
result += " %s%s.irp.module.F90"%(irpdir,m.filename)
print >>file, result
print(result, file=file)
result = "OBJ_IRP = %sirp_stack.irp.o "%(irpdir)
for m in mod:
if not m.is_main:
result += " %s%s.irp.o"%(irpdir,m.filename)
result += " %s%s.irp.module.o"%(irpdir,m.filename)
print >>file, result
print(result, file=file)
print >>file, "OBJ1 = $(OBJ_IRP) $(OBJ) %sirp_touches.irp.o %sirp_checkpoint.irp.o"%(irpdir,irpdir),
print("OBJ1 = $(OBJ_IRP) $(OBJ) %sirp_touches.irp.o "%(irpdir), end=' ', file=file)
# print >>file, " %sirp_checkpoint.irp.o"%(irpdir),
if command_line.do_profile:
print >>file, " %sirp_profile.irp.o"%(irpdir), " irp_rdtsc.o",
print(" %sirp_profile.irp.o"%(irpdir), " irp_rdtsc.o", end=' ', file=file)
if command_line.do_codelet:
print >>file, " irp_rdtsc.o",
print(" irp_rdtsc.o", end=' ', file=file)
if command_line.do_openmp:
print >>file, " %sirp_locks.irp.o"%(irpdir)
print(" %sirp_locks.irp.o"%(irpdir), file=file)
else:
print >>file, ""
print("", file=file)
all = filter(lambda x: modules[x].is_main, modules)
all = map(lambda x: x[:-6], all)
all_o = map(lambda x: "%s.irp.module.o %s.irp.o"%(x,x), all)
print >>file, "ALL = %s"%(" ".join(all))
print >>file, "ALL_OBJ = %s"%(" ".join(all_o))
print >>file, "ALL_OBJ1 = $(patsubst %%, %s%%,$(notdir $(ALL_OBJ)))"%(irpdir)
print >>file, "all:$(ALL)"
print >>file, "\t@$(MAKE) -s move"
print >>file, "ifdef USE_IRPF90_A"
all = [x for x in modules if modules[x].is_main]
all = [x[:-6] for x in all]
all_o = ["%s.irp.module.o %s.irp.o"%(x,x) for x in all]
print("ALL = %s"%(" ".join(all)), file=file)
print("ALL_OBJ = %s"%(" ".join(all_o)), file=file)
print("ALL_OBJ1 = $(patsubst %%, %s%%,$(notdir $(ALL_OBJ)))"%(irpdir), file=file)
print("all:$(ALL)", file=file)
print("\t@$(MAKE) -s move", file=file)
# print >>file, "ifdef USE_IRPF90_A"
for m in mod:
if m.is_main:
exe = m.filename
print >>file, "%s: %s%s.irp.o %s%s.irp.module.o irpf90.a"%(exe,irpdir,exe,irpdir,exe)
print >>file, "\t$(FC) -o $@ %s$@.irp.o %s$@.irp.module.o irpf90.a $(LIB)"%(irpdir,irpdir)
print >>file, "\t@$(MAKE) -s move"
print >>file, "else"
for m in mod:
if m.is_main:
exe = m.filename
print >>file, "%s: %s%s.irp.o %s%s.irp.module.o $(OBJ1)"%(exe,irpdir,exe,irpdir,exe)
print >>file, "\t$(FC) -o $@ %s$@.irp.o %s$@.irp.module.o $(OBJ1) $(LIB)"%(irpdir,irpdir)
print >>file, "\t@$(MAKE) -s move"
print >>file, "endif"
print("%s: %s%s.irp.o %s%s.irp.module.o IRPF90_temp/irpf90.a"%(exe,irpdir,exe,irpdir,exe), file=file)
print("\t$(FC) -o $@ %s$@.irp.o %s$@.irp.module.o IRPF90_temp/irpf90.a $(LIB)"%(irpdir,irpdir), file=file)
print("\t@$(MAKE) -s move", file=file)
# print >>file, "else"
# for m in mod:
# if m.is_main:
# exe = m.filename
# print >>file, "%s: %s%s.irp.o %s%s.irp.module.o $(OBJ1)"%(exe,irpdir,exe,irpdir,exe)
# print >>file, "\t$(FC) -o $@ %s$@.irp.o %s$@.irp.module.o $(OBJ1) $(LIB)"%(irpdir,irpdir)
# print >>file, "\t@$(MAKE) -s move"
# print >>file, "endif"
buffer = ""
for m in mod:
filename = "%s%s.irp.o: $(OBJ) %s%s.irp.module.o"%(irpdir,m.filename,irpdir,m.filename)
needed_modules = filter( lambda x: modules[x].name in m.needed_modules, modules )
needed_files = map(lambda x: modules[x].filename, needed_modules)
mds = map (lambda x: " %s%s.irp.module.o"%(irpdir,x),needed_files)
print >>file, filename," ".join(mds)," ".join(m.includes)
needed_modules = [x for x in modules if modules[x].name in m.needed_modules]
needed_files = [modules[x].filename for x in needed_modules]
mds = [" %s%s.irp.module.o"%(irpdir,x) for x in needed_files]
print(filename," ".join(mds)," ".join(m.includes), file=file)
if not m.is_main:
buffer += "\t - @echo '"+filename+" ".join(mds)+"' >> %sdist_Makefile\n"%(irpdir)
print >>file, "%sirp_touches.irp.o %sirp_checkpoint.irp.o: $(OBJ) "%(irpdir,irpdir),
mds = filter(lambda x: not x.is_main,mod)
mds = map(lambda x: " %s%s.irp.o %s%s.irp.o"%(irpdir,x.filename,irpdir,x.filename),mds)
print >>file," ".join(mds)
# print >>file, "%sirp_touches.irp.o %sirp_checkpoint.irp.o: $(OBJ) "%(irpdir,irpdir),
print("%sirp_touches.irp.o: $(OBJ) "%(irpdir), end=' ', file=file)
mds = [x for x in mod if not x.is_main]
mds = [" %s%s.irp.o %s%s.irp.o"%(irpdir,x.filename,irpdir,x.filename) for x in mds]
print(" ".join(mds), file=file)
if command_line.do_profile:
print >>file, "%sirp_profile.irp.o:"%(irpdir),
print >>file," ".join(mds)
print("%sirp_profile.irp.o:"%(irpdir), end=' ', file=file)
print(" ".join(mds), file=file)
if command_line.do_openmp:
print >>file, "%sirp_locks.irp.o:"%(irpdir),
print >>file," ".join(mds)
print("%sirp_locks.irp.o:"%(irpdir), end=' ', file=file)
print(" ".join(mds), file=file)
for dir in [ irpdir ] + map(lambda x: irpdir+x, command_line.include_dir):
print >>file, dir+"%.irp.module.o: $(OBJ) "+dir+"%.irp.module.F90"
print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.module.F90 -o "+dir+"$*.irp.module.o"
print >>file, dir+"%.irp.o: $(OBJ) "+dir+"%.irp.module.o "+dir+"%.irp.F90"
print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o"
print >>file, dir+"%.irp.o: $(OBJ) "+dir+"%.irp.F90"
print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o"
print >>file, dir+"%.o: %.F90"
print >>file, "\t$(FC) $(FCFLAGS) -c $*.F90 -o "+dir+"$*.o"
print >>file, dir+"%.o: %.f90\n\t$(FC) $(FCFLAGS) -c $*.f90 -o "+dir+"$*.o"
print >>file, dir+"%.o: %.f\n\t$(FC) $(FCFLAGS) -c $*.f -o "+dir+"$*.o"
print >>file, dir+"%.o: %.F\n\t$(FC) $(FCFLAGS) -c $*.F -o "+dir+"$*.o"
print >>file, dir+"%.irp.F90: "+IRPF90_MAKE+"\n"
print >>file, "move:\n\t@mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING=\n"
print >>file, "irpf90.a: $(OBJ) $(OBJ1)\n\t$(AR) crf irpf90.a $(OBJ1)\n"
print >>file, "clean:\n\trm -rf $(EXE) $(OBJ1) irpf90.a $(ALL_OBJ1) $(ALL)\n"
print >>file, "veryclean:\n\t- $(MAKE) clean\n"
print >>file, "\t- rm -rf "+irpdir+" "+mandir+" "+IRPF90_MAKE+" irpf90_entities dist tags\n"
for dir in [ irpdir ] + [irpdir+x for x in command_line.include_dir]:
print(dir+"%.irp.module.o: $(OBJ) "+dir+"%.irp.module.F90", file=file)
print("\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.module.F90 -o "+dir+"$*.irp.module.o", file=file)
print(dir+"%.irp.o: $(OBJ) "+dir+"%.irp.module.o "+dir+"%.irp.F90", file=file)
print("\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o", file=file)
print(dir+"%.irp.o: $(OBJ) "+dir+"%.irp.F90", file=file)
print("\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o", file=file)
print(dir+"%.o: %.F90", file=file)
print("\t$(FC) $(FCFLAGS) -c $*.F90 -o "+dir+"$*.o", file=file)
print(dir+"%.o: %.f90\n\t$(FC) $(FCFLAGS) -c $*.f90 -o "+dir+"$*.o", file=file)
print(dir+"%.o: %.f\n\t$(FC) $(FCFLAGS) -c $*.f -o "+dir+"$*.o", file=file)
print(dir+"%.o: %.F\n\t$(FC) $(FCFLAGS) -c $*.F -o "+dir+"$*.o", file=file)
print(dir+"%.irp.F90: "+IRPF90_MAKE+"\n", file=file)
print("move:\n\t@mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING=\n", file=file)
print("IRPF90_temp/irpf90.a: $(OBJ) $(OBJ1)\n\t$(ARCHIVE) IRPF90_temp/irpf90.a $(OBJ1)\n", file=file)
print("clean:\n\trm -rf $(EXE) $(OBJ1) IRPF90_temp/irpf90.a $(ALL_OBJ1) $(ALL)\n", file=file)
print("veryclean:\n\t- $(MAKE) clean\n", file=file)
print("\t- rm -rf "+irpdir+" "+mandir+" "+IRPF90_MAKE+" irpf90_entities dist tags\n", file=file)
file.close()
######################################################################
def run():
if command_line.do_ninja:
run_ninja()
else:
run_make()

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -57,7 +57,7 @@ class Fmodule(object):
def prog_name(self):
if '_prog_name' not in self.__dict__:
buffer = filter(lambda x: type(x[1]) == Program,self.text)
buffer = [x for x in self.text if type(x[1]) == Program]
if buffer == []:
self._prog_name = None
else:
@ -69,7 +69,7 @@ class Fmodule(object):
if '_variables' not in self.__dict__:
from variables import variables
name = self.name
self._variables = filter(lambda x: variables[x].fmodule == name, variables)
self._variables = [x for x in variables if variables[x].fmodule == name]
return self._variables
variables = property(variables)
@ -79,7 +79,7 @@ class Fmodule(object):
result = [ "module %s"%(self.name) ]
result += self.use
result += self.dec
result += flatten( map(lambda x: variables[x].header,self.variables) )
result += flatten( [variables[x].header for x in self.variables] )
result.append( "end module %s"%(self.name) )
self._head = result
return self._head
@ -87,7 +87,7 @@ class Fmodule(object):
def needed_vars(self):
if '_needed_vars' not in self.__dict__:
result = map(lambda x: variables[x].needs,self.variables)
result = [variables[x].needs for x in self.variables]
result = make_single ( flatten(result) )
self._needed_vars = result
return self._needed_vars
@ -140,7 +140,7 @@ class Fmodule(object):
if type(line) in [ Subroutine, Function ]:
variable_list = list(vars)
elif type(line) == End:
result += map(lambda x: ([],Use(line.i,x,line.filename)), build_use(variable_list))
result += [([],Use(line.i,x,line.filename)) for x in build_use(variable_list)]
else:
variable_list += vars
result.append( (vars,line) )
@ -169,21 +169,21 @@ class Fmodule(object):
result = []
for vars,line in text:
result.append( ([],line) )
result += map(lambda x: ([],Simple_line(line.i,x,line.filename)), call_provides(vars))
result += [([],Simple_line(line.i,x,line.filename)) for x in call_provides(vars)]
return result
result = remove_providers(self.text)
result = modify_functions(result)
use,dec,result = extract_use_dec_text(result)
self._use = make_single(map(lambda x: " "+x[1].text, use))
self._dec = map(lambda x: " "+x[1].text, dec)
self._use = make_single([" "+x[1].text for x in use])
self._dec = [" "+x[1].text for x in dec]
# self._dec = make_single(map(lambda x: " "+x[1].text, dec))
result = provide_variables(result)
result = move_to_top(result,Declaration)
result = move_to_top(result,Implicit)
result = move_to_top(result,Use)
result = map(lambda x: x[1], result)
result = map(lambda x: x.text, result)
result = [x[1] for x in result]
result = [x.text for x in result]
self._residual_text = result
return self._residual_text
residual_text = property(residual_text)
@ -203,10 +203,9 @@ class Fmodule(object):
def needed_modules(self):
if '_needed_modules' not in self.__dict__:
buffer = filter(lambda x: x.lstrip().startswith("use "), \
self.generated_text+self.head+self.residual_text)
buffer = map(lambda x: x.split()[1], buffer)
buffer = filter(lambda x: x.endswith("_mod"),buffer )
buffer = [x for x in self.generated_text+self.head+self.residual_text if x.lstrip().startswith("use ")]
buffer = [x.split()[1] for x in buffer]
buffer = [x for x in buffer if x.endswith("_mod")]
self._needed_modules = make_single(buffer)
if self.name in self._needed_modules:
self._needed_modules.remove(self.name)
@ -222,6 +221,6 @@ if __name__ == '__main__':
x = Fmodule(text,filename)
break
for line in x.head:
print line
print x.includes
print(line)
print(x.includes)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -44,9 +44,9 @@ def write_module(m):
# Module data
filename = irpdir+m.filename+".irp.module.F90"
text = m.header + m.head
text = map(lambda x: "%s\n"%(x),text)
text = ["%s\n"%(x) for x in text]
if not same_file(filename,text):
print filename
# print filename
file = open(filename,"w")
file.writelines(text)
file.close()
@ -54,9 +54,9 @@ def write_module(m):
# Subroutines
filename = irpdir+m.filename+".irp.F90"
text = m.header + m.generated_text + m.residual_text
text = map(lambda x: "%s\n"%(x),text)
text = ["%s\n"%(x) for x in text]
if not same_file(filename,text):
print filename
# print filename
file = open(filename,"w")
file.writelines(text)
file.close()

421
src/ninja.py Normal file
View File

@ -0,0 +1,421 @@
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
#
# 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 irpf90_t
from command_line import command_line
from modules import modules
irpdir = irpf90_t.irpdir
mandir = irpf90_t.mandir
irp_id = irpf90_t.irp_id
FILENAME = os.path.join(irpdir,"build.ninja")
cwd = os.getcwd()
PRINT_WIDTH=50
if sys.platform in ["linux", "linux2"]:
AR = "ar crs"
elif sys.platform == "darwin":
AR = "libtool -static -o"
else:
print("Unknown platform. Only Linux and Darwin are supported.")
sys.exit(-1)
def dress(f,in_root=False):
"""
Transfoms the filename f into $PWD/IRPF90_temp/f
"""
if in_root:
result = os.path.join(cwd,f)
else:
result = os.path.join(cwd,irpdir,f)
result = os.path.normpath(result)
return result
def create_build_touches(list_of_other_o):
"""
Create the build command for the irp_touches.o file and the irpf90.a library.
"""
name = "irp_touches"
short_lib = "irpf90.a"
short_target_o = "%s.irp.o"%name
short_target_F90 = "%s.irp.F90"%name
lib = dress(short_lib)
target_o = dress(short_target_o)
target_F90 = dress(short_target_F90)
needed_modules = [ "%s.irp.module.o"%(modules[x].filename) for x in modules ]
list_of_modules = list(map(dress, needed_modules)) + list_of_other_o
list_of_modules = ' '.join(list_of_modules)
result = '\n'.join(
[
"build {target_o}: compile_touches_{id} {target_F90} | {list_of_modules}",
" short_in = {short_target_F90}",
" short_out = {short_target_o}",
"",
"build {lib}: link_lib_{id} {target_o} {list_of_modules}",
" short_out = {short_lib}",
"",
] )
result = result.format(
id = irp_id ,
lib = lib ,
list_of_modules = list_of_modules ,
short_lib = short_lib ,
short_target_F90 = os.path.split(target_F90)[1] ,
short_target_o = os.path.split(target_o)[1] ,
target_F90 = target_F90 ,
target_o = target_o
)
return result
def create_build_target(t,list_of_other_o):
"""
Create the build command for the target module t. t is a Fmodule object.
"""
name = t.filename
irp_lib = dress("irpf90.a")
target = dress(name,in_root=True)
short_target_o = "%s.irp.o"%name
short_target_F90 = "%s.irp.F90"%name
short_target_module_F90 = "%s.irp.module.F90"%name
short_target_module_o = "%s.irp.module.o"%name
target_o = dress(short_target_o)
target_F90 = dress(short_target_F90)
target_module_o = dress(short_target_module_o)
target_module_F90 = dress(short_target_module_F90)
needed_modules = [ "%s.irp.module.o"%(modules[x].filename) for x in modules \
if modules[x].name in t.needed_modules ] + [ target_module_o ]
list_of_o = [ target_o, target_module_o, irp_lib ]
list_of_o = ' '.join(list_of_o)
list_of_modules = list(map(dress, needed_modules)) + list_of_other_o
list_of_modules = ' '.join(list_of_modules)
list_of_includes = ' '.join([dress(x,in_root=True) for x in t.includes])
result = '\n'.join(
[ "build {target}: link_{id} {list_of_o}",
" short_out = {short_target}",
"",
"build {target_o}: compile_fortran_{id} {target_F90} | {list_of_modules} {list_of_includes}",
" short_in = {short_target_F90}",
" short_out = {short_target_o}",
"",
"build {target_module_o}: compile_fortran_{id} {target_module_F90}",
" short_in = {short_target_module_F90}",
" short_out = {short_target_module_o}",
"",
] )
result = result.format(
id = irp_id ,
list_of_includes = list_of_includes ,
list_of_modules = list_of_modules ,
list_of_o = list_of_o ,
short_target_F90 = os.path.split(target_F90)[1] ,
short_target_module_F90 = os.path.split(target_module_F90)[1] ,
short_target_module_o = os.path.split(target_module_o)[1] ,
short_target = name ,
short_target_o = os.path.split(target_o)[1] ,
target_F90 = target_F90 ,
target_module_F90 = target_module_F90 ,
target_module_o = target_module_o ,
target_o = target_o ,
target = target
)
return result
def create_build_non_target(t,list_of_other_o):
"""
Create the build command for the non-target module t. t is a Fmodule object.
"""
name = t.filename
target = dress(name,in_root=True)
short_target_o = "%s.irp.o"%name
short_target_F90 = "%s.irp.F90"%name
short_target_module_F90 = "%s.irp.module.F90"%name
short_target_module_o = "%s.irp.module.o"%name
target_o = dress(short_target_o)
target_F90 = dress(short_target_F90)
target_module_o = dress(short_target_module_o)
target_module_F90 = dress(short_target_module_F90)
needed_modules = [ "%s.irp.module.o"%(modules[x].filename) for x in modules \
if modules[x].name in t.needed_modules ] + [ target_module_o ]
list_of_modules = list(map(dress, needed_modules))
list_of_modules = ' '.join(list_of_modules)
list_of_externals = ' '.join([ dress(x,in_root=True) for x in list_of_other_o ])
list_of_includes = ' '.join([dress(x,in_root=True) for x in t.includes])
result = '\n'.join(
[
"build {target_o}: compile_fortran_{id} {target_F90} | {list_of_modules} {list_of_externals}",
" short_in = {short_target_F90}",
" short_out = {short_target}",
"",
"build {target_module_o}: compile_fortran_{id} {target_module_F90} | {list_of_externals} {list_of_includes}",
" short_in = {short_target_F90}",
" short_out = {short_target_o}",
"",
] )
result = result.format(
id = irp_id ,
list_of_externals = list_of_externals ,
list_of_includes = list_of_includes ,
list_of_modules = list_of_modules ,
short_target_F90 = os.path.split(target_F90)[1] ,
short_target = name ,
short_target_o = os.path.split(target_o)[1] ,
target_F90 = target_F90 ,
target_module_F90 = target_module_F90 ,
target_module_o = target_module_o ,
target_o = target_o
)
return result
def create_build_remaining(f):
"""
Create the build command for the remaining file f. f is a file name (str).
"""
t, extension = f.rsplit('.',1)
t1 = dress(t,in_root=True)
t2 = dress(t,in_root=False)
target_i = f
target_o = "%s.o"%t
if not target_o.startswith(os.path.join(cwd,irpdir)):
target_o = target_o.replace(cwd,os.path.join(cwd,irpdir))
if extension.lower() in [ 'f', 'f90' ]:
result = [ "build {target_o}: compile_fortran_{id} {target_i}" ]
elif extension.lower() in [ 'c' ]:
result = [ "build {target_o}: compile_c_{id} {target_i}" ]
elif extension.lower() in [ 'cxx', 'cpp' ]:
result = [ "build {target_o}: compile_cxx_{id} {target_i}" ]
result += [ " short_in = {short_target_i}",
" short_out = {short_target_o}", "" ]
result = '\n'.join(result).format(
target_o = target_o,
target_i = target_i,
short_target_o = os.path.split(target_o)[1],
short_target_i = os.path.split(target_i)[1],
id = irp_id
)
return result
def create_irpf90_make(targets):
targets = ' '.join(targets)
result = """NINJA += -C {0}
TARGETS={1}
.PHONY: all clean veryclean
all:
$(NINJA)
$(TARGETS):
$(NINJA) $(PWD)/$@
clean:
$(NINJA) -t clean
veryclean: clean
rm -rf IRPF90_temp/ IRPF90_man/ irpf90.make irpf90_entities dist tags
""".format(irpdir, targets)
import makefile
with open(makefile.IRPF90_MAKE,'w') as file:
file.write(result)
def run():
output = [ "builddir = %s"%os.path.join(cwd,irpdir) ]
# Environment variables
try: FC = os.environ["FC"]
except KeyError: FC="gfortran -ffree-line-length-none"
try: ARCHIVE = os.environ["ARCHIVE"]
except KeyError: ARCHIVE=AR
try: CC = os.environ["CC"]
except KeyError: CC="gcc"
try: CXX = os.environ["CXX"]
except KeyError: CXX="g++"
includes = [ "-I %s"%(i) for i in command_line.include_dir ]
FC += " "+' '.join(includes)
CC += " "+' '.join(includes)
CXX += " "+' '.join(includes)
try: SRC = os.environ["SRC"].split()
except KeyError: SRC=[]
try: OBJ = os.environ["OBJ"].split()
except KeyError: OBJ=[]
try: LIB = os.environ["LIB"].split()
except KeyError: LIB=[]
try: FCFLAGS = os.environ["FCFLAGS"].split()
except KeyError: FCFLAGS = [ "-O2" ]
try: CFLAGS = os.environ["CFLAGS"].split()
except KeyError: CFLAGS = [ "-O2" ]
try: CXXFLAGS = os.environ["CXXFLAGS"].split()
except KeyError: CXXFLAGS = [ "-O2" ]
FCFLAGS = ' '.join(FCFLAGS)
CFLAGS = ' '.join(CFLAGS)
CXXFLAGS = ' '.join(CXXFLAGS)
LIB = ' '.join(LIB)
# Rules
t = [ "rule compile_fortran_{id}",
" command = {FC} {FCFLAGS} -c $in -o $out",
" description = F : $short_in -> $short_out",
"",
"rule compile_touches_{id}",
" command = {FC} -c $in -o $out",
" description = F : $short_in -> $short_out",
"",
"",
"rule compile_c_{id}" ,
" command = {CC} {CFLAGS} -c $in -o $out",
" description = C : $short_in -> $short_out",
"",
"rule compile_cxx_{id}",
" command = {CXX} {CXXFLAGS} -c $in -o $out",
" description = C++ : $short_in -> $short_out",
"",
"rule link_lib_{id}",
" command = {ARCHIVE} $out $in" ,
" description = Link: $short_out",
"",
"rule link_{id}",
" command = {FC} $in {LIB} -o $out" ,
" description = Link: $short_out"]
output += [ '\n'.join(t).format(id=irp_id, FC=FC, FCFLAGS=FCFLAGS, LIB=LIB, CXX=CXX, CXXFLAGS=CXXFLAGS, CC=CC, CFLAGS=CFLAGS, ARCHIVE=ARCHIVE) ]
# All modules : list of Fmodule objects
l_mod = list( modules.values() )
# Modules that are not targets
l_non_targets = [ x for x in l_mod if not x.is_main ]
# Common object/source files
l_common_o = [ "irp_touches.irp.o" ] + \
[ "{0}.irp.o".format(x.filename) for x in l_non_targets ] + \
[ "{0}.irp.module.o".format(x.filename) for x in l_non_targets ]
l_common_s = []
if command_line.do_debug:
l_common_o += [ "irp_stack.irp.o" ]
l_common_s += [ "irp_stack.irp.F90" ]
if command_line.do_openmp:
l_common_o += [ "irp_locks.irp.o" ]
l_common_s += [ "irp_locks.irp.F90" ]
if command_line.do_profile:
l_common_o += [ "irp_profile.irp.o", "irp_rdtsc.o" ]
l_common_s += [ "irp_profile.irp.F90", "irp_rdtsc.c" ]
l_common_o = list(map(dress,l_common_o)) + [dress(x,in_root=True) for x in OBJ]
l_common_s = list(map(dress,l_common_s)) + [dress(x,in_root=True) for x in SRC]
# IRP_touches
output.append(create_build_touches(l_common_o[1:]))
# All targets : list of Fmodule objects
l_targets = [ x for x in l_mod if x.is_main ]
# Create lines
for i in l_non_targets:
output.append (create_build_non_target(i,OBJ))
for i in l_targets:
output.append(create_build_target(i, l_common_o))
# Remaining files
for i in l_common_s:
output.append(create_build_remaining(i))
text = '\n\n'.join(output)
text = text.replace(cwd+"/IRPF90_temp","$T")
text = text.replace(cwd,"$X")
with open(FILENAME,'w') as f:
f.write("X="+cwd+"\nT="+cwd+"/IRPF90_temp\n")
f.write(text)
f.write('\n')
create_irpf90_make([ x.filename for x in l_targets ] + [ os.path.join(irpdir,'irpf90.a') ] )
return

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -33,9 +33,9 @@ from subroutines import subroutines
import regexps, re
import error
vtuple = map(lambda v: (v, variables[v].same_as, variables[v].regexp), variables.keys())
stuple = map(lambda s: (s, subroutines[s].regexp), subroutines.keys())
stuple = filter(lambda s: subroutines[s[0]].is_function, stuple)
vtuple = [(v, variables[v].same_as, variables[v].regexp) for v in list(variables.keys())]
stuple = [(s, subroutines[s].regexp) for s in list(subroutines.keys())]
stuple = [s for s in stuple if subroutines[s[0]].is_function]
re_string_sub = regexps.re_string.sub
regexps_re_string_sub = regexps.re_string.sub
@ -79,20 +79,20 @@ def check_touch(line,vars,main_vars):
error.fail(line,"Variable %s unknown"%(main_var,))
x = variables[main_var]
return [main_var]+x.others
all_others = make_single(flatten( map(fun,main_vars) ))
all_others = make_single(flatten( list(map(fun,main_vars)) ))
all_others.sort()
vars.sort()
for x,y in zip(vars,all_others):
if x != y:
message = "The following entities should be touched:\n"
message = "\n".join([message]+map(lambda x: "- %s"%(x,),all_others))
message = "\n".join([message]+["- %s"%(x,) for x in all_others])
error.fail(line,message)
################################################################################
def update_variables():
for filename,text in preprocessed_text:
for line in filter(lambda x: type(x) in [ Touch, SoftTouch ], text):
for line in [x for x in text if type(x) in [ Touch, SoftTouch ]]:
vars = line.lower.split()
if len(vars) < 2:
error.fail(line,"Syntax error")
@ -101,7 +101,7 @@ def update_variables():
error.fail(line,"Variable %s unknown"%(v,))
variables[v]._is_touched = True
for line in filter(lambda x: type(x) == Free,text):
for line in [x for x in text if type(x) == Free]:
vars = line.lower.split()
if len(vars) < 2:
error.fail(line,"Syntax error")
@ -110,10 +110,10 @@ def update_variables():
error.fail(line,"Variable %s unknown"%(v,))
variables[v].is_freed = True
for line in filter(lambda x: type(x) == Irp_read,text):
for line in [x for x in text if type(x) == Irp_read]:
variables[line.filename]._is_read = True
for line in filter(lambda x: type (x) == Irp_write,text):
for line in [x for x in text if type (x) == Irp_write]:
variables[line.filename]._is_written = True
################################################################################
@ -148,7 +148,7 @@ def get_parsed_text():
elif type(line) in [ Begin_provider, Cont_provider ]:
if type(line) == Begin_provider:
varlist = []
buffer = map(strip,line.lower.replace(']','').split(','))
buffer = list(map(strip,line.lower.replace(']','').split(',')))
assert len(buffer) > 1
v = buffer[1]
varlist.append(v)
@ -156,7 +156,7 @@ def get_parsed_text():
try:
variable_list.remove(variables[v].same_as)
except ValueError:
print v, variables[v].same_as
print(v, variables[v].same_as)
raise
append( (variable_list,line) )
elif type(line) == End_provider:
@ -164,7 +164,7 @@ def get_parsed_text():
append( ([],line) )
elif type(line) == Provide:
l = line.lower.split()[1:]
l = filter(lambda x: x not in varlist, l)
l = [x for x in l if x not in varlist]
for v in l:
if v not in variables:
error.fail(line,"Variable %s is unknown"%(v))
@ -175,7 +175,7 @@ def get_parsed_text():
for v in l:
if v not in variables:
error.fail(line,"Variable %s is unknown"%(v))
l = map(lambda x: "-%s"%(x), l)
l = ["-%s"%(x) for x in l]
append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) )
elif type(line) in [ Touch, SoftTouch ]:
vars = line.lower.split()
@ -185,7 +185,7 @@ def get_parsed_text():
def fun(x):
main = variables[x].same_as
return main
main_vars = make_single( map(fun, vars) )
main_vars = make_single( list(map(fun, vars)) )
check_touch(line,vars,main_vars)
txt = " ".join(vars)
append ( (vars,Simple_line(line.i,"!",line.filename)) )
@ -195,19 +195,19 @@ def get_parsed_text():
error.fail(line,"Variable %s unknown"%(x,))
return [ ([],Simple_line(line.i," call touch_%s"%(x,),line.filename)),
([],Use(line.i," use %s"%(variables[x].fmodule), line.filename)) ]
result += flatten(map( fun, main_vars ))
result += flatten(list(map( fun, main_vars )))
def fun(x):
if x not in variables:
error.fail(line,"Variable %s unknown"%(x,))
return ([],Simple_line(line.i," %s_is_built = .True."%(x,),line.filename))
result += map( fun, main_vars[:-1] )
result += list(map( fun, main_vars[:-1] ))
if type(line) == SoftTouch:
append ( ([],Simple_line(line.i,"! <<< END TOUCH (Soft)",line.filename)) )
else:
append ( ([],Provide_all(line.i,"! <<< END TOUCH",line.filename)) )
elif type(line) == Call:
l = find_variables_in_line(line)
l = filter(lambda x: x not in varlist, l)
l = [x for x in l if x not in varlist]
sub = find_subroutine_in_line(line)
if sub not in subroutines:
t = Simple_line
@ -220,12 +220,10 @@ def get_parsed_text():
vars = line.lower.split()
vars = vars[1:]
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
use = map(lambda x: " use %s"%(variables[x].fmodule),vars)
use = [" use %s"%(variables[x].fmodule) for x in vars]
for var in vars:
result += map(lambda x: ([],Use(line.i,x,line.filename)),
make_single(use))
result += map(lambda x: ([],Simple_line(line.i,x,line.filename)),
variables[var].free)
result += [([],Use(line.i,x,line.filename)) for x in make_single(use)]
result += [([],Simple_line(line.i,x,line.filename)) for x in variables[var].free]
elif type(line) == Irp_read:
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
elif type(line) == Irp_write:
@ -234,14 +232,14 @@ def get_parsed_text():
pass
else:
l = find_variables_in_line(line)
l = filter(lambda x: x not in varlist, l)
l = [x for x in l if x not in varlist]
append( (l,line) )
return result
#main_result = []
#for filename,text in preprocessed_text:
# main_result.append( (filename, func(filename,text)) )
#return main_result
# Remove duplicates
global preprocessed_text
d = dict(preprocessed_text)
preprocessed_text = [ (k,d[k]) for k in d.keys() ]
return parallel_loop(func,preprocessed_text)
update_variables()
@ -365,7 +363,7 @@ def move_variables():
elif type(line) in [ If, Select ]:
ifvars += list(varlist)
append( (varlist,line) )
vars += filter(lambda x: x in elsevars, ifvars)
vars += [x for x in ifvars if x in elsevars]
ifvars = old_ifvars.pop()
elsevars = old_elsevars.pop()
varlist = old_varlist.pop() + vars
@ -401,13 +399,13 @@ def move_variables():
varlist = list(vars)
elif type(line) in [ If, Select ]:
old_varlist.append(varlist)
vars = filter(lambda x: x not in varlist,vars)
vars = [x for x in vars if x not in varlist]
varlist = make_single(varlist + vars)
assert old_varlist is not varlist
elif type(line) in [ Elseif, Else, Case ]:
varlist = old_varlist.pop()
old_varlist.append(varlist)
vars = filter(lambda x: x not in varlist,vars)
vars = [x for x in vars if x not in varlist]
varlist = make_single(varlist + vars)
assert old_varlist is not varlist
elif type(line) in [ Endif, End_select ]:
@ -426,11 +424,11 @@ def move_variables():
error.fail(line,"Unable to parse file")
return result
main_result = []
for filename,text in parsed_text:
main_result.append( (filename, func(filename,text)) )
return main_result
#return parallel_loop(func,parsed_text)
# main_result = []
# for filename,text in parsed_text:
# main_result.append( (filename, func(filename,text)) )
# return main_result
return parallel_loop(func,parsed_text)
parsed_text = move_variables()
@ -441,7 +439,7 @@ def build_needs():
var = None
for vars,line in text:
if type(line) == Begin_provider:
buffer = map(strip,line.lower.replace(']',',').split(','))
buffer = list(map(strip,line.lower.replace(']',',').split(',')))
var = variables[buffer[1]]
var.needs = []
var.to_provide = vars
@ -510,9 +508,9 @@ def check_opt():
for vars,line in text:
if not type(line) == Provide_all:
if do_level > 0 and vars != []:
print "Optimization: %s line %d"%(line.filename,line.i)
print("Optimization: %s line %d"%(line.filename,line.i))
for v in vars:
print " PROVIDE ",v
print(" PROVIDE ",v)
if type(line) == Do:
do_level += 1
elif type(line) == Enddo:
@ -527,7 +525,7 @@ def perform_loop_substitutions():
append = result.append
for vars,line in text:
if type(line) in [ Do, If, Elseif ] :
for k,v in command_line.substituted.items():
for k,v in list(command_line.substituted.items()):
reg = v[1]
while reg.search(line.text) is not None:
line.text = re.sub(reg,r'\1%s\3', line.text,count=1)%v[0]
@ -541,9 +539,9 @@ parsed_text = perform_loop_substitutions()
if __name__ == '__main__':
for i in range(len(parsed_text)):
if parsed_text[i][0] == sys.argv[1]:
print '!-------- %s -----------'%(parsed_text[i][0])
print('!-------- %s -----------'%(parsed_text[i][0]))
for line in parsed_text[i][1]:
print line[1]
print line[0], line[1].filename
print(line[1])
print(line[0], line[1].filename)
#for i in subroutines:
# print i, subroutines[i].needs, subroutines[i].to_provide

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -46,7 +46,6 @@ Fixed_form = 1
######################################################################
# Dictionary of simple statements
simple_dict = {
"program": Program ,
"subroutine": Subroutine ,
"begin_shell": Begin_shell ,
"end_shell": End_shell ,
@ -140,6 +139,9 @@ def get_type (i, filename, line, is_doc):
if firstword == "begin_doc":
return [ Begin_doc (i,line,filename) ], True
if firstword == "program":
return [ Program (i,line,filename) ], False
if is_doc:
return [ Doc (i,line,filename) ], is_doc
@ -261,7 +263,7 @@ def execute_templates(text):
fail(line,"Subst","Syntax error")
buffer = buffer[1].replace(']','')
buffer = buffer.split(',')
return map(lambda x: '$%s'%(x.strip()), buffer)
return ['$%s'%(x.strip()) for x in buffer]
TEMPLATE = 1
SUBST = 2
@ -299,7 +301,7 @@ def execute_templates(text):
if subst[-2:] == ';;':
subst = subst[:-2]
for s in subst.split(';;'):
buffer = map(lambda x: x.strip(), s.split(';'))
buffer = [x.strip() for x in s.split(';')]
if len(buffer) != len(variables):
fail(line,"subst","%d variables defined, and %d substitutions"%(len(variables),len(buffer)))
script += "v.append( { \\\n"
@ -309,7 +311,7 @@ def execute_templates(text):
script += "for d in v:\n t0 = str(template)\n"
for v in variables:
script += " t0 = t0.replace('%s',d['%s'])\n"%(v,v)
script += " print t0\n"
script += " print(t0)\n"
# Write script file
scriptname = "%s%s_template_%d"%(irpdir,line.filename,line.i)
file = open(scriptname,'w')
@ -321,7 +323,7 @@ def execute_templates(text):
file.close()
# Execute shell
import os
pipe = os.popen("python < %s"%(scriptname),'r')
pipe = os.popen("python3 < %s"%(scriptname),'r')
lines = pipe.readlines()
pipe.close()
result += get_text(lines,scriptname)
@ -359,23 +361,35 @@ def form(text):
######################################################################
def add_operators(text):
re_incr = re.compile(r"(\s*)(.*)(\+=)(.*$)",re.S)
re_decr = re.compile(r"(\s*)(.*)(-=)(.*$)",re.S)
re_mult = re.compile(r"(\s*)(.*)(\*=)(.*$)",re.S)
re_incr = re.compile(r"(\s*)(.*)(\+=)(.*$)", re.S)
re_decr = re.compile(r"(\s*)(.*)(-=)(.*$)", re.S)
re_mult = re.compile(r"(\s*)(.*)(\*=)(.*$)", re.S)
re_incr_if = re.compile(r"(.*)(\))(\s*)(.*)(\+=)(.*$)", re.S)
re_decr_if = re.compile(r"(.*)(\))(\s*)(.*)(-=)(.*$)", re.S)
re_mult_if = re.compile(r"(.*)(\))(\s*)(.*)(\*=)(.*$)", re.S)
'''Change additional operators'''
result = []
for line in text:
buffer = line.text
if "+=" in buffer:
if buffer.lstrip().startswith("if "):
re_incr = re.compile(r"(.*)(\))(\s*)(.*)(\+=)(.*$)",re.S)
line.text = re.sub(re_incr,r'\1\2\4=\4+(\6)', buffer)
else:
line.text = re.sub(re_incr,r'\1\2=\2+(\4)', buffer)
elif "-=" in buffer:
line.text = re.sub(re_decr,r'\1\2=\2-(\4)', buffer)
elif "*=" in buffer:
line.text = re.sub(re_mult,r'\1\2=\2*(\4)', buffer)
ls = buffer.strip()
if ls.startswith('print ') or \
ls.startswith('print*') or \
ls.startswith('write('):
pass
elif buffer.lstrip().startswith("if "):
if "+=" in buffer:
line.text = re.sub(re_incr_if, r'\1\2\4=\4+(\6)', buffer)
elif "-=" in buffer:
line.text = re.sub(re_incr_if, r'\1\2\4=\4-(\6)', buffer)
elif "*=" in buffer:
line.text = re.sub(re_incr_if, r'\1\2\4=\4*(\6)', buffer)
else:
if "+=" in buffer:
line.text = re.sub(re_incr, r'\1\2=\2+(\4)', buffer)
elif "-=" in buffer:
line.text = re.sub(re_decr, r'\1\2=\2-(\4)', buffer)
elif "*=" in buffer:
line.text = re.sub(re_mult, r'\1\2=\2*(\4)', buffer)
result.append(line)
return result
@ -499,7 +513,7 @@ def irp_simple_statements(text):
def process_return(line):
assert type(line) == Return
if command_line.do_assert or command_line.do_debug:
if command_line.do_debug:
newline = Simple_line(line.i," call irp_leave(irp_here)",line.filename)
result = [newline, line]
else:
@ -514,7 +528,11 @@ def irp_simple_statements(text):
if match is not None:
matches = [ match.group(1).strip(), match.group(3).strip() ]
for m in matches:
if not(m.isdigit() or ("'" in m) or (m == "")):
ok = m != "" # not empty
ok = ok and not m.isdigit() # not a digit
ok = ok and "'" not in m # not a string
ok = ok and m.count('(') == m.count(')') # balanced parenthesis
if ok:
result.append ( Simple_line (line.i, " print *, '%s = ', %s"%(m,m), line.filename) )
result.append ( Simple_line (line.i, " print *, ''", line.filename) )
return result
@ -535,7 +553,6 @@ def irp_simple_statements(text):
Empty_line(i, "!", f),
Empty_line(i, "! >>> %s"%(txt,), f),
If (i, " if (.not.%s) then"%(condition,), f),
Simple_line(i, " call irp_trace", f),
Simple_line(i, " print *, irp_here//': Assert failed:'", f),
Simple_line(i, " print *, ' file: %s, line: %d'"%(f,i), f),
Simple_line(i, " print *, '%s'"%(condition_str,), f),
@ -552,7 +569,7 @@ def irp_simple_statements(text):
def process_end(line):
'''Set irp_here variable in provider block'''
line.text = "end"
if command_line.do_assert or command_line.do_debug:
if command_line.do_debug:
i = line.i
f = line.filename
result = [
@ -576,7 +593,7 @@ def irp_simple_statements(text):
f = line.filename
result = [ Begin_provider(i,line.text, (f,varname)),
Declaration(i," character*(%d) :: irp_here = '%s'"%(length,varname), f) ]
if command_line.do_assert or command_line.do_debug:
if command_line.do_debug:
result += [
Simple_line(i," call irp_enter(irp_here)", f),
]
@ -602,7 +619,7 @@ def irp_simple_statements(text):
f = line.filename
result = [ line,
Declaration(i," character*(%d) :: irp_here = '%s'"%(length,subname), f) ]
if command_line.do_assert or command_line.do_debug:
if command_line.do_debug:
result += [
Simple_line(i," call irp_enter_f(irp_here)", f),
]
@ -616,7 +633,7 @@ def irp_simple_statements(text):
f = line.filename
result = [ line,
Declaration(i," character*(%d) :: irp_here = '%s'"%(length,subname), f) ]
if command_line.do_assert or command_line.do_debug:
if command_line.do_debug:
result += [
Simple_line(i," call irp_enter_f(irp_here)", f),
]
@ -672,7 +689,7 @@ def change_includes(text):
if type(line) == Include:
txt = line.text.replace('"',"'").split("'")
if len(txt) != 3:
print txt
print(txt)
error.fail(line,"Error in include statement")
directory = (("./"+line.filename).rsplit('/',1)[0]+'/')[2:]
if directory == "":
@ -776,7 +793,7 @@ def check_begin_end(text):
filter_line = lambda line: type(line) in [ Do, Enddo, If, Endif, \
Program, Begin_provider, End_provider, \
Subroutine, Function, End, Begin_doc, End_doc ]
text = filter(filter_line, text)
text = list(filter(filter_line, text))
d = { 'do' : Do, 'enddo': Enddo,
'if' : If, 'endif': Endif,
@ -894,16 +911,16 @@ def create_preprocessed_text(filename):
######################################################################
preprocessed_text = parallel_loop( lambda x,y: create_preprocessed_text(x), \
map(lambda x: (x,None), irpf90_files ) )
[(x,None) for x in irpf90_files] )
######################################################################
def debug():
for filename, txt in preprocessed_text:
if filename == 'invert.irp.f':
print "=== "+filename+" ==="
print("=== "+filename+" ===")
for line in txt:
print line
print irpf90_files
print(line)
print(irpf90_files)
if __name__ == '__main__':
debug()

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -45,10 +45,10 @@ import subprocess
import tempfile
import os
import threading
from irpf90_t import irpdir
def build_rdtsc():
file,filename = tempfile.mkstemp()
filename += ".c"
filename = irpdir+"irp_rdtsc.c"
file = open(filename,'w')
file.write(rdtsc)
file.close()
@ -104,11 +104,10 @@ subroutine irp_init_timer
double precision :: irp_rdtsc, t0
irp_profile = 0.d0
irp_rdtsc_shift = 0.d0
do i=1,1000
do i=1,1000000
t0 = irp_rdtsc()
irp_rdtsc_shift = irp_rdtsc_shift + (irp_rdtsc()-t0)
enddo
irp_rdtsc_shift = 1.d-3*irp_rdtsc_shift
irp_rdtsc_shift = 1.d-6*(irp_rdtsc()-t0)
%(text)s
end

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -46,12 +46,13 @@ re_decl = re.compile( "".join( [ r"^\ *",
r"|intrinsic *(::)?",
r"|external *(::)?",
r"|equivalence *(::)?",
r"|type",
r"|type *\(",
r"|type +",
r"|end ?type",
r")[^=(]"
] ) )
re_test = re.compile(r"\( *(.*)(\.[a-zA-Z]*\.|[<>]=?|[=/]=)([^=]*)\)")
re_string = re.compile(r"'.*?'")
re_string = re.compile(r"'.*?'|\".*?\"")

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -58,8 +58,8 @@ class Sub(object):
def doc(self):
if '_doc' not in self.__dict__:
def f(l): return
buffer = filter(lambda l:type(l) == Doc, self.text)
self._doc = map(lambda l: l.text.lstrip()[1:], buffer)
buffer = [l for l in self.text if type(l) == Doc]
self._doc = [l.text.lstrip()[1:] for l in buffer]
if buffer == []:
error.warn(None,"Subroutine %s is not documented"%(self.name))
return self._doc
@ -77,7 +77,7 @@ class Sub(object):
if '_touches' not in self.__dict__:
from subroutines import subroutines
self._touches = []
for line in filter(lambda x: type(x) in [Touch, SoftTouch],self.text):
for line in [x for x in self.text if type(x) in [Touch, SoftTouch]]:
self._touches += line.text.split()[1:]
for sub in self.calls:
if sub in subroutines:
@ -113,7 +113,7 @@ class Sub(object):
############################################################
def calls(self):
if '_calls' not in self.__dict__:
buffer = filter(lambda x: type(x) == Call,self.text)
buffer = [x for x in self.text if type(x) == Call]
self._calls = []
for line in buffer:
sub = line.text.split('(',1)[0].split()[1].lower()
@ -127,5 +127,5 @@ if __name__ == '__main__':
from preprocessed_text import preprocessed_text
from variables import variables
from subroutines import subroutines
print map(lambda x: variables[x].needs, subroutines['full_ci'].needs)
print subroutines['full_ci'].calls
print([variables[x].needs for x in subroutines['full_ci'].needs])
print(subroutines['full_ci'].calls)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -51,7 +51,7 @@ def create_subroutines():
return result
def create_called_by(subs,vars):
for s in subs.values() + vars.values():
for s in list(subs.values()) + list(vars.values()):
if type(s) == Variable and s.same_as != s.name:
continue
for x in s.calls:
@ -60,7 +60,7 @@ def create_called_by(subs,vars):
except KeyError:
pass
for s in subs.values():
for s in list(subs.values()):
s.called_by = make_single(s.called_by)
s.called_by.sort()
@ -68,5 +68,5 @@ subroutines = create_subroutines()
create_called_by(subroutines,variables)
if __name__ == '__main__':
for v in subroutines.keys():
print v
for v in list(subroutines.keys()):
print(v)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -34,11 +34,11 @@ FILENAME=irpdir+'irp_touches.irp.F90'
def create():
out = []
l = variables.keys()
l = list(variables.keys())
l.sort
main_modules = filter(lambda x: modules[x].is_main, modules)
main_modules = [x for x in modules if modules[x].is_main]
finalize = "subroutine irp_finalize_%s\n"%(irp_id)
for m in filter(lambda x: not modules[x].is_main, modules):
for m in [x for x in modules if not modules[x].is_main]:
finalize += " use %s\n"%(modules[m].name)
for v in l:
var = variables[v]
@ -59,7 +59,7 @@ def create():
if out != []:
out = map(lambda x: "%s\n"%(x),out)
out = ["%s\n"%(x) for x in out]
out += finalize

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -64,7 +64,7 @@ def build_dim_colons(v):
if d == []:
return ""
else:
x = map(lambda x: ":", d)
x = [":" for x in d]
return "(%s)"%(','.join(x))
@ -83,7 +83,7 @@ def make_single(l):
d = {}
for x in l:
d[x] = True
return d.keys()
return list(d.keys())
def flatten(l):
if type(l) == list:
@ -108,11 +108,11 @@ def dimsize(x):
size = str( int(b1) - int(b0) + 1 )
else:
if b0.replace('-','').isdigit():
size = "%s - (%d)"%(b1,int(b0)-1)
size = "(%s) - (%d)"%(b1,int(b0)-1)
elif b1.replace('-','').isdigit():
size = "%d - (%s)"%(int(b1)+1,b0)
size = "(%d) - (%s)"%(int(b1)+1,b0)
else:
size = "%s - (%s) + 1"%(b1,b0)
size = "(%s) - (%s) + 1"%(b1,b0)
return size
def put_info(text,filename):
@ -128,17 +128,17 @@ def put_info(text,filename):
line.text = format%(line.text.ljust(lenmax),line.filename,str(line.i))
return text
import cPickle as pickle
import pickle as pickle
import os, sys
def parallel_loop(f,source):
pidlist = range(NTHREADS)
pidlist = list(range(NTHREADS))
src = [ [] for i in xrange(NTHREADS) ]
src = [ [] for i in range(NTHREADS) ]
index = 0
try:
source = map( lambda x: (len(x[1]),(x[0], x[1])), source )
source = [(len(x[1]),(x[0], x[1])) for x in source]
source.sort()
source = map( lambda x: x[1], source )
source = [x[1] for x in source]
except:
pass
for i in source:
@ -149,8 +149,8 @@ def parallel_loop(f,source):
thread_id = 0
fork = 1
r = range(0,NTHREADS)
for thread_id in xrange(1,NTHREADS):
r = list(range(0,NTHREADS))
for thread_id in range(1,NTHREADS):
r[thread_id], w = os.pipe()
fork = os.fork()
if fork == 0:
@ -166,14 +166,14 @@ def parallel_loop(f,source):
result = []
for filename, text in src[thread_id]:
result.append( (filename, f(filename,text)) )
result.sort()
result = sorted(result, key=lambda x: x[0])
if fork == 0:
pickle.dump(result,w,-1)
w.close()
os._exit(0)
for i in xrange(1,NTHREADS):
for i in range(1,NTHREADS):
result += pickle.load(r[i])
r[i].close()
os.waitpid(pidlist[i],0)[1]
@ -183,10 +183,10 @@ def parallel_loop(f,source):
if __name__ == '__main__':
print "10",dimsize("10") #-> "10"
print "0:10",dimsize("0:10") # -> "11"
print "0:x",dimsize("0:x") # -> "x+1"
print "-3:x",dimsize("-3:x") # -> "x+1"
print "x:y",dimsize("x:y") # -> "y-x+1"
print "x:5",dimsize("x:5") # -> "y-x+1"
print("10",dimsize("10")) #-> "10"
print("0:10",dimsize("0:10")) # -> "11"
print("0:x",dimsize("0:x")) # -> "x+1"
print("-3:x",dimsize("-3:x")) # -> "x+1"
print("x:y",dimsize("x:y")) # -> "y-x+1"
print("x:5",dimsize("x:5")) # -> "y-x+1"

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -105,6 +105,11 @@ class Variable(object):
for line in text:
if type(line) == Begin_provider:
self._name = line.filename[1]
if "(" in self._name:
error.fail(line,"""'(' not allowed in variable name.
A ',' is probably missing between the name of the variable and the
dimension.
""")
break
return self._name
name = property(name)
@ -113,8 +118,8 @@ class Variable(object):
def doc(self):
if '_doc' not in self.__dict__:
text = self.text
buffer = filter(lambda l:type(l) == Doc, text)
self._doc = map(lambda l: l.text.lstrip()[1:], buffer)
buffer = [l for l in text if type(l) == Doc]
self._doc = [l.text.lstrip()[1:] for l in buffer]
if buffer == []:
error.warn(None,"Variable %s is not documented"%(self.name))
return self._doc
@ -132,7 +137,7 @@ class Variable(object):
if '_includes' not in self.__dict__:
self._includes = []
text = self.text
for line in filter(lambda x: type(x) == Include,text):
for line in [x for x in text if type(x) == Include]:
self._includes.append(line.filename)
make_single(self._includes)
return self._includes
@ -143,7 +148,7 @@ class Variable(object):
if '_calls' not in self.__dict__:
self._calls = []
text = self.text
for line in filter(lambda x: type(x) == Call,text):
for line in [x for x in text if type(x) == Call]:
sub = line.text.split('(',1)[0].split()[1].lower()
self._calls.append(sub)
make_single(self._calls)
@ -157,7 +162,7 @@ class Variable(object):
append = result.append
f = lambda l: type(l) in [Begin_provider, Cont_provider]
text = self.text
lines = filter(f, text)
lines = list(filter(f, text))
for line in lines:
append(line.filename[1])
result.remove(self.name)
@ -185,7 +190,7 @@ class Variable(object):
from variables import variables
def f(var):
return variables[var].dim != []
self._allocate = filter ( f, self.others + [self.name] )
self._allocate = list(filter ( f, self.others + [self.name] ))
return self._allocate
allocate = property(allocate)
@ -198,7 +203,7 @@ class Variable(object):
self._dim = []
else:
buffer = buffer[2].strip()[1:-1].split(',')
self._dim = map(strip,buffer)
self._dim = list(map(strip,buffer))
return self._dim
dim = property(dim)
@ -238,7 +243,7 @@ class Variable(object):
if '_line' not in self.__dict__:
f = lambda l: type(l) in [Begin_provider, Cont_provider]
text = self.text
lines = filter(f, text)
lines = list(filter(f, text))
for line in lines:
buffer = line.filename[1]
if self._name == buffer:
@ -277,18 +282,18 @@ class Variable(object):
import parsed_text
parents = self.parents
parents.sort()
mods = map(lambda x: variables[x].fmodule, parents)
mods = [variables[x].fmodule for x in parents]
mods = make_single(mods)+[self.fmodule]
name = self.name
result = [ "subroutine touch_%s"%(name) ]
result += map(lambda x: " Use %s"%(x),mods)
result += [" Use %s"%(x) for x in mods]
result.append(" implicit none")
if command_line.do_debug:
length = str(len("touch_%s"%(name)))
result += [ " character*(%s) :: irp_here = 'touch_%s'"%(length,name) ]
if command_line.do_debug:
result += [ " call irp_enter(irp_here)" ]
result += map( lambda x: " %s_is_built = .False."%(x), parents)
result += [" %s_is_built = .False."%(x) for x in parents]
result.append(" %s_is_built = .True."%(name))
if command_line.do_debug:
result.append(" call irp_leave(irp_here)")
@ -358,7 +363,7 @@ class Variable(object):
result += [\
" character*(%d) :: irp_here = 'reader_%s'"%(length,name),
" call irp_enter(irp_here)" ]
result += map(lambda x: " call reader_%s(irp_num)"%(x),self.needs)
result += [" call reader_%s(irp_num)"%(x) for x in self.needs]
result += [ \
" irp_is_open = .True.",
" irp_iunit = 9",
@ -408,7 +413,7 @@ class Variable(object):
" if (.not.%s_is_built) then"%(self.same_as),
" call provide_%s"%(self.same_as),
" endif" ]
result += map(lambda x: " call writer_%s(irp_num)"%(x),self.needs)
result += [" call writer_%s(irp_num)"%(x) for x in self.needs]
result += [ \
" irp_is_open = .True.",
" irp_iunit = 9",
@ -475,7 +480,7 @@ class Variable(object):
return result+")'"
def check_dimensions():
result = map(lambda x: "(%s>0)"%(dimsize(x)), self.dim)
result = ["(%s>0)"%(dimsize(x)) for x in self.dim]
result = ".and.".join(result)
result = " if (%s) then"%(result)
return result
@ -547,15 +552,15 @@ class Variable(object):
"!$ integer :: nthreads"]
if command_line.do_openmp:
result.append(" call irp_lock_%s(.True.)"%(same_as))
if command_line.do_assert or command_line.do_debug:
if command_line.do_debug:
result.append(" call irp_enter(irp_here)")
result += call_provides(self.to_provide)
result += flatten( map(build_alloc,[self.same_as]+self.others) )
result += flatten( list(map(build_alloc,[self.same_as]+self.others)) )
result += [ " if (.not.%s_is_built) then"%(same_as),
" call bld_%s"%(same_as),
" %s_is_built = .True."%(same_as), "" ]
result += [ " endif" ]
if command_line.do_assert or command_line.do_debug:
if command_line.do_debug:
result.append(" call irp_leave(irp_here)")
if command_line.do_openmp:
result.append(" call irp_lock_%s(.False.)"%(same_as))
@ -586,7 +591,7 @@ class Variable(object):
vars = []
if inside:
text.append( (vars,line) )
text += map( lambda x: ([],Simple_line(line.i,x,line.filename)), call_provides(vars) )
text += [([],Simple_line(line.i,x,line.filename)) for x in call_provides(vars)]
if command_line.do_profile and type(line) == Begin_provider:
text.append( ( [], Declaration(line.i," double precision :: irp_rdtsc, irp_rdtsc1, irp_rdtsc2",line.filename) ) )
text.append( ( [], Simple_line(line.i," irp_rdtsc1 = irp_rdtsc()",line.filename) ) )
@ -597,9 +602,9 @@ class Variable(object):
text = parsed_text.move_to_top(text,Declaration)
text = parsed_text.move_to_top(text,Implicit)
text = parsed_text.move_to_top(text,Use)
text = map(lambda x: x[1], text)
text = [x[1] for x in text]
# inside_omp = False
for line in filter(lambda x: type(x) not in [ Begin_doc, End_doc, Doc], text):
for line in [x for x in text if type(x) not in [ Begin_doc, End_doc, Doc]]:
if type(line) == Begin_provider:
result = []
if command_line.directives and command_line.inline in ["all","builders"]:
@ -681,5 +686,17 @@ if __name__ == '__main__':
from variables import variables
#for v in variables.keys():
# print v
for line in variables['e_loc'].parents:
print line
def print_dot(x,done):
if x.children == []:
return
for i in x.needs:
pair = (x.name, i)
if pair not in done:
print("%s -> %s"%( x.name, i ))
done[pair] = None
print_dot(variables[i],done)
print("digraph G { ")
# print_dot(variables['e_loc'], {})
print_dot(variables['psi_value'], {})
print("}")

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -29,6 +29,9 @@ from variable import *
from irpf90_t import *
from command_line import command_line
from util import *
import error
forbidden_names = ["type", "double precision", "integer", "use", "character", "real"]
######################################################################
def create_variables():
@ -47,8 +50,20 @@ def create_variables():
inside = False
icount += 1
v = Variable(buffer,icount)
if v.name in result:
print("Warning: Duplicate provider for %s in"%(v.name))
print("- ", v.line.filename[0], " line ", v.line.i)
print("- ", result[v.name].line.filename[0], " line ", result[v.name].line.i)
print("Choosing first version")
if v.name in forbidden_names:
error.fail(line,"A variable can't be named %s"%(v.name))
result[v.name] = v
for other in v.others:
if other in result:
print("Warning: Duplicate provider for %s in"%(other))
print("- ", v.line.filename[0], " line ", v.line.i)
print("- ", result[other].line.filename[0], " line ", result[other].line.i)
print("Choosing first version")
result[other] = Variable(buffer,icount,other)
buffer = []
return result
@ -57,16 +72,16 @@ variables = create_variables()
######################################################################
def build_use(vars):
result = map(lambda x: " use %s"%(variables[x].fmodule), vars)
result = [" use %s"%(variables[x].fmodule) for x in vars]
result = make_single(result)
return result
######################################################################
def call_provides(vars,opt=False):
vars = make_single( map(lambda x: variables[x].same_as, vars) )
vars = make_single( [variables[x].same_as for x in vars] )
if opt:
all_children = flatten( map(lambda x: variables[x].children, vars ))
vars = filter(lambda x: x not in all_children,vars)
all_children = flatten( [variables[x].children for x in vars])
vars = [x for x in vars if x not in all_children]
def fun(x):
result = []
result += [ \
@ -77,10 +92,10 @@ def call_provides(vars,opt=False):
" endif" ]
return result
result = flatten ( map (fun, vars) )
result = flatten ( list(map (fun, vars)) )
return result
######################################################################
if __name__ == '__main__':
for v in variables.keys():
print v
for v in list(variables.keys()):
print(v)

View File

@ -1 +1 @@
version = "1.6.1"
version="2.0.5"

View File

@ -1,4 +1,4 @@
#/usr/bin/env python
#/usr/bin/env python3
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
# the Implicit Reference to Parameters (IRP) method.
# Copyright (C) 2009 Anthony SCEMAMA
@ -39,8 +39,10 @@ def install():
file.close()
if not os.access(VIM+"/syntax",os.F_OK):
os.mkdir(VIM+"/syntax")
wd = os.path.abspath(os.path.dirname(__file__))+"/../vim"
os.symlink(wd+"/irpf90.vim",VIM+"/syntax/irpf90.vim")
wd = os.path.abspath(os.path.dirname(__file__))
with open(wd+"/irpf90.vim",'r') as f_in:
with open(VIM+"/syntax/irpf90.vim",'w') as f_out:
f_out.write( f_in.read() )
except:
pass

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import os,sys
ROOT = os.path.dirname(__file__)+'/../../'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import os
ROOT = os.path.dirname(__file__)+'/../../'