I'm sorry for my bad english.
th code:
================================
program dadi
implicit none
integer i,j,a
dimension a(2:12)
do i=1,6
do j=1,6
a(i+j) = a(i+j) + 1
enddo
enddo
do i=2,12
write(*,*) i,':',('#',j=1,a(i))
enddo
stop
end
==============================
On intel compiler i have:
~/Documenti/Fortran$ ifc dadi.f -o dadi
program DADI
18 Lines Compiled
~/Documenti/Fortran$ ./dadi
2 :#
3 :##
4 :###
5 :####
6 :#####
7 :######
8 :#####
9 :####
10 :###
11 :##
12 :#
it's OK :)
but with g77 (g77 version 2.95.4 20011002 (Debian prerelease) (from
FSF-g77 version 0.5.25 20010319 (prerelease)) )
I have:
~/Documenti/Fortran$ g77 dadi.f -o dadi
~/Documenti/Fortran$ ./dadi
#############################################################################
##############################################################################
##############################################################################
##############################################################################
##############################################################################
##############################################################################
##############################################################################
##############################################################################
##############################################################################
##############################################################################
##############################################################################
##############################################################################
[KILL]
infinire loop!
????
why?
|
|
0
|
|
|
|
Reply
|
M
|
6/25/2003 1:13:30 PM |
|
On Wed, 25 Jun 2003 13:13:30, -=M=M=-@cippa.lippa.net <-=M=M=-@cippa.lippa.net>
wrote in <_dhKa.118738$Ny5.3397650@twister2.libero.it>:
> program dadi
> implicit none
> integer i,j,a
> dimension a(2:12)
> do i=1,6
> do j=1,6
> a(i+j) = a(i+j) + 1
^^^^^^^^^^^^^^^^^^^
You never initialise the values in a()! There is no guarantee
what values they might hold; some compilers/OSs _might_ initialise them to
zero, but you can't depend on it. So you must implicitly do this yourself.
On all compilers you can use a DO-loop; on modern compilers you can use
the array syntax a=0 to initialise the whole array.
> enddo
> enddo
> do i=2,12
> write(*,*) i,':',('#',j=1,a(i))
> enddo
> stop
> end
>==============================
> On intel compiler i have:
> ~/Documenti/Fortran$ ifc dadi.f -o dadi
> program DADI
> 18 Lines Compiled
> ~/Documenti/Fortran$ ./dadi
> 2 :#
> 3 :##
> 4 :###
> 5 :####
> 6 :#####
> 7 :######
> 8 :#####
> 9 :####
> 10 :###
> 11 :##
> 12 :#
> it's OK :)
> but with g77 (g77 version 2.95.4 20011002 (Debian prerelease) (from
> FSF-g77 version 0.5.25 20010319 (prerelease)) )
> I have:
> ~/Documenti/Fortran$ g77 dadi.f -o dadi
> ~/Documenti/Fortran$ ./dadi
> #############################################################################
> ##############################################################################
> ##############################################################################
> ##############################################################################
> ##############################################################################
> ##############################################################################
> ##############################################################################
> ##############################################################################
> ##############################################################################
> ##############################################################################
> ##############################################################################
> ##############################################################################
> [KILL]
> infinire loop!
--
Ivan Reid, Electronic & Computer Engineering, ___ CMS Collaboration,
Brunel University. Ivan.Reid@brunel.ac.uk Room 40-1-B12, CERN
GSX600F, RG250WD. "You Porsche. Me pass!" DoD #484 JKLO# 003, 005
WP7# 3000 LC Unit #2368 (tinlc) UKMC#00009 BOTAFOT#16 UKRMMA#7 (Hon)
KotPT -- "for stupidity above and beyond the call of duty".
|
|
0
|
|
|
|
Reply
|
Ivan.Reid (496)
|
6/25/2003 1:47:23 PM
|
|
-=M=M=-@cippa.lippa.net wrote:
>
> but with g77 (g77 version 2.95.4 20011002 (Debian prerelease) (from
> FSF-g77 version 0.5.25 20010319 (prerelease)) )
>
> I have:
>
....snip...
> [KILL]
> infinire loop!
> why?
Other than it takes you 36 tries to fill 11 array elements :) I note
that the g77 version info says something about "prerelease" -- I guess
it's got a bug...
|
|
0
|
|
|
|
Reply
|
dp_bozarth (473)
|
6/25/2003 1:48:45 PM
|
|
-=M=M=-@cippa.lippa.net wrote:
> th code:
> ================================
> program dadi
> implicit none
> integer i,j,a
> dimension a(2:12)
>
> do i=1,6
> do j=1,6
> a(i+j) = a(i+j) + 1
> enddo
> enddo
> do i=2,12
> write(*,*) i,':',('#',j=1,a(i))
> enddo
> stop
> end
> ==============================
> On intel compiler i have:
> ~/Documenti/Fortran$ ifc dadi.f -o dadi
> ...
> it's OK :)
> but with g77 (g77 version 2.95.4 20011002 (Debian prerelease) (from
> FSF-g77 version 0.5.25 20010319 (prerelease)) )
> ...
> infinire loop!
> why?
You didn't initialize array a to 0. Unless you do so, the array starts
out undefined. Usually this means that the contents are whatever left-over
stuff is sitting in the memory. IFC is apparently presetting the array
contents to 0, but that behavior is not required by the Fortran standard
and is compiler-specific. On the other hand, g77 does no presetting,
and the output reflects the random contents of a. Both compilers are
acting compatibly with the standard.
--
John Wingate Learning facts takes valuable time that
johnww@worldpath.net could be better spent developing biases.
--Richard Maine
|
|
0
|
|
|
|
Reply
|
johnww (67)
|
6/25/2003 1:52:53 PM
|
|
Jugoslav Dujic wrote:
>
> Duane Bozarth wrote:
> | -=M=M=-@cippa.lippa.net wrote:
> ||
> || but with g77 (g77 version 2.95.4 20011002 (Debian prerelease) (from
> || FSF-g77 version 0.5.25 20010319 (prerelease)) )
> ||
> || I have:
> ||
> | ...snip...
> || [KILL]
> || infinire loop!
> || why?
> |
> | Other than it takes you 36 tries to fill 11 array elements :) I note
> | that the g77 version info says something about "prerelease" -- I guess
> | it's got a bug...
>
> Do we have the "Blind spot of the year" award ;-))) ?
Probably--I shortly after posting realized the problem and tried to
withdraw the post, but it apparently had already gotten out before I was
able to cancel it--(he says with face of red) :(
|
|
0
|
|
|
|
Reply
|
dp_bozarth (473)
|
6/25/2003 7:35:34 PM
|
|
-=M=M=-@cippa.lippa.net wrote:
> but with g77 (g77 version 2.95.4 20011002 (Debian prerelease) (from
> FSF-g77 version 0.5.25 20010319 (prerelease)) )
> ##############################################################################
> [KILL]
> infinire loop!
>
> ????
>
> why?
Well, I hate to say this about my favourite GNU/Linux distribution, but
producing Debian GCC 2.95.4 from a prerelease was a mistake. There are
several bug reports in our bug database (http://gcc.gnu.org) against
this compiler.
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://gcc-g95.sourceforge.net/ (under construction)
|
|
0
|
|
|
|
Reply
|
toon (154)
|
6/25/2003 7:44:27 PM
|
|
Toon Moene wrote:
> -=M=M=-@cippa.lippa.net wrote:
>> [KILL]
>> infinire loop!
>>
>> ????
>> why?
>
>
> Well, I hate to say this about my favourite GNU/Linux distribution, but
> producing Debian GCC 2.95.4 from a prerelease was a mistake. There are
> several bug reports in our bug database (http://gcc.gnu.org) against
> this compiler.
Notwithstanding the truthfullness of this statement, the other
explanation for the behaviour you see that's circulating on this
newsgroup is better.
[ open mouth, insert foot :-( ]
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
GNU Fortran 95: http://gcc-g95.sourceforge.net/ (under construction)
|
|
0
|
|
|
|
Reply
|
toon (154)
|
6/25/2003 7:53:41 PM
|
|
On Wed, 25 Jun 2003 21:53:41 +0200, Toon Moene <toon@moene.indiv.nluug.nl>
wrote in <3EF9FDC5.4060708@moene.indiv.nluug.nl>:
> Toon Moene wrote:
>> Well, I hate to say this about my favourite GNU/Linux distribution, but
>> producing Debian GCC 2.95.4 from a prerelease was a mistake. There are
>> several bug reports in our bug database (http://gcc.gnu.org) against
>> this compiler.
> Notwithstanding the truthfullness of this statement, the other
> explanation for the behaviour you see that's circulating on this
> newsgroup is better.
> [ open mouth, insert foot :-( ]
"Success is 99% failure."
-- Soichiro Honda
:-)
--
Ivan Reid, Electronic & Computer Engineering, ___ CMS Collaboration,
Brunel University. Ivan.Reid@brunel.ac.uk Room 40-1-B12, CERN
|
|
0
|
|
|
|
Reply
|
Ivan.Reid (496)
|
6/25/2003 8:00:41 PM
|
|
|
7 Replies
43 Views
(page loaded in 0.128 seconds)
|