forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Syntax unknown

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
ajaytaneja



Joined: 08 Apr 2011
Posts: 17

PostPosted: Mon Dec 19, 2016 3:15 pm    Post subject: Syntax unknown Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4919
Location: Salford, UK

PostPosted: Mon Dec 19, 2016 3:29 pm    Post subject: Reply with quote

Does it compile? Can you provide the context (some more code before and after).
Back to top
View user's profile Send private message
ajaytaneja



Joined: 08 Apr 2011
Posts: 17

PostPosted: Mon Dec 19, 2016 3:30 pm    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4919
Location: Salford, UK

PostPosted: Mon Dec 19, 2016 3:34 pm    Post subject: Reply with quote

It would help if you could give some more lines. Is it part of an INTERFACE?
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 732

PostPosted: Mon Dec 19, 2016 3:50 pm    Post subject: Re: Reply with quote

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
View user's profile Send private message
ajaytaneja



Joined: 08 Apr 2011
Posts: 17

PostPosted: Mon Dec 19, 2016 4:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 732

PostPosted: Mon Dec 19, 2016 4:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
ajaytaneja



Joined: 08 Apr 2011
Posts: 17

PostPosted: Mon Dec 19, 2016 5:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 732

PostPosted: Mon Dec 19, 2016 7:38 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group