[petsc-users] Fortran interface -- low level access to petsc data

Tabrez Ali stali at geology.wisc.edu
Sun Oct 27 14:51:01 CDT 2013


On 10/27/2013 12:36 PM, Hossein Talebi wrote:
> Thank you for your answer.
>
> It is not true that F2003 support is that limited: Gfortran, Intel 
> Fortran, Cray Fortran, IBM Fortran and PGI Fortran all support nearly 
> full F2003. Some other ones support the C portability of F2003 
> although not supporting the rest.

You're 100% right but many systems often have older versions of these 
compilers that don't support the Fortran C interoperability. There is 
absolutely no excuse to not upgrade but then its not always possible.

Unless there is a significant gain in functionality (or ease of support) 
by moving to a Fortran 2003 compiler it would be better to be 
conservative. One advantage of being able to build PETSc on a old enough 
system (e.g., Debian Etch with GCC 4.1; glibc 2.4)  is that you can very 
easily build a static binary of your code and it will run pretty much on 
every Linux machine out there.

T

> * I can contribute on creating this interface. I have experience with 
> F2003 to C++ and it works fine while C is a lot easier. My idea is to 
> create the F03 interface to petsc as a separate tool. So, anyone 
> trying to use petsc with a F03 compiler can compile this interface 
> again to avoid the compiler inconsistency of Modules.
>
> We can work on a python (or similar) script to generate the 
> interfaces. For example, a project called gtk-fortran uses this 
> method. Can any of you guys help a little for planning the interface 
> design?
>
>
> Cheers
> Hossein
>
>
>
>
>
>
>
>
>
>
> On Sun, Oct 27, 2013 at 4:42 PM, Satish Balay <balay at mcs.anl.gov 
> <mailto:balay at mcs.anl.gov>> wrote:
>
>     On Sun, 27 Oct 2013, Matthew Knepley wrote:
>
>     > On Sun, Oct 27, 2013 at 6:16 AM, Hossein Talebi
>     <talebi.hossein at gmail.com <mailto:talebi.hossein at gmail.com>>wrote:
>     >
>     > >  Hello All,
>     > >
>     > > I am trying to use petsc with Fortran. The initial mechanism
>     to use petsc
>     > > with FORTRAN77 that works fine. However, I found the Fortran
>     90 interfaces
>     > > difficult to work with. The very first issue is one has to
>     recompile petsc
>     > > with the Fortran compiler in case different to the one which
>     was used to
>     > > create the Fortran Mod files.
>
>     Yes - one cannot mix fortran code compiled with 2 different compilers
>     - or 2 different version of the same compiler wrt modules.
>
>     But we generally recommend not mixing compilers   for C aswell as
>           this
>     can cause problems.
>
>     Also you don't need to use modules to get f90 interfaces. You can
>     include
>     the f90 interface include files    directly in your code.
>
>     #incude "finclude/petsc.h90"
>
>     > > Also, we would still need to use C type
>     > > #include statements along with Fortran 'use' statement which
>     is not so
>     > > optimal.
>
>     Even if you were to use f90 modules #include is unavoidable as we
>     still
>     have other stuff in include files.
>
>     check include/finclude/petscsysdef.h  include/finclude/petscsys.h
>
>     > > Since Fortran 2003 offers great interface to C, did anyone try
>     to write a
>     > > F03 interface to petsc? Using F03 features, we can have very
>     low data
>     > > access to petsc database as well.
>     > >
>     >
>     > F2003 support is fairly thin in the compiler world, and we have
>     not had
>     > much call for it. We do gratefully accept contributions.
>
>     Currently we have the f90 interfaces [in include/finclude/ftn-auto/]
>     automatically generated by bfort tool from the C interface. So to
>     support F03 it would be ideal if there is such a tool. [or update
>     bfort to do it]
>
>     Satish
>
>
>
>


-- 
No one trusts a model except the one who wrote it; Everyone trusts an observation except the one who made it- Harlow Shapley

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131027/5f54e702/attachment.html>


More information about the petsc-users mailing list