- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
subroutineA
.......
CALLBVPMS(FCNEQN,FCNJAC,FCNBC,NEQNS,TLEFT,TRIGHT,DTOL,BTOL,MAXIT,NINIT,TINIT,YINIT,LDYINI,NMAX,NFINAL,TFINAL,YFINAL,LDYFIN)
endsubroutineA
subroutineFCNEQN(NEQNS,T,Y,P,DYDT)
......
!common/yy/Y
!REALY(NEQNS)
CALLNEQBF(FCN,N,XGUESS,XSCALE,FSCALE,IPARAM,RPARAM,X,FVEC)
......
endsubroutineFCNEQN
subroutineFCN(N,X,F)
......
!Y will be used in this subroutine
endsubroutineFCN
The code in GREEN issue the following error:
error#6406:Conflictingattributesormultipledeclarationofname.
error#6756:ACOMMONblockdataobjectmustnotbeanautomaticobject.
My Question: How to pass Y to subroutine FCN?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have also tried the following code:
COMMON /pptr/ pt
REAL, POINTER :: pt
pt=> Y
error #6796: The variable must have the TARGET attribute or be a subobject of an object with the TARGET attribute, or it must have the POINTER attribute.
Since you can't define the storage of Y, using a pointer seems a way to go.
However, your syntax is wrong. You need something like:
[cpp]subroutine FCNEQN(NEQNS, ..., Y, ...) real, target:: Y(NEQNS) real, pointer:: pY(:) common /pptr/ pY ... pY => Y[/cpp]
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
subroutineA
.......
CALLBVPMS(FCNEQN,FCNJAC,FCNBC,NEQNS,TLEFT,TRIGHT,DTOL,BTOL,MAXIT,NINIT,TINIT,YINIT,LDYINI,NMAX,NFINAL,TFINAL,YFINAL,LDYFIN)
endsubroutineA
subroutineFCNEQN(NEQNS,T,Y,P,DYDT)
......
!common/yy/Y
!REALY(NEQNS)
CALLNEQBF(FCN,N,XGUESS,XSCALE,FSCALE,IPARAM,RPARAM,X,FVEC)
......
endsubroutineFCNEQN
subroutineFCN(N,X,F)
......
!Y will be used in this subroutine
endsubroutineFCN
The code in GREEN issue the following error:
error#6406:Conflictingattributesormultipledeclarationofname.
error#6756:ACOMMONblockdataobjectmustnotbeanautomaticobject.
My Question: How to pass Y to subroutine FCN?
Thanks!
Are you asking more than one question? You could include the COMMON block in the subroutine, or pass a dummy argument (preferably with appropriate IN, OUT, or INOUT). In simple cases, the standard prohibits conflicts where there would be ambiguity between a dummy argument value passed at an earlier stage of execution, and a COMMON block value which is always up to date. In more complicated cases, the standard won't protect you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
subroutineFCNEQN(NEQNS,T,Y,P,DYDT)
......
!common/yy/Y
!REALY(NEQNS)
CALLNEQBF(FCN,N,XGUESS,XSCALE,FSCALE,IPARAM,RPARAM,X,FVEC)
......
endsubroutineFCNEQN
The code in GREEN issue the following error:
error#6406:Conflictingattributesormultipledeclarationofname.
error#6756:ACOMMONblockdataobjectmustnotbeanautomaticobject.
My Question: How to pass Y to subroutine FCN?
Thanks!
You can use COMMON to share Y among different unis. What you cannot do is size the arrays in common dynamically -- NEQNS is a variable, and you cannot use that. It has to be a literal constant or a PARAMETER.
Alternatively, and more flexibly, you can define Y within a MODULE and USE that module in both routines. In that case, Y can be declared ALLOCATABLE, and you can ALLOCATE it to a desired size before use.
Finally, if you can change the source of NEQBF, you can pass Y through. If I recall correctly, it's an IMSL routine, so it's not an option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use COMMON to share Y among different unis. What you cannot do is size the arrays in common dynamically -- NEQNS is a variable, and you cannot use that. It has to be a literal constant or a PARAMETER.
Alternatively, and more flexibly, you can define Y within a MODULE and USE that module in both routines. In that case, Y can be declared ALLOCATABLE, and you can ALLOCATE it to a desired size before use.
Finally, if you can change the source of NEQBF, you can pass Y through. If I recall correctly, it's an IMSL routine, so it's not an option.
Thank you.
Yes, BVPMS and NEQBFare IMSL routines. The problem is Y isnot difined by me but passed to FCNEQN by BVPMS and its value is changing on each entry. So I cant't put Y in a module.
The fortran code is ina MATLAB Fortran mex file. NEQNS is passedin from MATLAB. IF I define NEQNS a parameter, then I have to change its valuewhen the number of equations changed and remex the programm. It's inconvenient.
According to your advice "not size the array in common", I delete the code "REAL Y(NEQNS), I got the following error:
error #6412: A dummy argument name is invalid in this context.
I have also tried the following code:
COMMON /pptr/ pt
REAL, POINTER :: pt
pt=> Y
error #6796: The variable must have the TARGET attribute or be a subobject of an object with the TARGET attribute, or it must have the POINTER attribute.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have also tried the following code:
COMMON /pptr/ pt
REAL, POINTER :: pt
pt=> Y
error #6796: The variable must have the TARGET attribute or be a subobject of an object with the TARGET attribute, or it must have the POINTER attribute.
Since you can't define the storage of Y, using a pointer seems a way to go.
However, your syntax is wrong. You need something like:
[cpp]subroutine FCNEQN(NEQNS, ..., Y, ...) real, target:: Y(NEQNS) real, pointer:: pY(:) common /pptr/ pY ... pY => Y[/cpp]
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page