- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm hooping someone can help me with the following problem.
I am getting the following error message and have been unable to track down any information about what it means.
I am passing a subset of an array to a subroutine and getting this message everytime I call the subroutine.
"%FOR-W-DIAGNOSTIC, Message number 135266304, In call to XXXXX, an array temporary was created for argument #1"
Any help/suggestions much appreciated.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PROGRAM Assumed REAL:: Array(48) INTEGER:: k Array = (/(k, k=1,48)/) CALL sub(Array(33)) CALL sub(Array(33:48)) CALL sub(Array(15:48:2)) CONTAINS SUBROUTINE Sub(Arr) REAL:: Arr(16) WRITE(*,"(4F4.0)") Arr WRITE(*,*) "------------------" END SUBROUTINE Sub END PROGRAM Assumed OUTPUT: 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. ------------------ 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. ------------------ forrtl: warning (402): fort: (1): In call to SUB, an array temporary was created for argument #1 15. 17. 19. 21. 23. 25. 27. 29. 31. 33. 35. 37. 39. 41. 43. 45. ------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The suggested solution with sub(array(33)) does not work if modern features like interfaces to overload routines are used.
An example is given below.
1. If the source code is compiled with call test_ta(17,b(1,32)) the following error is given
test_tmparray.f90(58): error #6285: There is no matching specific subroutine for this generic subroutine call. [TEST_TA]
(It works for the second call test_ta_s(17,b(1,32))!)
2. If the call is changed to call test_ta(17,b(1,32:48)), the code compiles but the runtime warning is issued!
forrtl: warning (402): fort: (1): In call to TEST_TA_S, an array temporary was created for argument #2
So either a compile error or a runtime warning is received. I think the compiler should not issue a warning in this case, because it will probably only pass the first adress and the size and should not create a tmp array.
Hendrik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regarding the compile-time error - I agree that this is a compiler bug and I will let the developers know. The compiler is evidently not taking sequence association into account when doing generic resolution.
As for the run-time warning, you are forgetting (or are perhaps unaware) that Fortran stores arrays in "column-major" order so that the leftmost subscript changes the fastest. Your array section b(1,32:48) is NOT contiguous. You probably want to reverse the order of the subscripts. Even if the compiler allowed the first call, it would not do what you expect, since the element following b(1,32) is b(2,32), not b(1,33).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"array section b(1,32:48) is NOT contiguous"
In that case, the creation of a temporary stride 1 array would be an optimization if the subroutine reads it repeatedly, particularly in a context which enables vectorization.
The Fortran 77 case of passing the first array element to the procedure could be used to avoid the copy, but the procedure would need to show the stride explicitly (F77 style).
In addition to limitations previously mentioned on combining F77 and array syntax, ifort MIC offload doesn't accept the F77 method of passing an array section by naming the first element. It's necessary to set a POINTER (in principle, requiring TARGET attribute on the actual array) and pass that in the call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
integer, parameter :: m=100
real :: b(3,m)
...
call test_ta(17,b(1,32:48))
Must create a temporary array. test_ta, as written, requires dummy a(n) to be contiguous, b(1,32:48) does not specify contiguous memory (it has a stride of 3). Memory for b is organized:
(1,1), (2,1), (3,1), (1,2), (2,2), (3,2), ...
Your call specifies (bold):
(1,32), (2,32), (3,32), (1,33), (2,33), (3,33), (1,34), (2,34), (3,34), ...
If you want to avoid creating temporary .AND. pass strided arguments then in test_ta_s
real :: a(:) ! use assumed shape to permit strided arguments without temporary copy
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It turns out that I missed seeing a key part of the Fortran standard when I said that the compile-time error was incorrect, Sequence association does not participate in generic resolution. The standard says:
If the procedure is nonelemental and is referenced by a generic name or as a defined operator or defined assignment, the ranks of the actual arguments and corresponding dummy arguments shall agree.
While you can call the specific function with an array element, you can't call a generic and expect it to resolve to a specific that accepts an array argument.

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