- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Usually allocated array will be automatically deallocated by leaving a subroutine. In some cases we are using recursive functions. If the result has the attribute 'allocatable', the compiler complains:
"Error: The array-spec for a function name with no POINTER attribute must be an explicit shape array (R505.9)"
Compilation succeeds using the attribute 'pointer' for the result (array). One cannot deallocate the array, because it is needed after completion of the function. But now we are facing the problem, that the used memory grows with every calling of the function. How can we free the memory after a function call, so that the stack does not overflow?
"Error: The array-spec for a function name with no POINTER attribute must be an explicit shape array (R505.9)"
Compilation succeeds using the attribute 'pointer' for the result (array). One cannot deallocate the array, because it is needed after completion of the function. But now we are facing the problem, that the used memory grows with every calling of the function. How can we free the memory after a function call, so that the stack does not overflow?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The version of Visual Fortran you are using doesn't support ALLOCATABLE functions - that is a Fortran 2000 (draft) feature that was added to version 6.6A.
If you do pointer assignment of the result to a local pointer, you should be able to deallocate it when done.
Steve
If you do pointer assignment of the result to a local pointer, you should be able to deallocate it when done.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
I have same problem with fbucher, on calling of function. I have tried using allocatable (in CVF 6.6A), but the used memory is bigger then using conventional dimension.
My function as below:
Anyone can help?
Thank
toppo
I have same problem with fbucher, on calling of function. I have tried using allocatable (in CVF 6.6A), but the used memory is bigger then using conventional dimension.
My function as below:
function a_multiply(C, iA, jA, B) result(r_v) ! ... ! ... argument list ! ... real(kind=kv), intent(in), dimension(:) :: C, B integer, intent(in), dimension(:) :: iA, jA ! ... ! ... result ! ... ! real(kind=kv), dimension(1:size(B)) :: r_v real(kind=kv), allocatable, dimension(:) :: r_v ! ... ! ... local variables ! ... integer :: i, j !................... allocate(r_v(1:size(B))); r_v = n0 ! ... do i = 1, size(B) r_v(i)=C(iA(i))*B(i) do j = iA(i)+1, iA(i+1)-1 r_v(i)=r_v(i)+A(j)*B(jA(j)) enddo enddo ! ... end function a_multiply
Anyone can help?
Thank
toppo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
toppo,
I don't get any errors with your code. Since this is just a fragment, I suspect the problem is elsewhere. Please send a small but complete example with the exact error message, or even better, a ZIP archive of your project, to vf-support@compaq.com and we'll take a look.
Steve
I don't get any errors with your code. Since this is just a fragment, I suspect the problem is elsewhere. Please send a small but complete example with the exact error message, or even better, a ZIP archive of your project, to vf-support@compaq.com and we'll take a look.
Steve

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