Index: /NEMO/trunk/cfgs/SHARED/namelist_ref
===================================================================
--- /NEMO/trunk/cfgs/SHARED/namelist_ref	(revision 9931)
+++ /NEMO/trunk/cfgs/SHARED/namelist_ref	(revision 9932)
@@ -523,4 +523,5 @@
    !                                ! 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
    rn_speed_limit          = 0.     ! CFL speed limit for a berg
 
Index: /NEMO/trunk/src/OCE/ICB/icb_oce.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icb_oce.F90	(revision 9931)
+++ /NEMO/trunk/src/OCE/ICB/icb_oce.F90	(revision 9932)
@@ -111,4 +111,6 @@
    INTEGER , PUBLIC ::   nn_test_icebergs                !: Create icebergs in absence of a restart file from the supplied class nb
    REAL(wp), PUBLIC, DIMENSION(4) ::   rn_test_box       !: lon1,lon2,lat1,lat2 box to create them in
+   LOGICAL , PUBLIC ::   ln_use_calving                  !: Force use of calving data even with nn_test_icebergs > 0 
+                                                         !  (default is not to use calving data with test bergs)
    INTEGER , PUBLIC ::   nn_sample_rate                  !: Timesteps between sampling of position for trajectory storage
    INTEGER , PUBLIC ::   nn_verbose_write                !: timesteps between verbose messages
Index: /NEMO/trunk/src/OCE/ICB/icbclv.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icbclv.F90	(revision 9931)
+++ /NEMO/trunk/src/OCE/ICB/icbclv.F90	(revision 9932)
@@ -63,5 +63,5 @@
       berg_grid%calving_hflx(:,:) = src_calving_hflx(:,:) * tmask_i(:,:)
 
-      IF( ll_first_call .AND. .NOT. l_restarted_bergs) THEN      ! This is a hack to simplify initialization
+      IF( ll_first_call .AND. .NOT. l_restarted_bergs ) THEN      ! This is a hack to simplify initialization
          ll_first_call = .FALSE.
          !do jn=1, nclasses
@@ -100,5 +100,5 @@
 
 
-   SUBROUTINE icb_clv()
+   SUBROUTINE icb_clv( kt )
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE icb_clv  ***
@@ -114,4 +114,5 @@
       !!                is considered
       !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt
       INTEGER       ::   ji, jj, jn   ! dummy loop indices
       INTEGER       ::   icnt, icntmax
Index: /NEMO/trunk/src/OCE/ICB/icbini.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icbini.F90	(revision 9931)
+++ /NEMO/trunk/src/OCE/ICB/icbini.F90	(revision 9932)
@@ -228,5 +228,5 @@
 
       ! when not generating test icebergs we need to setup calving file
-      IF( nn_test_icebergs < 0 ) THEN
+      IF( nn_test_icebergs < 0 .OR. ln_use_calving ) THEN
          !
          ! maximum distribution class array does not change in time so read it once
@@ -358,5 +358,5 @@
          &              rn_bits_erosion_fraction        , rn_sicn_shift       , ln_passive_mode      ,   &
          &              ln_time_average_weight          , nn_test_icebergs    , rn_test_box          ,   &
-         &              rn_speed_limit , cn_dir, sn_icb
+         &              ln_use_calving , rn_speed_limit , cn_dir, sn_icb
       !!----------------------------------------------------------------------
 
@@ -399,4 +399,10 @@
          IF(lwp) WRITE(numout,*) '   ==>>>   Resetting of nn_test_icebergs to ', nclasses
          nn_test_icebergs = nclasses
+      ENDIF
+      !
+      IF( nn_test_icebergs < 0 .AND. .NOT. ln_use_calving ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '   ==>>>   Resetting ln_use_calving to .true. since we are not using test icebergs'
+         ln_use_calving = .true.
       ENDIF
       !
@@ -440,4 +446,5 @@
          WRITE(numout,*) '   Create icebergs in absence of a restart file   nn_test_icebergs  = ', nn_test_icebergs
          WRITE(numout,*) '                   in lon/lat box                                   = ', rn_test_box
+         WRITE(numout,*) '   Use calving data even if nn_test_icebergs > 0    ln_use_calving  = ', ln_use_calving
          WRITE(numout,*) '   CFL speed limit for a berg            speed_limit                = ', rn_speed_limit
          WRITE(numout,*) '   Writing Iceberg status information to icebergs.stat file        '
Index: /NEMO/trunk/src/OCE/ICB/icbrst.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icbrst.F90	(revision 9931)
+++ /NEMO/trunk/src/OCE/ICB/icbrst.F90	(revision 9932)
@@ -117,4 +117,6 @@
          END DO
          !
+      ELSE
+         ibergs_in_file = 0
       ENDIF 
 
@@ -130,5 +132,5 @@
       ! Sanity check
       jn = icb_utl_count()
-      IF (nn_verbose_level >= 0)   &
+      IF ( lwp .AND. nn_verbose_level >= 0 )   &
          WRITE(numout,'(2(a,i5))') 'icebergs, read_restart_bergs: # bergs =',jn,' on PE',narea-1
       IF( lk_mpp ) THEN
@@ -137,5 +139,5 @@
          CALL mpp_sum(jn)
       ENDIF
-      IF(lwp)   WRITE(numout,'(a,i5,a,i5,a)') 'icebergs, read_restart_bergs: there were',ibergs_in_file,   &
+      IF( lwp )   WRITE(numout,'(a,i5,a,i5,a)') 'icebergs, icb_rst_read: there were',ibergs_in_file,   &
          &                                    ' bergs in the restart file and', jn,' bergs have been read'
       !
@@ -143,5 +145,5 @@
       CALL iom_close( ncid )
       !
-      IF( lwp .AND. nn_verbose_level >= 0)  WRITE(numout,'(a)') 'icebergs, read_restart_bergs: completed'
+      IF( lwp .AND. nn_verbose_level >= 0 )  WRITE(numout,'(a)') 'icebergs, icb_rst_read: completed'
       !
    END SUBROUTINE icb_rst_read
@@ -163,199 +165,220 @@
       !!----------------------------------------------------------------------
 
-      ! Assume we write iceberg restarts to same directory as ocean restarts.
-      cl_path = TRIM(cn_ocerst_outdir)
-      IF( cl_path(LEN_TRIM(cl_path):) /= '/' ) cl_path = TRIM(cl_path) // '/'
-      IF( lk_mpp ) THEN
-         WRITE(cl_filename,'(A,"_icebergs_",I8.8,"_restart_",I4.4,".nc")') TRIM(cexper), kt, narea-1
-      ELSE
-         WRITE(cl_filename,'(A,"_icebergs_",I8.8,"_restart.nc")') TRIM(cexper), kt
+      ! Following the normal restart procedure, this routine will be called
+      ! the timestep before a restart stage as well as the restart timestep.
+      ! This is a performance step enabling the file to be opened and contents
+      ! defined in advance of the write. This is not possible with icebergs
+      ! since the number of bergs to be written could change between timesteps
+      IF( kt == nitrst ) THEN
+         ! Only operate on the restart timestep itself.
+         ! Assume we write iceberg restarts to same directory as ocean restarts.
+         cl_path = TRIM(cn_ocerst_outdir)
+         IF( cl_path(LEN_TRIM(cl_path):) /= '/' ) cl_path = TRIM(cl_path) // '/'
+         IF( lk_mpp ) THEN
+            WRITE(cl_filename,'(A,"_icebergs_",I8.8,"_restart_",I4.4,".nc")') TRIM(cexper), kt, narea-1
+         ELSE
+            WRITE(cl_filename,'(A,"_icebergs_",I8.8,"_restart.nc")') TRIM(cexper), kt
+         ENDIF
+         IF ( lwp .AND. nn_verbose_level >= 0) WRITE(numout,'(2a)') 'icebergs, write_restart: creating ',  &
+           &                                                         TRIM(cl_path)//TRIM(cl_filename)
+   
+         nret = NF90_CREATE(TRIM(cl_path)//TRIM(cl_filename), NF90_CLOBBER, ncid)
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_create failed')
+   
+         ! Dimensions
+         nret = NF90_DEF_DIM(ncid, 'x', jpi, ix_dim)
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim x failed')
+   
+         nret = NF90_DEF_DIM(ncid, 'y', jpj, iy_dim)
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim y failed')
+   
+         nret = NF90_DEF_DIM(ncid, 'c', nclasses, nc_dim)
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim c failed')
+   
+         nret = NF90_DEF_DIM(ncid, 'k', nkounts, ik_dim)
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim k failed')
+   
+         ! global attributes
+         IF( lk_mpp ) THEN
+            ! Set domain parameters (assume jpdom_local_full)
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_number'         , narea-1            )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_dimensions_ids' , (/1     , 2     /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_global'    , (/jpiglo, jpjglo/) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_local'     , (/jpi   , jpj   /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_first' , (/nimpp , njmpp /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_last'  , (/nimpp + jpi - 1 , njmpp + jpj - 1  /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_start', (/nldi - 1        , nldj - 1         /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_end'  , (/jpi - nlei      , jpj - nlej       /) )
+            nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_type'           , 'BOX'              )
+         ENDIF
+         
+         IF (associated(first_berg)) then
+            nret = NF90_DEF_DIM(ncid, 'n', NF90_UNLIMITED, in_dim)
+            IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim n failed')
+         ENDIF
+   
+         ! Variables
+         nret = NF90_DEF_VAR(ncid, 'kount'       , NF90_INT   , (/ ik_dim /), nkountid)
+         nret = NF90_DEF_VAR(ncid, 'calving'     , NF90_DOUBLE, (/ ix_dim, iy_dim /), ncalvid)
+         nret = NF90_DEF_VAR(ncid, 'calving_hflx', NF90_DOUBLE, (/ ix_dim, iy_dim /), ncalvhid)
+         nret = NF90_DEF_VAR(ncid, 'stored_ice'  , NF90_DOUBLE, (/ ix_dim, iy_dim, nc_dim /), nsiceid)
+         nret = NF90_DEF_VAR(ncid, 'stored_heat' , NF90_DOUBLE, (/ ix_dim, iy_dim /), nsheatid)
+   
+         ! Attributes
+         nret = NF90_PUT_ATT(ncid, ncalvid , 'long_name', 'iceberg calving')
+         nret = NF90_PUT_ATT(ncid, ncalvid , 'units', 'some')
+         nret = NF90_PUT_ATT(ncid, ncalvhid, 'long_name', 'heat flux associated with iceberg calving')
+         nret = NF90_PUT_ATT(ncid, ncalvhid, 'units', 'some')
+         nret = NF90_PUT_ATT(ncid, nsiceid , 'long_name', 'stored ice used to calve icebergs')
+         nret = NF90_PUT_ATT(ncid, nsiceid , 'units', 'kg/s')
+         nret = NF90_PUT_ATT(ncid, nsheatid, 'long_name', 'heat in stored ice used to calve icebergs')
+         nret = NF90_PUT_ATT(ncid, nsheatid, 'units', 'J/kg/s')
+   
+         IF ( ASSOCIATED(first_berg) ) THEN
+   
+            ! Only add berg variables for this PE if we have anything to say
+   
+            ! Variables
+            nret = NF90_DEF_VAR(ncid, 'lon', NF90_DOUBLE, in_dim, nlonid)
+            nret = NF90_DEF_VAR(ncid, 'lat', NF90_DOUBLE, in_dim, nlatid)
+            nret = NF90_DEF_VAR(ncid, 'xi', NF90_DOUBLE, in_dim, nxid)
+            nret = NF90_DEF_VAR(ncid, 'yj', NF90_DOUBLE, in_dim, nyid)
+            nret = NF90_DEF_VAR(ncid, 'uvel', NF90_DOUBLE, in_dim, nuvelid)
+            nret = NF90_DEF_VAR(ncid, 'vvel', NF90_DOUBLE, in_dim, nvvelid)
+            nret = NF90_DEF_VAR(ncid, 'mass', NF90_DOUBLE, in_dim, nmassid)
+            nret = NF90_DEF_VAR(ncid, 'thickness', NF90_DOUBLE, in_dim, nthicknessid)
+            nret = NF90_DEF_VAR(ncid, 'width', NF90_DOUBLE, in_dim, nwidthid)
+            nret = NF90_DEF_VAR(ncid, 'length', NF90_DOUBLE, in_dim, nlengthid)
+            nret = NF90_DEF_VAR(ncid, 'number', NF90_INT, (/ik_dim,in_dim/), numberid)
+            nret = NF90_DEF_VAR(ncid, 'year', NF90_INT, in_dim, nyearid)
+            nret = NF90_DEF_VAR(ncid, 'day', NF90_DOUBLE, in_dim, ndayid)
+            nret = NF90_DEF_VAR(ncid, 'mass_scaling', NF90_DOUBLE, in_dim, nscaling_id)
+            nret = NF90_DEF_VAR(ncid, 'mass_of_bits', NF90_DOUBLE, in_dim, nmass_of_bits_id)
+            nret = NF90_DEF_VAR(ncid, 'heat_density', NF90_DOUBLE, in_dim, nheat_density_id)
+   
+            ! Attributes
+            nret = NF90_PUT_ATT(ncid, nlonid, 'long_name', 'longitude')
+            nret = NF90_PUT_ATT(ncid, nlonid, 'units', 'degrees_E')
+            nret = NF90_PUT_ATT(ncid, nlatid, 'long_name', 'latitude')
+            nret = NF90_PUT_ATT(ncid, nlatid, 'units', 'degrees_N')
+            nret = NF90_PUT_ATT(ncid, nxid, 'long_name', 'x grid box position')
+            nret = NF90_PUT_ATT(ncid, nxid, 'units', 'fractional')
+            nret = NF90_PUT_ATT(ncid, nyid, 'long_name', 'y grid box position')
+            nret = NF90_PUT_ATT(ncid, nyid, 'units', 'fractional')
+            nret = NF90_PUT_ATT(ncid, nuvelid, 'long_name', 'zonal velocity')
+            nret = NF90_PUT_ATT(ncid, nuvelid, 'units', 'm/s')
+            nret = NF90_PUT_ATT(ncid, nvvelid, 'long_name', 'meridional velocity')
+            nret = NF90_PUT_ATT(ncid, nvvelid, 'units', 'm/s')
+            nret = NF90_PUT_ATT(ncid, nmassid, 'long_name', 'mass')
+            nret = NF90_PUT_ATT(ncid, nmassid, 'units', 'kg')
+            nret = NF90_PUT_ATT(ncid, nthicknessid, 'long_name', 'thickness')
+            nret = NF90_PUT_ATT(ncid, nthicknessid, 'units', 'm')
+            nret = NF90_PUT_ATT(ncid, nwidthid, 'long_name', 'width')
+            nret = NF90_PUT_ATT(ncid, nwidthid, 'units', 'm')
+            nret = NF90_PUT_ATT(ncid, nlengthid, 'long_name', 'length')
+            nret = NF90_PUT_ATT(ncid, nlengthid, 'units', 'm')
+            nret = NF90_PUT_ATT(ncid, numberid, 'long_name', 'iceberg number on this processor')
+            nret = NF90_PUT_ATT(ncid, numberid, 'units', 'count')
+            nret = NF90_PUT_ATT(ncid, nyearid, 'long_name', 'calendar year of calving event')
+            nret = NF90_PUT_ATT(ncid, nyearid, 'units', 'years')
+            nret = NF90_PUT_ATT(ncid, ndayid, 'long_name', 'year day of calving event')
+            nret = NF90_PUT_ATT(ncid, ndayid, 'units', 'days')
+            nret = NF90_PUT_ATT(ncid, nscaling_id, 'long_name', 'scaling factor for mass of calving berg')
+            nret = NF90_PUT_ATT(ncid, nscaling_id, 'units', 'none')
+            nret = NF90_PUT_ATT(ncid, nmass_of_bits_id, 'long_name', 'mass of bergy bits')
+            nret = NF90_PUT_ATT(ncid, nmass_of_bits_id, 'units', 'kg')
+            nret = NF90_PUT_ATT(ncid, nheat_density_id, 'long_name', 'heat density')
+            nret = NF90_PUT_ATT(ncid, nheat_density_id, 'units', 'J/kg')
+   
+         ENDIF ! associated(first_berg)
+   
+         ! End define mode
+         nret = NF90_ENDDEF(ncid)
+   
+         ! --------------------------------
+         ! now write some data
+   
+         nstrt3(1) = 1
+         nstrt3(2) = 1
+         nlngth3(1) = jpi
+         nlngth3(2) = jpj
+         nlngth3(3) = 1
+   
+         DO jn=1,nclasses
+            griddata(:,:,1) = berg_grid%stored_ice(:,:,jn)
+            nstrt3(3) = jn
+            nret = NF90_PUT_VAR( ncid, nsiceid, griddata, nstrt3, nlngth3 )
+            IF (nret .ne. NF90_NOERR) THEN
+               IF( lwp ) WRITE(numout,*) TRIM(NF90_STRERROR( nret ))
+               CALL ctl_stop('icebergs, write_restart: nf_put_var stored_ice failed')
+            ENDIF
+         ENDDO
+         IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: stored_ice  written'
+   
+         nret = NF90_PUT_VAR( ncid, nkountid, num_bergs(:) )
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var kount failed')
+   
+         nret = NF90_PUT_VAR( ncid, nsheatid, berg_grid%stored_heat(:,:) )
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var stored_heat failed')
+         IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: stored_heat written'
+   
+         nret = NF90_PUT_VAR( ncid, ncalvid , src_calving(:,:) )
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving failed')
+         nret = NF90_PUT_VAR( ncid, ncalvhid, src_calving_hflx(:,:) )
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving_hflx failed')
+         IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: calving written'
+   
+         IF ( ASSOCIATED(first_berg) ) THEN
+   
+            ! Write variables
+            ! just write out the current point of the trajectory
+   
+            this => first_berg
+            jn = 0
+            DO WHILE (ASSOCIATED(this))
+               pt => this%current_point
+               jn=jn+1
+   
+               nret = NF90_PUT_VAR(ncid, numberid, this%number, (/1,jn/), (/nkounts,1/) )
+               nret = NF90_PUT_VAR(ncid, nscaling_id, this%mass_scaling, (/ jn /) )
+   
+               nret = NF90_PUT_VAR(ncid, nlonid, pt%lon, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nlatid, pt%lat, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nxid, pt%xi, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nyid, pt%yj, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nuvelid, pt%uvel, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nvvelid, pt%vvel, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nmassid, pt%mass, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nthicknessid, pt%thickness, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nwidthid, pt%width, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nlengthid, pt%length, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nyearid, pt%year, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, ndayid, pt%day, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nmass_of_bits_id, pt%mass_of_bits, (/ jn /) )
+               nret = NF90_PUT_VAR(ncid, nheat_density_id, pt%heat_density, (/ jn /) )
+   
+               this=>this%next
+            END DO
+            !
+         ENDIF ! associated(first_berg)
+   
+         ! Finish up
+         nret = NF90_CLOSE(ncid)
+         IF (nret /= NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_close failed')
+   
+         ! Sanity check
+         jn = icb_utl_count()
+         IF ( lwp .AND. nn_verbose_level >= 0)   &
+            WRITE(numout,'(2(a,i5))') 'icebergs, icb_rst_write: # bergs =',jn,' on PE',narea-1
+         IF( lk_mpp ) THEN
+            CALL mpp_sum(jn)
+         ENDIF
+         IF(lwp)   WRITE(numout,'(a,i5,a,i5,a)') 'icebergs, icb_rst_write: ', jn,   &
+            &                                    ' bergs in total have been written at timestep ', kt
+         !
+         ! Finish up
+         !
       ENDIF
-      IF (nn_verbose_level >= 0) WRITE(numout,'(2a)') 'icebergs, write_restart: creating ',TRIM(cl_path)//TRIM(cl_filename)
-
-      nret = NF90_CREATE(TRIM(cl_path)//TRIM(cl_filename), NF90_CLOBBER, ncid)
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_create failed')
-
-      ! Dimensions
-      nret = NF90_DEF_DIM(ncid, 'x', jpi, ix_dim)
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim x failed')
-
-      nret = NF90_DEF_DIM(ncid, 'y', jpj, iy_dim)
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim y failed')
-
-      nret = NF90_DEF_DIM(ncid, 'c', nclasses, nc_dim)
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim c failed')
-
-      nret = NF90_DEF_DIM(ncid, 'k', nkounts, ik_dim)
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim k failed')
-
-      ! global attributes
-      IF( lk_mpp ) THEN
-         ! Set domain parameters (assume jpdom_local_full)
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_number'         , narea-1            )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_dimensions_ids' , (/1     , 2     /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_global'    , (/jpiglo, jpjglo/) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_size_local'     , (/jpi   , jpj   /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_first' , (/nimpp , njmpp /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_position_last'  , (/nimpp + jpi - 1 , njmpp + jpj - 1  /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_start', (/nldi - 1        , nldj - 1         /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_halo_size_end'  , (/jpi - nlei      , jpj - nlej       /) )
-         nret = NF90_PUT_ATT( ncid, NF90_GLOBAL, 'DOMAIN_type'           , 'BOX'              )
-      ENDIF
-      
-      IF (associated(first_berg)) then
-         nret = NF90_DEF_DIM(ncid, 'n', NF90_UNLIMITED, in_dim)
-         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim n failed')
-      ENDIF
-
-      ! Variables
-      nret = NF90_DEF_VAR(ncid, 'kount'       , NF90_INT   , (/ ik_dim /), nkountid)
-      nret = NF90_DEF_VAR(ncid, 'calving'     , NF90_DOUBLE, (/ ix_dim, iy_dim /), ncalvid)
-      nret = NF90_DEF_VAR(ncid, 'calving_hflx', NF90_DOUBLE, (/ ix_dim, iy_dim /), ncalvhid)
-      nret = NF90_DEF_VAR(ncid, 'stored_ice'  , NF90_DOUBLE, (/ ix_dim, iy_dim, nc_dim /), nsiceid)
-      nret = NF90_DEF_VAR(ncid, 'stored_heat' , NF90_DOUBLE, (/ ix_dim, iy_dim /), nsheatid)
-
-      ! Attributes
-      nret = NF90_PUT_ATT(ncid, ncalvid , 'long_name', 'iceberg calving')
-      nret = NF90_PUT_ATT(ncid, ncalvid , 'units', 'some')
-      nret = NF90_PUT_ATT(ncid, ncalvhid, 'long_name', 'heat flux associated with iceberg calving')
-      nret = NF90_PUT_ATT(ncid, ncalvhid, 'units', 'some')
-      nret = NF90_PUT_ATT(ncid, nsiceid , 'long_name', 'stored ice used to calve icebergs')
-      nret = NF90_PUT_ATT(ncid, nsiceid , 'units', 'kg/s')
-      nret = NF90_PUT_ATT(ncid, nsheatid, 'long_name', 'heat in stored ice used to calve icebergs')
-      nret = NF90_PUT_ATT(ncid, nsheatid, 'units', 'J/kg/s')
-
-      IF ( ASSOCIATED(first_berg) ) THEN
-
-         ! Only add berg variables for this PE if we have anything to say
-
-         ! Variables
-         nret = NF90_DEF_VAR(ncid, 'lon', NF90_DOUBLE, in_dim, nlonid)
-         nret = NF90_DEF_VAR(ncid, 'lat', NF90_DOUBLE, in_dim, nlatid)
-         nret = NF90_DEF_VAR(ncid, 'xi', NF90_DOUBLE, in_dim, nxid)
-         nret = NF90_DEF_VAR(ncid, 'yj', NF90_DOUBLE, in_dim, nyid)
-         nret = NF90_DEF_VAR(ncid, 'uvel', NF90_DOUBLE, in_dim, nuvelid)
-         nret = NF90_DEF_VAR(ncid, 'vvel', NF90_DOUBLE, in_dim, nvvelid)
-         nret = NF90_DEF_VAR(ncid, 'mass', NF90_DOUBLE, in_dim, nmassid)
-         nret = NF90_DEF_VAR(ncid, 'thickness', NF90_DOUBLE, in_dim, nthicknessid)
-         nret = NF90_DEF_VAR(ncid, 'width', NF90_DOUBLE, in_dim, nwidthid)
-         nret = NF90_DEF_VAR(ncid, 'length', NF90_DOUBLE, in_dim, nlengthid)
-         nret = NF90_DEF_VAR(ncid, 'number', NF90_INT, (/ik_dim,in_dim/), numberid)
-         nret = NF90_DEF_VAR(ncid, 'year', NF90_INT, in_dim, nyearid)
-         nret = NF90_DEF_VAR(ncid, 'day', NF90_DOUBLE, in_dim, ndayid)
-         nret = NF90_DEF_VAR(ncid, 'mass_scaling', NF90_DOUBLE, in_dim, nscaling_id)
-         nret = NF90_DEF_VAR(ncid, 'mass_of_bits', NF90_DOUBLE, in_dim, nmass_of_bits_id)
-         nret = NF90_DEF_VAR(ncid, 'heat_density', NF90_DOUBLE, in_dim, nheat_density_id)
-
-         ! Attributes
-         nret = NF90_PUT_ATT(ncid, nlonid, 'long_name', 'longitude')
-         nret = NF90_PUT_ATT(ncid, nlonid, 'units', 'degrees_E')
-         nret = NF90_PUT_ATT(ncid, nlatid, 'long_name', 'latitude')
-         nret = NF90_PUT_ATT(ncid, nlatid, 'units', 'degrees_N')
-         nret = NF90_PUT_ATT(ncid, nxid, 'long_name', 'x grid box position')
-         nret = NF90_PUT_ATT(ncid, nxid, 'units', 'fractional')
-         nret = NF90_PUT_ATT(ncid, nyid, 'long_name', 'y grid box position')
-         nret = NF90_PUT_ATT(ncid, nyid, 'units', 'fractional')
-         nret = NF90_PUT_ATT(ncid, nuvelid, 'long_name', 'zonal velocity')
-         nret = NF90_PUT_ATT(ncid, nuvelid, 'units', 'm/s')
-         nret = NF90_PUT_ATT(ncid, nvvelid, 'long_name', 'meridional velocity')
-         nret = NF90_PUT_ATT(ncid, nvvelid, 'units', 'm/s')
-         nret = NF90_PUT_ATT(ncid, nmassid, 'long_name', 'mass')
-         nret = NF90_PUT_ATT(ncid, nmassid, 'units', 'kg')
-         nret = NF90_PUT_ATT(ncid, nthicknessid, 'long_name', 'thickness')
-         nret = NF90_PUT_ATT(ncid, nthicknessid, 'units', 'm')
-         nret = NF90_PUT_ATT(ncid, nwidthid, 'long_name', 'width')
-         nret = NF90_PUT_ATT(ncid, nwidthid, 'units', 'm')
-         nret = NF90_PUT_ATT(ncid, nlengthid, 'long_name', 'length')
-         nret = NF90_PUT_ATT(ncid, nlengthid, 'units', 'm')
-         nret = NF90_PUT_ATT(ncid, numberid, 'long_name', 'iceberg number on this processor')
-         nret = NF90_PUT_ATT(ncid, numberid, 'units', 'count')
-         nret = NF90_PUT_ATT(ncid, nyearid, 'long_name', 'calendar year of calving event')
-         nret = NF90_PUT_ATT(ncid, nyearid, 'units', 'years')
-         nret = NF90_PUT_ATT(ncid, ndayid, 'long_name', 'year day of calving event')
-         nret = NF90_PUT_ATT(ncid, ndayid, 'units', 'days')
-         nret = NF90_PUT_ATT(ncid, nscaling_id, 'long_name', 'scaling factor for mass of calving berg')
-         nret = NF90_PUT_ATT(ncid, nscaling_id, 'units', 'none')
-         nret = NF90_PUT_ATT(ncid, nmass_of_bits_id, 'long_name', 'mass of bergy bits')
-         nret = NF90_PUT_ATT(ncid, nmass_of_bits_id, 'units', 'kg')
-         nret = NF90_PUT_ATT(ncid, nheat_density_id, 'long_name', 'heat density')
-         nret = NF90_PUT_ATT(ncid, nheat_density_id, 'units', 'J/kg')
-
-      ENDIF ! associated(first_berg)
-
-      ! End define mode
-      nret = NF90_ENDDEF(ncid)
-
-      ! --------------------------------
-      ! now write some data
-
-      nstrt3(1) = 1
-      nstrt3(2) = 1
-      nlngth3(1) = jpi
-      nlngth3(2) = jpj
-      nlngth3(3) = 1
-
-      DO jn=1,nclasses
-         griddata(:,:,1) = berg_grid%stored_ice(:,:,jn)
-         nstrt3(3) = jn
-         nret = NF90_PUT_VAR( ncid, nsiceid, griddata, nstrt3, nlngth3 )
-         IF (nret .ne. NF90_NOERR) THEN
-            IF( lwp ) WRITE(numout,*) TRIM(NF90_STRERROR( nret ))
-            CALL ctl_stop('icebergs, write_restart: nf_put_var stored_ice failed')
-         ENDIF
-      ENDDO
-      IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: stored_ice  written'
-
-      nret = NF90_PUT_VAR( ncid, nkountid, num_bergs(:) )
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var kount failed')
-
-      nret = NF90_PUT_VAR( ncid, nsheatid, berg_grid%stored_heat(:,:) )
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var stored_heat failed')
-      IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: stored_heat written'
-
-      nret = NF90_PUT_VAR( ncid, ncalvid , src_calving(:,:) )
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving failed')
-      nret = NF90_PUT_VAR( ncid, ncalvhid, src_calving_hflx(:,:) )
-      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving_hflx failed')
-      IF( lwp ) WRITE(numout,*) 'file: ',TRIM(cl_path)//TRIM(cl_filename),' var: calving written'
-
-      IF ( ASSOCIATED(first_berg) ) THEN
-
-         ! Write variables
-         ! just write out the current point of the trajectory
-
-         this => first_berg
-         jn = 0
-         DO WHILE (ASSOCIATED(this))
-            pt => this%current_point
-            jn=jn+1
-
-            nret = NF90_PUT_VAR(ncid, numberid, this%number, (/1,jn/), (/nkounts,1/) )
-            nret = NF90_PUT_VAR(ncid, nscaling_id, this%mass_scaling, (/ jn /) )
-
-            nret = NF90_PUT_VAR(ncid, nlonid, pt%lon, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nlatid, pt%lat, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nxid, pt%xi, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nyid, pt%yj, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nuvelid, pt%uvel, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nvvelid, pt%vvel, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nmassid, pt%mass, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nthicknessid, pt%thickness, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nwidthid, pt%width, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nlengthid, pt%length, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nyearid, pt%year, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, ndayid, pt%day, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nmass_of_bits_id, pt%mass_of_bits, (/ jn /) )
-            nret = NF90_PUT_VAR(ncid, nheat_density_id, pt%heat_density, (/ jn /) )
-
-            this=>this%next
-         END DO
-         !
-      ENDIF ! associated(first_berg)
-
-      ! Finish up
-      nret = NF90_CLOSE(ncid)
-      IF (nret /= NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_close failed')
-      !
    END SUBROUTINE icb_rst_write
    !
Index: /NEMO/trunk/src/OCE/ICB/icbstp.F90
===================================================================
--- /NEMO/trunk/src/OCE/ICB/icbstp.F90	(revision 9931)
+++ /NEMO/trunk/src/OCE/ICB/icbstp.F90	(revision 9932)
@@ -71,5 +71,5 @@
       nktberg = kt
       !
-      IF( nn_test_icebergs < 0 ) THEN     !* read calving data
+      IF( nn_test_icebergs < 0 .OR. ln_use_calving ) THEN !* read calving data
          !
          CALL fld_read ( kt, 1, sf_icb )
@@ -99,5 +99,5 @@
                                      CALL icb_clv_flx( kt )   ! Accumulate ice from calving
       !                              !
-                                     CALL icb_clv()           ! Calve excess stored ice into icebergs
+                                     CALL icb_clv( kt )       ! Calve excess stored ice into icebergs
       !                              !
       !
