- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi,
the following code,
[fortran]subroutine init_material( this, lMin, nlMin ) class( material ), intent(inout) :: this class( gumLinMaterial ), intent(in) :: lMin class( gumNonlinMaterial ), intent(in) :: nlMin
! gumLinMat, gumNonLinMat are abstract derived types,
! both extending another abstract derived types linearMaterial and nonLinMaterial this%isNonLin = .true. allocate( this%gumLinMat, source=lMin )
! material%gumLinMat variable definition is:
! class( gumLinMaterial ), allocatable :: gumLinMat allocate( this%gumNonLinMat, source=nlMin) allocate( this%gumNonLinMat%hardening, source=nlMin%hardening ) select type( linM => this%gumLinMat )
! class is( linearMaterial ), fortran recogizes that this is not viable during compiling... class is( gumLinMaterial ) write(*,*) 'gumlin' end select end subroutine init_material[/fortran]compiles. but gives some unexpected results (for my opinion).
select type will tell me that this%gumLinMat is not a class(gumLinMaterial), so the type specific write will not be executed.
how could this be? both the allocated type and declaration type is gumLinMaterial?
p.s.: the whole code is quite a few thousand lines so it is difficult to post it
the following code,
[fortran]subroutine init_material( this, lMin, nlMin ) class( material ), intent(inout) :: this class( gumLinMaterial ), intent(in) :: lMin class( gumNonlinMaterial ), intent(in) :: nlMin
! gumLinMat, gumNonLinMat are abstract derived types,
! both extending another abstract derived types linearMaterial and nonLinMaterial this%isNonLin = .true. allocate( this%gumLinMat, source=lMin )
! material%gumLinMat variable definition is:
! class( gumLinMaterial ), allocatable :: gumLinMat allocate( this%gumNonLinMat, source=nlMin) allocate( this%gumNonLinMat%hardening, source=nlMin%hardening ) select type( linM => this%gumLinMat )
! class is( linearMaterial ), fortran recogizes that this is not viable during compiling... class is( gumLinMaterial ) write(*,*) 'gumlin' end select end subroutine init_material[/fortran]compiles. but gives some unexpected results (for my opinion).
select type will tell me that this%gumLinMat is not a class(gumLinMaterial), so the type specific write will not be executed.
how could this be? both the allocated type and declaration type is gumLinMaterial?
p.s.: the whole code is quite a few thousand lines so it is difficult to post it
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page