mirror of https://gitlab.com/scemama/irpf90.git
Compare commits
29 Commits
Author | SHA1 | Date |
---|---|---|
Anthony Scemama | beac615343 | |
Anthony Scemama | 01899b41b2 | |
Anthony Scemama | 451c93a52c | |
Anthony Scemama | 76946321d6 | |
Anthony Scemama | ba1a2837aa | |
Anthony Scemama | 4ab1b175fc | |
Anthony Scemama | 0007f72f67 | |
Otto Kohulak | a885761ea2 | |
Otto Kohulak | 152c69c754 | |
Anthony Scemama | 34ca9a7852 | |
Otto Kohulak | d1e475dc22 | |
Anthony Scemama | 088c6fdc04 | |
Ot(t)o Kohulák | c938931e5e | |
Anthony Scemama | ab88cc01a6 | |
Anthony Scemama | 33ca5e1018 | |
Anthony Scemama | 132a4a1661 | |
Anthony Scemama | 2027274583 | |
Anthony Scemama | da3ee8864a | |
Anthony Scemama | 22115cd6a5 | |
Anthony Scemama | bcc208624b | |
Anthony Scemama | a13a4a0741 | |
Anthony Scemama | c9809ddae3 | |
Lorentz Panadestein | b6acbe76ef | |
Anthony Scemama | f1c8d20fa8 | |
Pierre-Francois Loos | bccb9adbe6 | |
Anthony Scemama | cc61d6271b | |
Anthony Scemama | 97a3fe9985 | |
Anthony Scemama | cfeeb46c65 | |
Anthony Scemama | e5af6c693a |
|
@ -3,7 +3,7 @@ RST2MAN=rst2man -d -t
|
|||
default: man1/irpman.1.gz man1/irpf90.1.gz
|
||||
|
||||
options.rst: ../src/command_line.py
|
||||
python ../src/command_line.py > options.rst
|
||||
python3 ../src/command_line.py > options.rst
|
||||
|
||||
man1/irpf90.1.gz: irpf90.rst options.rst
|
||||
rm -f $@ ; $(RST2MAN) --title="IRP Fortran 90" irpf90.rst man1/irpf90.1 ; gzip man1/irpf90.1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||
# the Implicit Reference to Parameters (IRP) method.
|
||||
# Copyright (C) 2009 Anthony SCEMAMA
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||
# the Implicit Reference to Parameters (IRP) method.
|
||||
# Copyright (C) 2009 Anthony SCEMAMA
|
||||
|
|
|
@ -34,7 +34,7 @@ import sys, os
|
|||
from irpf90_libs.irpf90_t import mandir
|
||||
filename = sys.argv[1].lower()+".l"
|
||||
if filename not in os.listdir(mandir):
|
||||
print "%s does not exist"%(sys.argv[1])
|
||||
print("%s does not exist"%(sys.argv[1]))
|
||||
sys.exit(-1)
|
||||
|
||||
os.system("man ./"+mandir+sys.argv[1].lower()+".l")
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import sys
|
||||
|
||||
import setuptools
|
||||
import version
|
||||
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
v = version.version
|
||||
|
||||
setuptools.setup(
|
||||
name = 'irpf90',
|
||||
version = '1.7.7',
|
||||
version = v,
|
||||
scripts = ["irpf90", "irpman", "irpf90_indent"],
|
||||
author = 'Anthony Scemama',
|
||||
author_email = 'scemama@irsamc.ups-tlse.fr',
|
||||
|
@ -15,10 +18,10 @@ setuptools.setup(
|
|||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://irpf90.ups-tlse.fr",
|
||||
download_url = 'https://gitlab.com/scemama/irpf90/-/archive/v1.7.6/irpf90-v1.7.6.tar.gz',
|
||||
download_url = f'https://gitlab.com/scemama/irpf90/-/archive/v{v}/irpf90-v{v}.tar.gz',
|
||||
packages=setuptools.find_packages(),
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 2",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Fortran",
|
||||
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../src/version.py
|
10
src/Makefile
10
src/Makefile
|
@ -1,3 +1,13 @@
|
|||
all: exe vim emacs
|
||||
|
||||
exe: ../bin/irpf90
|
||||
|
||||
vim:
|
||||
python3 vim.py
|
||||
|
||||
emacs:
|
||||
python3 emacs.py
|
||||
|
||||
../bin/irpf90: irpf90_python.exe
|
||||
rm ../bin/irpf90 ; cd ../bin ; ln -s ../src/irpf90_python.exe irpf90
|
||||
clean:
|
||||
|
|
|
@ -222,7 +222,7 @@ def do_print_subroutines_rst(sub):
|
|||
filename = sub.line.filename
|
||||
name = sub.name
|
||||
file = open("%s%s.rst"%(mandir,sub.name), "w")
|
||||
print(".. c:function:: %s:\n"%(sub.name.lower()), file=file)
|
||||
print(".. c:macro:: %s:\n"%(sub.name.lower()), file=file)
|
||||
print("", file=file)
|
||||
print(" File : :file:`"+filename+"`", file=file)
|
||||
print("", file=file)
|
||||
|
@ -327,6 +327,32 @@ def run():
|
|||
for line in tags:
|
||||
file.write(line)
|
||||
file.close()
|
||||
|
||||
# # Create emacs tags
|
||||
# tags = {}
|
||||
# l = list(variables.keys())
|
||||
# for v in l:
|
||||
# line = variables[v].line
|
||||
# if line.filename[0] not in tags:
|
||||
# tags[line.filename[0]] = []
|
||||
# tags[line.filename[0]].append( (v,line) )
|
||||
# l = list(subroutines.keys())
|
||||
# for v in l:
|
||||
# line = subroutines[v].line
|
||||
# if line.filename not in tags:
|
||||
# tags[line.filename] = []
|
||||
# tags[line.filename].append( (v,line) )
|
||||
#
|
||||
# file = open("TAGS","w")
|
||||
# for f in tags:
|
||||
# tags[f].sort()
|
||||
# text = ""
|
||||
# for v, line in tags[f]:
|
||||
# text += "%s\x7f%s\x01%d,0\n"%(line.text.split('!')[0].rstrip(),v,line.i)
|
||||
# file.write("\x0c\n%s,%d\n"%(f, len(text)))
|
||||
# file.write(text)
|
||||
# file.close()
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
os.waitpid(pid1,0)
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
"""
|
||||
IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||
the Implicit Reference to Parameters (IRP) method.
|
||||
Copyright (C) 2009 Anthony SCEMAMA
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
This script handles the files needed to use the IRPF90 Emacs mode. This
|
||||
config used the emacs package `use-package`
|
||||
(https://jwiegley.github.io/use-package/).
|
||||
The user is responsible for its installing and configuring it.
|
||||
Contributed by Ramon L. Panades-Barrueta (https://tinyurl.com/y6qvjmxg ).
|
||||
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
def install():
|
||||
"""Installs the irp-mode in Emacs"""
|
||||
# Check user Emacs config
|
||||
emacs_init = [*map(lambda x: os.environ["HOME"] + x,
|
||||
["/.emacs.d/inil.el", "/.emacs"])]
|
||||
|
||||
emacs_dir = os.environ["HOME"] + "/.emacs.d"
|
||||
os.makedirs(f"{emacs_dir}/lib", exist_ok=True)
|
||||
|
||||
emacs = emacs_init[0] if os.access(
|
||||
emacs_init[0], os.F_OK) else emacs_init[1]
|
||||
|
||||
# Add support for irp-mode and Yasnippets
|
||||
with open(emacs, "a") as emfil:
|
||||
emfil.write("\n")
|
||||
emfil.write(";; Use Yasnippets\n")
|
||||
emfil.write("(use-package yasnippet\n")
|
||||
emfil.write(" :ensure t\n")
|
||||
emfil.write(" :config\n")
|
||||
emfil.write(" (yas-global-mode 1))\n")
|
||||
emfil.write("\n")
|
||||
emfil.write(";; Use irp-mode\n")
|
||||
emfil.write("(use-package irp-mode\n")
|
||||
emfil.write(r""" :mode ("\\.irp.f\\'")""")
|
||||
emfil.write(f"""\n :load-path "{emacs_dir}/lib")\n""")
|
||||
|
||||
# Copy irp-mode files
|
||||
workd = os.path.abspath(os.path.dirname(__file__))
|
||||
with open(f"{workd}/irp-mode.el", 'r') as f_in:
|
||||
with open(f"{emacs_dir}/lib/irp-mode.el", 'w') as f_out:
|
||||
f_out.write(f_in.read())
|
||||
|
||||
# Snippets
|
||||
os.makedirs(f"{emacs_dir}/snippets/irp-mode/", exist_ok=True)
|
||||
snips = os.listdir(f"{workd}/irp_snippets")
|
||||
for fil in snips:
|
||||
shutil.copy(f"{workd}/irp_snippets/{fil}",
|
||||
f"{emacs_dir}/snippets/irp-mode/")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
install()
|
|
@ -0,0 +1,41 @@
|
|||
;;; irp-mode.el --- A major mode for dealing with IRPF90 files
|
||||
|
||||
;;; Commentary:
|
||||
;; An attempt to support Scemama's IRPF90 in Emacs
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Define IRPF90 extended FORTRAN syntax
|
||||
|
||||
(defvar irp-font-lock-keywords)
|
||||
|
||||
(setq irp-font-lock-keywords
|
||||
(let* (
|
||||
;; Define different keywords
|
||||
(x-keywords '("BEGIN_PROVIDER" "END_PROVIDER" "ASSERT"
|
||||
"FREE" "PROVIDE" "BEGIN_TEMPLATE"
|
||||
"END_TEMPLATE" "BEGIN_SHELL"
|
||||
"END_SHELL" "IRP_IF" "IRP_ELSE"))
|
||||
(x-types '("double precision" "integer"))
|
||||
(x-comments '("BEGIN_DOC" "END_DOC"))
|
||||
|
||||
;; Generate regex
|
||||
(x-keywords-regexp (regexp-opt x-keywords 'words))
|
||||
(x-types-regexp (regexp-opt x-types 'words))
|
||||
(x-comments-regexp (regexp-opt x-comments 'words)))
|
||||
|
||||
`(
|
||||
(,x-types-regexp . font-lock-type-face)
|
||||
(,x-keywords-regexp . font-lock-preprocessor-face)
|
||||
(,x-comments-regexp . font-lock-comment-face)
|
||||
)))
|
||||
|
||||
;;;###autoload
|
||||
(define-derived-mode irp-mode f90-mode "irp mode"
|
||||
"Major mode for editing IRPF90 files."
|
||||
:syntax-table nil
|
||||
:abbrev-table nil
|
||||
(font-lock-add-keywords nil irp-font-lock-keywords))
|
||||
|
||||
(provide 'irp-mode)
|
||||
;;; irp-mode.el ends here
|
|
@ -0,0 +1,5 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: ASSERT
|
||||
# key: ass
|
||||
# --
|
||||
ASSERT ($0)
|
|
@ -0,0 +1,7 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: BEGIN_DOC ... END_DOC
|
||||
# key: bc
|
||||
# --
|
||||
BEGIN_DOC
|
||||
! $0
|
||||
END_DOC
|
|
@ -0,0 +1,7 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: BEGIN_PROVIDER ... END_PROVIDER
|
||||
# key: bp
|
||||
# --
|
||||
BEGIN_PROVIDER [${1:integer}, ${2:var}]
|
||||
$0
|
||||
END_PROVIDER
|
|
@ -0,0 +1,8 @@
|
|||
# -*- mode: snippet -*-
|
||||
# -*- mode: snippet -*-
|
||||
# name: BEGIN_SHELL ... END_SHELL
|
||||
# key: bsh
|
||||
# --
|
||||
BEGIN_SHELL [ ${1:/bin/bash} ]
|
||||
$0
|
||||
END_SHELL
|
|
@ -38,8 +38,6 @@ from command_line import command_line
|
|||
|
||||
def main():
|
||||
|
||||
vim.install()
|
||||
|
||||
if command_line.do_help:
|
||||
command_line.usage()
|
||||
|
||||
|
|
|
@ -26,10 +26,21 @@
|
|||
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
LENMAX = 70
|
||||
tabn = 2
|
||||
|
||||
#copy of locals without "import copy"
|
||||
locals_ = {x: y for x, y in locals().items()}
|
||||
for key, value in locals_.items():
|
||||
try:
|
||||
val = os.environ["IRPF90_INDENT_"+key.upper()]
|
||||
locals()[key] = type(locals_[key])(val)
|
||||
except:
|
||||
pass
|
||||
|
||||
tab = " "*tabn
|
||||
|
||||
class Grep(object):
|
||||
|
@ -106,6 +117,14 @@ class Grep(object):
|
|||
def declaration(self,string):
|
||||
return re.match(self.re_declaration,string) is not None
|
||||
|
||||
re_preprocessor = re.compile(r"^\s*#.*$")
|
||||
def preprocessor(self,string):
|
||||
return re.match(self.re_preprocessor,string) is not None
|
||||
|
||||
re_omppragma = re.compile(r"^\s*!\$omp\s.*$")
|
||||
def omppragma(self,string):
|
||||
return re.match(self.re_omppragma,string) is not None
|
||||
|
||||
grep = Grep()
|
||||
|
||||
class indent(object):
|
||||
|
@ -119,10 +138,12 @@ class indent(object):
|
|||
return l.strip().ljust(n) + ' :: '+ r.strip()
|
||||
|
||||
def format_continuation(self,string,n):
|
||||
buffer = string.split('&')
|
||||
buffer = string.split('&', 1)
|
||||
if len(buffer) == 1:
|
||||
l = buffer[0]
|
||||
return l
|
||||
elif buffer[0].strip() == "":
|
||||
return self.format_continuation(buffer[1], n)
|
||||
else:
|
||||
l, r = buffer
|
||||
return l.strip().ljust(69-len(n)) + '&'+ r.strip()
|
||||
|
@ -165,6 +186,19 @@ class indent(object):
|
|||
for i in range(len(self.text)):
|
||||
prevline = line
|
||||
line = self.text[i].strip()
|
||||
|
||||
if line == "":
|
||||
print("")
|
||||
continue
|
||||
|
||||
if grep.preprocessor(line):
|
||||
print(line.lstrip())
|
||||
continue
|
||||
|
||||
if grep.omppragma(line):
|
||||
print(line.lstrip())
|
||||
continue
|
||||
|
||||
if grep.continuation(line):
|
||||
line = self.format_continuation(line,k)
|
||||
|
||||
|
|
|
@ -35,6 +35,15 @@ FILENAME = "Makefile"
|
|||
FILENAME_GITIGNORE = ".gitignore"
|
||||
IRPF90_MAKE = "irpf90.make"
|
||||
|
||||
if sys.platform in ["linux", "linux2"]:
|
||||
ARCHIVE = "ar crs"
|
||||
elif sys.platform == "darwin":
|
||||
ARCHIVE = "libtool -static -o"
|
||||
else:
|
||||
print("Unknown platform. Only Linux and Darwin are supported.")
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
######################################################################
|
||||
def create():
|
||||
has_makefile = True
|
||||
|
@ -49,7 +58,7 @@ def create():
|
|||
FC = gfortran
|
||||
FCFLAGS= -O2 -ffree-line-length-none -I .
|
||||
NINJA = ninja
|
||||
AR = ar
|
||||
ARCHIVE= %s
|
||||
RANLIB = ranlib
|
||||
|
||||
SRC=
|
||||
|
@ -61,7 +70,7 @@ export
|
|||
|
||||
%s: $(filter-out %s%%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile
|
||||
\t$(IRPF90)
|
||||
"""%(IRPF90_MAKE,IRPF90_MAKE,irpdir)
|
||||
"""%(ARCHIVE,IRPF90_MAKE,IRPF90_MAKE,irpdir)
|
||||
file.write(t)
|
||||
file.close()
|
||||
create_gitignore()
|
||||
|
@ -188,7 +197,7 @@ def run_make():
|
|||
print(dir+"%.o: %.F\n\t$(FC) $(FCFLAGS) -c $*.F -o "+dir+"$*.o", file=file)
|
||||
print(dir+"%.irp.F90: "+IRPF90_MAKE+"\n", file=file)
|
||||
print("move:\n\t@mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING=\n", file=file)
|
||||
print("IRPF90_temp/irpf90.a: $(OBJ) $(OBJ1)\n\t$(AR) crf IRPF90_temp/irpf90.a $(OBJ1)\n", file=file)
|
||||
print("IRPF90_temp/irpf90.a: $(OBJ) $(OBJ1)\n\t$(ARCHIVE) IRPF90_temp/irpf90.a $(OBJ1)\n", file=file)
|
||||
print("clean:\n\trm -rf $(EXE) $(OBJ1) IRPF90_temp/irpf90.a $(ALL_OBJ1) $(ALL)\n", file=file)
|
||||
print("veryclean:\n\t- $(MAKE) clean\n", file=file)
|
||||
print("\t- rm -rf "+irpdir+" "+mandir+" "+IRPF90_MAKE+" irpf90_entities dist tags\n", file=file)
|
||||
|
|
83
src/ninja.py
83
src/ninja.py
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
# IRPF90 is a Fortran90 preprocessor written in Python for programming using
|
||||
# the Implicit Reference to Parameters (IRP) method.
|
||||
# Copyright (C) 2009 Anthony SCEMAMA
|
||||
# Copyright (C) 2009 Anthony SCEMAMA
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -20,8 +20,8 @@
|
|||
# Anthony Scemama
|
||||
# LCPQ - IRSAMC - CNRS
|
||||
# Universite Paul Sabatier
|
||||
# 118, route de Narbonne
|
||||
# 31062 Toulouse Cedex 4
|
||||
# 118, route de Narbonne
|
||||
# 31062 Toulouse Cedex 4
|
||||
# scemama@irsamc.ups-tlse.fr
|
||||
|
||||
|
||||
|
@ -39,6 +39,14 @@ cwd = os.getcwd()
|
|||
|
||||
PRINT_WIDTH=50
|
||||
|
||||
if sys.platform in ["linux", "linux2"]:
|
||||
AR = "ar crs"
|
||||
elif sys.platform == "darwin":
|
||||
AR = "libtool -static -o"
|
||||
else:
|
||||
print("Unknown platform. Only Linux and Darwin are supported.")
|
||||
sys.exit(-1)
|
||||
|
||||
def dress(f,in_root=False):
|
||||
"""
|
||||
Transfoms the filename f into $PWD/IRPF90_temp/f
|
||||
|
@ -47,7 +55,8 @@ def dress(f,in_root=False):
|
|||
result = os.path.join(cwd,f)
|
||||
else:
|
||||
result = os.path.join(cwd,irpdir,f)
|
||||
return os.path.normpath(result)
|
||||
result = os.path.normpath(result)
|
||||
return result
|
||||
|
||||
|
||||
def create_build_touches(list_of_other_o):
|
||||
|
@ -68,7 +77,7 @@ def create_build_touches(list_of_other_o):
|
|||
list_of_modules = ' '.join(list_of_modules)
|
||||
|
||||
result = '\n'.join(
|
||||
[
|
||||
[
|
||||
"build {target_o}: compile_touches_{id} {target_F90} | {list_of_modules}",
|
||||
" short_in = {short_target_F90}",
|
||||
" short_out = {short_target_o}",
|
||||
|
@ -86,7 +95,7 @@ def create_build_touches(list_of_other_o):
|
|||
short_target_F90 = os.path.split(target_F90)[1] ,
|
||||
short_target_o = os.path.split(target_o)[1] ,
|
||||
target_F90 = target_F90 ,
|
||||
target_o = target_o
|
||||
target_o = target_o
|
||||
)
|
||||
return result
|
||||
|
||||
|
@ -110,7 +119,7 @@ def create_build_target(t,list_of_other_o):
|
|||
needed_modules = [ "%s.irp.module.o"%(modules[x].filename) for x in modules \
|
||||
if modules[x].name in t.needed_modules ] + [ target_module_o ]
|
||||
|
||||
list_of_o = [ target_o, target_module_o, irp_lib ]
|
||||
list_of_o = [ target_o, target_module_o, irp_lib ]
|
||||
list_of_o = ' '.join(list_of_o)
|
||||
|
||||
list_of_modules = list(map(dress, needed_modules)) + list_of_other_o
|
||||
|
@ -119,7 +128,7 @@ def create_build_target(t,list_of_other_o):
|
|||
list_of_includes = ' '.join([dress(x,in_root=True) for x in t.includes])
|
||||
|
||||
result = '\n'.join(
|
||||
[ "build {target}: link_{id} {list_of_o}",
|
||||
[ "build {target}: link_{id} {list_of_o}",
|
||||
" short_out = {short_target}",
|
||||
"",
|
||||
"build {target_o}: compile_fortran_{id} {target_F90} | {list_of_modules} {list_of_includes}",
|
||||
|
@ -146,7 +155,7 @@ def create_build_target(t,list_of_other_o):
|
|||
target_module_F90 = target_module_F90 ,
|
||||
target_module_o = target_module_o ,
|
||||
target_o = target_o ,
|
||||
target = target
|
||||
target = target
|
||||
)
|
||||
return result
|
||||
|
||||
|
@ -176,7 +185,7 @@ def create_build_non_target(t,list_of_other_o):
|
|||
list_of_includes = ' '.join([dress(x,in_root=True) for x in t.includes])
|
||||
|
||||
result = '\n'.join(
|
||||
[
|
||||
[
|
||||
"build {target_o}: compile_fortran_{id} {target_F90} | {list_of_modules} {list_of_externals}",
|
||||
" short_in = {short_target_F90}",
|
||||
" short_out = {short_target}",
|
||||
|
@ -198,7 +207,7 @@ def create_build_non_target(t,list_of_other_o):
|
|||
target_F90 = target_F90 ,
|
||||
target_module_F90 = target_module_F90 ,
|
||||
target_module_o = target_module_o ,
|
||||
target_o = target_o
|
||||
target_o = target_o
|
||||
)
|
||||
return result
|
||||
|
||||
|
@ -222,7 +231,7 @@ def create_build_remaining(f):
|
|||
elif extension.lower() in [ 'cxx', 'cpp' ]:
|
||||
result = [ "build {target_o}: compile_cxx_{id} {target_i}" ]
|
||||
|
||||
result += [ " short_in = {short_target_i}",
|
||||
result += [ " short_in = {short_target_i}",
|
||||
" short_out = {short_target_o}", "" ]
|
||||
result = '\n'.join(result).format(
|
||||
target_o = target_o,
|
||||
|
@ -246,7 +255,7 @@ TARGETS={1}
|
|||
all:
|
||||
$(NINJA)
|
||||
|
||||
$(TARGETS):
|
||||
$(TARGETS):
|
||||
$(NINJA) $(PWD)/$@
|
||||
|
||||
clean:
|
||||
|
@ -271,8 +280,8 @@ def run():
|
|||
try: FC = os.environ["FC"]
|
||||
except KeyError: FC="gfortran -ffree-line-length-none"
|
||||
|
||||
try: AR = os.environ["AR"]
|
||||
except KeyError: AR="ar"
|
||||
try: ARCHIVE = os.environ["ARCHIVE"]
|
||||
except KeyError: ARCHIVE=AR
|
||||
|
||||
try: CC = os.environ["CC"]
|
||||
except KeyError: CC="gcc"
|
||||
|
@ -285,7 +294,7 @@ def run():
|
|||
FC += " "+' '.join(includes)
|
||||
CC += " "+' '.join(includes)
|
||||
CXX += " "+' '.join(includes)
|
||||
|
||||
|
||||
try: SRC = os.environ["SRC"].split()
|
||||
except KeyError: SRC=[]
|
||||
|
||||
|
@ -311,32 +320,32 @@ def run():
|
|||
|
||||
# Rules
|
||||
|
||||
t = [ "rule compile_fortran_{id}",
|
||||
" command = {FC} {FCFLAGS} -c $in -o $out",
|
||||
" description = F : $short_in -> $short_out",
|
||||
t = [ "rule compile_fortran_{id}",
|
||||
" command = {FC} {FCFLAGS} -c $in -o $out",
|
||||
" description = F : $short_in -> $short_out",
|
||||
"",
|
||||
"rule compile_touches_{id}",
|
||||
"rule compile_touches_{id}",
|
||||
" command = {FC} -c $in -o $out",
|
||||
" description = F : $short_in -> $short_out",
|
||||
" description = F : $short_in -> $short_out",
|
||||
"",
|
||||
"",
|
||||
"rule compile_c_{id}" ,
|
||||
" command = {CC} {CFLAGS} -c $in -o $out",
|
||||
" description = C : $short_in -> $short_out",
|
||||
" command = {CC} {CFLAGS} -c $in -o $out",
|
||||
" description = C : $short_in -> $short_out",
|
||||
"",
|
||||
"rule compile_cxx_{id}",
|
||||
" command = {CXX} {CXXFLAGS} -c $in -o $out",
|
||||
" description = C++ : $short_in -> $short_out",
|
||||
"rule compile_cxx_{id}",
|
||||
" command = {CXX} {CXXFLAGS} -c $in -o $out",
|
||||
" description = C++ : $short_in -> $short_out",
|
||||
"",
|
||||
"rule link_lib_{id}",
|
||||
" command = {AR} crf $out $in" ,
|
||||
" description = Link: $short_out",
|
||||
"rule link_lib_{id}",
|
||||
" command = {ARCHIVE} $out $in" ,
|
||||
" description = Link: $short_out",
|
||||
"",
|
||||
"rule link_{id}",
|
||||
"rule link_{id}",
|
||||
" command = {FC} $in {LIB} -o $out" ,
|
||||
" description = Link: $short_out"]
|
||||
|
||||
output += [ '\n'.join(t).format(id=irp_id, FC=FC, FCFLAGS=FCFLAGS, LIB=LIB, CXX=CXX, CXXFLAGS=CXXFLAGS, CC=CC, CFLAGS=CFLAGS, AR=AR) ]
|
||||
" description = Link: $short_out"]
|
||||
|
||||
output += [ '\n'.join(t).format(id=irp_id, FC=FC, FCFLAGS=FCFLAGS, LIB=LIB, CXX=CXX, CXXFLAGS=CXXFLAGS, CC=CC, CFLAGS=CFLAGS, ARCHIVE=ARCHIVE) ]
|
||||
|
||||
|
||||
# All modules : list of Fmodule objects
|
||||
|
@ -396,9 +405,13 @@ def run():
|
|||
for i in l_common_s:
|
||||
output.append(create_build_remaining(i))
|
||||
|
||||
|
||||
|
||||
text = '\n\n'.join(output)
|
||||
text = text.replace(cwd+"/IRPF90_temp","$T")
|
||||
text = text.replace(cwd,"$X")
|
||||
with open(FILENAME,'w') as f:
|
||||
f.write('\n\n'.join(output))
|
||||
f.write("X="+cwd+"\nT="+cwd+"/IRPF90_temp\n")
|
||||
f.write(text)
|
||||
f.write('\n')
|
||||
|
||||
create_irpf90_make([ x.filename for x in l_targets ] + [ os.path.join(irpdir,'irpf90.a') ] )
|
||||
|
|
|
@ -236,10 +236,10 @@ def get_parsed_text():
|
|||
append( (l,line) )
|
||||
return result
|
||||
|
||||
#main_result = []
|
||||
#for filename,text in preprocessed_text:
|
||||
# main_result.append( (filename, func(filename,text)) )
|
||||
#return main_result
|
||||
# Remove duplicates
|
||||
global preprocessed_text
|
||||
d = dict(preprocessed_text)
|
||||
preprocessed_text = [ (k,d[k]) for k in d.keys() ]
|
||||
return parallel_loop(func,preprocessed_text)
|
||||
|
||||
update_variables()
|
||||
|
@ -424,11 +424,11 @@ def move_variables():
|
|||
error.fail(line,"Unable to parse file")
|
||||
return result
|
||||
|
||||
main_result = []
|
||||
for filename,text in parsed_text:
|
||||
main_result.append( (filename, func(filename,text)) )
|
||||
return main_result
|
||||
#return parallel_loop(func,parsed_text)
|
||||
# main_result = []
|
||||
# for filename,text in parsed_text:
|
||||
# main_result.append( (filename, func(filename,text)) )
|
||||
# return main_result
|
||||
return parallel_loop(func,parsed_text)
|
||||
|
||||
parsed_text = move_variables()
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ def execute_templates(text):
|
|||
file.close()
|
||||
# Execute shell
|
||||
import os
|
||||
pipe = os.popen("python < %s"%(scriptname),'r')
|
||||
pipe = os.popen("python3 < %s"%(scriptname),'r')
|
||||
lines = pipe.readlines()
|
||||
pipe.close()
|
||||
result += get_text(lines,scriptname)
|
||||
|
|
|
@ -46,12 +46,13 @@ re_decl = re.compile( "".join( [ r"^\ *",
|
|||
r"|intrinsic *(::)?",
|
||||
r"|external *(::)?",
|
||||
r"|equivalence *(::)?",
|
||||
r"|type",
|
||||
r"|type *\(",
|
||||
r"|type +",
|
||||
r"|end ?type",
|
||||
r")[^=(]"
|
||||
] ) )
|
||||
|
||||
re_test = re.compile(r"\( *(.*)(\.[a-zA-Z]*\.|[<>]=?|[=/]=)([^=]*)\)")
|
||||
|
||||
re_string = re.compile(r"'.*?'")
|
||||
re_string = re.compile(r"'.*?'|\".*?\"")
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ def parallel_loop(f,source):
|
|||
result = []
|
||||
for filename, text in src[thread_id]:
|
||||
result.append( (filename, f(filename,text)) )
|
||||
result.sort()
|
||||
result = sorted(result, key=lambda x: x[0])
|
||||
|
||||
if fork == 0:
|
||||
pickle.dump(result,w,-1)
|
||||
|
|
|
@ -29,6 +29,9 @@ from variable import *
|
|||
from irpf90_t import *
|
||||
from command_line import command_line
|
||||
from util import *
|
||||
import error
|
||||
|
||||
forbidden_names = ["type", "double precision", "integer", "use", "character", "real"]
|
||||
|
||||
######################################################################
|
||||
def create_variables():
|
||||
|
@ -52,6 +55,8 @@ def create_variables():
|
|||
print("- ", v.line.filename[0], " line ", v.line.i)
|
||||
print("- ", result[v.name].line.filename[0], " line ", result[v.name].line.i)
|
||||
print("Choosing first version")
|
||||
if v.name in forbidden_names:
|
||||
error.fail(line,"A variable can't be named %s"%(v.name))
|
||||
result[v.name] = v
|
||||
for other in v.others:
|
||||
if other in result:
|
||||
|
|
|
@ -1 +1 @@
|
|||
version = "2.0.1"
|
||||
version="2.0.5"
|
||||
|
|
Loading…
Reference in New Issue