HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- CALL decc$bsearch from FORTRAN
Operating System - OpenVMS
1828658
Members
1839
Online
109983
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 07:40 AM
03-11-2008 07:40 AM
CALL decc$bsearch from FORTRAN
VMS 8.3 FORTRAN X8.0n
In a Fortran application I call the C-routine decc$bsearch using the HP specific POINTER statement: POINTER (pointer,pointee) (ex. test_bsearch1.for, o.k.).
Another way is to use an interface block to define the function and its parameter (ex. test_bsearch2.for). Example 2 runs with accvio and I think some dummy parameters are not defined correctly. You can see the correct C-format of the interface block with
$ help crtl bsearch.
An interface block in Fortran is type specific I think, there is no "void" pointer as in C. What is to do if you want to call decc$bsearch twice in a routine with different table-types and keys? With the Pointer statement as in example 1 it's easy, but using interface blocks, do I have to write two special routines with different interface blocks each?
In a Fortran application I call the C-routine decc$bsearch using the HP specific POINTER statement: POINTER (pointer,pointee) (ex. test_bsearch1.for, o.k.).
Another way is to use an interface block to define the function and its parameter (ex. test_bsearch2.for). Example 2 runs with accvio and I think some dummy parameters are not defined correctly. You can see the correct C-format of the interface block with
$ help crtl bsearch.
An interface block in Fortran is type specific I think, there is no "void" pointer as in C. What is to do if you want to call decc$bsearch twice in a routine with different table-types and keys? With the Pointer statement as in example 1 it's easy, but using interface blocks, do I have to write two special routines with different interface blocks each?
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 01:18 PM
03-11-2008 01:18 PM
Re: CALL decc$bsearch from FORTRAN
Probably not the answer you want...
Do you need to call the innards of a C standard library function directly from Fortran?
Under the theory of "if it hurts, don't do it", I'd tend to either jacket the code with C code that has tailored the underlying interface to meet Fortran norms, or move to the lib$ tree-related calls, including:
LIB$INSERT_TREE, LIB$LOOKUP_TREE, LIB$TRAVERSE_TREE_64, etc.
I personally find that arbitrary API jacketing is easier in C than in Fortran.
And if this is a case of not using C, you can also use a Macro32 jacket. Or the LIB$ RTL calls.
Rules for pointees (which you've probably already found) are here:
http://h71000.www7.hp.com/DOC/82final/6324/6324pro_060.html#df_pointer_stmt
Do you need to call the innards of a C standard library function directly from Fortran?
Under the theory of "if it hurts, don't do it", I'd tend to either jacket the code with C code that has tailored the underlying interface to meet Fortran norms, or move to the lib$ tree-related calls, including:
LIB$INSERT_TREE, LIB$LOOKUP_TREE, LIB$TRAVERSE_TREE_64, etc.
I personally find that arbitrary API jacketing is easier in C than in Fortran.
And if this is a case of not using C, you can also use a Macro32 jacket. Or the LIB$ RTL calls.
Rules for pointees (which you've probably already found) are here:
http://h71000.www7.hp.com/DOC/82final/6324/6324pro_060.html#df_pointer_stmt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 04:10 PM
03-11-2008 04:10 PM
Re: CALL decc$bsearch from FORTRAN
Michael,
If you want your arguments type checked, and have different types, then you'll need to distinguish between different instances of the routine. FORTRAN doesn't do polymorphism very well.
I don't have a compiler handy to check, but it's possible the function name doesn't need to be the same as the C function name. So this might work:
INTERFACE
FUNCTION decc$bsearch_TYPE1 (key, tab, tabSize, elemSize, cmpFunc)
USE keyidx
IMPLICIT NONE
!DEC$ ATTRIBUTES C :: decc$bsearch
...
END INTERFACE
INTERFACE
FUNCTION decc$bsearch_TYPE2 (key, tab, tabSize, elemSize, cmpFunc)
USE keyidx
IMPLICIT NONE
!DEC$ ATTRIBUTES C :: decc$bsearch
...
END INTERFACE
if not you can implement a simple jacket routine. Hoff finds C easier, but I think MACRO32 is the easiest of all:
.title DECC$BSEARCH_JACKETS
.psect $code,rd,nowrt,exe
.CALL_ENTRY LABEL=decc$bsearch_type1,MAX_ARGS=5,HOME_ARGS=TRUE
CALLG (AP),G^DECC$BSEARCH
RET
.CALL_ENTRY LABEL=decc$bsearch_type2,MAX_ARGS=5,HOME_ARGS=TRUE
CALLG (AP),G^DECC$BSEARCH
RET
.END
On the other hand, if you use a builtin function on your argument %VAL, %REF you disable type checking for that argument. So, using a builtin when you don't actually need to will make that argument polymorphic (but the compiler won't help spot your bugs)
If you want your arguments type checked, and have different types, then you'll need to distinguish between different instances of the routine. FORTRAN doesn't do polymorphism very well.
I don't have a compiler handy to check, but it's possible the function name doesn't need to be the same as the C function name. So this might work:
INTERFACE
FUNCTION decc$bsearch_TYPE1 (key, tab, tabSize, elemSize, cmpFunc)
USE keyidx
IMPLICIT NONE
!DEC$ ATTRIBUTES C :: decc$bsearch
...
END INTERFACE
INTERFACE
FUNCTION decc$bsearch_TYPE2 (key, tab, tabSize, elemSize, cmpFunc)
USE keyidx
IMPLICIT NONE
!DEC$ ATTRIBUTES C :: decc$bsearch
...
END INTERFACE
if not you can implement a simple jacket routine. Hoff finds C easier, but I think MACRO32 is the easiest of all:
.title DECC$BSEARCH_JACKETS
.psect $code,rd,nowrt,exe
.CALL_ENTRY LABEL=decc$bsearch_type1,MAX_ARGS=5,HOME_ARGS=TRUE
CALLG (AP),G^DECC$BSEARCH
RET
.CALL_ENTRY LABEL=decc$bsearch_type2,MAX_ARGS=5,HOME_ARGS=TRUE
CALLG (AP),G^DECC$BSEARCH
RET
.END
On the other hand, if you use a builtin function on your argument %VAL, %REF you disable type checking for that argument. So, using a builtin when you don't actually need to will make that argument polymorphic (but the compiler won't help spot your bugs)
A crucible of informative mistakes
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP