- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am experiencing what appears to be incorrect behavior when attempting to remap the bounds of an array within a derived type. Given an allocatable array of components(elements), within a 'mesh' type, I am trying to remap the rank-1 'elems' array within a 'mesh' type to a rank-3 view. Unfortunately I have not yet had luck trying to produce a minimum working example so the following code is just to convey the concept here.
type :: element_t integer :: ielem end type type :: mesh_t type(element_t), allocatable :: elems(:) end type type :: domain_t type(mesh_t) :: mesh end type
I encounter the behavior in a situation like the following, where I have a domain%mesh%elems component that I would like to remap as a matrix:
type(domain_t) :: domain type(element_t), pointer :: elems_m(:,:,:) % Domain is initialized with 2 elements elems_m(1:2,1:1,1:1) => domain%mesh%elems(1:2)
When I access the elements of elems_m(1,1,1) and elems_m(2,1,1), they both point to domain%mesh%elems(1).
I am using ifort 15.0.3 on OS X. I have observed gfortran 4.9.2 produces the expected results of elems_m(1,1,1) => elems(1) and elems_m(2,1,1) => elems(2).
I did find a work around via an entry on https://wiki.ucar.edu/display/ccsm/Fortran+Compiler+Bug+List with regards to the NAG compiler. In the workaround, I first create a temporary rank-1 pointer and associate it with the rank-1 derived-type component. I then remap the bounds using the temporary pointer as follows:
type(domain_t) :: domain type(element_t), pointer :: elems_m(:,:,:) type(element_t), pointer :: temp(:) % Initialize domain%mesh with 2 elements temp => domain%mesh%elems elems_m(1:2,1:1,1:1) => temp(1:2)
Now, accessing the components of elems_m produces the expected results as elems_m(1,1,1) => elems(1) and elems_m(2,1,1) => elems(2)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was able to reproduce the problem in 15.0.4, but not in 16.0. The 16.0 compiler will be released in August.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, I'll see if I can take your snippets and construct a reproducer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was able to reproduce the problem in 15.0.4, but not in 16.0. The 16.0 compiler will be released in August.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great, thanks for the follow-up Steve.

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