Nvfortran: Unable to cope with select type construct containing block statements

The following valid Fortran 2003 code is not processed by the nvfortran compiler (nvfortran 22.1-0 64-bit target on x86-64 Linux -tp skylake-avx512).

module dftbp_geoopt_package
  implicit none


  type, abstract :: TOptimizerInput
  end type TOptimizerInput

  type, extends(TOptimizerInput) :: TFireInput
  end type TFireInput

  type, extends(TOptimizerInput) :: TLbfgsInput
  end type TLbfgsInput

  type, extends(TOptimizerInput) :: TRationalFuncInput
  end type TRationalFuncInput


  subroutine createOptimizer(input)
    class(TOptimizerInput), intent(inout) :: input

    select type (input)

    type is (TLbfgsInput)
        print *, "TLbfgsInput"
      end block

    type is (TRationalFuncInput)
        print *, "TRationalFuncInput"
      end block

    type is (TFireInput)
        print *, "TFireInput"
      end block

    end select

  end subroutine createOptimizer

end module dftbp_geoopt_package

Compiling the code results in

nvfortran -c ~/package.f90 
NVFORTRAN-S-0044-Multiple declaration for symbol is (/home/aradi/package.f90: 38)
NVFORTRAN-S-0117-Statement not allowed within a derived type definition (/home/aradi/package.f90: 38)
  0 inform,   0 warnings,   2 severes, 0 fatal for createoptimizer

Interestingly, if the block statements are removed, the code is at least compiled…

Thanks BalintAradi. I’ve filed this as TPR #31206 and sent it to engineering for investigation.


Hi BalintAradi,

Engineering let me know that they have fixed this issue in our 22.3 release.