Fortran: Pointer to array section with vector subscripts

Click For Summary
SUMMARY

The discussion centers on the challenge of creating a pointer to specific columns of a rank-2 array in Fortran, specifically using vector subscripts. The user attempts to implement this with the syntax ptr1 => arrA(1:k,(/col1,col3/)), but is informed that this method violates the Fortran 2008 standard due to constraint C724. The user seeks alternative methods to achieve the same goal without using scalar triplets, as they require non-uniform column selection.

PREREQUISITES
  • Understanding of Fortran 2008 standards and constraints
  • Familiarity with array pointers in Fortran
  • Knowledge of rank-2 arrays and their indexing
  • Experience with vector subscripting in Fortran
NEXT STEPS
  • Research alternative methods for creating pointers to array subsections in Fortran
  • Learn about the implications of Fortran 2008 constraint C724
  • Explore the use of derived types to manage non-contiguous array sections
  • Investigate the use of Fortran's ALLOCATABLE arrays for dynamic column selection
USEFUL FOR

This discussion is beneficial for Fortran developers, particularly those working with scientific computing, who need to manipulate multi-dimensional arrays and require advanced pointer techniques for efficient data handling.

seneika
Messages
4
Reaction score
0
Hi. I'm trying to make a pointer point to sections of a rank-2 array given by specific values of
it's second index. I other words: given a table I wan't a pointer to point to specific columns, making of it a "filtered" table.

The method I was trying was like

Code:
DOUBLE PRECISION, DIMENSION(M,N), TARGET :: arrA  
DOUBLE PRECISION, DIMENSION(:,:), POINTER :: ptr1  
  ...
ptr1 => arrA(1:k,(/col1,col3/))

to point to columns col1 and col3, rows 1 to k.

However, I've been told in the Intel forum that this procedure would consist in targeting an array
subsection with a vector subscript, which is forbiden in the standard by the constraint C724 of
F2008.

Is there any other way of doing this?

I'm not using a scalar triplet on the second index because, in practice, I'll select more columns without a regular stride, so a rule like col1:colN:stride doesn't seem to be of use.

Thanks.
 
Technology news on Phys.org
I would like to resurrect this thread, I am interested in the answer. :-)
 

Similar threads

  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 2 ·
Replies
2
Views
9K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 10 ·
Replies
10
Views
26K
  • · Replies 3 ·
Replies
3
Views
13K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 6 ·
Replies
6
Views
2K