Comments (15)
Thanks for reporting. I don't have access to a Windows machine to test on, but will be happy to receive a PR to fix this.
from f90wrap.
Note that gfortran is available through conda-forge via m2w64-gcc-fortran
, so you should not need to install those outside your conda environment (there is also m2w64-gcc
and m2w64-toolchain
and various others)
from f90wrap.
Made some progress on this by adding the below to f90wrap/__init__.py
.
import os
if os.name =="nt":
os.add_dll_directory(f'{os.path.dirname(os.path.realpath(__file__))}/.libs')
This resolves the missing dll issue and simple examples will build. Unfortunately some examples now have an undefined reference to '__precision_MOD_five'
error when trying to run f2py-f90wrap
. See full error below:
...
gfortran.exe:f90: f90wrap/f90wrap_aa2_defineAllProperties.f90
gfortran.exe:f90: f90wrap/f90wrap_toplevel.f90
copying .\libsrc.a -> .\Release\src.lib
C:\Apps\mingw64\bin\gfortran.exe -Wall -g -Wall -g -shared ~\f90wrap\examples\example2\Release\f90wrap\f90wrap_aa0_typelist.o ~\f90wrap\examples\example2\Release\f90wrap\f90wrap_aa1_modules.o ~\f90wrap\examples\example2\Release\f90wrap\f90wrap_aa2_defineAllProperties.o ~\f90wrap\examples\example2\Release\f90wrap\f90wrap_toplevel.o -LC:\Apps\mingw64\lib\gcc\x86_64-w64-mingw32\7.2.0 -L~\f90wrap\venv\libs -LC:\~\AppData\Local\Programs\Python\Python38\libs -LC:\~\AppData\Local\Programs\Python\Python38 -L~\f90wrap\venv\PCbuild\amd64 -o .\Release\.libs\libf90wrap_.HUF45REHGPWYBYV53E2NYKMSFCRWWWJV.gfortran-win_amd64.dll -Wl,--allow-multiple-definition -Wl,--output-def,.\Release\libf90wrap_.HUF45REHGPWYBYV53E2NYKMSFCRWWWJV.gfortran-win_amd64.def -Wl,--export-all-symbols -Wl,--enable-auto-import -static -mlong-double-64
~\f90wrap\examples\example2\Release\f90wrap\f90wrap_aa0_typelist.o:f90wrap_aa0_typelist.f90:(.rdata$.refptr.__precision_MOD_five[.refptr.__precision_MOD_five]+0x0): undefined reference to `__precision_MOD_five'
~\f90wrap\examples\example2\Release\f90wrap\f90wrap_aa0_typelist.o:f90wrap_aa0_typelist.f90:(.rdata$.refptr.__precision_MOD_in2ft[.refptr.__precision_MOD_in2ft]+0x0): undefined reference to `__precision_MOD_in2ft'
I'll take another look into this later and see if I can make a smaller example.
from f90wrap.
Nearly there! This is pushing my limited understanding of the compilers but it seems to work.
Adding the original .f90
files to the f2py-f90wrap
call results in successful compilation when just a single file is used.
f2py-f90wrap --fcompiler=gfortran --build-dir . -c -m _pipeline -L. -lsrc f90wrap_demo.f90
to
f2py-f90wrap --fcompiler=gfortran --build-dir . -c demo.f90 -m _pipeline -L. -lsrc f90wrap_demo.f90
demo.f90:
module demo
implicit none
TYPE :: DemoType
Integer :: nL
end type DemoType
public :: hello
contains
! This function caused build fail without above change
function hello(val_in) result(outval)
REAL, intent(in):: val_in
REAL :: outval
outval = val_in + 1.0
end function
end module demo
Including more than 1 file caused a seg fault!
from f90wrap.
OK, looks good. Usually you would compile demo.f90
yourself separately (e.g. with gfortran -c demo.f90 -o demo.o
) and include the resulting object file demo.o
on the f2py-f90wrap
command line, or combine a number of .o
files into a static library (.a
in Linux, not sure how this works in Windows).
from f90wrap.
That's what I had been doing for linux but in Windows it was having some issues. I'll take another look later.
from f90wrap.
@sbland would you mind sharing your compiler list and build tools (MSVC? gcc through MSYS/mingw/something else) for windows? I'm trying something out with all three, found your hints super useful.. if I hit upon a solution I can report here too
from f90wrap.
I got f90wrap to work on Windows 10 (64 bit, home edition) with Anaconda Python 3.8.8, numpy version 1.20.1 and f90wrap 0.2.7; gfortran through mingw-w64 (v8.1.0). I built f90wrap with python setup.py install after telling distutils.cfg to use mingw32 (and not the microsoft visual c/c++ compiler)
from f90wrap.
Note that gfortran is available through conda-forge via
m2w64-gcc-fortran
, so you should not need to install those outside your conda environment (there is alsom2w64-gcc
andm2w64-toolchain
and various others)
Thanks @bilderbuchi - I'll try it out.
from f90wrap.
@bilderbuchi It seems the package contains some older versions of the compilers; is it up-to-date with what ships with the other toolchains? The conda package version seems to suggest gcc v5.x
from f90wrap.
Yeah, no, it's 5.3.0, unfortunately not the freshest, but luckily enough for my Fortran codebase. As this gcc is underpinning much of the scientific Python ecosystem it's not easy to upgrade, apparently, but there are issues about that, see e.g. conda-forge/fpm-feedstock#4 conda-forge/conda-forge.github.io#1044
from f90wrap.
Also conda-forge/conda-forge.github.io#961
from f90wrap.
@sbland did you try the mingw-w64 toolchain? Hope it resolved your issue.
Looks like Windows 11 allows for WSL to be installed as an application through the Microsoft store, so you could try that if your IT policy is permissive enough.
from f90wrap.
i tried setup.py install with anaconda 3.8.8 on a windows machine today; latest f90wrap does not need the patch in init.py. This issue can be closed?
from f90wrap.
@sbland Did you compile the shared library on Windows 10 while you define and use "user defined data type"? Your example code went well on my Windows 10. I compiled the *.pyd file and *.dll file and imported into Python and got correct results. However, while I use the "user defined data type", the compiler will assume they are "void" and give me the error "getctype: No C-type found in "{'typespec': 'type', 'typename': 'real_array'}", assuming void." The code I tested is from "f90wrap/examples/arrays_in_derived_types_issue50" test.f90
` module module_test
type real_array
real, dimension(6) :: item
end type real_array
contains
subroutine testf(x)
implicit none
type(real_array) :: x
print*, "This is received in fortran : ", x%item
x%item(4) = 4
print*, "This is sent back to python : ", x%item
end subroutine testf
end module module_test`
Do you have any suggestions? Thank you.
from f90wrap.
Related Issues (20)
- IndentationError with python 3.9 HOT 5
- Extra (unnecessary) newline character in .py file for long variable names HOT 3
- more explanations on the provided examples HOT 2
- Handling reserved Python words in f90wrap HOT 6
- Help wrapping a project HOT 7
- Data type determined at run time
- Issues with Compiling MPI Program HOT 3
- Support for Intel oneAPI2022
- multidimensional arrays in derived types broken if compiled with long integers as default HOT 1
- Python 3.11 support HOT 8
- Pre-build f90wrap wheels for windows HOT 3
- Derived types containing allocatable character arrays
- `integer, value, intent(in)`/`integer, value` arguments converted to/wrapped as `real`
- Wrong module class name in a call to `f90wrap.runtime.FortranDerivedTypeArray` HOT 2
- numpy > 1.23 support HOT 2
- Switch to pyproject.toml based build system HOT 7
- duplicate symbol in formal argument list HOT 2
- Issues on Mac OS X - for f90wrap 0.2.12 HOT 1
- BUG: Routines including procedure arguments (callbacks) are excluded HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from f90wrap.