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: 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)
  • Re: using dot_product from c++
    ... I tried to write a very simple subroutine where two vector are dot ... Assumed shape arrays are incompatible with mixed language use unless you code explicitly for the descriptor on the other side, which will be highly nonportable (even from one version of a compiler to another, let alone from one compiler to another). ... You should either not initialize the vectors or you should not use push_back but instead reference the location you wish to access directly. ... I guess maybe it arises because the misunderstandings between the codes multiply to put the memory manager out of whack. ...
    (comp.lang.fortran)