MetOffice / MetOffice/lfric_core

mesh read multiple open calls

Open
#417 1 comment 0 reactions 2 assignees View on GitHub

@EdHone is already working on this.

Since Jul 8, 2026.

Dominant language
Fortran
Stars
26
Forks
73
Avg merge
1d 8h
Merged PRs (30d)
4

Description

when reading data from mesh files, the `lfric_core` code places the file open calls within a call structure which results in a rank opening the file numerous times during the mesh reading

this puts unhelpful load on parallel file systems at scale.

The mesh reading netCDF interface code should be refactored such that reading, whether a full mesh or pre-partitioned mesh, requires only one open call, that is safely closed on completion or error.

The key loop is within [load_global_mesh_multiple](https://github.com/MetOffice/lfric_core/blob/main/components/driver/source/mesh/load_global_mesh_mod.f90#L39)

Which is iterated over mulitple times, with `N` epending on the configuration (e.g. C224 `lfric_atm` test this is called 5 times)

The problem is that the actual file interactions are located further down the call stack:
```
#9 file_open$ncdf_quad_mod_ +0x8de [0x11671ae]
#10 set_from_file_read$ugrid_2d_mod_ +0x15e [0x119530e]
#11 read_from_file$ugrid_mesh_data_mod_ +0xa8e [0x6d04de]
#12 load_global_mesh_single$load_global_mesh_mod_ +0x83e [0x67325e]
#13 load_global_mesh_multiple$load_global_mesh_mod_ +0x59 [0x672a09]
#14 init_mesh$driver_mesh_mod_ +0x1b55 [0x4f4ad5]
#15 initialise_infrastructure$gungho_model_mod_ +0x4740 [0x4afb00]
#16 initialise$gungho_driver_mod_ +0xa1a [0x489cba]
```

So, a redesign and re-implementation is needed.

Success Criteria:
* The netCDF file is only opened once, and accessed multiple times, not opened and closed for each element within this loop.

The open code is located within: [file_open](https://github.com/MetOffice/lfric_core/blob/main/infrastructure/source/io/ncdf_quad_mod.F90#L229)

which is called from [set_from_file_read](https://github.com/MetOffice/lfric_core/blob/main/infrastructure/source/io/ugrid_2d_mod.F90#L496C12-L496C30)

(note that [check_error](https://github.com/MetOffice/lfric_core/blob/main/infrastructure/source/io/ncdf_quad_mod.F90#L1807) could be used to manage the `also close on failure` case)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.