Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double array access is not lexed #19

Open
madgen opened this issue Jun 1, 2016 · 4 comments
Open

Double array access is not lexed #19

madgen opened this issue Jun 1, 2016 · 4 comments
Assignees

Comments

@madgen
Copy link
Member

madgen commented Jun 1, 2016

program example
  arr(1)(1:1) = x
end program example

Need to check if this is even valid Fortran.

@madgen madgen self-assigned this Jun 1, 2016
@dorchard
Copy link
Member

dorchard commented Nov 2, 2016

I've seen this used in some of corpus.
Here is an example which (for what its worth) is accepted by gfortran:

program dubsub
  implicit none
  character(5), dimension(10) :: x
  x(1)(1:3) = 'a'
end program

@madgen
Copy link
Member Author

madgen commented Nov 2, 2016

Just because compiler handle it doesn't necessarily mean it is valid Fortran. Though this probably is. There is a grammatical reason that I didn't resolve it earlier. I will attend to it when I can.

@dorchard
Copy link
Member

dorchard commented Nov 2, 2016

I think this might be a Fortran 90 feature. In the FORTRAN 77 standard section 5.3 suggests that we have to have an array name as the subject of a subcript a (s [,s]) (http://www.fortran.com/fortran/F77_std/rjcnf-5.html#sh-5.3).
In Fortran 90, an array element is a 'data-ref' followed by zero or more subscripts (Section 6.2.2) and a data-ref can be a subscript expression itself (Section 6.1.2) (ftp://ftp.nag.co.uk/sc22wg5/N001-N1100/N692.pdf).

@jme52
Copy link

jme52 commented Jan 28, 2018

If x is a rank-1 character array, x(1)(1:3) is valid Fortran 77 code for a substring formed by the first 3 characters of the element of the array with index 1.

If x is not a rank-1 character array, I can't think of any valid meaning of the expression x(1)(1:3).

Please bear in mind that section 5.3 of the Fortran 77 standard is about array elements - character substrings are discussed in section 5.7, see #63. The corresponding part of the Fortran 90 standard is section 6.1.1.

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

No branches or pull requests

3 participants