- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a query reqarding the MODULES in Intel Fortran 9.1. I have a set of C functions, which need to be called from Fortran so I provided the wrappers andthese behaves well. Now I am adding the MODULE INTERFACES for these wrappers.
For a specific functionI have a difficutly in defining the INTERFACE in the MODULE. One of the arguments of the functions can be scalar or can be a array. As by default Fortran takes the pointer it doesnt matter whether I send a address of a scalar or a address of an array. How can I resolve this in MODULE.
Example code:
MODULE TEST
INTERFACE
INTEGER (KIND=4) FUNCTION IDS_GETREAL (iSpot1,gdsName,nbr,rVar,maxNbr)
INTEGER (KIND=4) iSpot1
CHARACTER(LEN=*) gdsName
INTEGER (KIND=4) NBR
REAL (KIND=4) rVar---------------------- or REAL (KIND=4) rVar(*)
INTEGER (KIND=4) maxNbr
END FUNCTION IDS_GETREAL
END INTERFACE
END MODULETEST
In this function, the variable rVar can be a scalar or an array. If Idefine it as REAL (KIND=4)rVar, itgives the type mismatch errorIf I send anarray.
Is there is anywaythat I can overload the declartionin the Module.
Regards,
Manoj
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a query reqarding the MODULES in Intel Fortran 9.1. I have a set of C functions, which need to be called from Fortran so I provided the wrappers andthese behaves well. Now I am adding the MODULE INTERFACES for these wrappers.
For a specific functionI have a difficutly in defining the INTERFACE in the MODULE. One of the arguments of the functions can be scalar or can be a array. As by default Fortran takes the pointer it doesnt matter whether I send a address of a scalar or a address of an array. How can I resolve this in MODULE.
Example code:
MODULE TEST
INTERFACE
INTEGER (KIND=4) FUNCTION IDS_GETREAL (iSpot1,gdsName,nbr,rVar,maxNbr)
INTEGER (KIND=4) iSpot1
CHARACTER(LEN=*) gdsName
INTEGER (KIND=4) NBR
REAL (KIND=4) rVar---------------------- or REAL (KIND=4) rVar(*)
INTEGER (KIND=4) maxNbr
END FUNCTION IDS_GETREAL
END INTERFACE
END MODULETEST
In this function, the variable rVar can be a scalar or an array. If Idefine it as REAL (KIND=4)rVar, itgives the type mismatch errorIf I send anarray.
Is there is anywaythat I can overload the declartionin the Module.
Regards,
Manoj
Is IDS_GETREAL an 'elemental' function? Usually, this is the only type of Fortran function that can take a scalar or an array equally happily (or else, how does the function find out what it has been sent?).
If it is an elemental function, then obviously the interface definition should say so.
Stephen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[plain]INTERFACE IDS_GETREAL INTEGER (KIND=4) FUNCTION IDS_GETREAL_S (iSpot1,gdsName,nbr,rVar,maxNbr) !DEC$ ATTRIBUTES DECORATE,ALIAS:"IDS_GETREAL" :: IDS_GETREAL_S INTEGER (KIND=4) iSpot1 CHARACTER(LEN=*) gdsName INTEGER (KIND=4) NBR REAL (KIND=4) rVar INTEGER (KIND=4) maxNbr END FUNCTION IDS_GETREAL_S INTEGER (KIND=4) FUNCTION IDS_GETREAL_A (iSpot1,gdsName,nbr,rVar,maxNbr) !DEC$ ATTRIBUTES DECORATE,ALIAS:"IDS_GETREAL" :: IDS_GETREAL_A INTEGER (KIND=4) iSpot1 CHARACTER(LEN=*) gdsName INTEGER (KIND=4) NBR REAL (KIND=4) rVar(*) INTEGER (KIND=4) maxNbr END FUNCTION IDS_GETREAL_A END INTERFACE IDS_GETREAL[/plain]The compiler will select the correct interface.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[plain]INTERFACE IDS_GETREAL INTEGER (KIND=4) FUNCTION IDS_GETREAL_S (iSpot1,gdsName,nbr,rVar,maxNbr) !DEC$ ATTRIBUTES DECORATE,ALIAS:"IDS_GETREAL" :: IDS_GETREAL_S INTEGER (KIND=4) iSpot1 CHARACTER(LEN=*) gdsName INTEGER (KIND=4) NBR REAL (KIND=4) rVar INTEGER (KIND=4) maxNbr END FUNCTION IDS_GETREAL_S INTEGER (KIND=4) FUNCTION IDS_GETREAL_A (iSpot1,gdsName,nbr,rVar,maxNbr) !DEC$ ATTRIBUTES DECORATE,ALIAS:"IDS_GETREAL" :: IDS_GETREAL_A INTEGER (KIND=4) iSpot1 CHARACTER(LEN=*) gdsName INTEGER (KIND=4) NBR REAL (KIND=4) rVar(*) INTEGER (KIND=4) maxNbr END FUNCTION IDS_GETREAL_A END INTERFACE IDS_GETREAL[/plain]The compiler will select the correct interface.
Hi Steve,
Thank you very much , I had implemented it.
Regards,
Manoj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![](/skins/images/71A9511A625CE5D5D45FB59952A4AA71/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page