Allocatable array as return value in function 
Author Message
 Allocatable array as return value in function

Hi

I have a program written under the auspicies of F. The program has got
included a function which has as return parameter something like:

function extract_numbers(string,char,ano,NaN_char,NaN) result (e_vector)
                ......
                real,dimension(:),allocatable :: e_vector
                ...

The F compile does not rebel, but the Intel fortran compiler says that a
function return value may not be allocatable.

I thought the F compiler is more picky than every other compiler? Or is
my above usage of Fortran quite insane?

Regards,
S. Gonzi



Mon, 22 Nov 2004 15:13:54 GMT  
 Allocatable array as return value in function
I understand F2K compilers will have allocatable function output capability..
Here is how I achieve a similiar result in one of my functions:

   function leastsquares(...)   result (coef)
   use myprog_1
   real :: coef(0:nc,t1:t2)

where in my use the nc, t1, t2  are integer parameters defined in myprog_1 module
but they could just as easily be defined as integer variables.
and sometimes I  pass output dimensions via function input arguments.


Quote:
> Hi

> I have a program written under the auspicies of F. The program has got
> included a function which has as return parameter something like:

> function extract_numbers(string,char,ano,NaN_char,NaN) result (e_vector)
> ......
> real,dimension(:),allocatable :: e_vector
> ...

> The F compile does not rebel, but the Intel Fortran compiler says that a
> function return value may not be allocatable.

> I thought the F compiler is more picky than every other compiler? Or is
> my above usage of Fortran quite insane?

> Regards,
> S. Gonzi



Mon, 22 Nov 2004 17:02:43 GMT  
 Allocatable array as return value in function

Quote:

> I understand F2K compilers will have allocatable function output capability..
> Here is how I achieve a similiar result in one of my functions:

>    function leastsquares(...)   result (coef)
>    use myprog_1
>    real :: coef(0:nc,t1:t2)

> where in my use the nc, t1, t2  are integer parameters defined in myprog_1 module
> but they could just as easily be defined as integer variables.
> and sometimes I  pass output dimensions via function input arguments.

That was my solution too! But I just wondered why F is more forbearing
than the Intel ifc compiler. Normally I would say the opposite is true.

I am not sure whether the F compiler would also whine here:

real, dimension(:,:),allocatable, intent(out) :: erg_array

Why can't an array from a subroutine be declared as intent(out) and
allocatable? I solved it with POINTER.

Regards,
S. Gonzi



Mon, 22 Nov 2004 17:07:13 GMT  
 Allocatable array as return value in function

Quote:
> I am not sure whether the F compiler would also whine here:

> real, dimension(:,:),allocatable, intent(out) :: erg_array

> Why can't an array from a subroutine be declared as intent(out) and
> allocatable? I solved it with POINTER.

It just happens to be a missing feature in F95 - it's in F2K.

I am surprised that an allocatable function result was suspected - I
would have thought that this comes under the same restriction and TR.

        Jan



Mon, 22 Nov 2004 21:13:53 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. return value as an allocatable array

2. f90 function returns structure with allocatable arrays

3. java array return value not array in tcl

4. Possible to return an allocatable array?

5. F95: Possible to return an allocatable array?

6. How can I return an allocatable array?

7. debugger: examine values of allocatable array (OVMS)

8. F95: array-returning function as argument to another function

9. Passing array valued functions as argument to function.

10. allocatable vs non-allocatable arrays

11. Allocatable array of allocatable defined types?

12. passing allocatable array to a function and getting the bounds

 

 
Powered by phpBB® Forum Software