Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Fortran Programming Language

VARYING attribute for dealing with Fortran variable arg list


Hi
I have a variable arg function in C which i am calling from Fortran. I
use the following attribute which accounts for this calling convention
from Fortran.

!DEC$ ATTRIBUTES C,VARYING :: c_program.
It works fine in Compaq visual fortran but fails with HP compiler in
Unix and PGI compiler in Linux. The application was building but it
could not be able to fetch the variable arguments and it prints some
junk values for all the variable arguments. I believe this VARYING
attribute is not available in the mentioned compilers and hence it
doesn't recognise the variable arguments. Does anybody aware of
equivalent compiler directives for VARYING in the above platforms!!!!!
kindly let me know.
Best regards
Arun

In article <1179395968.087284.110@y80g2000hsf.googlegroups.com>,
 Arun Prasath <abaru@hotmail.com> wrote:

> I have a variable arg function in C which i am calling from Fortran.

If you are concerned with portability, then I would recommend
writing an interface function in C that takes a fixed number of
arguments and that then calls the other variable argument C
function.  You can then call this interface function from fortran
without so much concern about portability.

There is a common subset of calling sequences that work between the
languages without too much trouble, but there are a lot of things in
fortran (e.g. assumed shape arrays, access through generic
interfaces, module variables) that are difficult to match to C and
there are a lot of things in C (e.g. arrays of function pointers,
varying arguments) that are difficult to match to fortran.

$.02 -Ron Shepard

Hi
Thanks for the suggestion. Yeah...right now the creation of interface
block from Fortran is the only viable option to avoid portability
issues. Any way i have already implemented that and every thing works
fine on all mentioned platforms.
Thanks and regards,
Arun

<abaru@gmail.com> wrote:
> Thanks for the suggestion. Yeah...right now the creation of interface
> block from Fortran is the only viable option to avoid portability
> issues.
> Ron Shepard wrote:
> > In article <1179395968.087284.110@y80g2000hsf.googlegroups.com>,
> >  Arun Prasath <abaru@hotmail.com> wrote:

> > > I have a variable arg function in C which i am calling from Fortran.

> > If you are concerned with portability, then I would recommend
> > writing an interface function in C that takes a fixed number of
> > arguments and that then calls the other variable argument C
> > function.  You can then call this interface function from fortran
> > without so much concern about portability.

It might just be a typographicall slip, but I thought I'd clarify just
in case...

Ron said nothing about an interface block. An interface block is a
specific technical thing in Fortran, and it isn't what Ron was talking
about. He mentioned an interface function, also sometimes called a
wrapper function; neither of those are specific technical terms in
Fortran, but just a descriptive ones.

Interface blocks are also useful when doing C interop. I tend to write
interface blocks for the C functions that I use. With the f2003 C
interop stuff, an interface body is needed to tell the compiler that the
function is a C one. But interface blocks do nothing to address the
issue at hand - C varargs.

--
Richard Maine                    | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle           |  -- Mark Twain

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc