View previous topic :: View next topic |
Author |
Message |
ajaytaneja
Joined: 08 Apr 2011 Posts: 17
|
Posted: Mon Dec 19, 2016 3:15 pm Post subject: Syntax unknown |
|
|
Can anyone throw some light to what does this syntax mean (it is within a module)
Code: | procedure(A), pointer :: XYZ |
Thanks
Chris |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Mon Dec 19, 2016 3:29 pm Post subject: |
|
|
Does it compile? Can you provide the context (some more code before and after). |
|
Back to top |
|
|
ajaytaneja
Joined: 08 Apr 2011 Posts: 17
|
Posted: Mon Dec 19, 2016 3:30 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Mon Dec 19, 2016 3:34 pm Post subject: |
|
|
It would help if you could give some more lines. Is it part of an INTERFACE? |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Mon Dec 19, 2016 3:50 pm Post subject: Re: |
|
|
ajaytaneja wrote: | 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. |
|
Back to top |
|
|
ajaytaneja
Joined: 08 Apr 2011 Posts: 17
|
Posted: Mon Dec 19, 2016 4:12 pm Post subject: |
|
|
The context is that the procedures are accessing data from an external dll.
Here is some part of declaration in module
Code: | 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 |
|
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Mon Dec 19, 2016 4:43 pm Post subject: |
|
|
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.
Code: | !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. |
|
Back to top |
|
|
ajaytaneja
Joined: 08 Apr 2011 Posts: 17
|
Posted: Mon Dec 19, 2016 5:23 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
|
Back to top |
|
|
|