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.

an array temporary was created

rudolfii
Beginner
1,492 Views
Hello,

1) please, is anything potentially wrong with this code?

program aa
call tisk( (/0,0/) )
end program aa

subroutine tisk(a)
integer, intent(in), dimension(2) :: a
write (*,*) a
end subroutine tisk


Running the compiler with '-check all' gives:
forrtl: warning (402): fort: (1): In call to TISK, an array temporary was created for argument #1

If I use '-check all, noarg_temp_created' the warning disappears. Also, if I first use a special variable, say integer, dimension(2) :: b and save (/0, 0/) to it and call tisk(b), warning is gone as well. I guess that in my case the warning is completely harmless and creating a special variable like 'b' is unnecessary. However, I am flooded with warnings like this---I also use something like call tisk((/i, j/) in a loop, where i and j are, say, integers. And again I think they are harmless. But having a hundred of harmless warnings... So a question arises. Should I completely turn off the checking or not? What is a potential problem?

2) Is there any system-independent way to find out the unit open for standard output? Everybody just mentions, it is ususally 6. But usually sounds very bad to me...

Thank you a lot!
Ruda
0 Kudos
3 Replies
Steven_L_Intel1
Employee
1,492 Views
The warning went away when you said noarg_temp_created because you disabled checking for this condition. The temp was still created.

In this example, the diagnostic is technically correct but perhaps inappropriate. It created a temp for the array constructor expression, as it would have to in any case. In my opinion, this diagnostic should be issued only if the compiler is making a run-time copy of a variable (as it would have to if you had passed a non-contiguous array slice, for example.)

You can safely turn off the warning - all it does is let you know of a potential performance impact. I will send a complaint about this to the developers.

As for the unit for standard output, yes, there is a standard way to do this:

use, intrinsic :: iso_fort_env
,,,
! The constant OUTPUT_UNIT tells you the "standard output" unit

I will caution you that, by default in ifort, writes to unit * do NOT go to unit 6. You would want to add the option:

-assume noold_unit_star

to have unit 6 used for WRITEs to * and for PRINT.
0 Kudos
rudolfii
Beginner
1,492 Views
Thanks a lot for your answer and also for being willing to send the mail to the developers.
Ruda

0 Kudos
rudolfii
Beginner
1,492 Views
Only you probably meant

use, intrinsic :: iso_fortran_env
instead of
use, intrinsic :: iso_fort_env

but anyway thanks for showing the direction :)
Ruda
0 Kudos
Reply