- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The IVF11.1.067 does not give some compile / run-time error for allocatable array shape conformance problem. For example:
subroutine Array_Shape_Conformance
implicit none
real:: ra(3, 3), rb(4, 4), rc(4, 4)
real, allocatable:: sa(:, :), sb(:, :), xy(:)
ra = 3.0; rb = 4.0;
! The shapes of the array expressions do not conform.
! rc = ra + rb ! *** *** *** error
allocate( sa(3, 3), source = ra )
allocate( sb(4, 4), source = rb )
rc = sa + sb ! the compiler give no compile or run-time error
write(unit = *, fmt = "(4F12.7)") rc
return
end subroutine
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The above example should be a runtime error when bounds checking enabled.
While there is sufficient information at compile time to determine that the expression is in error (due to knowing the shape of the arrays), I do not believe there is something in the specification to require the compiler to detect such an error. A "lint" feature should detect this error in programming.
While there is sufficient information at compile time to determine that the expression is in error (due to knowing the shape of the arrays), I do not believe there is something in the specification to require the compiler to detect such an error. A "lint" feature should detect this error in programming.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As rc is big enough to accommodate all SIZEs involved, this may not strictly produce a bounds check error. I agree with Jim that it ought to produce a run time error when /check is set at compile time. Apparently, other brands of compilers agree also, judging by web references to updates to diagnose such problems.
Early f90 compilers diagnosed these unconditionally, but the performance hit was unacceptable.
I notice the results produced by ifort and gfortran are different, both problematical.
Early f90 compilers diagnosed these unconditionally, but the performance hit was unacceptable.
I notice the results produced by ifort and gfortran are different, both problematical.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Intel compiler does not do run-time shape checking. This is on our wish list. Sometimes, array bounds checking will be triggered by such an error but not always.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot.
#1 what's meaning of -- lint
#2 what's meaning of -- rc
#3 I suggest: the IVF compiler give a run-time switch for (allocatable) array shape checking.
#1 what's meaning of -- lint
#2 what's meaning of -- rc
#3 I suggest: the IVF compiler give a run-time switch for (allocatable) array shape checking.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
lint is an old Unix term for static syntax checking.
rc is the name you gave your array.
rc is the name you gave your array.
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