- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to build a static library which contains a subroutine which does this:
SUBROUTINE S(A,B,C)
IMPLICIT NONE
INTEGER,INTENT(IN) :: A
CHARACTER(10),INTENT(IN),OPTIONAL :: B
CHARACTER(20),INTENT(IN),OPTIONAL :: C
CHARACTER(*) UPCASE
...
IF (PRESENT(B)) THEN
WRITE(*,*) UPCASE(B)
ENDIF
IF (PRESENT(C)) THEN
WRITE(*,*) UPCASE(C)
ENDIF
...
END SUBROUTINE S
When in my code Band Care not passed to A a build error occurs. Ifthey arepresent then the code builds (and run) properly. The build error comes from the external subroutine UPCASE (which just does an upper case conversion of the strings B and C) which can not be linked if B and C are not present.
How can I get around the fact that S (a library subroutine) may or may not be called by my customers' programs with or without B and C- and therefore may trigger build errors?
Thanks!
Olivier
SUBROUTINE S(A,B,C)
IMPLICIT NONE
INTEGER,INTENT(IN) :: A
CHARACTER(10),INTENT(IN),OPTIONAL :: B
CHARACTER(20),INTENT(IN),OPTIONAL :: C
CHARACTER(*) UPCASE
...
IF (PRESENT(B)) THEN
WRITE(*,*) UPCASE(B)
ENDIF
IF (PRESENT(C)) THEN
WRITE(*,*) UPCASE(C)
ENDIF
...
END SUBROUTINE S
When in my code Band Care not passed to A a build error occurs. Ifthey arepresent then the code builds (and run) properly. The build error comes from the external subroutine UPCASE (which just does an upper case conversion of the strings B and C) which can not be linked if B and C are not present.
How can I get around the fact that S (a library subroutine) may or may not be called by my customers' programs with or without B and C- and therefore may trigger build errors?
Thanks!
Olivier
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You left out some important points, such as which compiler you used and whether or not an explicit interface for subroutine S was visible to the caller. I'm going to guess 1) CVF and 2) No. If you correct #2, the build (and execution) issues should go away.
An explicit interface is required to be visible when calling a routine with an OPTIONAL argument. Ideally, subroutine S would be in a MODULE that is USEd by the caller, or is a CONTAINed procedure.
An explicit interface is required to be visible when calling a routine with an OPTIONAL argument. Ideally, subroutine S would be in a MODULE that is USEd by the caller, or is a CONTAINed procedure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
You left out some important points, such as which compiler you used and whether or not an explicit interface for subroutine S was visible to the caller. I'm going to guess 1) CVF and 2) No. If you correct #2, the build (and execution) issues should go away.
An explicit interface is required to be visible when calling a routine with an OPTIONAL argument. Ideally, subroutine S would be in a MODULE that is USEd by the caller, or is a CONTAINed procedure.
An explicit interface is required to be visible when calling a routine with an OPTIONAL argument. Ideally, subroutine S would be in a MODULE that is USEd by the caller, or is a CONTAINed procedure.
I am using IVF 10 - and there was an explicit interface to S. But it turns out I had to declare an explicit interface for UPCASE in S as well. It works now.
Thanks for your help!
Olivier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Curious - what were the build errors before? Are you using /iface:cvf?
Reply
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