By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,491 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,491 IT Pros & Developers. It's quick & easy.

f2py on windows XP - "Unknown Switch"??

P: n/a
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\PCBuil d -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

Aug 21 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a

Sile wrote:
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]

Aug 26 '06 #2

P: n/a
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

Aug 28 '06 #3

P: n/a
On 28/08/2006 6:44 PM, Sile wrote:
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
Aug 28 '06 #4

P: n/a
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\si te-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

Aug 28 '06 #5

P: n/a
On 28/08/2006 9:47 PM, Sile wrote:
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\si te-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
Aug 28 '06 #6

P: n/a
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.
>
THE LINE ABOVE WAS ORIGINALLY:
version_pattern = r'G95.*\(experimental \(g95!\)
(?P<version.*)\).*'

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

Many thanks again,

Sile

Aug 28 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.