473,805 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

f2py and Fortran90 gfortran_filena me error

Hello All:

Since my last post I have attempted to use the f2py program which
comes with numpy. I am able to create a <module_name>.s o file fine;
however, when I import it into Python, I receive the following
message:
>>import matsolve2
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: ./matsolve2.so: undefined symbol: _gfortran_filen ame
The steps I used to create the matsolve2.so file are as follows:

(1) Created a Fortran90 program matsolve.f90

Note: The program compiles fine and prints the proper output for the
simple matrix specified. I have also attached below the file
matsolve.f90 if it helps at all.

(2) f2py matsolve.f90 -m matsolve2 -h matsolve2.pyf
(3) f2py -c matsolve2.pyf --f90exec=/usr/bin/gfortran matsolve.f90

Note: I had to specify the f90 path as f2py did not automatically find
it.

Any suggestions are greatly appreciated.

Cheers,

t.

! MATSOLVE.f90
!
! Start main program
PROGRAM MATSOLVE
IMPLICIT NONE
INTEGER,PARAMET ER :: n=3
INTEGER :: i,j
REAL,DIMENSION( n) :: x,b
REAL,DIMENSION( n,n) :: A,L,U
! Initialize the vectors and matrices with a test case from text
! Using the one given in Appendix A from Thompson.
! Known vector "b"
b(1) = 12.
b(2) = 11.
b(3) = 2.

! Known coefficient matrix "A", and initialize L and U
DO i=1,n
DO j=1,n
L(i,j) = 0.
U(i,j) = 0.
END DO
END DO

A(1,1) = 3.
A(1,2) = -1.
A(1,3) = 2.

A(2,1) = 1.
A(2,2) = 2.
A(2,3) = 3.

A(3,1) = 2.
A(3,2) = -2.
A(3,3) = -1.
! Call subroutine to create L and U matrices from A
CALL lumake(L,U,A,n)
! Print results
PRINT *, '-----------------------'
DO i=1,n
DO j=1,n
PRINT *, i, j, A(i,j), L(i,j), U(i,j)
END DO
END DO
PRINT *, '-----------------------'

! Call subroutine to solve for "x" using L and U
CALL lusolve(x,L,U,b ,n)

! Print results
PRINT *, '-----------------------'
DO i=1,n
PRINT *, i, x(i)
END DO
PRINT *, '-----------------------'

END PROGRAM MATSOLVE
! Create subroutine to make L and U matrices
SUBROUTINE lumake(LL,UU,AA ,n1)
IMPLICIT NONE
INTEGER,PARAMET ER :: n=3
INTEGER :: i,j,k
REAL :: LUSUM
INTEGER,INTENT( IN) :: n1
REAL,DIMENSION( n,n),INTENT(IN) :: AA
REAL,DIMENSION( n,n),INTENT(OUT ) :: LL,UU

! We first note that the diagonal in our UPPER matrix is
! going to be UU(j,j) = 1.0, this allows us to initialize
! the first set of expressions
UU(1,1) = 1.

! Find first column of LL
DO i = 1,n1
LL(i,1) = AA(i,1)/UU(1,1)
END DO

! Now find first row of UU
DO j = 2,n1
UU(1,j) = AA(1,j)/LL(1,1)
END DO

! Now find middle LL elements
DO j = 2,n1
DO i = j,n1
LUSUM = 0.
DO k = 1,j-1
LUSUM = LUSUM + LL(i,k)*UU(k,j)
END DO
LL(i,j) = AA(i,j) - LUSUM
END DO

! Set Diagonal UU
UU(j,j) = 1.

! Now find middle UU elements
DO i = j+1,n1
LUSUM = 0.
DO k = 1,j-1
LUSUM = LUSUM + LL(j,k)*UU(k,i)
END DO
UU(j,i) = (AA(j,i) - LUSUM)/LL(j,j)
END DO
END DO
END SUBROUTINE lumake
! Make subroutine to solve for x
SUBROUTINE lusolve(xx,L2,U 2,bb,n2)
IMPLICIT NONE
INTEGER,PARAMET ER :: n=3
INTEGER :: i,j,k
REAL :: LYSUM,UXSUM
REAL,DIMENSION( n):: y
INTEGER,INTENT( IN) :: n2
REAL,DIMENSION( n),INTENT(IN) :: bb
REAL,DIMENSION( n,n),INTENT(IN) :: L2,U2
REAL,DIMENSION( n),INTENT(OUT) :: xx

! Initialize
DO i=1,n2
y(i) = 0.
xx(i) = 0.
END DO

! Solve L.y = b
y(1) = bb(1)/L2(1,1)
DO i = 2,n2
LYSUM = 0.
DO k = 1,i-1
LYSUM = LYSUM + L2(i,k)*y(k)
END DO
y(i) = (bb(i) - LYSUM)/L2(i,i)
END DO

! Now do back subsitution for U.x = y
xx(n2) = y(n2)/U2(n2,n2)
DO j = n2-1,1,-1
UXSUM = 0.
DO k = j+1,n2
UXSUM = UXSUM + U2(j,k)*xx(k)
END DO
xx(j) = y(j) - UXSUM
END DO
END SUBROUTINE lusolve

Feb 28 '07 #1
5 2027
Tyler wrote:
Hello All:

Since my last post I have attempted to use the f2py program which
comes with numpy.
It's better to ask these questions on numpy-discussion, instead. There are more
f2py users per capita there.

http://www.scipy.org/Mailing_Lists
I am able to create a <module_name>.s o file fine;
however, when I import it into Python, I receive the following
message:
>>>import matsolve2
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: ./matsolve2.so: undefined symbol: _gfortran_filen ame
The steps I used to create the matsolve2.so file are as follows:

(1) Created a Fortran90 program matsolve.f90

Note: The program compiles fine and prints the proper output for the
simple matrix specified. I have also attached below the file
matsolve.f90 if it helps at all.

(2) f2py matsolve.f90 -m matsolve2 -h matsolve2.pyf
(3) f2py -c matsolve2.pyf --f90exec=/usr/bin/gfortran matsolve.f90

Note: I had to specify the f90 path as f2py did not automatically find
it.
You want to specify the *kind* of Fortran compiler such that f2py knows what
compile/link flags to use. Only use the --f90exec option to inform f2py that the
actual executable is named something odd or is in an unexpected place, like
/opt/gfortran/bin/gfortran-4.3, for example. The correct option to use is

--fcompiler=gnu95

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Feb 28 '07 #2
On Feb 28, 12:40 am, Robert Kern <robert.k...@gm ail.comwrote:
Tyler wrote:
Hello All:
Since my last post I have attempted to use the f2py program which
comes with numpy.

It's better to ask these questions on numpy-discussion, instead. There are more
f2py users per capita there.

http://www.scipy.org/Mailing_Lists
I am able to create a <module_name>.s o file fine;
however, when I import it into Python, I receive the following
message:
>>import matsolve2
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: ./matsolve2.so: undefined symbol: _gfortran_filen ame
The steps I used to create the matsolve2.so file are as follows:
(1) Created a Fortran90 program matsolve.f90
Note: The program compiles fine and prints the proper output for the
simple matrix specified. I have also attached below the file
matsolve.f90 if it helps at all.
(2) f2py matsolve.f90 -m matsolve2 -h matsolve2.pyf
(3) f2py -c matsolve2.pyf --f90exec=/usr/bin/gfortran matsolve.f90
Note: I had to specify the f90 path as f2py did not automatically find
it.

You want to specify the *kind* of Fortran compiler such that f2py knows what
compile/link flags to use. Only use the --f90exec option to inform f2py that the
actual executable is named something odd or is in an unexpected place, like
/opt/gfortran/bin/gfortran-4.3, for example. The correct option to use is

--fcompiler=gnu95

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Hi Robert:

Thanks for the advice and I'll try posting to the mailing list you
mentioned. For what it's worth, the option, --fcompiler=gnu95 yileds
the following error in the second calling of f2py:

error: don't know how to compile Fortran code on platform 'posix' with
'gnu95' compiler. Supported compilers are:
compaq,absoft,i ntel,gnu,sun,f, vast,ibm,lahey, intelv,intele,p g,compaqv,mips, hpux,intelev,na g)

Cheers,

t.

Feb 28 '07 #3
On Feb 28, 12:40 am, Robert Kern <robert.k...@gm ail.comwrote:
Tyler wrote:
Hello All:
Since my last post I have attempted to use the f2py program which
comes with numpy.

It's better to ask these questions on numpy-discussion, instead. There are more
f2py users per capita there.

http://www.scipy.org/Mailing_Lists
I wish the Google Groups interface to the list http://groups.google.com/group/Numpy-discussion
worked. When I use it to post my messages bounce, but messages from
the list do show up on Google Groups. The "bounces" say

"This mailing list is now defunct. Please use
nu************* *@scipy.org to discuss NumPy, Numeric, and numarray.

http://projects.scipy. org/mailman/listinfo/numpy-discussion"

Yes, I know I could follow these instructions, but I prefer to use
Google Groups.

Feb 28 '07 #4
Beliavsky wrote:
On Feb 28, 12:40 am, Robert Kern <robert.k...@gm ail.comwrote:
>Tyler wrote:
>>Hello All:
Since my last post I have attempted to use the f2py program which
comes with numpy.
It's better to ask these questions on numpy-discussion, instead. There are more
f2py users per capita there.

http://www.scipy.org/Mailing_Lists

I wish the Google Groups interface to the list http://groups.google.com/group/Numpy-discussion
worked. When I use it to post my messages bounce, but messages from
the list do show up on Google Groups. The "bounces" say

"This mailing list is now defunct. Please use
nu************* *@scipy.org to discuss NumPy, Numeric, and numarray.

http://projects.scipy. org/mailman/listinfo/numpy-discussion"

Yes, I know I could follow these instructions, but I prefer to use
Google Groups.
Well, you'll have to find out who set up that interface or whoever at Google is
in charge of maintaining such gatewayed groups to let them know that the mailing
list has migrated. I used the "Send email to the owner" link, but I have no idea
who that is supposed to go to.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Feb 28 '07 #5
Robert Kern wrote:
Beliavsky wrote:
>I wish the Google Groups interface to the list http://groups.google.com/group/Numpy-discussion
worked. When I use it to post my messages bounce, but messages from
the list do show up on Google Groups. The "bounces" say

"This mailing list is now defunct. Please use
nu************* *@scipy.org to discuss NumPy, Numeric, and numarray.

http://projects.scipy. org/mailman/listinfo/numpy-discussion"

Yes, I know I could follow these instructions, but I prefer to use
Google Groups.

Well, you'll have to find out who set up that interface or whoever at Google is
in charge of maintaining such gatewayed groups to let them know that the mailing
list has migrated. I used the "Send email to the owner" link, but I have no idea
who that is supposed to go to.
It worked.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Feb 28 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5319
by: Markus Faust | last post by:
Hi, I'm trying to link Fortran files generated with “Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update B)” under “Enthought Edition build 1028, Python 2.3 (#46, Aug 11 2003, 09:34:05) on win32” on Windows-XP”. I changed mingw32_support.py as proposed by Pearu Peterson on April 8 2003 (I changed `if 1:` block into `if 0:` block). When trying the following Python session:
6
2226
by: M. Faust | last post by:
Hi, after having installed F2PY-2.43.239_1806 I get the following error when trying to run the hello.f example from the /docs directory: f2py.py --fcompiler=compaqv -c -m hello hello.f numpy_info: FOUND: define_macros = include_dirs =
0
1485
by: Carl | last post by:
I have been experimenting with f2py and some fortran code that I want to port to Python. I have the following fortran file (TEST_00.f): C FILE: TEST_00.f SUBROUTINE FOO(WORK) IMPLICIT REAL*8 (A-H, O-Z) COMMON /SIZES/ NINT DIMENSION WORK(NINT)
6
2769
by: Sile | last post by:
Hello, I'm trying to get f2py working from the command line on windows XP. I have mingw32 as my C complier (after some advice on a previous thread) and Compaq Visual Fortran 6.5. Changing my C complier reduced my errors but I'm still having trouble. I think I have all the correct paths set but I'm not sure. F2PY gets further when I specifically tell it what my compilers are as follows................. C:\Program...
5
2296
by: Flavio | last post by:
Hi, has anyone tried to build extensions for win32 on Linux using xmingw? I need to use f2py to compile code for the win32 platform and I want to do this in Linux. I googled aroung but could not find any documentation on this. For those who dont know xmingw is a port to linux of mingw.
1
2048
by: Blubaugh, David A. | last post by:
Pauli, Yes, I am utilizing the windows environment. I cannot install f2py. I obtain the following error when I try to execute the setup.py file within the f2py folder located within the numpy master folder: Warning: Assuming default configuration
0
1513
by: Blubaugh, David A. | last post by:
Sir, Thank you for your reply. This is as to how I developed my .pyd file. I entered the following commands within my MS-DOS prompt within Windows XP: C:\python25\ScriptsC:\python25\python f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -m hello hello.f90 I am using the gfortran compiler, that was prescribed to use, as well as, the required commands on the following website: http://www.scipy.org/F2PY_Window...
0
1443
by: Gabriel Genellina | last post by:
En Sun, 21 Sep 2008 19:42:10 -0300, Blubaugh, David A. <dblubaugh@belcan.comescribió: Below there is a transcript of a compile session. I've used a somewhat old version of mingw and g77, scipy 1.1.1, python 2.5.2: C:\TEMP\for>dir /b dscal.for
1
3981
by: bkamrani | last post by:
Hi Python gurus, I have installed numpy and interested in testing f2py module using the first example in the documentation. First I tried: C:\test>python "C:\Program Files\Python25\Scripts\f2py.py" -c fib1.f running build running config_cc unifing config_cc, config, build_clib, build_ext, build commands --
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10607
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10359
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10104
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9182
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.