Skip to content

Conversation

raehik
Copy link
Collaborator

@raehik raehik commented May 13, 2022

No description provided.

@raehik
Copy link
Collaborator Author

raehik commented May 13, 2022

gfortran has some strange behaviour for implied DO loops:

  • used in a print, the final value of the loop variable is retained
  • used in an assignment, the loop variable is left untouched
program main
    integer i
    integer is(5)
    print *, i                  ! 0
    print *, ( i, i = -1, 2 )
    print *, i                  ! 3
    is = [ (i, i = 2, 6) ]
    print *, is
    print *, i                  ! 3
end

Putting aside the print behaviour, they feel like syntactic sugar. gfortran even tells you if it's the wrong shape for the assigning array, implying it evaluates them to arrays during compilation. Based on this, I feel the assignment inside implied DOs isn't a real assignment, just syntax reuse.

@dorchard
Copy link
Member

The tricky thing is that now we've lost the data flow path due to an assignment...!

@mrd
Copy link
Collaborator

mrd commented May 16, 2022

I wouldn't count on gfortran for sensible/reliable behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants