TLUSTY/new/README.md

171 lines
4.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# TLUSTY 和 SYNSPEC 模块化版本
本目录包含 TLUSTY208 和 SYNSPEC54 的模块化 Fortran 版本。
## 目录结构
```
new/
├── tlusty/ # TLUSTY 源代码
│ ├── main/ # 主程序
│ │ └── tlusty_main.f90
│ ├── modules/ # Fortran 模块
│ │ ├── impli_module.f90 (类型声明)
│ │ ├── basics_module.f90 (基本参数和常量)
│ │ ├── iterat_module.f90 (迭代控制)
│ │ ├── alipar_module.f90 (ALI 方法参数)
│ │ ├── atomic_module.f90 (原子数据)
│ │ ├── modelq_module.f90 (模型物理量)
│ │ ├── odfpar_module.f90 (ODF 参数)
│ │ └── array1_module.f90 (工作数组)
│ ├── subroutines/ # 子程序模块
│ └── CMakeLists.txt
├── synspec/ # SYNSPEC 源代码
│ ├── main/ # 主程序
│ │ └── synspec_main.f90
│ ├── modules/ # Fortran 模块
│ │ ├── params_module.f90 (参数定义)
│ │ ├── lindat_module.f90 (谱线数据)
│ │ ├── modelp_module.f90 (模型参数)
│ │ ├── synthp_module.f90 (合成光谱参数)
│ │ ├── wincom_module.f90 (窗口通用变量)
│ │ └── optpar_module.f90 (不透明度参数)
│ ├── subroutines/ # 子程序模块
│ ├── utils/ # 工具程序
│ │ ├── rotin.f90
│ │ └── ngrid.f90
│ └── CMakeLists.txt
├── CMakeLists.txt # 顶层 CMake 配置
└── build.sh # 构建脚本
```
## 编译说明
### 前置要求
- CMake >= 3.15
- GFortran (支持 Fortran 90+)
### 快速开始
```bash
# 进入新目录
cd new
# 使用默认设置编译Release 模式)
./build.sh
# Debug 模式编译
./build.sh --debug
# 清理并重新编译
./build.sh --clean
# 指定安装目录
./build.sh --install /opt/tlusty
```
### 手动编译
```bash
# 创建构建目录
mkdir build && cd build
# CMake 配置
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=../install \
-DBUILD_TLUSTY=ON \
-DBUILD_SYNSPEC=ON
# 编译
make -j$(nproc)
# 安装
make install
```
## 主要变化
### 从 INCLUDE 到 MODULE
原始代码使用 Fortran 77 风格的 INCLUDE 文件:
```fortran
PROGRAM TLUSTY
INCLUDE 'IMPLIC.FOR'
INCLUDE 'BASICS.FOR'
```
新版本使用现代 Fortran 模块:
```fortran
PROGRAM TLUSTY
USE impli_module
USE basics_module
```
### 模块依赖关系
**TLUSTY 模块依赖:**
```
impli_module (无依赖)
basics_module (依赖 impli_module)
iterat_module, alipar_module, atomic_module, odfpar_module
modelq_module (依赖 basics + atomic)
array1_module (依赖所有上述模块)
```
**SYNSPEC 模块依赖:**
```
params_module (无依赖)
lindat_module, modelp_module, synthp_module, wincom_module, optpar_module
```
## 与原始版本的兼容性
### 保持兼容
- 所有公共变量块 (COMMON blocks) 已转换为模块变量
- 数组维度和参数保持不变
- 物理常数和数学常数保持不变
- 子程序接口保持不变
### 需要更新的内容
原始版本中的大型子程序(如 START、RESOLV、SOLVE 等)需要从 `tlusty208.f``synspec54.f` 中提取并放到 `subroutines/` 目录下。
## 下一步工作
1. **子程序提取**:将原始单文件中的子程序拆分到独立文件
2. **数值验证**:对比新旧版本的输出,确保数值一致性
3. **测试集成**:将现有测试用例集成到 CTest
4. **文档完善**:补充详细的用户指南和开发者文档
## 已知限制
- 当前版本仅完成了模块框架,完整的子程序实现需要进一步工作
- 部分大型数组可能需要调整以适应不同的内存配置
- 某些 Fortran 77 特性(如 EQUIVALENCE 语句)需要特殊处理
## 参考资料
- 原始 TLUSTY 文档:`../tlusty/README.md`
- 原始 SYNSPEC 文档:`../synspec/README_functions.md`
- 安装与使用指南:`../README.md`
## 许可证
请遵循原始 TLUSTY/SYNSPEC 软件包的许可条款。
## 联系方式
如有问题或建议,请通过原项目渠道联系。