Issue |
144530
|
Summary |
[flang] generation of invalid module file
|
Labels |
|
Assignees |
|
Reporter |
MarDiehl
|
I’m trying to compile DAMASK with clang+flang but encounter an issue related to the generation of module files for submodules. The code has nested submodules. That works in general, i.e. I could not reproduce the error with a MWE.
The error message explains the situation nicely.
```
error: Semantic errors in /tmp/DAMASK/src/phase_mechanical_plastic.f90
./phase-mechanical.mod:3:5: error: Module 'phase' cannot USE itself from its own submodule 'mechanical'
use phase,only:ph
^^^^^
./phase-mechanical.mod:3:16: error: 'ph' not found in module 'phase'
use phase,only:ph
^^
./phase-mechanical.mod:4:1: error: PRIVATE statement may only appear in the specification part of a module
private::ph
```
the content of the module file is given below.
Since I cannot build an MWE, I've creates a [script](https://github.com/user-attachments/files/20776631/run_sh.txt) that triggers the issue. Besides flang, clang, and clang++ it needs build tools like CMake and make. It installs PETSc with HDF5 and then a minimal version of DAMASK.
```
#! /usr/bin/env bash
cd $(mktemp -d)
git clone g...@gitlab.com:petsc/petsc.git
cd petsc
git checkout 8c8ad5034fba97ace90de833fd30fd3e0748fc58
export PETSC_DIR=${PWD}
export PETSC_ARCH=flang_test
./configure \
--with-cc=clang --with-cxx=clang++ --with-fc=flang \
-FOPTFLAGS='-O0 -g' -COPTFLAGS='-O0 -g' -CXXOPTFLAGS='-O0 -g' \
--with-fortran-bindings=1 --with-mpi-f90module-visibility=1 --with-shared-libraries=1 \
--download-mpich=1 \
--download-hdf5=1 --with-hdf5-fortran-bindings=1 --with-hdf5-cxx-bindings=1
make all
cd ..
wget https://martin-diehl.net/download/DAMASK.tar.xz
tar -xf DAMASK.tar.xz
cd DAMASK
make test OPENMP=OFF
```
[](url)
```
!mod$ v1 sum:a3d8a5a7569feda3
submodule(phase) mechanical
use phase,only:ph
private::ph
type(ttensorcontainer),allocatable::phase_mechanical_fe(:)
type(ttensorcontainer),allocatable::phase_mechanical_fi(:)
type(ttensorcontainer),allocatable::phase_mechanical_fp(:)
type(ttensorcontainer),allocatable::phase_mechanical_f(:)
type(ttensorcontainer),allocatable::phase_mechanical_li(:)
type(ttensorcontainer),allocatable::phase_mechanical_lp(:)
type(ttensorcontainer),allocatable::phase_mechanical_s(:)
type(ttensorcontainer),allocatable::phase_mechanical_p(:)
type(ttensorcontainer),allocatable::phase_mechanical_fi0(:)
type(ttensorcontainer),allocatable::phase_mechanical_fp0(:)
type(ttensorcontainer),allocatable::phase_mechanical_f0(:)
type(ttensorcontainer),allocatable::phase_mechanical_li0(:)
type(ttensorcontainer),allocatable::phase_mechanical_lp0(:)
type(ttensorcontainer),allocatable::phase_mechanical_s0(:)
interface
module subroutine eigen_init(phases)
type(tdict),pointer::phases
end
end interface
interface
module subroutine elastic_init(phases)
type(tdict),pointer::phases
end
end interface
interface
module subroutine plastic_init()
end
end interface
interface
module subroutine phase_hooke_sanditstangents(s,ds_dfe,ds_dfi,fe,fi,ph,en)
real(8),intent(out)::s(1_8:3_8,1_8:3_8)
real(8),intent(out)::ds_dfe(1_8:3_8,1_8:3_8,1_8:3_8,1_8:3_8)
real(8),intent(out)::ds_dfi(1_8:3_8,1_8:3_8,1_8:3_8,1_8:3_8)
real(8),intent(in)::fe(1_8:3_8,1_8:3_8)
real(8),intent(in)::fi(1_8:3_8,1_8:3_8)
integer(4),intent(in)::ph
integer(4),intent(in)::en
end
end interface
interface
module subroutine plastic_isotropic_lianditstangent(li,dli_dmi,mi,ph,en)
real(8),intent(out)::li(1_8:3_8,1_8:3_8)
real(8),intent(out)::dli_dmi(1_8:3_8,1_8:3_8,1_8:3_8,1_8:3_8)
real(8),intent(in)::mi(1_8:3_8,1_8:3_8)
integer(4),intent(in)::ph
integer(4),intent(in)::en
end
end interface
interface
module function plastic_dotstate(subdt,ph,en) result(dotstate)
real(8),intent(in)::subdt
integer(4),intent(in)::ph
integer(4),intent(in)::en
real(8)::dotstate(1_8:int(plasticstate(int(ph,kind=8))%tstate%sizedotstate,kind=8))
end
end interface
interface
module function plastic_deltastate(ph,en) result(status)
integer(4),intent(in)::ph
integer(4),intent(in)::en
integer(4)::status
end
end interface
interface
module subroutine phase_lianditstangents(li,dli_ds,dli_dfi,s,fi,ph,en)
real(8),intent(out)::li(1_8:3_8,1_8:3_8)
real(8),intent(out)::dli_ds(1_8:3_8,1_8:3_8,1_8:3_8,1_8:3_8)
real(8),intent(out)::dli_dfi(1_8:3_8,1_8:3_8,1_8:3_8,1_8:3_8)
real(8),intent(in)::s(1_8:3_8,1_8:3_8)
real(8),intent(in)::fi(1_8:3_8,1_8:3_8)
integer(4),intent(in)::ph
integer(4),intent(in)::en
end
end interface
interface
module subroutine plastic_lpanditstangents(lp,dlp_ds,dlp_dfi,s,fi,ph,en)
real(8),intent(out)::lp(1_8:3_8,1_8:3_8)
real(8),intent(out)::dlp_ds(1_8:3_8,1_8:3_8,1_8:3_8,1_8:3_8)
real(8),intent(out)::dlp_dfi(1_8:3_8,1_8:3_8,1_8:3_8,1_8:3_8)
real(8),intent(in)::s(1_8:3_8,1_8:3_8)
real(8),intent(in)::fi(1_8:3_8,1_8:3_8)
integer(4),intent(in)::ph
integer(4),intent(in)::en
end
end interface
interface
module subroutine plastic_isotropic_result(ph,group)
integer(4),intent(in)::ph
character(*,1),intent(in)::group
end
end interface
interface
module subroutine plastic_phenopowerlaw_result(ph,group)
integer(4),intent(in)::ph
character(*,1),intent(in)::group
end
end interface
interface
module subroutine plastic_kinehardening_result(ph,group)
integer(4),intent(in)::ph
character(*,1),intent(in)::group
end
end interface
interface
module subroutine plastic_dislotwin_result(ph,group)
integer(4),intent(in)::ph
character(*,1),intent(in)::group
end
end interface
interface
module subroutine plastic_dislotungsten_result(ph,group)
integer(4),intent(in)::ph
character(*,1),intent(in)::group
end
end interface
interface
module subroutine plastic_nonlocal_result(ph,group)
integer(4),intent(in)::ph
character(*,1),intent(in)::group
end
end interface
interface
module function plastic_dislotwin_homogenizedc(ph,en) result(homogenizedc)
integer(4),intent(in)::ph
integer(4),intent(in)::en
real(8)::homogenizedc(1_8:6_8,1_8:6_8)
end
end interface
interface
module pure function elastic_c66(ph,en) result(c66)
integer(4),intent(in)::ph
integer(4),intent(in)::en
real(8)::c66(1_8:6_8,1_8:6_8)
end
end interface
interface
module pure function elastic_mu(ph,en,isotropic_bound) result(mu)
integer(4),intent(in)::ph
integer(4),intent(in)::en
character(*,1),intent(in)::isotropic_bound
real(8)::mu
end
end interface
interface
module pure function elastic_nu(ph,en,isotropic_bound) result(nu)
integer(4),intent(in)::ph
integer(4),intent(in)::en
character(*,1),intent(in)::isotropic_bound
real(8)::nu
end
end interface
type::toutput
character(256_4,1),allocatable::label(:)
end type
type(toutput),allocatable::output_mechanical(:)
procedure(integratestatefpi),pointer::integratestate
contains
module subroutine mechanical_init(phases,num_mech)
type(tdict),pointer::phases
type(tdict),pointer::num_mech
end
module subroutine mechanical_result(group,ph)
character(*,1),intent(in)::group
integer(4),intent(in)::ph
end
function integratestress(f,fp0,fi0,delta_t,ph,en) result(status)
real(8),intent(in)::f(1_8:3_8,1_8:3_8)
real(8),intent(in)::fp0(1_8:3_8,1_8:3_8)
real(8),intent(in)::fi0(1_8:3_8,1_8:3_8)
real(8),intent(in)::delta_t
integer(4),intent(in)::ph
integer(4),intent(in)::en
integer(4)::status
end
function integratestatefpi(f_0,f,fp0,fi0,state0,delta_t,ph,en) result(status)
real(8),intent(in)::f_0(1_8:3_8,1_8:3_8)
real(8),intent(in)::f(1_8:3_8,1_8:3_8)
real(8),intent(in)::fp0(1_8:3_8,1_8:3_8)
real(8),intent(in)::fi0(1_8:3_8,1_8:3_8)
real(8),intent(in)::state0(:)
real(8),intent(in)::delta_t
integer(4),intent(in)::ph
integer(4),intent(in)::en
integer(4)::status
end
function integratestateeuler(f_0,f,fp0,fi0,state0,delta_t,ph,en) result(status)
real(8),intent(in)::f_0(1_8:3_8,1_8:3_8)
real(8),intent(in)::f(1_8:3_8,1_8:3_8)
real(8),intent(in)::fp0(1_8:3_8,1_8:3_8)
real(8),intent(in)::fi0(1_8:3_8,1_8:3_8)
real(8),intent(in)::state0(:)
real(8),intent(in)::delta_t
integer(4),intent(in)::ph
integer(4),intent(in)::en
integer(4)::status
end
function integratestateeuleradaptive(f_0,f,fp0,fi0,state0,delta_t,ph,en) result(status)
real(8),intent(in)::f_0(1_8:3_8,1_8:3_8)
real(8),intent(in)::f(1_8:3_8,1_8:3_8)
real(8),intent(in)::fp0(1_8:3_8,1_8:3_8)
real(8),intent(in)::fi0(1_8:3_8,1_8:3_8)
real(8),intent(in)::state0(:)
real(8),intent(in)::delta_t
integer(4),intent(in)::ph
integer(4),intent(in)::en
integer(4)::status
end
function integratestaterk4(f_0,f,fp0,fi0,state0,delta_t,ph,en) result(status)
real(8),intent(in)::f_0(1_8:3_8,1_8:3_8)
real(8),intent(in)::f(1_8:3_8,1_8:3_8)
real(8),intent(in)::fp0(1_8:3_8,1_8:3_8)
real(8),intent(in)::fi0(1_8:3_8,1_8:3_8)
real(8),intent(in)::state0(:)
real(8),intent(in)::delta_t
integer(4),intent(in)::ph
integer(4),intent(in)::en
integer(4)::status
end
function integratestaterkck45(f_0,f,fp0,fi0,state0,delta_t,ph,en) result(status)
real(8),intent(in)::f_0(1_8:3_8,1_8:3_8)
real(8),intent(in)::f(1_8:3_8,1_8:3_8)
real(8),intent(in)::fp0(1_8:3_8,1_8:3_8)
real(8),intent(in)::fi0(1_8:3_8,1_8:3_8)
real(8),intent(in)::state0(:)
real(8),intent(in)::delta_t
integer(4),intent(in)::ph
integer(4),intent(in)::en
integer(4)::status
end
function integratestaterk(f_0,f,fp0,fi0,state0,delta_t,ph,en,a,b,c,db) result(status)
real(8),intent(in)::f_0(1_8:3_8,1_8:3_8)
real(8),intent(in)::f(1_8:3_8,1_8:3_8)
real(8),intent(in)::fp0(1_8:3_8,1_8:3_8)
real(8),intent(in)::fi0(1_8:3_8,1_8:3_8)
real(8),intent(in)::state0(:)
real(8),intent(in)::delta_t
integer(4),intent(in)::ph
integer(4),intent(in)::en
real(8),intent(in)::a(:,:)
real(8),intent(in)::b(:)
real(8),intent(in)::c(:)
real(8),intent(in),optional::db(:)
integer(4)::status
end
subroutine results(group,ph)
character(*,1),intent(in)::group
integer(4),intent(in)::ph
end
module subroutine mechanical_forward()
end
module function phase_mechanical_constitutive(delta_t,co,ce) result(status)
real(8),intent(in)::delta_t
integer(4),intent(in)::co
integer(4),intent(in)::ce
integer(4)::status
end
module subroutine mechanical_restore(ce,includel)
integer(4),intent(in)::ce
logical(4),intent(in)::includel
end
module function phase_mechanical_dpdf(delta_t,co,ce) result(dpdf)
real(8),intent(in)::delta_t
integer(4),intent(in)::co
integer(4),intent(in)::ce
real(8)::dpdf(1_8:3_8,1_8:3_8,1_8:3_8,1_8:3_8)
end
module subroutine mechanical_restartwrite(grouphandle,ph)
integer(8),intent(in)::grouphandle
integer(4),intent(in)::ph
end
module subroutine mechanical_restartread(grouphandle,ph)
integer(8),intent(in)::grouphandle
integer(4),intent(in)::ph
end
module function mechanical_s(ph,en) result(s)
integer(4),intent(in)::ph
integer(4),intent(in)::en
real(8)::s(1_8:3_8,1_8:3_8)
end
module function mechanical_l_p(ph,en) result(l_p)
integer(4),intent(in)::ph
integer(4),intent(in)::en
real(8)::l_p(1_8:3_8,1_8:3_8)
end
module function mechanical_f_e(ph,en) result(f_e)
integer(4),intent(in)::ph
integer(4),intent(in)::en
real(8)::f_e(1_8:3_8,1_8:3_8)
end
module function mechanical_f_i(ph,en) result(f_i)
integer(4),intent(in)::ph
integer(4),intent(in)::en
real(8)::f_i(1_8:3_8,1_8:3_8)
end
module function phase_p(co,ce) result(p)
integer(4),intent(in)::co
integer(4),intent(in)::ce
real(8)::p(1_8:3_8,1_8:3_8)
end
module function phase_f(co,ce) result(f)
integer(4),intent(in)::co
integer(4),intent(in)::ce
real(8)::f(1_8:3_8,1_8:3_8)
end
module subroutine phase_set_f(f,co,ce)
real(8),intent(in)::f(1_8:3_8,1_8:3_8)
integer(4),intent(in)::co
integer(4),intent(in)::ce
end
end
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs