F90 problem compiling function returning pointer array 
Author Message
 F90 problem compiling function returning pointer array

System: AIX
fortran 90:  AIX XL Fortran Compiler
command line options:

-qlanglvl=90pure -qxlf77= -bnoquiet -C -g -qextchk -qflttrap -qnosave
-qspnans -qcharlen=4096 -qAUX_SIZE=16384 -qxflag=dd24 -qinitauto=00

Diagnostics:

...

../main/../alloc/alloc.f", line 54613.29: 1514-198 (S) Variables which
are pointers may not be declared with the TARGET, EXTERNAL, INTRINS.

which referres to line
        character,pointer ::realloc1char(:)*(length)

in function

        function realloc1char(array,length, lb1,o1,n1, istat)

Please also find an example in attachment.

Thank you very much,

Azat.

[ realloc1char.f 1K ]
        function realloc1char(array,length, lb1,o1,n1, istat)

        implicit none
        logical isalloc

        integer istat,length
        integer i1,i2,i3
        integer lb1,lb2,lb3
        integer ub1,ub2,ub3
        integer n1,n2,n3
        integer o1,o2,o3
c function result
        character,pointer ::realloc1char(:)*(length)

        character, pointer::array(:)*(length)
c Formals: lb* - lower bound of an array (usually 1)
c          o*  - old upper bound
c          n*  - new upper bound
        istat = 0

c allocate new array
        allocate( realloc1char(lb1:n1),stat=istat)
        if(istat.gt.0) then
          nullify(realloc1char)
          istat = 1
          return
        endif
        isalloc=associated(array)
c copy to new location
        ub1=lb1
        if( isalloc ) then
          do i1=lb1,min(o1,n1)
            realloc1char(i1)=array(i1)
          end do
          ub1=o1+1
        endif
c initialize additional space
        if(o1.lt.n1.or..not.isalloc) then
          do i1=ub1, n1
            realloc1char(i1)=' '
          end do
        endif

c free memory
        if( isalloc ) then
          deallocate(array,stat=istat)
          nullify(array)
          if(istat.gt.0) then
            istat = 2
            return
          endif
        endif

        return
        end



Wed, 18 Jun 1902 08:00:00 GMT  
 F90 problem compiling function returning pointer array
Are you confusing the compiler with the use of -qlanglvl=90pure
and -qxlf77=? Your code becomes pure f90 if you change your
comment lines to start with '!' instead of 'c', and if you change

character, pointer :: realloc1char(:)*(length)

to

character(length), pointer :: realloc1char(:)

Please try that.

Mike Metcalf

--



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. HELP F90, External function returning pointer

2. C++ calling f90 function returning array

3. F90 function returning array

4. f90 function returns structure with allocatable arrays

5. Returning Pointer To Pointer From Function

6. Problem with Digital F90 pointer valued functions

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

8. returning arrays/pointers across C/Fortran

9. fnct returning array (F90)

10. Efficiency of pointer vs. allocatable arrays in F90

11. Help: Array of Pointers in F90

12. Q: Pointers in F90/ neg. array indices

 

 
Powered by phpBB® Forum Software