dpgrote / forthon Goto Github PK
View Code? Open in Web Editor NEWPython wrapper generator for Fortran
Python wrapper generator for Fortran
Hi Dave,
if you are interested I would send you a pull-request adding continous integration testing for each of your pushes via the free service travis-ci.org.
Here is my development branch: https://github.com/ax3l/Forthon/tree/topic-travisCI
Automated builds of UEDGE on GitHub runners using workflows started failing in last 2 months. The error seems to imply a Forthon issue:
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DFORTHON_PKGNAME=\"uedge\" -I/tmp/pip-build-env-qqg6217r/overlay/lib/python3.9/site-packages/Forthon -I/tmp/pip-build-env-qqg6217r/overlay/lib/python3.9/site-packages/numpy/_core/include -I/opt/hostedtoolcache/Python/3.9.19/x64/include/python3.9 -c build/temp.linux-x86_64-cpython-39/compymodule.c -o build/temp.linux-x86_64-cpython-39/compymodule.o
In file included from build/temp.linux-x86_64-cpython-39/compymodule.c:1:
build/temp.linux-x86_64-cpython-39/Forthon.h: In function ‘Forthon_setarray’:
build/temp.linux-x86_64-cpython-39/Forthon.h:860:58: error: ‘PyArray_Descr’ {aka ‘struct _PyArray_Descr’} has no member named ‘elsize’
860 | (((PyArrayObject_fields *)(farray->pya))->descr->elsize) = 0;
| ^~
build/temp.linux-x86_64-cpython-39/Forthon.h:863:58: error: ‘PyArray_Descr’ {aka ‘struct _PyArray_Descr’} has no member named ‘elsize’
863 | (((PyArrayObject_fields *)(farray->pya))->descr->elsize) = (int)PyArray_ITEMSIZE(ax);
| ^~
build/temp.linux-x86_64-cpython-39/Forthon.h:875:64: error: ‘PyArray_Descr’ {aka ‘struct _PyArray_Descr’} has no member named ‘elsize’
875 | if (d > -1) (((PyArrayObject_fields *)(farray->pya))->descr->elsize) = d;
| ^~
error: command '/usr/bin/gcc' failed with exit code 1
make: *** [Makefile.Forthon:19: build/compydep] Error 1
Full logs available here: https://github.com/LLNL/UEDGE/actions/runs/9865600958
Fails on all build platforms. Happy to provide more information and help debugging. Will try to recreate locally.
The link in the About section is broken.
I am working on a project and need to use openblas. Documentation for the server that I am working on suggests using:
-L$(BLAS_DIR)/lib -lopenblas
Where BLAS_DIR is an environment variable
BLAS_DIR=/fusion/usc/c8/opt/env/gcc-8.3.1
I have tried many approaches but my most recent and best attempt was the following:
$(BUILDDIR)/gtnpydep: gtn/main.F gtn/calctransm.F gtn/gtn.v
$(FORTHON) -a $(INSTALLARGS) -a $(FCOMP) $(DEBUG) --fargs "-LUMFPACK2 -lumfpack -L$(BLAS_DIR)/lib -lopenblas" --interfacefile gtn/gtn.v -f gtn/main.F gtn $(GTN_SRC)
touch $@
What is the correct syntax for incorporating a library?
The error that I am encountering is that python can't find the symbol dgesv_, which I have confirmed is in libopenblas.so
(gtneut_env) [deshazere@omega-a pygtneut_develop]$ python gtneut_run.py
>>> GTNEUT version: 0.00
python: symbol lookup error: /fusion/projects/codes/conda/omega/dev_envs/deshazere/gtneut_env/lib/python3.7/site-packages/gtneut/gtnpy.cpython-37m-x86_64-linux-gnu.so: undefined symbol: dgesv_
When working with new Python modules, I make heavy use of a period followed by to investigate the class members of an object, or sometimes simply the dir() command. How can I get a list of the class members of a Forthon object from the object itself?
I installed Forthon following the directions in INSTALL. I used the option --home=/some/other/directory/ because I do not have root and my user directory is too small. In total:
python setup.py install --home=/some/other/directory
My python path contains this /some/other/directory. When I start up python I can "import Forthon" without error.
When I type 'make' in the Forthon/simpleexample/ directory I get the following error:
(cd forthon_example_source ; Forthon --install --pkgdir . forthon_example)
/bin/sh: Forthon: command not found
make: *** [install] Error 127
I'm certain this is a trivial problem for more experienced users, but I am uncertain what to try next.
I am unable to build Forthon using Python 3.3.2. The relevant errors are:
Can't parse build/lib/Forthon/version.py: ParseError: bad input: type=2, value='3634', context=('', (2, 16))
and
File "/home/jlarson/.local/lib/python3.3/site-packages/Forthon/version.py", line 2
gitversion = 'b'3634cc7''
^
SyntaxError: invalid syntax
The complete output is below:
[jlarson@blogin2 software]$ git clone https://github.com/dpgrote/Forthon.git
Initialized empty Git repository in /fusion/gpfs/home/jlarson/software/Forthon/.git/
remote: Counting objects: 2505, done.
remote: Total 2505 (delta 0), reused 0 (delta 0), pack-reused 2505
Receiving objects: 100% (2505/2505), 445.63 KiB, done.
Resolving deltas: 100% (1719/1719), done.
[jlarson@blogin2 software]$ cd Forthon/
[jlarson@blogin2 Forthon]$ python setup.py install --user
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/Forthon
copying Lib/ForthonTimer.py -> build/lib/Forthon
copying Lib/Forthon_builder.py -> build/lib/Forthon
copying Lib/Forthon_options.py -> build/lib/Forthon
copying Lib/_Forthon.py -> build/lib/Forthon
copying Lib/init.py -> build/lib/Forthon
copying Lib/cfinterface.py -> build/lib/Forthon
copying Lib/compilers.py -> build/lib/Forthon
copying Lib/fvars.py -> build/lib/Forthon
copying Lib/interfaceparser.py -> build/lib/Forthon
copying Lib/preprocess.py -> build/lib/Forthon
copying Lib/wrappergen_derivedtypes.py -> build/lib/Forthon
copying Lib/wrappergenerator.py -> build/lib/Forthon
copying Lib/version.py -> build/lib/Forthon
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
Can't parse build/lib/Forthon/version.py: ParseError: bad input: type=2, value='3634', context=('', (2, 16))
running build_scripts
creating build/scripts-3.3
copying and adjusting Forthon3 -> build/scripts-3.3
changing mode of build/scripts-3.3/Forthon3 from 644 to 755
running install_lib
copying build/lib/Forthon/ForthonTimer.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/Forthon_builder.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/Forthon_options.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/_Forthon.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/init.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/cfinterface.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/compilers.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/fvars.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/interfaceparser.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/preprocess.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/wrappergen_derivedtypes.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/wrappergenerator.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying build/lib/Forthon/version.py -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/ForthonTimer.py to ForthonTimer.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/Forthon_builder.py to Forthon_builder.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/Forthon_options.py to Forthon_options.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/_Forthon.py to _Forthon.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/init.py to init.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/cfinterface.py to cfinterface.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/compilers.py to compilers.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/fvars.py to fvars.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/interfaceparser.py to interfaceparser.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/preprocess.py to preprocess.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/wrappergen_derivedtypes.py to wrappergen_derivedtypes.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/wrappergenerator.py to wrappergenerator.cpython-33.pyc
byte-compiling /home/jlarson/.local/lib/python3.3/site-packages/Forthon/version.py to version.cpython-33.pyc
File "/home/jlarson/.local/lib/python3.3/site-packages/Forthon/version.py", line 2
gitversion = 'b'3634cc7''
^
SyntaxError: invalid syntax
running install_scripts
copying build/scripts-3.3/Forthon3 -> /home/jlarson/.local/bin
changing mode of /home/jlarson/.local/bin/Forthon3 to 755
running install_data
copying License.txt -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying Src/Forthon.h -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
copying Src/Forthon.c -> /home/jlarson/.local/lib/python3.3/site-packages/Forthon
running install_egg_info
Removing /home/jlarson/.local/lib/python3.3/site-packages/Forthon-0.8.15-py3.3.egg-info
Writing /home/jlarson/.local/lib/python3.3/site-packages/Forthon-0.8.15-py3.3.egg-info
I am trying to use Forthon to build warp. The callpyfunc routine depends on the variable FORTHON_PKGNAME (in the file Forthon.c) that is undeclared. Is warp expected to declare this?
The comment on the commit b08eb865c3eef5473497295bc05ffc7eb5d0bc5a
suggests that warp used to be referenced. But commit bb6e73395a5d84ef34098cd1b343b78780720da4
says that this work around is a hack specific to the warp code.
I would think that FORTHON_PKGNAME would be declared by Forthon, and not by the application using Forthon.
Thank you very much for the help!
When trying to build MPI code using Forthon with MPICH and gfortran on recent Debian or Ubuntu (specifically, 20.04 Focal Fossa), I find that Forthon fails with the error Fortran compiler not found
.
This seems to be because the mpifort
provided in the Debian mpich
package executes the Fortran compiler via the f95
alias rather than an explicit gfortran
. I'm guessing this was done because there's another Debian package, flang-7
, that also provides an implementation of that alias, via the Debian 'alternatives' system which maintains symlinks /usr/bin/f95 -> /etc/alternatives/f95 -> /usr/bin/{gfortran,flang}
Thus, in compilers.py
, either the compiler is not found (if --fcomp
is unspecified), or the assertion that the command line given by mpifort -show
begins with the specified name fails.
I'm not sure of the best way to resolve this. Forthon could trust the user's specification of compiler type, at the expense of the consistency checking it does now. It could go down the rabbit hole of recursively resolving symlinks (which would fail on further wrappers) or running the command specified to get version output and interpreting that.
Hi Dave,
I am trying to install Forthon on a Ubuntu 14.04 server (gfortran 4.8.2) and fail on
$ pip [-v] install Forthon
Collecting Forthon
Downloading Forthon-0.8.19.tar.gz (83kB)
...
with
running build_scripts
creating build/scripts-3.5
error: file '/tmp/pip-build-52frweiy/Forthon/Forthon3' does not exist
Environment:
The verbose output is
Collecting Forthon
1 location(s) to search for versions of Forthon:
* https://pypi.python.org/simple/forthon/
Getting page https://pypi.python.org/simple/forthon/
Looking up "https://pypi.python.org/simple/forthon/" in the cache
Current age based on date: 437
Freshness lifetime from max-age: 600
Freshness lifetime from request max-age: 600
The response is "fresh", returning cached response
600 > 437
Analyzing links from page https://pypi.python.org/simple/forthon/
Found link https://pypi.python.org/packages/source/F/Forthon/Forthon-0.8.11.tar.gz#md5=fa77ad60646f78e176293989f8be3c89 (from https://pypi.python.org/simple/forthon/), version: 0.8.11
Found link https://pypi.python.org/packages/source/F/Forthon/Forthon-0.8.13.tar.gz#md5=b0d29aba88448270e7e2ea1bf30f2d4c (from https://pypi.python.org/simple/forthon/), version: 0.8.13
Found link https://pypi.python.org/packages/source/F/Forthon/Forthon-0.8.14.tar.gz#md5=251c83781e84bd29dfcff2e7af7e74e6 (from https://pypi.python.org/simple/forthon/), version: 0.8.14
Found link https://pypi.python.org/packages/source/F/Forthon/Forthon-0.8.15.tar.gz#md5=0973c39167911547c91d8395daecac1f (from https://pypi.python.org/simple/forthon/), version: 0.8.15
Found link https://pypi.python.org/packages/source/F/Forthon/Forthon-0.8.16.tar.gz#md5=60cf6e312b9c6a5904145fc1dddb9689 (from https://pypi.python.org/simple/forthon/), version: 0.8.16
Found link https://pypi.python.org/packages/source/F/Forthon/Forthon-0.8.17.tar.gz#md5=790acd517d22120fa92a5a42c18783f2 (from https://pypi.python.org/simple/forthon/), version: 0.8.17
Found link https://pypi.python.org/packages/source/F/Forthon/Forthon-0.8.18.tar.gz#md5=7895705bfaf91882f7feed750abc32b5 (from https://pypi.python.org/simple/forthon/), version: 0.8.18
Found link https://pypi.python.org/packages/source/F/Forthon/Forthon-0.8.19.tar.gz#md5=17f6a6cf058f0cf457ac02cdb1090e34 (from https://pypi.python.org/simple/forthon/), version: 0.8.19
Using version 0.8.19 (newest of versions: 0.8.11, 0.8.13, 0.8.14, 0.8.15, 0.8.16, 0.8.17, 0.8.18, 0.8.19)
Looking up "https://pypi.python.org/packages/source/F/Forthon/Forthon-0.8.19.tar.gz" in the cache
Current age based on date: 437
Freshness lifetime from max-age: 31557600
The response is "fresh", returning cached response
31557600 > 437
Using cached Forthon-0.8.19.tar.gz
Downloading from URL https://pypi.python.org/packages/source/F/Forthon/Forthon-0.8.19.tar.gz#md5=17f6a6cf058f0cf457ac02cdb1090e34 (from https://pypi.python.org/simple/forthon/)
Running setup.py (path:/tmp/pip-build-r142h5n1/Forthon/setup.py) egg_info for package Forthon
Running command python setup.py egg_info
running egg_info
creating pip-egg-info/Forthon.egg-info
writing dependency_links to pip-egg-info/Forthon.egg-info/dependency_links.txt
writing pip-egg-info/Forthon.egg-info/PKG-INFO
writing top-level names to pip-egg-info/Forthon.egg-info/top_level.txt
writing manifest file 'pip-egg-info/Forthon.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
reading manifest file 'pip-egg-info/Forthon.egg-info/SOURCES.txt'
writing manifest file 'pip-egg-info/Forthon.egg-info/SOURCES.txt'
Source in /tmp/pip-build-r142h5n1/Forthon has version 0.8.19, which satisfies requirement Forthon from https://pypi.python.org/packages/source/F/Forthon/Forthon-0.8.19.tar.gz#md5=17f6a6cf058f0cf457ac02cdb1090e34
Building wheels for collected packages: Forthon
Running setup.py bdist_wheel for Forthon ... Destination directory: /tmp/tmppwwj9v58pip-wheel-
Running command /home/huebl/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-r142h5n1/Forthon/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmppwwj9v58pip-wheel- --python-tag cp35
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/Forthon
copying source/cfinterface.py -> build/lib/Forthon
copying source/Forthon_builder.py -> build/lib/Forthon
copying source/wrappergen_derivedtypes.py -> build/lib/Forthon
copying source/interfaceparser.py -> build/lib/Forthon
copying source/fvars.py -> build/lib/Forthon
copying source/Forthon_options.py -> build/lib/Forthon
copying source/ForthonTimer.py -> build/lib/Forthon
copying source/compilers.py -> build/lib/Forthon
copying source/wrappergenerator.py -> build/lib/Forthon
copying source/_Forthon.py -> build/lib/Forthon
copying source/preprocess.py -> build/lib/Forthon
copying source/__init__.py -> build/lib/Forthon
copying source/version.py -> build/lib/Forthon
copying source/License.txt -> build/lib/Forthon
copying source/Forthon.h -> build/lib/Forthon
copying source/Forthon.c -> build/lib/Forthon
Skipping optional fixer: buffer
Skipping optional fixer: idioms
Skipping optional fixer: set_literal
Skipping optional fixer: ws_comma
running build_scripts
creating build/scripts-3.5
error: file '/tmp/pip-build-r142h5n1/Forthon/Forthon3' does not exist
error
Failed building wheel for Forthon
Running setup.py clean for Forthon
Running command /home/huebl/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-r142h5n1/Forthon/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" clean --all
running clean
'build/lib' does not exist -- can't clean it
'build/bdist.linux-x86_64' does not exist -- can't clean it
'build/scripts-3.5' does not exist -- can't clean it
Failed to build Forthon
Installing collected packages: Forthon
Running setup.py install for Forthon ... Running command /home/huebl/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-r142h5n1/Forthon/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-e0ji5pjp-record/install-record.txt --single-version-externally-managed --compile
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/Forthon
copying source/cfinterface.py -> build/lib/Forthon
copying source/Forthon_builder.py -> build/lib/Forthon
copying source/wrappergen_derivedtypes.py -> build/lib/Forthon
copying source/interfaceparser.py -> build/lib/Forthon
copying source/fvars.py -> build/lib/Forthon
copying source/Forthon_options.py -> build/lib/Forthon
copying source/ForthonTimer.py -> build/lib/Forthon
copying source/compilers.py -> build/lib/Forthon
copying source/wrappergenerator.py -> build/lib/Forthon
copying source/_Forthon.py -> build/lib/Forthon
copying source/preprocess.py -> build/lib/Forthon
copying source/__init__.py -> build/lib/Forthon
copying source/version.py -> build/lib/Forthon
copying source/License.txt -> build/lib/Forthon
copying source/Forthon.h -> build/lib/Forthon
copying source/Forthon.c -> build/lib/Forthon
Skipping optional fixer: buffer
Skipping optional fixer: idioms
Skipping optional fixer: set_literal
Skipping optional fixer: ws_comma
running build_scripts
creating build/scripts-3.5
error: file '/tmp/pip-build-r142h5n1/Forthon/Forthon3' does not exist
error
Cleaning up...
Removing source in /tmp/pip-build-r142h5n1/Forthon
Command "/home/huebl/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-r142h5n1/Forthon/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-e0ji5pjp-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-r142h5n1/Forthon/
Exception information:
Traceback (most recent call last):
File "/home/huebl/anaconda3/lib/python3.5/site-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/home/huebl/anaconda3/lib/python3.5/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/home/huebl/anaconda3/lib/python3.5/site-packages/pip/req/req_set.py", line 732, in install
**kwargs
File "/home/huebl/anaconda3/lib/python3.5/site-packages/pip/req/req_install.py", line 884, in install
spinner=spinner,
File "/home/huebl/anaconda3/lib/python3.5/site-packages/pip/utils/__init__.py", line 718, in call_subprocess
% (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command "/home/huebl/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-r142h5n1/Forthon/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-e0ji5pjp-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-r142h5n1/Forthon/
Can you help?
Thanks a lot,
Axel
When running Forthon code in a Jupyter notebook, if the print statements are in Fortran, their output appears in the terminal where jupyter was started, rather than in the notebook cell. When I create a "hello world" program using Cython, which translates python to C and creates a .so file that can be imported in python, the outputs appear in the notebook properly.
This line in example2.F is generating the error:
call DelPyRefType2(t2) ! Must be added to clean up memory
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.