Discussion:
etime
François-Xavier Coudert
2004-09-22 15:33:20 UTC
Permalink
Hello,

I am trying to use gfortran to compile scientific code (including BLAS,
LAPACK and ARPACK packages), but my compilation (using gfortran-20040922)
fails at linking:

undefined reference to `etime_'

Is there a problem I cannot see, or is ETIME not yet included in gfortran ?

Thanks for you help,
FX

PS : please Cc me as I'm no suscriber of this mailing-list
--
Engineering: "How will this work?"
Science: "Why will this work?"
Management: "When will this work?"
Liberal Arts: "Do you want fries with that?"
Tobias Schlüter
2004-09-22 15:51:35 UTC
Permalink
Post by François-Xavier Coudert
Hello,
I am trying to use gfortran to compile scientific code (including BLAS,
LAPACK and ARPACK packages), but my compilation (using gfortran-20040922)
undefined reference to `etime_'
Is there a problem I cannot see, or is ETIME not yet included in gfortran ?
Hm, gfortran has both an etime subroutine and an etime function. I just tried
them, and they work (as documented in the g77 documentation, we don't yet seem
to have our own documentation). There's an issue that I found: if one tries to
use both the function and the subroutine in the same program unit, one gets a
compiler error.

Could you provide some example source code illustrating your problem?

- Tobi
François-Xavier Coudert
2004-09-22 15:59:18 UTC
Permalink
Post by Tobias Schlüter
Could you provide some example source code illustrating your problem?
Here is a minimal example, working well with g77.

pc31 ~ $ cat sec.f
PROGRAM MAIN

REAL SECOND
REAL T1
REAL TARRAY( 2 )
REAL ETIME
EXTERNAL ETIME

T1 = ETIME( TARRAY )
SECOND = TARRAY( 1 )

END

pc31 ~ $ g77 sec.f

pc31 ~ $ /opt/gfortran/gfortran-20040922/bin/gfortran sec.f
/tmp/ccypfi8q.o(.text+0xd): In function `MAIN__':
: undefined reference to `etime_'
collect2: ld returned 1 exit status
--
Everyone who comes in here wants three things:
1. They want it quick.
2. They want it good.
3. They want it cheap.
I tell 'em to pick two and call me back.
-- sign on the back wall of a small printing company in Delaware
Tobias Schlüter
2004-09-24 12:07:56 UTC
Permalink
ETIME is declared EXTERNAL in LAPACK. g77 calls the intrinsic nonetheless, so
Post by François-Xavier Coudert
Here is a minimal example, working well with g77.
pc31 ~ $ cat sec.f
PROGRAM MAIN
REAL SECOND
REAL T1
REAL TARRAY( 2 )
REAL ETIME
EXTERNAL ETIME
T1 = ETIME( TARRAY )
SECOND = TARRAY( 1 )
END
We use different calling ocnventions for intrinsics and extrernal functions
(because we want to evade copying of arrays where possible), so I propose this
workaround.

I assume that g77 works with most of its intrinsics declared EXTERNAL, but
instead of trying to fix all of them, I suggest fixing them one at a time as
they appear. If we want to fix all at a time, we should have a field
indicating "this intrinsic takes its arguments in the g77 way", and not use
prefix on their implementations.

Anyway, patch below. Built and verified that it works as expected.

- Tobi

2004-09-24 Tobias Schlueter <***@physik.uni-muenchen.de>

* etime.c (etime_): New function.

Index: etime.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/intrinsics/etime.c,v
retrieving revision 1.2
diff -u -p -r1.2 etime.c
--- etime.c 21 Jun 2004 22:25:12 -0000 1.2
+++ etime.c 24 Sep 2004 12:07:38 -0000
@@ -78,3 +78,22 @@ prefix(etime) (gfc_array_r4 *t)
prefix(etime_sub) (t, &val);
return val;
}
+
+/* LAPACK's test programs declares ETIME external, therefore we
+ need this. */
+
+GFC_REAL_4
+etime_ (GFC_REAL_4 *t)
+{
+ gfc_array_r4 desc;
+ GFC_REAL_4 val;
+
+ /* We only fill in the fields that are used in etime_sub. */
+ desc.dim[0].lbound = 0;
+ desc.dim[0].ubound = 1;
+ desc.dim[0].stride = 1;
+ desc.data = t;
+
+ prefix(etime_sub) (&desc, &val);
+ return val;
+}
Paul Brook
2004-09-24 16:34:14 UTC
Permalink
Post by Tobias Schlüter
* etime.c (etime_): New function.
Ok.

Paul

François-Xavier Coudert
2004-09-22 16:07:37 UTC
Permalink
Post by Tobias Schlüter
Could you provide some example source code illustrating your problem?
OK, using the code I posted in the brother message of this one, I can get it
working if I remove the 'external ETIME' declaration.

I don't know if it's a normal situation (I suppose not), but at least I can
work around this issue.

Sorry for the annoyance,
FX
--
Neurotics build castles in the sky,
Psychotics live in them,
And psychiatrists collect the rent.
Loading...