Re: [f2py] What's the preferred way to select a compiler

"Marcel Loose" <loose-JEfgvD5ZcVNmR6Xm/[email protected]> Wed, 22 Jun 2011 10:18:02 +0200
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
On Tue, 2011-06-21 at 21:01 +0300, Pearu Peterson wrote:
> 
> 
> On Tue, Jun 21, 2011 at 4:02 PM, Marcel Loose <loose-JEfgvD5ZcVNmR6Xm/[email protected]> wrote:
>         Hi all,
>         
>         I'm a bit puzzled as to what is the proper way to select a
>         compiler. I
>         noticed that you can either select a compiler by vendor, using
>         the
>         --fcompiler option; or by specifying the full path to f77
>         and/or f90,
>         using --f77exec and/or --f90exec.
>         
> 
> The simplest way is to select a compiler by vendor since in most
> cases the defaults should just work. The --f77exec and
> --f90exec options are useful when either testing f2py with different
> compiler versions of the same vendor or when compilers are installed
> to non-standard
> locations.
> 
>  
>         Related questions:
>              * If I specify --f77exec and/or --f90exec, will these
>         compilers
>                then take precedence?
> 
> They will override the corresponding paths in default --fcompiler
> key. So, if the default is gnu95, and you specify, say,
> --f90exec=/path/to/intel/f90,
> then you'll get problems.
>  
>              * And what's the precedence between f77 and f90?
> 
> When talking about gnu compilers then in recent numpy
> f90, that is --fcompiler=gnu95, is default. In older numpy
> g77 (equivalent to --fcompiler=gnu) was the default.
> 
> 
>              * Do I always need to specify full paths to both f77 and
>         f90.
> 
> No, when numpy.distutils is able to find them from PATH.
> 
> While implementing support for various Fortran compilers,
> I have always specified the compiler by vendor. This means
> that the compilers are assumed to be installed and the
> compiler environment variables are set according to the
> instructions of compiler vendors. People often skip the
> last requirement and then they will need to set the full
> paths to f77 or f90.
> 
> HTH,
> Pearu
> 
> _______________________________________________
> f2py-users mailing list
> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> http://cens.ioc.ee/mailman/listinfo/f2py-users

Hi Pearu,


Thanks for you answers. It clarified things.

The reason my question popped up is that I'm trying to write a CMake
macro add_f2py_module() that can automatically generated a Python module
from a list of Fortran sources, using f2py under the hood.

I could use the CMake variable CMAKE_Fortran_COMPILER, which contains
the full path to the Fortran compiler used throughout the build, as
argument to either --f90exec, --f77exec, or both. However, when I do
that, I notice that f2py will still search for suitable compilers. 

I could also use the CMake variable CMAKE_Fortran_COMPILER_ID, which
contains the "vendor", and use that as argument to --fcompiler. In that
case, f2py does not search for a suitable compiler. However, then there
is a (small) risk that f2py will find a different compiler than CMake
did (e.g., when there's more than one GNU compiler installed).

Or maybe I should use both --fcompiler and --f77exec/--f90exec, using
the CMake variables mentioned above?

What's your suggestion?


Best regards,
Marcel Loose.

-- 
Marcel Loose
Senior Software Engineer, Computing Group R&D, Astron, the Netherlands