I have an issue with the compilation of my code related with the resolution of generic interfaces. I cannot post my code due to its large extent, but I isolated the origin of the problem and I pasted a simple example below. I apologize for the length of the code. I signaled the most important lines with commented out labelled arrows:
MODULE su2_matrix IMPLICIT NONE PRIVATE PUBLIC :: su2, trace TYPE :: su2 COMPLEX :: a = CMPLX(1.,0.) ! <===  COMPLEX :: b = CMPLX(0.,0.) ! <===  END TYPE su2 INTERFACE trace MODULE PROCEDURE tr_su2 END INTERFACE trace CONTAINS PURE ELEMENTAL FUNCTION tr_su2(u) RESULT(z) TYPE(su2), INTENT(in) :: u COMPLEX :: z z = CMPLX(2.*REAL(u%a),0.) END FUNCTION tr_su2 END MODULE su2_matrix MODULE suN_matrix USE su2_matrix ! <===  IMPLICIT NONE PRIVATE PUBLIC :: suN, trace INTEGER, PARAMETER, PRIVATE :: N = 3 TYPE :: suN COMPLEX :: idx(N,N) END TYPE suN INTERFACE trace MODULE PROCEDURE tr_suN END INTERFACE trace CONTAINS PURE ELEMENTAL FUNCTION tr_suN(a) RESULT(z) TYPE(suN), INTENT(in) :: a COMPLEX :: z INTEGER :: i z = CMPLX(0.,0.) DO i=1,N z = z + a%idx(i,i) END DO END FUNCTION tr_suN END MODULE suN_matrix MODULE dof USE suN_matrix ! <===  USE su2_matrix ! <===  IMPLICIT NONE PRIVATE PUBLIC :: su2, suN, trace END MODULE dof MODULE lattfield USE dof ! <===  !USE suN_matrix ! <===  !USE su2_matrix ! <===  IMPLICIT NONE PRIVATE PUBLIC :: cpx_field, su2_field, suN_field, trace INTEGER, PARAMETER :: l(3) = [ 8,8,8 ] TYPE :: cpx_field COMPLEX :: site(l(1),l(2),l(3)) END TYPE cpx_field TYPE :: su2_field TYPE(su2) :: site(l(1),l(2),l(3)) END TYPE su2_field TYPE :: suN_field TYPE(suN) :: site(l(1),l(2),l(3)) END TYPE suN_field INTERFACE trace MODULE PROCEDURE tr_su2f MODULE PROCEDURE tr_suNf END INTERFACE trace CONTAINS PURE ELEMENTAL FUNCTION tr_su2f(a) RESULT(z) TYPE(su2_field), INTENT(in) :: a TYPE(cpx_field) :: z z%site = trace(a%site) END FUNCTION tr_su2f PURE ELEMENTAL FUNCTION tr_suNf(a) RESULT(z) TYPE(suN_field), INTENT(in) :: a TYPE(cpx_field) :: z z%site = trace(a%site) ! <===  END FUNCTION tr_suNf END MODULE lattfield
The code contains 4 modules, the 3rd of which, “MODULE dof”, is an umbrella module that I use for pure convenience. All it does is to collect the public objects in the 1st and 2nd modules and make them public again, so I can use them in “MODULE lattfield”.
In principle, there is nothing wrong in doing this that I know of. In fact, it compiles and behaves perfectly well with the Intel and GNU compilers. However, when I compile it with pgf90 (PGI Workstation v12.5 for Linux) it issues the following error, associated with line :
PGF90-S-0155-Could not resolve generic procedure trace (test.f90: 119)
0 inform, 0 warnings, 1 severes, 0 fatal for tr_sunf
The error message vanishes and the compilation is successful in any of the following situations:
- if I swap the lines labelled by  and  like this:
USE su2_matrix ! <===  USE suN_matrix ! <=== 
if I simply avoid calling “USE dof” in the last module, line , and call the 1st and 2nd modules directly, lines  and .
if I delete the line  (but it should be there for future use).
and also, curiously, if I avoid instantiating the components of the derived type “su2” with default values, in lines  and  (This one is puzzling).
Thus the question is: Why is this so? Why can’t I use an umbrella module in this way? Why is the order of the lines  and  important? I don’t remember the order being relevant in the Fortran standard. Also, the derived types “su2” and “suN” are very different and there is no apparent ambiguity in the generic interface for “trace”.
Update: I made corrections to the code above.