What is wrong with this Fortran program?
complex :: z(5) call random_number(z%re) write(*,*) z end
Intel ifort classic 2021 throws the following error message:
error #6672: This intrinsic procedure or system subprogram must not have an expression or constant as an argument. [RANDOM_NUMBER]
For comparison, gfortran compiles and runs flawlessly. Is this an ifort compiler bug? Generally speaking, what is the easiest way of assigning real/imaginary components of complex numbers separately?
There haven't been bugfix change logs for years. Only people with paid support can file an official report. But the Intel support engineers often pick up issues from this forum.
I filed bug report 05244368 on your behalf. I reported a similar issue with %re and %im in a I/O list about a year and a half ago.
To answer your other question, the complex-part-designator (%re or %im) is the easiest way of doing this - that's what it's for.