- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I get an access violation when I try to copy one extended structure to another:
"forrtl: severe (157): Program Exception - access violation"
If I use ordinary "types", then this works fine.
Am I not allowed to copy one extended type to another? Is there are workaround?
I am using the Intel Visual Fortran Compiler v. 16.0.
program Console1 implicit none ! Variables integer, parameter :: DP=8 integer, parameter :: MAXNAMELENGTH=10 !-- BASIC TYPE type :: T_BASIC(n) integer, len :: n=MAXNAMELENGTH !length of nam (defaults to MAXNAMELENGTH) character(len=n) :: nam !name integer :: iPoi !internal pointer end type T_BASIC !-- beam appurtenance properties type, extends(T_BASIC) :: T_prtapp !<- **** this will lead to trouble **** ! type :: T_prtapp !<- **** this will work **** integer :: Tp end type T_prtapp !-- beam appurtenances (actual appurtenances as used) type :: T_bapp type (T_prtapp) :: prt !appurtenance properties for this beam appurtenance end type T_bapp !-- Global data type :: T_G type(T_prtapp), dimension(:), allocatable :: prtapp !appurtenance properties integer :: nprtapp !number of appurtenance properties type(T_bapp), dimension(:), allocatable :: Bapp !beam appurtenances integer :: nBApp !number of beam appurtenances end type T_G type(T_G) :: G integer :: iret ! Body of Console1 G%nprtapp = 5 allocate(G%prtapp(G%nprtapp)) G%nBapp = 3 allocate(G%Bapp(G%nBapp)) G%Bapp(1)%prt = G%prtapp(1) !<- this throws the error iret = 1 end program Console1
Best regards
Lars
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can reproduce this in 16.0.3 but not in the current version 17.0.0. Please upgrade.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was able to create default assignment code to make it work. But the area of parameterized derived types has been problematic and if Steve says use latest compiler then it certainly is good advice.
module myType implicit none integer, parameter :: DP=8 integer, parameter :: MAXNAMELENGTH=10 type :: T_BASIC(n) integer, len :: n=MAXNAMELENGTH character(len=n) :: nam integer :: iPoi end type type, extends(T_BASIC) :: T_prtapp integer :: Tp end type type :: T_bapp type (T_prtapp) :: prt end type type :: T_G type(T_prtapp), dimension(:), allocatable :: prtapp integer :: nprtapp type(T_bapp), dimension(:), allocatable :: Bapp integer :: nBApp end type interface assignment(=) module procedure assignT_Basic module procedure assignT_prtapp end interface contains elemental subroutine assignT_Basic(b, a) type(T_Basic(*)), intent(in) :: a type(T_Basic(*)), intent(inout) :: b b%nam = a%nam b%iPoi = a%iPoi end elemental subroutine assignT_prtapp(b, a) type(T_prtapp), intent(in) :: a type(T_prtapp), intent(inout) :: b b%T_Basic = a%T_Basic b%Tp = a%Tp end end module program Console1 use myType implicit none type(T_G) :: G integer :: iret G%nprtapp = 5 allocate(G%prtapp(G%nprtapp)) G%nBapp = 3 allocate(G%Bapp(G%nBapp)) G%Bapp(1)%prt = G%prtapp(1) !<- this now works iret = 1 end program
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have upgraded to version 17 and it now seem to work.
Thank you both for the quick response.
Lars
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