geometry_mod.F90
源码路径:LMDZ.COMMON-6.3\LMDZ.COMMON\libf\phy_common\geometry_mod.F90 Mars 运行参与度:条件经过。Mars 3D 物理初始化通过 inigeomphy_mod 写入本模块;Mars 1D/testphys1d 也直接初始化本模块;Mars physics、diagnostics 和 XIOS 输出读取其中的经纬度、面积、边界和全局索引。
文件职责
geometry_mod 保存当前 MPI rank / OpenMP 线程局部物理列的几何状态。它不是全局 regular lon-lat 网格表,也不做插值;它只接收上游已经切分好的 klon 个物理列,把经纬度、cell 边界、面积、可选全局 cell index 和可选水平分辨率缓存为 SAVE, ALLOCATABLE, THREADPRIVATE 数组。
本模块还单独保存 cell_area_for_lonlat_outputs。该数组服务 lon-lat 输出,极点面积按动力 lon-lat 网格的重复极点处理,不能和 physics cell area cell_area 混用。
模块状态
| 符号 | 维度 | 单位/含义 | 初始化 |
|---|---|---|---|
longitude(:) |
klon |
cell center longitude, rad | init_geometry |
latitude(:) |
klon |
cell center latitude, rad | init_geometry |
longitude_deg(:) |
klon |
longitude*180/PI |
init_geometry |
latitude_deg(:) |
klon |
latitude*180/PI |
init_geometry |
boundslon(:,:) |
klon,nvertex |
cell boundaries longitude, rad | init_geometry |
boundslat(:,:) |
klon,nvertex |
cell boundaries latitude, rad | init_geometry |
dx(:) |
klon |
longitude cell resolution, valid only for 2D grid | optional dx_ |
dy(:) |
klon |
latitude cell resolution, valid only for 2D grid | optional dy_ |
cell_area(:) |
klon |
physics cell area, m2 | init_geometry |
cell_area_for_lonlat_outputs(:) |
klon |
lon-lat output area with polar treatment | init_geometry_cell_area_for_outputs |
ind_cell_glo(:) |
klon |
global 1D cell index for local cells | optional ind_cell_glo_ |
所有这些 arrays 都是 SAVE, ALLOCATABLE 并分别声明 !$OMP THREADPRIVATE(...)。因此 OpenMP 并行运行时,每个线程持有自己的局部物理列几何。复现时必须确认初始化发生在正确的 OpenMP parallel 上下文内。
例程清单
| 例程 | 输入 | 行为 |
|---|---|---|
init_geometry(klon, longitude_, latitude_, boundslon_, boundslat_, cell_area_, ind_cell_glo_, dx_, dy_) |
klon,经纬度中心、边界、面积;可选全局 index、dx/dy |
按 klon 和 mod_grid_phy_lmdz:nvertex 分配局部数组,复制输入,并派生 degree 坐标。 |
init_geometry_cell_area_for_outputs(klon, cell_area_for_lonlat_outputs_) |
输出专用面积 | 分配并复制 cell_area_for_lonlat_outputs(:)。 |
本文件不释放这些 allocatable 数组,也不检查重复初始化。如果同一线程重复调用初始化例程而数组仍已分配,Fortran allocate 会失败;正常路径应只初始化一次。
初始化链
Mars 3D GCM 路径:
MARS dynphy_lonlat/phymars/iniphysiq_mod
-> COMMON inigeomphy_mod:inigeomphy
-> init_geometry(klon_omp, lonfi, latfi,
boundslonfi, boundslatfi,
airefi, ind_cell_glo_fi, cufi, cvfi)
-> init_geometry_cell_area_for_outputs(klon_omp, airefi_for_outputs)
-> init_vertical_layers(...)
-> Mars ini_fillgeom(klon_omp, latitude, longitude, cell_area)
inigeomphy_mod.F90 在 OpenMP 局部分片后调用本模块。ind_cell_glo_fi 由当前 offset 和 klon_omp_begin/end 构造,dx/dy 来自 cufi/cvfi。Mars iniphysiq_mod.F90 随后读取 latitude/longitude/cell_area 调用 ini_fillgeom,把物理几何同步到 Mars comgeomfi_h。
Mars 1D/testphys1d 路径:
init_testphys1d_mod
-> init_regular_lonlat(1, 1, ...)
-> init_geometry(1, longitude, latitude, zero bounds, cell_area, [1])
-> init_geometry_cell_area_for_outputs(1, cell_area)
1D 路径使用一个物理列,边界数组传入 4 个 0 值,ind_cell_glo=[1]。
主要使用位置
| 使用方 | 读取符号 | 用途 |
|---|---|---|
Mars iniphysiq_mod.F90 |
latitude, longitude, cell_area |
初始化 Mars physics 几何副本 comgeomfi_h。 |
COMMON wxios.F90 regular domain |
latitude_deg, longitude_deg |
gather/bcast 后建立 XIOS regular lon-lat domain。 |
COMMON wxios.F90 unstructured domain |
longitude, latitude, boundslon, boundslat, ind_cell_glo |
gather OMP 局部 unstructured 坐标、边界和 0-based i_index。 |
Mars writediagfi.F |
cell_area |
gather physics mesh area 后写 diagfi header/area。 |
Mars aeropacity_mod.F |
latitude, longitude |
latitude-dependent dust opacity 和 localized storm distance。 |
Mars utility newstart.F, lect_start_archive.F |
longitude, latitude, cell_area |
start/restart/archive 转换、watercap tag 重建和 physics restart 写出。 |
Mars subslope_mola.F90 |
boundslon, boundslat |
用 cell boundaries 对 MOLA 子坡度数据做局部几何判断。 |
复现要点
longitude/latitude/boundslon/boundslat的源码注释单位是 rad;longitude_deg/latitude_deg才是 degree。cell_area是 physics grid area;lon-lat 输出面积要用cell_area_for_lonlat_outputs。dx/dy只有调用方传入时才分配,且注释说明只对 2D grid 有效;使用位置必须先确认是否存在有效初始化。ind_cell_glo也是可选数组。XIOS unstructured domain 路径依赖它,因此该路径必须来自提供ind_cell_glo_的初始化。- 本模块只保存局部线程几何,不知道全局
nbp_lon/nbp_lat/klon_glo布局;全局规模和 1D/2D 映射见 mod_grid_phy_lmdz。
待确认
- 源码没有显式 deallocate/reinitialize 入口;如果某些运行模式会在同一进程内重建物理网格,需要由上层初始化流程证明不会重复 allocate。
dx/dy在 Mars 当前诊断链中的活跃使用位置未在本页完整枚举;本页只确认它们由inigeomphy_mod作为cufi/cvfi传入。