Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29575 Discussions

An internal bug in IFX when using submodule ?

HyLiu
Beginner
65 Views

I try to compile a module where a class is defined as 

  type, abstract, extends(CSteadySol)::CUnsteadySol
  contains
  procedure::init_solution=>init_solution_Unsteady
  procedure::solve=>solve_Unsteady
  procedure::UpdateTime=>UpdateTime_Unsteady

  end type

all procedures are module procedures and a submodule is used to define the body of there subroutines. But a error returned, as following in the submodule file 

D:\FEA\BFREM1_6\FEA\src\temporal_solver\CTemporalSol_smod.f90(814): error #6406: Conflicting attributes or multiple declaration of name.   [CUNSTEADYSOL_INIT]
D:\FEA\BFREM1_6\FEA\src\temporal_solver\CTemporalSol_smod.f90(859): error #6115: A separate interface body must have been declared in the program unit or an ancestor of the program unit for the separate module procedure.   [INIT_SOLUTION_UNSTEADY]
xfortcom: Fatal: There has been an internal compiler error (C0000005).
0 Kudos
5 Replies
MarcGrodent
New Contributor II
42 Views

The error suggests an interface block is missing in your module. The procedures that are implemented in a submodule must be declared in the module by means of an interface. For instance:

interface
  module subroutine init_solution_Unsteady
    ...
  end subroutine init_solution_Unsteady

  ![same for the other procedures implemented in the submodule]
end interface

 

0 Kudos
HyLiu
Beginner
33 Views

 

 I use the interface like this, and it works when i use ifort compiler



  interface

 

 
  module subroutine init_solution_Unsteady(this, eqsys_, cfg)
  implicit none
  class(CUnsteadySol), target::this
  class(*), target::eqsys_
  type(json_file)::cfg

 

  end subroutine
  module subroutine solve_Unsteady(this, eqsys_, cfg)
  implicit none
  class(CUnsteadySol), target::this
  class(*), target::eqsys_
  type(json_file)::cfg

 

  !class(CEquation_sys)::eq_sys!equation system

 

  end subroutine

 

  end interface

 

 
0 Kudos
HyLiu
Beginner
27 Views

But I found that if I declare init_solution_Unsteady as a private function, it works.

0 Kudos
MarcGrodent
New Contributor II
25 Views

Could you please show the exact code of the parent module containing the type definition and the interface block as well as the corresponding submodule (not the whole implementation, just the lines where the submodule and your subroutines are declared)?

0 Kudos
HyLiu
Beginner
22 Views

This part is in the mod file:

 

  module CUnSteadySol_mod
 
  implicit none

 

  public::CUnsteadySol, CUnsteadySol_
  !public::init_solution_Unsteady ,UpdateTime_Unsteady
  private
  type, abstract, extends(CSteadySol)::CUnsteadySol
 

  contains
  procedure::init_solution=>init_solution_Unsteady
  procedure::solve=>solve_Unsteady
  procedure::UpdateTime=>UpdateTime_Unsteady

  end type


  interface CUnsteadySol_
  module procedure CUnsteadySol_init
  end interface

  interface

 
  module subroutine CUnsteadySol_init(this0, eqsys_, cfg)
  implicit none
  class(CTemporalSol)::this0
  class(*), target::eqsys_
  type(json_file)::cfg
  !procedure,target::space_integ,SetAux

  end subroutine

 
  module subroutine init_solution_Unsteady(this, eqsys_, cfg)
  implicit none
  class(CUnsteadySol), target::this
  class(*), target::eqsys_
  type(json_file)::cfg

  end subroutine

 
  module subroutine solve_Unsteady(this, eqsys_, cfg)
  implicit none
  class(CUnsteadySol), target::this
  class(*), target::eqsys_
  type(json_file)::cfg

  !class(CEquation_sys)::eq_sys!equation system

  end subroutine
 
  module subroutine UpdateTime_Unsteady(this, eqsys_, cfg)
  implicit none
  class(CUnsteadySol), target::this
  class(*), target::eqsys_
  type(json_file)::cfg

  !class(CEquation_sys)::eq_sys!equation system

  end subroutine

  end interface

  end module



------------------------------------------------------------------------------
this part is in the submodule file:
 
 
submodule(CUnSteadySol_mod) CUnSteadySol_smod

  contains

 
  module subroutine CUnsteadySol_init(this0, eqsys_, cfg)
  use Cstudy_mod
  use stdlib_strings,only: to_string
  implicit none
  class(CTemporalSol)::this0
  class(*), target::eqsys_
  type(json_file)::cfg
 
  end subroutine

 
  module subroutine init_solution_Unsteady(this, eqsys_, cfg)
  use Cstudy_mod
  implicit none
  class(CUnsteadySol), target::this
  class(*), target::eqsys_
  type(json_file)::cfg

 !...

  end subroutine

 
  module subroutine solve_Unsteady(this, eqsys_, cfg)
  use stdlib_strings
  use KSP_solver_mod
  use Cstudy_mod
  implicit none
  class(CUnsteadySol), target::this
  class(*), target::eqsys_
  type(json_file)::cfg
!....

  end subroutine

 
  module subroutine UpdateTime_Unsteady(this, eqsys_, cfg)
  use Cstudy_mod
  implicit none
  class(CUnsteadySol), target::this
  class(*), target::eqsys_
  type(json_file)::cfg
!...
  end subroutine

  end submodule
0 Kudos
Reply