[petsc-dev] What needs to be done before a release?

Barry Smith bsmith at mcs.anl.gov
Fri May 25 22:10:24 CDT 2012


   Tim,

   Thanks. But what I want is all bundled up a routine that takes in the Fortran array of character strings and allocates and copies over them to the C ptr business. Likely I could figure it out myself with but Blaise is such a Fortran wizard he can do it optimally in his sleep :-)

   Barry

On May 25, 2012, at 8:14 PM, Tim Gallagher wrote:

> For what it's worth, I answered a question about how to pass string arrays awhile ago on StackOverflow:
> 
> http://stackoverflow.com/questions/9686532/arrays-of-strings-in-fortran-c-bridges-using-iso-c-binding/9686741#9686741
> 
> Tim
> 
> ----- Original Message -----
> From: "Barry Smith" <bsmith at mcs.anl.gov>
> To: "For users of the development version of PETSc" <petsc-dev at mcs.anl.gov>
> Sent: Friday, May 25, 2012 8:57:52 PM
> Subject: Re: [petsc-dev] What needs to be done before a release?
> 
>  Blaise
> 
>   If you provide a fortran function to convert an array of Fortran strings to an array of C strings and tell us how to delete the result then we'll provide a PetscOptionsGetEnum() for Fortran.
> 
>   Barry
> 
> On May 2, 2012, at 12:02 PM, Blaise Bourdin wrote:
> 
>> Barry,
>> 
>>>> Also, fortran wrappers over PetscOptionsEnum and PetscBagRegisterEnum would be nice. I understand that it
>>>> is a bit tricky since it involves passing fortran arrays of strings.
>>> 
>>>   Yup. We'd be willing to support these from FORTRAN but someone else has to do the dirty work of figuring out how to handle those array of strings (maybe F2003?).
>> 
>> I am attaching a simple proof of concept example that demonstrates how to write a fortran interface and call petsc C functions from fortran using F2003 C-interoperability instead of going through the fortran bindings.
>> 
>> Don't be put off by all the warnings if you use gfortran. They would be easy to avoid. Basically, right now, you detect the fortran integer and real kinds that match that of the C ones. It would be quite simple to get the fortran C-interoperable integer and real types associated with the C type of PetscInt, PetscReal etc.
>> 
>> Basically, we (I?) could write a fortran interface and a fortran function for the tricky functions involving arrays of string, instead of creating a custom binding in C. Are you willing to let some fortran pollution into the petsc code? Where would these function have to be? 
>> 
>> Blaise
>> 
>> PS: you need FCFLAGS='-ffixed-line-length-none  -ffree-line-length-none -ffree-form' or some subset of these to compile with gfortran. I'm not sure why these are not the default with a file suffix .F90
>> 
>> <PetscF2003Binding.F90>
>> -- 
>> Department of Mathematics and Center for Computation & Technology
>> Louisiana State University, Baton Rouge, LA 70803, USA
>> Tel. +1 (225) 578 1612, Fax  +1 (225) 578 4276 http://www.math.lsu.edu/~bourdin
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 




More information about the petsc-dev mailing list