Re: variable content lost



On Mar 30, 6:03 pm, lis...@xxxxxxxxx wrote:
Hi,
I just started writing in Fortran90 using gfortran on Mac OSX.

When you are using one compiler and getting stuck, its a good idea to
try another one. G95 is free and available on Mac OSX.

At the
moment I am startled by this issue, which I couldnt resolve on my own:
[code]
...
write (*, '(A,F5.2)') "before:", fib%r(id,1)
call segment_distance(fib%r(id,1:3), fib%p(id,:), fib%r(m,:),&
fib%p(m,:))
write (*, '(A,F5.2)') "after", fib%r(id,1)
...
subroutine segment_distance(r, p, rr, pp)
real(dp), dimension(3), intent(in) :: r, p, rr, pp
...
end subroutine segment_distance

I don't see anything wrong, but a compilable code that reproduces the
error would be helpful.
Are you sure that that all the arrays passed to segment_distance have
dimension 3? Is the subroutine in a MODULE (which I recommend)? Can
you change the subroutine above to use assumed-shape array arguments
so that it looks like

subroutine segment_distance(r, p, rr, pp)
real(dp), dimension(:), intent(in) :: r, p, rr, pp

and check that size(r)=size(p)=size(rr)=size(pp)=3?

[/code]
The first write results in the expected "before:11.00" (defined some
place before). But I do not understand why I get "after 0.00".
If further information is required, I will happily provide more
details.
I would be glad if someone could give me a hint here.

Christian


.



Relevant Pages

  • Re: Is this a compiler error?
    ... First order of business is to change the 'pure' in the functions x, y, z, since this would give a compiler error or it should give a compiler error. ... subroutine initialize ... pure subroutine random_s ... It is very common that integer overflow is silent. ...
    (comp.lang.fortran)
  • Re: DPROD issues
    ... a switch like that typically ... makes a compiler nonstandard in that mode. ... treatment of specific intrinsics is one ... subroutine sub1a ...
    (comp.lang.fortran)
  • Re: Jumping into block of an if construct
    ... (For that matter a clever enough compiler could replace this PUT DATA ... routine which itself executes the loops around element handling. ... Either way I think the cost of element handling will usually ... So locally based on subroutine arguments, but not on, for example, ...
    (comp.lang.fortran)
  • Re: Bus error/ segmentation fault--help?
    ... When I compile with the intel fortran compiler, ... This subroutine integrates the function y3 up one step, ... implicit double precision (a-h, o-z) ...
    (comp.lang.fortran)
  • Re: Question about name conflicts in Fortran
    ... I am hacking the g95 compiler so that it dumps the structure ... Subroutine foo ... The para after the 2nd numbered list in 16.2 covers the case where the ... One of the exceptions is "a generic name may be the ...
    (comp.lang.fortran)