This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Internal procedures as dummy arguments in gfortran?


Daniel Kraft wrote:
Paul Richard Thomas wrote:
To my astonishment, given some of the remarks, changing the error to
an error on notification works just fine on FC9/i386 :-)

Have you tried this with some kind of more complicated stuff? I'm no expert on using PROCEDURE and procedures as actual arguments, but something along:

ABSTRACT INTERFACE
  INTEGER FUNCTION myproc ()
    IMPLICIT NONE
  END FUNCTION myproc
END ABSTRACT INTERFACE

...

IMPLICIT NONE

...

SUBROUTINE sub1 (proc)
  PROCEDURE(myproc) :: proc
  CALL sub2 (proc)
END SUBROUTINE sub1

SUBROUTINE sub2 (p1, p2)
  PROCEDURE(myproc) :: p1, p2
  PRINT *, p1 () ! Should be 1
  PRINT *, p2 () ! Should be 2
END SUBROUTINE sub2

RECURSIVE SUBROUTINE sub2 (proc)
  PROCEDURE(myproc), OPTIONAL :: proc

INTEGER :: a

  IF (PRESENT (proc))
    a = 2
    CALL sub2 (proc, internal_proc)
  ELSE
    a = 1
    CALL sub1 (internal_proc)
  END IF

CONTAINS

  INTEGER FUNCTION internal_proc ()
    internal_proc = a
  END FUNCTION internal_proc

END SUBROUTINE sub3


Interesting.
Does RECURSIVE apply to the internal procedure, or should it be repeated there? This might take care of some of the problems associated with "internal procedure as dummy argument" under OpenMP.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]