4

How do I properly write an empty array literal of user derived type?

The following works in GFortran, but not in IFort up to version 19.1.1.217

 type(SpinOrbIdx_t), allocatable :: det_I(:)
det_I = [SpinOrbIdx_t::]

Is this a bug in ifort, or non standard conforming behaviour of GFortran?

1 Answer 1

4

That is indeed the correct syntax to declare the type of a constructed (zero-size) array. Intel Fortran is wrong to reject this as Fortran 2003+ syntax: you should report this to Intel support.

In Fortran 2018 this is syntax rule R770 (with R769 and other context).

As a work-around you can allocate det_I to be of size zero or use an array constructor of structure constructors with no elements:

allocate(det_I(0))
det_I = [(SpinOrbIdx(...),i=1,0)]  ! For appropriate structure constructor, etc.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.