Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Using realloc-lhs with size 0 array

OP1
New Contributor III
530 Views
When A is an allocatable array, provided that the option /assume:realloc_lhs is used, the following syntax is correct:

A= [1,2,3]

But how do I allocate A to size 0 (short of a proper ALLOCATE statement)? A = [] does not work (with IVF 11.1). It's a bit of an academic questoin, but for debugging purposes it's quite helpful.

Thanks,

Olivier
0 Kudos
5 Replies
Arjen_Markus
Honored Contributor II
530 Views
You might try:
A = [ (i, i=1,0) ]
I do not know why your original statement does not work, but the above creates a zero-length
array explicitly, so I expect it to do the trick.
Regards,
Arjen
0 Kudos
IanH
Honored Contributor III
530 Views
Put a type-spec in the array-constructor.

A = [ INTEGER :: ]
0 Kudos
OP1
New Contributor III
530 Views

Thanks Ian - it works! It does look a bit weird, certainly.

Olivier

0 Kudos
jimdempseyatthecove
Honored Contributor III
530 Views
>>it works! It does look a bit weird

What is the data type on the rhs with

A = []

?

Fortran does not have a "void" type, but it does have an empty array of (specified) type.
0 Kudos
OP1
New Contributor III
530 Views
Jim,

It's an INTEGER allocatable array. I was looking for the convenience of A = []. Ian suggestion works.

Olivier
0 Kudos
Reply