LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-08-2013, 07:07 AM   #1
surja
LQ Newbie
 
Registered: Jun 2013
Posts: 14

Rep: Reputation: Disabled
compilation problem for gfortran


Hi all,

The problem is coming for different version of gcc compiler .
the f90 program
Tringal.f90 is working without any error in gcc version
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
but for version
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
the error is as

gfortran -c Traingle.f90
Traingle.f90:16.26:

REAL :: a, b, c, Area
1
Error: Symbol 'area' at (1) already has basic type of REAL
Traingle.f90:19.14:

READ *, a, b, c
1
Error: Symbol 'a' at (1) has no IMPLICIT type
Traingle.f90:19.17:

READ *, a, b, c
1
Error: Symbol 'b' at (1) has no IMPLICIT type
Traingle.f90:19.20:

READ *, a, b, c
1
Error: Symbol 'c' at (1) has no IMPLICIT type



The Triangle.f90 program is

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, Area
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
 
Old 07-08-2013, 07:25 AM   #2
surja
LQ Newbie
 
Registered: Jun 2013
Posts: 14

Original Poster
Rep: Reputation: Disabled
Hi all,

The problem is coming for different version of gcc compiler .
the f90 program
Tringal.f90 is working without any error in gcc version
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
but for version
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
the error is as

gfortran -c Traingle.f90
Quote:
Traingle.f90:16.26:

REAL :: a, b, c, Area
1
Error: Symbol 'area' at (1) already has basic type of REAL
Traingle.f90:19.14:

READ *, a, b, c
1
Error: Symbol 'a' at (1) has no IMPLICIT type
Traingle.f90:19.17:

READ *, a, b, c
1
Error: Symbol 'b' at (1) has no IMPLICIT type
Traingle.f90:19.20:

READ *, a, b, c
1
Error: Symbol 'c' at (1) has no IMPLICIT type


The Triangle.f90 program is

Quote:
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, Area
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
 
Old 07-08-2013, 07:58 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,848

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
You should not use the same string both for function and variable (Area).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in installing gcc-gfortran 4.3.3 Kilam orez Linux - Newbie 12 06-29-2011 01:20 AM
have problem with gfortran linker! p.heidary Programming 3 05-07-2011 01:55 PM
Problem installing GFortran on RHEL5 with x86 hippster Red Hat 4 01-20-2011 08:32 AM
gfortran compiling problem, RHEL 4 The_Watcher Linux - Enterprise 1 08-22-2008 11:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration