fortran structure support in gcc4 (on redhat linux 4)

Tobias Burnus burnus@net-b.de
Wed Oct 18 20:57:00 GMT 2006


Hi,

(I cc to the list as there are probably some which know more about VMS
than I do.)

dennis.p.kelly@census.gov wrote:
> This is just a test program to see how much I am in for to migrate from VMS
> to Linux.  After Your TYPE code revision, I then get an error on "RECORD"
> Error: Unclassifiable statement (The code is below)
>   
If I read
http://h21007.www2.hp.com/dspp/files/unprotected/Fortran/docs/lrm/lrm0646.htm
correctly, then this is equivalent to

type(s) :: r(10)

in the example below.

>       PROGRAM fortest
>       TYPE s
>       SEQUENCE ! This makes sure the order is kept
>       real :: x
>       END TYPE
>   

>       RECORD /s/ r(10)      <--- *
>   
type(s) :: r(10)

>       POINTER (s,p)
>   
This should work with -fcray-pointer, but the Fortran 9x way of doing is:
type(s), pointer :: p

>       do i = 1, 10
>          r(i).x = 3.0 * i
>   
r(i)%x = 3.0 * i

>       enddo
>       do i = 1, 10
>          write(*,*) r(i).x
>   
write(*,*) r(i)%x

>       enddo
>       do i = 1, 10
>          write(*,*) SIND(3.0 * i)
>   
real, parameter :: M_PI = 3.1415926535897932384626433832795029
real, parameter :: degree = 2.0*M_PI/360.0
write(*,*) sin(3.0*i *degree)

Tobias



More information about the Fortran mailing list