MetOffice / MetOffice/jules

vn7.9 crash when using elevated tiles: elevation ancil read before ainfo/jules_vars association

Open
#25 0 comments 0 reactions 1 assignee Claimed by @sarahshannon-uor View on GitHub
Dominant language
Fortran
Stars
23
Forks
36
Avg merge
5d 9h
Merged PRs (30d)
3

Description

I am setting up a gridded latitude–longitude JULES run with an elevated tile, where tile elevation is specified in metres above sea level and requires the gridbox-mean elevation from the forcing data. vn7.9 crashes with a segmentation fault, however the same setup with vn4.7 completes successfully. The problem is related to reading the gridbox-mean elevation file.

**Namelist example**

```fortran
&jules_z_land
surf_hgt_band = 8*0.0, 1000.0,
use_file = .true.,
file = '/path/to/elevation.nc',
z_land_name = 'elevation',
/
```
There appear to be two related issues in vn7.9, both associated with the order of initialisation in init.F90.

**Problem 1:**
When the elevation field is mapped to land points in map_to_land, the code uses ainfo%land_index. At this point, ainfo has not yet been associated with ainfo_data, so ainfo%land_index is empty. The association via

```fortran
CALL ancil_info_assoc(ainfo, ainfo_data)
```
occurs after the call to init_grid, which is where the elevation field is read and processed. This causes the indexing

```fortran
j = (ainfo%land_index(l) - 1) / t_i_length + 1
```

to fail with a segmentation fault.

**Problem 2:**
In populate_var.inc, the call to cube_get_data uses jules_vars%z_land_land. This array is only associated later in init.F90 via

```fortran
CALL jules_vars_assoc(jules_vars, jules_vars_data)
```
which again happens after init_grid. As a result, jules_vars%z_land_land has size zero when cube_get_data is called.

**Summary**

Both issues suggest that, in vn7.9, the elevation ancillary is being read and mapped before the required data structures (ainfo and jules_vars) are fully associated. This ordering appears to differ from vn4.7 and leads to a crash when using elevated tiles.

Assigning to myself for now - development branch of main in forked repo here https://github.com/sarahshannon-uor/jules/tree/z_land_fix

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.