Rasmus C. Østergaard writes:
> My problem is that when I turn a "Write(*,*) 'Anything'" command on, the
> result gets wrong.
That kind of symptom is typical of memory getting overwritten. Making
apparently innocuous changes makes different memory get overwritten,
causing different symptoms. That is not the only possible cause,
but it is one to be suspicious of. I'd suggest turning on all
available disgnostic options that the compiler supports, particularly
any options relating to array bounds checking. For the NAG compiler,
the "-C" option should turn on all the available checks.
Another candidate for overwriting memory is argument lists that
don't agree. Carefully check al argument lists, making sure that
the type, kind, and rank of the actual and dummy arguments all
agree. If all your subroutines are in modules, this checking will
automatically be done by the compiler...which is one of the reasons
that I like to put all my subroutines in modules.
> I have used "IMPLICIT NONE" in all subroutines.
That's good.
> My reals are declared as ex.: REAL(KIND=8) :: stress(neqn)
Kind=8 isn't so good. Better is to use a kind number parameter
defined using selected_real_kind. In fact, by default NAG doesn't
even have a kind=8, though it has a switch to activate that kind
numbering scheme.
Thus preferred would be something like
real(r_kind) :: stress(neqn)
(the r_kind is a name I made up - nothing special about it).
You can then define r_kind by something like
integer, parameter :: r_kind=selected_real_kind(12)
which asks for at least 12 decimal digits of precision. If you
don't want to fuss with selected_real_kind, you could even do just
integer, parameter :: r_kind=8
or, using the default Nag kind numbering scheme
integer, parameter :: r_kind=2
As long as you use a named parameter, then at least it is easy
to change if you ever do need to. Using selected_real_kind lowers
the odds that you'll need to change it.
This shouldn't really make a difference to your problem, though.
It is mostly a question of style and portability. (Though since it
isn't NAG's default, that mode probably isn't checked out as well
as the default one.)
> All formulas are written as ex.: dfdx=dsqrt(x)*2.d0*....
Basically never use specific intrinsics like dsqrt. Use just plain
old sqrt. It is a generic, which means that the compiler
automatically selects the appropriate specific routine for the
argument. Dsqrt is a holdover from f66. There really hasn't been
much good reason to use it since f77 came out about 25 years ago.
Mostly it shouldn't make any difference, but dsqrt gives a lot
more opportunity for error (and makes changing precisions harder).
--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
| -- Mark Twain
|