mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-10-19 22:41:40 +02:00
Compare commits
No commits in common. "master" and "v1.7.3" have entirely different histories.
@ -8,7 +8,7 @@ Dependencies
|
|||||||
------------
|
------------
|
||||||
|
|
||||||
- GNU make (>= 3.81 recommended)
|
- GNU make (>= 3.81 recommended)
|
||||||
- Python >2.6
|
- Python > 2.3
|
||||||
- Any Fortran 90 compiler (Intel recommended)
|
- Any Fortran 90 compiler (Intel recommended)
|
||||||
|
|
||||||
Installing IRPF90
|
Installing IRPF90
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
|
19
bin/irpman
19
bin/irpman
@ -29,20 +29,21 @@
|
|||||||
case "$0" in
|
case "$0" in
|
||||||
*irpman)
|
*irpman)
|
||||||
if [[ -z $1 ]] ; then
|
if [[ -z $1 ]] ; then
|
||||||
if [[ $(ps -p $$ -ocomm=) == "zsh" ]]
|
echo "To activate auto-completion in bash:"
|
||||||
then
|
echo "source " $0
|
||||||
source $(dirname $0)/../irpman-completions.bash
|
|
||||||
else
|
|
||||||
echo "To activate auto-completion in bash/zsh:"
|
|
||||||
echo "source " $0
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
exec python3 $(dirname $0)/../src/irpman.py $1
|
exec python2 $(dirname $0)/../src/irpman.py $1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
source $(dirname ${BASH_SOURCE[0]})/../irpman-completions.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
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
IRPF90 = python3 ../src/irpf90.py -I input
|
IRPF90 = python2 ../src/irpf90.py -I input
|
||||||
FC = ifort
|
FC = ifort
|
||||||
FCFLAGS= -O2
|
FCFLAGS= -O2
|
||||||
NINJA =
|
NINJA =
|
||||||
|
@ -3,7 +3,7 @@ RST2MAN=rst2man -d -t
|
|||||||
default: man1/irpman.1.gz man1/irpf90.1.gz
|
default: man1/irpman.1.gz man1/irpf90.1.gz
|
||||||
|
|
||||||
options.rst: ../src/command_line.py
|
options.rst: ../src/command_line.py
|
||||||
python3 ../src/command_line.py > options.rst
|
python ../src/command_line.py > options.rst
|
||||||
|
|
||||||
man1/irpf90.1.gz: irpf90.rst 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
|
rm -f $@ ; $(RST2MAN) --title="IRP Fortran 90" irpf90.rst man1/irpf90.1 ; gzip man1/irpf90.1
|
||||||
|
Binary file not shown.
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
wd = os.path.abspath(os.path.dirname(__file__))
|
wd = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
|
@ -28,13 +28,13 @@
|
|||||||
|
|
||||||
function run ()
|
function run ()
|
||||||
{
|
{
|
||||||
cat << EOF | exec python3 - $@
|
cat << EOF | exec python2 - $@
|
||||||
import sys, os
|
import sys, os
|
||||||
|
|
||||||
from irpf90_libs.irpf90_t import mandir
|
from irpf90_libs.irpf90_t import mandir
|
||||||
filename = sys.argv[1].lower()+".l"
|
filename = sys.argv[1].lower()+".l"
|
||||||
if filename not in os.listdir(mandir):
|
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)
|
sys.exit(-1)
|
||||||
|
|
||||||
os.system("man ./"+mandir+sys.argv[1].lower()+".l")
|
os.system("man ./"+mandir+sys.argv[1].lower()+".l")
|
||||||
|
38
pip/setup.py
38
pip/setup.py
@ -1,30 +1,16 @@
|
|||||||
import sys
|
from distutils.core import setup
|
||||||
|
|
||||||
import setuptools
|
setup(
|
||||||
import version
|
|
||||||
|
|
||||||
with open("README.md", "r") as fh:
|
|
||||||
long_description = fh.read()
|
|
||||||
|
|
||||||
v = version.version
|
|
||||||
|
|
||||||
setuptools.setup(
|
|
||||||
name = 'irpf90',
|
name = 'irpf90',
|
||||||
version = v,
|
packages = ['irpf90_libs'], # this must be the same as the name above
|
||||||
scripts = ["irpf90", "irpman", "irpf90_indent"],
|
version = '1.6.9',
|
||||||
|
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.',
|
||||||
author = 'Anthony Scemama',
|
author = 'Anthony Scemama',
|
||||||
author_email = 'scemama@irsamc.ups-tlse.fr',
|
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.',
|
url = 'http://irpf90.ups-tlse.fr', # use the URL to the github repo
|
||||||
long_description=long_description,
|
download_url = 'https://github.com/scemama/irpf90/archive/v1.6.9.tar.gz', # I'll explain this in a second
|
||||||
long_description_content_type="text/markdown",
|
keywords = ['programming', 'fortran', 'IRP'], # arbitrary keywords
|
||||||
url="https://irpf90.ups-tlse.fr",
|
classifiers = [],
|
||||||
download_url = f'https://gitlab.com/scemama/irpf90/-/archive/v{v}/irpf90-v{v}.tar.gz',
|
scripts = ["irpf90", "irpman", "irpf90_indent"],
|
||||||
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 +0,0 @@
|
|||||||
../src/version.py
|
|
19
src/Makefile
19
src/Makefile
@ -1,14 +1,21 @@
|
|||||||
all: exe vim emacs
|
PYTHON=python2
|
||||||
|
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)
|
||||||
|
|
||||||
exe: ../bin/irpf90
|
../bin/irpf90: irpf90.so
|
||||||
|
rm ../bin/irpf90 ; cd ../bin ; ln -s ../src/irpf90_python.exe irpf90
|
||||||
|
|
||||||
vim:
|
irpf90.so : $(wildcard *.py) irpf90.c
|
||||||
python3 vim.py
|
./cython_setup.py build_ext --inplace
|
||||||
|
|
||||||
emacs:
|
irpf90.c: irpf90.py
|
||||||
python3 emacs.py
|
cython --embed irpf90.py
|
||||||
|
|
||||||
|
else
|
||||||
../bin/irpf90: irpf90_python.exe
|
../bin/irpf90: irpf90_python.exe
|
||||||
rm ../bin/irpf90 ; cd ../bin ; ln -s ../src/irpf90_python.exe irpf90
|
rm ../bin/irpf90 ; cd ../bin ; ln -s ../src/irpf90_python.exe irpf90
|
||||||
|
endif
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.c *.so *.pyc *.pyo 2>/dev/null
|
rm -f *.c *.so *.pyc *.pyo 2>/dev/null
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
# For relative imports to work in Python 3.6
|
|
||||||
import os, sys
|
|
||||||
sys.path = [ os.path.dirname(os.path.realpath(__file__)) ] + sys.path
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -36,10 +36,10 @@ FILENAME=irpdir+'irp_checkpoint.irp.F90'
|
|||||||
|
|
||||||
def create():
|
def create():
|
||||||
out_write = [ "subroutine irp_checkpoint_write" ]
|
out_write = [ "subroutine irp_checkpoint_write" ]
|
||||||
l = list(variables.keys())
|
l = variables.keys()
|
||||||
l.sort
|
l.sort
|
||||||
main_modules = [x for x in modules if modules[x].is_main]
|
main_modules = filter(lambda x: modules[x].is_main, modules)
|
||||||
for m in [x for x in modules if not modules[x].is_main]:
|
for m in filter(lambda x: not modules[x].is_main, modules):
|
||||||
out_write += [ " use %s"%(modules[m].name) ]
|
out_write += [ " use %s"%(modules[m].name) ]
|
||||||
out_write += [ " implicit none" ]
|
out_write += [ " implicit none" ]
|
||||||
out_write += [ " integer, parameter :: iunit = %d"%(CHECKPOINT_UNIT_NUMBER) ]
|
out_write += [ " integer, parameter :: iunit = %d"%(CHECKPOINT_UNIT_NUMBER) ]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -76,7 +76,7 @@ class CommandLine(object):
|
|||||||
for o,a in self.opts:
|
for o,a in self.opts:
|
||||||
if o in [ "-I", '--'+options['I'][0] ]:
|
if o in [ "-I", '--'+options['I'][0] ]:
|
||||||
if len(a) < 1:
|
if len(a) < 1:
|
||||||
print("Error: -I option needs a directory")
|
print "Error: -I option needs a directory"
|
||||||
if a[-1] != '/':
|
if a[-1] != '/':
|
||||||
a = a+'/'
|
a = a+'/'
|
||||||
self._include_dir.append(a)
|
self._include_dir.append(a)
|
||||||
@ -116,12 +116,12 @@ class CommandLine(object):
|
|||||||
elif len(buffer) == 3:
|
elif len(buffer) == 3:
|
||||||
self._codelet = [buffer[0], int(buffer[2]), buffer[1], filename]
|
self._codelet = [buffer[0], int(buffer[2]), buffer[1], filename]
|
||||||
else:
|
else:
|
||||||
print("""
|
print """
|
||||||
Error in codelet definition. Use:
|
Error in codelet definition. Use:
|
||||||
--codelet=provider:NMAX
|
--codelet=provider:NMAX
|
||||||
or
|
or
|
||||||
--codelet=provider:precondition:NMAX
|
--codelet=provider:precondition:NMAX
|
||||||
""")
|
"""
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
return self._codelet
|
return self._codelet
|
||||||
codelet = property(fget=codelet)
|
codelet = property(fget=codelet)
|
||||||
@ -209,11 +209,11 @@ Options:
|
|||||||
"""
|
"""
|
||||||
t = t.replace("$EXE",self.executable_name)
|
t = t.replace("$EXE",self.executable_name)
|
||||||
t = t.replace("$DESCR",description)
|
t = t.replace("$DESCR",description)
|
||||||
print(t)
|
print t
|
||||||
print_options()
|
print_options()
|
||||||
print("")
|
print ""
|
||||||
print("Version : ", version)
|
print "Version : ", version
|
||||||
print("")
|
print ""
|
||||||
|
|
||||||
def opts(self):
|
def opts(self):
|
||||||
if self._opts is None:
|
if self._opts is None:
|
||||||
@ -228,10 +228,10 @@ Options:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._opts, args = getopt.getopt(self.argv[1:], optlist[0], optlist[1])
|
self._opts, args = getopt.getopt(self.argv[1:], optlist[0], optlist[1])
|
||||||
except getopt.GetoptError as err:
|
except getopt.GetoptError, err:
|
||||||
# print help information and exit:
|
# print help information and exit:
|
||||||
self.usage()
|
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)
|
sys.exit(2)
|
||||||
|
|
||||||
return self._opts
|
return self._opts
|
||||||
@ -248,9 +248,9 @@ def do_$LONG(self):
|
|||||||
return self._do_$LONG
|
return self._do_$LONG
|
||||||
do_$LONG = property(fget=do_$LONG)
|
do_$LONG = property(fget=do_$LONG)
|
||||||
"""
|
"""
|
||||||
for short_opt in options:
|
for short in options:
|
||||||
long_opt = options[short_opt][0]
|
long = options[short][0]
|
||||||
exec(t.replace("$LONG",long_opt).replace("$SHORT",short_opt)) #in locals()
|
exec t.replace("$LONG",long).replace("$SHORT",short) #in locals()
|
||||||
|
|
||||||
def do_run(self):
|
def do_run(self):
|
||||||
if '_do_run' not in self.__dict__:
|
if '_do_run' not in self.__dict__:
|
||||||
@ -267,16 +267,16 @@ do_$LONG = property(fget=do_$LONG)
|
|||||||
command_line = CommandLine()
|
command_line = CommandLine()
|
||||||
|
|
||||||
def print_options():
|
def print_options():
|
||||||
keys = list(options.keys())
|
keys = options.keys()
|
||||||
keys.sort()
|
keys.sort()
|
||||||
import subprocess
|
import subprocess
|
||||||
for k in keys:
|
for k in keys:
|
||||||
description = options[k][1]
|
description = options[k][1]
|
||||||
p1 = subprocess.Popen(["fold", "-s", "-w", "40"],stdout=subprocess.PIPE,stdin=subprocess.PIPE, encoding='utf8')
|
p1 = subprocess.Popen(["fold", "-s", "-w", "40"],stdout=subprocess.PIPE,stdin=subprocess.PIPE)
|
||||||
description = p1.communicate(description)[0]
|
description = p1.communicate(description)[0]
|
||||||
description = description.replace('\n','\n'.ljust(27))
|
description = description.replace('\n','\n'.ljust(27))
|
||||||
print(("-%s, --%s"%(k,options[k][0])).ljust(25), description+'\n')
|
print ("-%s, --%s"%(k,options[k][0])).ljust(25), description+'\n'
|
||||||
print("\n")
|
print "\n"
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print_options()
|
print_options()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -34,13 +34,12 @@ from util import *
|
|||||||
|
|
||||||
|
|
||||||
def do_print_short(file,var):
|
def do_print_short(file,var):
|
||||||
"""Makes a short print, as in irpf90_entities"""
|
|
||||||
assert type(var) == Variable
|
assert type(var) == Variable
|
||||||
print("%s : %s :: %s %s"%( \
|
print >>file, "%s : %s :: %s %s"%( \
|
||||||
var.line.filename[0].ljust(35),
|
var.line.filename[0].ljust(35),
|
||||||
var.type.ljust(30),
|
var.type.ljust(30),
|
||||||
var.name.ljust(25),
|
var.name.ljust(25),
|
||||||
build_dim(var.dim) ), file=file)
|
build_dim(var.dim) )
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def process_doc(file,line):
|
def process_doc(file,line):
|
||||||
@ -48,13 +47,13 @@ def process_doc(file,line):
|
|||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line == "":
|
if line == "":
|
||||||
line = ".br"
|
line = ".br"
|
||||||
print(line, file=file)
|
print >>file, line
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def process_deps(file,l):
|
def process_deps(file,l):
|
||||||
assert type(l) == list
|
assert type(l) == list
|
||||||
for v in l:
|
for v in l:
|
||||||
print("%s\n.br"%(v,), file=file)
|
print >>file, "%s\n.br"%(v,)
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def process_types(file,var):
|
def process_types(file,var):
|
||||||
@ -65,7 +64,7 @@ def process_types(file,var):
|
|||||||
var = variables[var]
|
var = variables[var]
|
||||||
Type = var.type
|
Type = var.type
|
||||||
dim = build_dim(var.dim)
|
dim = build_dim(var.dim)
|
||||||
print("%s\t:: %s\t%s"%(Type,name,dim), file=file)
|
print >>file, "%s\t:: %s\t%s"%(Type,name,dim)
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def do_print(var):
|
def do_print(var):
|
||||||
@ -73,106 +72,37 @@ def do_print(var):
|
|||||||
filename = var.line.filename[0]
|
filename = var.line.filename[0]
|
||||||
name = var.name
|
name = var.name
|
||||||
file = open("%s%s.l"%(mandir,var.name), "w")
|
file = open("%s%s.l"%(mandir,var.name), "w")
|
||||||
print('.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name), file=file)
|
print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name)
|
||||||
if var.same_as != var.name:
|
if var.same_as != var.name:
|
||||||
var = variables[var.same_as]
|
var = variables[var.same_as]
|
||||||
print(".SH Declaration", file=file)
|
print >>file, ".SH Declaration"
|
||||||
print(".nf", file=file)
|
print >>file, ".nf"
|
||||||
process_types(file,var)
|
process_types(file,var)
|
||||||
print(".ni", file=file)
|
print >>file, ".ni"
|
||||||
if var.doc != []:
|
if var.doc != []:
|
||||||
print(".SH Description", file=file)
|
print >>file, ".SH Description"
|
||||||
for l in var.doc:
|
for l in var.doc:
|
||||||
process_doc(file,l)
|
process_doc(file,l)
|
||||||
print(".SH File\n.P", file=file)
|
print >>file, ".SH File\n.P"
|
||||||
print(filename, file=file)
|
print >>file, filename
|
||||||
if var.needs != []:
|
if var.needs != []:
|
||||||
var.needs.sort()
|
var.needs.sort()
|
||||||
print(".SH Needs", file=file)
|
print >>file, ".SH Needs"
|
||||||
process_deps(file,var.needs)
|
process_deps(file,var.needs)
|
||||||
if var.needed_by != []:
|
if var.needed_by != []:
|
||||||
var.needed_by.sort()
|
var.needed_by.sort()
|
||||||
print(".SH Needed by", file=file)
|
print >>file, ".SH Needed by"
|
||||||
process_deps(file,var.needed_by)
|
process_deps(file,var.needed_by)
|
||||||
print(".SH Instability factor", file=file)
|
print >>file, ".SH Instability factor"
|
||||||
fo = len(var.children)
|
fo = len(var.children)
|
||||||
fi = len(var.parents)
|
fi = len(var.parents)
|
||||||
print("%5.1f %%"%(100.* (fi / (fi+fo+.000001) )), file=file)
|
print >>file, "%5.1f %%"%(100.* (fi / (fi+fo+.000001) ))
|
||||||
print(".br", file=file)
|
print >>file, ".br"
|
||||||
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()
|
file.close()
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def process_declaration_subroutine(file, sub):
|
def process_declaration_subroutine(file, sub):
|
||||||
print(sub.line.text.split('!')[0].strip(), file=file)
|
print >>file, sub.line.text.split('!')[0].strip()
|
||||||
|
|
||||||
# for line in sub.text:
|
# for line in sub.text:
|
||||||
######################################################################
|
######################################################################
|
||||||
@ -181,116 +111,38 @@ def do_print_subroutines(sub):
|
|||||||
filename = sub.line.filename
|
filename = sub.line.filename
|
||||||
name = sub.name
|
name = sub.name
|
||||||
file = open("%s%s.l"%(mandir,sub.name), "w")
|
file = open("%s%s.l"%(mandir,sub.name), "w")
|
||||||
print('.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name), file=file)
|
print >>file, '.TH "IRPF90 entities" l %s "IRPF90 entities" %s'%(name,name)
|
||||||
print(".SH Declaration", file=file)
|
print >>file, ".SH Declaration"
|
||||||
print(".nf", file=file)
|
print >>file, ".nf"
|
||||||
process_declaration_subroutine(file,sub)
|
process_declaration_subroutine(file,sub)
|
||||||
print(".ni", file=file)
|
print >>file, ".ni"
|
||||||
if sub.doc != []:
|
if sub.doc != []:
|
||||||
print(".SH Description", file=file)
|
print >>file, ".SH Description"
|
||||||
for l in sub.doc:
|
for l in sub.doc:
|
||||||
process_doc(file,l)
|
process_doc(file,l)
|
||||||
print(".SH File\n.P", file=file)
|
print >>file, ".SH File\n.P"
|
||||||
print(filename, file=file)
|
print >>file, filename
|
||||||
if sub.needs != []:
|
if sub.needs != []:
|
||||||
sub.needs.sort()
|
sub.needs.sort()
|
||||||
print(".SH Needs", file=file)
|
print >>file, ".SH Needs"
|
||||||
process_deps(file,sub.needs)
|
process_deps(file,sub.needs)
|
||||||
if sub.called_by != []:
|
if sub.called_by != []:
|
||||||
sub.called_by.sort()
|
sub.called_by.sort()
|
||||||
print(".SH Called by", file=file)
|
print >>file, ".SH Called by"
|
||||||
process_deps(file,sub.called_by)
|
process_deps(file,sub.called_by)
|
||||||
if sub.calls != []:
|
if sub.calls != []:
|
||||||
sub.calls.sort()
|
sub.calls.sort()
|
||||||
print(".SH Calls", file=file)
|
print >>file, ".SH Calls"
|
||||||
process_deps(file,sub.calls)
|
process_deps(file,sub.calls)
|
||||||
if sub.touches != []:
|
if sub.touches != []:
|
||||||
sub.touches.sort()
|
sub.touches.sort()
|
||||||
print(".SH Touches", file=file)
|
print >>file, ".SH Touches"
|
||||||
process_deps(file,sub.touches)
|
process_deps(file,sub.touches)
|
||||||
print(".SH Instability factor", file=file)
|
print >>file, ".SH Instability factor"
|
||||||
fo = len(sub.needs)+len(sub.calls)+len(sub.touches)
|
fo = len(sub.needs)+len(sub.calls)+len(sub.touches)
|
||||||
fi = len(sub.called_by)
|
fi = len(sub.called_by)
|
||||||
print("%5.1f %%"%(100.* (fi / (fi+fo+.000001) )), file=file)
|
print >>file, "%5.1f %%"%(100.* (fi / (fi+fo+.000001) ))
|
||||||
print(".br", file=file)
|
print >>file, ".br"
|
||||||
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()
|
file.close()
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
@ -299,60 +151,34 @@ def run():
|
|||||||
import os,sys
|
import os,sys
|
||||||
pid1 = os.fork()
|
pid1 = os.fork()
|
||||||
if pid1 == 0:
|
if pid1 == 0:
|
||||||
for v in list(variables.values()):
|
for v in variables.values():
|
||||||
do_print(v)
|
do_print(v)
|
||||||
do_print_rst(v)
|
for s in subroutines.values():
|
||||||
for s in list(subroutines.values()):
|
|
||||||
do_print_subroutines(s)
|
do_print_subroutines(s)
|
||||||
do_print_subroutines_rst(s)
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
pid2 = os.fork()
|
pid2 = os.fork()
|
||||||
if pid2 == 0:
|
if pid2 == 0:
|
||||||
tags = []
|
tags = []
|
||||||
l = list(variables.keys())
|
l = variables.keys()
|
||||||
file = open("irpf90_entities","w")
|
file = open("irpf90_entities","w")
|
||||||
l.sort()
|
l.sort()
|
||||||
for v in l:
|
for v in l:
|
||||||
do_print_short(file,variables[v])
|
do_print_short(file,variables[v])
|
||||||
line = variables[v].line
|
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) )
|
tags.append( '%s\t%s\t%d\n'%(v,line.filename[0],line.i) )
|
||||||
file.close()
|
file.close()
|
||||||
l = list(subroutines.keys())
|
l = subroutines.keys()
|
||||||
for v in l:
|
for v in l:
|
||||||
line = subroutines[v].line
|
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.append('%s\t%s\t%d\n'%(v,line.filename,line.i))
|
||||||
tags.sort()
|
tags.sort()
|
||||||
file = open("tags","w")
|
file = open("tags","w")
|
||||||
for line in tags:
|
for line in tags:
|
||||||
file.write(line)
|
file.write(line)
|
||||||
file.close()
|
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)
|
sys.exit(0)
|
||||||
|
|
||||||
os.waitpid(pid1,0)
|
os.waitpid(pid1,0)
|
||||||
|
38
irpman-completions.bash → src/cython_setup.py
Normal file → Executable file
38
irpman-completions.bash → src/cython_setup.py
Normal file → Executable file
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -24,17 +24,29 @@
|
|||||||
# 31062 Toulouse Cedex 4
|
# 31062 Toulouse Cedex 4
|
||||||
# scemama@irsamc.ups-tlse.fr
|
# scemama@irsamc.ups-tlse.fr
|
||||||
|
|
||||||
if [[ $(ps -p $$ -ocomm=) == "zsh" ]]
|
from distutils.core import setup
|
||||||
then
|
from distutils.extension import Extension
|
||||||
autoload bashcompinit
|
from Cython.Distutils import build_ext
|
||||||
bashcompinit
|
import os
|
||||||
fi
|
|
||||||
|
to_remove = """__init__.py 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
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_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
|
|
||||||
|
|
72
src/emacs.py
72
src/emacs.py
@ -1,72 +0,0 @@
|
|||||||
"""
|
|
||||||
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()
|
|
20
src/error.py
20
src/error.py
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -32,14 +32,14 @@ do_warnings = command_line.do_warnings
|
|||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def fail(line,message):
|
def fail(line,message):
|
||||||
print("""
|
print """
|
||||||
Error:
|
Error:
|
||||||
-----
|
-----
|
||||||
""")
|
"""
|
||||||
print(message, '\n')
|
print message, '\n'
|
||||||
if line is not None:
|
if line is not None:
|
||||||
assert isinstance(line,Line)
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
@ -49,14 +49,14 @@ def warn(line,message):
|
|||||||
return
|
return
|
||||||
if line is not None:
|
if line is not None:
|
||||||
assert isinstance(line,Line)
|
assert isinstance(line,Line)
|
||||||
print("""
|
print """
|
||||||
Warning:
|
Warning:
|
||||||
-------
|
-------
|
||||||
""")
|
"""
|
||||||
print(message, '\n')
|
print message, '\n'
|
||||||
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)
|
||||||
else:
|
else:
|
||||||
print("Warning: %s"%(message))
|
print "Warning: %s"%(message)
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
19
src/init.py
19
src/init.py
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -67,7 +67,7 @@ def init():
|
|||||||
try:
|
try:
|
||||||
os.stat(dir)
|
os.stat(dir)
|
||||||
except:
|
except:
|
||||||
print(dir,'not in dir')
|
print dir,'not in dir'
|
||||||
continue
|
continue
|
||||||
for filename in os.listdir(dir):
|
for filename in os.listdir(dir):
|
||||||
filename = dir+filename
|
filename = dir+filename
|
||||||
@ -76,17 +76,14 @@ def init():
|
|||||||
file = open(filename,"r")
|
file = open(filename,"r")
|
||||||
except IOError:
|
except IOError:
|
||||||
if command_line.do_warnings:
|
if command_line.do_warnings:
|
||||||
print("Warning : Unable to read file %s."%(filename))
|
print "Warning : Unable to read file %s."%(filename)
|
||||||
else:
|
else:
|
||||||
try:
|
buffer = file.read()
|
||||||
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()
|
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
|
initialized = True
|
||||||
|
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
;;; 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
|
|
@ -1,5 +0,0 @@
|
|||||||
# -*- mode: snippet -*-
|
|
||||||
# name: ASSERT
|
|
||||||
# key: ass
|
|
||||||
# --
|
|
||||||
ASSERT ($0)
|
|
@ -1,7 +0,0 @@
|
|||||||
# -*- mode: snippet -*-
|
|
||||||
# name: BEGIN_DOC ... END_DOC
|
|
||||||
# key: bc
|
|
||||||
# --
|
|
||||||
BEGIN_DOC
|
|
||||||
! $0
|
|
||||||
END_DOC
|
|
@ -1,7 +0,0 @@
|
|||||||
# -*- mode: snippet -*-
|
|
||||||
# name: BEGIN_PROVIDER ... END_PROVIDER
|
|
||||||
# key: bp
|
|
||||||
# --
|
|
||||||
BEGIN_PROVIDER [${1:integer}, ${2:var}]
|
|
||||||
$0
|
|
||||||
END_PROVIDER
|
|
@ -1,8 +0,0 @@
|
|||||||
# -*- mode: snippet -*-
|
|
||||||
# -*- mode: snippet -*-
|
|
||||||
# name: BEGIN_SHELL ... END_SHELL
|
|
||||||
# key: bsh
|
|
||||||
# --
|
|
||||||
BEGIN_SHELL [ ${1:/bin/bash} ]
|
|
||||||
$0
|
|
||||||
END_SHELL
|
|
154
src/irp_stack.py
154
src/irp_stack.py
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -41,25 +41,52 @@ def create():
|
|||||||
txt = """
|
txt = """
|
||||||
module irp_stack_mod
|
module irp_stack_mod
|
||||||
integer, parameter :: STACKMAX=1000
|
integer, parameter :: STACKMAX=1000
|
||||||
character*(128),allocatable :: irp_stack(:)
|
character*(128),allocatable :: irp_stack(:,:)
|
||||||
double precision,allocatable :: irp_cpu(:)
|
double precision,allocatable :: irp_cpu(:,:)
|
||||||
integer :: stack_index
|
integer,allocatable :: stack_index(:)
|
||||||
logical :: alloc = .False.
|
logical :: alloc = .False.
|
||||||
|
integer :: nthread
|
||||||
character*(128) :: white = ''
|
character*(128) :: white = ''
|
||||||
end module
|
end module
|
||||||
|
|
||||||
subroutine irp_enter(irp_where)
|
subroutine irp_enter(irp_where)
|
||||||
use irp_stack_mod
|
use irp_stack_mod
|
||||||
|
integer :: ithread
|
||||||
character*(*) :: irp_where
|
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"
|
txt += "$1"
|
||||||
|
|
||||||
if do_memory:
|
if do_memory:
|
||||||
txt+="""
|
txt+="""
|
||||||
if (.not.alloc) then
|
if (.not.alloc) then
|
||||||
print *, 'Allocating irp_stack(',STACKMAX+1,')'
|
"""
|
||||||
print *, 'Allocating irp_cpu(',STACKMAX+1,')'
|
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,',',0:nthread,')'
|
||||||
|
print *, 'Allocating irp_cpu(',STACKMAX,',',0:nthread,')'
|
||||||
|
print *, 'Allocating stack_index(',0:nthread,')'
|
||||||
endif"""
|
endif"""
|
||||||
txt +="""
|
txt +="""
|
||||||
$2
|
$2
|
||||||
@ -67,14 +94,42 @@ end subroutine
|
|||||||
|
|
||||||
subroutine irp_enter_f(irp_where)
|
subroutine irp_enter_f(irp_where)
|
||||||
use irp_stack_mod
|
use irp_stack_mod
|
||||||
|
integer :: ithread
|
||||||
character*(*) :: irp_where
|
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
|
$1
|
||||||
"""
|
"""
|
||||||
if do_memory:
|
if do_memory:
|
||||||
txt+="""
|
txt+="""
|
||||||
if (.not.alloc) then
|
if (.not.alloc) then
|
||||||
print *, 'Allocating irp_stack(',STACKMAX+1,')'
|
"""
|
||||||
print *, 'Allocating irp_cpu(',STACKMAX+1,')'
|
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,',',0:nthread,')'
|
||||||
|
print *, 'Allocating irp_cpu(',STACKMAX,',',0:nthread,')'
|
||||||
|
print *, 'Allocating stack_index(',0:nthread,')'
|
||||||
endif
|
endif
|
||||||
"""
|
"""
|
||||||
txt += """
|
txt += """
|
||||||
@ -84,7 +139,19 @@ end subroutine
|
|||||||
subroutine irp_leave (irp_where)
|
subroutine irp_leave (irp_where)
|
||||||
use irp_stack_mod
|
use irp_stack_mod
|
||||||
character*(*) :: irp_where
|
character*(*) :: irp_where
|
||||||
|
integer :: ithread
|
||||||
double precision :: cpu
|
double precision :: cpu
|
||||||
|
"""
|
||||||
|
if do_openmp:
|
||||||
|
txt += """
|
||||||
|
integer, external :: omp_get_thread_num
|
||||||
|
ithread = omp_get_thread_num()
|
||||||
|
"""
|
||||||
|
else:
|
||||||
|
txt += """
|
||||||
|
ithread = 0
|
||||||
|
"""
|
||||||
|
txt += """
|
||||||
$3
|
$3
|
||||||
$4
|
$4
|
||||||
end subroutine
|
end subroutine
|
||||||
@ -94,17 +161,44 @@ end subroutine
|
|||||||
if do_debug:
|
if do_debug:
|
||||||
s = """
|
s = """
|
||||||
if (.not.alloc) then
|
if (.not.alloc) then
|
||||||
allocate(irp_stack(0:STACKMAX))
|
"""
|
||||||
allocate(irp_cpu(0:STACKMAX))
|
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,0:nthread))
|
||||||
|
allocate(irp_cpu(0:STACKMAX,0:nthread))
|
||||||
|
allocate(stack_index(0:nthread))
|
||||||
stack_index = 0
|
stack_index = 0
|
||||||
alloc = .True.
|
alloc = .True.
|
||||||
endif
|
endif
|
||||||
stack_index = min(stack_index+1,STACKMAX)
|
!$OMP END CRITICAL
|
||||||
irp_stack(stack_index) = irp_where"""
|
endif
|
||||||
|
stack_index(ithread) = min(stack_index(ithread)+1,STACKMAX)
|
||||||
|
irp_stack(stack_index(ithread),ithread) = 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) = min(stack_index(1)+1,STACKMAX)
|
||||||
|
irp_stack(stack_index(1),1) = irp_where"""
|
||||||
if do_memory:
|
if do_memory:
|
||||||
txt+="""
|
txt+="""
|
||||||
print *, 'Allocating irp_stack(',STACKMAX+1,')'
|
print *, 'Allocating irp_stack(',STACKMAX,','0:nthread,')'
|
||||||
print *, 'Allocating irp_cpu(',STACKMAX+1,')' """
|
print *, 'Allocating irp_cpu(',STACKMAX,','0:nthread,')'
|
||||||
|
print *, 'Allocating stack_index(',0:nthread,')'"""
|
||||||
else:
|
else:
|
||||||
s = ""
|
s = ""
|
||||||
txt = txt.replace("$1",s)
|
txt = txt.replace("$1",s)
|
||||||
@ -112,8 +206,8 @@ end subroutine
|
|||||||
# $2
|
# $2
|
||||||
if do_debug:
|
if do_debug:
|
||||||
txt = txt.replace("$2","""
|
txt = txt.replace("$2","""
|
||||||
print *, white(1:stack_index)//'-> ', trim(irp_where)
|
print *, ithread, ':', white(1:stack_index(ithread))//'-> ', trim(irp_where)
|
||||||
call cpu_time(irp_cpu(stack_index))""")
|
call cpu_time(irp_cpu(stack_index(ithread),ithread))""")
|
||||||
else:
|
else:
|
||||||
txt = txt.replace("$2","")
|
txt = txt.replace("$2","")
|
||||||
|
|
||||||
@ -121,35 +215,47 @@ end subroutine
|
|||||||
if do_debug:
|
if do_debug:
|
||||||
txt = txt.replace("$3","""
|
txt = txt.replace("$3","""
|
||||||
call cpu_time(cpu)
|
call cpu_time(cpu)
|
||||||
print *, white(1:stack_index)//'<- ', &
|
print *, ithread, ':', white(1:stack_index(ithread))//'<- ', &
|
||||||
trim(irp_stack(stack_index)), &
|
trim(irp_stack(stack_index(ithread),ithread)), &
|
||||||
cpu-irp_cpu(stack_index)""")
|
cpu-irp_cpu(stack_index(ithread),ithread)""")
|
||||||
else:
|
else:
|
||||||
txt = txt.replace("$3","")
|
txt = txt.replace("$3","")
|
||||||
|
|
||||||
# $4
|
# $4
|
||||||
if do_debug:
|
if do_debug:
|
||||||
txt = txt.replace("$4","""
|
txt = txt.replace("$4","""
|
||||||
stack_index = max(0,stack_index-1)""")
|
stack_index(ithread) = max(0,stack_index(ithread)-1)""")
|
||||||
else:
|
else:
|
||||||
txt = txt.replace("$4","")
|
txt = txt.replace("$4","")
|
||||||
|
|
||||||
txt += """
|
txt += """
|
||||||
subroutine irp_trace
|
subroutine irp_trace
|
||||||
use irp_stack_mod
|
use irp_stack_mod
|
||||||
|
integer :: ithread
|
||||||
integer :: i
|
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
|
if (.not.alloc) return
|
||||||
print *, 'Stack trace: '
|
print *, 'Stack trace: ', ithread
|
||||||
print *, '-------------------------'
|
print *, '-------------------------'
|
||||||
do i=1,stack_index
|
do i=1,stack_index(ithread)
|
||||||
print *, trim(irp_stack(i))
|
print *, trim(irp_stack(i,ithread))
|
||||||
enddo
|
enddo
|
||||||
print *, '-------------------------'
|
print *, '-------------------------'
|
||||||
end subroutine
|
end subroutine
|
||||||
"""
|
"""
|
||||||
|
|
||||||
txt = txt.split('\n')
|
txt = txt.split('\n')
|
||||||
txt = [x+"\n" for x in txt]
|
txt = map(lambda x: x+"\n",txt)
|
||||||
if not util.same_file(FILENAME, txt):
|
if not util.same_file(FILENAME, txt):
|
||||||
file = open(FILENAME,'w')
|
file = open(FILENAME,'w')
|
||||||
file.writelines(txt)
|
file.writelines(txt)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -26,24 +26,27 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import vim
|
||||||
|
import os,sys
|
||||||
try:
|
try:
|
||||||
wd = os.path.abspath(os.path.dirname(__file__))
|
wd = os.path.abspath(os.path.dirname(__file__))
|
||||||
sys.path.insert(0,(wd+"/../src/"))
|
sys.path.insert(0,(wd+"/../src/"))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
sys.setcheckinterval(1000)
|
||||||
|
|
||||||
import vim
|
|
||||||
import os,sys
|
|
||||||
from command_line import command_line
|
from command_line import command_line
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
vim.install()
|
||||||
|
|
||||||
if command_line.do_help:
|
if command_line.do_help:
|
||||||
command_line.usage()
|
command_line.usage()
|
||||||
|
|
||||||
if command_line.do_version:
|
if command_line.do_version:
|
||||||
from version import version
|
from version import version
|
||||||
print(version)
|
print version
|
||||||
|
|
||||||
from init import init
|
from init import init
|
||||||
if command_line.do_init:
|
if command_line.do_init:
|
||||||
@ -55,20 +58,20 @@ def main():
|
|||||||
for filename,text in preprocessed_text:
|
for filename,text in preprocessed_text:
|
||||||
if filename in command_line.preprocessed:
|
if filename in command_line.preprocessed:
|
||||||
for line in text:
|
for line in text:
|
||||||
print(line.text)
|
print line.text
|
||||||
|
|
||||||
|
|
||||||
if command_line.do_touch:
|
if command_line.do_touch:
|
||||||
from variables import variables
|
from variables import variables
|
||||||
for var in command_line.touched:
|
for var in command_line.touched:
|
||||||
if var not in variables:
|
if var not in variables:
|
||||||
print("%s is not an IRP entity"%(var,))
|
print "%s is not an IRP entity"%(var,)
|
||||||
else:
|
else:
|
||||||
print("Touching %s invalidates the following entities:"%(var,))
|
print "Touching %s invalidates the following entities:"%(var,)
|
||||||
parents = variables[var].parents
|
parents = variables[var].parents
|
||||||
parents.sort()
|
parents.sort()
|
||||||
for x in parents:
|
for x in parents:
|
||||||
print("- %s"%(x,))
|
print "- %s"%(x,)
|
||||||
|
|
||||||
|
|
||||||
if not command_line.do_run:
|
if not command_line.do_run:
|
||||||
@ -89,7 +92,7 @@ def main():
|
|||||||
codelet.run()
|
codelet.run()
|
||||||
|
|
||||||
from modules import modules, write_module
|
from modules import modules, write_module
|
||||||
for m in list(modules.keys()):
|
for m in modules.keys():
|
||||||
write_module(modules[m])
|
write_module(modules[m])
|
||||||
|
|
||||||
makefile.run()
|
makefile.run()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -26,21 +26,10 @@
|
|||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
LENMAX = 70
|
LENMAX = 70
|
||||||
tabn = 2
|
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
|
tab = " "*tabn
|
||||||
|
|
||||||
class Grep(object):
|
class Grep(object):
|
||||||
@ -117,14 +106,6 @@ class Grep(object):
|
|||||||
def declaration(self,string):
|
def declaration(self,string):
|
||||||
return re.match(self.re_declaration,string) is not None
|
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()
|
grep = Grep()
|
||||||
|
|
||||||
class indent(object):
|
class indent(object):
|
||||||
@ -138,12 +119,10 @@ class indent(object):
|
|||||||
return l.strip().ljust(n) + ' :: '+ r.strip()
|
return l.strip().ljust(n) + ' :: '+ r.strip()
|
||||||
|
|
||||||
def format_continuation(self,string,n):
|
def format_continuation(self,string,n):
|
||||||
buffer = string.split('&', 1)
|
buffer = string.split('&')
|
||||||
if len(buffer) == 1:
|
if len(buffer) == 1:
|
||||||
l = buffer[0]
|
l = buffer[0]
|
||||||
return l
|
return l
|
||||||
elif buffer[0].strip() == "":
|
|
||||||
return self.format_continuation(buffer[1], n)
|
|
||||||
else:
|
else:
|
||||||
l, r = buffer
|
l, r = buffer
|
||||||
return l.strip().ljust(69-len(n)) + '&'+ r.strip()
|
return l.strip().ljust(69-len(n)) + '&'+ r.strip()
|
||||||
@ -186,38 +165,25 @@ class indent(object):
|
|||||||
for i in range(len(self.text)):
|
for i in range(len(self.text)):
|
||||||
prevline = line
|
prevline = line
|
||||||
line = self.text[i].strip()
|
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):
|
if grep.continuation(line):
|
||||||
line = self.format_continuation(line,k)
|
line = self.format_continuation(line,k)
|
||||||
|
|
||||||
if grep.continuation(prevline):
|
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
|
continue
|
||||||
|
|
||||||
if grep.begin_subroutine(line):
|
if grep.begin_subroutine(line):
|
||||||
print(line)
|
print line
|
||||||
k = indent0+tab
|
k = indent0+tab
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.begin_function(line):
|
if grep.begin_function(line):
|
||||||
print(line)
|
print line
|
||||||
k = indent0+tab
|
k = indent0+tab
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.begin_program(line):
|
if grep.begin_program(line):
|
||||||
print(line)
|
print line
|
||||||
k = indent0+tab
|
k = indent0+tab
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -225,76 +191,76 @@ class indent(object):
|
|||||||
if line[0] != '&':
|
if line[0] != '&':
|
||||||
k = indent0+tab
|
k = indent0+tab
|
||||||
if grep.begin_provider(self.text[i+1].strip()):
|
if grep.begin_provider(self.text[i+1].strip()):
|
||||||
print(" "+line)
|
print " "+line
|
||||||
else:
|
else:
|
||||||
print(line)
|
print line
|
||||||
else:
|
else:
|
||||||
print(line)
|
print line
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.declaration(line):
|
if grep.declaration(line):
|
||||||
print(k+self.format_declaration(line,30))
|
print k+self.format_declaration(line,30)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.begin_do(line):
|
if grep.begin_do(line):
|
||||||
print(k+line)
|
print k+line
|
||||||
k += tab
|
k += tab
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.begin_if(line):
|
if grep.begin_if(line):
|
||||||
print(k+line)
|
print k+line
|
||||||
k += tab
|
k += tab
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.xelse(line):
|
if grep.xelse(line):
|
||||||
print(k[:-tabn]+line)
|
print k[:-tabn]+line
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.begin_select(line):
|
if grep.begin_select(line):
|
||||||
print(k+line)
|
print k+line
|
||||||
k += 2*tab
|
k += 2*tab
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.case(line):
|
if grep.case(line):
|
||||||
print(k[:-tabn]+line)
|
print k[:-tabn]+line
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.end_do(line):
|
if grep.end_do(line):
|
||||||
k = k[:-tabn]
|
k = k[:-tabn]
|
||||||
print(k+line)
|
print k+line
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.end_if(line):
|
if grep.end_if(line):
|
||||||
k = k[:-tabn]
|
k = k[:-tabn]
|
||||||
print(k+line)
|
print k+line
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.end_select(line):
|
if grep.end_select(line):
|
||||||
k = k[:-2*tabn]
|
k = k[:-2*tabn]
|
||||||
print(k+line)
|
print k+line
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.end_subroutine(line):
|
if grep.end_subroutine(line):
|
||||||
print(line)
|
print line
|
||||||
k = indent0
|
k = indent0
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.end_function(line):
|
if grep.end_function(line):
|
||||||
print(line)
|
print line
|
||||||
k = indent0
|
k = indent0
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.end_provider(line):
|
if grep.end_provider(line):
|
||||||
print(line)
|
print line
|
||||||
k = indent0
|
k = indent0
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if grep.end_program(line):
|
if grep.end_program(line):
|
||||||
print(line)
|
print line
|
||||||
k = indent0
|
k = indent0
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print(k+line)
|
print k+line
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -29,7 +29,7 @@ from zlib import crc32
|
|||||||
|
|
||||||
irpdir = "IRPF90_temp/"
|
irpdir = "IRPF90_temp/"
|
||||||
mandir = "IRPF90_man/"
|
mandir = "IRPF90_man/"
|
||||||
irp_id = abs(crc32(os.getcwd().encode()))
|
irp_id = abs(crc32(os.getcwd()))
|
||||||
|
|
||||||
|
|
||||||
class Line(object):
|
class Line(object):
|
||||||
@ -391,11 +391,11 @@ def create_irpf90_files():
|
|||||||
import os
|
import os
|
||||||
def is_irpf90_file(filename):
|
def is_irpf90_file(filename):
|
||||||
return filename.endswith(".irp.f") and not filename.startswith('.')
|
return filename.endswith(".irp.f") and not filename.startswith('.')
|
||||||
result = list(filter ( is_irpf90_file, os.listdir(os.getcwd()) ))
|
result = filter ( is_irpf90_file, os.listdir(os.getcwd()) )
|
||||||
for dir in command_line.include_dir:
|
for dir in command_line.include_dir:
|
||||||
try:
|
try:
|
||||||
os.stat(dir)
|
os.stat(dir)
|
||||||
result += [dir+x for x in list(filter ( is_irpf90_file, os.listdir(dir) ))]
|
result += map(lambda x: dir+x, filter ( is_irpf90_file, os.listdir(dir) ) )
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
if command_line.do_codelet:
|
if command_line.do_codelet:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -32,7 +32,7 @@ wd = os.path.abspath(os.path.dirname(__file__))
|
|||||||
from irpf90_t import mandir
|
from irpf90_t import mandir
|
||||||
filename = sys.argv[1].lower()+".l"
|
filename = sys.argv[1].lower()+".l"
|
||||||
if filename not in os.listdir(mandir):
|
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)
|
sys.exit(-1)
|
||||||
|
|
||||||
os.system("man ./"+mandir+sys.argv[1].lower()+".l")
|
os.system("man ./"+mandir+sys.argv[1].lower()+".l")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -34,7 +34,7 @@ FILENAME=irpdir+'irp_locks.irp.F90'
|
|||||||
|
|
||||||
def create():
|
def create():
|
||||||
out = []
|
out = []
|
||||||
l = list(variables.keys())
|
l = variables.keys()
|
||||||
l.sort
|
l.sort
|
||||||
for v in l:
|
for v in l:
|
||||||
var = variables[v]
|
var = variables[v]
|
||||||
@ -47,7 +47,7 @@ def create():
|
|||||||
out += [ " call irp_lock_%s(.True.)"%v ]
|
out += [ " call irp_lock_%s(.True.)"%v ]
|
||||||
out += [ " call irp_lock_%s(.False.)"%v ]
|
out += [ " call irp_lock_%s(.False.)"%v ]
|
||||||
out += [ "end subroutine" ]
|
out += [ "end subroutine" ]
|
||||||
out = ["%s\n"%(x) for x in out]
|
out = map(lambda x: "%s\n"%(x),out)
|
||||||
if not same_file(FILENAME,out):
|
if not same_file(FILENAME,out):
|
||||||
file = open(FILENAME,'w')
|
file = open(FILENAME,'w')
|
||||||
file.writelines(out)
|
file.writelines(out)
|
||||||
|
113
src/makefile.py
113
src/makefile.py
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -35,15 +35,6 @@ FILENAME = "Makefile"
|
|||||||
FILENAME_GITIGNORE = ".gitignore"
|
FILENAME_GITIGNORE = ".gitignore"
|
||||||
IRPF90_MAKE = "irpf90.make"
|
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():
|
def create():
|
||||||
has_makefile = True
|
has_makefile = True
|
||||||
@ -58,7 +49,7 @@ def create():
|
|||||||
FC = gfortran
|
FC = gfortran
|
||||||
FCFLAGS= -O2 -ffree-line-length-none -I .
|
FCFLAGS= -O2 -ffree-line-length-none -I .
|
||||||
NINJA = ninja
|
NINJA = ninja
|
||||||
ARCHIVE= %s
|
AR = ar
|
||||||
RANLIB = ranlib
|
RANLIB = ranlib
|
||||||
|
|
||||||
SRC=
|
SRC=
|
||||||
@ -70,7 +61,7 @@ export
|
|||||||
|
|
||||||
%s: $(filter-out %s%%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile
|
%s: $(filter-out %s%%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile
|
||||||
\t$(IRPF90)
|
\t$(IRPF90)
|
||||||
"""%(ARCHIVE,IRPF90_MAKE,IRPF90_MAKE,irpdir)
|
"""%(IRPF90_MAKE,IRPF90_MAKE,irpdir)
|
||||||
file.write(t)
|
file.write(t)
|
||||||
file.close()
|
file.close()
|
||||||
create_gitignore()
|
create_gitignore()
|
||||||
@ -98,7 +89,7 @@ def run_ninja():
|
|||||||
def run_make():
|
def run_make():
|
||||||
from modules import modules
|
from modules import modules
|
||||||
mod = []
|
mod = []
|
||||||
for m in list(modules.values()):
|
for m in modules.values():
|
||||||
mod.append(m)
|
mod.append(m)
|
||||||
|
|
||||||
file = open(IRPF90_MAKE,'w')
|
file = open(IRPF90_MAKE,'w')
|
||||||
@ -117,41 +108,41 @@ def run_make():
|
|||||||
for m in mod:
|
for m in mod:
|
||||||
result += " %s%s.irp.F90"%(irpdir,m.filename)
|
result += " %s%s.irp.F90"%(irpdir,m.filename)
|
||||||
result += " %s%s.irp.module.F90"%(irpdir,m.filename)
|
result += " %s%s.irp.module.F90"%(irpdir,m.filename)
|
||||||
print(result, file=file)
|
print >>file, result
|
||||||
|
|
||||||
result = "OBJ_IRP = %sirp_stack.irp.o "%(irpdir)
|
result = "OBJ_IRP = %sirp_stack.irp.o "%(irpdir)
|
||||||
for m in mod:
|
for m in mod:
|
||||||
if not m.is_main:
|
if not m.is_main:
|
||||||
result += " %s%s.irp.o"%(irpdir,m.filename)
|
result += " %s%s.irp.o"%(irpdir,m.filename)
|
||||||
result += " %s%s.irp.module.o"%(irpdir,m.filename)
|
result += " %s%s.irp.module.o"%(irpdir,m.filename)
|
||||||
print(result, file=file)
|
print >>file, result
|
||||||
|
|
||||||
print("OBJ1 = $(OBJ_IRP) $(OBJ) %sirp_touches.irp.o "%(irpdir), end=' ', file=file)
|
print >>file, "OBJ1 = $(OBJ_IRP) $(OBJ) %sirp_touches.irp.o "%(irpdir),
|
||||||
# print >>file, " %sirp_checkpoint.irp.o"%(irpdir),
|
# print >>file, " %sirp_checkpoint.irp.o"%(irpdir),
|
||||||
if command_line.do_profile:
|
if command_line.do_profile:
|
||||||
print(" %sirp_profile.irp.o"%(irpdir), " irp_rdtsc.o", end=' ', file=file)
|
print >>file, " %sirp_profile.irp.o"%(irpdir), " irp_rdtsc.o",
|
||||||
if command_line.do_codelet:
|
if command_line.do_codelet:
|
||||||
print(" irp_rdtsc.o", end=' ', file=file)
|
print >>file, " irp_rdtsc.o",
|
||||||
if command_line.do_openmp:
|
if command_line.do_openmp:
|
||||||
print(" %sirp_locks.irp.o"%(irpdir), file=file)
|
print >>file, " %sirp_locks.irp.o"%(irpdir)
|
||||||
else:
|
else:
|
||||||
print("", file=file)
|
print >>file, ""
|
||||||
|
|
||||||
all = [x for x in modules if modules[x].is_main]
|
all = filter(lambda x: modules[x].is_main, modules)
|
||||||
all = [x[:-6] for x in all]
|
all = map(lambda x: x[:-6], all)
|
||||||
all_o = ["%s.irp.module.o %s.irp.o"%(x,x) for x in all]
|
all_o = map(lambda x: "%s.irp.module.o %s.irp.o"%(x,x), all)
|
||||||
print("ALL = %s"%(" ".join(all)), file=file)
|
print >>file, "ALL = %s"%(" ".join(all))
|
||||||
print("ALL_OBJ = %s"%(" ".join(all_o)), file=file)
|
print >>file, "ALL_OBJ = %s"%(" ".join(all_o))
|
||||||
print("ALL_OBJ1 = $(patsubst %%, %s%%,$(notdir $(ALL_OBJ)))"%(irpdir), file=file)
|
print >>file, "ALL_OBJ1 = $(patsubst %%, %s%%,$(notdir $(ALL_OBJ)))"%(irpdir)
|
||||||
print("all:$(ALL)", file=file)
|
print >>file, "all:$(ALL)"
|
||||||
print("\t@$(MAKE) -s move", file=file)
|
print >>file, "\t@$(MAKE) -s move"
|
||||||
# print >>file, "ifdef USE_IRPF90_A"
|
# print >>file, "ifdef USE_IRPF90_A"
|
||||||
for m in mod:
|
for m in mod:
|
||||||
if m.is_main:
|
if m.is_main:
|
||||||
exe = m.filename
|
exe = m.filename
|
||||||
print("%s: %s%s.irp.o %s%s.irp.module.o IRPF90_temp/irpf90.a"%(exe,irpdir,exe,irpdir,exe), file=file)
|
print >>file, "%s: %s%s.irp.o %s%s.irp.module.o IRPF90_temp/irpf90.a"%(exe,irpdir,exe,irpdir,exe)
|
||||||
print("\t$(FC) -o $@ %s$@.irp.o %s$@.irp.module.o IRPF90_temp/irpf90.a $(LIB)"%(irpdir,irpdir), file=file)
|
print >>file, "\t$(FC) -o $@ %s$@.irp.o %s$@.irp.module.o IRPF90_temp/irpf90.a $(LIB)"%(irpdir,irpdir)
|
||||||
print("\t@$(MAKE) -s move", file=file)
|
print >>file, "\t@$(MAKE) -s move"
|
||||||
# print >>file, "else"
|
# print >>file, "else"
|
||||||
# for m in mod:
|
# for m in mod:
|
||||||
# if m.is_main:
|
# if m.is_main:
|
||||||
@ -164,43 +155,43 @@ def run_make():
|
|||||||
buffer = ""
|
buffer = ""
|
||||||
for m in mod:
|
for m in mod:
|
||||||
filename = "%s%s.irp.o: $(OBJ) %s%s.irp.module.o"%(irpdir,m.filename,irpdir,m.filename)
|
filename = "%s%s.irp.o: $(OBJ) %s%s.irp.module.o"%(irpdir,m.filename,irpdir,m.filename)
|
||||||
needed_modules = [x for x in modules if modules[x].name in m.needed_modules]
|
needed_modules = filter( lambda x: modules[x].name in m.needed_modules, modules )
|
||||||
needed_files = [modules[x].filename for x in needed_modules]
|
needed_files = map(lambda x: modules[x].filename, needed_modules)
|
||||||
mds = [" %s%s.irp.module.o"%(irpdir,x) for x in needed_files]
|
mds = map (lambda x: " %s%s.irp.module.o"%(irpdir,x),needed_files)
|
||||||
print(filename," ".join(mds)," ".join(m.includes), file=file)
|
print >>file, filename," ".join(mds)," ".join(m.includes)
|
||||||
if not m.is_main:
|
if not m.is_main:
|
||||||
buffer += "\t - @echo '"+filename+" ".join(mds)+"' >> %sdist_Makefile\n"%(irpdir)
|
buffer += "\t - @echo '"+filename+" ".join(mds)+"' >> %sdist_Makefile\n"%(irpdir)
|
||||||
# print >>file, "%sirp_touches.irp.o %sirp_checkpoint.irp.o: $(OBJ) "%(irpdir,irpdir),
|
# print >>file, "%sirp_touches.irp.o %sirp_checkpoint.irp.o: $(OBJ) "%(irpdir,irpdir),
|
||||||
print("%sirp_touches.irp.o: $(OBJ) "%(irpdir), end=' ', file=file)
|
print >>file, "%sirp_touches.irp.o: $(OBJ) "%(irpdir),
|
||||||
mds = [x for x in mod if not x.is_main]
|
mds = filter(lambda x: not x.is_main,mod)
|
||||||
mds = [" %s%s.irp.o %s%s.irp.o"%(irpdir,x.filename,irpdir,x.filename) for x in mds]
|
mds = map(lambda x: " %s%s.irp.o %s%s.irp.o"%(irpdir,x.filename,irpdir,x.filename),mds)
|
||||||
print(" ".join(mds), file=file)
|
print >>file," ".join(mds)
|
||||||
if command_line.do_profile:
|
if command_line.do_profile:
|
||||||
print("%sirp_profile.irp.o:"%(irpdir), end=' ', file=file)
|
print >>file, "%sirp_profile.irp.o:"%(irpdir),
|
||||||
print(" ".join(mds), file=file)
|
print >>file," ".join(mds)
|
||||||
if command_line.do_openmp:
|
if command_line.do_openmp:
|
||||||
print("%sirp_locks.irp.o:"%(irpdir), end=' ', file=file)
|
print >>file, "%sirp_locks.irp.o:"%(irpdir),
|
||||||
print(" ".join(mds), file=file)
|
print >>file," ".join(mds)
|
||||||
|
|
||||||
|
|
||||||
for dir in [ irpdir ] + [irpdir+x for x in command_line.include_dir]:
|
for dir in [ irpdir ] + map(lambda x: irpdir+x, command_line.include_dir):
|
||||||
print(dir+"%.irp.module.o: $(OBJ) "+dir+"%.irp.module.F90", file=file)
|
print >>file, dir+"%.irp.module.o: $(OBJ) "+dir+"%.irp.module.F90"
|
||||||
print("\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.module.F90 -o "+dir+"$*.irp.module.o", file=file)
|
print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.module.F90 -o "+dir+"$*.irp.module.o"
|
||||||
print(dir+"%.irp.o: $(OBJ) "+dir+"%.irp.module.o "+dir+"%.irp.F90", file=file)
|
print >>file, dir+"%.irp.o: $(OBJ) "+dir+"%.irp.module.o "+dir+"%.irp.F90"
|
||||||
print("\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o", file=file)
|
print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o"
|
||||||
print(dir+"%.irp.o: $(OBJ) "+dir+"%.irp.F90", file=file)
|
print >>file, dir+"%.irp.o: $(OBJ) "+dir+"%.irp.F90"
|
||||||
print("\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o", file=file)
|
print >>file, "\t$(FC) $(FCFLAGS) -c "+dir+"$*.irp.F90 -o "+dir+"$*.irp.o"
|
||||||
print(dir+"%.o: %.F90", file=file)
|
print >>file, dir+"%.o: %.F90"
|
||||||
print("\t$(FC) $(FCFLAGS) -c $*.F90 -o "+dir+"$*.o", file=file)
|
print >>file, "\t$(FC) $(FCFLAGS) -c $*.F90 -o "+dir+"$*.o"
|
||||||
print(dir+"%.o: %.f90\n\t$(FC) $(FCFLAGS) -c $*.f90 -o "+dir+"$*.o", file=file)
|
print >>file, dir+"%.o: %.f90\n\t$(FC) $(FCFLAGS) -c $*.f90 -o "+dir+"$*.o"
|
||||||
print(dir+"%.o: %.f\n\t$(FC) $(FCFLAGS) -c $*.f -o "+dir+"$*.o", file=file)
|
print >>file, dir+"%.o: %.f\n\t$(FC) $(FCFLAGS) -c $*.f -o "+dir+"$*.o"
|
||||||
print(dir+"%.o: %.F\n\t$(FC) $(FCFLAGS) -c $*.F -o "+dir+"$*.o", file=file)
|
print >>file, dir+"%.o: %.F\n\t$(FC) $(FCFLAGS) -c $*.F -o "+dir+"$*.o"
|
||||||
print(dir+"%.irp.F90: "+IRPF90_MAKE+"\n", file=file)
|
print >>file, dir+"%.irp.F90: "+IRPF90_MAKE+"\n"
|
||||||
print("move:\n\t@mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING=\n", file=file)
|
print >>file, "move:\n\t@mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING=\n"
|
||||||
print("IRPF90_temp/irpf90.a: $(OBJ) $(OBJ1)\n\t$(ARCHIVE) IRPF90_temp/irpf90.a $(OBJ1)\n", file=file)
|
print >>file, "IRPF90_temp/irpf90.a: $(OBJ) $(OBJ1)\n\t$(AR) crf IRPF90_temp/irpf90.a $(OBJ1)\n"
|
||||||
print("clean:\n\trm -rf $(EXE) $(OBJ1) IRPF90_temp/irpf90.a $(ALL_OBJ1) $(ALL)\n", file=file)
|
print >>file, "clean:\n\trm -rf $(EXE) $(OBJ1) IRPF90_temp/irpf90.a $(ALL_OBJ1) $(ALL)\n"
|
||||||
print("veryclean:\n\t- $(MAKE) clean\n", file=file)
|
print >>file, "veryclean:\n\t- $(MAKE) clean\n"
|
||||||
print("\t- rm -rf "+irpdir+" "+mandir+" "+IRPF90_MAKE+" irpf90_entities dist tags\n", file=file)
|
print >>file, "\t- rm -rf "+irpdir+" "+mandir+" "+IRPF90_MAKE+" irpf90_entities dist tags\n"
|
||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -57,7 +57,7 @@ class Fmodule(object):
|
|||||||
|
|
||||||
def prog_name(self):
|
def prog_name(self):
|
||||||
if '_prog_name' not in self.__dict__:
|
if '_prog_name' not in self.__dict__:
|
||||||
buffer = [x for x in self.text if type(x[1]) == Program]
|
buffer = filter(lambda x: type(x[1]) == Program,self.text)
|
||||||
if buffer == []:
|
if buffer == []:
|
||||||
self._prog_name = None
|
self._prog_name = None
|
||||||
else:
|
else:
|
||||||
@ -69,7 +69,7 @@ class Fmodule(object):
|
|||||||
if '_variables' not in self.__dict__:
|
if '_variables' not in self.__dict__:
|
||||||
from variables import variables
|
from variables import variables
|
||||||
name = self.name
|
name = self.name
|
||||||
self._variables = [x for x in variables if variables[x].fmodule == name]
|
self._variables = filter(lambda x: variables[x].fmodule == name, variables)
|
||||||
return self._variables
|
return self._variables
|
||||||
variables = property(variables)
|
variables = property(variables)
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ class Fmodule(object):
|
|||||||
result = [ "module %s"%(self.name) ]
|
result = [ "module %s"%(self.name) ]
|
||||||
result += self.use
|
result += self.use
|
||||||
result += self.dec
|
result += self.dec
|
||||||
result += flatten( [variables[x].header for x in self.variables] )
|
result += flatten( map(lambda x: variables[x].header,self.variables) )
|
||||||
result.append( "end module %s"%(self.name) )
|
result.append( "end module %s"%(self.name) )
|
||||||
self._head = result
|
self._head = result
|
||||||
return self._head
|
return self._head
|
||||||
@ -87,7 +87,7 @@ class Fmodule(object):
|
|||||||
|
|
||||||
def needed_vars(self):
|
def needed_vars(self):
|
||||||
if '_needed_vars' not in self.__dict__:
|
if '_needed_vars' not in self.__dict__:
|
||||||
result = [variables[x].needs for x in self.variables]
|
result = map(lambda x: variables[x].needs,self.variables)
|
||||||
result = make_single ( flatten(result) )
|
result = make_single ( flatten(result) )
|
||||||
self._needed_vars = result
|
self._needed_vars = result
|
||||||
return self._needed_vars
|
return self._needed_vars
|
||||||
@ -140,7 +140,7 @@ class Fmodule(object):
|
|||||||
if type(line) in [ Subroutine, Function ]:
|
if type(line) in [ Subroutine, Function ]:
|
||||||
variable_list = list(vars)
|
variable_list = list(vars)
|
||||||
elif type(line) == End:
|
elif type(line) == End:
|
||||||
result += [([],Use(line.i,x,line.filename)) for x in build_use(variable_list)]
|
result += map(lambda x: ([],Use(line.i,x,line.filename)), build_use(variable_list))
|
||||||
else:
|
else:
|
||||||
variable_list += vars
|
variable_list += vars
|
||||||
result.append( (vars,line) )
|
result.append( (vars,line) )
|
||||||
@ -169,21 +169,21 @@ class Fmodule(object):
|
|||||||
result = []
|
result = []
|
||||||
for vars,line in text:
|
for vars,line in text:
|
||||||
result.append( ([],line) )
|
result.append( ([],line) )
|
||||||
result += [([],Simple_line(line.i,x,line.filename)) for x in call_provides(vars)]
|
result += map(lambda x: ([],Simple_line(line.i,x,line.filename)), call_provides(vars))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
result = remove_providers(self.text)
|
result = remove_providers(self.text)
|
||||||
result = modify_functions(result)
|
result = modify_functions(result)
|
||||||
use,dec,result = extract_use_dec_text(result)
|
use,dec,result = extract_use_dec_text(result)
|
||||||
self._use = make_single([" "+x[1].text for x in use])
|
self._use = make_single(map(lambda x: " "+x[1].text, use))
|
||||||
self._dec = [" "+x[1].text for x in dec]
|
self._dec = map(lambda x: " "+x[1].text, dec)
|
||||||
# self._dec = make_single(map(lambda x: " "+x[1].text, dec))
|
# self._dec = make_single(map(lambda x: " "+x[1].text, dec))
|
||||||
result = provide_variables(result)
|
result = provide_variables(result)
|
||||||
result = move_to_top(result,Declaration)
|
result = move_to_top(result,Declaration)
|
||||||
result = move_to_top(result,Implicit)
|
result = move_to_top(result,Implicit)
|
||||||
result = move_to_top(result,Use)
|
result = move_to_top(result,Use)
|
||||||
result = [x[1] for x in result]
|
result = map(lambda x: x[1], result)
|
||||||
result = [x.text for x in result]
|
result = map(lambda x: x.text, result)
|
||||||
self._residual_text = result
|
self._residual_text = result
|
||||||
return self._residual_text
|
return self._residual_text
|
||||||
residual_text = property(residual_text)
|
residual_text = property(residual_text)
|
||||||
@ -203,9 +203,10 @@ class Fmodule(object):
|
|||||||
|
|
||||||
def needed_modules(self):
|
def needed_modules(self):
|
||||||
if '_needed_modules' not in self.__dict__:
|
if '_needed_modules' not in self.__dict__:
|
||||||
buffer = [x for x in self.generated_text+self.head+self.residual_text if x.lstrip().startswith("use ")]
|
buffer = filter(lambda x: x.lstrip().startswith("use "), \
|
||||||
buffer = [x.split()[1] for x in buffer]
|
self.generated_text+self.head+self.residual_text)
|
||||||
buffer = [x for x in buffer if x.endswith("_mod")]
|
buffer = map(lambda x: x.split()[1], buffer)
|
||||||
|
buffer = filter(lambda x: x.endswith("_mod"),buffer )
|
||||||
self._needed_modules = make_single(buffer)
|
self._needed_modules = make_single(buffer)
|
||||||
if self.name in self._needed_modules:
|
if self.name in self._needed_modules:
|
||||||
self._needed_modules.remove(self.name)
|
self._needed_modules.remove(self.name)
|
||||||
@ -221,6 +222,6 @@ if __name__ == '__main__':
|
|||||||
x = Fmodule(text,filename)
|
x = Fmodule(text,filename)
|
||||||
break
|
break
|
||||||
for line in x.head:
|
for line in x.head:
|
||||||
print(line)
|
print line
|
||||||
print(x.includes)
|
print x.includes
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -44,7 +44,7 @@ def write_module(m):
|
|||||||
# Module data
|
# Module data
|
||||||
filename = irpdir+m.filename+".irp.module.F90"
|
filename = irpdir+m.filename+".irp.module.F90"
|
||||||
text = m.header + m.head
|
text = m.header + m.head
|
||||||
text = ["%s\n"%(x) for x in text]
|
text = map(lambda x: "%s\n"%(x),text)
|
||||||
if not same_file(filename,text):
|
if not same_file(filename,text):
|
||||||
# print filename
|
# print filename
|
||||||
file = open(filename,"w")
|
file = open(filename,"w")
|
||||||
@ -54,7 +54,7 @@ def write_module(m):
|
|||||||
# Subroutines
|
# Subroutines
|
||||||
filename = irpdir+m.filename+".irp.F90"
|
filename = irpdir+m.filename+".irp.F90"
|
||||||
text = m.header + m.generated_text + m.residual_text
|
text = m.header + m.generated_text + m.residual_text
|
||||||
text = ["%s\n"%(x) for x in text]
|
text = map(lambda x: "%s\n"%(x),text)
|
||||||
if not same_file(filename,text):
|
if not same_file(filename,text):
|
||||||
# print filename
|
# print filename
|
||||||
file = open(filename,"w")
|
file = open(filename,"w")
|
||||||
|
41
src/ninja.py
41
src/ninja.py
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -39,14 +39,6 @@ cwd = os.getcwd()
|
|||||||
|
|
||||||
PRINT_WIDTH=50
|
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):
|
def dress(f,in_root=False):
|
||||||
"""
|
"""
|
||||||
Transfoms the filename f into $PWD/IRPF90_temp/f
|
Transfoms the filename f into $PWD/IRPF90_temp/f
|
||||||
@ -55,8 +47,7 @@ def dress(f,in_root=False):
|
|||||||
result = os.path.join(cwd,f)
|
result = os.path.join(cwd,f)
|
||||||
else:
|
else:
|
||||||
result = os.path.join(cwd,irpdir,f)
|
result = os.path.join(cwd,irpdir,f)
|
||||||
result = os.path.normpath(result)
|
return os.path.normpath(result)
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def create_build_touches(list_of_other_o):
|
def create_build_touches(list_of_other_o):
|
||||||
@ -73,7 +64,7 @@ def create_build_touches(list_of_other_o):
|
|||||||
|
|
||||||
needed_modules = [ "%s.irp.module.o"%(modules[x].filename) for x in modules ]
|
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 = map(dress, needed_modules) + list_of_other_o
|
||||||
list_of_modules = ' '.join(list_of_modules)
|
list_of_modules = ' '.join(list_of_modules)
|
||||||
|
|
||||||
result = '\n'.join(
|
result = '\n'.join(
|
||||||
@ -122,10 +113,10 @@ def create_build_target(t,list_of_other_o):
|
|||||||
list_of_o = [ target_o, target_module_o, irp_lib ]
|
list_of_o = [ target_o, target_module_o, irp_lib ]
|
||||||
list_of_o = ' '.join(list_of_o)
|
list_of_o = ' '.join(list_of_o)
|
||||||
|
|
||||||
list_of_modules = list(map(dress, needed_modules)) + list_of_other_o
|
list_of_modules = map(dress, needed_modules) + list_of_other_o
|
||||||
list_of_modules = ' '.join(list_of_modules)
|
list_of_modules = ' '.join(list_of_modules)
|
||||||
|
|
||||||
list_of_includes = ' '.join([dress(x,in_root=True) for x in t.includes])
|
list_of_includes = ' '.join(map(lambda x: dress(x,in_root=True), t.includes))
|
||||||
|
|
||||||
result = '\n'.join(
|
result = '\n'.join(
|
||||||
[ "build {target}: link_{id} {list_of_o}",
|
[ "build {target}: link_{id} {list_of_o}",
|
||||||
@ -179,10 +170,10 @@ def create_build_non_target(t,list_of_other_o):
|
|||||||
needed_modules = [ "%s.irp.module.o"%(modules[x].filename) for x in modules \
|
needed_modules = [ "%s.irp.module.o"%(modules[x].filename) for x in modules \
|
||||||
if modules[x].name in t.needed_modules ] + [ target_module_o ]
|
if modules[x].name in t.needed_modules ] + [ target_module_o ]
|
||||||
|
|
||||||
list_of_modules = list(map(dress, needed_modules))
|
list_of_modules = map(dress, needed_modules)
|
||||||
list_of_modules = ' '.join(list_of_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_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])
|
list_of_includes = ' '.join(map(lambda x: dress(x,in_root=True), t.includes))
|
||||||
|
|
||||||
result = '\n'.join(
|
result = '\n'.join(
|
||||||
[
|
[
|
||||||
@ -280,8 +271,8 @@ def run():
|
|||||||
try: FC = os.environ["FC"]
|
try: FC = os.environ["FC"]
|
||||||
except KeyError: FC="gfortran -ffree-line-length-none"
|
except KeyError: FC="gfortran -ffree-line-length-none"
|
||||||
|
|
||||||
try: ARCHIVE = os.environ["ARCHIVE"]
|
try: AR = os.environ["AR"]
|
||||||
except KeyError: ARCHIVE=AR
|
except KeyError: AR="ar"
|
||||||
|
|
||||||
try: CC = os.environ["CC"]
|
try: CC = os.environ["CC"]
|
||||||
except KeyError: CC="gcc"
|
except KeyError: CC="gcc"
|
||||||
@ -338,14 +329,14 @@ def run():
|
|||||||
" description = C++ : $short_in -> $short_out",
|
" description = C++ : $short_in -> $short_out",
|
||||||
"",
|
"",
|
||||||
"rule link_lib_{id}",
|
"rule link_lib_{id}",
|
||||||
" command = {ARCHIVE} $out $in" ,
|
" command = {AR} crf $out $in" ,
|
||||||
" description = Link: $short_out",
|
" description = Link: $short_out",
|
||||||
"",
|
"",
|
||||||
"rule link_{id}",
|
"rule link_{id}",
|
||||||
" command = {FC} $in {LIB} -o $out" ,
|
" command = {FC} $in {LIB} -o $out" ,
|
||||||
" description = Link: $short_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) ]
|
output += [ '\n'.join(t).format(id=irp_id, FC=FC, FCFLAGS=FCFLAGS, LIB=LIB, CXX=CXX, CXXFLAGS=CXXFLAGS, CC=CC, CFLAGS=CFLAGS, AR=AR) ]
|
||||||
|
|
||||||
|
|
||||||
# All modules : list of Fmodule objects
|
# All modules : list of Fmodule objects
|
||||||
@ -381,8 +372,8 @@ def run():
|
|||||||
l_common_o += [ "irp_profile.irp.o", "irp_rdtsc.o" ]
|
l_common_o += [ "irp_profile.irp.o", "irp_rdtsc.o" ]
|
||||||
l_common_s += [ "irp_profile.irp.F90", "irp_rdtsc.c" ]
|
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_o = map(dress,l_common_o) + map(lambda x: dress(x,in_root=True), OBJ)
|
||||||
l_common_s = list(map(dress,l_common_s)) + [dress(x,in_root=True) for x in SRC]
|
l_common_s = map(dress,l_common_s) + map(lambda x: dress(x,in_root=True), SRC)
|
||||||
|
|
||||||
|
|
||||||
# IRP_touches
|
# IRP_touches
|
||||||
@ -406,12 +397,8 @@ def run():
|
|||||||
output.append(create_build_remaining(i))
|
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:
|
with open(FILENAME,'w') as f:
|
||||||
f.write("X="+cwd+"\nT="+cwd+"/IRPF90_temp\n")
|
f.write('\n\n'.join(output))
|
||||||
f.write(text)
|
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
|
|
||||||
create_irpf90_make([ x.filename for x in l_targets ] + [ os.path.join(irpdir,'irpf90.a') ] )
|
create_irpf90_make([ x.filename for x in l_targets ] + [ os.path.join(irpdir,'irpf90.a') ] )
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -33,9 +33,9 @@ from subroutines import subroutines
|
|||||||
import regexps, re
|
import regexps, re
|
||||||
import error
|
import error
|
||||||
|
|
||||||
vtuple = [(v, variables[v].same_as, variables[v].regexp) for v in list(variables.keys())]
|
vtuple = map(lambda v: (v, variables[v].same_as, variables[v].regexp), variables.keys())
|
||||||
stuple = [(s, subroutines[s].regexp) for s in list(subroutines.keys())]
|
stuple = map(lambda s: (s, subroutines[s].regexp), subroutines.keys())
|
||||||
stuple = [s for s in stuple if subroutines[s[0]].is_function]
|
stuple = filter(lambda s: subroutines[s[0]].is_function, stuple)
|
||||||
re_string_sub = regexps.re_string.sub
|
re_string_sub = regexps.re_string.sub
|
||||||
|
|
||||||
regexps_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,))
|
error.fail(line,"Variable %s unknown"%(main_var,))
|
||||||
x = variables[main_var]
|
x = variables[main_var]
|
||||||
return [main_var]+x.others
|
return [main_var]+x.others
|
||||||
all_others = make_single(flatten( list(map(fun,main_vars)) ))
|
all_others = make_single(flatten( map(fun,main_vars) ))
|
||||||
all_others.sort()
|
all_others.sort()
|
||||||
vars.sort()
|
vars.sort()
|
||||||
for x,y in zip(vars,all_others):
|
for x,y in zip(vars,all_others):
|
||||||
if x != y:
|
if x != y:
|
||||||
message = "The following entities should be touched:\n"
|
message = "The following entities should be touched:\n"
|
||||||
message = "\n".join([message]+["- %s"%(x,) for x in all_others])
|
message = "\n".join([message]+map(lambda x: "- %s"%(x,),all_others))
|
||||||
error.fail(line,message)
|
error.fail(line,message)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
def update_variables():
|
def update_variables():
|
||||||
for filename,text in preprocessed_text:
|
for filename,text in preprocessed_text:
|
||||||
|
|
||||||
for line in [x for x in text if type(x) in [ Touch, SoftTouch ]]:
|
for line in filter(lambda x: type(x) in [ Touch, SoftTouch ], text):
|
||||||
vars = line.lower.split()
|
vars = line.lower.split()
|
||||||
if len(vars) < 2:
|
if len(vars) < 2:
|
||||||
error.fail(line,"Syntax error")
|
error.fail(line,"Syntax error")
|
||||||
@ -101,7 +101,7 @@ def update_variables():
|
|||||||
error.fail(line,"Variable %s unknown"%(v,))
|
error.fail(line,"Variable %s unknown"%(v,))
|
||||||
variables[v]._is_touched = True
|
variables[v]._is_touched = True
|
||||||
|
|
||||||
for line in [x for x in text if type(x) == Free]:
|
for line in filter(lambda x: type(x) == Free,text):
|
||||||
vars = line.lower.split()
|
vars = line.lower.split()
|
||||||
if len(vars) < 2:
|
if len(vars) < 2:
|
||||||
error.fail(line,"Syntax error")
|
error.fail(line,"Syntax error")
|
||||||
@ -110,10 +110,10 @@ def update_variables():
|
|||||||
error.fail(line,"Variable %s unknown"%(v,))
|
error.fail(line,"Variable %s unknown"%(v,))
|
||||||
variables[v].is_freed = True
|
variables[v].is_freed = True
|
||||||
|
|
||||||
for line in [x for x in text if type(x) == Irp_read]:
|
for line in filter(lambda x: type(x) == Irp_read,text):
|
||||||
variables[line.filename]._is_read = True
|
variables[line.filename]._is_read = True
|
||||||
|
|
||||||
for line in [x for x in text if type (x) == Irp_write]:
|
for line in filter(lambda x: type (x) == Irp_write,text):
|
||||||
variables[line.filename]._is_written = True
|
variables[line.filename]._is_written = True
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -148,7 +148,7 @@ def get_parsed_text():
|
|||||||
elif type(line) in [ Begin_provider, Cont_provider ]:
|
elif type(line) in [ Begin_provider, Cont_provider ]:
|
||||||
if type(line) == Begin_provider:
|
if type(line) == Begin_provider:
|
||||||
varlist = []
|
varlist = []
|
||||||
buffer = list(map(strip,line.lower.replace(']','').split(',')))
|
buffer = map(strip,line.lower.replace(']','').split(','))
|
||||||
assert len(buffer) > 1
|
assert len(buffer) > 1
|
||||||
v = buffer[1]
|
v = buffer[1]
|
||||||
varlist.append(v)
|
varlist.append(v)
|
||||||
@ -156,7 +156,7 @@ def get_parsed_text():
|
|||||||
try:
|
try:
|
||||||
variable_list.remove(variables[v].same_as)
|
variable_list.remove(variables[v].same_as)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print(v, variables[v].same_as)
|
print v, variables[v].same_as
|
||||||
raise
|
raise
|
||||||
append( (variable_list,line) )
|
append( (variable_list,line) )
|
||||||
elif type(line) == End_provider:
|
elif type(line) == End_provider:
|
||||||
@ -164,7 +164,7 @@ def get_parsed_text():
|
|||||||
append( ([],line) )
|
append( ([],line) )
|
||||||
elif type(line) == Provide:
|
elif type(line) == Provide:
|
||||||
l = line.lower.split()[1:]
|
l = line.lower.split()[1:]
|
||||||
l = [x for x in l if x not in varlist]
|
l = filter(lambda x: x not in varlist, l)
|
||||||
for v in l:
|
for v in l:
|
||||||
if v not in variables:
|
if v not in variables:
|
||||||
error.fail(line,"Variable %s is unknown"%(v))
|
error.fail(line,"Variable %s is unknown"%(v))
|
||||||
@ -175,7 +175,7 @@ def get_parsed_text():
|
|||||||
for v in l:
|
for v in l:
|
||||||
if v not in variables:
|
if v not in variables:
|
||||||
error.fail(line,"Variable %s is unknown"%(v))
|
error.fail(line,"Variable %s is unknown"%(v))
|
||||||
l = ["-%s"%(x) for x in l]
|
l = map(lambda x: "-%s"%(x), l)
|
||||||
append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
||||||
elif type(line) in [ Touch, SoftTouch ]:
|
elif type(line) in [ Touch, SoftTouch ]:
|
||||||
vars = line.lower.split()
|
vars = line.lower.split()
|
||||||
@ -185,7 +185,7 @@ def get_parsed_text():
|
|||||||
def fun(x):
|
def fun(x):
|
||||||
main = variables[x].same_as
|
main = variables[x].same_as
|
||||||
return main
|
return main
|
||||||
main_vars = make_single( list(map(fun, vars)) )
|
main_vars = make_single( map(fun, vars) )
|
||||||
check_touch(line,vars,main_vars)
|
check_touch(line,vars,main_vars)
|
||||||
txt = " ".join(vars)
|
txt = " ".join(vars)
|
||||||
append ( (vars,Simple_line(line.i,"!",line.filename)) )
|
append ( (vars,Simple_line(line.i,"!",line.filename)) )
|
||||||
@ -195,19 +195,19 @@ def get_parsed_text():
|
|||||||
error.fail(line,"Variable %s unknown"%(x,))
|
error.fail(line,"Variable %s unknown"%(x,))
|
||||||
return [ ([],Simple_line(line.i," call touch_%s"%(x,),line.filename)),
|
return [ ([],Simple_line(line.i," call touch_%s"%(x,),line.filename)),
|
||||||
([],Use(line.i," use %s"%(variables[x].fmodule), line.filename)) ]
|
([],Use(line.i," use %s"%(variables[x].fmodule), line.filename)) ]
|
||||||
result += flatten(list(map( fun, main_vars )))
|
result += flatten(map( fun, main_vars ))
|
||||||
def fun(x):
|
def fun(x):
|
||||||
if x not in variables:
|
if x not in variables:
|
||||||
error.fail(line,"Variable %s unknown"%(x,))
|
error.fail(line,"Variable %s unknown"%(x,))
|
||||||
return ([],Simple_line(line.i," %s_is_built = .True."%(x,),line.filename))
|
return ([],Simple_line(line.i," %s_is_built = .True."%(x,),line.filename))
|
||||||
result += list(map( fun, main_vars[:-1] ))
|
result += map( fun, main_vars[:-1] )
|
||||||
if type(line) == SoftTouch:
|
if type(line) == SoftTouch:
|
||||||
append ( ([],Simple_line(line.i,"! <<< END TOUCH (Soft)",line.filename)) )
|
append ( ([],Simple_line(line.i,"! <<< END TOUCH (Soft)",line.filename)) )
|
||||||
else:
|
else:
|
||||||
append ( ([],Provide_all(line.i,"! <<< END TOUCH",line.filename)) )
|
append ( ([],Provide_all(line.i,"! <<< END TOUCH",line.filename)) )
|
||||||
elif type(line) == Call:
|
elif type(line) == Call:
|
||||||
l = find_variables_in_line(line)
|
l = find_variables_in_line(line)
|
||||||
l = [x for x in l if x not in varlist]
|
l = filter(lambda x: x not in varlist, l)
|
||||||
sub = find_subroutine_in_line(line)
|
sub = find_subroutine_in_line(line)
|
||||||
if sub not in subroutines:
|
if sub not in subroutines:
|
||||||
t = Simple_line
|
t = Simple_line
|
||||||
@ -220,10 +220,12 @@ def get_parsed_text():
|
|||||||
vars = line.lower.split()
|
vars = line.lower.split()
|
||||||
vars = vars[1:]
|
vars = vars[1:]
|
||||||
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
||||||
use = [" use %s"%(variables[x].fmodule) for x in vars]
|
use = map(lambda x: " use %s"%(variables[x].fmodule),vars)
|
||||||
for var in vars:
|
for var in vars:
|
||||||
result += [([],Use(line.i,x,line.filename)) for x in make_single(use)]
|
result += map(lambda x: ([],Use(line.i,x,line.filename)),
|
||||||
result += [([],Simple_line(line.i,x,line.filename)) for x in variables[var].free]
|
make_single(use))
|
||||||
|
result += map(lambda x: ([],Simple_line(line.i,x,line.filename)),
|
||||||
|
variables[var].free)
|
||||||
elif type(line) == Irp_read:
|
elif type(line) == Irp_read:
|
||||||
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
||||||
elif type(line) == Irp_write:
|
elif type(line) == Irp_write:
|
||||||
@ -232,14 +234,14 @@ def get_parsed_text():
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
l = find_variables_in_line(line)
|
l = find_variables_in_line(line)
|
||||||
l = [x for x in l if x not in varlist]
|
l = filter(lambda x: x not in varlist, l)
|
||||||
append( (l,line) )
|
append( (l,line) )
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# Remove duplicates
|
#main_result = []
|
||||||
global preprocessed_text
|
#for filename,text in preprocessed_text:
|
||||||
d = dict(preprocessed_text)
|
# main_result.append( (filename, func(filename,text)) )
|
||||||
preprocessed_text = [ (k,d[k]) for k in d.keys() ]
|
#return main_result
|
||||||
return parallel_loop(func,preprocessed_text)
|
return parallel_loop(func,preprocessed_text)
|
||||||
|
|
||||||
update_variables()
|
update_variables()
|
||||||
@ -363,7 +365,7 @@ def move_variables():
|
|||||||
elif type(line) in [ If, Select ]:
|
elif type(line) in [ If, Select ]:
|
||||||
ifvars += list(varlist)
|
ifvars += list(varlist)
|
||||||
append( (varlist,line) )
|
append( (varlist,line) )
|
||||||
vars += [x for x in ifvars if x in elsevars]
|
vars += filter(lambda x: x in elsevars, ifvars)
|
||||||
ifvars = old_ifvars.pop()
|
ifvars = old_ifvars.pop()
|
||||||
elsevars = old_elsevars.pop()
|
elsevars = old_elsevars.pop()
|
||||||
varlist = old_varlist.pop() + vars
|
varlist = old_varlist.pop() + vars
|
||||||
@ -399,13 +401,13 @@ def move_variables():
|
|||||||
varlist = list(vars)
|
varlist = list(vars)
|
||||||
elif type(line) in [ If, Select ]:
|
elif type(line) in [ If, Select ]:
|
||||||
old_varlist.append(varlist)
|
old_varlist.append(varlist)
|
||||||
vars = [x for x in vars if x not in varlist]
|
vars = filter(lambda x: x not in varlist,vars)
|
||||||
varlist = make_single(varlist + vars)
|
varlist = make_single(varlist + vars)
|
||||||
assert old_varlist is not varlist
|
assert old_varlist is not varlist
|
||||||
elif type(line) in [ Elseif, Else, Case ]:
|
elif type(line) in [ Elseif, Else, Case ]:
|
||||||
varlist = old_varlist.pop()
|
varlist = old_varlist.pop()
|
||||||
old_varlist.append(varlist)
|
old_varlist.append(varlist)
|
||||||
vars = [x for x in vars if x not in varlist]
|
vars = filter(lambda x: x not in varlist,vars)
|
||||||
varlist = make_single(varlist + vars)
|
varlist = make_single(varlist + vars)
|
||||||
assert old_varlist is not varlist
|
assert old_varlist is not varlist
|
||||||
elif type(line) in [ Endif, End_select ]:
|
elif type(line) in [ Endif, End_select ]:
|
||||||
@ -424,11 +426,11 @@ def move_variables():
|
|||||||
error.fail(line,"Unable to parse file")
|
error.fail(line,"Unable to parse file")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# main_result = []
|
main_result = []
|
||||||
# for filename,text in parsed_text:
|
for filename,text in parsed_text:
|
||||||
# main_result.append( (filename, func(filename,text)) )
|
main_result.append( (filename, func(filename,text)) )
|
||||||
# return main_result
|
return main_result
|
||||||
return parallel_loop(func,parsed_text)
|
#return parallel_loop(func,parsed_text)
|
||||||
|
|
||||||
parsed_text = move_variables()
|
parsed_text = move_variables()
|
||||||
|
|
||||||
@ -439,7 +441,7 @@ def build_needs():
|
|||||||
var = None
|
var = None
|
||||||
for vars,line in text:
|
for vars,line in text:
|
||||||
if type(line) == Begin_provider:
|
if type(line) == Begin_provider:
|
||||||
buffer = list(map(strip,line.lower.replace(']',',').split(',')))
|
buffer = map(strip,line.lower.replace(']',',').split(','))
|
||||||
var = variables[buffer[1]]
|
var = variables[buffer[1]]
|
||||||
var.needs = []
|
var.needs = []
|
||||||
var.to_provide = vars
|
var.to_provide = vars
|
||||||
@ -508,9 +510,9 @@ def check_opt():
|
|||||||
for vars,line in text:
|
for vars,line in text:
|
||||||
if not type(line) == Provide_all:
|
if not type(line) == Provide_all:
|
||||||
if do_level > 0 and vars != []:
|
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:
|
for v in vars:
|
||||||
print(" PROVIDE ",v)
|
print " PROVIDE ",v
|
||||||
if type(line) == Do:
|
if type(line) == Do:
|
||||||
do_level += 1
|
do_level += 1
|
||||||
elif type(line) == Enddo:
|
elif type(line) == Enddo:
|
||||||
@ -525,7 +527,7 @@ def perform_loop_substitutions():
|
|||||||
append = result.append
|
append = result.append
|
||||||
for vars,line in text:
|
for vars,line in text:
|
||||||
if type(line) in [ Do, If, Elseif ] :
|
if type(line) in [ Do, If, Elseif ] :
|
||||||
for k,v in list(command_line.substituted.items()):
|
for k,v in command_line.substituted.items():
|
||||||
reg = v[1]
|
reg = v[1]
|
||||||
while reg.search(line.text) is not None:
|
while reg.search(line.text) is not None:
|
||||||
line.text = re.sub(reg,r'\1%s\3', line.text,count=1)%v[0]
|
line.text = re.sub(reg,r'\1%s\3', line.text,count=1)%v[0]
|
||||||
@ -539,9 +541,9 @@ parsed_text = perform_loop_substitutions()
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
for i in range(len(parsed_text)):
|
for i in range(len(parsed_text)):
|
||||||
if parsed_text[i][0] == sys.argv[1]:
|
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]:
|
for line in parsed_text[i][1]:
|
||||||
print(line[1])
|
print line[1]
|
||||||
print(line[0], line[1].filename)
|
print line[0], line[1].filename
|
||||||
#for i in subroutines:
|
#for i in subroutines:
|
||||||
# print i, subroutines[i].needs, subroutines[i].to_provide
|
# print i, subroutines[i].needs, subroutines[i].to_provide
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -263,7 +263,7 @@ def execute_templates(text):
|
|||||||
fail(line,"Subst","Syntax error")
|
fail(line,"Subst","Syntax error")
|
||||||
buffer = buffer[1].replace(']','')
|
buffer = buffer[1].replace(']','')
|
||||||
buffer = buffer.split(',')
|
buffer = buffer.split(',')
|
||||||
return ['$%s'%(x.strip()) for x in buffer]
|
return map(lambda x: '$%s'%(x.strip()), buffer)
|
||||||
|
|
||||||
TEMPLATE = 1
|
TEMPLATE = 1
|
||||||
SUBST = 2
|
SUBST = 2
|
||||||
@ -301,7 +301,7 @@ def execute_templates(text):
|
|||||||
if subst[-2:] == ';;':
|
if subst[-2:] == ';;':
|
||||||
subst = subst[:-2]
|
subst = subst[:-2]
|
||||||
for s in subst.split(';;'):
|
for s in subst.split(';;'):
|
||||||
buffer = [x.strip() for x in s.split(';')]
|
buffer = map(lambda x: x.strip(), s.split(';'))
|
||||||
if len(buffer) != len(variables):
|
if len(buffer) != len(variables):
|
||||||
fail(line,"subst","%d variables defined, and %d substitutions"%(len(variables),len(buffer)))
|
fail(line,"subst","%d variables defined, and %d substitutions"%(len(variables),len(buffer)))
|
||||||
script += "v.append( { \\\n"
|
script += "v.append( { \\\n"
|
||||||
@ -311,7 +311,7 @@ def execute_templates(text):
|
|||||||
script += "for d in v:\n t0 = str(template)\n"
|
script += "for d in v:\n t0 = str(template)\n"
|
||||||
for v in variables:
|
for v in variables:
|
||||||
script += " t0 = t0.replace('%s',d['%s'])\n"%(v,v)
|
script += " t0 = t0.replace('%s',d['%s'])\n"%(v,v)
|
||||||
script += " print(t0)\n"
|
script += " print t0\n"
|
||||||
# Write script file
|
# Write script file
|
||||||
scriptname = "%s%s_template_%d"%(irpdir,line.filename,line.i)
|
scriptname = "%s%s_template_%d"%(irpdir,line.filename,line.i)
|
||||||
file = open(scriptname,'w')
|
file = open(scriptname,'w')
|
||||||
@ -323,7 +323,7 @@ def execute_templates(text):
|
|||||||
file.close()
|
file.close()
|
||||||
# Execute shell
|
# Execute shell
|
||||||
import os
|
import os
|
||||||
pipe = os.popen("python3 < %s"%(scriptname),'r')
|
pipe = os.popen("python2 < %s"%(scriptname),'r')
|
||||||
lines = pipe.readlines()
|
lines = pipe.readlines()
|
||||||
pipe.close()
|
pipe.close()
|
||||||
result += get_text(lines,scriptname)
|
result += get_text(lines,scriptname)
|
||||||
@ -689,7 +689,7 @@ def change_includes(text):
|
|||||||
if type(line) == Include:
|
if type(line) == Include:
|
||||||
txt = line.text.replace('"',"'").split("'")
|
txt = line.text.replace('"',"'").split("'")
|
||||||
if len(txt) != 3:
|
if len(txt) != 3:
|
||||||
print(txt)
|
print txt
|
||||||
error.fail(line,"Error in include statement")
|
error.fail(line,"Error in include statement")
|
||||||
directory = (("./"+line.filename).rsplit('/',1)[0]+'/')[2:]
|
directory = (("./"+line.filename).rsplit('/',1)[0]+'/')[2:]
|
||||||
if directory == "":
|
if directory == "":
|
||||||
@ -793,7 +793,7 @@ def check_begin_end(text):
|
|||||||
filter_line = lambda line: type(line) in [ Do, Enddo, If, Endif, \
|
filter_line = lambda line: type(line) in [ Do, Enddo, If, Endif, \
|
||||||
Program, Begin_provider, End_provider, \
|
Program, Begin_provider, End_provider, \
|
||||||
Subroutine, Function, End, Begin_doc, End_doc ]
|
Subroutine, Function, End, Begin_doc, End_doc ]
|
||||||
text = list(filter(filter_line, text))
|
text = filter(filter_line, text)
|
||||||
|
|
||||||
d = { 'do' : Do, 'enddo': Enddo,
|
d = { 'do' : Do, 'enddo': Enddo,
|
||||||
'if' : If, 'endif': Endif,
|
'if' : If, 'endif': Endif,
|
||||||
@ -911,16 +911,16 @@ def create_preprocessed_text(filename):
|
|||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
preprocessed_text = parallel_loop( lambda x,y: create_preprocessed_text(x), \
|
preprocessed_text = parallel_loop( lambda x,y: create_preprocessed_text(x), \
|
||||||
[(x,None) for x in irpf90_files] )
|
map(lambda x: (x,None), irpf90_files ) )
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def debug():
|
def debug():
|
||||||
for filename, txt in preprocessed_text:
|
for filename, txt in preprocessed_text:
|
||||||
if filename == 'invert.irp.f':
|
if filename == 'invert.irp.f':
|
||||||
print("=== "+filename+" ===")
|
print "=== "+filename+" ==="
|
||||||
for line in txt:
|
for line in txt:
|
||||||
print(line)
|
print line
|
||||||
print(irpf90_files)
|
print irpf90_files
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
debug()
|
debug()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -46,13 +46,12 @@ re_decl = re.compile( "".join( [ r"^\ *",
|
|||||||
r"|intrinsic *(::)?",
|
r"|intrinsic *(::)?",
|
||||||
r"|external *(::)?",
|
r"|external *(::)?",
|
||||||
r"|equivalence *(::)?",
|
r"|equivalence *(::)?",
|
||||||
r"|type *\(",
|
r"|type",
|
||||||
r"|type +",
|
|
||||||
r"|end ?type",
|
r"|end ?type",
|
||||||
r")[^=(]"
|
r")[^=(]"
|
||||||
] ) )
|
] ) )
|
||||||
|
|
||||||
re_test = re.compile(r"\( *(.*)(\.[a-zA-Z]*\.|[<>]=?|[=/]=)([^=]*)\)")
|
re_test = re.compile(r"\( *(.*)(\.[a-zA-Z]*\.|[<>]=?|[=/]=)([^=]*)\)")
|
||||||
|
|
||||||
re_string = re.compile(r"'.*?'|\".*?\"")
|
re_string = re.compile(r"'.*?'")
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -58,8 +58,8 @@ class Sub(object):
|
|||||||
def doc(self):
|
def doc(self):
|
||||||
if '_doc' not in self.__dict__:
|
if '_doc' not in self.__dict__:
|
||||||
def f(l): return
|
def f(l): return
|
||||||
buffer = [l for l in self.text if type(l) == Doc]
|
buffer = filter(lambda l:type(l) == Doc, self.text)
|
||||||
self._doc = [l.text.lstrip()[1:] for l in buffer]
|
self._doc = map(lambda l: l.text.lstrip()[1:], buffer)
|
||||||
if buffer == []:
|
if buffer == []:
|
||||||
error.warn(None,"Subroutine %s is not documented"%(self.name))
|
error.warn(None,"Subroutine %s is not documented"%(self.name))
|
||||||
return self._doc
|
return self._doc
|
||||||
@ -77,7 +77,7 @@ class Sub(object):
|
|||||||
if '_touches' not in self.__dict__:
|
if '_touches' not in self.__dict__:
|
||||||
from subroutines import subroutines
|
from subroutines import subroutines
|
||||||
self._touches = []
|
self._touches = []
|
||||||
for line in [x for x in self.text if type(x) in [Touch, SoftTouch]]:
|
for line in filter(lambda x: type(x) in [Touch, SoftTouch],self.text):
|
||||||
self._touches += line.text.split()[1:]
|
self._touches += line.text.split()[1:]
|
||||||
for sub in self.calls:
|
for sub in self.calls:
|
||||||
if sub in subroutines:
|
if sub in subroutines:
|
||||||
@ -113,7 +113,7 @@ class Sub(object):
|
|||||||
############################################################
|
############################################################
|
||||||
def calls(self):
|
def calls(self):
|
||||||
if '_calls' not in self.__dict__:
|
if '_calls' not in self.__dict__:
|
||||||
buffer = [x for x in self.text if type(x) == Call]
|
buffer = filter(lambda x: type(x) == Call,self.text)
|
||||||
self._calls = []
|
self._calls = []
|
||||||
for line in buffer:
|
for line in buffer:
|
||||||
sub = line.text.split('(',1)[0].split()[1].lower()
|
sub = line.text.split('(',1)[0].split()[1].lower()
|
||||||
@ -127,5 +127,5 @@ if __name__ == '__main__':
|
|||||||
from preprocessed_text import preprocessed_text
|
from preprocessed_text import preprocessed_text
|
||||||
from variables import variables
|
from variables import variables
|
||||||
from subroutines import subroutines
|
from subroutines import subroutines
|
||||||
print([variables[x].needs for x in subroutines['full_ci'].needs])
|
print map(lambda x: variables[x].needs, subroutines['full_ci'].needs)
|
||||||
print(subroutines['full_ci'].calls)
|
print subroutines['full_ci'].calls
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -51,7 +51,7 @@ def create_subroutines():
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def create_called_by(subs,vars):
|
def create_called_by(subs,vars):
|
||||||
for s in list(subs.values()) + list(vars.values()):
|
for s in subs.values() + vars.values():
|
||||||
if type(s) == Variable and s.same_as != s.name:
|
if type(s) == Variable and s.same_as != s.name:
|
||||||
continue
|
continue
|
||||||
for x in s.calls:
|
for x in s.calls:
|
||||||
@ -60,7 +60,7 @@ def create_called_by(subs,vars):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for s in list(subs.values()):
|
for s in subs.values():
|
||||||
s.called_by = make_single(s.called_by)
|
s.called_by = make_single(s.called_by)
|
||||||
s.called_by.sort()
|
s.called_by.sort()
|
||||||
|
|
||||||
@ -68,5 +68,5 @@ subroutines = create_subroutines()
|
|||||||
create_called_by(subroutines,variables)
|
create_called_by(subroutines,variables)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
for v in list(subroutines.keys()):
|
for v in subroutines.keys():
|
||||||
print(v)
|
print v
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -34,11 +34,11 @@ FILENAME=irpdir+'irp_touches.irp.F90'
|
|||||||
|
|
||||||
def create():
|
def create():
|
||||||
out = []
|
out = []
|
||||||
l = list(variables.keys())
|
l = variables.keys()
|
||||||
l.sort
|
l.sort
|
||||||
main_modules = [x for x in modules if modules[x].is_main]
|
main_modules = filter(lambda x: modules[x].is_main, modules)
|
||||||
finalize = "subroutine irp_finalize_%s\n"%(irp_id)
|
finalize = "subroutine irp_finalize_%s\n"%(irp_id)
|
||||||
for m in [x for x in modules if not modules[x].is_main]:
|
for m in filter(lambda x: not modules[x].is_main, modules):
|
||||||
finalize += " use %s\n"%(modules[m].name)
|
finalize += " use %s\n"%(modules[m].name)
|
||||||
for v in l:
|
for v in l:
|
||||||
var = variables[v]
|
var = variables[v]
|
||||||
@ -59,7 +59,7 @@ def create():
|
|||||||
|
|
||||||
|
|
||||||
if out != []:
|
if out != []:
|
||||||
out = ["%s\n"%(x) for x in out]
|
out = map(lambda x: "%s\n"%(x),out)
|
||||||
|
|
||||||
out += finalize
|
out += finalize
|
||||||
|
|
||||||
|
36
src/util.py
36
src/util.py
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -64,7 +64,7 @@ def build_dim_colons(v):
|
|||||||
if d == []:
|
if d == []:
|
||||||
return ""
|
return ""
|
||||||
else:
|
else:
|
||||||
x = [":" for x in d]
|
x = map(lambda x: ":", d)
|
||||||
return "(%s)"%(','.join(x))
|
return "(%s)"%(','.join(x))
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ def make_single(l):
|
|||||||
d = {}
|
d = {}
|
||||||
for x in l:
|
for x in l:
|
||||||
d[x] = True
|
d[x] = True
|
||||||
return list(d.keys())
|
return d.keys()
|
||||||
|
|
||||||
def flatten(l):
|
def flatten(l):
|
||||||
if type(l) == list:
|
if type(l) == list:
|
||||||
@ -128,17 +128,17 @@ def put_info(text,filename):
|
|||||||
line.text = format%(line.text.ljust(lenmax),line.filename,str(line.i))
|
line.text = format%(line.text.ljust(lenmax),line.filename,str(line.i))
|
||||||
return text
|
return text
|
||||||
|
|
||||||
import pickle as pickle
|
import cPickle as pickle
|
||||||
import os, sys
|
import os, sys
|
||||||
def parallel_loop(f,source):
|
def parallel_loop(f,source):
|
||||||
pidlist = list(range(NTHREADS))
|
pidlist = range(NTHREADS)
|
||||||
|
|
||||||
src = [ [] for i in range(NTHREADS) ]
|
src = [ [] for i in xrange(NTHREADS) ]
|
||||||
index = 0
|
index = 0
|
||||||
try:
|
try:
|
||||||
source = [(len(x[1]),(x[0], x[1])) for x in source]
|
source = map( lambda x: (len(x[1]),(x[0], x[1])), source )
|
||||||
source.sort()
|
source.sort()
|
||||||
source = [x[1] for x in source]
|
source = map( lambda x: x[1], source )
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
for i in source:
|
for i in source:
|
||||||
@ -149,8 +149,8 @@ def parallel_loop(f,source):
|
|||||||
|
|
||||||
thread_id = 0
|
thread_id = 0
|
||||||
fork = 1
|
fork = 1
|
||||||
r = list(range(0,NTHREADS))
|
r = range(0,NTHREADS)
|
||||||
for thread_id in range(1,NTHREADS):
|
for thread_id in xrange(1,NTHREADS):
|
||||||
r[thread_id], w = os.pipe()
|
r[thread_id], w = os.pipe()
|
||||||
fork = os.fork()
|
fork = os.fork()
|
||||||
if fork == 0:
|
if fork == 0:
|
||||||
@ -166,14 +166,14 @@ def parallel_loop(f,source):
|
|||||||
result = []
|
result = []
|
||||||
for filename, text in src[thread_id]:
|
for filename, text in src[thread_id]:
|
||||||
result.append( (filename, f(filename,text)) )
|
result.append( (filename, f(filename,text)) )
|
||||||
result = sorted(result, key=lambda x: x[0])
|
result.sort()
|
||||||
|
|
||||||
if fork == 0:
|
if fork == 0:
|
||||||
pickle.dump(result,w,-1)
|
pickle.dump(result,w,-1)
|
||||||
w.close()
|
w.close()
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
for i in range(1,NTHREADS):
|
for i in xrange(1,NTHREADS):
|
||||||
result += pickle.load(r[i])
|
result += pickle.load(r[i])
|
||||||
r[i].close()
|
r[i].close()
|
||||||
os.waitpid(pidlist[i],0)[1]
|
os.waitpid(pidlist[i],0)[1]
|
||||||
@ -183,10 +183,10 @@ def parallel_loop(f,source):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("10",dimsize("10")) #-> "10"
|
print "10",dimsize("10") #-> "10"
|
||||||
print("0:10",dimsize("0:10")) # -> "11"
|
print "0:10",dimsize("0:10") # -> "11"
|
||||||
print("0:x",dimsize("0:x")) # -> "x+1"
|
print "0:x",dimsize("0:x") # -> "x+1"
|
||||||
print("-3:x",dimsize("-3:x")) # -> "x+1"
|
print "-3:x",dimsize("-3:x") # -> "x+1"
|
||||||
print("x:y",dimsize("x:y")) # -> "y-x+1"
|
print "x:y",dimsize("x:y") # -> "y-x+1"
|
||||||
print("x:5",dimsize("x:5")) # -> "y-x+1"
|
print "x:5",dimsize("x:5") # -> "y-x+1"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -118,8 +118,8 @@ dimension.
|
|||||||
def doc(self):
|
def doc(self):
|
||||||
if '_doc' not in self.__dict__:
|
if '_doc' not in self.__dict__:
|
||||||
text = self.text
|
text = self.text
|
||||||
buffer = [l for l in text if type(l) == Doc]
|
buffer = filter(lambda l:type(l) == Doc, text)
|
||||||
self._doc = [l.text.lstrip()[1:] for l in buffer]
|
self._doc = map(lambda l: l.text.lstrip()[1:], buffer)
|
||||||
if buffer == []:
|
if buffer == []:
|
||||||
error.warn(None,"Variable %s is not documented"%(self.name))
|
error.warn(None,"Variable %s is not documented"%(self.name))
|
||||||
return self._doc
|
return self._doc
|
||||||
@ -137,7 +137,7 @@ dimension.
|
|||||||
if '_includes' not in self.__dict__:
|
if '_includes' not in self.__dict__:
|
||||||
self._includes = []
|
self._includes = []
|
||||||
text = self.text
|
text = self.text
|
||||||
for line in [x for x in text if type(x) == Include]:
|
for line in filter(lambda x: type(x) == Include,text):
|
||||||
self._includes.append(line.filename)
|
self._includes.append(line.filename)
|
||||||
make_single(self._includes)
|
make_single(self._includes)
|
||||||
return self._includes
|
return self._includes
|
||||||
@ -148,7 +148,7 @@ dimension.
|
|||||||
if '_calls' not in self.__dict__:
|
if '_calls' not in self.__dict__:
|
||||||
self._calls = []
|
self._calls = []
|
||||||
text = self.text
|
text = self.text
|
||||||
for line in [x for x in text if type(x) == Call]:
|
for line in filter(lambda x: type(x) == Call,text):
|
||||||
sub = line.text.split('(',1)[0].split()[1].lower()
|
sub = line.text.split('(',1)[0].split()[1].lower()
|
||||||
self._calls.append(sub)
|
self._calls.append(sub)
|
||||||
make_single(self._calls)
|
make_single(self._calls)
|
||||||
@ -162,7 +162,7 @@ dimension.
|
|||||||
append = result.append
|
append = result.append
|
||||||
f = lambda l: type(l) in [Begin_provider, Cont_provider]
|
f = lambda l: type(l) in [Begin_provider, Cont_provider]
|
||||||
text = self.text
|
text = self.text
|
||||||
lines = list(filter(f, text))
|
lines = filter(f, text)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
append(line.filename[1])
|
append(line.filename[1])
|
||||||
result.remove(self.name)
|
result.remove(self.name)
|
||||||
@ -190,7 +190,7 @@ dimension.
|
|||||||
from variables import variables
|
from variables import variables
|
||||||
def f(var):
|
def f(var):
|
||||||
return variables[var].dim != []
|
return variables[var].dim != []
|
||||||
self._allocate = list(filter ( f, self.others + [self.name] ))
|
self._allocate = filter ( f, self.others + [self.name] )
|
||||||
return self._allocate
|
return self._allocate
|
||||||
allocate = property(allocate)
|
allocate = property(allocate)
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ dimension.
|
|||||||
self._dim = []
|
self._dim = []
|
||||||
else:
|
else:
|
||||||
buffer = buffer[2].strip()[1:-1].split(',')
|
buffer = buffer[2].strip()[1:-1].split(',')
|
||||||
self._dim = list(map(strip,buffer))
|
self._dim = map(strip,buffer)
|
||||||
return self._dim
|
return self._dim
|
||||||
dim = property(dim)
|
dim = property(dim)
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ dimension.
|
|||||||
if '_line' not in self.__dict__:
|
if '_line' not in self.__dict__:
|
||||||
f = lambda l: type(l) in [Begin_provider, Cont_provider]
|
f = lambda l: type(l) in [Begin_provider, Cont_provider]
|
||||||
text = self.text
|
text = self.text
|
||||||
lines = list(filter(f, text))
|
lines = filter(f, text)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
buffer = line.filename[1]
|
buffer = line.filename[1]
|
||||||
if self._name == buffer:
|
if self._name == buffer:
|
||||||
@ -282,18 +282,18 @@ dimension.
|
|||||||
import parsed_text
|
import parsed_text
|
||||||
parents = self.parents
|
parents = self.parents
|
||||||
parents.sort()
|
parents.sort()
|
||||||
mods = [variables[x].fmodule for x in parents]
|
mods = map(lambda x: variables[x].fmodule, parents)
|
||||||
mods = make_single(mods)+[self.fmodule]
|
mods = make_single(mods)+[self.fmodule]
|
||||||
name = self.name
|
name = self.name
|
||||||
result = [ "subroutine touch_%s"%(name) ]
|
result = [ "subroutine touch_%s"%(name) ]
|
||||||
result += [" Use %s"%(x) for x in mods]
|
result += map(lambda x: " Use %s"%(x),mods)
|
||||||
result.append(" implicit none")
|
result.append(" implicit none")
|
||||||
if command_line.do_debug:
|
if command_line.do_debug:
|
||||||
length = str(len("touch_%s"%(name)))
|
length = str(len("touch_%s"%(name)))
|
||||||
result += [ " character*(%s) :: irp_here = 'touch_%s'"%(length,name) ]
|
result += [ " character*(%s) :: irp_here = 'touch_%s'"%(length,name) ]
|
||||||
if command_line.do_debug:
|
if command_line.do_debug:
|
||||||
result += [ " call irp_enter(irp_here)" ]
|
result += [ " call irp_enter(irp_here)" ]
|
||||||
result += [" %s_is_built = .False."%(x) for x in parents]
|
result += map( lambda x: " %s_is_built = .False."%(x), parents)
|
||||||
result.append(" %s_is_built = .True."%(name))
|
result.append(" %s_is_built = .True."%(name))
|
||||||
if command_line.do_debug:
|
if command_line.do_debug:
|
||||||
result.append(" call irp_leave(irp_here)")
|
result.append(" call irp_leave(irp_here)")
|
||||||
@ -363,7 +363,7 @@ dimension.
|
|||||||
result += [\
|
result += [\
|
||||||
" character*(%d) :: irp_here = 'reader_%s'"%(length,name),
|
" character*(%d) :: irp_here = 'reader_%s'"%(length,name),
|
||||||
" call irp_enter(irp_here)" ]
|
" call irp_enter(irp_here)" ]
|
||||||
result += [" call reader_%s(irp_num)"%(x) for x in self.needs]
|
result += map(lambda x: " call reader_%s(irp_num)"%(x),self.needs)
|
||||||
result += [ \
|
result += [ \
|
||||||
" irp_is_open = .True.",
|
" irp_is_open = .True.",
|
||||||
" irp_iunit = 9",
|
" irp_iunit = 9",
|
||||||
@ -413,7 +413,7 @@ dimension.
|
|||||||
" if (.not.%s_is_built) then"%(self.same_as),
|
" if (.not.%s_is_built) then"%(self.same_as),
|
||||||
" call provide_%s"%(self.same_as),
|
" call provide_%s"%(self.same_as),
|
||||||
" endif" ]
|
" endif" ]
|
||||||
result += [" call writer_%s(irp_num)"%(x) for x in self.needs]
|
result += map(lambda x: " call writer_%s(irp_num)"%(x),self.needs)
|
||||||
result += [ \
|
result += [ \
|
||||||
" irp_is_open = .True.",
|
" irp_is_open = .True.",
|
||||||
" irp_iunit = 9",
|
" irp_iunit = 9",
|
||||||
@ -480,7 +480,7 @@ dimension.
|
|||||||
return result+")'"
|
return result+")'"
|
||||||
|
|
||||||
def check_dimensions():
|
def check_dimensions():
|
||||||
result = ["(%s>0)"%(dimsize(x)) for x in self.dim]
|
result = map(lambda x: "(%s>0)"%(dimsize(x)), self.dim)
|
||||||
result = ".and.".join(result)
|
result = ".and.".join(result)
|
||||||
result = " if (%s) then"%(result)
|
result = " if (%s) then"%(result)
|
||||||
return result
|
return result
|
||||||
@ -555,7 +555,7 @@ dimension.
|
|||||||
if command_line.do_debug:
|
if command_line.do_debug:
|
||||||
result.append(" call irp_enter(irp_here)")
|
result.append(" call irp_enter(irp_here)")
|
||||||
result += call_provides(self.to_provide)
|
result += call_provides(self.to_provide)
|
||||||
result += flatten( list(map(build_alloc,[self.same_as]+self.others)) )
|
result += flatten( map(build_alloc,[self.same_as]+self.others) )
|
||||||
result += [ " if (.not.%s_is_built) then"%(same_as),
|
result += [ " if (.not.%s_is_built) then"%(same_as),
|
||||||
" call bld_%s"%(same_as),
|
" call bld_%s"%(same_as),
|
||||||
" %s_is_built = .True."%(same_as), "" ]
|
" %s_is_built = .True."%(same_as), "" ]
|
||||||
@ -591,7 +591,7 @@ dimension.
|
|||||||
vars = []
|
vars = []
|
||||||
if inside:
|
if inside:
|
||||||
text.append( (vars,line) )
|
text.append( (vars,line) )
|
||||||
text += [([],Simple_line(line.i,x,line.filename)) for x in call_provides(vars)]
|
text += map( lambda x: ([],Simple_line(line.i,x,line.filename)), call_provides(vars) )
|
||||||
if command_line.do_profile and type(line) == Begin_provider:
|
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( ( [], 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) ) )
|
text.append( ( [], Simple_line(line.i," irp_rdtsc1 = irp_rdtsc()",line.filename) ) )
|
||||||
@ -602,9 +602,9 @@ dimension.
|
|||||||
text = parsed_text.move_to_top(text,Declaration)
|
text = parsed_text.move_to_top(text,Declaration)
|
||||||
text = parsed_text.move_to_top(text,Implicit)
|
text = parsed_text.move_to_top(text,Implicit)
|
||||||
text = parsed_text.move_to_top(text,Use)
|
text = parsed_text.move_to_top(text,Use)
|
||||||
text = [x[1] for x in text]
|
text = map(lambda x: x[1], text)
|
||||||
# inside_omp = False
|
# inside_omp = False
|
||||||
for line in [x for x in text if type(x) not in [ Begin_doc, End_doc, Doc]]:
|
for line in filter(lambda x: type(x) not in [ Begin_doc, End_doc, Doc], text):
|
||||||
if type(line) == Begin_provider:
|
if type(line) == Begin_provider:
|
||||||
result = []
|
result = []
|
||||||
if command_line.directives and command_line.inline in ["all","builders"]:
|
if command_line.directives and command_line.inline in ["all","builders"]:
|
||||||
@ -692,11 +692,11 @@ if __name__ == '__main__':
|
|||||||
for i in x.needs:
|
for i in x.needs:
|
||||||
pair = (x.name, i)
|
pair = (x.name, i)
|
||||||
if pair not in done:
|
if pair not in done:
|
||||||
print("%s -> %s"%( x.name, i ))
|
print "%s -> %s"%( x.name, i )
|
||||||
done[pair] = None
|
done[pair] = None
|
||||||
print_dot(variables[i],done)
|
print_dot(variables[i],done)
|
||||||
|
|
||||||
print("digraph G { ")
|
print "digraph G { "
|
||||||
# print_dot(variables['e_loc'], {})
|
# print_dot(variables['e_loc'], {})
|
||||||
print_dot(variables['psi_value'], {})
|
print_dot(variables['psi_value'], {})
|
||||||
print("}")
|
print "}"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
@ -29,9 +29,6 @@ from variable import *
|
|||||||
from irpf90_t import *
|
from irpf90_t import *
|
||||||
from command_line import command_line
|
from command_line import command_line
|
||||||
from util import *
|
from util import *
|
||||||
import error
|
|
||||||
|
|
||||||
forbidden_names = ["type", "double precision", "integer", "use", "character", "real"]
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def create_variables():
|
def create_variables():
|
||||||
@ -51,19 +48,17 @@ def create_variables():
|
|||||||
icount += 1
|
icount += 1
|
||||||
v = Variable(buffer,icount)
|
v = Variable(buffer,icount)
|
||||||
if v.name in result:
|
if v.name in result:
|
||||||
print("Warning: Duplicate provider for %s in"%(v.name))
|
print "Warning: Duplicate provider for %s in"%(v.name)
|
||||||
print("- ", v.line.filename[0], " line ", v.line.i)
|
print "- ", v.line.filename[0], " line ", v.line.i
|
||||||
print("- ", result[v.name].line.filename[0], " line ", result[v.name].line.i)
|
print "- ", result[v.name].line.filename[0], " line ", result[v.name].line.i
|
||||||
print("Choosing first version")
|
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
|
result[v.name] = v
|
||||||
for other in v.others:
|
for other in v.others:
|
||||||
if other in result:
|
if other in result:
|
||||||
print("Warning: Duplicate provider for %s in"%(other))
|
print "Warning: Duplicate provider for %s in"%(other)
|
||||||
print("- ", v.line.filename[0], " line ", v.line.i)
|
print "- ", v.line.filename[0], " line ", v.line.i
|
||||||
print("- ", result[other].line.filename[0], " line ", result[other].line.i)
|
print "- ", result[other].line.filename[0], " line ", result[other].line.i
|
||||||
print("Choosing first version")
|
print "Choosing first version"
|
||||||
result[other] = Variable(buffer,icount,other)
|
result[other] = Variable(buffer,icount,other)
|
||||||
buffer = []
|
buffer = []
|
||||||
return result
|
return result
|
||||||
@ -72,16 +67,16 @@ variables = create_variables()
|
|||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def build_use(vars):
|
def build_use(vars):
|
||||||
result = [" use %s"%(variables[x].fmodule) for x in vars]
|
result = map(lambda x: " use %s"%(variables[x].fmodule), vars)
|
||||||
result = make_single(result)
|
result = make_single(result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
def call_provides(vars,opt=False):
|
def call_provides(vars,opt=False):
|
||||||
vars = make_single( [variables[x].same_as for x in vars] )
|
vars = make_single( map(lambda x: variables[x].same_as, vars) )
|
||||||
if opt:
|
if opt:
|
||||||
all_children = flatten( [variables[x].children for x in vars])
|
all_children = flatten( map(lambda x: variables[x].children, vars ))
|
||||||
vars = [x for x in vars if x not in all_children]
|
vars = filter(lambda x: x not in all_children,vars)
|
||||||
def fun(x):
|
def fun(x):
|
||||||
result = []
|
result = []
|
||||||
result += [ \
|
result += [ \
|
||||||
@ -92,10 +87,10 @@ def call_provides(vars,opt=False):
|
|||||||
" endif" ]
|
" endif" ]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
result = flatten ( list(map (fun, vars)) )
|
result = flatten ( map (fun, vars) )
|
||||||
return result
|
return result
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
for v in list(variables.keys()):
|
for v in variables.keys():
|
||||||
print(v)
|
print v
|
||||||
|
@ -1 +1 @@
|
|||||||
version="2.0.5"
|
version = "1.7.3"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#/usr/bin/env python3
|
#/usr/bin/env python2
|
||||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||||
# the Implicit Reference to Parameters (IRP) method.
|
# the Implicit Reference to Parameters (IRP) method.
|
||||||
# Copyright (C) 2009 Anthony SCEMAMA
|
# Copyright (C) 2009 Anthony SCEMAMA
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
import os,sys
|
import os,sys
|
||||||
ROOT = os.path.dirname(__file__)+'/../../'
|
ROOT = os.path.dirname(__file__)+'/../../'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
import os
|
import os
|
||||||
ROOT = os.path.dirname(__file__)+'/../../'
|
ROOT = os.path.dirname(__file__)+'/../../'
|
||||||
|
Loading…
Reference in New Issue
Block a user