f2py on windows XP - "Unknown Switch"??

S

Sile

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 Files\ESI_Software\SileFortran\ExampleF2PY>f2py
--fcompiler=compaqv -
-compiler=mingw32 -c -m hello hello.f

If I don't specify the compliers it looks for a file cl.exe then
terminates when it can't find it.

Once the compliers are specified it seems to read my fortran code ok,
build the module "hello" and the wrapper function "foo" and writes a
temporary file "hellomodule.c"

Then it seems to use MINGW32 ok.........

The problem arises right at the end when it tries to generate hello.pyd
and I'm not sure why, I've included the error below.

I've tried eveything I can think of but I'm very new to programming so
I'm not having much success.

Any help would be much appreciated.

Thanks,
Sile

DF:f77: hello.f
DF
c:\docume~1\esil\locals~1\temp\tmp-tajpa\Release\docume~1\esil\locals~1\temp\
tmp-tajpa\src.win32-2.3\hellomodule.o
c:\docume~1\esil\locals~1\temp\tmp-tajpa\R
elease\docume~1\esil\locals~1\temp\tmp-tajpa\src.win32-2.3\fortranobject.o
c:\do
cume~1\esil\locals~1\temp\tmp-tajpa\Release\hello.o
-LC:\PROGRA~1\ESI_SO~1\UTILS
_~1\PYTHON~1.3_C\libs
-LC:\PROGRA~1\ESI_SO~1\UTILS_~1\PYTHON~1.3_C\PCBuild -lpyt
hon23 /OUT:.\hello.pyd
DF: error: Unknown switch:
'-LC:\PROGRA~1\ESI_SO~1\UTILS_~1\PYTHON~1.3_C\libs'
error: Command "DF
c:\docume~1\esil\locals~1\temp\tmp-tajpa\Release\docume~1\esi
l\locals~1\temp\tmp-tajpa\src.win32-2.3\hellomodule.o
c:\docume~1\esil\locals~1\
temp\tmp-tajpa\Release\docume~1\esil\locals~1\temp\tmp-tajpa\src.win32-2.3\fortr
anobject.o c:\docume~1\esil\locals~1\temp\tmp-tajpa\Release\hello.o
-LC:\PROGRA~
1\ESI_SO~1\UTILS_~1\PYTHON~1.3_C\libs
-LC:\PROGRA~1\ESI_SO~1\UTILS_~1\PYTHON~1.3
_C\PCBuild -lpython23 /OUT:.\hello.pyd" failed with exit status 1
 
J

John Machin

Sile said:
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.................
[snip]

Sile,

I'd suggest that if you haven't got this sorted yet, you try the f2py
mailing list, or e-mail direct to the package author.

Cheers,
John [who's been away from the net for a week]
 
S

Sile

Cheers John -

I did finally getting f2py working on XP using MinGW, GnuFcompiler for
F77, and much help! However, having set up everything correctly I have
been told in work I now need to use F90. I have downloaded and
installed G95 MinGW in my MinGW directory and this isn't working now,
I'm not having much joy with this! When I check the available fortran
compilers in F2PY I get the following...............

customize Gnu95FCompiler

Could not locate executable f95

Executable f95 does not exist

Could not locate executable f95

Executable f95 does not exist

Could not locate executable f95

Executable f95 does not exist

customize IntelVisualFCompiler

Could not locate executable ifl

Executable ifl does not exist

customize G95FCompiler

Couldn't match compiler version for 'G95 (GCC 4.0.3 (g95 0.90!) Aug 22
2006) Copyright (C) 2002-2005 Free Software Foundation, Inc.nG95 comes
with NO WARRANTY, to the extent permitted by law. You may redistribute
copies of G95under the terms of the GNU General Public License.For more
information about these

................etc.


based on suggestions on the web I changed one line in g95.py to
version_pattern =r'G95.*\(GCC4.01)\(g95!) (?P<version>.\).
Unfortunately this didn't work for me. The problem seems to be with my
gcc version so I'm trying to find a way around this at the moment. Any
suggestions would be much appreciated, I have submitted this problem to
the f2py mailing list too.

thanks,

Sile
 
J

John Machin

Cheers John -

I did finally getting f2py working on XP using MinGW, GnuFcompiler for
F77, and much help! However, having set up everything correctly I have
been told in work I now need to use F90. I have downloaded and
installed G95 MinGW in my MinGW directory and this isn't working now,
I'm not having much joy with this! When I check the available fortran
compilers in F2PY I get the following...............

customize Gnu95FCompiler

Could not locate executable f95

Executable f95 does not exist

Could not locate executable f95

Executable f95 does not exist

Could not locate executable f95

Executable f95 does not exist

customize IntelVisualFCompiler

Could not locate executable ifl

Executable ifl does not exist

customize G95FCompiler

Couldn't match compiler version for 'G95 (GCC 4.0.3 (g95 0.90!) Aug 22
2006) Copyright (C) 2002-2005 Free Software Foundation, Inc.nG95 comes
with NO WARRANTY, to the extent permitted by law. You may redistribute
copies of G95under the terms of the GNU General Public License.For more
information about these

...............etc.


based on suggestions on the web I changed one line in g95.py to
version_pattern =r'G95.*\(GCC4.01)\(g95!) (?P<version>.\).
Unfortunately this didn't work for me. The problem seems to be with my
gcc version so I'm trying to find a way around this at the moment. Any
suggestions would be much appreciated, I have submitted this problem to
the f2py mailing list too.

Ummm shouldn't that be "GCC 4.0.1", not "GCC4.01" ???
Further that pattern seems as though it's been through some web
garbling; for example "&lt;" instead of "<", the parentheses don't
match, the string isn't terminated by a "'", spaces missing, ....

Can you post an ungarbled version of the original line (maybe the
*whole* g95.py -- e-mail if it's too big) and what you changed it to,
plus what your f95 compiler puts out when you run it with --version?

Cheers,
John
 
S

Sile

Thanks for your reply,
Sorry about the last post - pasting from another post didn't work so
well...

The --version output from my f95 compiler is as follows:

C:\>g95 --version
G95 (GCC 4.0.3 (g95 0.90!) Aug 22 2006)
Copyright (C) 2002-2005 Free Software Foundation, Inc.

G95 comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of G95
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

The f95.py file is located under Numpy as follows.......
C:\Program
Files\ESI_Software\UTILS_2006\Python2.3_CFD\Lib\site-packages\numpy\distutils\fcompiler\f95.py

import os
import sys

from numpy.distutils.cpuinfo import cpu
from numpy.distutils.fcompiler import FCompiler

class G95FCompiler(FCompiler):

compiler_type = 'g95'
version_pattern = r'G95.*\(GCC 4.0.3 \(g95!\) (?P<version>.*)\).*'
THE LINE ABOVE WAS ORIGINALLY:
version_pattern = r'G95.*\(experimental \(g95!\)
(?P<version.*)\).*'

executables = {
'version_cmd' : ["g95", "--version"],
'compiler_f77' : ["g95", "-ffixed-form"],
'compiler_fix' : ["g95", "-ffixed-form"],
'compiler_f90' : ["g95"],
'linker_so' : ["g95","-shared"],
'archiver' : ["ar", "-cr"],
'ranlib' : ["ranlib"]
}
pic_flags = ['-fpic']
module_dir_switch = '-fmod='
module_include_switch = '-I'

def get_flags(self):
return ['-fno-second-underscore']
def get_flags_opt(self):
return ['-O']
def get_flags_debug(self):
return ['-g']

if __name__ == '__main__':
from distutils import log
log.set_verbosity(2)
from numpy.distutils.fcompiler import new_fcompiler
#compiler = new_fcompiler(compiler='g95')
compiler = G95FCompiler()
compiler.customize()
print compiler.get_version()


The output from f2py when I check the fortran compilers is.........

C:\>f2py -c --help-fcompiler
....................
Could not locate executable f95
Executable f95 does not exist
customize VastFCompiler
Could not locate executable vf90
Executable vf90 does not exist
customize GnuFCompiler
customize IbmFCompiler
Could not locate executable xlf
Executable xlf does not exist
customize Gnu95FCompiler
Could not locate executable f95
Executable f95 does not exist
Could not locate executable f95
Executable f95 does not exist
Could not locate executable f95
Executable f95 does not exist
customize IntelVisualFCompiler
Could not locate executable ifl
Executable ifl does not exist
customize G95FCompiler
Couldn't match compiler version for 'G95 (GCC 4.0.3 (g95 0.90!) Aug 22
2006)\nCo
pyright (C) 2002-2005 Free Software Foundation, Inc.\n\nG95 comes with
NO WARRAN
TY, to the extent permitted by law.\nYou may redistribute copies of
G95\nunder the terms of the GNU General Public License.\nFor more
information about these matters, see the file named COPYING'
customize IntelItaniumFCompiler
Could not locate executable efc
Executable efc does not exist
customize PGroupFCompiler
Could not locate executable pgf77
Executable pgf77 does not exist
customize LaheyFCompiler
Could not locate executable lf95
Executable lf95 does not exist
customize CompaqVisualFCompiler
customize MipsFCompiler
customize HPUXFCompiler
customize IntelItaniumVisualFCompiler
Could not locate executable efl
Executable efl does not exist
customize IntelEM64TFCompiler
Could not locate executable efc
Executable efc does not exist
List of available Fortran compilers:
--fcompiler=compaqv DIGITAL|Compaq Visual Fortran Compiler (6.5)
--fcompiler=gnu GNU Fortran Compiler (3.4.5)

I hope that makes it a bit clearer,

Thanks,

Sile
 
J

John Machin

Thanks for your reply,
Sorry about the last post - pasting from another post didn't work so
well...

The --version output from my f95 compiler is as follows:

C:\>g95 --version
G95 (GCC 4.0.3 (g95 0.90!) Aug 22 2006)
Copyright (C) 2002-2005 Free Software Foundation, Inc. [snip]
The f95.py file is located under Numpy as follows.......
C:\Program
Files\ESI_Software\UTILS_2006\Python2.3_CFD\Lib\site-packages\numpy\distutils\fcompiler\f95.py

Looks like asking the Numpy folks might be a good idea ...
import os
import sys

from numpy.distutils.cpuinfo import cpu
from numpy.distutils.fcompiler import FCompiler

class G95FCompiler(FCompiler):

compiler_type = 'g95'
version_pattern = r'G95.*\(GCC 4.0.3 \(g95!\) (?P<version>.*)\).*'

That won't match the guff your f95 puts out. The "!)" appears *after*
the version number. See below.

|>>> import re
|>>> guff = 'G95 (GCC 4.0.3 (g95 0.90!) Aug 22 2006) etc etc'
|>>> vp1 = r'G95.*\(GCC 4.0.3 \(g95!\) (?P<version>.*)\).*'
|>>> vp2 = r'G95.*\(GCC 4.0.3 \(g95 (?P<version>.*)!\).*'
|>>> m1 = re.match(vp1, guff)
|>>> print m1
None
|>>> m2 = re.match(vp2, guff)
|>>> print m2
<_sre.SRE_Match object at 0x00AED9E0>
|>>> print m2.group('version')
0.90
|>>>

THE LINE ABOVE WAS ORIGINALLY:
version_pattern = r'G95.*\(experimental \(g95!\)
(?P<version.*)\).*'

No it wasn't. It would have had a ">" after "version" :)

HTH,
John
 
S

Sile

Thanks John,

Your help is very much appreciated - my f2py finally recognises my
fortran compiler - I'm very relieved!
That won't match the guff your f95 puts out. The "!)" appears *after*
the version number. See below.

|>>> import re
|>>> guff = 'G95 (GCC 4.0.3 (g95 0.90!) Aug 22 2006) etc etc'
|>>> vp1 = r'G95.*\(GCC 4.0.3 \(g95!\) (?P<version>.*)\).*'
|>>> vp2 = r'G95.*\(GCC 4.0.3 \(g95 (?P<version>.*)!\).*'

I changed my g95 file so that version_pattern was correct.
No it wasn't. It would have had a ">" after "version" :)
oops!

Many thanks again,

Sile
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top