CP2K 代码在编译时出现以下错误,提示缺少编译器版本定义,需要在代码中添加相应的编译器版本信息。

/public1/home/scb6511/software-scb6511/1/cp2k-2023.1/src/start/cp2k.F(61): error #6580: Name in only-list does not exist.   [COMPILER_OPTIONS]
   USE iso_fortran_env,                 ONLY: compiler_options,&
----------------------------------------------^
/public1/home/scb6511/software-scb6511/1/cp2k-2023.1/src/start/cp2k.F(62): error #6580: Name in only-list does not exist.   [COMPILER_VERSION]
                                              compiler_version
----------------------------------------------^
/public1/home/scb6511/software-scb6511/1/cp2k-2023.1/src/start/cp2k.F(331): error #6404: This name does not have a type, and must have an explicit type.   [COMPILER_OPTIONS]
               compiler_options_string = compiler_options()
-----------------------------------------^
/public1/home/scb6511/software-scb6511/1/cp2k-2023.1/src/start/cp2k.F(331): error #6054: A CHARACTER data type is required in this context.   [COMPILER_OPTIONS]
               compiler_options_string = compiler_options()
-----------------------------------------^
/public1/home/scb6511/software-scb6511/1/cp2k-2023.1/src/start/cp2k.F(332): error #6404: This name does not have a type, and must have an explicit type.   [COMPILER_VERSION]
               WRITE (output_unit, '(T2,A,A)') 'compiler: ', compiler_version()
-------------------------------------------------------------^
compilation aborted for cp2k.F90 (code 1)

解决方法:

  • **添加编译器版本定义:**在代码中添加一个明确的编译器版本定义,例如:
INTEGER :: compiler_version = 2023
  • 更新代码: 确保代码中使用 compiler_version 变量的地方与定义一致。

  • 检查编译器选项: 查看编译器选项,确保 compiler_optionscompiler_version 变量已正确设置。

示例:

PROGRAM main
  USE iso_fortran_env, ONLY: compiler_options, compiler_version
  INTEGER :: compiler_version = 2023
  CHARACTER(LEN=100) :: compiler_options_string

  compiler_options_string = compiler_options()
  WRITE (6, '(T2,A,A)') 'compiler: ', compiler_version()

END PROGRAM

通过添加编译器版本定义和更新代码,应该能够解决这些错误并成功编译 CP2K 代码。

CP2K 编译错误: #6580 和 #6404 - 编译器版本问题

原文地址: http://www.cveoy.top/t/topic/mOLh 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录