Fortran95模块函数调用缺失符号:编译警告与运行时错误求助
This is a classic name collision issue in Fortran modules—let's break down what's happening and fix it:
Root Cause
In your dsftdw subroutine, you’ve declared a local logical variable named dless. This overrides the private module function dless you intend to call. The compiler prioritizes the local variable over the module function, so it never links to the actual function implementation—hence the missing symbol warning and runtime error.
Step-by-Step Solution
Remove the conflicting local variable declaration
In yourdsftdwsubroutine, delete this line entirely:logical :: dlessSince
dlessis a private function in the same module, the subroutine already has access to it without needing a local declaration. The local variable was masking the function entirely.Clean up minor syntax (optional but recommended)
In yourdlessfunction, there’s a missing colon in an integer declaration:integer(kind =3) k ! Missing ::Update it to:
integer(kind=3) :: kMost compilers will tolerate the original syntax, but fixing this avoids potential parsing quirks.
Recompile and test
Rebuild your code in PLATO—this should eliminate the missing symbol warning and runtime error, as the subroutine will now correctly reference the module’sdlessfunction.
Why This Works
Fortran follows scope rules where local declarations take priority over module-level symbols. By removing the local dless variable, the subroutine falls back to using the private module function defined in the contains section of your module.
内容的提问来源于stack exchange,提问作者ALIN

