New URL for NEMO forge!

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
[SIREN] `create_bathy` segmentation fault – Message List – Discussion – NEMO

Tools (#2) - [SIREN] create_bathy segmentation fault (#1) - Message List

[SIREN] create_bathy segmentation fault

Hello, I try to create a nested grid in a parent model grid using SIREN. create_coordinates.exe works as expected, and generates which I subsequently use in create_bathymetry.nam is just the file that I created by interpolating the gebco bathymetry, and when I use it in the coarse model, it runs fine:

ncdump -h
netcdf bathy_coarse { dimensions:
  x = 576 ; y = 282 ;
  double nav_lon(y, x) ; 
   double nav_lat(y, x) ; 
   double Bathymetry(y, x) ; 
   double longitude(x) ; 
   double latitude(y) ;

But create_bathymetry.exe throws a segmentation fault. This is the line where the segmentation fault happens:    00002B77002818D0  Unknown               Unknown  Unknown
create_bathy.exe   000000000050D92A  iom_mpp_mp_iom_mp         588  iom_mpp.f90
create_bathy.exe   000000000050A88E  iom_mpp_mp_iom_mp         411  iom_mpp.f90
create_bathy.exe   000000000048182B  grid_mp_grid__get        1225  grid.f90
create_bathy.exe   000000000047CDE5  grid_mp_grid__get         543  grid.f90
create_bathy.exe   000000000040C2CC  MAIN                      413  create_bathy.f90

So in gridget_info_mpp -> grid_get_pivot -> iom_mpp_read_var(td_mpp, 'latitude') -> iom_mppread_var_value -> the assignment to td_var%d_value(...)

Here is my namelist:

  cn_varfile='   '

In case it helps, I stored the coarse bathymetry online ( ).



  • Message #1

    I tracked the flow of the code and found the error...

    The subroutine iom__read_var_name directs to different subroutines that do the actual reading, depending on the type of file to read.

    Only 2 cases are implemented in iom.f90, cdf and dimg. But I had a netcdf4 file, and td_file%c_type was equal to cdf4, not cdf. Therefor, iom__read_var_name did nothing and the returning variable tl_var had sizes 0 0 0 0 , leading to the seg fault when putting these values into td_var.

    I added a new case in iom__read_var_name, cdf4, which does exactly the same as when the file type is cdf. Of course the netcdf library must be netcdf4.

    It works now.

    • Message #2

      you're right, SIREN is not yet netcdf4 compliant. However if it's work, it's fine.

      Maybe to avoid other issue like this one, you should force td_file%c_type='cdf' in iom_cdf.f90 (iom_cdf__get_info) for netcdf4 case, Instead of adding CASE('cdf4') every time you need it.


No attachments created.