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

  private

  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


contains

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

    select type (input)

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

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

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

    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.

-Mat

Hi BalintAradi,

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

-Mat