aliased intent(in out) arguments

beliavsky_at_aol.com
Date: 10/26/04

  • Next message: James Giles: "Re: aliased intent(in out) arguments"
    Date: 25 Oct 2004 21:56:26 -0700
    
    

    Is the program below standard-conforming Fortran 95? A subroutine with
    two intent(in out) arguments is called with both arguments being the
    same variable. None of the Windows Fortran 95 compilers I tried
    complain and simply print i=3 at the end.

    This test program is motivated by a Usenet posting of Alex Martelli
    with subject "Re: By value or by reference" in comp.lang.python at
    http://groups.google.com/groups?q=fortran&hl=en&lr=&group=comp.lang.python.*&c2coff=1&scoring=d&selm=1glwh14.11nk6427up7a6N%25aleaxit%40yahoo.com&rnum=5
    .

    module foo
    implicit none
    contains
    subroutine incboth(i,j)
    integer, intent(in out) :: i,j
    i = i + 1
    j = j + 2
    end subroutine incboth
    end module foo

    program xinc
    use foo, only: incboth
    implicit none
    integer :: i
    i = 0
    call incboth(i,i) ! same variable for 2 intent(in out) arguments
    print*,i
    end program xinc


  • Next message: James Giles: "Re: aliased intent(in out) arguments"
  • Quantcast