Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

NLON raises error in ice_history_write

Imke_Sievers

New Member
Hi,

After updating my CICE version from v6.2 to v6.4.2, I tried running CICE with the same input and name list options (ice_in attached) as I am running my 6.2 set-up and get the following error:

(abort_ice)ABORTED:
(abort_ice) error = (ice_write_hist)ERROR: writingNLON


I substituted NLON with ULON in line 822 (and in line 825, 828 and 831) in ice_history_write.F90 (altered file attached), which is the line raising the issue and now CICE runs without any issues. It seems like the coordinates NLON, NLAT, ELON and ELAT are allowcated but not assingt their correct values. I'm running CICE on a B-grid, so I think I am fine with my work around, but I don't think this is a good solution. I think I would need to asigne NLON, NLAT, ELON and ELAT their actual values, but I could not figure out where that should be done.

Best,
Imke
 

Attachments

  • CICE_files.tar.gz
    11.4 KB · Views: 1

dbailey

CSEG and Liaisons
Staff member
I think you are correct that NLON will not be allocated / set properly for a B-grid. I need to do some more debugging here. It should be that this is not written to the history file when the B-grid is active.
 

Philippe Blain

New Member
Hi Imke,

the arrays NLON, NLAT, ELON, ELAT are initialized in subroutine ice_grid::Tlatlon, which is called from ice_grid::init_grid2 as long as l_readCenter is not set. This variable is set to .true. if the NetCDF variable ANGLET is found in your grid file. I'm guessing this is the case ?

This would maybe explain the error you are seeing. I write maybe because I'm not sure exactly what causes your error; the NLON, NLAT, ELON, ELAT arrays are always allocated (in ice_grid::alloc_grid), so the error would be caused by the fact that the NetCDF library does not like writing uninitialized data and so nf90_put_var returns an error. According to the doc of nf90_put_var I guess it can happen if the uninitialized data happens to be interpreted as a number outside the range of our dbl_kind. I think we could confirm that suspicion by converting the NetCDF error code to its string representation, like this:

Diff:
diff --git a/./cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90 b/./cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90
index 51d76a6f..2d24a284 100644
--- a/./cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90
+++ b/./cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90
@@ -838,7 +838,7 @@ subroutine ice_write_hist (ns)
                   'ERROR: getting varid for '//var_coord(i)%short_name)
              status = nf90_put_var(ncid,varid,work_g1)
              if (status /= nf90_noerr) call abort_ice(subname// &
-                  'ERROR: writing'//var_coord(i)%short_name)
+                  'ERROR: writing'//var_coord(i)%short_name)//' : '//  trim(nf90_strerror(status))
           endif
         enddo


So, these arrays are correctly allocated and set for the B grid, unless the grid file contains ANGLET, in which case they are not set at all, which indeed seems to be a bug.

However, I agree with Dave that we should in fact not write these arrays at all to the history files if we are on the B grid.
 

dbailey

CSEG and Liaisons
Staff member
This seems related to what Till's group found. We should fix this in the next release.
 

Philippe Blain

New Member
sorry, my suggestion doesn't compile, a correct diff is:

Diff:
diff --git a/./cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90 b/./cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90
index 51d76a6f..ea847faa 100644
--- a/./cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90
+++ b/./cicecore/cicedyn/infrastructure/io/io_netcdf/ice_history_write.F90
@@ -838,7 +838,7 @@ subroutine ice_write_hist (ns)
                   'ERROR: getting varid for '//var_coord(i)%short_name)
              status = nf90_put_var(ncid,varid,work_g1)
              if (status /= nf90_noerr) call abort_ice(subname// &
-                  'ERROR: writing'//var_coord(i)%short_name)
+                  'ERROR: writing'//var_coord(i)%short_name//' : '//  trim(nf90_strerror(status)))
           endif
         enddo
 
Top