Fortran90: XLF 3.02 bug in RESHAPE ? 
Author Message
 Fortran90: XLF 3.02 bug in RESHAPE ?

Consider the following procedure:

        SUBROUTINE shape_bug ( arg )
          INTEGER, DIMENSION(:,:)              :: arg        !  line 2
          INTEGER, DIMENSION(SIZE(      arg )) :: arg_rank1
          INTEGER, DIMENSION(SIZE(SHAPE(arg))) :: arg_shape  !  line 4

          arg_shape = SHAPE(arg)
          arg_rank1 = 0
          arg       = RESHAPE(arg_rank1, arg_shape)          !  line 8
        END SUBROUTINE shape_bug

IMHO, this is legal F90 code. Although the missing RANK() intrinsic has
to be coded by the use of SIZE(SHAPE(arg)) in line 4, it _must_ be clear
to the compiler that both arg_rank1 and arg_shape are rank-one arrays.
(Of course, because of (:,:) in line 2 I know the extent of arg_shape
 is 2, but this is just a simple example...)

This code is compiled by NAG's f90 and FN90 compilers. However, IBM's
XLF Version 3.02 flags the following error:

  line 8.42: 1513-141 (S) SHAPE must be of type integer, rank one,
                          and constant size.

Is this a compiler bug, or is the above code not legal F90?

Best regards,
Michael

 ======================================================================
  Michael Hennecke          URL: http://www.*-*-*.com/ ~rz48/
 ----------------------------------------------------------------------


  Zirkel 2  *  P.O. Box 69 80                 Phone: +49 721  608-4862
  D-76128  Karlsruhe                               Fax: +49 721  32550
 ======================================================================



Sat, 23 Aug 1997 03:04:20 GMT  
 Fortran90: XLF 3.02 bug in RESHAPE ?

|> Consider the following procedure:
|>
|>         SUBROUTINE shape_bug ( arg )
|>           INTEGER, DIMENSION(:,:)              :: arg        !  line 2
|>           INTEGER, DIMENSION(SIZE(      arg )) :: arg_rank1
|>           INTEGER, DIMENSION(SIZE(SHAPE(arg))) :: arg_shape  !  line 4
|>
|>           arg_shape = SHAPE(arg)
|>           arg_rank1 = 0
|>           arg       = RESHAPE(arg_rank1, arg_shape)          !  line 8
|>         END SUBROUTINE shape_bug
|>
|> This code is compiled by NAG's f90 and FN90 compilers. However, IBM's
|> XLF Version 3.02 flags the following error:
|>
|>   line 8.42: 1513-141 (S) SHAPE must be of type integer, rank one,
|>                           and constant size.
|>
|> Is this a compiler bug, or is the above code not legal F90?
|>

     I believe this code is not legal fortran 90.  According to the standard,
the SHAPE argument of RESHAPE must have a constant size.  According to 7.1.6.1,
among other things, a constant expression is:

    (6) A reference to an inquiry intrinsic function which is:
           a) an array inquiry function (13.10.15) other than ALLOCATED,
              .
              .
              .
        and where each argument of the function is
           a) a constant expression, or
           b) a variable whose properties inquired about are not:
              1) assumed,
              2) defined by an expression that is not a constant expression,
                 or
              3) definable by an ALLOCATE or POINTER assignment statement

(The above text comes from defect item 97 - the original text in the standard
was slightly different.)

     In your example, the size of arg_shape is SIZE(SHAPE(arg)).  For this to be
a constant expression, SHAPE(arg) must be a constant expression (since it's not
a variable).  In order for SHAPE(arg) to be a constant expression, the
properties of arg about which we are inquiring must not be assumed.  However,
arg is an assumed-shape array.  Which means that SHAPE(arg) is not a constant
expression, and in turn, SIZE(SHAPE(arg)) is not a constant expression.

     I'm not sure off-hand what would be a good substitute for the code that
you use.  I'll try to dig a little deeper into this.

Thanks,

Henry
-------------------------------------------------------------------------------
Henry Zongaro      XL Fortran Compiler Development
IBM SWS Toronto Lab   Phone (416) 448-6044



Sat, 23 Aug 1997 23:44:52 GMT  
 Fortran90: XLF 3.02 bug in RESHAPE ?

Quote:


>(Michael Hennecke) writes:
>|>Consider the following...:
>|>
>|>          arg       = RESHAPE(arg_rank1, arg_shape)          !  line 8

                                            ^^^^^^^^^ non-standard,
                                                      non-constant, intrinsic
                                                      argument

Quote:

>Just as another data point, DEC Fortran 90 doesn't complain about this code.

How about when the DEC Fortran 90 option "-std" is used to flag
non-Fortran 90 elements? It is important that users know they are
relying on extensions particularly when they are learning the language.
--



Mon, 25 Aug 1997 04:32:16 GMT  
 Fortran90: XLF 3.02 bug in RESHAPE ?


Quote:
(Michael Hennecke) writes:

|>Consider the following procedure:
|>
|>        SUBROUTINE shape_bug ( arg )
|>          INTEGER, DIMENSION(:,:)              :: arg        !  line 2
|>          INTEGER, DIMENSION(SIZE(      arg )) :: arg_rank1
|>          INTEGER, DIMENSION(SIZE(SHAPE(arg))) :: arg_shape  !  line 4
|>
|>          arg_shape = SHAPE(arg)
|>          arg_rank1 = 0
|>          arg       = RESHAPE(arg_rank1, arg_shape)          !  line 8
|>        END SUBROUTINE shape_bug
|>

Just as another data point, DEC Fortran 90 doesn't complain about this code.
--


DEC Fortran Development           WWW:  http://www.digital.com/info/slionel.html
Digital Equipment Corporation     CompuServe: 75263,3001
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698             "Free advice is worth every cent"




Sun, 24 Aug 1997 04:45:05 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. J 3.02

2. (g)sed 3.02 for native Win32 available

3. Princen send mail 3.02

4. SIX 3.00.01 to SIX 3.02

5. Six RDD 3.02 o COMIX RDD 3.09

6. Announcing ficl release 3.02

7. Six Library 3.00 to 3.02

8. Rexx2Nrx vs 3.02 pre-release 7

9. BROKEN ALLOC.DEF in JPI 3.02

10. Topspeed Modula-2 3.02 and DLL

11. TS 3.02 & bios.def

12. Topspeed Modula-2 3.02 and DLL

 

 
Powered by phpBB® Forum Software