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

Copying common blocks

wkramer
Beginner
321 Views
Hello,
I always used to copy contiguous elements betweencommon blocks or within a common block usingthe followingfunction:
Code:
      SUBROUTINE A203(L,A,B)

C***********************************************************************
C     A203 - COPIES L ARRAY ELEMENTS, STARTING WITH ELEMENT 1 OF       *
C     ARRAY A TO ELEMENT 1 OF ARRAY B                                  *
C***********************************************************************
      USE PRECISION
      IMPLICIT NONE

      INTEGER(ISP), INTENT(IN) :: L
      REAL(FP), DIMENSION(1), INTENT(IN) ::  A
      REAL(FP), DIMENSION(1), INTENT(OUT) :: B
      INTEGER(ISP) :: I

      DO I=1,L
        B(I)=A(I)
      ENDDO
      RETURN
      END
It still functions, but since IVF version 9.0 offers the possibility I switched on /gen-interfaces /warn:interfaces and now I get the following warning and the build stops:
Error: If the actual argument is scalar, the corresponding dummy argument shall be scalar unless the actual argument is an element of an array that is not an assumed-shape or pointer array, or a substring of such an element.
The entries of the common block(s) are indeed scalar.
Ithere a better way of copying contiguous elements between or within common blocks, so I can keep the aforementioned compiler options on and further investigate my application?
Thanks,
Walter

Message Edited by wkramer on 07-04-2005 11:14 AM

0 Kudos
3 Replies
Steven_L_Intel1
Employee
321 Views
My advice would be:

1. Replace DIMENSION(1) with DIMENSION(*)
2. Add the line:
!DEC$ ATTRIBUTES NO_ARG_CHECK :: A, B
3. Write an explicit interface for this routine (as above) and make it visible to the caller.

I don't think the /gen_interfaces copies the NO_ARG_CHECK directive, though perhaps it should.

Are the array contents always REAL? If they can be other types, you may be in for some surprises....

Message Edited by sblionel on 07-04-2005 04:17 PM

0 Kudos
wkramer
Beginner
321 Views
Hello Steve,
Thanks, your suggestion works, but I found out that the applicationcontains hundreds of calls to similar type of routines and what is even worse: reals, Integers and character(4) strings are mixed in common blocks.Common blocks are used as a contiguous memory block and arrays of reals, integers, character strings and even user defined types are filled from there using the type of routines as I described.
So I can just hope that I won't be in for the surprises you mentioned.
Regards,
Walter
0 Kudos
Steven_L_Intel1
Employee
321 Views
In that case, you definitely want to declare the arrays as INTEGER and not REAL. Performance will go up and you'll not get some values changed when they copy. (Anything that looks like a "Signaling NaN" will get changed to a "Quiet NaN".)
0 Kudos
Reply