[petsc-dev] Fortran 2003 enum

Blaise Bourdin bourdin at lsu.edu
Wed Dec 8 16:36:02 CST 2010


Hi,

>> On Tue, Dec 7, 2010 at 20:05, Barry Smith <bsmith at mcs.anl.gov> wrote:
>> In fact many of the Fortran manual bindings come from string issues.
>> 
>> Why has this not been automated?  I don't know the bfort source, but is it somehow fundamentally hard?
> 
>  It is not fundamentally hard, just a few different cases for different compilers and a bit of a pain in the butt to automate. We've managed ok without automating. If you tried to do it in bfort I think you (like Matt) would bitch and scream and swear that bfort should be rewritten in python :-)
> 
>   Anyways the issue with what Blaise wants is arrays of strings, we have no experience with arrays of strings, someone would just need to sit down and see how all Fortran compilers handle them and then write stubs to deal with them. Never been a priority for use because didn't know that Blaise wanted this.  Could be done.

Wow, I didn't know I had such powers ;)
I would have done it myself if it didn't involve passing strings. I don't understand C strings in general and I understand the magic involved in the fortran bindings involving strings even less.

> 
>   But if 2003 provides a standard way of doing this then we could just use that and save the manual work.
I have done a little bit of reading and asked for help on the intel fortran compiler forum. 
(see http://software.intel.com/en-us/forums/showthread.php?t=79287&p=1#136682 )
I am attaching an example showing how to pass scalar by value or address, arrays of scalar, and arrays of strings. This last one was tricky and even though it compiles and runs fine using the intel and gnu compilers, I am not completely sure that it is legit. I am waiting on feedback from the intel people.

You have access to more machines than I do, so perhaps you can test this example on several platforms? If it works, would you consider using this mechanism in cases where standard bindings are tricky?

Regards,
Blaise

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cfunc.c
Type: application/octet-stream
Size: 772 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20101208/7851ce0c/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cfunc.h
Type: application/octet-stream
Size: 175 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20101208/7851ce0c/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makefile
Type: application/octet-stream
Size: 304 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20101208/7851ce0c/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestF2003_C.f90
Type: application/octet-stream
Size: 2110 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20101208/7851ce0c/attachment-0003.obj>
-------------- next part --------------

-- 
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