Re: Using user defined type in Fortan 77 subroutines
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Tue, 15 Sep 2009 18:39:41 -0700
Hifi-Comp <wenbinyu.heaven@xxxxxxxxx> wrote:
TYPE (DN) FUNCTION DDOT(N,DX,INCX,DY,
+INCY)
USE TEST
C
C FORMS THE DOT PRODUCT OF TWO VECTORS.
C USES UNROLLED LOOPS FOR INCREMENTS EQUAL TO ONE.
C JACK DONGARRA, LINPACK, 3/11/78.
C
TYPE (DN) DX(*),DY(*),DTEMP
INTEGER I,INCX,INCY,IX,IY,M,MP1,N
60 DDOT = DTEMP
RETURN
END
DNAD.f90
MODULE TEST
TYPE,PUBLIC:: DN
REAL(8)::x
REAL(8)::xp
END TYPE DN
END MODULE TEST
Using CVF IDE on a PC, I can simply create a project containing these
two files. Both files can be compiled without any problem. Howeve, to
use gfortran in Linux system,
I do the following
gfortran -c DNAD.f90
DNAD.o and test.mod are generated.
Hower, when I compile blas.for using
gfortran -c blas.for
I got the following error messages:
In file blas.for:9
TYPE (DN) DX(*),DY(*),DTEMP
1
Error: Type name 'dn' at (1) is ambiguous
In file blas.for:11
60 DDOT = DTEMP
1
Error: Derived type 'dn' at (1) is being used before it is defined
In file blas.for:1
TYPE (DN) FUNCTION DDOT(N,DX,INCX,DY,
1
Error: The derived type 'ddot' at (1) is of type 'dn', which has not
been defined.
Doesn't look to me like this has anything at all to do with f77-related
issues, or for that matter with how you do the compilation. No wonder I
couldn't figure out what you were asking about. This is simply failure
of the code to compile and has nothing to do with it being originally
f77 or with any of the other issues that you mentioned.
Looks to me like the main problem is that you use the type DN prior to
the USE statement that makes it available. Apparently the CVF compiler
allows this, but gfortran does not.
To tell the truth, I forget whether the standard allows this case or
not. If it does allow it, then you have a bug report against gfortran.
I'll allow others to figure out whether or not such a bug report is
needed.
But my recommendation, regardless of whether the standard allows the
practice, is not to do it. It just asks for problems. If the standard
does allow it, then it is as a special-case exception to the general
rule. I know there are at least some such special-case exceptions, but I
have never bothered to memorize what cases they cover and what cases
they omit. I find it preferable to avoid their use.
Instead, I recommend taking the TYPE(DN) off of the function statement.
Replace it with a type declaration statement (after the USE) as in
type(dn) :: ddot
As I said, I don't recall whether the standard says that your original
code should work, but this change is "safer" anyway.
P.S. This is about example 42 billion of probably the most universal
advice on posting problem reports here. Don't try to describe the
problem. Odds are the description will be wrong anyway. Instead, show us
the problem. There is simply no way anyone could have figured this out
from the description in the original post. Some of us do occasionally
get flashes of vision in our crystal balls, but I don't think anyone has
a crystal ball that would have been up to that.
I'm not 100% sure that we have the problem completely solved yet. Some
of those error messages slightly puzzled me, but I'm hoping that they
were just fallout from the issue that I do see. In any case, I think we
can make progress from here.
--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
.
- Follow-Ups:
- Re: Using user defined type in Fortan 77 subroutines
- From: Hifi-Comp
- Re: Using user defined type in Fortan 77 subroutines
- References:
- Using user defined type in Fortan 77 subroutines
- From: Hifi-Comp
- Re: Using user defined type in Fortan 77 subroutines
- From: Richard Maine
- Re: Using user defined type in Fortan 77 subroutines
- From: Hifi-Comp
- Using user defined type in Fortan 77 subroutines
- Prev by Date: Re: Why are Variable-Length Character Strings Taking so Long to ??Implement?
- Next by Date: Re: Using user defined type in Fortan 77 subroutines
- Previous by thread: Re: Using user defined type in Fortan 77 subroutines
- Next by thread: Re: Using user defined type in Fortan 77 subroutines
- Index(es):
Relevant Pages
|