Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Writing internel Variables to file -> Warning: An Array was temporarry created

$
0
0

I am dealing with Fortran 77 legacy code and have therefore written a debugging routine with which I can save the timehistory of arbitrary internal Variables to a file:

      module M_checkup

       ...

      contains

      ...

      ! write new variable to output array
      subroutine writecheck(value,title,line,anzahl_o,mode)

      implicit none

      real,intent(in) :: value(:)
      character(*),dimension(*),intent(in) :: title
      integer,intent(in) ::line
      integer,optional,intent(in) :: anzahl_o
      character(*),optional :: mode

      ...

      end subroutine writecheck

      end module M_checkup

This routine matches the string(s) of "title" to an already existing title-list and expands the title-list if "title" is not already in there. The position of "title" in the title-list is extracted and "value" is written to an existing value-list at the corresponding position and "line". At the end of the program these title- and value-lists are written to a text file for further analysis via matlab, etc. Because sometimes you want to save whole arrays or multiple values at once the routine has to cope with single values as well as contiguous and non-contigous arrays, which is the reason for using assumed-size arrays.

Exemplary usage in Code:

       subroutine step

       use M_checkup,only:writecheck

       implicit none

       ...

       call writecheck((FORCER(1:6)),['S4_FX_ROT',
     F                                   'S4_FY_ROT',
     F                                   'S4_FZ_ROT',
     F                                   'S4_MX_ROT',
     F                                   'S4_MY_ROT',
     F                                   'S4_MZ_ROT'],
     F                                   JNBL,6)
      
        call writecheck([SPCKDATA%FSTEU(IB),(ZMR(19,JNBL))],
     F                      ['SPCK_FSTEU','S4_FSTEU__'],JNBL,2)

        call writecheck((/S4DATA%HUBFORCNONROT%FX/),'SPCK_FX_NR',JNBL,1)

       ....

       end subroutine step

As you can see, in the first example, the arguments are part of an existing array and therefore are contiguously represented in the memory. In the second example the arguments passed to the subroutine are from different variables and therefore are not-contiguously. As I understand it, example two is the reason the compiler throws the following warnings:

forrtl: warning (402): fort: (1): In call to WRITECHECK, an array temporary was created for argument #2

forrtl: warning (402): fort: (1): In call to I/O Write routine, an array temporary was created for argument #1

In my opinion the compiler seems to be warning me because the "title" and "value" arrays get copied because they are non-contiguous.

Because this routine gets called a lot of times the printout slows down the program quite a lot. Therefore I'd like to get rid of the warning without disabling the corresponding compiler option. I suspect, that I'm using assumed-size arrays wrong, because to I think I don't understand/ missunderstand the whole concept.

The responsible warnings are only enabled in the debug build-type and the corresponding routine is only used for debugging. Because iot that there is no problem with the implied performance loss due to the array copying. Therefore I have disabled the corresponding warning (/check:noarg_temp_created) for the moment. My question is:

 

Is there a way to improve this debugging routine so that the warning would not show?


Viewing all articles
Browse latest Browse all 3270

Trending Articles