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

trailing double underscores


A few weeks ago, someone asked if Sun f95 had an option
to append double trailing underscores to global names to
create linker names instead of the single trailing underscores
it normally uses.  Sun f95 does not have such an option.
My personal preference is not to provide such an option.

The reason given for wanting the option was that the CDF
library required it.  Are there other libraries that require the
use of double underscores?

Bob Corbett

On 22 mei, 08:34, robert.corb@sun.com wrote:

> A few weeks ago, someone asked if Sun f95 had an option
> to append double trailing underscores to global names to
> create linker names instead of the single trailing underscores
> it normally uses.  Sun f95 does not have such an option.
> My personal preference is not to provide such an option.

> The reason given for wanting the option was that the CDF
> library required it.  Are there other libraries that require the
> use of double underscores?

> Bob Corbett

Quite apart from any merits these double underscores might
have (personally I think they are a nuisance), could not
this issue be solved with a small module:

module cdf_double_underscores
    interface my_routine
        my_routine_
    end interface
    ...
end module cdf_double_underscores

where "my_routine" is the routine name to be used in one's
own code and "my_routine_" is the name of the library routine
with one underscore stripped - the compiler will decorate it
with an extra underscore, giving the required two underscores
at the end.

Of course, writing this module is tedious work, but nothing
complicated.

Regards,

Arjen

robert.corb@sun.com wrote:
> A few weeks ago, someone asked if Sun f95 had an option
> to append double trailing underscores to global names to
> create linker names instead of the single trailing underscores
> it normally uses.  Sun f95 does not have such an option.
> My personal preference is not to provide such an option.

> The reason given for wanting the option was that the CDF
> library required it.  Are there other libraries that require the
> use of double underscores?

As the compiler which typically used the double underscores has not been
maintained for several years, I would think that the perceived need for
such an option should be diminishing.
As if by magic, Tim Prince appeared !

> robert.corb@sun.com wrote:
>> A few weeks ago, someone asked if Sun f95 had an option
>> to append double trailing underscores to global names to
>> create linker names instead of the single trailing underscores
>> it normally uses.  Sun f95 does not have such an option.
>> My personal preference is not to provide such an option.

>> The reason given for wanting the option was that the CDF
>> library required it.  Are there other libraries that require the
>> use of double underscores?

> As the compiler which typically used the double underscores has not been
> maintained for several years, I would think that the perceived need for
> such an option should be diminishing.

Hmmmmm, I'm obviously getting more cynical ...

I would think that the need for such an option should be diminishing.
The perceived need is a totally different vessel of haddock,

Ian

On May 22, 1:34 am, robert.corb@sun.com wrote:

> A few weeks ago, someone asked if Sun f95 had an option
> to append double trailing underscores to global names to
> create linker names instead of the single trailing underscores
> it normally uses.  Sun f95 does not have such an option.
> My personal preference is not to provide such an option.

> The reason given for wanting the option was that the CDF
> library required it.  Are there other libraries that require the
> use of double underscores?

> Bob Corbett

I think there is a need for a general purpose alias/synonym capability
to allow specification of prefixes/suffixes for external names.

<gary.l.sc@lmco.com> wrote:
> I think there is a need for a general purpose alias/synonym capability
> to allow specification of prefixes/suffixes for external names.

Sounds like the BIND(C,NAME=...) specifier in the F2003 C interop. It
doesn't do anything like general rules though - just one procedure at a
time.

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

On May 22, 2:34 am, robert.corb@sun.com wrote:

> A few weeks ago, someone asked if Sun f95 had an option
> to append double trailing underscores to global names to
> create linker names instead of the single trailing underscores
> it normally uses.  Sun f95 does not have such an option.
> My personal preference is not to provide such an option.

An observation from our own experience - the peculiar double-
underscore decoration when the name already contains an underscore is
a g77 quirk (I can think of other words...).  Since there are a lot of
libraries coded in C but built to be called from g77, it's handy to
have such an option in other compilers.

As g77 fades into the sunset, perhaps the effort needed to properly
implement the double-underscore decoration isn't worth it in 2007, but
we do see people still using this option with Intel Fortran.

Steve

On May 22, 10:35 am, nos@see.signature (Richard Maine) wrote:

> <gary.l.sc@lmco.com> wrote:
> > I think there is a need for a general purpose alias/synonym capability
> > to allow specification of prefixes/suffixes for external names.

> Sounds like the BIND(C,NAME=...) specifier in the F2003 C interop. It
> doesn't do anything like general rules though - just one procedure at a
> time.

Its probably close enough.  I was hoping for something more general
purpose, but in practice it will probably work.  One of the things I'd
sometimes like to do is to provide alias' to Fortran routines (not
necessarily for C interoperability), but to for example provide a long/
verbose name and a short alias (perhaps even for Fortran 77
compatibility or just for those of us that just hate 30 character
procedure names).

A somewhat similar solution, but down at the Unix assembler level, is
something that I cooked up when faced with having to link with some
libraries (with no source available) that were compatible with my
Fortran compiler(s).

I take the linker "undefined symbol" output, remove all lines except
those containing "undefined", and use those to prepare a list of
undefined symbols such as this, for example:

        dgetrs
        dpotrf
        dgemm
        idamax

I take this list and pipe it into this C program:
________________________
#include <stdio.h>
#include <string.h>

int main(){
char exnam[51],lnam[51];
printf("\t.data\n");
while(fgets(exnam,50,stdin)){
     *(strchr(exnam,'\n'))='\0';
     strcpy(lnam,exnam);
         strlwr(lnam);
         printf(".globl _%s\n_%s: \n\t.long\t%s\n\n",
                 exnam,exnam,lnam);
         }

}

_________________________

and put this output into an assembler file that I then link to the
sources to resolve the undefined symbols:

                .data
        .globl _dgetrs
        _dgetrs:
                .long   dgetrs

        .globl _dpotrf
        _dpotrf:
                .long   dpotrf

        .globl _dgemm
        _dgemm:
                .long   dgemm

        .globl _idamax
        _idamax:
                .long   idamax

-- mecej4

On May 22, 12:34 am, robert.corb@sun.com wrote:

> My personal preference is not to provide such an option.

May I ask why your personal preference is not to?
I, as the one who had the problem with the CDF library, would have
saved quite a bit of time. A workaround was eventually found, but
instead of just specifying one compiler option I had to change a
number of macros in the Makefile, which by the way I wouldn't have
figured out on my own.
I know little about making compilers, but it just doesn't seem like a
big deal to enable such an option if it can be useful to a customer.
Not that I was implying Sun has to do it right away, but I am
surprized the issue has lead to a discussion where most people seem to
oppose the idea of having this option.

robert.corb@sun.com wrote:

> The reason given for wanting the option was that the CDF
> library required it.  Are there other libraries that require the
> use of double underscores?

Isn't that an error in the CDF library with their support for the Sun
compiler?

Fly Away <victor.proso@gmail.com> wrote:
> On May 22, 12:34 am, robert.corb@sun.com wrote:

> > My personal preference is not to provide such an option.

> May I ask why your personal preference is not to?

While I can't answer for Robert, and he might well have reasons
completely unrelated to any I could imagine... I can imagine some.

Compiler options like that bring with them a raft of support
complications. You run into things like having trouble mixing code that
was compiled with different option settings. This in turn sometimes
means that library providers need to provide code compiled both ways...
and handle all the support issues of people getting the wrong one. That
or you end up with libraries that are incompatible with each other. For
example, I could imagine things like being unable to use the
aforementioned CDF library and, say, IMSL, in the same program.

So in solving one problem, you open up a bunch of others.

I don't know how big the problems would be for the particular option in
question.

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

Fly Away wrote:
> On May 22, 12:34 am, robert.corb@sun.com wrote:

>>My personal preference is not to provide such an option.
> May I ask why your personal preference is not to?
> I, as the one who had the problem with the CDF library, would have
> saved quite a bit of time. A workaround was eventually found, but
> instead of just specifying one compiler option I had to change a
> number of macros in the Makefile, which by the way I wouldn't have
> figured out on my own.

Next someone will want an option for two leading underscores, or
three trailing underscores.  Also, different compilers have different
calling sequences which may be incompatible, so it might be that even
if a compiler can make the names agree it still won't be able to
use the library.

My choice would be either not to supply such an option or to
supply one as general as possible.  One could, for example,
give the parameters for the sed substitute (s) command that would
convert one name to another.  That would allow for fairly
general transformations between names.

But then some require in addition the number of byte of parameters
to be appended, so one should also allow for that.

-- glen

Craig Powers wrote:
> robert.corb@sun.com wrote:

>> The reason given for wanting the option was that the CDF
>> library required it.  Are there other libraries that require the
>> use of double underscores?

> Isn't that an error in the CDF library with their support for the Sun
> compiler?

Where does the CDF documentation say which compilers are supported?
It's confusing enough about which year of compilers are supported.  It
talks about DVF, and appears to consider g77 as THE STANDARD FORTRAN.
All of that may have been appropriate about 8 years ago, but then it
talks about expecting to support x86-64 some time in 2006.  It might be
simpler if they had source code available.

> Next someone will want an option for two leading underscores, or
> three trailing underscores.  

If 3 other compilers supply such an option and someone finds it
useful, or in my case necessary, I don't see why there is so much
resistance to it. It's not like enabling this option would require a
big change in design or using some sophisticated algorithms...

> Where does the CDF documentation say which compilers are supported?
> It's confusing enough about which year of compilers are supported.  It
> talks about DVF, and appears to consider g77 as THE STANDARD FORTRAN.
> All of that may have been appropriate about 8 years ago, but then it
> talks about expecting to support x86-64 some time in 2006.  It might be
> simpler if they had source code available.

The source code of CDF library is available.

Fly Away wrote:
>>Next someone will want an option for two leading underscores, or
>>three trailing underscores.  

No, this shouldn't be done with compiler switches, it should be
something generic and inline like name aliasing in which you can add any
prefix, suffix, or mid-fix you want.

> If 3 other compilers supply such an option and someone finds it
> useful, or in my case necessary, I don't see why there is so much
> resistance to it. It's not like enabling this option would require a
> big change in design or using some sophisticated algorithms...

--

Gary Scott
mailto:garylscott@sbcglobal dot net

Fortran Library:  http://www.fortranlib.com

Support the Original G95 Project:  http://www.g95.org
-OR-
Support the GNU GFortran Project:  http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows
it can't be done.

-- Henry Ford

I didn't look at it extensively.  I just noted that there was a current
website, which did have a support address.

[snip]

If one has GNU binutils, one can fix the object code with the
objcopy tool. Specifically in this case, the --rename-sym[s] options.

--
Janne Blomqvist

On May 21, 11:34 pm, robert.corb@sun.com wrote:

> A few weeks ago, someone asked if Sun f95 had an option
> to append double trailing underscores to global names to
> create linker names instead of the single trailing underscores
> it normally uses.

Someone pointed out in e-mail that I misunderstood the option
being requested.  I was told that the trailing double
underscores should be appended only if the name in the
source program contains an underscore; otherwise, a
single trailing underscore should be appended.  Thus, given
the CALL statement

      CALL TEST()

the linker name of the called routine would be test_, but
given the CALL statement

      CALL TEST_()

the linker name would be test___ (three underscores).

Bob Corbett

On May 22, 8:27 am, gary.l.sc@lmco.com wrote:

> I think there is a need for a general purpose alias/synonym capability
> to allow specification of prefixes/suffixes for external names.

I recently proposed adding an option to Sun f95 to specify
a file containing a list of aliases.  The aliases could be
quite general.  A name in a Fortran source program could be
mapped to any name the assembler and linker could handle.
Using a compiler option has the advantage that the source
code does not have to change.

My proposal was intended as a solution to a longstanding
problem with the option to change the default type kind
parameters.  In the case of Sun f95, the option is named
-xtypemap.  People who use -xtypemap to map REAL to REAL*8
and DOUBLE PRECISION to REAL*16 would still like to use
the BLAS and LAPACK routines from Sun's Performance Library
without having to change their source code.  Under my
proposal, the user could supply a file with a list of
aliases such as

      SAPXY=>daxpy_
      DAXPY=>qaxpy_

The compiler would use the alias as the linker name for the
called routine.

My proposal was not well received.

Bob Corbett

On May 22, 2:17 pm, Fly Away <victor.proso@gmail.com> wrote:

> On May 22, 12:34 am, robert.corb@sun.com wrote:

> > My personal preference is not to provide such an option.

> May I ask why your personal preference is not to?

Sure.

When I say it is my personal preference, I mean exactly
that.  It is not an official position of Sun or even of
Sun's Fortran engineering team.

I have no idea what the scope of the problem is.  Your
posting to Sun's Fortran Forum was the first time I heard
about the problem.  As I noted in my response, Sun's
Fortran team does not have a lot of Linux experience yet.
If the number of libraries that use the double underscores
convention is small, it is not worth the pain of adding a
new option.  That is why I asked if there are other such
libraries.

Adding the option is likely to encourage production and
maintenance of libraries that use incompatible naming
conventions.  In the long run, that hurts users.

I have long been an advocate of having common Fortran ABIs
for the common platforms.  I would like libraries for use
with Fortran programs to be independent of the particular
compiler being used.  I have dabbled in writing proposals
for such ABIs.  I would be more enthusiastic about spending
time on such proposals if I thought there were a chance they
would ever be adopted.

> I, as the one who had the problem with the CDF library, would have
> saved quite a bit of time. A workaround was eventually found, but
> instead of just specifying one compiler option I had to change a
> number of macros in the Makefile, which by the way I wouldn't have
> figured out on my own.
> I know little about making compilers, but it just doesn't seem like a
> big deal to enable such an option if it can be useful to a customer.

It would not be difficult to provide such an option.
Perhaps a day of coding, a week of testing, and a year
of getting the other software development tools to
understand the implications of the new option.

The problem is that I don't think most users would be
better off if Sun f95 provided such an option than they
would be if it did not.  If the number of libraries that
have the problem CDF has is small, I think it would be
better to try to produce versions of the libraries that
are compatible with Sun f95 than to provide an option to
make code generated by Sun f95 compatible with the
libraries.

Bob Corbett

> If 3 other compilers supply such an option and someone finds it
> useful, or in my case necessary, I don't see why there is so much
> resistance to it. It's not like enabling this option would require a
> big change in design or using some sophisticated algorithms...

As Bob Corbett said: a day of coding, a week of testing, a month of updating
all the documentation, and a year until all the tools know about it.

I agree with him that, in the long run, it is better to squash this g77
idiosyncrasy once and for all. And get the CDF people to support current F95
et seq. compilers properly. In all likelihood, it would be cheaper for Sun to
do that than to support the feature requested.

        Jan

On May 23, 1:51 am, Jan Vorbrggen

> I agree with him that, in the long run, it is better to squash this g77
> idiosyncrasy once and for all. And get the CDF people to support current F95
> et seq. compilers properly.

I don't want anyone to think I hold the CDF people at fault
here.  It would have been a bit much to expect them to
anticipate what Sun C and Sun f95 on Linux would look like.
We are the new kids in this playground, not them.

Bob Corbett

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