Hi,
Can anyone comment on the following example code?
It is about using alloctable arrays inside a derived type.
Is this a f90 or f95 feature ? I ask because the code
was sucessfullly compiled under ifort. But not under
gfortran and compaq alpha fortran compiler.
I think I can achieve the same goal by using
pointer inside the derived type. But I am
skeptical of using pointer.
How about the speed of the code using
a dervied type containing allocatable arrays?
Thanks and happy holidays.
Xiaogang
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
program test
implicit double precision (a-h,o-z)
type array2d
double precision, allocatable :: h(:,:)
end type
type (array2d) :: hmat(2)
integer :: nbas(2)
nbas(1) = 2
nbas(2) = 3
do i = 1, 2
allocate( hmat(i)%h(nbas(i),nbas(i)) )
hmat(i)%h = dble(i) + 1
end do
do i = 1, 2
write(*,*)'i=',i
write(*,'(f10.3)') hmat(i)%h(:,:)
end do
end program test
------------------------------------------------
Dr Xiaogang Wang
Departement de chimie
Universite de Montreal
C.P. 6128, succursale Centre-ville
Montreal (Quebec) H3C 3J7
Tel. (514) 3436111 ext 3947 (office)
FAX (514) 3437586 (office)
e-mail: [log in to unmask]
homepage: http://www.esi.umontreal.ca/~wangx
------------------------------------------------
|