0

I have this old code

module foo
    interface
      subroutine bar(A)
        !dir$ ignore_tkr(trd) A
        DOUBLE COMPLEX, DIMENSION(*) :: A
      end subroutine
    end interface
end module foo

This is compiled fine by nvfortan and gfortran compilers. Yet, LLVM Flang cannot even parse it, because it doesn't know what d in the ignore_tkr means.

I assume, it means "ignore dimension". But I couldn't google anything up about it.

Could someone please send something to read about it and/or explain in details this thing?

2 Answers2

1

Compiler directives are compiler specific. Note that for a standard Fortran compiler without any extensions they are just comments and will be ignored. The fact that it compiles with many compilers may just mean that those compilers ignore that directive altogether.

Some compilers will understand

!DIR$

other will understand

!DEC$

or

!GCC$

Gfortran, for example. has no obligation to understand directives specific to other compilers and will just ignore the directive you have shown.


For example, gfortran understand these directives https://gcc.gnu.org/onlinedocs/gfortran/GNU-Fortran-Compiler-Directives.html

For directives supported by Flang, consult the documentation https://releases.llvm.org/12.0.0/tools/flang/docs/Directives.html


Note that !dir$ ignore_tkr (tkr) var-list is supported by Flang and will omit checking the type, kind and/or rank of arguments passed to the procedure.

You specify the desired checks in the (tkr). You use all of t, k, and r if you want to disable all three. The letter d is not among the possible letters to use and hence is erroneous. If you want to disable the checks for the number of dimensions of the array, use r for rank.

Rank is the correct word that is used for the number of dimensions of an array in the Fortran standard.

The same syntax holds for nvfortran, see section 4.4 in https://docs.nvidia.com/hpc-sdk/archive/20.7/compilers/pdf/hpc207ref.pdf The only admissible parameters are t, k or r. No, d is not allowed. It does not mean anything in this context for these compilers.

The programmer may have used d instead of r inadvertently and the nvfortran compiler may ignore that or may even silently convert that to d. Such behaviour would only be specific to that compiler. I would just convert the d into r if it makes sense in that context.

4.4.1. IGNORE_TKR Directive Syntax
The syntax for the IGNORE_TKR directive is this:
!DIR$ IGNORE_TKR [ [(<letter>) <dummy_arg>] ... ]
<letter> is one or any combination of the following:
T – type
K – kind
R – rank
For example, KR indicates to ignore both kind and rank rules and TKR indicates to ignore the type, kind, and rank arguments

1

In nvfortran, the d specifier to the ignore_tkr directive tells the compiler to ignore the presence or absence of the device attribute in argument matching when compiling CUDA Fortran codes.

guest
  • 11
  • 1
  • Interesting possibility, but the code is probably ordinary Fortran, not CUDA Fortran. Else the other compilers would not be able to compile it. The Nvidia manual I linked in my answer does not mention this. Do you have a link describing this? – Vladimir F Героям слава Sep 19 '22 at 20:28
  • [link](https://docs.nvidia.com/hpc-sdk/compilers/fortran-cuda-interfaces/#iface-howto-doit) has: A final aid, specific to NVIDIA, worth mentioning here is ignore_tkr (d), which ignores the device attribute of an actual argument during interface matching. – guest Sep 19 '22 at 20:36
  • Thanks. This is not mentioned in the pdf manual "NVIDIA HPC COMPILERS REFERENCE GUIDE" – Vladimir F Героям слава Sep 19 '22 at 20:40