- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot for your answer and also for being willing to send the mail to the developers.
Ruda
Ruda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Only you probably meant
use, intrinsic :: iso_fortran_env
instead of
use, intrinsic :: iso_fort_env
but anyway thanks for showing the direction :)
Ruda
use, intrinsic :: iso_fortran_env
instead of
use, intrinsic :: iso_fort_env
but anyway thanks for showing the direction :)
Ruda

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page