Re: A question on Newton's Method
- From: beliavsky@xxxxxxx
- Date: 1 Apr 2005 20:20:09 -0800
Jon Harrop wrote:
> I can't believe you'd advise a noob to use a compiler which is still
getting
> 5 bug reports per day. How can you sleep at night?
G95 compiles and runs the codes listed at
http://www.g95.org/g95_status.html , which include both large
production codes and codes from textbooks. It also compiles my codes.
There are a few classes on Fortran 90 or 95 using g95 as the main
compiler, so some professors think g95 is mature enough for new
programmers.
>
> beliavsky@xxxxxxx wrote:
> > What "computer-specific problems" do you avoid by using OCaml
instead
> > of Fortran? Do you mean "platform-specific"?
>
> No, I mean problems with your numerical code which have nothing to do
with
> maths. My main concern here is non-determinism from:
>
> 1. Out of bounds
> 2. Uninitialised variables
> 3. Aliasing
> ...
The Fortran standard generally does not specify the required behavior
for such errors, but some compilers, including g95, do have good
error-checking, with the proper options enabled. For example, for the
following program
implicit none
real :: x(2),y ! y is not used
x(1) = 1.0
print*,x ! x(2) not set
print*,x(3) ! x(3) not used
end
informative warnings and error messages are issued at both compile time
and run time:
C:\fortran\all>g95 @g95_options.txt xtest.f90
In file xtest.f90:5
print*,x(3)
1
Warning (108): Array reference at (1) is out of bounds
In file xtest.f90:2
real :: x(2),y
1
Warning (137): Variable 'y' at (1) is never used and never set
C:\fortran\all>a.exe
1.000000 1.684729E+20
At line 5 of file xtest.f90 (Unit 6)
Fortran runtime error: Array element out of bounds
> As this is one students seem to have the most problems with. Most
compiler
> bugs probably also fall into this category. Memory leaks are
obviously
> another important class of hassle which most numerical programmers
> shouldn't have to deal with.
Using the ALLOCATABLE arrays of Fortran, one should not encounter
memory leaks.
<snip>
> An interactive programming environment is also particularly important
when
> starting out. Mathematica has an awesome graphical environment (the
> "notebook" front end) and OCaml has it's top-level.
It may be helpful, but it is not essential. The edit-compile-debug
cycle does not bother me. Somehow people learned how to program, using
Fortran, even when they had to use punch cards and wait hours for their
results to come back.
> Finally, the ability to visualise your results is hugely beneficial.
This is
> obviously easiest with Mathematica, followed by OCaml (the built-in
> Graphics module, or the lablGL OpenGL bindings) and then Fortran.
There are many Fortran-callable graphics libraries, such as DISLIN.
In general, your knowledge of Fortran and Fortran compilers appears to
be quite out of date, but that does not prevent you from making
sweeping generalizations about the language.
.
- Follow-Ups:
- Re: A question on Newton's Method
- From: Jon Harrop
- Re: A question on Newton's Method
- From: David M
- Re: A question on Newton's Method
- References:
- A question on Newton's Method
- From: David M
- Re: A question on Newton's Method
- From: Jon Harrop
- Re: A question on Newton's Method
- From: beliavsky
- Re: A question on Newton's Method
- From: Jon Harrop
- A question on Newton's Method
- Prev by Date: Re: Time Series Analysis
- Next by Date: Re: A question on Newton's Method
- Previous by thread: Re: A question on Newton's Method
- Next by thread: Re: A question on Newton's Method
- Index(es):
Relevant Pages
|