Home > Archive > Fortran > September 2006 > confliction of the name of the internal procedure
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
confliction of the name of the internal procedure
|
|
|
| Hi
What does this error message mean:
"Error: The name of the internal procedure conflicts with a name in the
encompassing scoping unit. [F]"
In this program I intend to use IMSL function (some minimization
function):
CALL UVMIF (F, XGUESS, STEP, BOUND, XACC, MAXFN, X)
I declared F(x) as contained function in main program. I use CVF6.6C &
Windows XP.
declarations in main program are:
INTEGER MAXFN, NOUT
REAL BOUND, FX, STEP, X, XACC, XGUESS
EXTERNAL F, UMACH, UVMIF
Mike
| |
| Dan Nagle 2006-09-20, 7:01 pm |
| Hello,
The name F refers both to an external procedure
and to an internal procedure. Hence the conflict arises.
Mike wrote:
> Hi
>
> What does this error message mean:
> "Error: The name of the internal procedure conflicts with a name in the
> encompassing scoping unit. [F]"
>
> In this program I intend to use IMSL function (some minimization
> function):
> CALL UVMIF (F, XGUESS, STEP, BOUND, XACC, MAXFN, X)
>
> I declared F(x) as contained function in main program. I use CVF6.6C &
> Windows XP.
>
> declarations in main program are:
> INTEGER MAXFN, NOUT
> REAL BOUND, FX, STEP, X, XACC, XGUESS
> EXTERNAL F, UMACH, UVMIF
>
> Mike
>
--
Cheers!
Dan Nagle
Purple Sage Computing Solutions, Inc.
| |
| Michael Metcalf 2006-09-20, 7:01 pm |
|
"Mike" <acout@yam.com> wrote in message
news:1158796950.650876.120390@b28g2000cwb.googlegroups.com...
>
> I declared F(x) as contained function in main program. I use CVF6.6C &
> Windows XP.
>
You cannot use an internal procedure as an actual argument. Try making it a
module procedure instead (see also "Fortran 95/2003 Explained", Section
5.12).
Regards,
Mike Metcalf
| |
| Richard Maine 2006-09-20, 7:01 pm |
| Mike <acout@yam.com> wrote:
> I declared F(x) as contained function in main program. I use CVF6.6C &
> Windows XP.
>
> declarations in main program are:
> INTEGER MAXFN, NOUT
> REAL BOUND, FX, STEP, X, XACC, XGUESS
> EXTERNAL F, UMACH, UVMIF
Well, there's your diect conflct. You said that F is a "contained"
procedure. The technical term for that is "internal". Here you declare F
to be an external procedure. Note that external/=internal. The compiler
is interpreting this as attempting to declare 2 different things with
the same name... since "clearly" (from the compiler's perspective) this
is 2 different things rather than one. You can't have one things that is
both internal and external.
But as Metcalf noted, you can't pass an internal procedure as an actual
argument at all - not with any syntax. I just thought I'd try to
elaborate on why you are getting that as an error message.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
| |
| glen herrmannsfeldt 2006-09-20, 7:01 pm |
| Mike <acout@yam.com> wrote:
> What does this error message mean:
> "Error: The name of the internal procedure conflicts with a name in the
> encompassing scoping unit. [F]"
> In this program I intend to use IMSL function (some minimization
> function):
> CALL UVMIF (F, XGUESS, STEP, BOUND, XACC, MAXFN, X)
> I declared F(x) as contained function in main program. I use CVF6.6C &
> Windows XP.
(snip)
> EXTERNAL F, UMACH, UVMIF
If it is an internal function, I don't think you can declare it
external.
-- glen
| |
| michael@athenavisual.com 2006-09-20, 9:59 pm |
| Mike
The code works ok with me (see below)
!DEC$ REAL:8
!
!DEC$OBJCOMMENT LIB:'IMSLS_ERR.LIB'
!DEC$OBJCOMMENT LIB:'IMSL.LIB'
Options /EXTEND_SOURCE
Program MAIN
!
!:Variable Declarations Section
!
Implicit None
Integer MAXFN, NOUT
Real*8 BOUND, FX, STEP, X, XACC, XGUESS
!
!:External Declarations, Common Blocks and Data Statements
!
External F
!
Call UVMIF (F, XGUESS, STEP, BOUND, XACC, MAXFN, X)
!
!:End of MAIN Program
!
END
REAL*8 function F(x)
Implicit None
!
!:Variable Declaration Statements section
!
Real*8 X
!
!:Executable Code and Common Blocks Section
!
!
!:Enter the User's Statement Section
!
F=(X-1)**2
!
!:End of User Procedure
!
Return
End
This compiles with no problem
Michael
Mike wrote:
> Hi
>
> What does this error message mean:
> "Error: The name of the internal procedure conflicts with a name in the
> encompassing scoping unit. [F]"
>
> In this program I intend to use IMSL function (some minimization
> function):
> CALL UVMIF (F, XGUESS, STEP, BOUND, XACC, MAXFN, X)
>
> I declared F(x) as contained function in main program. I use CVF6.6C &
> Windows XP.
>
> declarations in main program are:
> INTEGER MAXFN, NOUT
> REAL BOUND, FX, STEP, X, XACC, XGUESS
> EXTERNAL F, UMACH, UVMIF
>
> Mike
| |
|
| michael@athenavisual.com wrote:[color=darkred]
> Mike
> The code works ok with me (see below)
> !DEC$ REAL:8
> !
> !DEC$OBJCOMMENT LIB:'IMSLS_ERR.LIB'
> !DEC$OBJCOMMENT LIB:'IMSL.LIB'
> Options /EXTEND_SOURCE
> Program MAIN
> !
> !:Variable Declarations Section
> !
> Implicit None
> Integer MAXFN, NOUT
> Real*8 BOUND, FX, STEP, X, XACC, XGUESS
> !
> !:External Declarations, Common Blocks and Data Statements
> !
> External F
> !
> Call UVMIF (F, XGUESS, STEP, BOUND, XACC, MAXFN, X)
> !
> !:End of MAIN Program
> !
> END
>
> REAL*8 function F(x)
> Implicit None
> !
> !:Variable Declaration Statements section
> !
> Real*8 X
> !
> !:Executable Code and Common Blocks Section
> !
> !
> !:Enter the User's Statement Section
> !
> F=(X-1)**2
> !
> !:End of User Procedure
> !
> Return
> End
>
> This compiles with no problem
>
> Michael
>
> Mike wrote:
thank you michael. But I do a little modification.
And I have some questions.
1. modify "REAL*8 " to "REAL*4"
2. add
xguess=3.
step=0.01
bound=100.
xacc=0.001
maxfn=50
before Call UVMIF (F, XGUESS, STEP, BOUND, XACC, MAXFN, X)
3. When I add
print *,'x, f(x)=',x,f(x)
after caller UVMIF
errors show
"Error: This name does not have a type, and must have an explicit type.
[F]".
Why? Isn't it a REAL*4 function type?
4. Why don't you have to put "USE numerical_libraries" ?
I mean you don't have to use IMSL library. It's quite strange. But
it's right.
Mike
| |
| Richard Maine 2006-09-21, 4:01 am |
| Mike <acout@yam.com> wrote:
> "Error: This name does not have a type, and must have an explicit type.
> [F]".
> Why? Isn't it a REAL*4 function type?
We've sure seen this question a lot recently. Must be at least the 3rd
time this w .
There is nothing in the main program to tell this to the compiler.
External procedures are, in principle, compiled separately. An external
procedure might not yet even be written when you compile the main
program that invokes it. The compiler does not get to "cheat" by looking
at the source code of the external function when compiling whatever
invokes it. You have to repeat the type information in every scope where
the function is invoked.
No, I don't like this. If you don't either, then don't use external
functions, as that's the way they have been since Fortran II. Module and
internal functions work differently; in those cases the calling routine
does have information about the called one.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
| |
| michael@athenavisual.com 2006-09-21, 8:01 am |
| Hi Mike:
This code works and executes correctly
Take a look at it and you can modify yous. The !DEC directive is enough
to link the
IMSL Library.
!DEC$ REAL:4
!DEC$OBJCOMMENT LIB:'IMSLS_ERR.LIB'
!DEC$OBJCOMMENT LIB:'IMSL.LIB'
Options /EXTEND_SOURCE
Program MAIN
!
!:Variable Declarations Section
!
Implicit None
Integer MAXFN, NOUT
Real*4 BOUND, F, STEP, X, XACC, XGUESS
External F
!
!:Prepare Results File
!
Open(Unit=6,FILE='ZO.RES',STATUS='UNKNOWN')
Rewind(Unit=6)
!
!:User Defined Problem Parameters
!
XGUESS=3.
STEP=0.01
BOUND=100.
XACC=0.001
MAXFN=50
CALL UVMIF (F, XGUESS, STEP, BOUND, XACC, MAXFN, X)
WRITE(6,*)X,F(X)
End
Real*4 Function F(X)
Implicit None
Real*4 X
!
!:Enter the User's Statement Section
!
F=(X-1)**2
Return
End
Cheers
Michael
Mike wrote:
> michael@athenavisual.com wrote:
>
> thank you michael. But I do a little modification.
> And I have some questions.
>
> 1. modify "REAL*8 " to "REAL*4"
> 2. add
> xguess=3.
> step=0.01
> bound=100.
> xacc=0.001
> maxfn=50
> before Call UVMIF (F, XGUESS, STEP, BOUND, XACC, MAXFN, X)
> 3. When I add
> print *,'x, f(x)=',x,f(x)
> after caller UVMIF
> errors show
> "Error: This name does not have a type, and must have an explicit type.
> [F]".
> Why? Isn't it a REAL*4 function type?
> 4. Why don't you have to put "USE numerical_libraries" ?
> I mean you don't have to use IMSL library. It's quite strange. But
> it's right.
>
> Mike
|
|
|
|
|