|
| View previous topic :: View next topic |
| Author |
Message |
sgs
Joined: 29 Jan 2013 Posts: 4
|
Posted: Tue Jan 29, 2013 5:52 pm Post subject: Object-Oriented Fortran 03 |
|
|
I've been looking to use CUDA Fortran and/or OpenACC to accelerate some kernels in a moderately large code I work with (which is written in OO F03). However, I've been encountering several issues compiling with PGI.
I've created a small test program that demonstrates the current issues I'm observing, which seem to be related to allocatable arrays in user defined derived types. Any thoughts on what sorts of support should be coming out in future releases? Or work-arounds to these issues?
| Code: |
PROGRAM vector
IMPLICIT NONE
TYPE,ABSTRACT :: VectorType
LOGICAL(4) :: isInit=.FALSE.
INTEGER(4) :: n=0
ENDTYPE VectorType
TYPE,EXTENDS(VectorType) :: RealVectorType
REAL(8),ALLOCATABLE :: b(:)
ENDTYPE RealVectorType
TYPE(RealVectorType) :: thisVector
INTEGER(4) :: n=5
SELECTTYPE(thisVector); TYPE IS(RealVectorType)
IF(.NOT. thisVector%isInit) THEN
IF(n < 1) THEN
WRITE(*,*) 'fail'
ELSE
thisVector%isInit=.TRUE.
thisVector%n=n
ALLOCATE(thisVector%b(n))
WRITE(*,*) 'success'
ENDIF
ENDIF
ENDSELECT
ENDPROGRAM vector |
|
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Wed Jan 30, 2013 10:06 am Post subject: |
|
|
Hi sgs,
The problem with this code is that "thisVector" isn't polymorphic. What error are you getting? What version of the compiler are you using?
We did add support allocatable arrays in user defined derived types a few years ago (sorry I've forgotten the exact version) so you're issue may be solved by using the latest compiler version.
- Mat
| Code: | % pgfortran -c 1_30_13.f90
PGF90-S-0034-Syntax error at or near identifier vectortype (1_30_13.f90: 17)
0 inform, 0 warnings, 1 severes, 0 fatal for vector |
gfortran gives a better error message: | Code: |
% gfortran -c 1_30_13.f90
1_30_13.f90:17.25:
SELECTTYPE(thisVector); TYPE IS(RealVectorType)
1
Error: Selector shall be polymorphic in SELECT TYPE statement at (1)
|
|
|
| Back to top |
|
 |
sgs
Joined: 29 Jan 2013 Posts: 4
|
Posted: Wed Jan 30, 2013 11:39 am Post subject: |
|
|
Mat,
Thanks for your reply. I see that my small test program was incorrect. However,I'm made a slight modification so thisVector is polymorphic. This compiles fine with gfortran, but not pgi (at least with version 12.9.0) as far as I can tell.
| Code: |
PROGRAM vector
IMPLICIT NONE
TYPE,ABSTRACT :: VectorType
LOGICAL(4) :: isInit=.FALSE.
INTEGER(4) :: n=0
ENDTYPE VectorType
TYPE,EXTENDS(VectorType) :: RealVectorType
REAL(8),ALLOCATABLE :: b(:)
ENDTYPE RealVectorType
CLASS(VectorType),ALLOCATABLE :: thisVector
INTEGER(4) :: n=5
ALLOCATE(RealVectorType :: thisVector)
SELECTTYPE(thisVector); TYPE IS(RealVectorType)
IF(.NOT. thisVector%isInit) THEN
IF(n < 1) THEN
WRITE(*,*) 'fail'
ELSE
thisVector%isInit=.TRUE.
thisVector%n=n
ALLOCATE(thisVector%b(n))
WRITE(*,*) 'success'
ENDIF
ENDIF
ENDSELECT
ENDPROGRAM vector
|
|
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Wed Jan 30, 2013 2:26 pm Post subject: |
|
|
Thanks SGS,
I sent this to one of our engineers who determine it is indeed a compiler error but as he puts it, " albeit a very strange one". I submitted a problem report, TPR#19094.
The work around is to change "TYPE IS" to "CLASS IS".
Thanks for the report,
Mat |
|
| Back to top |
|
 |
sgs
Joined: 29 Jan 2013 Posts: 4
|
Posted: Wed Jan 30, 2013 3:11 pm Post subject: |
|
|
Interesting. Yeah, we've definitely had some trouble with some of the object oriented-ness in general. We have a lot of extra SELECTTYPE statements as work arounds for Intel windows compilers. We'll see how it goes...at least until the next version is released.
Thanks for your time. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|