Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Lahey Fortran 7.5.1 (windows) and post F95 Code (OOP)

287 views
Skip to first unread message

ben.r...@gmail.com

unread,
Jul 8, 2014, 3:38:39 PM7/8/14
to
Hello,

Sorry if this is a noob problem but I just can't understand what is going on.
We recently purchased a few copies of Lahey Fortran 7.5.1. Lahey support has not been very quick in getting back to me. The web site shows many examples of the use of OO programming, but when we copy the code verbatim to a new console application, the compiler complains with "LF95.exe" exited with code 10.

Does anyone know what is going on? Is there a switch somewhere?

Below is the sample code.

Thank you very much!


module class_Circle
implicit none
private
real :: pi = 3.1409823234

type,public :: Circle
real :: radius
contains
procedure :: area => circle_area
end type Circle
contains
function circle_area(this) result(area)
class(Circle),intent(in) :: this
real :: area
area = pi * this%radius**2
end function circle_area

end module

program circle_test
use class_Circle

real :: radius = 1.5
type(Circle) :: c
c = Circle(radius)
call c%area
end program


Beliavsky

unread,
Jul 8, 2014, 4:03:54 PM7/8/14
to
Gfortran 4.10.0 complains about the line with "call c%area", saying

xcircle.f90:26.16:

call c%area
1
Error: 'area' at (1) should be a SUBROUTINE

mecej4

unread,
Jul 8, 2014, 4:30:45 PM7/8/14
to
The component c%area is declared as a function of type real, but is
being called as a subroutine. You probably need something similar to

real :: acirc
...
acirc = c%area()

in the main program.

Lahey lf95 is a Fortran 95 compiler, and will not understand Fortran
2003 features such as CLASS and procedure components.

-- mecej4

Beliavsky

unread,
Jul 8, 2014, 5:00:33 PM7/8/14
to
On Tuesday, July 8, 2014 4:30:45 PM UTC-4, mecej4 wrote:

> Lahey lf95 is a Fortran 95 compiler, and will not understand Fortran
>
> 2003 features such as CLASS and procedure components.

Lahey Fortran 7.5 http://www.lahey.com/proto/lf75/lf75.htm is actually two compilers, Lahey/Fujitsu Fortran 95 and also Lahey/GNU Fortran, their adapted version of gfortran. If the OP is using Lahey/GNU Fortran, many Fortran 2003 features will be available.

FX

unread,
Jul 8, 2014, 5:03:53 PM7/8/14
to
> Lahey/GNU Fortran, their adapted version of gfortran

Just to be clear: the programming environment is Lahey's, but from what I
understand the gfortran compiler itself (the core) is not adapted. I.e.,
it is the same compiler (diagnostics, features support, generated code)
as the GNU releases.

--
FX

ben.r...@gmail.com

unread,
Jul 8, 2014, 8:33:10 PM7/8/14
to
On Tuesday, July 8, 2014 3:38:39 PM UTC-4, ben.r...@gmail.com wrote:
> Hello,
>
>
>
> Sorry if this is a noob problem but I just can't understand what is going on.
>
> We recently purchased a few copies of Lahey Fortran 7.5.1. Lahey support has not been very quick in getting back to me. The web site shows many examples of the use of OO programming, but when we copy the code verbatim to a new console application, the compiler complains with "LF95.exe" exited with code 10.
>
>
>
> Does anyone know what is going on? Is there a switch somewhere?
>
>
>
> Below is the sample code.
>
>
>
> Thank you very much!
>

Appreciate the feedback everyone. Note that this code is taken directly from the web page on Lahey's site for it's LF Compiler 7.5.
The site is here: http://www.lahey.com/proto/lf75/lf75.htm
Look under the header "Stack Navigation".
They use OOP in several places.

It looks like perhaps we need to switch to the Lahey-GNU compiler.

Louis Krupp

unread,
Jul 9, 2014, 1:04:42 AM7/9/14
to
I think I found the sample code you meant to copy, and it's in a
debugger screen shot with a file name of "circle.f90." You didn't
quite get it verbatim (that's not what human beings are good at), but
that's not what really matters.

What matters is that you're seeing error messages that tell you more
than "exited with code 10." If that's all you're seeing, you have a
different problem (and one that I am gloriously unqualified to help
you with).

Louis

Thomas Koenig

unread,
Jul 10, 2014, 1:52:49 PM7/10/14
to
ben.r...@gmail.com <ben.r...@gmail.com> schrieb:

> real :: pi = 3.1409823234

Huh? More like 3.141592... or, even better,

real, parameter :: pi = 4. * atan(1.0)
0 new messages