Roland Schilling wrote:
> On Fri, 14 Oct 2005, Michael E. Burke wrote:
>
>
>>The snippet now reads:
>>
>> MODULE Triangle_Operations
>> IMPLICIT NONE
>> CONTAINS
>> FUNCTION Area(x,y,z)
>> REAL :: Area ! function type
>> REAL, INTENT( IN ) :: x, y, z
>> REAL :: theta, height
>> theta = ACOS((x**2+y**2-z**2)/(2.0*x*y))
>> height = x*SIN(theta); Area = 0.5*y*height
>> END FUNCTION Area
>> END MODULE Triangle_Operations
>>
>> PROGRAM Triangle
>> USE Triangle_Operations
>> IMPLICIT NONE
>> REAL :: a, b, c
>> PRINT *, 'Welcome, please enter the&
>> &lengths of the 3 sides.'
>> READ *, a, b, c
>> PRINT *, "Triangle's area: ", Area(a,b,c)
>> END PROGRAM Triangle
>>
>>And the error message I get is:
>>
>>In ASIN(x) or ACOS(x), ABS(x).gt.1.0 (x=-0.220000005e+01).
>> Error occurs at or near line 8 of _triangle_operations@_area_
>> Called from or near line 20 of _MAIN__
>
>
> This is strange. On my Linux system it compiles and runs well
> using the NAG f95, the Intel f95 or the GNU g95 compiler.
>
> Roland
>
Doesn't it depend on the input values? The error message
probably means that a**2 + b**2 - c**2 is -2.2 and he
doesn't have a triangle.
To be robust, you need to do some checks on the input
values.
Dick Hendrickson
|