Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I

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

Jump to solution

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

Accepted Solutions
Highlighted
New Contributor I

Thanks for comments.

Jump to solution

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

0 Kudos
3 Replies
Highlighted
Valued Contributor II

You don't say which version

Jump to solution

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.

0 Kudos
Highlighted
Valued Contributor III

Can you, by any chance, retry

Jump to solution

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.

0 Kudos
Highlighted
New Contributor I
1 View

Thanks for comments.

Jump to solution

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

0 Kudos