PGF90 10.X problem with "check bound" & zero s

Hello .

I have problem with the “-C” check bound option and zero size array
(The original code I’m debuging has 1 million of lines = Meso-NH , the French WRF ;-) )

When compiled with ( I have the last current version PFG9010.9 )

pgf90 -C -g test_real_dim0.f90 -o test_real_dim0

I at run time I go’t

test_real_dim0
TEST :: sub_print from MAIN
MAIN :: size(CSV)= 0 shape(CSV)= 0 lbound(CSV)= 1 ubound(CSV)= 0
PASSED :: sub_print from MAIN

TEST :: sub_print from sub_with_size
sub_with_size :: size(HSV)= 0 shape(HSV)= 0 lbound(HSV)= 1 ubound(HSV)= 0
PASSED :: sub_with_size

TEST :: sub_print from sub_no_size
sub_no_size :: size(HSV)= 0 shape(HSV)= 0 lbound(HSV)= 1 ubound(HSV)= 0
0: Subscript out of range for array hsv (test_real_dim0.f90: 40)
subscript=1, lower bound=1, upper bound=0, dimension=1

The test code show 3 ways of calling the F77 ( without interface ) “sub_print” routine with an array of size-zero
( in our code Meso-NH, the array is multidimensional, and the size is read from namelist file & could by zero depending of the algorithm used , and a lot of other variables as passed to the subroutine ) .

The first 2 call , from main program and , passing the size of the array work fine,
but the last one , calling from and “assume shape array” + size(array) generate the “out of range” …

This code run without problem with all other FORTRAN compiler & check bound I’ve tested , ifort/gfortran/g95 .

Thank you in advance .

Juan , fort the Meso-NH user support

Here is the test code

SUBROUTINE sub_print(KSV,HSV)                                          
  IMPLICIT NONE                                                        

  INTEGER               :: KSV       ! number of scalars
  REAL, DIMENSION(KSV)  :: HSV                          

  INTEGER :: I
  !print*," => OK :: sub_print KSV=",KSV
  DO i=1,KSV                            
     PRINT*,"i,HSV",i,HSV               
  END DO                                

END SUBROUTINE sub_print
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MODULE mode_sub                                                                                            

CONTAINS
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  SUBROUTINE sub_with_size(KSV,HSV)                                                                        
    IMPLICIT NONE                                                                                          

    INTEGER                           :: KSV       ! number of scalars
    REAL, DIMENSION(KSV), INTENT(IN)  :: HSV                          

    write(*,'("  sub_with_size :: size(HSV)= ",I4," shape(HSV)=",I4 ," lbound(HSV)=",I4," ubound(HSV)=",I4)') &
           size(HSV), shape(HSV), lbound(HSV),  ubound(HSV)                                                    
    CALL sub_print(KSV,HSV)                                                                                    

  END SUBROUTINE sub_with_size
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  SUBROUTINE sub_no_size(HSV)                                                                              
    IMPLICIT NONE                                                                                          

    REAL, DIMENSION(:), INTENT(IN)  :: HSV 

    write(*,'("  sub_no_size   :: size(HSV)= ",I4," shape(HSV)=",I4 ," lbound(HSV)=",I4," ubound(HSV)=",I4)') &
          size(HSV), shape(HSV), lbound(HSV),  ubound(HSV)                                                     

    CALL sub_print(SIZE(HSV),HSV)

  END SUBROUTINE sub_no_size

END MODULE mode_sub
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
PROGRAM test_dim0                                                                                          

USE mode_sub

IMPLICIT NONE

INTEGER                          :: ISV       ! number of scalars
REAL, DIMENSION(:), ALLOCATABLE  :: CSV

ISV = 0
ALLOCATE (CSV(ISV))
CSV = 1.0

print*," TEST   :: sub_print from MAIN "
write(*,'("  MAIN          :: size(CSV)= ",I4," shape(CSV)=",I4 ," lbound(CSV)=",I4," ubound(CSV)=",I4)') &
          size(CSV), shape(CSV), lbound(CSV),  ubound(CSV)

CALL sub_print(ISV,CSV)
print*," PASSED :: sub_print from MAIN " ; print*

print*," TEST   :: sub_print from sub_with_size  "
CALL sub_with_size(ISV,CSV)
print*," PASSED :: sub_with_size  " ; print*

print*," TEST    :: sub_print from sub_no_size  "
CALL sub_no_size(CSV)
print*," PASSED :: sub_no_size  " ; print*

END PROGRAM test_dim0

Hello, it’s me again .

I’ve bypassed some of the previous problem in mono-processor execution ( deactivating the ‘-C’ for some routines )

But now I go a similare problem on (MPI) multi-processor runs with boundary array ( of zero-size , for processors not in the physical boundarys ) …

So a more simple test example of the same problem with , check bound + zero-size array , this time with multi-dimensional array .

pgf90 -C -g test_real_multi_dim0.f90 -o test_real_multi_dim0
test_real_multi_dim0
TEST :: sub_no_size
0: Subscript out of range for array boundary (test_real_multi_dim0.f90: 39)
subscript=1, lower bound=1, upper bound=0, dimension=1

With ifort no problem :

ifort -C -g test_real_multi_dim0.f90 -o test_real_multi_dim0
test_real_multi_dim0
TEST :: sub_no_size
sub_no_size :: size(HSV)= 0 shape(HSV)= 0 lbound(HSV)= 1 ubound(HSV)= 0
==> sub_no_size : no boundary
PASSED :: sub_no_size

The test_real_multi_dim0.f90 file

MODULE mode_sub                                                                                              

CONTAINS
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  SUBROUTINE sub_no_size(HSV)                                                                              
    IMPLICIT NONE                                                                                          

    REAL, DIMENSION(:), INTENT(IN)  :: HSV 

    write(*,'("  sub_no_size   :: size(HSV)= ",I4," shape(HSV)=",I4 ," lbound(HSV)=",I4," ubound(HSV)=",I4)') &
          size(HSV), shape(HSV), lbound(HSV),  ubound(HSV)                                                     

    IF (size(HSV) .EQ. 0 ) THEN
       print*," ==> sub_no_size : no boundary " 
    ELSE                                        
       print*," ==> sub_no_size : boundary , DO some WORK  " 
    END IF                                                   
                                                             
  END SUBROUTINE sub_no_size

END MODULE mode_sub
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
PROGRAM test_multi_dim0

USE mode_sub

IMPLICIT NONE

INTEGER                            :: NX,NZ      ! dims
REAL, DIMENSION(:,:), ALLOCATABLE  :: BOUNDARY

NX = 0   ! MPI domain decomposiotn , some proc have no boundary !!!
NZ = 10
ALLOCATE(BOUNDARY(NX,NZ))
BOUNDARY = 1.0

print*," TEST    :: sub_no_size  "
CALL sub_no_size(BOUNDARY(:,NZ))
print*," PASSED :: sub_no_size  " ; print*

END PROGRAM test_multi_dim0

Thank you .
Juan

Hi Juan,

Thanks for the report. It does appear that the bounds checking is in error. I have created a technical problem report (TPR#17399) and sent on to our engineers for further investigation.

Best Regards,
Mat

:-) OK Thank you Mat ( ;-) more are coming soon )

Juan

Juan,

TPR 17399 - Checking the bounds of zero-size arrays

has been corrected in the 11.0 release, which is now available.

Thanks again for your submission.

regards,
dave

:-) Thank you Dave & Bonne Année

I’m testing this new version right now …

Bye

Juan