If we consider the following simple subroutine
suborouine Test (X)
complex(8) :: X(0:,:)
Real(8) ,allocatable :: Y(:,:)
Complex(8) ,allocatable :: Z(:,:)
The following problem occurs.
Why lbound (Z,dim=1) == 0, and for lbound(Y,dim=1) ==1?
How can I make the lower boundary of the Y array equal to 0?
I cannot use Allocate(Y,mold=X) because the data types are different.
If you use allocate (Y,mold=X%RE) you get that lbound(Y,dim=1)==1.
Because REAL(X,8) is an expression that has the shape of X, but not the lower bound. (Shape is concerned with extent only.)
I think this will do what you want:
Thank you, Steve.
That's how I use it, but this approach is not very logical or convenient.
I don't understand why array boundaries are not inherited.
This kind of implicit boundary mismatch gave me a lot of trouble.
Also, I have to use the compiler flag (/nostandard-realloc-lhs).
Array expressions are always 1:x based on the number of elements (extent) in the expression value. There are no special rules for things such as REAL(X). Keep in mind there are such things as vector subscripts.