Having moved from fixed arrays that were equivalenced to dynamic arrays I'd like to reinstate an equivalent to the old equivalence.
program main use iso_c_binding implicit none real(4) :: ra(0:11,3) integer(4) :: ia(0:11,3) common /x/ ra equivalence(ra(0,1),ia(0,1)) real(4), allocatable :: wra(:,:) integer(4), pointer :: wia_ptr(:,:) ra = 0.0 ra(0,1) = transfer(1,0.0) write(*,'(a,i0)') 'ia(0,1) = ',ia(0,1) allocate(wra(0:11,3), source=0.0) call c_f_pointer(c_loc(wra), wia_ptr, [12,3]) wra(0,1) = transfer(1,0.0) write(*,'(a,i0)') 'wia_ptr(1,1) = ',wia_ptr(1,1) end program main
In order for my application to work I need wia_ptr(0,1) to be valid and == wra(0,1) but I can't work out the syntax. Is it possible using this method or is there another method that I should be using?
Thanks.