For Programmers: Free Programming Magazines  


Home > Archive > Fortran > March 2007 > Re: Is C faster than fortran?









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 Re: Is C faster than fortran?
highegg

2007-03-30, 7:04 pm

> If I recall correctly, the arrays are about 20 MB.
> I am kind of surprised that they are formulated as automatic
> variables.


That's very common with current Fortran compilers. Automatic arrays
need to be allocated on subroutine entry and deallocated on subroutine
exit, thus they qualify for stack allocation, which is faster than
heap allocation. Compiler-generated temporaries usually also live on
the stack. Allocatable arrays normally go on heap. Some compilers also
offer options to specify the largest array that can be stack-
allocated.

> In the C version, they are allocated using malloc(), so they do not
> exhaust automatic storage.
> Hence the C version does not need excessive stack requirements.

Neither would the Fortran version, if allocatable arrays were used
instead. However, it is a good general idea to increase stack for
Fortran programs - some compilers do that automatically.

Sponsored Links







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

Copyright 2008 codecomments.com