Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29273 Discussions

Trouble debugging an example of a type bound procedure [SOLVED/BUG]

pestun
Beginner
567 Views
Hi all,

Description of problem
I have trouble debugging the test program (see Code1 below), which makes use of a person type with a type bound procedure (see Code2). The program does work as expected---so no questions for this part, but I have trouble debugging it!

Now, the expected test behavior is that after the call of subroutine pers%new the fields pers%name and pers%id get initialized and become 'default' and 1, respectively.

In debug mode I can indeed see that this is the case within the main program. However, if I step into the subroutine null_person (see Code3), which is overloaded as "new", I get problems. Namely, the fields this%name and this%id look now as if they were undefined somehow, e.g., this%name='CK ' and this%id=1397900624.

Code1: Main program test03.f90.
[fxfortran]      program test03
use person_class03
implicit none
! Declaration
type (person) :: pers
! Default constructor (initialization)
call pers%new
! Use getter methods for output
write(6,fmt='(A)') pers%get_name()
write(6,fmt='(I)') pers%get_id()
! Destructor
call pers%term
stop 'Stop test03.'
end[/fxfortran]
Code2: Declaration of the person type (from person_class03.f90).
[fortran]type :: person
private
character(len=10) :: name
integer :: id
contains
procedure, pass :: new => null_person
procedure, pass :: term => term_person
procedure, pass :: get_name
procedure, pass :: get_id
end type person[/fortran]
Code3: Subroutine null_person (from person_class03.f90).
[fortran]subroutine null_person(this)
class (person), intent(out) :: this
this%name = 'default'
this%id = 1
end subroutine null_person[/fortran]

Test without type bound procedure
When I try the same test without bounding procedures to type (see Code4 and Code5), I see no problems in debug mode, as expected.

Code4: Main program test90.f90 without type-bounding.
[fxfortran]      program test90
use person_class90
implicit none
! Declaration
type (person) :: pers
! Default constructor (initialization)
call new(pers)
! Use getter methods for output
write(6,fmt='(A)') get_name(pers)
write(6,fmt='(I)') get_id(pers)
! Destructor
call term(pers)
stop 'Stop test90.'
end[/fxfortran]
Code5: Declaration of the person type (from person_class90.f90) without type-bounding.
[fortran]type :: person
private
character(len=10) :: name
integer :: id
end type person

interface new
module procedure null_person
end interface
interface term
module procedure term_person
end interface[/fortran]
Questions
I was wondering if this is a known behavior of the debugger. Is there a way to get the things displayed correctly in debug mode (VS options whatsoever)? Is it related to the implementation of FORTRAN 2003 features?

The environment
  • Microsoft Visual Studio 2008 Professional Edition, Version 9.0.30729.1 SP
  • Intel Visual Fortran Compiler Professional, Version 11.1 Build 20090930, Package ID: w_cprof_p_11.1.048
  • Intel Visual Fortran Compiler Integration for Microsoft Visual Studio* 2008, 11.1.3466.2008

The source files used in these examples are attached to the post.

Thank you in advance.
Pavel
0 Kudos
1 Solution
Lorri_M_Intel
Employee
567 Views
Yes, there were issues trying to debug dummy arguments that are "class" objectsin 11.1

We have addressed this in the next major release, but for now, the best option is what you've done; go up to the caller and look at the argument.

I apologize for that inconvenience.

- Lorri

View solution in original post

0 Kudos
2 Replies
Lorri_M_Intel
Employee
568 Views
Yes, there were issues trying to debug dummy arguments that are "class" objectsin 11.1

We have addressed this in the next major release, but for now, the best option is what you've done; go up to the caller and look at the argument.

I apologize for that inconvenience.

- Lorri
0 Kudos
pestun
Beginner
567 Views
Lorri,

Thank you for the prompt response.
I look forward to seeing this fixed in the next release :)

When is the next major release tentatively scheduled?

Pavel
0 Kudos
Reply