- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
All,
I have the following:
CALL ECBC(XLATLP, XLATN0, XLONLP, XLONN0, DTNED0, QN0C,
+ TNO2UC, TNT2NO, TECBC, EC, BC, XLOS, WE, DTR, RTD)
....
SUBROUTINE ECBC(XLL,XL0,XLONL,XLON0,DELTIM,TUC2NO,TNO2UC,TNT2NO,
+ T,EC,BC,XLOS,WE,DTR,RTD)
....
END
This is legacy code that builds and executes just fine. I modify the subroutine declaration and subroutine like this:
CALL ECBC(XLATLP, XLATN0, XLONLP, XLONN0, DTNED0, QN0C,
+ TNO2UC, TNT2NO, TECBC, EC, BC, XLOS, WE, DTR, RTD,switch)
...
OPTIONAL :: switch
....
END
The subroutine compiles and the static library in which it resides compiles and builds. However, the module that calls ECBC, which has not been modified, produces a link failure that indicates that ECBC cannot be found due to the wrong number of calling parameters.
What am I missing? There must be some way to add an optional parameter to an existing subroutine without modifying ALL of the places that call that subroutine. Otherwise, the parameter is not very "optional".
TIA,
Bill
I have the following:
CALL ECBC(XLATLP, XLATN0, XLONLP, XLONN0, DTNED0, QN0C,
+ TNO2UC, TNT2NO, TECBC, EC, BC, XLOS, WE, DTR, RTD)
....
SUBROUTINE ECBC(XLL,XL0,XLONL,XLON0,DELTIM,TUC2NO,TNO2UC,TNT2NO,
+ T,EC,BC,XLOS,WE,DTR,RTD)
....
END
This is legacy code that builds and executes just fine. I modify the subroutine declaration and subroutine like this:
CALL ECBC(XLATLP, XLATN0, XLONLP, XLONN0, DTNED0, QN0C,
+ TNO2UC, TNT2NO, TECBC, EC, BC, XLOS, WE, DTR, RTD,switch)
...
OPTIONAL :: switch
....
END
The subroutine compiles and the static library in which it resides compiles and builds. However, the module that calls ECBC, which has not been modified, produces a link failure that indicates that ECBC cannot be found due to the wrong number of calling parameters.
What am I missing? There must be some way to add an optional parameter to an existing subroutine without modifying ALL of the places that call that subroutine. Otherwise, the parameter is not very "optional".
TIA,
Bill
링크가 복사됨
2 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
The definition with optional argument has to be visible whereever the subroutine is called, according to module procedure or interface block. You may have to create interface block and USE it where it is required.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
What is optional is the inclusion of OPTIONAL arguments in a subroutine/function invocation. What is not optional is the requirement that the programmer provide an explicit interface to subprograms with OPTIONAL arguments -- a fact the necessity for which becomes obvious if one asks how the compiler is to process OPTIONAL arguments in the invocation, in particular those that were left out from the call.
There are other restrictions on the use of optional arguments, which are detailed in the Fortran standard and in the compiler reference manual.
There are other restrictions on the use of optional arguments, which are detailed in the Fortran standard and in the compiler reference manual.