Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26734 Discussions

How to pass 'structured type' in another 'structure type' variable?

dimdol10
New Contributor I
123 Views

Hello,

I need to define a 'structured type' variable(A) in another 'structure type' variable(B), and pass it to a subroutine.

However, when I tried to pass the variable (B) to a subroutine and check the 'watch' of the variable, the variable (A) in (B) does not seem to be delivered properly, as shown in the following figure. The integer variable NZC is passed well, but the array CIDX and COMP is shown to be undefined array.

Straingely enough, when I print this varible, the printing result is fine. I think the way I use in the below example code is not proper for passing the 'structured type' variable. Please give any comments or helps. Thanks.

check_watch.png

Below is the corresponding example code.

C     ===================================================================     
      MODULE SPARSE_SOL
     
      TYPE CSR
          INTEGER, ALLOCATABLE :: CIDX(:) ! col idx
          DOUBLE PRECISION, ALLOCATABLE :: COMP(:)    ! component
          INTEGER nzc ! # of non-zero col
      END TYPE
     
      TYPE CSRG
          TYPE(CSR), ALLOCATABLE :: MAT(:)
          INTEGER tot_nz  ! tot # of nonzero components
c     vector format
          INTEGER, ALLOCATABLE :: G_RIDX(:) ! row idx
          INTEGER, ALLOCATABLE :: G_CIDX(:) ! col idx
          DOUBLE PRECISION, ALLOCATABLE :: G_COMP(:)  ! components       
      END TYPE     
           
      END MODULE
C     ===================================================================
     
      PROGRAM type_argument
      USE SPARSE_SOL     
      IMPLICIT NONE
      INTEGER I,J
     
c     input variables
      TYPE(CSRG) KT    
     
      KT%tot_nz = 25   ! total # of nonzero components
      ALLOCATE(KT%MAT(5))
     
      DO I = 1,5
          ALLOCATE(KT%MAT(I)%CIDX(5),KT%MAT(I)%COMP(5))   
          DO J = 1,5
              KT%MAT(I)%CIDX(J) = J         
              KT%MAT(I)%COMP(J) = J**2
          END DO
          KT%MAT(I)%nzc = 5
      END DO
      ALLOCATE(KT%G_RIDX(6),KT%G_CIDX(5),KT%G_COMP(KT%tot_nz))
     
      DO I = 1,5
          KT%G_RIDX(I) = 5*I
          KT%G_CIDX(I) = I
          DO J = 1,5
              KT%G_COMP(5*(I-1)+J) = MOD(J,5)**2
          END DO
      END DO
         
      CALL PRINT_FUNC(KT)
     
      CONTINUE
     
      END
     
C     ===========================================================
      SUBROUTINE print_func(A)
     
      USE SPARSE_SOL  
     
      TYPE(CSRG) A
      INTEGER I
     
     
      DO I = 1,5
      PRINT *, I,'-th row of the matrix'
      PRINT *, A%MAT(I)%CIDX     
      PRINT *, A%MAT(I)%nzc
      PRINT *, A%MAT(I)%COMP
      PRINT *, '====================='
      END DO
          
      CONTINUE
     
      END     

 

 

 

0 Kudos
1 Solution
dimdol10
New Contributor I
123 Views

Thanks for comments.

I have executed the above code using the latest version of the parallel studio (XE2018 update 1 cluster edition).

As mentioned by FortranFan, I have registered a support request for this incident.

Thanks.

 

 

 

View solution in original post

3 Replies
andrew_4619
Honored Contributor I
123 Views

You don't say which version you are using. In 18 (original) I see this behaviour often but it is usually just a debugger display problem, you usually find it is passed OK.

FortranFan
Honored Contributor II
123 Views

Can you, by any chance, retry with Intel Fortran 18.0 compiler Update 1?  I think what you're noticing is a limitation with Intel Fortran with Visual Studio (VS) debugger.  If you still find issues with the latest Intel Fortran offering, then I suggest you submit an incident at the Intel Online Support Center (OSC):

https://supporttickets.intel.com/?lang=en-US

and request that the Intel Fortran integration with Visual Studio be enhanced to allow users to work with objects in the Watch windows in VS debugger environment that are Fortran derived type components with the ALLOCATABLE (and also POINTER) attribute.  And attach everything you show in the original post above with the incident.

dimdol10
New Contributor I
124 Views

Thanks for comments.

I have executed the above code using the latest version of the parallel studio (XE2018 update 1 cluster edition).

As mentioned by FortranFan, I have registered a support request for this incident.

Thanks.

 

 

 

View solution in original post

Reply