For Programmers: Free Programming Magazines  


Home > Archive > Fortran > August 2005 > is this program ok?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author is this program ok?
Bart Vandewoestyne

2005-08-22, 7:02 pm

Today, I came across a situation that I can summarize in the
following test-program:

program test_permtable_assignment

type :: my_pointer
integer, dimension(:), pointer :: p
end type my_pointer

integer :: i, j
integer, dimension(10) :: bases = (/ (i, i=1,10) /)
type(my_pointer), dimension(size(bases)) :: table

do i=1,size(bases)
allocate(table(i)%p(bases(i)))
table(i)%p = (/ (j, j=0,bases(i)-1) /)
end do

end program test_permtable_assignment


When I compile this with

Intel(R) Fortran Compiler for 32-bit applications, Version 7.0 Build 20021028Z

I get no errors or warnings:


bartv@vonneumann:~/fortran$ make test_permtable_assignment
ifc -o test_permtable_assignment -g -C -e95 -Tf test_permtable_assignment.f95
program TEST_PERMTABLE_ASSIGNMENT

16 Lines Compiled


but i do get the runtime error:


bartv@vonneumann:~/fortran$ ./test_permtable_assignment

Run-Time Error 406: Array bounds exceeded

In Procedure: main program

Diagnostics Entered From MAIN PROGRAM Line 13

End of diagnostics


g95 and the F-compiler compiled and run this cleanly, so I could not understand
why ifc complained on this. Therefore, i tested with another version of the
Intel compiler:

Intel(R) Fortran Compiler for 32-bit applications, Version 9.0 Build 20050430Z

And with this version I don't get the runtime error anymore.


My only question to this group is now: was ifc version 7 indeed wrong and is
this program standard Fortran 90/95 conforming, or should I be suspicious and
is there indeed something wrong with that piece of code?

Regards,
Bart

--
"Share what you know. Learn what you don't."
[JvO]

2005-08-23, 7:00 pm

Yes, there must be a bug in the old
2002 version of ifc.

[JvO]

Bart Vandewoestyne

2005-08-23, 7:00 pm

On 2005-08-23, [JvO] <jvo_36@hotmail.com> wrote:
> Yes, there must be a bug in the old
> 2002 version of ifc.


OK. Thanks for confirming what I was thinking :-)

Regards,
Bart

--
"Share what you know. Learn what you don't."
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com