Model crashes when reading runoff depth in river forcing file - netCDF/iom_get issue?

Hello,

I’m creating a new river forcing dataset that includes a runoff depth variable. However, the model fails to read the rodepth variable. The ocean.output file ends at “==>>> runoffs depth read in a file”, and my log file shows a “Fortran runtime error: end of record”. I believe the issue is related to iom_get reading the runoff depth variable in the corresponding file.

When I disable reading depth information (setting ln_rnf_depth to false), the model runs normally.

I’ve removed all coordinate values and ensured the time dimension is unlimited. At first glance, it looks exactly like my old forcing files.

As the rodepth value is constant in time, I’ve also tried creating it without the time dimension, but it doesn’t help.

Any assistance would be greatly appreciated. Thank you!

Mathurin

(See next post for ncdump/namelist sections)

Here’s my ncdump -h output for the runoff file:

netcdf rnf_y1995 {
dimensions:
time = UNLIMITED ; // (12 currently)
lat = 44 ;
lon = 81 ;
variables:
double sorunoff(time, lat, lon) ;
double rosaline(time, lat, lon) ;
double rotemper(time, lat, lon) ;
double rodepth(time, lat, lon) ;
}

Here’s the relevant namelist section:

!-----------------------------------------------------------------------
&namsbc_rnf ! runoffs (ln_rnf =T)
!-----------------------------------------------------------------------
ln_rnf_depth = .true. ! read in depth information for runoff
ln_rnf_tem = .true. ! read in temperature information for runoff
ln_rnf_sal = .true. ! read in salinity information for runoff
!
cn_dir = ‘<forcing_path>’ ! root directory for the runoff data location
!!______!!!!!!!!_______!
! ! file name ! frequency (hours) ! variable ! time interp.! clim ! ‘yearly’/ ! weights filename ! rotation ! land/sea mask !
! ! ! (if <0 months) ! name ! (logical) ! (T/F) ! ‘monthly’ ! ! pairing ! filename !
sn_rnf = ‘rnf’ , -1 , ‘sorunoff’, .true. , .false., ‘yearly’ , ‘’ , ‘’ , ‘’
sn_s_rnf = ‘rnf’ , -1 , ‘rosaline’, .false. , .false., ‘yearly’ , ‘’ , ‘’ , ‘’
sn_t_rnf = ‘rnf’ , -1 , ‘rotemper’, .true. , .false., ‘yearly’ , ‘’ , ‘’ , ‘’
sn_dep_rnf = ‘rnf’ , -1 , ‘rodepth’ , .false. , .false., ‘yearly’ , ‘’ , ‘’ , ‘’

I create these netCDF files with xarray in Python. I also tried different netcdf4 formats. These forcing files (physics and biogeochemistry) are regularly read by NEMO, except for runoff depth.

python snippet:
year_data.time.encoding[“unlimited”] = True
year_data.to_netcdf(path, unlimited_dims=[“time”], encoding={v:{‘_FillValue’: None} for v in year_data.data_vars}, format=“NETCDF4_CLASSIC”)

Bonjour Mathurin,

I just checked in my namelist, and i have the runoff depth information
as false/true/yearly.

/robinson

Hi Robinson,

Thanks for the quick reply!

If I include the runoff depth as a climatological file, it does indeed work!
That’s somehow surprising, because for the forcing files that I used until now (created with a matlab script), I could read them in as yearly files with climatology set to false.

I’ll try to investigate the issue further, because it feels like I am missing some key specification of netcdf forcing files for nemo (I don’t know much about the underlying iom_get routines and netcdf apart from what ncdump shows me). Having to remove all coordinate values and setting time to unlimited is something I realized for some other type of forcing files in the past, and I’m surprised its not enough here.

mathurin

Très bien.

Actually I do not find this very surprising, if you set climatological to false it means there should be inter annual variability. Which is even more absurd for something that is constant.
This depth field is not really a forcing field, but it is read as a forcing field technically, it should more be read as a kind of addition to the bathymetry field.

I was just thinking, perhaps it would work if you also put nothing regarding whether this field is climatological or not.

You’re correct that runoff depth doesn’t change with time. In my forcing files, I used a constant repeating value (as I do for river salinity forcing due to lack of data).

I was puzzled why my model was crashing with new forcing files when it worked fine with the old ones. It turns out this wasn’t due to hidden NetCDF attributes, but an uncaught filepath error:

In OCE/SBC/sbcrnf.F90, runoff depth is read with iom_open(rn_dep_file, inum), while temperature, salinity, and runoff use fld_fill. The issue is that in sbcrnf.F90, rn_dep_file is limited to 32 characters, whereas fld_fill has no length limit for the path.

My new forcing files were in a location with a longer path name, exceeding this 32-character limit. This caused the path to be improperly read, resulting in a cryptic Fortran “end of file” error as the model tried reading some other file.

Problem solved, and I learned a valuable lesson: it’s always worth adding a write(*,*) filepath statement to debug if NEMO is reading the file I think it is. (and always putting river files in the GEO folder directly…)

thanks for discussing the issue!