This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran] PR29396 PR29606 PR30625 and PR30871 - subreference array pointers.


I am glad to report that in spite of ignoring WHERE and FORALL masks,
the above patch works quite well with them!

This is an indication of how powerful these features can be when used together:

  type :: t
    logical :: flag
    real :: value
  end type

  type(t), target :: tar(3)

  logical, pointer :: lptr(:)
  real, pointer :: rptr(:)

  tar = (/t(.true., 1.0), t(.false., 3.0), t(.false., 7.0)/)

  lptr => tar%flag
  rptr => tar%value

  print *, "initial values  ", rptr

  forall (i = 1:3, lptr(i)) rptr(i) = 42.0
  forall (i = 1:3, .not.lptr(i)) rptr(i) = 0.0

  print *, "after FORALL    ", rptr

  where (.not.lptr)
    rptr = 77.0
  elsewhere
    rptr = 99.0
  endwhere

print *, "after WHERE     ", rptr

end

Cheers

Paul


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]