Namelist confusing in iceberg initialisation
Context
Copy/paste of the not closed ticket 2467 from the Trac system.
By looking at SETTE, Seb spotted that ORCA2 LONG/SHORT have different icb settings and magically gave the same answer. After looking at it in more detailed, this was normal but I found it very confusing.
Analysis
Namelist ref controlling the icb initialisation:
nn_test_icebergs = 10 ! Create test icebergs of this class (-1 = no)
! ! Put a test iceberg at each gridpoint in box (lon1,lon2,lat1,lat2)
rn_test_box = 108.0, 116.0, -66.0, -58.0
ln_use_calving = .false. ! Use calving data even when nn_test_icebergs > 0
So by default if you switch off the iceberg calving, you use the test functionality and you don't read a calving file.
In icbini, nn_test_icebergs = -1
and ln_use_calving
have a similar effect => trigger the reading of the calving file:
! when not generating test icebergs we need to setup calving file
IF( nn_test_icebergs < 0 .OR. ln_use_calving ) THEN
In icbini, if we want to read the icb restart, we need to set nn_test_icebergs <= 0
.
IF( .NOT.ln_rstart ) THEN
IF( nn_test_icebergs > 0 ) CALL icb_ini_gen()
ELSE
IF( nn_test_icebergs > 0 ) THEN
CALL icb_ini_gen()
ELSE
CALL icb_rst_read()
l_restarted_bergs = .TRUE.
ENDIF
ENDIF
And if you want to initialized with icebergs (test), and let the model go using restart without a calving file defined it seems you need to set nn_test_icebergs = 0
.
Extra suggestion: being able to read an initial file (basically an old restart even if NEMO does not start using restart), this will decrease the spinup time of the icebergs
Suggestion
All of this looks very confusing and possible source of unwanted behavior. I suggest to change the namelist_ref (and the code will need to be change accordingly):
ln_use_test = .false. ! use the testing capacity
nn_test_icebergs = 0 ! Create test icebergs of this class (need to be larger than 1)
rn_test_box = 0.0, 0.0, -90.0, -90.0 ! Put a test iceberg at each gridpoint in box (lon1,lon2,lat1,lat2)
ln_test_rst = .false. ! do not read a restart file when ln_use_test = .true., seed icb in the testing box instead.
ln_use_calving = .false. ! read a calving file
sn_icb = '', '', ... ! calving file definition
ln_icb_init = .false. ! read icb from a previous restart (only used when the master flag ln_rstart is false)
cn_icbini= 'icbinit.nc' ! icb restart name
By default both flag ln_use_test
and ln_use_calving
are false and NEMO should STOP.
Then you choose what you want, and if you activate both, you initialized the icb as defined by the test and read a calving file