Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28994 Discussions

How to create irregular size (non-rectangular) arrays

Roberto_Soares
Beginner
1,268 Views
Hi,
I am working with FEM sparse matrices and would like to create a non-rectangular array. I am trying to store a linked node connectivity for each node in order toinitiallystore the sparse stiffness matrix. However, each node (representing first index, or rows) will contain a different number of nodes connected to themselves, therefore requiring different "second index" sizes.
Let's say node 1 is connected to nodes 2 and 3, so position 1, would contain 2 and 3, or 2 spaces. Node 2, may be connected to nodes 1, 3 and 4. Therefore requiring 3 spaces.
Is this even possible? Otherwise, any suggestions?
Thanks,
Roberto
Intel Fortran 11, MKL user, Windows XP 32 bits.
0 Kudos
3 Replies
Steven_L_Intel1
Employee
1,268 Views
An array of derived type, where the type contains an ALLOCATABLE (or POINTER) array component, is the only thing that comes to mind.
0 Kudos
mecej4
Honored Contributor III
1,268 Views
You could simply mimic one of the sparse matrix storage schemes that you will probably use when your FEM global matrix is assembled. One way that is venerable, simple but not elegant, and works even with Fortran 77, is as follows.

Have two arrays, say NODES and FIRST, with the following contents for the example that you gave:

NODES: || 2 | 3 || 1 | 3 | 4 || ...

FIRST: | 1 | 3 | 6 | ...

The size of NODES should be at least the number of non-zero entries in the adjacency matrix, and FIRST should be of size = number of nodes + 1.

The list of nodes connected to node I is read off from NODES, starting with index FIRST(I) and ending with index FIRST(I+1)-1.
0 Kudos
Roberto_Soares
Beginner
1,268 Views
Thanks for the reply. I actually thought of something like this, however I don't know the final size of each row until the end. It would have to be something to be incremented as the loop was progressing.
0 Kudos
Reply