- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi
I am trying procedure component with version 11.0.039 beta to fake a type bound procedure (at least I think that is what I am doing :) )
But I get compilation error as:
For Test # 1 (see below for source code)
Error 1 error #6460: This is not a field name that is defined in the encompassing structure. [SHOW]
Error 2 Compilation Aborted (code 1)
The output log is
Compiling with Intel Fortran 11.0.039 [IA-32]... ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\" /object:"Debug\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc8 /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin" "C:\Abhi\MySource\Tests\Test_TypewithPointers\NewMain.f90" C:\Abhi\MySource\Tests\Test_TypewithPointers\NewMain.f90(288): error #6460: This is not a field name that is defined in the encompassing structure. [SHOW] Call Trial%Show(Trial, j) --------------------^ fortcom: Fatal: There has been an internal compiler error (C0000005). compilation aborted for C:\Abhi\MySource\Tests\Test_TypewithPointers\NewMain.f90 (code 1) Test_TypewithPointers - 2 error(s), 0 warning(s)
And for Test # 2
Error 1 Compilation Aborted (code 1)
The output log is
Deleting intermediate files and output files for project 'Test_TypewithPointers', configuration 'Debug|Win32'. |
I am not sure what I am doing wrong. Below is the source code for two methods I tried.
Abhi
===============
[1] Test # 1
Module TypeWithProcedure
Implicit None
Type Mytype
Integer :: n
Procedure(), Pointer, NoPass :: Show
End Type Mytype
Contains
Subroutine Display(DummyType, iSomeThingElse)
Implicit None
Type(Mytype), Intent(INOUT) :: DummyType
Integer, Intent(OUT) :: iSomeThingElse
Write(*,*) DummyType%n
iSomeThingElse = 1
End Subroutine Display
Subroutine Initialize_Mytype(DummyType)
Implicit None
Type(Mytype), Intent(OUT) :: DummyType
DummyType%n = 0
DummyType%Show => Display
End Subroutine Initialize_mytype
End Module TypeWithProcedure
Program Test_TypeWithProcedure
Use TypeWithProcedure
Implicit None
Integer :: j
Type(Mytype) :: Trial
Call Initialize_Mytype(Trial)
j = 0
Call Trial%Show(Trial, j)
Print *, j
End Program Test_TypeWithProcedure
=========
[2] Test # 2
Module TypeDefinition
Implicit None
Type Mytype
Integer :: n
Procedure(), Pointer, NoPass :: Show
End Type Mytype
End Module TypeDefinition
Module TypeProcedures
Use TypeDefinition
Implicit None
Contains
Subroutine Display(DummyType, iSomeThingElse)
Implicit None
Type(Mytype), Intent(INOUT) :: DummyType
Integer, Intent(OUT) :: iSomeThingElse
Write(*,*) DummyType%n
iSomeThingElse = 1
End Subroutine Display
End Module TypeProcedures
Module TypeBind
Use TypeDefinition
Use TypeProcedures
Implicit None
Subroutine Initialize_Mytype(DummyType)
Implicit None
Type(Mytype), Intent(OUT) :: DummyType
DummyType%n = 0
DummyType%Show => Display
End Subroutine Initialize_mytype
End Module TypeBind
Program Test_TypeWithProcedure
Use TypeDefinition
Use TypeBind
Implicit None
Integer :: j
Type(Mytype) :: Trial
Call Initialize_Mytype(Trial)
j = 0
Call Trial%Show(Trial, j)
Print *, j
End Program Test_TypeWithProcedure
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
The 11.0 Beta compiler is suffering an internal compiler error for both cases and while we ask that customer file Premier issues against the Beta compiler, I will do that for this instance.
I may be wrong, but I think the PROCEDURE statement may require a name of an abstract interface or a procedure with an explicit interface.
Perhaps the changes I made below to declare and use ShowMe will accomplish what you are after.
[cpp] 1 Module TypeWithProcedure
2 Implicit None
3
4 Type Mytype
5 Integer :: n
6 Procedure(ShowMe), Pointer, NoPass :: Show
7 End Type Mytype
8
9 Abstract Interface
10 Subroutine ShowMe(DType,iThing)
11 Import Mytype
12 Type(Mytype), Intent(INOUT) :: DType
13 Integer, Intent(OUT) :: iThing
14 end subroutine ShowMe
15 end interface
16
17 Contains
18
19 Subroutine Display(DummyType, iSomeThingElse)
20 Implicit None
21
22 Type(Mytype), Intent(INOUT) :: DummyType
23 Integer, Intent(OUT) :: iSomeThingElse
24
25 Write(*,*) DummyType%n
26
27 iSomeThingElse = 1
28
29 End Subroutine Display
30
31 Subroutine Initialize_Mytype(DummyType)
32 Implicit None
33
34 Type(Mytype), Intent(OUT) :: DummyType
35
36 DummyType%n = 0
37 DummyType%Show => Display
38
39 End Subroutine Initialize_mytype
40 End Module TypeWithProcedure
41
42 Program Test_TypeWithProcedure
43
44 Use TypeWithProcedure
45 Implicit None
46
47 Integer :: j
48 Type(Mytype) :: Trial
49
50 Call Initialize_Mytype(Trial)
51
52 j = 0
53 Call Trial%Show(Trial, j)
54 Print *, j
55
56 End Program Test_TypeWithProcedure[/cpp]
Link kopiert
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
The 11.0 Beta compiler is suffering an internal compiler error for both cases and while we ask that customer file Premier issues against the Beta compiler, I will do that for this instance.
I may be wrong, but I think the PROCEDURE statement may require a name of an abstract interface or a procedure with an explicit interface.
Perhaps the changes I made below to declare and use ShowMe will accomplish what you are after.
[cpp] 1 Module TypeWithProcedure
2 Implicit None
3
4 Type Mytype
5 Integer :: n
6 Procedure(ShowMe), Pointer, NoPass :: Show
7 End Type Mytype
8
9 Abstract Interface
10 Subroutine ShowMe(DType,iThing)
11 Import Mytype
12 Type(Mytype), Intent(INOUT) :: DType
13 Integer, Intent(OUT) :: iThing
14 end subroutine ShowMe
15 end interface
16
17 Contains
18
19 Subroutine Display(DummyType, iSomeThingElse)
20 Implicit None
21
22 Type(Mytype), Intent(INOUT) :: DummyType
23 Integer, Intent(OUT) :: iSomeThingElse
24
25 Write(*,*) DummyType%n
26
27 iSomeThingElse = 1
28
29 End Subroutine Display
30
31 Subroutine Initialize_Mytype(DummyType)
32 Implicit None
33
34 Type(Mytype), Intent(OUT) :: DummyType
35
36 DummyType%n = 0
37 DummyType%Show => Display
38
39 End Subroutine Initialize_mytype
40 End Module TypeWithProcedure
41
42 Program Test_TypeWithProcedure
43
44 Use TypeWithProcedure
45 Implicit None
46
47 Integer :: j
48 Type(Mytype) :: Trial
49
50 Call Initialize_Mytype(Trial)
51
52 j = 0
53 Call Trial%Show(Trial, j)
54 Print *, j
55
56 End Program Test_TypeWithProcedure[/cpp]
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hello Kevin
Many thanks for your response and taking care of submitting it to the premier support. Your snippet works as expected.
There are two points in my mind:
(1) The procedure pointer component is surely NOT required to have the interface given. The only restriction for the implicit interface is that the prcedure has to be "NoPass". While for the purposes of "faking" a type bound procedure, there should be no problem in creating the abstract interfaces, I don't think it is something that the "standard requires".
(2) If I am 90% sure of what the language standard is about the previous point, I am not so sure for the this one...In particular, this has to with the order in which the type and interface is specified. The abstract interface, although used in the procedure pointer component's interface specification, is AFTER the type declaration and yet the type has no problems accepting it.... We cannot put the abstract interface before the type declaration since it imports the type defintion. Then, why, if I may ask, can't one just ommit the Abstract Interface declaration? That is why can't the interface to the procedure, in this case, subroutine Display, be directly used? The procedure is in the same module and if the type can "wait" and then resolve the procedure component interface through abstract interface why not through the module's procedure?
Abhi
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I also find that if I don't inlcude "iSomethingElse" in the interface to the procedure, I get an internal compiler error.
More specifically, the subroutine Display has only one argument and that is the object of type MyType. The procedure pointer component is still give the attribute "Pass". When the call is made from the program, it is simply Trial%Show since no argument needs to be passed.
With this change I get: fortcom: Fatal: There has been an internal compiler error (C0000005).
If I used NoPass instead and make a corresponding change to call, the building (and execuation) is successful.
Abhi
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi Abhi,
I am still learning about this and other F2003 features and after some further reading; I concur with you about (1) and am seeking some guidance regarding yours questions in (2).
I suspect all of the internal errors are related and will code up the third variant per your description and include that in the report to the Fortran Front-end developer. It is possible some or all of the variants will work after the internal error is fixed. I will keep you posted. (Internal ref. CQ-50185)
Kevin
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Kevin
I appreciate you entertaining this post and following up on it. I would be looking for to testing the new beta version when (and if) that is available.
The abstract interface and passing a dummying argument (or using NoPass) is an work-around that is good enough at present.
Abhi
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi Abhi,
This issue is fixed in the latest 11.0 update, 11.0.072 (Windows). It is also included in the latest Linux/Mac OS updates 11.0.081/11.0.059.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi Abhi,
This issue is fixed in the latest 11.0 update, 11.0.072 (Windows). It is also included in the latest Linux/Mac OS updates 11.0.081/11.0.059.
Hi Kevin
I am not sure what has been fixed..The program below will not compile. I am using 11.0.072 on WinXP64 with VS2005. The error listing I get is:
Error 1 error #8169: The specified interface is not declared. [VIEW] C:AbhiMySourceTestsTest_TypeWithProcTest_TypeWithProc.f90 8
Error 2 error #6404: This name does not have a type, and must have an explicit...

- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite