Can anyone throw some light to what does this syntax mean (it is within a module)
procedure(A), pointer :: XYZ
Thanks Chris
Welcome to our forums
Can anyone throw some light to what does this syntax mean (it is within a module)
procedure(A), pointer :: XYZ
Thanks Chris
Does it compile? Can you provide the context (some more code before and after).
I have just given you a line from the module. I know it is to do with procedure pointers but trying to interpret the meaning better.
It would help if you could give some more lines. Is it part of an INTERFACE?
Quoted from ajaytaneja I have just given you a line from the module. I know it is to do with procedure pointers but trying to interpret the meaning better.
It is impossible to 'interpret the meaning better' without your providing context. In particular, note the (A). That is meaningful only if there exists a declaration, possibly as an abstract interface, of the kind of procedures that can be signified by (A).
The 'A' itself is a programmer's chosen name for a type of procedure, and is not known to the compiler beforehand.
The context is that the procedures are accessing data from an external dll.
Here is some part of declaration in module
use DLLBasic
use IFP
use IFW
use, intrinsic :: iso_c_d
implicit none
!-- Private/Public
public :: AA, &
BB, &
CC, &
DD, &
EE, &
FF, &
GG private
!-- Types
integer(handle) :: lib_handle=0 !DLL library handle
procedure(dll_fun_int), pointer :: CreateElement !Interface to CreateElement sub
procedure(dllGetInterfacePointers), pointer :: GetInterfacePointers !Interface to GetInterfacePointers sub
procedure(dllGetInterfaceTextArrayLength), pointer :: GetInterfaceTextArrayLength !Interface to GetInterface... sub
procedure(dll_fun), pointer :: GetDllVersionInfo !Interface to GetDllVersionInfo
procedure(dll_fun), pointer :: GetElemTypeInfo !Interface to GetElemTypeInfo
procedure(dll_fun), pointer :: FreeDllMemory !Interface to FreeDllMemory sub
procedure(dll_fun_int), pointer :: WriteOutput !Interface to WriteOutput sub
procedure(dll_fun), pointer :: GetInterfaceArrayLength !Interface to GetInterfaceArrayLength sub
procedure(dll_fun), pointer :: SetOutputPath !Interface to SetOutputPath
procedure(dll_fun_2int), pointer :: GetStiffnessMatrix !Interface to GetStiffnessMatrix
procedure(dll_fun_int), pointer :: UpdateElementState !Interface to UpdateElementState
procedure(dll_fun), pointer :: SetLongTextString
procedure(dll_fun_2int), pointer :: GetInternalForces !Interface to GetInternalForces
procedure(dll_fun_2int), pointer :: LoadStepExit !Interface to LoadStepExit
procedure(dll_fun_int), pointer :: GetElementStateInfo !Interface to GetElementStateInfo
integer(C_INTPTR_T) :: p
type(C_PTR) :: pText, pArray
integer(1), dimension(:), pointer :: asciiText
real(8), dimension(:), pointer :: realArray
integer(C_INTPTR_T) :: iTxtLen !Length of text array (returned from dll)
integer(C_INTPTR_T) :: iRealLen !Length of real array (returned from dll)
logical :: IsDllLoaded=.false. !true if Dll is loaded into memory
!-- Interfaces
!-- Contained routines
contains
Ah, there is no procedure named A or with an abstract interface named A. 'A' is just a name that you made up for asking a question in the forum.
Let us take the first item in the code extract, for concreteness.
!DLL library handle
procedure(dll_fun_int), pointer :: CreateElement
This declaration is for a procedure pointer, and the interface to the pointee procedure (subroutine or function) -- the interface named dll_fun_init -- is provided in the module DLLBasic (or another module that has USE association). That is why your original cryptic question could not be answered.
Note that only a pointer is declared, so you cannot call CreateElement until you have pointer-assigned it to an actual procedure that has the matching interface.
It would be a good idea to specify a default initialization of NULL() for such pointers, lest the procedure be called before it is pointing at anything.
See the example at, for example, https://gist.github.com/Sharpie/349107 .
Silverfrost Fortran has limited support for Fortran 2003 features such as this item.
Thank you v much. I shall be grateful if you can throw some light on what are procedure pointers and interfaces in FORTRAN 2003 ?
As I said, that I will be provided some data from external dll's that I use as input to my program.
That best source for that information is text books and manuals. See, for example Modern Fortran Explained by Metcalf, Reid and Cohen, https://global.oup.com/academic/product/modern-fortran-explained-9780199601424?cc=us&lang=en& .
You are probably using a compiler other than FTN95 if your source code uses procedure pointers and abstract interfaces. See the documentation of your compiler.