Fortran 77 simple code question 
Author Message
 Fortran 77 simple code question

I am compiling a piece of fortran 77 code with the G77 compiler.

My compiler is throwing an error on:

Fortran:
--------------------------------------------------------------------------------
ANSB=AMAX1(ANSN,QUAD1A,QUAD1B,QUAD1C,QUAD1D,
     &        QUAD1E,QUAD1F,QUAD1G,QUAD1H,
     &      QUAD1I,QUAD1J,QUAD1K,QUAD1L,
     &      QUAD2A,QUAD2B,QUAD2C,QUAD2D,
     &      QUAD3A,QUAD3B,QUAD3C,QUAD3D)
--------------------------------------------------------------------------------

x3500.f:1755:
ANSB=AMAX1(ANSN,QUAD1A,QUAD1B,QUAD1C,QUAD1D,
^
Reference to intrinsic `AMAX1' at (^) invalid -- one or more arguments
have incorrect type

I think it is the way it is spaced or the location or use of the "&"?
Do you know how i should change it so it is ok and is not over 72
characters long on 1 line?



Sat, 26 Nov 2005 23:05:28 GMT  
 Fortran 77 simple code question

Quote:
>I am compiling a piece of fortran 77 code with the G77 compiler.

>My compiler is throwing an error on:

>Fortran:
>--------------------------------------------------------------------------------
>ANSB=AMAX1(ANSN,QUAD1A,QUAD1B,QUAD1C,QUAD1D,
>     &        QUAD1E,QUAD1F,QUAD1G,QUAD1H,
>     &      QUAD1I,QUAD1J,QUAD1K,QUAD1L,
>     &      QUAD2A,QUAD2B,QUAD2C,QUAD2D,
>     &      QUAD3A,QUAD3B,QUAD3C,QUAD3D)
>--------------------------------------------------------------------------------

>x3500.f:1755:
>ANSB=AMAX1(ANSN,QUAD1A,QUAD1B,QUAD1C,QUAD1D,
>^
>Reference to intrinsic `AMAX1' at (^) invalid -- one or more arguments
>have incorrect type

>I think it is the way it is spaced or the location or use of the "&"?
>Do you know how i should change it so it is ok and is not over 72
>characters long on 1 line?

 What types are the arguments (e.g. real, double precision, integer..etc)?


Sat, 26 Nov 2005 17:08:53 GMT  
 Fortran 77 simple code question

Quote:

> I am compiling a piece of fortran 77 code with the G77 compiler.

> My compiler is throwing an error on:

> Fortran:
> --------------------------------------------------------------------------------
> ANSB=AMAX1(ANSN,QUAD1A,QUAD1B,QUAD1C,QUAD1D,
>      &        QUAD1E,QUAD1F,QUAD1G,QUAD1H,
>      &      QUAD1I,QUAD1J,QUAD1K,QUAD1L,
>      &      QUAD2A,QUAD2B,QUAD2C,QUAD2D,
>      &      QUAD3A,QUAD3B,QUAD3C,QUAD3D)
> --------------------------------------------------------------------------------

> x3500.f:1755:
> ANSB=AMAX1(ANSN,QUAD1A,QUAD1B,QUAD1C,QUAD1D,
> ^
> Reference to intrinsic `AMAX1' at (^) invalid -- one or more arguments
> have incorrect type

> I think it is the way it is spaced or the location or use of the "&"?
> Do you know how i should change it so it is ok and is not over 72
> characters long on 1 line?

My assumption: Your code snippet contained tab characters and actually looks something
like:
C2345678901234567890<--- column counters
        ANSB=AMAX1(ANSN,QUAD1A,QUAD1B,QUAD1C,QUAD1D,
     &      QUAD1E,QUAD1F,QUAD1G,QUAD1H,
     &      QUAD1I,QUAD1J,QUAD1K,QUAD1L,
     &      QUAD2A,QUAD2B,QUAD2C,QUAD2D,
     &      QUAD3A,QUAD3B,QUAD3C,QUAD3D)
in your code with the "&" characters occurring in column 6.

So, the error message says "one or more arguments have incorrect type". Have you looked
into what arguments AMAX1 expects (default reals) and whether that agrees with the type
definitions of your argument list? I believe that all the arguments must have the same
type.

cheers,

paulv

--
Paul van Delst

Ph: (301)763-8000 x7748
Fax:(301)763-8545



Sat, 26 Nov 2005 23:23:19 GMT  
 Fortran 77 simple code question
Quote:

> I am compiling a piece of fortran 77 code with the G77 compiler.

> My compiler is throwing an error on:

> Fortran:
> --------------------------------------------------------------------------------
> ANSB=AMAX1(ANSN,QUAD1A,QUAD1B,QUAD1C,QUAD1D,
>      &        QUAD1E,QUAD1F,QUAD1G,QUAD1H,
>      &      QUAD1I,QUAD1J,QUAD1K,QUAD1L,
>      &      QUAD2A,QUAD2B,QUAD2C,QUAD2D,
>      &      QUAD3A,QUAD3B,QUAD3C,QUAD3D)
> --------------------------------------------------------------------------------

> x3500.f:1755:
> ANSB=AMAX1(ANSN,QUAD1A,QUAD1B,QUAD1C,QUAD1D,
> ^
> Reference to intrinsic `AMAX1' at (^) invalid -- one or more arguments
> have incorrect type

> I think it is the way it is spaced or the location or use of the "&"?
> Do you know how i should change it so it is ok and is not over 72
> characters long on 1 line?



Sat, 26 Nov 2005 23:48:04 GMT  
 Fortran 77 simple code question

Quote:

> Reference to intrinsic `AMAX1' at (^) invalid -- one or more arguments
> have incorrect type

Well, it seems at least vaguely possible that perhaps one or more
arguments have incorrect type.  :-)

You haven't either mentioned what type the arguments are or shown us
the relevant parts of the code (the declarations) so that we can verify
it ourselves.  Although it is certainly possible that some other
subtle thing might be causing a misleading error message, I'd go with
the simplest theory first - that the error is exactly what the message
says.  Have you checked that?  You didn't mention anything about it.

--
Richard Maine
email: my last name at domain
domain: isomedia dot com



Sun, 27 Nov 2005 03:20:45 GMT  
 Fortran 77 simple code question
I was able to find out that AMAX1 is a function for determining the
largest number in a list of numbers.  The G77 compiler for some reason
did not recognize this function so when I saw some code on the web
using DMAX1 instead i changed it to that and it works perfectly now.
Does anyone know if there is a difference between AMAX1 and DMAX1?


Mon, 28 Nov 2005 21:22:11 GMT  
 Fortran 77 simple code question

Quote:
>I was able to find out that AMAX1 is a function for determining the
>largest number in a list of numbers.  The G77 compiler for some reason
>did not recognize this function so when I saw some code on the web
>using DMAX1 instead i changed it to that and it works perfectly now.
>Does anyone know if there is a difference between AMAX1 and DMAX1?

  If you had paid attention to previous replies to your original
question you would have checked the types of your arguments and
no doubt found them to be double precision - which is what dmax1 is
expecting - so it works, whereas amax1 is expecting single precision
arguments, so it doesn't.

 Usually (depending on compiler) there's a generic form- e.g. amax()
for which the compiler checks the argument types and substitutes
the correct specific function.

Chris



Mon, 28 Nov 2005 16:01:38 GMT  
 Fortran 77 simple code question

Quote:

> I was able to find out that AMAX1 is a function for determining the
> largest number in a list of numbers.  The G77 compiler for some reason
> did not recognize this function so when I saw some code on the web
> using DMAX1 instead i changed it to that and it works perfectly now.
> Does anyone know if there is a difference between AMAX1 and DMAX1?

Yes, g77 does so recognize the AMAX1 function.  The error message made
it pretty explicit that g77 did recognize the function and knew that
you were using it incorrectly.  If your source of information says
nothing more about AMAX1 than that it "is a function for determining
the largest number in a list of numbers", then I suggest you should
use a better source of information in the future.  Any Fortran textbook
should do; if you find a textbook that doesn't give better information
than that, please let us know so we can avoid it.  Information about
the type of things is *ABSOLUTELY CRITICAL*; if you don't keep types
straight, then your code will have all kinds of errors, some of them
compilation errors, and some of them just wrong results.  It really
matters.  There is a huge difference between 2/3 and 2.0/3.0; you
need to understand what that difference is or your code *WILL* have
errors.

Yes, there is a difference between AMAX1 and DMAX1, but you really should
use neither.  Both of them are throwbacks to Fortran 66.  As of f77,
there was no longer any reason to use these, but many people were used
to old habits..and then taught the old habits to younger people.

Use just plain MAX.  It is generic and takes arguments of any numeric
type (though all the arguments do have to be of the same type).

AMAX1 is an old form from before generics were introduced in f77;
it takes only real (single precision) arguments.  DMAX1 is a form
from the same era that takes only double precision arguments.

The language (and g77) still supports the old AMAX1 and DMAX1 forms,
but there really is no reason to ever use them in new code ("new"
meaning less than about 20 years old in this case).  For some of the
other old specific names, there are occasional obscure cases where
they just might possibly be useful, but they are pretty rare...and I
can't think of any of those cases that would apply to AMAX1 and DMAX1.

--
Richard Maine                       |  Good judgment comes from experience;
email: my first.last at org.domain  |  experience comes from bad judgment.
org: nasa, domain: gov              |        -- Mark Twain



Tue, 29 Nov 2005 00:05:58 GMT  
 Fortran 77 simple code question

Quote:

>  Usually (depending on compiler) there's a generic form- e.g. amax()
> for which the compiler checks the argument types and substitutes
> the correct specific function.

Not just "usually".  Always..anyway since f77.  It is part of the standard,
and the name is MAX().

--
Richard Maine                       |  Good judgment comes from experience;
email: my first.last at org.domain  |  experience comes from bad judgment.
org: nasa, domain: gov              |        -- Mark Twain



Tue, 29 Nov 2005 00:08:05 GMT  
 Fortran 77 simple code question


Quote:
> Yes, there is a difference between AMAX1 and DMAX1, but you really should
> use neither.  Both of them are throwbacks to Fortran 66.  As of f77,
> there was no longer any reason to use these, but many people were used
> to old habits..and then taught the old habits to younger people.

> Use just plain MAX.  It is generic and takes arguments of any numeric
> type (though all the arguments do have to be of the same type).

> AMAX1 is an old form from before generics were introduced in f77;
> it takes only real (single precision) arguments.  DMAX1 is a form
> from the same era that takes only double precision arguments.

What about AMAX0 and MAX1, a real result from integer arguments, or integer
result from real arguments, respectively?

-- glen



Tue, 29 Nov 2005 01:23:41 GMT  
 Fortran 77 simple code question


Quote:

> What about AMAX0 and MAX1, a real result from integer arguments, or
integer
> result from real arguments, respectively?

As Richard said, Max is the generic name for all these specific names
("Fortran 90/95 Explained", Table 11.1). It's in the book!

Regards,

Mike Metcalf



Tue, 29 Nov 2005 01:31:19 GMT  
 Fortran 77 simple code question

Quote:

> What about AMAX0 and MAX1, a real result from integer arguments, or integer
> result from real arguments, respectively?

Those are different.  There is at least some argument for using them
because they don't quite directly translate to just MAX; they are MAX
plus a type conversion.  I don't happen to think the argument for
using them is very good, but I at least acknowledge that there is
a point there.  I can see no reason at all for using MIN0, AMAX1, or
DMAX1 (if I've got the names straight) in new code.

--
Richard Maine                       |  Good judgment comes from experience;
email: my first.last at org.domain  |  experience comes from bad judgment.
org: nasa, domain: gov              |        -- Mark Twain



Tue, 29 Nov 2005 02:11:47 GMT  
 Fortran 77 simple code question

Quote:



>> What about AMAX0 and MAX1, a real result from integer arguments, or
>integer
>> result from real arguments, respectively?

>As Richard said, Max is the generic name for all these specific names
>("Fortran 90/95 Explained", Table 11.1). It's in the book!

I don't have that book but I do have Adams et al "Fortran 95 Handbook".
I failed to find how MAX1 should convert real to integer, so it might
be a good idea to decide which of INT, NINT, FLOOR, CEILING is really
needed and say so, e.g. MAX(INT(x),INT(y)) or whatever. Try this:

REAL:: x1 = 0.1, x2 = 0.9, x3 = -0.1, x4 = -0.9
PRINT*,'INT     ',INT    (x1),INT    (x2),INT    (x3),INT    (x4)
PRINT*,'NINT    ',NINT   (x1),NINT   (x2),NINT   (x3),NINT   (x4)
PRINT*,'FLOOR   ',FLOOR  (x1),FLOOR  (x2),FLOOR  (x3),FLOOR  (x4)
PRINT*,'CEILING ',CEILING(x1),CEILING(x2),CEILING(x3),CEILING(x4)
PRINT*,'MAX1    ',MAX1(x1,x1),MAX1(x2,x2),MAX1(x3,x3),MAX1(x4,x4)
END

The 3 compilers I used (NAG, Compaq, Forte) all suggested MAX1 uses INT,
but does the standard insist? The nearest I found was that INT must be
used in assignment statements like i = x where i is integer, x real.

John Harper, School of Mathematical and Computing Sciences,
Victoria University, PO Box 600, Wellington, New Zealand



Tue, 29 Nov 2005 07:58:29 GMT  
 Fortran 77 simple code question
FORTRAN 77 doesn't say much that I can find about how MAX1 works.  It
just gives a table (page 15-23) that says  
choosing largest value;  MAX1;  argument type = real;  result = integer
without saying how that happens.

Fortran 95 says in table 13.13 that the specific
name MAX1(...) is equivalent to the generic "name" INT(MAX(...)) where
the arguments to MAX are default real type.  

Would it ever make a difference if a processor instead did something
like  MAX(INT(a1),INT(a2)...)?  I'm not sure you could tell.  

In general, I believe that when the standard says something like
"convert to integer" it means using the assignment rules, ie truncate
towards zero; unless there are specific other qualifiers which imply
ceiling, etc.

Dick Hendrickson

Quote:





> >> What about AMAX0 and MAX1, a real result from integer arguments, or
> >integer
> >> result from real arguments, respectively?

> >As Richard said, Max is the generic name for all these specific names
> >("Fortran 90/95 Explained", Table 11.1). It's in the book!

> I don't have that book but I do have Adams et al "Fortran 95 Handbook".
> I failed to find how MAX1 should convert real to integer, so it might
> be a good idea to decide which of INT, NINT, FLOOR, CEILING is really
> needed and say so, e.g. MAX(INT(x),INT(y)) or whatever. Try this:

> REAL:: x1 = 0.1, x2 = 0.9, x3 = -0.1, x4 = -0.9
> PRINT*,'INT     ',INT    (x1),INT    (x2),INT    (x3),INT    (x4)
> PRINT*,'NINT    ',NINT   (x1),NINT   (x2),NINT   (x3),NINT   (x4)
> PRINT*,'FLOOR   ',FLOOR  (x1),FLOOR  (x2),FLOOR  (x3),FLOOR  (x4)
> PRINT*,'CEILING ',CEILING(x1),CEILING(x2),CEILING(x3),CEILING(x4)
> PRINT*,'MAX1    ',MAX1(x1,x1),MAX1(x2,x2),MAX1(x3,x3),MAX1(x4,x4)
> END

> The 3 compilers I used (NAG, Compaq, Forte) all suggested MAX1 uses INT,
> but does the standard insist? The nearest I found was that INT must be
> used in assignment statements like i = x where i is integer, x real.

> John Harper, School of Mathematical and Computing Sciences,
> Victoria University, PO Box 600, Wellington, New Zealand




Wed, 30 Nov 2005 02:12:29 GMT  
 Fortran 77 simple code question


Quote:
> FORTRAN 77 doesn't say much that I can find about how MAX1 works.  It
> just gives a table (page 15-23) that says
> choosing largest value;  MAX1;  argument type = real;  result = integer
> without saying how that happens.

> Fortran 95 says in table 13.13 that the specific
> name MAX1(...) is equivalent to the generic "name" INT(MAX(...)) where
> the arguments to MAX are default real type.

> Would it ever make a difference if a processor instead did something
> like  MAX(INT(a1),INT(a2)...)?  I'm not sure you could tell.

I wondered about that, too.  As far as I can see mathematically, the result
is the same either way.  It might be that MAX1 allows the implementation to
do the conversion before or after max, as is faster on that implementation.
Conversion time can vary greatly between implementations, some have hardware
support and some don't.

MAX1 and AMAX0 exist in Fortran 66, and maybe earlier.

-- glen



Wed, 30 Nov 2005 03:16:34 GMT  
 
 [ 21 post ]  Go to page: [1] [2]

 Relevant Pages 

1. A Very Simple Fortran 77 question

2. Fortran 77 code using Fortran 90 compiler

3. problems converting Fortran 77 code to Fortran 90

4. Beginner-Need simple math libraries FORTRAN 77

5. Simple Array to File problem in fortran 77

6. simple Fortran 77 programming problem

7. Machine Code in Fortran 77

8. Reading Undocumented fortran 77 source code.

9. Using JNI to interface Fortran 77 codes

10. Coding EOF in FORTRAN 77?

11. Fortran 77 code that employs Neville's Algorithm for Interpolation and Differentiation of Tabular Data

12. need to call a C++ function from within a fortran 77 code

 

 
Powered by phpBB® Forum Software