Hi Alan, James,


In the attachment you will find a demonstration of the sort of Fortran bindings 
I have in mind. The essence is:

-        Use iso_c_binding to call the C functions directly (no intervening C 
wrapper if that can be avoided)

-        Use the renaming feature of the use statement to switch between single 
and double precision without code duplication. The result is that the bindings 
provide two versions, one for single-precision arguments and one for 
double-precision arguments, which are selected automatically by the compiler. 
(Mixtures of precisions within a single call are not supported - that would 
lead to a very akward combinatorics and I doubt this at all a practical use 
case.)

-        Hide those things like parameters that are not intended for the public 
interface. I will probably go and use "private" as the default and make the 
individual items public instead of what I have now (default "public" and hide 
the things that are not needed)

The source code currently is tuned to example x00f, slightly modified wrt the 
trunk. You can change the worknig precision parameter "wp" to select the other 
precision.

Notes:

-        newbinding.f90 is the topmost source file. All other files are 
included into it.

-        To link the example you need the PLplot C library. See the shell 
script "mk", which was set up for Cygwin

-        With slight modifications this should work on Linux too (there you can 
use the libplplot.so shared object directly).

-        I have not tested this with command-line arguments yet - that is the 
trickier part of the code.

Regards,

Arjen

> -----Original Message-----
> From: Alan W. Irwin [mailto:ir...@beluga.phys.uvic.ca]
> Sent: Sunday, May 17, 2015 7:00 PM
> To: Arjen Markus
> Cc: PLplot development list
> Subject: A possible design of our new Fortran binding
>
> On 2015-05-17 07:38-0000 Arjen Markus wrote:
>
> > My new bindings would not have prevented this [argument kind error], as it 
> > was an
> omission, not an incorrect implementation.
>
> Hi Arjen:
>
> This is an important point that I think needs more discussion because the new
> Fortran binding for ephcom very much prevents such issues from happening.
>
> There I completely dropped all C code and C headers that helped define the old
> fortran binding (the ephcom equivalent to PLplot's plstubs.h, sc3d.c, 
> sccont.c, and
> scstubs.c).  Instead, I used the features of the iso_c_binding module to 
> write the
> interface virtually entirely in Fortran (except for the few cases where 
> iso_c_binding
> did not have some argument processing feature that I had to write from 
> scratch in C).
> So if I had omitted something from the Fortran interface.f90 file, there was 
> no leftover
> C infrastructure that would silently generate a f77 fallback.  Instead, the 
> omission
> would be immediately detected when I attempted to use the missing function.
>
> I am pretty sure it should be possible (since argument transformations from 
> single to
> double or double to single is the only extra
> requirement) to do the same thing for our new Fortran interface.  To make that
> specific, I think our first goal should be to write an
> interface.f90 file that contains complete information to handle single or 
> double
> precision versions of x00f.f90 with no C code required at all to define the 
> interface.
>
> If you agree, then once that first goal is achieved (again with plstubs.h, 
> sc3d.c,
> sccont.c, and scstubs.c removed), we should be able to expand the interface 
> (using
> a C layer where necessary for processing special kinds of arguments) to handle
> standard examples that include use of more complicated PLplot arguments.
>
> Alan
> __________________________
> Alan W. Irwin
>
> Astronomical research affiliation with Department of Physics and Astronomy,
> University of Victoria (astrowww.phys.uvic.ca).
>
> Programming affiliations with the FreeEOS equation-of-state implementation for
> stellar interiors (freeeos.sf.net); the Time Ephemerides project 
> (timeephem.sf.net);
> PLplot scientific plotting software package (plplot.sf.net); the libLASi 
> project
> (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the 
> Linux Brochure
> Project (lbproject.sf.net).
> __________________________
>
> Linux-powered Science
> __________________________

DISCLAIMER: This message is intended exclusively for the addressee(s) and may 
contain confidential and privileged information. If you are not the intended 
recipient please notify the sender immediately and destroy this message. 
Unauthorized use, disclosure or copying of this message is strictly prohibited. 
The foundation 'Stichting Deltares', which has its seat at Delft, The 
Netherlands, Commercial Registration Number 41146461, is not liable in any way 
whatsoever for consequences and/or damages resulting from the improper, 
incomplete and untimely dispatch, receipt and/or content of this e-mail.

Attachment: demo-fortran.tgz
Description: demo-fortran.tgz

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to