- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I started using Intel Fortran on my Linux machine. I am trying to do the following: exploit the column-major memory management of Fortran in order to go from 1D array of pointers into 2D arrays. Here is an example:
PROGRAM main
REAL, DIMENSION(:), POINTER :: U
ALLOCATE(U(IMAX*JMAX*KMAX))
...
CALL getslice(U(1))
...
CONTAINS
SUBROUTINE getslice(V)
real, dimension(IMAX,JMAX), intent(IN) :: V
...
END SUBROUTINE getslice
END PROGRAM main
As you can see from this sample code, I am passing the pointer to the first entry of U to the subroutine, which receives a 2D array. I always did this, with pathscale and also Intel compiler but on different architectures. Now with Intel on Linux it does not work (I am using .f90 files):
main.f90(75): error #7836: If the actual argument is scalar, the corresponding dummy argument shall be scalar unless the actual argument is an element of an array that is not an assumed-shape or pointer array, or a substring of such an element.
call getslice(U(1))
Thanks for any help!
Also, is it possible to use the array visualizer on Linux?
AB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
CALL getslice(U(1:IMAX*JMAX))
should do it. What you're doing is passing element U(1) from the array. An alternative would be:
integer :: k
REAL, DIMENSION(:), TARGET :: U
REAL, DIMENSION(:), pointer :: U_ptr
ALLOCATE(U(IMAX*JMAX*KMAX))
k=1
U_ptr => U(k*(IMAX*JMAX))
...
CALL getslice(U_ptr)
...
or, just another way of looking into the flat array ...
REAL, DIMENSION(:), TARGET :: U
REAL, DIMENSION(:,:), pointer :: U_ptr
ALLOCATE(U(IMAX*JMAX*KMAX))
k=1
U_ptr => U((k-1)*(IMAX*JMAX)+1:k*(IMAX*JMAX))
U_ptr(1,1) = some_real_number
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
CALL getslice(U(1:IMAX*JMAX))
should do it. What you're doing is passing element U(1) from the array. An alternative would be:
integer :: k
REAL, DIMENSION(:), TARGET :: U
REAL, DIMENSION(:), pointer :: U_ptr
ALLOCATE(U(IMAX*JMAX*KMAX))
k=1
U_ptr => U(k*(IMAX*JMAX))
...
CALL getslice(U_ptr)
...
or, just another way of looking into the flat array ...
REAL, DIMENSION(:), TARGET :: U
REAL, DIMENSION(:,:), pointer :: U_ptr
ALLOCATE(U(IMAX*JMAX*KMAX))
k=1
U_ptr => U((k-1)*(IMAX*JMAX)+1:k*(IMAX*JMAX))
U_ptr(1,1) = some_real_number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page