Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 3359)
@@ -442,9 +442,9 @@
                CALL histdef( nid_T, "berg_melt"           , "Melt rate of icebergs"                    , "kg/m2/s", &
                   &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "berg_melt_buoy"      , "Buoyancy component of iceberg melt rate"  , "kg/m2/s", &
+               CALL histdef( nid_T, "berg_buoy_melt"      , "Buoyancy component of iceberg melt rate"  , "kg/m2/s", &
                   &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "berg_melt_eros"      , "Erosion component of iceberg melt rate"   , "kg/m2/s", &
+               CALL histdef( nid_T, "berg_eros_melt"      , "Erosion component of iceberg melt rate"   , "kg/m2/s", &
                   &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "berg_melt_conv"      , "Convective component of iceberg melt rate", "kg/m2/s", &
+               CALL histdef( nid_T, "berg_conv_melt"      , "Convective component of iceberg melt rate", "kg/m2/s", &
                   &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
                CALL histdef( nid_T, "berg_virtual_area"   , "Virtual coverage by icebergs"             , "m2"     , &
@@ -628,11 +628,11 @@
          IF( ln_bergdia ) THEN
             CALL histwrite( nid_T, "berg_melt"           , it, berg_melt        , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "berg_melt_buoy"      , it, melt_buoy        , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "berg_melt_eros"      , it, melt_eros        , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "berg_melt_conv"      , it, melt_conv        , ndim_hT, ndex_hT   )  
+            CALL histwrite( nid_T, "berg_buoy_melt"      , it, buoy_melt        , ndim_hT, ndex_hT   )  
+            CALL histwrite( nid_T, "berg_eros_melt"      , it, eros_melt        , ndim_hT, ndex_hT   )  
+            CALL histwrite( nid_T, "berg_conv_melt"      , it, conv_melt        , ndim_hT, ndex_hT   )  
             CALL histwrite( nid_T, "berg_virtual_area"   , it, virtual_area     , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "bits_src"           , it, bits_src        , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "bits_melt"          , it, bits_melt       , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "bits_mass"          , it, bits_mass       , ndim_hT, ndex_hT   )  
+            CALL histwrite( nid_T, "bits_src"            , it, bits_src         , ndim_hT, ndex_hT   )  
+            CALL histwrite( nid_T, "bits_melt"           , it, bits_melt        , ndim_hT, ndex_hT   )  
+            CALL histwrite( nid_T, "bits_mass"           , it, bits_mass        , ndim_hT, ndex_hT   )  
             CALL histwrite( nid_T, "berg_mass"           , it, berg_mass        , ndim_hT, ndex_hT   )  
             !
Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icb_oce.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icb_oce.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icb_oce.F90	(revision 3359)
@@ -88,6 +88,6 @@
    INTEGER                         ::   current_year
    REAL(wp)                        ::   current_yearday            ! 1.00-365.99
-   REAL(wp), DIMENSION(:), POINTER ::   initial_width, initial_length
-   LOGICAL                         ::   restarted_bergs=.false.          ! Indicate whether we read state from a restart or not
+   REAL(wp), DIMENSION(:), POINTER ::   first_width, first_length
+   LOGICAL                         ::   l_restarted_bergs=.FALSE.          ! Indicate whether we read state from a restart or not
    !                                                           ! arbitrary numbers for diawri entry
    REAL(wp), DIMENSION(nclasses), PUBLIC ::   class_num=(/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 /)
@@ -107,15 +107,15 @@
 
    !!gm almost all those PARAM ARE defined in NEMO
-   REAL(wp), PUBLIC, PARAMETER :: rho_ice      = 916.7_wp   ! Density of fresh ice @ 0oC (kg/m^3)
-   REAL(wp), PUBLIC, PARAMETER :: rho_water    = 999.8_wp   ! Density of fresh water @ 0oC (kg/m^3)
-   REAL(wp), PUBLIC, PARAMETER :: rho_air      = 1.1_wp     ! Density of air @ 0oC (kg/m^3) ???
-   REAL(wp), PUBLIC, PARAMETER :: rho_seawater = 1025._wp   ! Approx. density of surface sea water @ 0oC (kg/m^3)
+   REAL(wp), PUBLIC, PARAMETER :: pp_rho_ice      = 916.7_wp   ! Density of fresh ice @ 0oC (kg/m^3)
+   REAL(wp), PUBLIC, PARAMETER :: pp_rho_water    = 999.8_wp   ! Density of fresh water @ 0oC (kg/m^3)
+   REAL(wp), PUBLIC, PARAMETER :: pp_rho_air      = 1.1_wp     ! Density of air @ 0oC (kg/m^3) ???
+   REAL(wp), PUBLIC, PARAMETER :: pp_rho_seawater = 1025._wp   ! Approx. density of surface sea water @ 0oC (kg/m^3)
    !!gm end
-   REAL(wp), PUBLIC, PARAMETER :: Cd_av = 1.3_wp      ! (Vertical) Drag coefficient between bergs and atmos (?)
-   REAL(wp), PUBLIC, PARAMETER :: Cd_ah = 0.0055_wp   ! (Horizontal) Drag coefficient between bergs and atmos (?)
-   REAL(wp), PUBLIC, PARAMETER :: Cd_wv = 0.9_wp      ! (Vertical) Drag coefficient between bergs and ocean (?)
-   REAL(wp), PUBLIC, PARAMETER :: Cd_wh = 0.0012_wp   ! (Horizontal) Drag coefficient between bergs and ocean (?)
-   REAL(wp), PUBLIC, PARAMETER :: Cd_iv = 0.9_wp      ! (Vertical) Drag coefficient between bergs and sea-ice (?)
-   !TOM> no horizontal drag for sea ice! real, PARAMETER :: Cd_ih=0.0012 ! (Horizontal) Drag coefficient between bergs and sea-ice (?)
+   REAL(wp), PUBLIC, PARAMETER :: pp_Cd_av = 1.3_wp      ! (Vertical) Drag coefficient between bergs and atmos (?)
+   REAL(wp), PUBLIC, PARAMETER :: pp_Cd_ah = 0.0055_wp   ! (Horizontal) Drag coefficient between bergs and atmos (?)
+   REAL(wp), PUBLIC, PARAMETER :: pp_Cd_wv = 0.9_wp      ! (Vertical) Drag coefficient between bergs and ocean (?)
+   REAL(wp), PUBLIC, PARAMETER :: pp_Cd_wh = 0.0012_wp   ! (Horizontal) Drag coefficient between bergs and ocean (?)
+   REAL(wp), PUBLIC, PARAMETER :: pp_Cd_iv = 0.9_wp      ! (Vertical) Drag coefficient between bergs and sea-ice (?)
+   !TOM> no horizontal drag for sea ice! real, PARAMETER :: pp_Cd_ih=0.0012 ! (Horizontal) Drag coefficient between bergs and sea-ice (?)
 
    !                                           !** namberg namelist parameters (and defaults) **
@@ -147,14 +147,14 @@
 
    ! Single instance of an icebergs type initialised in icebergs_init and updated in icebergs_run
-   REAL(wp), ALLOCATABLE, PUBLIC, SAVE, DIMENSION(:,:)     ::   p_calving, p_calving_hflx
+   REAL(wp), ALLOCATABLE, PUBLIC, SAVE, DIMENSION(:,:)     ::   src_calving, src_calving_hflx
    INTEGER              , PUBLIC, SAVE                     ::   numicb 
-   INTEGER              , PUBLIC, SAVE, DIMENSION(nkounts) ::   kount_bergs
-   INTEGER              , PUBLIC, SAVE                     ::   icbdi, icbei, icbdj, icbej
-   REAL(wp)             , PUBLIC, SAVE                     ::   icb_left, icb_right
-   INTEGER              , PUBLIC, SAVE                     ::   icbpack
-   INTEGER              , PUBLIC, SAVE                     ::   ktberg, knberg
-   INTEGER, ALLOCATABLE , PUBLIC, SAVE, DIMENSION(:)       ::   icbfldpts
-   INTEGER, ALLOCATABLE , PUBLIC, SAVE, DIMENSION(:)       ::   icbflddest
-   INTEGER, ALLOCATABLE , PUBLIC, SAVE, DIMENSION(:)       ::   icbfldproc
+   INTEGER              , PUBLIC, SAVE, DIMENSION(nkounts) ::   num_bergs
+   INTEGER              , PUBLIC, SAVE                     ::   nicbdi, nicbei, nicbdj, nicbej
+   REAL(wp)             , PUBLIC, SAVE                     ::   ricb_left, ricb_right
+   INTEGER              , PUBLIC, SAVE                     ::   nicbpack
+   INTEGER              , PUBLIC, SAVE                     ::   nktberg, nknberg
+   INTEGER, ALLOCATABLE , PUBLIC, SAVE, DIMENSION(:)       ::   nicbfldpts
+   INTEGER, ALLOCATABLE , PUBLIC, SAVE, DIMENSION(:)       ::   nicbflddest
+   INTEGER, ALLOCATABLE , PUBLIC, SAVE, DIMENSION(:)       ::   nicbfldproc
 
    TYPE(FLD), ALLOCATABLE, PUBLIC     , DIMENSION(:)       ::   sf_icb       ! structure: file information, fields read
Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbclv.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbclv.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbclv.F90	(revision 3359)
@@ -14,5 +14,4 @@
    !!   accumulate_calving      :
    !!   icb_gen       : generate test icebergs
-   !!   icb_nam       : read iceberg namelist
    !!----------------------------------------------------------------------
    USE par_oce        ! NEMO parameters
@@ -29,6 +28,6 @@
    PRIVATE
 
-   PUBLIC   accumulate_calving  ! routine called in xxx.F90 module
-   PUBLIC   calve_icebergs      ! routine called in xxx.F90 module
+   PUBLIC   accumulate_calving  ! routine called in icbrun.F90 module
+   PUBLIC   calve_icebergs      ! routine called in icbrun.F90 module
 
 CONTAINS
@@ -43,8 +42,10 @@
       !!----------------------------------------------------------------------
       !
-      INTEGER                         :: kt
-      REAL(wp)                        :: calving_used, rdist, ufact
-      INTEGER                         :: jn, ji, jj, nmax
-      LOGICAL, SAVE                   :: first_call = .TRUE.
+      INTEGER, INTENT(in)             :: kt
+      !
+      REAL(wp)                        :: zcalving_used, zdist, zfact
+      INTEGER                         :: jn, ji, jj                    ! loop counters
+      INTEGER                         :: imx                           ! temporary integer for max berg class
+      LOGICAL, SAVE                   :: ll_first_call = .TRUE.
       !!----------------------------------------------------------------------
       !
@@ -52,12 +53,12 @@
       ! Use interior mask: so no bergs in overlap areas and convert from km^3/year to kg/s
       ! this assumes that input is given as equivalent water flux so that pure water density is appropriate
-      ufact = ( (1000._wp)**3 / ( NINT(rday) * nyear_len(1) ) ) * 1000._wp
-      berg_grid%calving(:,:) = p_calving(:,:) * tmask_i(:,:) * ufact
+      zfact = ( (1000._wp)**3 / ( NINT(rday) * nyear_len(1) ) ) * 1000._wp
+      berg_grid%calving(:,:) = src_calving(:,:) * tmask_i(:,:) * zfact
 
       ! Heat in units of W/m2, and mask (just in case)
-      berg_grid%calving_hflx(:,:) = p_calving_hflx(:,:) * tmask_i(:,:)
+      berg_grid%calving_hflx(:,:) = src_calving_hflx(:,:) * tmask_i(:,:)
 
-      IF( first_call .AND. .NOT.restarted_bergs) THEN      ! This is a hack to simplify initialization
-         first_call = .FALSE.
+      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
          !  where (berg_grid%calving==0.) berg_grid%stored_ice(:,:,jn)=0.
@@ -77,9 +78,9 @@
       DO jj = 1,jpj
          DO ji = 1,jpi
-            nmax = berg_grid%maxclass(ji,jj)
-            rdist = SUM( rn_distribution(1:nclasses) ) / SUM( rn_distribution(1:nmax) )
-            DO jn = 1, nmax
+            imx = berg_grid%maxclass(ji,jj)
+            zdist = SUM( rn_distribution(1:nclasses) ) / SUM( rn_distribution(1:imx) )
+            DO jn = 1, imx
                berg_grid%stored_ice(ji,jj,jn) = berg_grid%stored_ice(ji,jj,jn) + &
-                                          berg_dt * berg_grid%calving(ji,jj) * rn_distribution(jn) * rdist
+                                          berg_dt * berg_grid%calving(ji,jj) * rn_distribution(jn) * zdist
             END DO
          END DO
@@ -87,12 +88,10 @@
 
       ! before changing the calving, save the amount we're about to use and do budget
-      calving_used = SUM( berg_grid%calving(:,:) )
+      zcalving_used = SUM( berg_grid%calving(:,:) )
       berg_grid%tmp(:,:) = berg_dt * berg_grid%calving_hflx(:,:) * e1e2t(:,:) * tmask_i(:,:)
       berg_grid%stored_heat (:,:) = berg_grid%stored_heat (:,:) + berg_grid%tmp(:,:)
-      CALL incoming_budget( kt,  calving_used, berg_grid%tmp )
+      CALL incoming_budget( kt,  zcalving_used, berg_grid%tmp )
       !
    END SUBROUTINE accumulate_calving
-
-! ##############################################################################
 
    SUBROUTINE calve_icebergs()
@@ -114,7 +113,6 @@
       TYPE(iceberg)                   ::   newberg
       TYPE(point)                     ::   newpt
-      LOGICAL                         ::   lret
-      INTEGER                         ::   ji, jj, jn   ! dummy loop indices
-      REAL(wp)                        ::   xi, yj, ddt, calved_to_berg, heat_to_berg
+      INTEGER                         ::   ji, jj, jn                             ! dummy loop indices
+      REAL(wp)                        ::   zddt, zcalved_to_berg, zheat_to_berg
       !!----------------------------------------------------------------------
 
@@ -122,8 +120,8 @@
 
       DO jn = 1, nclasses
-         DO jj = icbdj, icbej
-            DO ji = icbdi, icbei
+         DO jj = nicbdj, nicbej
+            DO ji = nicbdi, nicbei
                !
-               ddt  = 0._wp
+               zddt  = 0._wp
                icnt = 0
                !
@@ -140,29 +138,29 @@
                   newpt%mass         = rn_initial_mass     (jn)
                   newpt%thickness    = rn_initial_thickness(jn)
-                  newpt%width        = initial_width    (jn)
-                  newpt%length       = initial_length   (jn)
+                  newpt%width        = first_width    (jn)
+                  newpt%length       = first_length   (jn)
                   newberg%mass_scaling = rn_mass_scaling     (jn)
                   newpt%mass_of_bits = 0._wp                          ! no bergy
                   !
                   newpt%year   = current_year
-                  newpt%day    = current_yearday + ddt / rday
+                  newpt%day    = current_yearday + zddt / rday
                   newpt%heat_density = berg_grid%stored_heat(ji,jj) / berg_grid%stored_ice(ji,jj,jn)   ! This is in J/kg
                   !
                   CALL increment_kounter()
-                  newberg%number(:) = kount_bergs(:)
+                  newberg%number(:) = num_bergs(:)
                   !
                   CALL add_new_berg_to_list( newberg, newpt )
                   !
-                  calved_to_berg = rn_initial_mass(jn) * rn_mass_scaling(jn)           ! Units of kg
+                  zcalved_to_berg = rn_initial_mass(jn) * rn_mass_scaling(jn)           ! Units of kg
                   !                                ! Heat content
-                  heat_to_berg           = calved_to_berg * newpt%heat_density             ! Units of J
-                  berg_grid%stored_heat(ji,jj) = berg_grid%stored_heat(ji,jj) - heat_to_berg
+                  zheat_to_berg           = zcalved_to_berg * newpt%heat_density             ! Units of J
+                  berg_grid%stored_heat(ji,jj) = berg_grid%stored_heat(ji,jj) - zheat_to_berg
                   !                                ! Stored mass
-                  berg_grid%stored_ice(ji,jj,jn)   = berg_grid%stored_ice(ji,jj,jn) - calved_to_berg
+                  berg_grid%stored_ice(ji,jj,jn)   = berg_grid%stored_ice(ji,jj,jn) - zcalved_to_berg
                   !
-                  ddt  = ddt + berg_dt * 2._wp / 17._wp    ! Minor offset to start day    !!gm why???
+                  zddt  = zddt + berg_dt * 2._wp / 17._wp    ! Minor offset to start day    !!gm why???
                   icnt = icnt + 1
                   !
-                  CALL calving_budget(ji, jj, jn,  calved_to_berg, heat_to_berg )
+                  CALL calving_budget(ji, jj, jn,  zcalved_to_berg, zheat_to_berg )
                END DO
                icntmax = MAX( icntmax, icnt )
Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbdia.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbdia.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbdia.F90	(revision 3359)
@@ -30,32 +30,32 @@
 
    REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: berg_melt=>NULL()    ! Melting+erosion rate of icebergs (kg/s/m^2)
-   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: melt_buoy=>NULL()    ! Buoyancy component of melting rate (kg/s/m^2)
-   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: melt_eros=>NULL()    ! Erosion component of melting rate (kg/s/m^2)
-   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: melt_conv=>NULL()    ! Convective component of melting rate (kg/s/m^2)
-   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: bits_src=>NULL()    ! Mass flux from berg erosion into bergy bits (kg/s/m^2)
-   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: bits_melt=>NULL()   ! Melting rate of bergy bits (kg/s/m^2)
-   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: bits_mass=>NULL()   ! Mass distribution of bergy bits (kg/s/m^2)
+   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: buoy_melt=>NULL()    ! Buoyancy component of melting rate (kg/s/m^2)
+   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: eros_melt=>NULL()    ! Erosion component of melting rate (kg/s/m^2)
+   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: conv_melt=>NULL()    ! Convective component of melting rate (kg/s/m^2)
+   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: bits_src=>NULL()     ! Mass flux from berg erosion into bergy bits (kg/s/m^2)
+   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: bits_melt=>NULL()    ! Melting rate of bergy bits (kg/s/m^2)
+   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: bits_mass=>NULL()    ! Mass distribution of bergy bits (kg/s/m^2)
    REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: virtual_area=>NULL() ! Virtual surface coverage by icebergs (m^2)
-   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: berg_mass=>NULL()         ! Mass distribution (kg/m^2)
+   REAL(wp), DIMENSION(:,:)  , POINTER, PUBLIC  :: berg_mass=>NULL()    ! Mass distribution (kg/m^2)
    REAL(wp), DIMENSION(:,:,:), POINTER, PUBLIC  :: real_calving=>NULL() ! Calving rate into iceberg class at calving locations (kg/s)
    REAL(wp), DIMENSION(:,:)  , POINTER, PRIVATE :: tmpc=>NULL()         ! Temporary work space
-   REAL(wp), DIMENSION(:)    , POINTER, PRIVATE :: zsumbuf=>NULL()         ! Temporary work space
-   INTEGER , DIMENSION(:)    , POINTER, PRIVATE :: isumbuf=>NULL()         ! Temporary work space
-
-   REAL(wp)                           , PRIVATE ::  net_berg_melt
-   REAL(wp)                           , PRIVATE ::  net_bits_src
-   REAL(wp)                           , PRIVATE ::  net_bits_melt
+   REAL(wp), DIMENSION(:)    , POINTER, PRIVATE :: rsumbuf=>NULL()      ! Temporary work space to reduce mpp exchanges
+   INTEGER , DIMENSION(:)    , POINTER, PRIVATE :: nsumbuf=>NULL()      ! Temporary work space to reduce mpp exchanges
+
+   REAL(wp)                           , PRIVATE ::  berg_melt_net
+   REAL(wp)                           , PRIVATE ::  bits_src_net
+   REAL(wp)                           , PRIVATE ::  bits_melt_net
    REAL(wp)                           , PRIVATE ::  bits_mass_start, bits_mass_end
    REAL(wp)                           , PRIVATE ::  floating_heat_start, floating_heat_end
    REAL(wp)                           , PRIVATE ::  floating_mass_start, floating_mass_end
-   REAL(wp)                           , PRIVATE ::  icebergs_mass_start, icebergs_mass_end
+   REAL(wp)                           , PRIVATE ::  bergs_mass_start, bergs_mass_end
    REAL(wp)                           , PRIVATE ::  stored_start, stored_heat_start
    REAL(wp)                           , PRIVATE ::  stored_end  , stored_heat_end
-   REAL(wp)                           , PRIVATE ::  net_incoming_calving, net_outgoing_calving
-   REAL(wp)                           , PRIVATE ::  net_incoming_calving_heat, net_outgoing_calving_heat
-   REAL(wp)                           , PRIVATE ::  net_incoming_calving_heat_used
-   REAL(wp)                           , PRIVATE ::  net_calving_received, net_calving_returned, net_calving_used
-   REAL(wp)                           , PRIVATE ::  net_heat_to_bergs, net_heat_to_ocean, net_melt
-   REAL(wp)                           , PRIVATE ::  net_calving_to_bergs
+   REAL(wp)                           , PRIVATE ::  calving_src_net, calving_out_net
+   REAL(wp)                           , PRIVATE ::  calving_src_heat_net, calving_out_heat_net
+   REAL(wp)                           , PRIVATE ::  calving_src_heat_used_net
+   REAL(wp)                           , PRIVATE ::  calving_rcv_net, calving_ret_net, calving_used_net
+   REAL(wp)                           , PRIVATE ::  heat_to_bergs_net, heat_to_ocean_net, melt_net
+   REAL(wp)                           , PRIVATE ::  calving_to_bergs_net
 
    INTEGER                            , PRIVATE ::  nbergs_start, nbergs_end, nbergs_calved
@@ -64,14 +64,14 @@
    INTEGER , DIMENSION(nclasses)      , PRIVATE ::  nbergs_calved_by_class
 
-   PUBLIC   icb_budget_end  ! routine called in xxx.F90 module
-   PUBLIC   icb_budget_init ! routine called in xxx.F90 module
-   PUBLIC   icb_budget      ! routine called in xxx.F90 module
-   PUBLIC   icb_budget_step ! routine called in xxx.F90 module
-   PUBLIC   icb_budget_put  ! routine called in xxx.F90 module
-   PUBLIC   melt_budget     ! routine called in xxx.F90 module
-   PUBLIC   size_budget     ! routine called in xxx.F90 module
-   PUBLIC   speed_budget     ! routine called in xxx.F90 module
-   PUBLIC   calving_budget  ! routine called in xxx.F90 module
-   PUBLIC   incoming_budget   ! routine called in xxx.F90 module
+   PUBLIC   icb_budget_end  ! routine called in icbrun.F90 module
+   PUBLIC   icb_budget_init ! routine called in icbini.F90 module
+   PUBLIC   icb_budget      ! routine called in icbrun.F90 module
+   PUBLIC   icb_budget_step ! routine called in icbrun.F90 module
+   PUBLIC   icb_budget_put  ! routine called in icbrun.F90 module
+   PUBLIC   melt_budget     ! routine called in icbthm.F90 module
+   PUBLIC   size_budget     ! routine called in icbthm.F90 module
+   PUBLIC   speed_budget    ! routine called in icbdyn.F90 module
+   PUBLIC   calving_budget  ! routine called in icbclv.F90 module
+   PUBLIC   incoming_budget ! routine called in icbclv.F90 module
 
 CONTAINS
@@ -83,7 +83,7 @@
       IF( .NOT. ln_bergdia ) RETURN
       DEALLOCATE( berg_melt )
-      DEALLOCATE( melt_buoy )
-      DEALLOCATE( melt_eros )
-      DEALLOCATE( melt_conv )
+      DEALLOCATE( buoy_melt )
+      DEALLOCATE( eros_melt )
+      DEALLOCATE( conv_melt )
       DEALLOCATE( bits_src )
       DEALLOCATE( bits_melt )
@@ -94,6 +94,6 @@
       DEALLOCATE( tmpc )
       IF( lk_mpp ) THEN
-         DEALLOCATE( zsumbuf )
-         DEALLOCATE( isumbuf )
+         DEALLOCATE( rsumbuf )
+         DEALLOCATE( nsumbuf )
       ENDIF
 
@@ -106,10 +106,10 @@
       IF( .NOT. ln_bergdia ) RETURN
       ALLOCATE( berg_melt    (jpi,jpj)   )           ;   berg_melt    (:,:) = 0._wp
-      ALLOCATE( melt_buoy    (jpi,jpj)   )           ;   melt_buoy    (:,:) = 0._wp
-      ALLOCATE( melt_eros    (jpi,jpj)   )           ;   melt_eros    (:,:) = 0._wp
-      ALLOCATE( melt_conv    (jpi,jpj)   )           ;   melt_conv    (:,:) = 0._wp
-      ALLOCATE( bits_src    (jpi,jpj)   )           ;   bits_src    (:,:) = 0._wp
-      ALLOCATE( bits_melt   (jpi,jpj)   )           ;   bits_melt   (:,:) = 0._wp
-      ALLOCATE( bits_mass   (jpi,jpj)   )           ;   bits_mass   (:,:) = 0._wp
+      ALLOCATE( buoy_melt    (jpi,jpj)   )           ;   buoy_melt    (:,:) = 0._wp
+      ALLOCATE( eros_melt    (jpi,jpj)   )           ;   eros_melt    (:,:) = 0._wp
+      ALLOCATE( conv_melt    (jpi,jpj)   )           ;   conv_melt    (:,:) = 0._wp
+      ALLOCATE( bits_src     (jpi,jpj)   )           ;   bits_src    (:,:) = 0._wp
+      ALLOCATE( bits_melt    (jpi,jpj)   )           ;   bits_melt   (:,:) = 0._wp
+      ALLOCATE( bits_mass    (jpi,jpj)   )           ;   bits_mass   (:,:) = 0._wp
       ALLOCATE( virtual_area (jpi,jpj)   )           ;   virtual_area (:,:) = 0._wp
       ALLOCATE( berg_mass    (jpi,jpj)   )           ;   berg_mass    (:,:) = 0._wp
@@ -117,53 +117,53 @@
       ALLOCATE( tmpc(jpi,jpj) )                      ;   tmpc(:,:)=0.
 
-      nbergs_start                   = 0
-      nbergs_end                     = 0
-      stored_end                     = 0._wp
-      nbergs_start                   = 0._wp
-      stored_start                   = 0._wp
-      nbergs_melted                  = 0
-      nbergs_calved                  = 0
-      nbergs_calved_by_class(:)      = 0
-      nspeeding_tickets              = 0
-      stored_heat_end                = 0._wp
-      floating_heat_end              = 0._wp
-      floating_mass_end              = 0._wp
-      icebergs_mass_end              = 0._wp
-      bits_mass_end                 = 0._wp
-      stored_heat_start              = 0._wp
-      floating_heat_start            = 0._wp
-      floating_mass_start            = 0._wp
-      icebergs_mass_start            = 0._wp
-      bits_mass_start               = 0._wp
-      bits_mass_end                 = 0._wp
-      net_calving_used               = 0._wp
-      net_calving_to_bergs           = 0._wp
-      net_heat_to_bergs              = 0._wp
-      net_heat_to_ocean              = 0._wp
-      net_calving_received           = 0._wp
-      net_calving_returned           = 0._wp
-      net_incoming_calving           = 0._wp
-      net_outgoing_calving           = 0._wp
-      net_incoming_calving_heat      = 0._wp
-      net_incoming_calving_heat_used = 0._wp
-      net_outgoing_calving_heat      = 0._wp
-      net_melt                       = 0._wp
-      net_berg_melt                  = 0._wp
-      net_bits_melt                 = 0._wp
-      net_bits_src                  = 0._wp
-
-      floating_mass_start            = sum_mass( first_berg )
-      icebergs_mass_start            = sum_mass( first_berg, justbergs=.true. )
-      bits_mass_start               = sum_mass( first_berg, justbits=.true. )
+      nbergs_start              = 0
+      nbergs_end                = 0
+      stored_end                = 0._wp
+      nbergs_start              = 0._wp
+      stored_start              = 0._wp
+      nbergs_melted             = 0
+      nbergs_calved             = 0
+      nbergs_calved_by_class(:) = 0
+      nspeeding_tickets         = 0
+      stored_heat_end           = 0._wp
+      floating_heat_end         = 0._wp
+      floating_mass_end         = 0._wp
+      bergs_mass_end            = 0._wp
+      bits_mass_end             = 0._wp
+      stored_heat_start         = 0._wp
+      floating_heat_start       = 0._wp
+      floating_mass_start       = 0._wp
+      bergs_mass_start          = 0._wp
+      bits_mass_start           = 0._wp
+      bits_mass_end             = 0._wp
+      calving_used_net          = 0._wp
+      calving_to_bergs_net      = 0._wp
+      heat_to_bergs_net         = 0._wp
+      heat_to_ocean_net         = 0._wp
+      calving_rcv_net           = 0._wp
+      calving_ret_net           = 0._wp
+      calving_src_net           = 0._wp
+      calving_out_net           = 0._wp
+      calving_src_heat_net      = 0._wp
+      calving_src_heat_used_net = 0._wp
+      calving_out_heat_net      = 0._wp
+      melt_net                  = 0._wp
+      berg_melt_net             = 0._wp
+      bits_melt_net             = 0._wp
+      bits_src_net              = 0._wp
+
+      floating_mass_start       = sum_mass( first_berg )
+      bergs_mass_start          = sum_mass( first_berg, justbergs=.true. )
+      bits_mass_start           = sum_mass( first_berg, justbits=.true. )
       IF( lk_mpp ) THEN
-         ALLOCATE( zsumbuf(23) )          ; zsumbuf(:) = 0._wp
-         ALLOCATE( isumbuf(4+nclasses) )  ; isumbuf(:) = 0
-         zsumbuf(1) = floating_mass_start
-         zsumbuf(2) = icebergs_mass_start
-         zsumbuf(3) = bits_mass_start
-         CALL mpp_sum( zsumbuf(1:3), 3 )
-         floating_mass_start = zsumbuf(1)
-         icebergs_mass_start = zsumbuf(2)
-         bits_mass_start = zsumbuf(3)
+         ALLOCATE( rsumbuf(23) )          ; rsumbuf(:) = 0._wp
+         ALLOCATE( nsumbuf(4+nclasses) )  ; nsumbuf(:) = 0
+         rsumbuf(1) = floating_mass_start
+         rsumbuf(2) = bergs_mass_start
+         rsumbuf(3) = bits_mass_start
+         CALL mpp_sum( rsumbuf(1:3), 3 )
+         floating_mass_start = rsumbuf(1)
+         bergs_mass_start = rsumbuf(2)
+         bits_mass_start = rsumbuf(3)
       ENDIF
 
@@ -172,186 +172,186 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE icb_budget( lbudge )
+   SUBROUTINE icb_budget( ld_budge )
       ! Arguments
-      LOGICAL                         ::   lbudge
+      LOGICAL, INTENT(in)             ::   ld_budge
       ! Local variables
-      INTEGER                         ::   k
-      REAL(wp)                        ::   unused_calving, tmpsum, grdd_berg_mass, grdd_bits_mass
-
-      IF( .NOT. ln_bergdia ) RETURN
-
-      unused_calving            = SUM( berg_grid%calving(:,:) )
-      tmpsum                    = SUM( berg_grid%floating_melt(:,:) * e1e2t(:,:) * tmask_i(:,:) )
-      net_melt                  = net_melt + tmpsum * berg_dt
-      net_outgoing_calving      = net_outgoing_calving + ( unused_calving + tmpsum ) * berg_dt
-      tmpsum                    = SUM( berg_melt(:,:) * e1e2t(:,:) * tmask_i(:,:) )
-      net_berg_melt             = net_berg_melt + tmpsum * berg_dt
-      tmpsum                    = SUM( bits_src(:,:) * e1e2t(:,:) * tmask_i(:,:) )
-      net_bits_src             = net_bits_src + tmpsum * berg_dt
-      tmpsum                    = SUM( bits_melt(:,:) * e1e2t(:,:) * tmask_i(:,:) )
-      net_bits_melt            = net_bits_melt + tmpsum * berg_dt
-      tmpsum                    = SUM( p_calving(:,:) * tmask_i(:,:) )
-      net_calving_returned      = net_calving_returned+tmpsum * berg_dt
-      tmpsum                    = SUM( berg_grid%calving_hflx(:,:) * e1e2t(:,:) * tmask_i(:,:) )
-      net_outgoing_calving_heat = net_outgoing_calving_heat + tmpsum * berg_dt   ! Units of J
-
-      IF( lbudge ) THEN
+      INTEGER                         ::   ik
+      REAL(wp)                        ::   zunused_calving, ztmpsum, zgrdd_berg_mass, zgrdd_bits_mass
+
+      IF( .NOT. ln_bergdia ) RETURN
+
+      zunused_calving           = SUM( berg_grid%calving(:,:) )
+      ztmpsum                   = SUM( berg_grid%floating_melt(:,:) * e1e2t(:,:) * tmask_i(:,:) )
+      melt_net                  = melt_net + ztmpsum * berg_dt
+      calving_out_net           = calving_out_net + ( zunused_calving + ztmpsum ) * berg_dt
+      ztmpsum                   = SUM( berg_melt(:,:) * e1e2t(:,:) * tmask_i(:,:) )
+      berg_melt_net             = berg_melt_net + ztmpsum * berg_dt
+      ztmpsum                   = SUM( bits_src(:,:) * e1e2t(:,:) * tmask_i(:,:) )
+      bits_src_net              = bits_src_net + ztmpsum * berg_dt
+      ztmpsum                   = SUM( bits_melt(:,:) * e1e2t(:,:) * tmask_i(:,:) )
+      bits_melt_net             = bits_melt_net + ztmpsum * berg_dt
+      ztmpsum                   = SUM( src_calving(:,:) * tmask_i(:,:) )
+      calving_ret_net           = calving_ret_net + ztmpsum * berg_dt
+      ztmpsum                   = SUM( berg_grid%calving_hflx(:,:) * e1e2t(:,:) * tmask_i(:,:) )
+      calving_out_heat_net      = calving_out_heat_net + ztmpsum * berg_dt   ! Units of J
+
+      IF( ld_budge ) THEN
          stored_end             = SUM( berg_grid%stored_ice(:,:,:) )
          stored_heat_end        = SUM( berg_grid%stored_heat(:,:) )
          floating_mass_end      = sum_mass( first_berg )
-         icebergs_mass_end      = sum_mass( first_berg,justbergs=.true. )
-         bits_mass_end         = sum_mass( first_berg,justbits=.true. )
+         bergs_mass_end         = sum_mass( first_berg,justbergs=.true. )
+         bits_mass_end          = sum_mass( first_berg,justbits=.true. )
          floating_heat_end      = sum_heat( first_berg )
 
          nbergs_end             = count_bergs()
-         grdd_berg_mass         = SUM( berg_mass (:,:)*e1e2t(:,:)*tmask_i(:,:) )
-         grdd_bits_mass        = SUM( bits_mass(:,:)*e1e2t(:,:)*tmask_i(:,:) )
+         zgrdd_berg_mass        = SUM( berg_mass (:,:)*e1e2t(:,:)*tmask_i(:,:) )
+         zgrdd_bits_mass        = SUM( bits_mass(:,:)*e1e2t(:,:)*tmask_i(:,:) )
 
          IF( lk_mpp ) THEN
-            zsumbuf( 1) = stored_end
-            zsumbuf( 2) = stored_heat_end
-            zsumbuf( 3) = floating_mass_end
-            zsumbuf( 4) = icebergs_mass_end
-            zsumbuf( 5) = bits_mass_end
-            zsumbuf( 6) = floating_heat_end
-            zsumbuf( 7) = net_calving_returned
-            zsumbuf( 8) = net_outgoing_calving
-            zsumbuf( 9) = net_calving_received
-            zsumbuf(10) = net_incoming_calving
-            zsumbuf(11) = net_incoming_calving_heat
-            zsumbuf(12) = net_incoming_calving_heat_used
-            zsumbuf(13) = net_outgoing_calving_heat
-            zsumbuf(14) = net_calving_used
-            zsumbuf(15) = net_calving_to_bergs
-            zsumbuf(16) = net_heat_to_bergs
-            zsumbuf(17) = net_heat_to_ocean
-            zsumbuf(18) = net_melt
-            zsumbuf(19) = net_berg_melt
-            zsumbuf(20) = net_bits_src
-            zsumbuf(21) = net_bits_melt
-            zsumbuf(22) = grdd_berg_mass
-            zsumbuf(23) = grdd_bits_mass
-
-            CALL mpp_sum( zsumbuf(1:23), 23)
-
-            stored_end                     = zsumbuf( 1)
-            stored_heat_end                = zsumbuf( 2)
-            floating_mass_end              = zsumbuf( 3)
-            icebergs_mass_end              = zsumbuf( 4)
-            bits_mass_end                 = zsumbuf( 5)
-            floating_heat_end              = zsumbuf( 6)
-            net_calving_returned           = zsumbuf( 7)
-            net_outgoing_calving           = zsumbuf( 8)
-            net_calving_received           = zsumbuf( 9)
-            net_incoming_calving           = zsumbuf(10)
-            net_incoming_calving_heat      = zsumbuf(11)
-            net_incoming_calving_heat_used = zsumbuf(12)
-            net_outgoing_calving_heat      = zsumbuf(13)
-            net_calving_used               = zsumbuf(14)
-            net_calving_to_bergs           = zsumbuf(15)
-            net_heat_to_bergs              = zsumbuf(16)
-            net_heat_to_ocean              = zsumbuf(17)
-            net_melt                       = zsumbuf(18)
-            net_berg_melt                  = zsumbuf(19)
-            net_bits_src                  = zsumbuf(20)
-            net_bits_melt                 = zsumbuf(21)
-            grdd_berg_mass                 = zsumbuf(22)
-            grdd_bits_mass                = zsumbuf(23)
-
-            isumbuf(1) = nbergs_end
-            isumbuf(2) = nbergs_calved
-            isumbuf(3) = nbergs_melted
-            isumbuf(4) = nspeeding_tickets
-            DO k = 1,nclasses
-               isumbuf(4+k) = nbergs_calved_by_class(k)
+            rsumbuf( 1) = stored_end
+            rsumbuf( 2) = stored_heat_end
+            rsumbuf( 3) = floating_mass_end
+            rsumbuf( 4) = bergs_mass_end
+            rsumbuf( 5) = bits_mass_end
+            rsumbuf( 6) = floating_heat_end
+            rsumbuf( 7) = calving_ret_net
+            rsumbuf( 8) = calving_out_net
+            rsumbuf( 9) = calving_rcv_net
+            rsumbuf(10) = calving_src_net
+            rsumbuf(11) = calving_src_heat_net
+            rsumbuf(12) = calving_src_heat_used_net
+            rsumbuf(13) = calving_out_heat_net
+            rsumbuf(14) = calving_used_net
+            rsumbuf(15) = calving_to_bergs_net
+            rsumbuf(16) = heat_to_bergs_net
+            rsumbuf(17) = heat_to_ocean_net
+            rsumbuf(18) = melt_net
+            rsumbuf(19) = berg_melt_net
+            rsumbuf(20) = bits_src_net
+            rsumbuf(21) = bits_melt_net
+            rsumbuf(22) = zgrdd_berg_mass
+            rsumbuf(23) = zgrdd_bits_mass
+
+            CALL mpp_sum( rsumbuf(1:23), 23)
+
+            stored_end                = rsumbuf( 1)
+            stored_heat_end           = rsumbuf( 2)
+            floating_mass_end         = rsumbuf( 3)
+            bergs_mass_end            = rsumbuf( 4)
+            bits_mass_end             = rsumbuf( 5)
+            floating_heat_end         = rsumbuf( 6)
+            calving_ret_net           = rsumbuf( 7)
+            calving_out_net           = rsumbuf( 8)
+            calving_rcv_net           = rsumbuf( 9)
+            calving_src_net           = rsumbuf(10)
+            calving_src_heat_net      = rsumbuf(11)
+            calving_src_heat_used_net = rsumbuf(12)
+            calving_out_heat_net      = rsumbuf(13)
+            calving_used_net          = rsumbuf(14)
+            calving_to_bergs_net      = rsumbuf(15)
+            heat_to_bergs_net         = rsumbuf(16)
+            heat_to_ocean_net         = rsumbuf(17)
+            melt_net                  = rsumbuf(18)
+            berg_melt_net             = rsumbuf(19)
+            bits_src_net              = rsumbuf(20)
+            bits_melt_net             = rsumbuf(21)
+            zgrdd_berg_mass           = rsumbuf(22)
+            zgrdd_bits_mass           = rsumbuf(23)
+
+            nsumbuf(1) = nbergs_end
+            nsumbuf(2) = nbergs_calved
+            nsumbuf(3) = nbergs_melted
+            nsumbuf(4) = nspeeding_tickets
+            DO ik = 1,nclasses
+               nsumbuf(4+ik) = nbergs_calved_by_class(ik)
             ENDDO
 
-            CALL mpp_sum( isumbuf(1:nclasses+4), nclasses+4 )
-
-            nbergs_end        = isumbuf(1)
-            nbergs_calved     = isumbuf(2)
-            nbergs_melted     = isumbuf(3)
-            nspeeding_tickets = isumbuf(4)
-            DO k = 1,nclasses
-               nbergs_calved_by_class(k)= isumbuf(4+k)
+            CALL mpp_sum( nsumbuf(1:nclasses+4), nclasses+4 )
+
+            nbergs_end        = nsumbuf(1)
+            nbergs_calved     = nsumbuf(2)
+            nbergs_melted     = nsumbuf(3)
+            nspeeding_tickets = nsumbuf(4)
+            DO ik = 1,nclasses
+               nbergs_calved_by_class(ik)= nsumbuf(4+ik)
             ENDDO
 
          ENDIF
 
-         CALL report_state('stored ice','kg','',stored_start,'',stored_end,'')
-         CALL report_state('floating','kg','',floating_mass_start,'',floating_mass_end,'',nbergs_end)
-         CALL report_state('icebergs','kg','',icebergs_mass_start,'',icebergs_mass_end,'')
-         CALL report_state('bits','kg','',bits_mass_start,'',bits_mass_end,'')
-         CALL report_istate('berg #','',nbergs_start,'',nbergs_end,'')
-         CALL report_ibudget('berg #','calved',nbergs_calved, &
-                                      'melted',nbergs_melted, &
-                                      '#',nbergs_start,nbergs_end)
-         CALL report_budget('stored mass','kg','calving used',net_calving_used, &
-                                               'bergs',net_calving_to_bergs, &
-                                               'stored mass',stored_start,stored_end)
-         CALL report_budget('floating mass','kg','calving used',net_calving_to_bergs, &
-                                                 'bergs',net_melt, &
-                                                 'stored mass',floating_mass_start,floating_mass_end)
-         CALL report_budget('berg mass','kg','calving',net_calving_to_bergs, &
-                                             'melt+eros',net_berg_melt, &
-                                             'berg mass',icebergs_mass_start,icebergs_mass_end)
-         CALL report_budget('bits mass','kg','eros used',net_bits_src, &
-                                             'bergs',net_bits_melt, &
-                                             'stored mass',bits_mass_start,bits_mass_end)
-         CALL report_budget('net mass','kg','recvd',net_calving_received, &
-                                            'rtrnd',net_calving_returned, &
-                                            'net mass',stored_start+floating_mass_start, &
-                                                       stored_end+floating_mass_end)
-         CALL report_consistant('iceberg mass','kg','gridded',grdd_berg_mass,'bergs',icebergs_mass_end)
-         CALL report_consistant('bits mass','kg','gridded',grdd_bits_mass,'bits',bits_mass_end)
-         CALL report_state('net heat','J','',stored_heat_start+floating_heat_start,'', &
-                                             stored_heat_end+floating_heat_end,'')
-         CALL report_state('stored heat','J','',stored_heat_start,'',stored_heat_end,'')
-         CALL report_state('floating heat','J','',floating_heat_start,'',floating_heat_end,'')
-         CALL report_budget('net heat','J','net heat',net_incoming_calving_heat, &
-                                           'net heat',net_outgoing_calving_heat, &
-                                           'net heat',stored_heat_start+floating_heat_start, &
-                                                      stored_heat_end+floating_heat_end)
-         CALL report_budget('stored heat','J','calving used',net_incoming_calving_heat_used, &
-                                              'bergs',net_heat_to_bergs, &
-                                              'net heat',stored_heat_start,stored_heat_end)
-         CALL report_budget('flting heat','J','calved',net_heat_to_bergs, &
-                                              'melt',net_heat_to_ocean, &
-                                              'net heat',floating_heat_start,floating_heat_end)
+         CALL report_state( 'stored ice','kg','',stored_start,'',stored_end,'')
+         CALL report_state( 'floating','kg','',floating_mass_start,'',floating_mass_end,'',nbergs_end)
+         CALL report_state( 'icebergs','kg','',bergs_mass_start,'',bergs_mass_end,'')
+         CALL report_state( 'bits','kg','',bits_mass_start,'',bits_mass_end,'')
+         CALL report_istate( 'berg #','',nbergs_start,'',nbergs_end,'')
+         CALL report_ibudget( 'berg #','calved',nbergs_calved, &
+                                       'melted',nbergs_melted, &
+                                       '#',nbergs_start,nbergs_end)
+         CALL report_budget( 'stored mass','kg','calving used',calving_used_net, &
+                                           'bergs',calving_to_bergs_net, &
+                                           'stored mass',stored_start,stored_end)
+         CALL report_budget( 'floating mass','kg','calving used',calving_to_bergs_net, &
+                                             'bergs',melt_net, &
+                                             'stored mass',floating_mass_start,floating_mass_end)
+         CALL report_budget( 'berg mass','kg','calving',calving_to_bergs_net, &
+                                              'melt+eros',berg_melt_net, &
+                                              'berg mass',bergs_mass_start,bergs_mass_end)
+         CALL report_budget( 'bits mass','kg','eros used',bits_src_net, &
+                                              'bergs',bits_melt_net, &
+                                              'stored mass',bits_mass_start,bits_mass_end)
+         CALL report_budget( 'net mass','kg','recvd',calving_rcv_net, &
+                                             'rtrnd',calving_ret_net, &
+                                             'net mass',stored_start+floating_mass_start, &
+                                                        stored_end+floating_mass_end)
+         CALL report_consistant( 'iceberg mass','kg','gridded',zgrdd_berg_mass,'bergs',bergs_mass_end)
+         CALL report_consistant( 'bits mass','kg','gridded',zgrdd_bits_mass,'bits',bits_mass_end)
+         CALL report_state( 'net heat','J','',stored_heat_start+floating_heat_start,'', &
+                                              stored_heat_end+floating_heat_end,'')
+         CALL report_state( 'stored heat','J','',stored_heat_start,'',stored_heat_end,'')
+         CALL report_state( 'floating heat','J','',floating_heat_start,'',floating_heat_end,'')
+         CALL report_budget( 'net heat','J','net heat',calving_src_heat_net, &
+                                            'net heat',calving_out_heat_net, &
+                                            'net heat',stored_heat_start+floating_heat_start, &
+                                                       stored_heat_end+floating_heat_end)
+         CALL report_budget( 'stored heat','J','calving used',calving_src_heat_used_net, &
+                                               'bergs',heat_to_bergs_net, &
+                                               'net heat',stored_heat_start,stored_heat_end)
+         CALL report_budget( 'flting heat','J','calved',heat_to_bergs_net, &
+                                               'melt',heat_to_ocean_net, &
+                                               'net heat',floating_heat_start,floating_heat_end)
          IF (nn_verbose_level >= 1) THEN
-            CALL report_consistant('top interface','kg','from SIS',net_incoming_calving, &
-                                   'received',net_calving_received)
-            CALL report_consistant('bot interface','kg','sent',net_outgoing_calving, &
-                                   'returned',net_calving_returned)
+            CALL report_consistant( 'top interface','kg','from SIS',calving_src_net, &
+                                    'received',calving_rcv_net)
+            CALL report_consistant( 'bot interface','kg','sent',calving_out_net, &
+                                    'returned',calving_ret_net)
          ENDIF
-         WRITE(numicb,'("calved by class = ",i6,20(",",i6))') (nbergs_calved_by_class(k),k=1,nclasses)
-         IF ( nspeeding_tickets .GT. 0 ) WRITE(numicb,'("speeding tickets issued = ",i6)') nspeeding_tickets
-
-         nbergs_start                   = nbergs_end
-         stored_start                   = stored_end
-         nbergs_melted                  = 0
-         nbergs_calved                  = 0
-         nbergs_calved_by_class(:)      = 0
-         nspeeding_tickets              = 0
-         stored_heat_start              = stored_heat_end
-         floating_heat_start            = floating_heat_end
-         floating_mass_start            = floating_mass_end
-         icebergs_mass_start            = icebergs_mass_end
-         bits_mass_start               = bits_mass_end
-         net_calving_used               = 0._wp
-         net_calving_to_bergs           = 0._wp
-         net_heat_to_bergs              = 0._wp
-         net_heat_to_ocean              = 0._wp
-         net_calving_received           = 0._wp
-         net_calving_returned           = 0._wp
-         net_incoming_calving           = 0._wp
-         net_outgoing_calving           = 0._wp
-         net_incoming_calving_heat      = 0._wp
-         net_incoming_calving_heat_used = 0._wp
-         net_outgoing_calving_heat      = 0._wp
-         net_melt                       = 0._wp
-         net_berg_melt                  = 0._wp
-         net_bits_melt                 = 0._wp
-         net_bits_src                  = 0._wp
+         WRITE( numicb, '("calved by class = ",i6,20(",",i6))') (nbergs_calved_by_class(ik),ik=1,nclasses)
+         IF ( nspeeding_tickets > 0 ) WRITE( numicb, '("speeding tickets issued = ",i6)') nspeeding_tickets
+
+         nbergs_start              = nbergs_end
+         stored_start              = stored_end
+         nbergs_melted             = 0
+         nbergs_calved             = 0
+         nbergs_calved_by_class(:) = 0
+         nspeeding_tickets         = 0
+         stored_heat_start         = stored_heat_end
+         floating_heat_start       = floating_heat_end
+         floating_mass_start       = floating_mass_end
+         bergs_mass_start          = bergs_mass_end
+         bits_mass_start           = bits_mass_end
+         calving_used_net          = 0._wp
+         calving_to_bergs_net      = 0._wp
+         heat_to_bergs_net         = 0._wp
+         heat_to_ocean_net         = 0._wp
+         calving_rcv_net           = 0._wp
+         calving_ret_net           = 0._wp
+         calving_src_net           = 0._wp
+         calving_out_net           = 0._wp
+         calving_src_heat_net      = 0._wp
+         calving_src_heat_used_net = 0._wp
+         calving_out_heat_net      = 0._wp
+         melt_net                  = 0._wp
+         berg_melt_net             = 0._wp
+         bits_melt_net             = 0._wp
+         bits_src_net              = 0._wp
       ENDIF
 
@@ -366,10 +366,10 @@
       IF( .NOT. ln_bergdia ) RETURN
       berg_melt    (:,:)   = 0._wp
-      melt_buoy    (:,:)   = 0._wp
-      melt_eros    (:,:)   = 0._wp
-      melt_conv    (:,:)   = 0._wp
-      bits_src    (:,:)   = 0._wp
-      bits_melt   (:,:)   = 0._wp
-      bits_mass   (:,:)   = 0._wp
+      buoy_melt    (:,:)   = 0._wp
+      eros_melt    (:,:)   = 0._wp
+      conv_melt    (:,:)   = 0._wp
+      bits_src     (:,:)   = 0._wp
+      bits_melt    (:,:)   = 0._wp
+      bits_mass    (:,:)   = 0._wp
       berg_mass    (:,:)   = 0._wp
       virtual_area (:,:)   = 0._wp
@@ -384,11 +384,11 @@
       IF( .NOT. ln_bergdia ) RETURN
       CALL iom_put( "berg_melt"         , berg_melt    (:,:)   )  ! 'Melt rate of icebergs'                    , 'kg/m2/s'
-      CALL iom_put( "berg_melt_buoy"    , melt_buoy    (:,:)   )  ! 'Buoyancy component of iceberg melt rate'  , 'kg/m2/s'
-      CALL iom_put( "berg_melt_eros"    , melt_eros    (:,:)   )  ! 'Erosion component of iceberg melt rate'   , 'kg/m2/s'
-      CALL iom_put( "berg_melt_conv"    , melt_conv    (:,:)   )  ! 'Convective component of iceberg melt rate', 'kg/m2/s'
+      CALL iom_put( "berg_buoy_melt"    , buoy_melt    (:,:)   )  ! 'Buoyancy component of iceberg melt rate'  , 'kg/m2/s'
+      CALL iom_put( "berg_eros_melt"    , eros_melt    (:,:)   )  ! 'Erosion component of iceberg melt rate'   , 'kg/m2/s'
+      CALL iom_put( "berg_conv_melt"    , conv_melt    (:,:)   )  ! 'Convective component of iceberg melt rate', 'kg/m2/s'
       CALL iom_put( "berg_virtual_area" , virtual_area (:,:)   )  ! 'Virtual coverage by icebergs'             , 'm2'
-      CALL iom_put( "bits_src"         , bits_src    (:,:)   )  ! 'Mass source of bergy bits'                , 'kg/m2/s'
-      CALL iom_put( "bits_melt"        , bits_melt   (:,:)   )  ! 'Melt rate of bergy bits'                  , 'kg/m2/s'
-      CALL iom_put( "bits_mass"        , bits_mass   (:,:)   )  ! 'Bergy bit density field'                  , 'kg/m2'
+      CALL iom_put( "bits_src"         , bits_src    (:,:)   )    ! 'Mass source of bergy bits'                , 'kg/m2/s'
+      CALL iom_put( "bits_melt"        , bits_melt   (:,:)   )    ! 'Melt rate of bergy bits'                  , 'kg/m2/s'
+      CALL iom_put( "bits_mass"        , bits_mass   (:,:)   )    ! 'Bergy bit density field'                  , 'kg/m2'
       CALL iom_put( "berg_mass"         , berg_mass    (:,:)   )  ! 'Iceberg density field'                    , 'kg/m2'
       CALL iom_put( "berg_real_calving" , real_calving (:,:,:) )  ! 'Calving into iceberg class'               , 'kg/s'
@@ -398,15 +398,15 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE calving_budget( ji, jj, jn, calved, heated )
-      INTEGER   :: ji, jj, jn
-      REAL(wp)  :: calved
-      REAL(wp)  :: heated
-
-      IF( .NOT. ln_bergdia ) RETURN
-      real_calving(ji,jj,jn)     = real_calving(ji,jj,jn) + calved / berg_dt
+   SUBROUTINE calving_budget( ki, kj, kn, pcalved, pheated )
+      INTEGER,  INTENT(in)  ::   ki, kj, kn
+      REAL(wp), INTENT(in)  ::   pcalved
+      REAL(wp), INTENT(in)  ::   pheated
+
+      IF( .NOT. ln_bergdia ) RETURN
+      real_calving(ki,kj,kn)     = real_calving(ki,kj,kn) + pcalved / berg_dt
       nbergs_calved              = nbergs_calved              + 1
-      nbergs_calved_by_class(jn) = nbergs_calved_by_class(jn) + 1
-      net_calving_to_bergs       = net_calving_to_bergs + calved
-      net_heat_to_bergs          = net_heat_to_bergs    + heated
+      nbergs_calved_by_class(kn) = nbergs_calved_by_class(kn) + 1
+      calving_to_bergs_net       = calving_to_bergs_net + pcalved
+      heat_to_bergs_net          = heat_to_bergs_net    + pheated
 
    END SUBROUTINE calving_budget
@@ -414,8 +414,8 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE incoming_budget( kt,  calving_used, heat_used )
+   SUBROUTINE incoming_budget( kt,  pcalving_used, pheat_used )
       INTEGER ,                 INTENT(in)  :: kt
-      REAL(wp),                 INTENT(in)  :: calving_used
-      REAL(wp), DIMENSION(:,:), INTENT(in)  :: heat_used
+      REAL(wp),                 INTENT(in)  :: pcalving_used
+      REAL(wp), DIMENSION(:,:), INTENT(in)  :: pheat_used
 
       IF( .NOT. ln_bergdia ) RETURN
@@ -431,10 +431,10 @@
       ENDIF
 
-      net_calving_received = net_calving_received + SUM( berg_grid%calving(:,:) ) * berg_dt
-      net_incoming_calving = net_calving_received
-      net_incoming_calving_heat = net_incoming_calving_heat +  &
+      calving_rcv_net = calving_rcv_net + SUM( berg_grid%calving(:,:) ) * berg_dt
+      calving_src_net = calving_rcv_net
+      calving_src_heat_net = calving_src_heat_net +  &
                                   SUM( berg_grid%calving_hflx(:,:) * e1e2t(:,:) ) * berg_dt   ! Units of J
-      net_calving_used = net_calving_used + calving_used * berg_dt
-      net_incoming_calving_heat_used = net_incoming_calving_heat_used + SUM( heat_used(:,:) )
+      calving_used_net = calving_used_net + pcalving_used * berg_dt
+      calving_src_heat_used_net = calving_src_heat_used_net + SUM( pheat_used(:,:) )
 
    END SUBROUTINE incoming_budget
@@ -442,12 +442,13 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE size_budget(ji, jj, Wn, Ln, Abits, mass_scale, Mnew, nMbits, z1_e1e2)
-      INTEGER             :: ji, jj
-      REAL(wp)            :: Wn, Ln, Abits, mass_scale, Mnew, nMbits, z1_e1e2
-
-      IF( .NOT. ln_bergdia ) RETURN
-      virtual_area(ji,jj) = virtual_area(ji,jj)+(Wn*Ln+Abits)*mass_scale        ! m^2
-      berg_mass(ji,jj)    = berg_mass(ji,jj) + Mnew * z1_e1e2                   ! kg/m2
-      bits_mass(ji,jj)   = bits_mass(ji,jj) + nMbits * z1_e1e2                ! kg/m2
+   SUBROUTINE size_budget(ki, kj, pWn, pLn, pAbits,   &
+      &                   pmass_scale, pMnew, pnMbits, pz1_e1e2)
+      INTEGER,  INTENT(in)           :: ki, kj
+      REAL(wp), INTENT(in)           :: pWn, pLn, pAbits, pmass_scale, pMnew, pnMbits, pz1_e1e2
+
+      IF( .NOT. ln_bergdia ) RETURN
+      virtual_area(ki,kj) = virtual_area(ki,kj) + ( pWn * pLn + pAbits ) * pmass_scale      ! m^2
+      berg_mass(ki,kj)    = berg_mass(ki,kj) + pMnew * pz1_e1e2                             ! kg/m2
+      bits_mass(ki,kj)    = bits_mass(ki,kj) + pnMbits * pz1_e1e2                           ! kg/m2
 
    END SUBROUTINE size_budget
@@ -464,44 +465,46 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE melt_budget(ji, jj, mnew, heat, mass_scale, dM, dMbitsE, dMbitsM, dMb, dMe, dMv, z1_dt_e1e2)
-
-      INTEGER               ::  ji, jj
-      REAL(wp), INTENT(in)  ::  mnew, heat, mass_scale
-      REAL(wp), INTENT(in)  ::  dM, dMbitsE, dMbitsM, dMb, dMe, dMv, z1_dt_e1e2
-
-      IF( .NOT. ln_bergdia ) RETURN
-
-      berg_melt    (ji,jj) = berg_melt    (ji,jj) + dM      * z1_dt_e1e2   ! kg/m2/s
-      bits_src    (ji,jj) = bits_src    (ji,jj) + dMbitsE * z1_dt_e1e2   ! mass flux into bergy bitskg/m2/s
-      bits_melt   (ji,jj) = bits_melt   (ji,jj) + dMbitsM * z1_dt_e1e2   ! melt rate of bergy bits kg/m2/s
-      melt_buoy    (ji,jj) = melt_buoy    (ji,jj) + dMb     * z1_dt_e1e2   ! kg/m2/s
-      melt_eros    (ji,jj) = melt_eros    (ji,jj) + dMe     * z1_dt_e1e2   ! erosion rate kg/m2/s
-      melt_conv    (ji,jj) = melt_conv    (ji,jj) + dMv     * z1_dt_e1e2   ! kg/m2/s
-      net_heat_to_ocean = net_heat_to_ocean + heat * mass_scale * berg_dt         ! J
+   SUBROUTINE melt_budget(ki, kj, pmnew, pheat, pmass_scale,   &
+      &                   pdM, pdMbitsE, pdMbitsM, pdMb, pdMe,   &
+      &                   pdMv, pz1_dt_e1e2)
+
+      INTEGER               ::  ki, kj
+      REAL(wp), INTENT(in)  ::  pmnew, pheat, pmass_scale
+      REAL(wp), INTENT(in)  ::  pdM, pdMbitsE, pdMbitsM, pdMb, pdMe, pdMv, pz1_dt_e1e2
+
+      IF( .NOT. ln_bergdia ) RETURN
+
+      berg_melt (ki,kj) = berg_melt (ki,kj) + pdM      * pz1_dt_e1e2   ! kg/m2/s
+      bits_src  (ki,kj) = bits_src  (ki,kj) + pdMbitsE * pz1_dt_e1e2   ! mass flux into bergy bitskg/m2/s
+      bits_melt (ki,kj) = bits_melt (ki,kj) + pdMbitsM * pz1_dt_e1e2   ! melt rate of bergy bits kg/m2/s
+      buoy_melt (ki,kj) = buoy_melt (ki,kj) + pdMb     * pz1_dt_e1e2   ! kg/m2/s
+      eros_melt (ki,kj) = eros_melt (ki,kj) + pdMe     * pz1_dt_e1e2   ! erosion rate kg/m2/s
+      conv_melt (ki,kj) = conv_melt (ki,kj) + pdMv     * pz1_dt_e1e2   ! kg/m2/s
+      heat_to_ocean_net = heat_to_ocean_net + pheat * pmass_scale * berg_dt         ! J
       IF( mnew <= 0._wp ) nbergs_melted = nbergs_melted + 1                        ! Delete the berg if completely melted
 
-
    END SUBROUTINE melt_budget
 
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE report_state(budgetstr,budgetunits,startstr,startval,endstr,endval,delstr,nbergs)
+   SUBROUTINE report_state( cd_budgetstr, cd_budgetunits, cd_startstr, pstartval, cd_endstr,   &
+      &                     pendval, cd_delstr, kbergs )
       ! Arguments
-      CHARACTER*(*), INTENT(in)           :: budgetstr, budgetunits, startstr, endstr, delstr
-      REAL(wp),      INTENT(in)           :: startval, endval
-      INTEGER,       INTENT(in), OPTIONAL :: nbergs
-
-      if (present(nbergs)) then
-        WRITE(numicb,100) budgetstr//' state:', &
-                            startstr//' start',startval,budgetunits, &
-                            endstr//' end',endval,budgetunits, &
-                            'Delta '//delstr,endval-startval,budgetunits, &
-                            '# of bergs',nbergs
-      else
-        WRITE(numicb,100) budgetstr//' state:', &
-                            startstr//' start',startval,budgetunits, &
-                            endstr//' end',endval,budgetunits, &
-                            delstr//'Delta',endval-startval,budgetunits
-      endif
+      CHARACTER*(*), INTENT(in)           :: cd_budgetstr, cd_budgetunits, cd_startstr, cd_endstr, cd_delstr
+      REAL(wp),      INTENT(in)           :: pstartval, pendval
+      INTEGER,       INTENT(in), OPTIONAL :: kbergs
+
+      IF ( PRESENT(kbergs) ) THEN
+         WRITE(numicb,100) cd_budgetstr // ' state:',                                    &
+                           cd_startstr  // ' start',  pstartval,         cd_budgetunits, &
+                           cd_endstr    // ' end',    pendval,           cd_budgetunits, &
+                           'Delta '     // cd_delstr, pendval-pstartval, cd_budgetunits, &
+                           '# of bergs', kbergs
+      ELSE
+         WRITE(numicb,100) cd_budgetstr // ' state:',                                   &
+                           cd_startstr  // ' start', pstartval,         cd_budgetunits, &
+                           cd_endstr    // ' end',   pendval,           cd_budgetunits, &
+                           cd_delstr    // 'Delta',  pendval-pstartval, cd_budgetunits
+      ENDIF
       100 FORMAT(a19,3(a18,"=",es14.7,x,a2,:,","),a12,i8)
    END SUBROUTINE report_state
@@ -509,13 +512,13 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE report_consistant(budgetstr,budgetunits,startstr,startval,endstr,endval)
+   SUBROUTINE report_consistant( cd_budgetstr, cd_budgetunits, cd_startstr, pstartval, cd_endstr, pendval)
       ! Arguments
-      CHARACTER*(*), INTENT(in) :: budgetstr, budgetunits, startstr, endstr
-      REAL(wp),      INTENT(in) :: startval, endval
-
-      WRITE(numicb,200) budgetstr//' check:', &
-                        startstr,startval,budgetunits, &
-                        endstr,endval,budgetunits, &
-                        'error',(endval-startval)/((endval+startval)+1e-30),'nd'
+      CHARACTER*(*), INTENT(in) :: cd_budgetstr, cd_budgetunits, cd_startstr, cd_endstr
+      REAL(wp),      INTENT(in) :: pstartval, pendval
+
+      WRITE(numicb,200) cd_budgetstr // ' check:',                 &
+                        cd_startstr,    pstartval, cd_budgetunits, &
+                        cd_endstr,      pendval,   cd_budgetunits, &
+                        'error',        (pendval-pstartval)/((pendval+pstartval)+1e-30), 'nd'
       200 FORMAT(a19,10(a18,"=",es14.7,x,a2,:,","))
    END SUBROUTINE report_consistant
@@ -523,14 +526,20 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE report_budget(budgetstr,budgetunits,instr,inval,outstr,outval,delstr,startval,endval)
+   SUBROUTINE report_budget( cd_budgetstr, cd_budgetunits, cd_instr, pinval, cd_outstr,   &
+      &                      poutval, cd_delstr, pstartval, pendval)
       ! Arguments
-      CHARACTER*(*), INTENT(in) :: budgetstr, budgetunits, instr, outstr, delstr
-      REAL(wp),      INTENT(in) :: inval, outval, startval, endval
-
-      WRITE(numicb,200) budgetstr//' budget:', &
-                        instr//' in',inval,budgetunits, &
-                        outstr//' out',outval,budgetunits, &
-                        'Delta '//delstr,inval-outval,budgetunits, &
-                        'error',((endval-startval)-(inval-outval))/max(1.e-30,max(abs(endval-startval),abs(inval-outval))),'nd'
+      CHARACTER*(*), INTENT(in) :: cd_budgetstr, cd_budgetunits, cd_instr, cd_outstr, cd_delstr
+      REAL(wp),      INTENT(in) :: pinval, poutval, pstartval, pendval
+      ! Local variables
+      REAL(wp)                  :: zval
+
+      zval = ( ( pendval - pstartval ) - ( pinval - poutval ) ) /   &
+             MAX( 1.e-30, MAX( abs( pendval - pstartval ) , ABS( pinval - poutval ) ) )
+
+      WRITE(numicb,200) cd_budgetstr // ' budget:', &
+                        cd_instr     // ' in',      pinval,         cd_budgetunits, &
+                        cd_outstr    // ' out',     poutval,        cd_budgetunits, &
+                        'Delta '     // cd_delstr,  pinval-poutval, cd_budgetunits, &
+                        'error',        zval,                       'nd'
       200 FORMAT(a19,3(a18,"=",es14.7,x,a2,:,","),a8,"=",es10.3,x,a2)
    END SUBROUTINE report_budget
@@ -538,13 +547,13 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE report_istate(budgetstr,startstr,startval,endstr,endval,delstr)
+   SUBROUTINE report_istate( cd_budgetstr, cd_startstr, pstartval, cd_endstr, pendval, cd_delstr)
       ! Arguments
-      CHARACTER*(*), INTENT(in) :: budgetstr, startstr, endstr, delstr
-      INTEGER,       INTENT(in) :: startval, endval
-
-      WRITE(numicb,100) budgetstr//' state:', &
-                        startstr//' start',startval, &
-                        endstr//' end',endval, &
-                        delstr//'Delta',endval-startval
+      CHARACTER*(*), INTENT(in) :: cd_budgetstr, cd_startstr, cd_endstr, cd_delstr
+      INTEGER,       INTENT(in) :: pstartval, pendval
+
+      WRITE(numicb,100) cd_budgetstr // ' state:',           &
+                        cd_startstr  // ' start', pstartval, &
+                        cd_endstr    // ' end',   pendval,   &
+                        cd_delstr    // 'Delta',  pendval-pstartval
       100 FORMAT(a19,3(a18,"=",i14,x,:,","))
    END SUBROUTINE report_istate
@@ -552,14 +561,15 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE report_ibudget(budgetstr,instr,inval,outstr,outval,delstr,startval,endval)
+   SUBROUTINE report_ibudget( cd_budgetstr, cd_instr, pinval, cd_outstr, poutval,   &
+      &                       cd_delstr, pstartval, pendval)
       ! Arguments
-      CHARACTER*(*), INTENT(in) :: budgetstr, instr, outstr, delstr
-      INTEGER,       INTENT(in) :: inval, outval, startval, endval
-
-      WRITE(numicb,200) budgetstr//' budget:', &
-                          instr//' in',inval, &
-                          outstr//' out',outval, &
-                          'Delta '//delstr,inval-outval, &
-                          'error',((endval-startval)-(inval-outval))
+      CHARACTER*(*), INTENT(in) :: cd_budgetstr, cd_instr, cd_outstr, cd_delstr
+      INTEGER,       INTENT(in) :: pinval, poutval, pstartval, pendval
+
+      WRITE(numicb,200) cd_budgetstr // ' budget:', &
+                        cd_instr     // ' in',      pinval, &
+                        cd_outstr    // ' out',     poutval, &
+                        'Delta '     // cd_delstr,  pinval-poutval, &
+                        'error',                    ( ( pendval - pstartval ) - ( pinval - poutval ) )
       200 FORMAT(a19,10(a18,"=",i14,x,:,","))
    END SUBROUTINE report_ibudget
Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbdyn.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbdyn.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbdyn.F90	(revision 3359)
@@ -13,9 +13,4 @@
    !!            -    !                            the broken one)
    !!----------------------------------------------------------------------
-   !!----------------------------------------------------------------------
-   !!   icb_init      : initialise
-   !!   icb_gen       : generate test icebergs
-   !!   icb_nam       : read iceberg namelist
-   !!----------------------------------------------------------------------
    USE par_oce        ! NEMO parameters
    USE dom_oce        ! NEMO ocean domain
@@ -29,5 +24,5 @@
    PRIVATE
 
-   PUBLIC   evolve_icebergs  ! routine called in xxx.F90 module
+   PUBLIC   evolve_icebergs  ! routine called in icbrun.F90 module
 
 CONTAINS
@@ -42,11 +37,11 @@
       !!----------------------------------------------------------------------
       !
-      REAL(wp)                        ::   uvel1 , vvel1 , u1, v1, ax1, ay1, xi1 , yj1
-      REAL(wp)                        ::   uvel2 , vvel2 , u2, v2, ax2, ay2, xi2 , yj2
-      REAL(wp)                        ::   uvel3 , vvel3 , u3, v3, ax3, ay3, xi3 , yj3
-      REAL(wp)                        ::   uvel4 , vvel4 , u4, v4, ax4, ay4, xi4 , yj4
-      REAL(wp)                        ::   uvel_n, vvel_n                  , xi_n, yj_n
-      REAL(wp)                        ::   zdt, zdt_2, zdt_6, e1, e2
-      LOGICAL                         ::   bounced
+      REAL(wp)                        ::   zuvel1 , zvvel1 , zu1, zv1, zax1, zay1, zxi1 , zyj1
+      REAL(wp)                        ::   zuvel2 , zvvel2 , zu2, zv2, zax2, zay2, zxi2 , zyj2
+      REAL(wp)                        ::   zuvel3 , zvvel3 , zu3, zv3, zax3, zay3, zxi3 , zyj3
+      REAL(wp)                        ::   zuvel4 , zvvel4 , zu4, zv4, zax4, zay4, zxi4 , zyj4
+      REAL(wp)                        ::   zuvel_n, zvvel_n                  , zxi_n, zyj_n
+      REAL(wp)                        ::   zdt, zdt_2, zdt_6, ze1, ze2
+      LOGICAL                         ::   ll_bounced
       TYPE(iceberg), POINTER          ::   berg
       TYPE(point)  , POINTER          ::   pt
@@ -77,19 +72,19 @@
          pt => berg%current_point
 
-         bounced = .false.
+         ll_bounced = .false.
 
 
          ! STEP 1 !
          ! ====== !
-         xi1 = pt%xi   ;   uvel1 = pt%uvel     !**   X1 in (i,j)  ;  V1 in m/s
-         yj1 = pt%yj   ;   vvel1 = pt%vvel
+         zxi1 = pt%xi   ;   zuvel1 = pt%uvel     !**   X1 in (i,j)  ;  V1 in m/s
+         zyj1 = pt%yj   ;   zvvel1 = pt%vvel
 
 
          !                                         !**   A1 = A(X1,V1)
-         CALL accel(        xi1, e1, uvel1, uvel1, ax1,     &
-            &        berg , yj1, e2, vvel1, vvel1, ay1, zdt_2 )
-         !
-         u1 = uvel1 / e1                           !**   V1 in d(i,j)/dt
-         v1 = vvel1 / e2
+         CALL accel(        zxi1, ze1, zuvel1, zuvel1, zax1,     &
+            &        berg , zyj1, ze2, zvvel1, zvvel1, zay1, zdt_2 )
+         !
+         zu1 = zuvel1 / ze1                           !**   V1 in d(i,j)/dt
+         zv1 = zvvel1 / ze2
 
          ! STEP 2 !
@@ -97,45 +92,48 @@
          !                                         !**   X2 = X1+dt/2*V1   ;   V2 = V1+dt/2*A1
          ! position using di/dt & djdt   !   V2  in m/s
-         xi2 = xi1 + zdt_2 * u1          ;   uvel2 = uvel1 + zdt_2 * ax1
-         yj2 = yj1 + zdt_2 * v1          ;   vvel2 = vvel1 + zdt_2 * ay1
-         !
-         CALL adjust_to_ground( xi2, xi1, u1, yj2, yj1, v1, bounced )
+         zxi2 = zxi1 + zdt_2 * zu1          ;   zuvel2 = zuvel1 + zdt_2 * zax1
+         zyj2 = zyj1 + zdt_2 * zv1          ;   zvvel2 = zvvel1 + zdt_2 * zay1
+         !
+         CALL adjust_to_ground( zxi2, zxi1, zu1,   &
+         &                      zyj2, zyj1, zv1, ll_bounced )
 
          !                                         !**   A2 = A(X2,V2)
-         CALL accel(        xi2, e1, uvel2, uvel1, ax2,    &
-            &        berg , yj2, e2, vvel2, vvel1, ay2, zdt_2 )
-         !
-         u2 = uvel2 / e1                           !**   V2 in d(i,j)/dt
-         v2 = vvel2 / e2
+         CALL accel(        zxi2, ze1, zuvel2, zuvel1, zax2,    &
+            &        berg , zyj2, ze2, zvvel2, zvvel1, zay2, zdt_2 )
+         !
+         zu2 = zuvel2 / ze1                           !**   V2 in d(i,j)/dt
+         zv2 = zvvel2 / ze2
          !
          ! STEP 3 !
          ! ====== !
          !                                         !**  X3 = X1+dt/2*V2  ;   V3 = V1+dt/2*A2; A3=A(X3)
-         xi3  = xi1  + zdt_2 * u2   ;   uvel3 = uvel1 + zdt_2 * ax2
-         yj3  = yj1  + zdt_2 * v2   ;   vvel3 = vvel1 + zdt_2 * ay2
-         !
-         CALL adjust_to_ground( xi3, xi1, u3, yj3, yj1, v3, bounced )
+         zxi3  = zxi1  + zdt_2 * zu2   ;   zuvel3 = zuvel1 + zdt_2 * zax2
+         zyj3  = zyj1  + zdt_2 * zv2   ;   zvvel3 = zvvel1 + zdt_2 * zay2
+         !
+         CALL adjust_to_ground( zxi3, zxi1, zu3,   &
+         &                      zyj3, zyj1, zv3, ll_bounced )
 
          !                                         !**   A3 = A(X3,V3)
-         CALL accel(        xi3, e1, uvel3, uvel1, ax3,    &
-            &        berg , yj3, e2, vvel3, vvel1, ay3, zdt )
-         !
-         u3 = uvel3 / e1                           !**   V3 in d(i,j)/dt
-         v3 = vvel3 / e2
+         CALL accel(        zxi3, ze1, zuvel3, zuvel1, zax3,    &
+            &        berg , zyj3, ze2, zvvel3, zvvel1, zay3, zdt )
+         !
+         zu3 = zuvel3 / ze1                           !**   V3 in d(i,j)/dt
+         zv3 = zvvel3 / ze2
 
          ! STEP 4 !
          ! ====== !
          !                                         !**   X4 = X1+dt*V3   ;   V4 = V1+dt*A3
-         xi4 = xi1 + zdt * u3   ;   uvel4 = uvel1 + zdt * ax3
-         yj4 = yj1 + zdt * v3   ;   vvel4 = vvel1 + zdt * ay3
-
-         CALL adjust_to_ground( xi4, xi1, u4, yj4, yj1, v4, bounced )
+         zxi4 = zxi1 + zdt * zu3   ;   zuvel4 = zuvel1 + zdt * zax3
+         zyj4 = zyj1 + zdt * zv3   ;   zvvel4 = zvvel1 + zdt * zay3
+
+         CALL adjust_to_ground( zxi4, zxi1, zu4,   &
+         &                      zyj4, zyj1, zv4, ll_bounced )
 
          !                                         !**   A4 = A(X4,V4)
-         CALL accel(        xi4, e1, uvel4, uvel1, ax4,    &
-            &        berg , yj4, e2, vvel4, vvel1, ay4, zdt )
-
-         u4 = uvel4 / e1                           !**   V4 in d(i,j)/dt
-         v4 = vvel4 / e2
+         CALL accel(        zxi4, ze1, zuvel4, zuvel1, zax4,    &
+            &        berg , zyj4, ze2, zvvel4, zvvel1, zay4, zdt )
+
+         zu4 = zuvel4 / ze1                           !**   V4 in d(i,j)/dt
+         zv4 = zvvel4 / ze2
 
          ! FINAL STEP !
@@ -143,17 +141,18 @@
          !                                         !**   Xn = X1+dt*(V1+2*V2+2*V3+V4)/6
          !                                         !**   Vn = V1+dt*(A1+2*A2+2*A3+A4)/6
-         xi_n   = pt%xi   + zdt_6 * (  u1  + 2.*(u2  + u3 ) + u4  )
-         yj_n   = pt%yj   + zdt_6 * (  v1  + 2.*(v2  + v3 ) + v4  )
-         uvel_n = pt%uvel + zdt_6 * (  ax1 + 2.*(ax2 + ax3) + ax4 )
-         vvel_n = pt%vvel + zdt_6 * (  ay1 + 2.*(ay2 + ay3) + ay4 )
-
-         CALL adjust_to_ground( xi_n, xi1, uvel_n, yj_n, yj1, vvel_n, bounced )
-
-         pt%uvel = uvel_n                        !** save in berg structure
-         pt%vvel = vvel_n
-         pt%xi   = xi_n
-         pt%yj   = yj_n
-
-         ! sga - update actual position
+         zxi_n   = pt%xi   + zdt_6 * (  zu1  + 2.*(zu2  + zu3 ) + zu4  )
+         zyj_n   = pt%yj   + zdt_6 * (  zv1  + 2.*(zv2  + zv3 ) + zv4  )
+         zuvel_n = pt%uvel + zdt_6 * (  zax1 + 2.*(zax2 + zax3) + zax4 )
+         zvvel_n = pt%vvel + zdt_6 * (  zay1 + 2.*(zay2 + zay3) + zay4 )
+
+         CALL adjust_to_ground( zxi_n, zxi1, zuvel_n,   &
+         &                      zyj_n, zyj1, zvvel_n, ll_bounced )
+
+         pt%uvel = zuvel_n                        !** save in berg structure
+         pt%vvel = zvvel_n
+         pt%xi   = zxi_n
+         pt%yj   = zyj_n
+
+         ! update actual position
          pt%lon  = bilin_x(glamt, pt%xi, pt%yj )
          pt%lat  = bilin(gphit, pt%xi, pt%yj, 'T', 0, 0 )
@@ -166,5 +165,6 @@
 
 
-   SUBROUTINE adjust_to_ground( pi, pi0, pu, pj, pj0, pv, bounced )
+   SUBROUTINE adjust_to_ground( pi, pi0, pu,   &
+      &                         pj, pj0, pv, ld_bounced )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE adjust_to_ground  ***
@@ -177,15 +177,12 @@
       REAL(wp), INTENT(in   )         ::   pi0, pj0   ! previous iceberg position
       REAL(wp), INTENT(inout)         ::   pu  , pv   ! current iceberg velocities
-      LOGICAL , INTENT(  out)         ::   bounced    ! bounced indicator
-      !
-      REAL(wp), PARAMETER ::   posn_eps = 0.05_wp     ! bouncing distance in (i,j) referential
+      LOGICAL , INTENT(  out)         ::   ld_bounced    ! bounced indicator
       !
       INTEGER  ::   ii, ii0
       INTEGER  ::   ij, ij0
-      INTEGER  ::   bounce_method
-      !!----------------------------------------------------------------------
-      !
-      bounced = .false.
-      bounce_method = 2
+      INTEGER  ::   ibounce_method
+      !!----------------------------------------------------------------------
+      !
+      ld_bounced = .FALSE.
       !
       ii0 = INT( pi0+0.5 )   ;   ij0 = INT( pj0+0.5 )       ! initial gridpoint position (T-cell)
@@ -204,5 +201,5 @@
       ! From here, berg have reach land: treat grounding/bouncing
       ! -------------------------------
-      bounced = .true.
+      ld_bounced = .TRUE.
 
       !! not obvious what should happen now
@@ -213,5 +210,6 @@
       !! of travel to zero; at a coastal boundary this has the effect of sliding the berg along the coast
 
-      SELECT CASE ( bounce_method )
+      ibounce_method = 2
+      SELECT CASE ( ibounce_method )
          CASE ( 1 )
             pi = pi0
@@ -233,6 +231,6 @@
 
 
-   SUBROUTINE accel(       xi, e1, uvel, uvel0, ax,                &
-      &             berg , yj, e2, vvel, vvel0, ay, dt )
+   SUBROUTINE accel(       pxi, pe1, puvel, puvel0, pax,                &
+      &             berg , pyj, pe2, pvvel, pvvel0, pay, pdt )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE accel  ***
@@ -243,125 +241,125 @@
       !!----------------------------------------------------------------------
       TYPE(iceberg ), POINTER           ::   berg
-      REAL(wp), INTENT(in   )           ::   xi   , yj      ! berg position in (i,j) referential
-      REAL(wp), INTENT(in   )           ::   uvel , vvel    ! berg velocity [m/s]
-      REAL(wp), INTENT(in   )           ::   uvel0, vvel0   ! initial berg velocity [m/s]
-      REAL(wp), INTENT(  out)           ::   e1, e2         ! horizontal scale factor at (xi,yj)
-      REAL(wp), INTENT(inout)           ::   ax, ay         ! berg acceleration
-      REAL(wp), INTENT(in   )           ::   dt             ! berg time step
-      !
-      REAL(wp), PARAMETER ::   alpha     = 0._wp      !
-      REAL(wp), PARAMETER ::   beta      = 1._wp      !
-      REAL(wp), PARAMETER ::   vel_lim   =15._wp      ! max allowed berg speed
-      REAL(wp), PARAMETER ::   accel_lim = 1.e-2_wp   ! max allowed berg acceleration
-      REAL(wp), PARAMETER ::   Cr0       = 0.06_wp    !
+      REAL(wp), INTENT(in   )           ::   pxi   , pyj      ! berg position in (i,j) referential
+      REAL(wp), INTENT(in   )           ::   puvel , pvvel    ! berg velocity [m/s]
+      REAL(wp), INTENT(in   )           ::   puvel0, pvvel0   ! initial berg velocity [m/s]
+      REAL(wp), INTENT(  out)           ::   pe1, pe2         ! horizontal scale factor at (xi,yj)
+      REAL(wp), INTENT(inout)           ::   pax, pay         ! berg acceleration
+      REAL(wp), INTENT(in   )           ::   pdt             ! berg time step
+      !
+      REAL(wp), PARAMETER ::   pp_alpha     = 0._wp      !
+      REAL(wp), PARAMETER ::   pp_beta      = 1._wp      !
+      REAL(wp), PARAMETER ::   pp_vel_lim   =15._wp      ! max allowed berg speed
+      REAL(wp), PARAMETER ::   pp_accel_lim = 1.e-2_wp   ! max allowed berg acceleration
+      REAL(wp), PARAMETER ::   pp_Cr0       = 0.06_wp    !
       !
       INTEGER  ::   itloop
-      REAL(wp) ::   uo, vo, ui, vi, ua, va, uwave, vwave, ssh_x, ssh_y, sst, cn, hi
-      REAL(wp) ::   zff, T, D, W, L, M, F
-      REAL(wp) ::   drag_ocn, drag_atm, drag_ice, wave_rad
-      REAL(wp) ::   c_ocn, c_atm, c_ice
-      REAL(wp) ::   ampl, wmod, Cr, Lwavelength, Lcutoff, Ltop
-      REAL(wp) ::   lambda, detA, A11, A12, axe, aye, D_hi
-      REAL(wp) ::   uveln, vveln, us, vs, speed, loc_dx, new_speed
+      REAL(wp) ::   zuo, zvo, zui, zvi, zua, zva, zuwave, zvwave, zssh_x, zssh_y, zsst, zcn, zhi
+      REAL(wp) ::   zff, zT, zD, zW, zL, zM, zF
+      REAL(wp) ::   zdrag_ocn, zdrag_atm, zdrag_ice, zwave_rad
+      REAL(wp) ::   z_ocn, z_atm, z_ice
+      REAL(wp) ::   zampl, zwmod, zCr, zLwavelength, zLcutoff, zLtop
+      REAL(wp) ::   zlambda, zdetA, zA11, zA12, zaxe, zaye, zD_hi
+      REAL(wp) ::   zuveln, zvveln, zus, zvs, zspeed, zloc_dx, zspeed_new
       !!----------------------------------------------------------------------
 
       ! Interpolate gridded fields to berg
-      knberg = berg%number(1)
-      CALL interp_flds( xi, e1, uo, ui, ua, ssh_x,                     &
-         &              yj, e2, vo, vi, va, ssh_y, sst, cn, hi, zff )
-
-      M = berg%current_point%mass
-      T = berg%current_point%thickness                           ! total thickness
-      D = ( rn_rho_bergs / rho_seawater ) * T   ! draught (keel depth)
-      F = T - D                                    ! freeboard
-      W = berg%current_point%width
-      L = berg%current_point%length
-
-      hi   = MIN( hi   , D    )
-      D_hi = MAX( 0._wp, D-hi )
+      nknberg = berg%number(1)
+      CALL interp_flds( pxi, pe1, zuo, zui, zua, zssh_x,                     &
+         &              pyj, pe2, zvo, zvi, zva, zssh_y, zsst, zcn, zhi, zff )
+
+      zM = berg%current_point%mass
+      zT = berg%current_point%thickness                           ! total thickness
+      zD = ( rn_rho_bergs / pp_rho_seawater ) * zT   ! draught (keel depth)
+      zF = zT - zD                                    ! freeboard
+      zW = berg%current_point%width
+      zL = berg%current_point%length
+
+      zhi   = MIN( zhi   , zD    )
+      zD_hi = MAX( 0._wp, zD-zhi )
 
       ! Wave radiation
-      uwave = ua - uo   ;   vwave = va - vo     ! Use wind speed rel. to ocean for wave model
-      wmod  = uwave*uwave + vwave*vwave         ! The wave amplitude and length depend on the  current;
+      zuwave = zua - zuo   ;   zvwave = zva - zvo     ! Use wind speed rel. to ocean for wave model
+      zwmod  = zuwave*zuwave + zvwave*zvwave         ! The wave amplitude and length depend on the  current;
       !                                         ! wind speed relative to the ocean. Actually wmod is wmod**2 here.
-      ampl        = 0.5 * 0.02025 * wmod        ! This is "a", the wave amplitude
-      Lwavelength =       0.32    * wmod        ! Surface wave length fitted to data in table at
+      zampl        = 0.5 * 0.02025 * zwmod        ! This is "a", the wave amplitude
+      zLwavelength =       0.32    * zwmod        ! Surface wave length fitted to data in table at
       !                                         ! http://www4.ncsu.edu/eos/users/c/ceknowle/public/chapter10/part2.html
-      Lcutoff     = 0.125 * Lwavelength
-      Ltop        = 0.25  * Lwavelength
-      Cr          = Cr0 * MIN(  MAX( 0., (L-Lcutoff) / ((Ltop-Lcutoff)+1.e-30)) , 1.)  ! Wave radiation coefficient
+      zLcutoff     = 0.125 * zLwavelength
+      zLtop        = 0.25  * zLwavelength
+      zCr          = pp_Cr0 * MIN(  MAX( 0., (zL-zLcutoff) / ((zLtop-zLcutoff)+1.e-30)) , 1.)  ! Wave radiation coefficient
       !                                         ! fitted to graph from Carrieres et al.,  POAC Drift Model.
-      wave_rad    = 0.5 * rho_seawater / M * Cr * grav * ampl * MIN( ampl,F ) * (2.*W*L) / (W+L)
-      wmod        = SQRT( ua*ua + va*va )       ! Wind speed
-      IF( wmod /= 0._wp ) THEN
-         uwave = ua/wmod ! Wave radiation force acts in wind direction ...       !!gm  this should be the wind rel. to ocean ?
-         vwave = va/wmod
+      zwave_rad    = 0.5 * pp_rho_seawater / zM * zCr * grav * zampl * MIN( zampl,zF ) * (2.*zW*zL) / (zW+zL)
+      zwmod        = SQRT( zua*zua + zva*zva )       ! Wind speed
+      IF( zwmod /= 0._wp ) THEN
+         zuwave = zua/zwmod ! Wave radiation force acts in wind direction ...       !!gm  this should be the wind rel. to ocean ?
+         zvwave = zva/zwmod
       ELSE
-         uwave = 0.   ;    vwave=0.   ;    wave_rad=0. ! ... and only when wind is present.     !!gm  wave_rad=0. is useless
+         zuwave = 0.   ;    zvwave=0.   ;    zwave_rad=0. ! ... and only when wind is present.     !!gm  wave_rad=0. is useless
       ENDIF
 
       ! Weighted drag coefficients
-      c_ocn = rho_seawater / M * (0.5*Cd_wv*W*(D_hi)+Cd_wh*W*L)
-      c_atm = rho_air      / M * (0.5*Cd_av*W*F     +Cd_ah*W*L)
-      c_ice = rho_ice      / M * (0.5*Cd_iv*W*hi              )
-      IF( abs(ui) + abs(vi) == 0._wp )   c_ice = 0._wp
-
-      uveln = uvel   ;   vveln = vvel ! Copy starting uvel, vvel
+      z_ocn = pp_rho_seawater / zM * (0.5*pp_Cd_wv*zW*(zD_hi)+pp_Cd_wh*zW*zL)
+      z_atm = pp_rho_air      / zM * (0.5*pp_Cd_av*zW*zF     +pp_Cd_ah*zW*zL)
+      z_ice = pp_rho_ice      / zM * (0.5*pp_Cd_iv*zW*zhi              )
+      IF( abs(zui) + abs(zvi) == 0._wp )   z_ice = 0._wp
+
+      zuveln = puvel   ;   zvveln = pvvel ! Copy starting uvel, vvel
       !
       DO itloop = 1, 2  ! Iterate on drag coefficients
          !
-         us = 0.5 * ( uveln + uvel )
-         vs = 0.5 * ( vveln + vvel )
-         drag_ocn = c_ocn * SQRT( (us-uo)*(us-uo) + (vs-vo)*(vs-vo) )
-         drag_atm = c_atm * SQRT( (us-ua)*(us-ua) + (vs-va)*(vs-va) )
-         drag_ice = c_ice * SQRT( (us-ui)*(us-ui) + (vs-vi)*(vs-vi) )
+         zus = 0.5 * ( zuveln + puvel )
+         zvs = 0.5 * ( zvveln + pvvel )
+         zdrag_ocn = z_ocn * SQRT( (zus-zuo)*(zus-zuo) + (zvs-zvo)*(zvs-zvo) )
+         zdrag_atm = z_atm * SQRT( (zus-zua)*(zus-zua) + (zvs-zva)*(zvs-zva) )
+         zdrag_ice = z_ice * SQRT( (zus-zui)*(zus-zui) + (zvs-zvi)*(zvs-zvi) )
          !
          ! Explicit accelerations
-         !axe= zff*vvel -grav*ssh_x +wave_rad*uwave &
-         !    -drag_ocn*(uvel-uo) -drag_atm*(uvel-ua) -drag_ice*(uvel-ui)
-         !aye=-zff*uvel -grav*ssh_y +wave_rad*vwave &
-         !    -drag_ocn*(vvel-vo) -drag_atm*(vvel-va) -drag_ice*(vvel-vi)
-         axe = -grav * ssh_x + wave_rad * uwave
-         aye = -grav * ssh_y + wave_rad * vwave
-         IF( alpha > 0._wp ) THEN   ! If implicit, use time-level (n) rather than RK4 latest
-            axe = axe + zff*vvel0
-            aye = aye - zff*uvel0
+         !zaxe= zff*pvvel -grav*zssh_x +zwave_rad*zuwave &
+         !    -zdrag_ocn*(puvel-zuo) -zdrag_atm*(puvel-zua) -zdrag_ice*(puvel-zui)
+         !zaye=-zff*puvel -grav*zssh_y +zwave_rad*zvwave &
+         !    -zdrag_ocn*(pvvel-zvo) -zdrag_atm*(pvvel-zva) -zdrag_ice*(pvvel-zvi)
+         zaxe = -grav * zssh_x + zwave_rad * zuwave
+         zaye = -grav * zssh_y + zwave_rad * zvwave
+         IF( pp_alpha > 0._wp ) THEN   ! If implicit, use time-level (n) rather than RK4 latest
+            zaxe = zaxe + zff*pvvel0
+            zaye = zaye - zff*puvel0
          else
-            axe=axe+zff*vvel
-            aye=aye-zff*uvel
+            zaxe=zaxe+zff*pvvel
+            zaye=zaye-zff*puvel
          endif
-         if (beta>0.) then ! If implicit, use time-level (n) rather than RK4 latest
-            axe=axe-drag_ocn*(uvel0-uo) -drag_atm*(uvel0-ua) -drag_ice*(uvel0-ui)
-            aye=aye-drag_ocn*(vvel0-vo) -drag_atm*(vvel0-va) -drag_ice*(vvel0-vi)
+         if (pp_beta>0.) then ! If implicit, use time-level (n) rather than RK4 latest
+            zaxe=zaxe-zdrag_ocn*(puvel0-zuo) -zdrag_atm*(puvel0-zua) -zdrag_ice*(puvel0-zui)
+            zaye=zaye-zdrag_ocn*(pvvel0-zvo) -zdrag_atm*(pvvel0-zva) -zdrag_ice*(pvvel0-zvi)
          else
-            axe=axe-drag_ocn*(uvel-uo) -drag_atm*(uvel-ua) -drag_ice*(uvel-ui)
-            aye=aye-drag_ocn*(vvel-vo) -drag_atm*(vvel-va) -drag_ice*(vvel-vi)
+            zaxe=zaxe-zdrag_ocn*(puvel-zuo) -zdrag_atm*(puvel-zua) -zdrag_ice*(puvel-zui)
+            zaye=zaye-zdrag_ocn*(pvvel-zvo) -zdrag_atm*(pvvel-zva) -zdrag_ice*(pvvel-zvi)
          endif
 
          ! Solve for implicit accelerations
-         IF( alpha + beta > 0._wp ) THEN
-            lambda = drag_ocn + drag_atm + drag_ice
-            A11 = 1.+beta*dt*lambda
-            A12 = alpha*dt*zff
-            detA = 1._wp / ( A11*A11 + A12*A12 )
-            ax = detA * ( A11*axe+A12*aye )
-            ay = detA * ( A11*aye-A12*axe )
+         IF( pp_alpha + pp_beta > 0._wp ) THEN
+            zlambda = zdrag_ocn + zdrag_atm + zdrag_ice
+            zA11 = 1.+pp_beta*pdt*zlambda
+            zA12 = pp_alpha*pdt*zff
+            zdetA = 1._wp / ( zA11*zA11 + zA12*zA12 )
+            pax = zdetA * ( zA11*zaxe+zA12*zaye )
+            pay = zdetA * ( zA11*zaye-zA12*zaxe )
          else
-            ax=axe   ;   ay=aye
+            pax=zaxe   ;   pay=zaye
          endif
 
-         uveln = uvel0 + dt*ax
-         vveln = vvel0 + dt*ay
+         zuveln = puvel0 + pdt*pax
+         zvveln = pvvel0 + pdt*pay
          !
       END DO      ! itloop
 
       IF( rn_speed_limit > 0.) THEN       ! Limit speed of bergs based on a CFL criteria (if asked)
-         speed = SQRT( uveln*uveln + vveln*vveln )    ! Speed of berg
-         IF( speed > 0.) THEN
-            loc_dx = MIN( e1, e2 )                          ! minimum grid spacing
-            new_speed = loc_dx / dt * rn_speed_limit     ! Speed limit as a factor of dx / dt
-            IF( new_speed < speed ) THEN
-               uveln = uveln * ( new_speed / speed )        ! Scale velocity to reduce speed
-               vveln = vveln * ( new_speed / speed )        ! without changing the direction
+         zspeed = SQRT( zuveln*zuveln + zvveln*zvveln )    ! Speed of berg
+         IF( zspeed > 0.) THEN
+            zloc_dx = MIN( pe1, pe2 )                          ! minimum grid spacing
+            zspeed_new = zloc_dx / pdt * rn_speed_limit     ! Speed limit as a factor of dx / dt
+            IF( zspeed_new < zspeed ) THEN
+               zuveln = zuveln * ( zspeed_new / zspeed )        ! Scale velocity to reduce speed
+               zvveln = zvveln * ( zspeed_new / zspeed )        ! without changing the direction
                CALL speed_budget()
             ENDIF
@@ -369,7 +367,7 @@
       ENDIF
       !                                      ! check the speed and acceleration limits
-      IF( ABS( uveln ) > vel_lim   .OR. ABS( vveln ) > vel_lim   )   &
+      IF( ABS( zuveln ) > pp_vel_lim   .OR. ABS( zvveln ) > pp_vel_lim   )   &
          WRITE(numicb,'("pe=",i3,x,a)') narea,'Dump triggered by excessive velocity'
-      IF( ABS( ax    ) > accel_lim .OR. ABS( ay    ) > accel_lim )   &
+      IF( ABS( pax    ) > pp_accel_lim .OR. ABS( pay    ) > pp_accel_lim )   &
          WRITE(numicb,'("pe=",i3,x,a)') narea,'Dump triggered by excessive acceleration'
       !
Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbini.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbini.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbini.F90	(revision 3359)
@@ -39,8 +39,8 @@
    TYPE(FLD_N), PRIVATE        ::   sn_icb                 ! information about the calving file to be read
 
-   PRIVATE  icb_alloc      ! routine called in xxx.F90 module
-   PUBLIC   icb_init       ! routine called in xxx.F90 module
-   PUBLIC   icb_gen        ! routine called in xxx.F90 module
-   PUBLIC   icb_nam        ! routine called in xxx.F90 module
+   PUBLIC   icb_init       ! routine called in nemogcm.F90 module
+   PUBLIC   icb_gen        ! routine called in icbclv.F90 module
+   PRIVATE  icb_nam
+   PRIVATE  icb_alloc  
 
 CONTAINS
@@ -100,18 +100,18 @@
       ALLOCATE( ssh_e(0:jpi+1,0:jpj+1) , STAT=ill)
       icb_alloc = icb_alloc + ill
-      ALLOCATE( initial_width    (nclasses) , STAT=ill)
-      icb_alloc = icb_alloc + ill
-      ALLOCATE( initial_length   (nclasses) , STAT=ill)
-      icb_alloc = icb_alloc + ill
-      ALLOCATE( p_calving(jpi,jpj) , STAT=ill)
-      icb_alloc = icb_alloc + ill
-      ALLOCATE( p_calving_hflx(jpi,jpj) , STAT=ill)
-      icb_alloc = icb_alloc + ill
-
-      ALLOCATE( icbfldpts(jpi) , STAT=ill)
-      icb_alloc = icb_alloc + ill
-      ALLOCATE( icbflddest(jpi) , STAT=ill)
-      icb_alloc = icb_alloc + ill
-      ALLOCATE( icbfldproc(jpni) , STAT=ill)
+      ALLOCATE( first_width    (nclasses) , STAT=ill)
+      icb_alloc = icb_alloc + ill
+      ALLOCATE( first_length   (nclasses) , STAT=ill)
+      icb_alloc = icb_alloc + ill
+      ALLOCATE( src_calving(jpi,jpj) , STAT=ill)
+      icb_alloc = icb_alloc + ill
+      ALLOCATE( src_calving_hflx(jpi,jpj) , STAT=ill)
+      icb_alloc = icb_alloc + ill
+
+      ALLOCATE( nicbfldpts(jpi) , STAT=ill)
+      icb_alloc = icb_alloc + ill
+      ALLOCATE( nicbflddest(jpi) , STAT=ill)
+      icb_alloc = icb_alloc + ill
+      ALLOCATE( nicbfldproc(jpni) , STAT=ill)
       icb_alloc = icb_alloc + ill
 
@@ -121,5 +121,5 @@
    END FUNCTION icb_alloc
 
-   SUBROUTINE icb_init( dt, kt )
+   SUBROUTINE icb_init( pdt, kt )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE dom_init  ***
@@ -129,11 +129,12 @@
       !! ** Method  : - blah blah
       !!----------------------------------------------------------------------
-      REAL(wp)                , INTENT(in) ::   dt      ! iceberg time-step (rdt*nn_fsbc)
+      REAL(wp)                , INTENT(in) ::   pdt     ! iceberg time-step (rdt*nn_fsbc)
       INTEGER                 , INTENT(in) ::   kt      ! time step number
       !
-      INTEGER                              ::   ji, jj, jn, i1, j1
-      INTEGER                              ::   ii, inum, ivar, k1
+      INTEGER                              ::   ji, jj, jn                ! loop counters
+      INTEGER                              ::   i1, i2, i3                ! dummy integers
+      INTEGER                              ::   ii, inum, ivar
       INTEGER                              ::   istat1, istat2, istat3
-      CHARACTER(len=300)                   ::   sdist
+      CHARACTER(len=300)                   ::   cl_sdist
       !!----------------------------------------------------------------------
 
@@ -146,7 +147,7 @@
       ! set parameters (mostly from namelist)
       !
-      berg_dt                  = dt
-      initial_width (:) = SQRT(  rn_initial_mass(:) / ( rn_LoW_ratio*rn_rho_bergs*rn_initial_thickness(:) )  )
-      initial_length(:) = rn_LoW_ratio * initial_width(:)
+      berg_dt                  = pdt
+      first_width (:) = SQRT(  rn_initial_mass(:) / ( rn_LoW_ratio * rn_rho_bergs * rn_initial_thickness(:) )  )
+      first_length(:) = rn_LoW_ratio * first_width(:)
 
       berg_grid%calving      (:,:)   = 0._wp
@@ -154,9 +155,9 @@
       berg_grid%stored_heat  (:,:)   = 0._wp
       berg_grid%floating_melt(:,:)   = 0._wp
-      berg_grid%maxclass      (:,:)  = nclasses
+      berg_grid%maxclass     (:,:)   = nclasses
       berg_grid%stored_ice   (:,:,:) = 0._wp
       berg_grid%tmp          (:,:)   = 0._wp
-      p_calving        (:,:)   = 0._wp
-      p_calving_hflx   (:,:)   = 0._wp
+      src_calving              (:,:)   = 0._wp
+      src_calving_hflx         (:,:)   = 0._wp
 
       ! domain for icebergs
@@ -166,19 +167,19 @@
       ! for the north fold we work out which points communicate by asking
       ! lbc_lnk to pass processor number (valid even in single processor case)
-      ! borrow p_calving arrays for this
+      ! borrow src_calving arrays for this
       !
       ! pack i and j together using a scaling of a power of 10
-      icbpack = 10000
-      IF( jpiglo >= icbpack ) CALL ctl_stop('icbini: processor index packing failure')
-      icbfldproc(:) = -1
+      nicbpack = 10000
+      IF( jpiglo >= nicbpack ) CALL ctl_stop('icbini: processor index packing failure')
+      nicbfldproc(:) = -1
 
       DO jj = 1, jpj
          DO ji = 1, jpi
-            p_calving_hflx(ji,jj) = narea
-            p_calving(ji,jj)      = icbpack*(njmpp+jj-1) + nimpp+ji-1
+            src_calving_hflx(ji,jj) = narea
+            src_calving(ji,jj)      = nicbpack*(njmpp+jj-1) + nimpp+ji-1
          ENDDO
       ENDDO
-      CALL lbc_lnk( p_calving_hflx, 'T', 1._wp )
-      CALL lbc_lnk( p_calving     , 'T', 1._wp )
+      CALL lbc_lnk( src_calving_hflx, 'T', 1._wp )
+      CALL lbc_lnk( src_calving     , 'T', 1._wp )
 
       ! work out interior of processor from exchange array
@@ -186,15 +187,15 @@
       ! last  entry                               is right hand interior index
       jj = jpj/2
-      icbdi = -1
-      icbei = -1
+      nicbdi = -1
+      nicbei = -1
       DO ji = 1,jpi
-         k1 = INT( p_calving(ji,jj) )
-         j1 = INT( k1/icbpack )
-         i1 = k1 - j1*icbpack
+         i3 = INT( src_calving(ji,jj) )
+         i2 = INT( i3/nicbpack )
+         i1 = i3 - i2*nicbpack
          IF( i1 == nimpp+ji-1 ) THEN
-            IF( icbdi < 0 ) THEN
-               icbdi = ji
+            IF( nicbdi < 0 ) THEN
+               nicbdi = ji
             ELSE
-               icbei = ji
+               nicbei = ji
             ENDIF
          ENDIF
@@ -203,15 +204,15 @@
       ! repeat for j direction
       ji = jpi/2
-      icbdj = -1
-      icbej = -1
+      nicbdj = -1
+      nicbej = -1
       DO jj = 1,jpj
-         k1 = INT( p_calving(ji,jj) )
-         j1 = INT( k1/icbpack )
-         i1 = k1 - j1*icbpack
-         IF( j1 == njmpp+jj-1 ) THEN
-            IF( icbdj < 0 ) THEN
-               icbdj = jj
+         i3 = INT( src_calving(ji,jj) )
+         i2 = INT( i3/nicbpack )
+         i1 = i3 - i2*nicbpack
+         IF( i2 == njmpp+jj-1 ) THEN
+            IF( nicbdj < 0 ) THEN
+               nicbdj = jj
             ELSE
-               icbej = jj
+               nicbej = jj
             ENDIF
          ENDIF
@@ -219,29 +220,29 @@
          
       ! special for east-west boundary exchange we save the destination index
-      i1 = MAX( icbdi-1, 1)
-      k1 = INT( p_calving(i1,jpj/2) )
-      jj = INT( k1/icbpack )
-      icb_left = REAL( k1 - icbpack*jj, wp )
-      i1 = MIN( icbei+1, jpi )
-      k1 = INT( p_calving(i1,jpj/2) )
-      jj = INT( k1/icbpack )
-      icb_right = REAL( k1 - icbpack*jj, wp )
+      i1 = MAX( nicbdi-1, 1)
+      i3 = INT( src_calving(i1,jpj/2) )
+      jj = INT( i3/nicbpack )
+      ricb_left = REAL( i3 - nicbpack*jj, wp )
+      i1 = MIN( nicbei+1, jpi )
+      i3 = INT( src_calving(i1,jpj/2) )
+      jj = INT( i3/nicbpack )
+      ricb_right = REAL( i3 - nicbpack*jj, wp )
       
       ! north fold
       IF( npolj > 0 ) THEN
          !
-         ! icebergs in row icbej+1 get passed across fold
-         icbfldpts(:)  = INT( p_calving(:,icbej+1) )
-         icbflddest(:) = INT( p_calving_hflx(:,icbej+1) )
+         ! icebergs in row nicbej+1 get passed across fold
+         nicbfldpts(:)  = INT( src_calving(:,nicbej+1) )
+         nicbflddest(:) = INT( src_calving_hflx(:,nicbej+1) )
          !
          ! work out list of unique processors to talk to
-         DO ji = icbdi, icbei
-            ii = icbflddest(ji)
+         DO ji = nicbdi, nicbei
+            ii = nicbflddest(ji)
             DO jn = 1, jpni
-               IF( icbfldproc(jn) == -1 ) THEN
-                  icbfldproc(jn) = ii
+               IF( nicbfldproc(jn) == -1 ) THEN
+                  nicbfldproc(jn) = ii
                   EXIT
                ENDIF
-               IF( icbfldproc(jn) == ii ) EXIT
+               IF( nicbfldproc(jn) == ii ) EXIT
             ENDDO
          ENDDO
@@ -253,36 +254,36 @@
          WRITE(numicb,*) 'nldi, nlei ', nldi, nlei
          WRITE(numicb,*) 'nldj, nlej ', nldj, nlej
-         WRITE(numicb,*) 'berg i interior ', icbdi, icbei
-         WRITE(numicb,*) 'berg j interior ', icbdj, icbej
-         WRITE(numicb,*) 'berg left       ', icb_left
-         WRITE(numicb,*) 'berg right      ', icb_right
+         WRITE(numicb,*) 'berg i interior ', nicbdi, nicbei
+         WRITE(numicb,*) 'berg j interior ', nicbdj, nicbej
+         WRITE(numicb,*) 'berg left       ', ricb_left
+         WRITE(numicb,*) 'berg right      ', ricb_right
          jj = jpj/2
          WRITE(numicb,*) "central j line:"
          WRITE(numicb,*) "i processor"
-         WRITE(numicb,*) (INT(p_calving_hflx(ji,jj)), ji=1,jpi)
+         WRITE(numicb,*) (INT(src_calving_hflx(ji,jj)), ji=1,jpi)
          WRITE(numicb,*) "i point"
-         WRITE(numicb,*) (INT(p_calving(ji,jj)), ji=1,jpi)
+         WRITE(numicb,*) (INT(src_calving(ji,jj)), ji=1,jpi)
          ji = jpi/2
          WRITE(numicb,*) "central i line:"
          WRITE(numicb,*) "j processor"
-         WRITE(numicb,*) (INT(p_calving_hflx(ji,jj)), jj=1,jpj)
+         WRITE(numicb,*) (INT(src_calving_hflx(ji,jj)), jj=1,jpj)
          WRITE(numicb,*) "j point"
-         WRITE(numicb,*) (INT(p_calving(ji,jj)), jj=1,jpj)
+         WRITE(numicb,*) (INT(src_calving(ji,jj)), jj=1,jpj)
          IF( npolj > 0 ) THEN
             WRITE(numicb,*) 'north fold destination points '
-            WRITE(numicb,*) icbfldpts
+            WRITE(numicb,*) nicbfldpts
             WRITE(numicb,*) 'north fold destination procs  '
-            WRITE(numicb,*) icbflddest
+            WRITE(numicb,*) nicbflddest
          ENDIF
          CALL flush(numicb)
       ENDIF
       
-      p_calving(:,:)      = 0._wp
-      p_calving_hflx(:,:) = 0._wp
+      src_calving(:,:)      = 0._wp
+      src_calving_hflx(:,:) = 0._wp
 
       ! assign each new iceberg with a unique number constructed from the processor number
       ! and incremented by the total number of processors
-      kount_bergs(:) = 0
-      kount_bergs(1) = narea - jpnij
+      num_bergs(:) = 0
+      num_bergs(1) = narea - jpnij
 
       ! when not generating test icebergs we need to setup calving file
@@ -290,11 +291,11 @@
          !
          ! maximum distribution class array does not change in time so read it once
-         sdist = TRIM( cn_dir )//TRIM( sn_icb%clname )
-         CALL iom_open ( sdist, inum )                              ! open file
+         cl_sdist = TRIM( cn_dir )//TRIM( sn_icb%clname )
+         CALL iom_open ( cl_sdist, inum )                              ! open file
          ivar = iom_varid( inum, 'maxclass', ldstop=.FALSE. )
          IF( ivar > 0 ) THEN
-            CALL iom_get  ( inum, jpdom_data, 'maxclass', p_calving )   ! read the max distribution array
-            berg_grid%maxclass(:,:) = INT( p_calving )
-            p_calving(:,:) = 0._wp
+            CALL iom_get  ( inum, jpdom_data, 'maxclass', src_calving )   ! read the max distribution array
+            berg_grid%maxclass(:,:) = INT( src_calving )
+            src_calving(:,:) = 0._wp
          ENDIF
          CALL iom_close( inum )                                     ! close file
@@ -321,5 +322,5 @@
             !
             CALL icebergs_read_restart()
-            restarted_bergs = .TRUE.
+             l_restarted_bergs = .TRUE.
          ENDIF
       ENDIF
@@ -336,5 +337,5 @@
 
       ! Local variables
-      INTEGER                         ::   i, j, nbergs
+      INTEGER                         ::   ji, jj, ibergs
       TYPE(iceberg)                   ::   localberg ! NOT a pointer but an actual local variable
       TYPE(point)                     ::   localpt
@@ -358,18 +359,18 @@
       ! use tmask here because tmask_i has been doctored on one side of the north fold line
 
-      DO j = icbdj,icbej
-         DO i = icbdi,icbei
-            IF (tmask(i,j,1) .GT. 0._wp .AND. &
-                gphit(i,j) .GT. rn_test_box(3) .AND. gphit(i,j) .LT. rn_test_box(4) .AND. &
-                glamt(i,j) .GT. rn_test_box(1) .AND. glamt(i,j) .LT. rn_test_box(2)) THEN
+      DO jj = nicbdj,nicbej
+         DO ji = nicbdi,nicbei
+            IF (tmask(ji,jj,1) .GT. 0._wp .AND. &
+                gphit(ji,jj) .GT. rn_test_box(3) .AND. gphit(ji,jj) .LT. rn_test_box(4) .AND. &
+                glamt(ji,jj) .GT. rn_test_box(1) .AND. glamt(ji,jj) .LT. rn_test_box(2)) THEN
                localberg%mass_scaling = rn_mass_scaling(iberg)
-               localpt%xi = REAL( nimpp+i-1, wp )
-               localpt%yj = REAL( njmpp+j-1, wp )
+               localpt%xi = REAL( nimpp+ji-1, wp )
+               localpt%yj = REAL( njmpp+jj-1, wp )
                localpt%lon = bilin(glamt, localpt%xi, localpt%yj, 'T', 0, 0 )
                localpt%lat = bilin(gphit, localpt%xi, localpt%yj, 'T', 0, 0 )
                localpt%mass = rn_initial_mass(iberg)
                localpt%thickness = rn_initial_thickness(iberg)
-               localpt%width = initial_width(iberg)
-               localpt%length = initial_length(iberg)
+               localpt%width = first_width(iberg)
+               localpt%length = first_length(iberg)
                localpt%year = iyr
                localpt%day = FLOAT(iday)+(FLOAT(ihr)+FLOAT(imin)/60._wp)/24._wp
@@ -379,5 +380,5 @@
                localpt%vvel = 0._wp
                CALL increment_kounter()
-               localberg%number(:) = kount_bergs(:)
+               localberg%number(:) = num_bergs(:)
                call add_new_berg_to_list(localberg, localpt)
             ENDIF
@@ -385,7 +386,7 @@
       ENDDO
 
-      nbergs = count_bergs()
-      IF( lk_mpp ) CALL mpp_sum(nbergs)
-      WRITE(numicb,'(a,i6,a)') 'diamonds, icb_gen: ',nbergs,' were generated'
+      ibergs = count_bergs()
+      IF( lk_mpp ) CALL mpp_sum(ibergs)
+      WRITE(numicb,'(a,i6,a)') 'diamonds, icb_gen: ',ibergs,' were generated'
 
    END SUBROUTINE icb_gen
@@ -406,6 +407,6 @@
          &              ln_time_average_weight, nn_test_icebergs, rn_test_box, rn_speed_limit,     &
          &              cn_dir, sn_icb
-      INTEGER   ::   k  ! loop counter
-      REAL(wp)  ::   dfact
+      INTEGER   ::   jn  ! loop counter
+      REAL(wp)  ::   zfact
       !!----------------------------------------------------------------------
 
@@ -431,10 +432,10 @@
       ENDIF
 
-      dfact = SUM( rn_distribution )
-      IF( dfact < 1._wp ) THEN
-         IF( dfact <= 0._wp ) THEN
+      zfact = SUM( rn_distribution )
+      IF( zfact < 1._wp ) THEN
+         IF( zfact <= 0._wp ) THEN
             CALL ctl_stop('icb_init: sum of berg distribution equal to zero')
          ELSE
-            rn_distribution(:) = rn_distribution(:) / dfact
+            rn_distribution(:) = rn_distribution(:) / zfact
             CALL ctl_warn('icb_init: sum of berg input distribution not equal to one and so RESCALED')
          ENDIF
@@ -448,18 +449,18 @@
          WRITE(numout,*) '   Period between sampling of position for trajectory storage   nn_sample_rate = ', nn_sample_rate
          WRITE(numout,*) '   Mass thresholds between iceberg classes (kg)                 rn_initial_mass     ='
-         DO k=1,nclasses
-            WRITE(numout,'(a,f15.2)') '                                                                ',rn_initial_mass(k)
+         DO jn=1,nclasses
+            WRITE(numout,'(a,f15.2)') '                                                                ',rn_initial_mass(jn)
          ENDDO
          WRITE(numout,*) '   Fraction of calving to apply to this class (non-dim)         rn_distribution     ='
-         DO k=1,nclasses
-            WRITE(numout,'(a,f10.2)') '                                                                ',rn_distribution(k)
+         DO jn=1,nclasses
+            WRITE(numout,'(a,f10.2)') '                                                                ',rn_distribution(jn)
          ENDDO
          WRITE(numout,*) '   Ratio between effective and real iceberg mass (non-dim)      rn_mass_scaling     = '
-         DO k=1,nclasses
-            WRITE(numout,'(a,f10.2)') '                                                                ',rn_mass_scaling(k)
+         DO jn=1,nclasses
+            WRITE(numout,'(a,f10.2)') '                                                                ',rn_mass_scaling(jn)
          ENDDO
          WRITE(numout,*) '   Total thickness of newly calved bergs (m)                   rn_initial_thickness = '
-         DO k=1,nclasses
-            WRITE(numout,'(a,f10.2)') '                                                                ',rn_initial_thickness(k)
+         DO jn=1,nclasses
+            WRITE(numout,'(a,f10.2)') '                                                                ',rn_initial_thickness(jn)
          ENDDO
          WRITE(numout,*) '   Timesteps between verbose messages                           nn_verbose_write    = ', nn_verbose_write
Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icblbc.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icblbc.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icblbc.F90	(revision 3359)
@@ -19,10 +19,10 @@
    !!                       routines because they do not lie on regular jpi,jpj grids
    !!                       Processor exchanges are handled as in lib_mpp whenever icebergs step 
-   !!                       across boundary of interior domain (icbdi-icbei, icbdj-icbej)
+   !!                       across boundary of interior domain (nicbdi-nicbei, nicbdj-nicbej)
    !!                       so that iceberg does not exist in more than one processor
    !!                       North fold exchanges controlled by three arrays:
-   !!                          icbflddest - unique processor numbers that current one exchanges with
-   !!                          icbfldproc - processor number that current grid point exchanges with
-   !!                          icbfldpts  - packed i,j point in exchanging processor
+   !!                          nicbflddest - unique processor numbers that current one exchanges with
+   !!                          nicbfldproc - processor number that current grid point exchanges with
+   !!                          nicbfldpts  - packed i,j point in exchanging processor
    !!----------------------------------------------------------------------
 
@@ -56,6 +56,6 @@
    TYPE(buffer), POINTER           ::   obuffer_f=>NULL() , ibuffer_f=>NULL()
 
-   INTEGER, PARAMETER, PUBLIC      ::   delta_buf = 25             ! Size by which to increment buffers
-   INTEGER, PARAMETER, PUBLIC      ::   buffer_width = 15+nkounts  ! items to store for each berg
+   INTEGER, PARAMETER, PUBLIC      ::   pp_delta_buf = 25             ! Size by which to increment buffers
+   INTEGER, PARAMETER, PUBLIC      ::   pp_buffer_width = 15+nkounts  ! items to store for each berg
 
 #endif
@@ -88,5 +88,5 @@
       TYPE(iceberg), POINTER :: this
       TYPE(point)  , POINTER :: pt
-      INTEGER                :: ine
+      INTEGER                :: iine
 
       !! periodic east/west boundaries
@@ -98,9 +98,9 @@
          DO WHILE( ASSOCIATED(this) )
             pt => this%current_point
-            ine = INT( pt%xi + 0.5 )
-            IF( ine .GT. nimpp+icbei-1 ) THEN
-               pt%xi = icb_right + MOD(pt%xi, 1._wp ) - 1._wp
-            ELSE IF( ine .LT. nimpp+icbdi-1 ) THEN
-               pt%xi = icb_left + MOD(pt%xi, 1._wp )
+            iine = INT( pt%xi + 0.5 )
+            IF( iine .GT. nimpp+nicbei-1 ) THEN
+               pt%xi = ricb_right + MOD(pt%xi, 1._wp ) - 1._wp
+            ELSE IF( iine .LT. nimpp+nicbdi-1 ) THEN
+               pt%xi = ricb_left + MOD(pt%xi, 1._wp )
             ENDIF
             this => this%next
@@ -136,22 +136,22 @@
       TYPE(iceberg), POINTER :: this
       TYPE(point)  , POINTER :: pt
-      INTEGER                :: ine, jne, kpts
-      INTEGER                :: jiglo, jjglo
+      INTEGER                :: iine, ijne, ipts
+      INTEGER                :: iiglo, ijglo
 
       this => first_berg
       DO WHILE( ASSOCIATED(this) )
          pt => this%current_point
-         jne = INT( pt%yj + 0.5 )
-         IF( jne .GT. njmpp+icbej-1 ) THEN
+         ijne = INT( pt%yj + 0.5 )
+         IF( ijne .GT. njmpp+nicbej-1 ) THEN
             !
-            ine = INT( pt%xi + 0.5 )
-            kpts  = icbfldpts (ine-nimpp+1)
+            iine = INT( pt%xi + 0.5 )
+            ipts  = nicbfldpts (iine-nimpp+1)
             !
             ! moving across the cut line means both position and
             ! velocity must change
-            jjglo = INT( kpts/icbpack )
-            jiglo = kpts - icbpack*jjglo
-            pt%xi = jiglo - ( pt%xi - REAL(ine,wp) )
-            pt%yj = jjglo - ( pt%yj - REAL(jne,wp) )
+            ijglo = INT( ipts/nicbpack )
+            iiglo = ipts - nicbpack*ijglo
+            pt%xi = iiglo - ( pt%xi - REAL(iine,wp) )
+            pt%yj = ijglo - ( pt%yj - REAL(ijne,wp) )
             pt%uvel = -1._wp * pt%uvel
             pt%vvel = -1._wp * pt%vvel
@@ -181,40 +181,40 @@
       TYPE(iceberg)         , POINTER     :: tmpberg, this
       TYPE(point)           , POINTER     :: pt
-      INTEGER                             :: nbergs_to_send_e, nbergs_to_send_w
-      INTEGER                             :: nbergs_to_send_n, nbergs_to_send_s
-      INTEGER                             :: nbergs_rcvd_from_e, nbergs_rcvd_from_w
-      INTEGER                             :: nbergs_rcvd_from_n, nbergs_rcvd_from_s
-      INTEGER                             :: i, nbergs_start, nbergs_end
-      INTEGER                             :: ine, jne
-      INTEGER                             :: pe_N, pe_S, pe_W, pe_E
-      REAL(wp), DIMENSION(2)              :: ewbergs, webergs, nsbergs, snbergs
-      INTEGER                             :: ml_req1, ml_req2, ml_req3, ml_req4
-      INTEGER                             :: ml_req5, ml_req6, ml_req7, ml_req8, ml_err
-      INTEGER, DIMENSION(MPI_STATUS_SIZE) :: ml_stat
+      INTEGER                             :: ibergs_to_send_e, ibergs_to_send_w
+      INTEGER                             :: ibergs_to_send_n, ibergs_to_send_s
+      INTEGER                             :: ibergs_rcvd_from_e, ibergs_rcvd_from_w
+      INTEGER                             :: ibergs_rcvd_from_n, ibergs_rcvd_from_s
+      INTEGER                             :: i, ibergs_start, ibergs_end
+      INTEGER                             :: iine, ijne
+      INTEGER                             :: ipe_N, ipe_S, ipe_W, ipe_E
+      REAL(wp), DIMENSION(2)              :: zewbergs, zwebergs, znsbergs, zsnbergs
+      INTEGER                             :: iml_req1, iml_req2, iml_req3, iml_req4
+      INTEGER                             :: iml_req5, iml_req6, iml_req7, iml_req8, iml_err
+      INTEGER, DIMENSION(MPI_STATUS_SIZE) :: iml_stat
 
       ! set up indices of neighbouring processors
-      pe_N = -1
-      pe_S = -1
-      pe_W = -1
-      pe_E = -1
-      IF( nbondi .EQ.  0 .OR. nbondi .EQ. 1) pe_W = nowe
-      IF( nbondi .EQ. -1 .OR. nbondi .EQ. 0) pe_E = noea
-      IF( nbondj .EQ.  0 .OR. nbondj .EQ. 1) pe_S = noso
-      IF( nbondj .EQ. -1 .OR. nbondj .EQ. 0) pe_N = nono
+      ipe_N = -1
+      ipe_S = -1
+      ipe_W = -1
+      ipe_E = -1
+      IF( nbondi .EQ.  0 .OR. nbondi .EQ. 1) ipe_W = nowe
+      IF( nbondi .EQ. -1 .OR. nbondi .EQ. 0) ipe_E = noea
+      IF( nbondj .EQ.  0 .OR. nbondj .EQ. 1) ipe_S = noso
+      IF( nbondj .EQ. -1 .OR. nbondj .EQ. 0) ipe_N = nono
       !
       ! at northern line of processors with north fold handle bergs differently
-      IF( npolj > 0 ) pe_N = -1
+      IF( npolj > 0 ) ipe_N = -1
 
       ! if there's only one processor in x direction then don't let mpp try to handle periodicity
       IF( jpni == 1 ) THEN
-         pe_E = -1
-         pe_W = -1
+         ipe_E = -1
+         ipe_W = -1
       ENDIF
 
       IF( nn_verbose_level >= 2 ) THEN
-         WRITE(numicb,*) 'processor west  : ', pe_W
-         WRITE(numicb,*) 'processor east  : ', pe_E
-         WRITE(numicb,*) 'processor north : ', pe_N
-         WRITE(numicb,*) 'processor south : ', pe_S
+         WRITE(numicb,*) 'processor west  : ', ipe_W
+         WRITE(numicb,*) 'processor east  : ', ipe_E
+         WRITE(numicb,*) 'processor north : ', ipe_N
+         WRITE(numicb,*) 'processor south : ', ipe_S
          WRITE(numicb,*) 'processor nimpp : ', nimpp
          WRITE(numicb,*) 'processor njmpp : ', njmpp
@@ -234,15 +234,15 @@
       IF( nn_verbose_level > 0 ) THEN
          ! store the number of icebergs on this processor at start
-         nbergs_start = count_bergs()
-      ENDIF
-
-      nbergs_to_send_e = 0
-      nbergs_to_send_w = 0
-      nbergs_to_send_n = 0
-      nbergs_to_send_s = 0
-      nbergs_rcvd_from_e = 0
-      nbergs_rcvd_from_w = 0
-      nbergs_rcvd_from_n = 0
-      nbergs_rcvd_from_s = 0
+         ibergs_start = count_bergs()
+      ENDIF
+
+      ibergs_to_send_e = 0
+      ibergs_to_send_w = 0
+      ibergs_to_send_n = 0
+      ibergs_to_send_s = 0
+      ibergs_rcvd_from_e = 0
+      ibergs_rcvd_from_w = 0
+      ibergs_rcvd_from_n = 0
+      ibergs_rcvd_from_s = 0
 
       ! Find number of bergs that headed east/west
@@ -251,30 +251,30 @@
          DO WHILE (ASSOCIATED(this))
             pt => this%current_point
-            ine = INT( pt%xi + 0.5 )
-            IF( pe_E >= 0 .AND. ine .GT. nimpp+icbei-1 ) THEN
+            iine = INT( pt%xi + 0.5 )
+            IF( ipe_E >= 0 .AND. iine .GT. nimpp+nicbei-1 ) THEN
                tmpberg => this
                this => this%next
-               nbergs_to_send_e = nbergs_to_send_e + 1
+               ibergs_to_send_e = ibergs_to_send_e + 1
                IF( nn_verbose_level >= 4 ) THEN
-                  WRITE(numicb,*) 'bergstep ',ktberg,' packing berg ',tmpberg%number(:),' for transfer to east'
+                  WRITE(numicb,*) 'bergstep ',nktberg,' packing berg ',tmpberg%number(:),' for transfer to east'
                   CALL flush( numicb )
                ENDIF
                ! deal with periodic case
-               tmpberg%current_point%xi = icb_right + MOD(tmpberg%current_point%xi, 1._wp ) - 1._wp
+               tmpberg%current_point%xi = ricb_right + MOD(tmpberg%current_point%xi, 1._wp ) - 1._wp
                ! now pack it into buffer and delete from list
-               CALL pack_berg_into_buffer( tmpberg, obuffer_e, nbergs_to_send_e)
+               CALL pack_berg_into_buffer( tmpberg, obuffer_e, ibergs_to_send_e)
                CALL delete_iceberg_from_list(first_berg, tmpberg)
-            ELSE IF( pe_W >= 0 .AND. ine .LT. nimpp+icbdi-1 ) THEN
+            ELSE IF( ipe_W >= 0 .AND. iine .LT. nimpp+nicbdi-1 ) THEN
                tmpberg => this
                this => this%next
-               nbergs_to_send_w = nbergs_to_send_w + 1
+               ibergs_to_send_w = ibergs_to_send_w + 1
                IF( nn_verbose_level >= 4 ) THEN
-                  WRITE(numicb,*) 'bergstep ',ktberg,' packing berg ',tmpberg%number(:),' for transfer to west'
+                  WRITE(numicb,*) 'bergstep ',nktberg,' packing berg ',tmpberg%number(:),' for transfer to west'
                   CALL flush( numicb )
                ENDIF
                ! deal with periodic case
-               tmpberg%current_point%xi = icb_left + MOD(tmpberg%current_point%xi, 1._wp )
+               tmpberg%current_point%xi = ricb_left + MOD(tmpberg%current_point%xi, 1._wp )
                ! now pack it into buffer and delete from list
-               CALL pack_berg_into_buffer( tmpberg, obuffer_w, nbergs_to_send_w)
+               CALL pack_berg_into_buffer( tmpberg, obuffer_w, ibergs_to_send_w)
                CALL delete_iceberg_from_list(first_berg, tmpberg)
             ELSE
@@ -284,5 +284,5 @@
       ENDIF
       if( nn_verbose_level >= 3) then
-         write(numicb,*) 'bergstep ',ktberg,' send ew: ', nbergs_to_send_e, nbergs_to_send_w
+         write(numicb,*) 'bergstep ',nktberg,' send ew: ', ibergs_to_send_e, ibergs_to_send_w
          call flush(numicb)
       endif
@@ -295,29 +295,29 @@
       SELECT CASE ( nbondi )
       CASE( -1 )
-         webergs(1) = nbergs_to_send_e
-         CALL mppsend( 12, webergs(1), 1, pe_E, ml_req1)
-         CALL mpprecv( 11, ewbergs(2), 1 )
-         IF( l_isend ) CALL mpi_wait( ml_req1, ml_stat, ml_err )
-         nbergs_rcvd_from_e = INT( ewbergs(2) )
+         zwebergs(1) = ibergs_to_send_e
+         CALL mppsend( 12, zwebergs(1), 1, ipe_E, iml_req1)
+         CALL mpprecv( 11, zewbergs(2), 1 )
+         IF( l_isend ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
+         ibergs_rcvd_from_e = INT( zewbergs(2) )
       CASE(  0 )
-         ewbergs(1) = nbergs_to_send_w
-         webergs(1) = nbergs_to_send_e
-         CALL mppsend( 11, ewbergs(1), 1, pe_W, ml_req2)
-         CALL mppsend( 12, webergs(1), 1, pe_E, ml_req3)
-         CALL mpprecv( 11, ewbergs(2), 1 )
-         CALL mpprecv( 12, webergs(2), 1 )
-         IF( l_isend ) CALL mpi_wait( ml_req2, ml_stat, ml_err )
-         IF( l_isend ) CALL mpi_wait( ml_req3, ml_stat, ml_err )
-         nbergs_rcvd_from_e = INT( ewbergs(2) )
-         nbergs_rcvd_from_w = INT( webergs(2) )
+         zewbergs(1) = ibergs_to_send_w
+         zwebergs(1) = ibergs_to_send_e
+         CALL mppsend( 11, zewbergs(1), 1, ipe_W, iml_req2)
+         CALL mppsend( 12, zwebergs(1), 1, ipe_E, iml_req3)
+         CALL mpprecv( 11, zewbergs(2), 1 )
+         CALL mpprecv( 12, zwebergs(2), 1 )
+         IF( l_isend ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
+         IF( l_isend ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
+         ibergs_rcvd_from_e = INT( zewbergs(2) )
+         ibergs_rcvd_from_w = INT( zwebergs(2) )
       CASE(  1 )
-         ewbergs(1) = nbergs_to_send_w
-         CALL mppsend( 11, ewbergs(1), 1, pe_W, ml_req4)
-         CALL mpprecv( 12, webergs(2), 1 )
-         IF( l_isend ) CALL mpi_wait( ml_req4, ml_stat, ml_err )
-         nbergs_rcvd_from_w = INT( webergs(2) )
+         zewbergs(1) = ibergs_to_send_w
+         CALL mppsend( 11, zewbergs(1), 1, ipe_W, iml_req4)
+         CALL mpprecv( 12, zwebergs(2), 1 )
+         IF( l_isend ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
+         ibergs_rcvd_from_w = INT( zwebergs(2) )
       END SELECT
       if( nn_verbose_level >= 3) then
-         write(numicb,*) 'bergstep ',ktberg,' recv ew: ', nbergs_rcvd_from_w, nbergs_rcvd_from_e
+         write(numicb,*) 'bergstep ',nktberg,' recv ew: ', ibergs_rcvd_from_w, ibergs_rcvd_from_e
          call flush(numicb)
       endif
@@ -325,13 +325,13 @@
       SELECT CASE ( nbondi )
       CASE( -1 )
-         IF( nbergs_to_send_e > 0 ) CALL mppsend( 14, obuffer_e%data, nbergs_to_send_e*buffer_width, pe_E, ml_req1 )
-         IF( nbergs_rcvd_from_e > 0 ) THEN
-            CALL increase_ibuffer(ibuffer_e, nbergs_rcvd_from_e)
-            CALL mpprecv( 13, ibuffer_e%data, nbergs_rcvd_from_e*buffer_width )
-         ENDIF
-         IF( nbergs_to_send_e > 0 .AND. l_isend ) CALL mpi_wait( ml_req1, ml_stat, ml_err )
-         DO i = 1, nbergs_rcvd_from_e
+         IF( ibergs_to_send_e > 0 ) CALL mppsend( 14, obuffer_e%data, ibergs_to_send_e*pp_buffer_width, ipe_E, iml_req1 )
+         IF( ibergs_rcvd_from_e > 0 ) THEN
+            CALL increase_ibuffer(ibuffer_e, ibergs_rcvd_from_e)
+            CALL mpprecv( 13, ibuffer_e%data, ibergs_rcvd_from_e*pp_buffer_width )
+         ENDIF
+         IF( ibergs_to_send_e > 0 .AND. l_isend ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
+         DO i = 1, ibergs_rcvd_from_e
             IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',ktberg,' unpacking berg ',INT(ibuffer_e%data(16,i)),' from east'
+               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_e%data(16,i)),' from east'
                CALL flush( numicb )
             ENDIF
@@ -339,26 +339,26 @@
          ENDDO
       CASE(  0 )
-         IF( nbergs_to_send_w > 0 ) CALL mppsend( 13, obuffer_w%data, nbergs_to_send_w*buffer_width, pe_W, ml_req2 )
-         IF( nbergs_to_send_e > 0 ) CALL mppsend( 14, obuffer_e%data, nbergs_to_send_e*buffer_width, pe_E, ml_req3 )
-         IF( nbergs_rcvd_from_e > 0 ) THEN
-            CALL increase_ibuffer(ibuffer_e, nbergs_rcvd_from_e)
-            CALL mpprecv( 13, ibuffer_e%data, nbergs_rcvd_from_e*buffer_width )
-         ENDIF
-         IF( nbergs_rcvd_from_w > 0 ) THEN
-            CALL increase_ibuffer(ibuffer_w, nbergs_rcvd_from_w)
-            CALL mpprecv( 14, ibuffer_w%data, nbergs_rcvd_from_w*buffer_width )
-         ENDIF
-         IF( nbergs_to_send_w > 0 .AND. l_isend ) CALL mpi_wait( ml_req2, ml_stat, ml_err )
-         IF( nbergs_to_send_e > 0 .AND. l_isend ) CALL mpi_wait( ml_req3, ml_stat, ml_err )
-         DO i = 1, nbergs_rcvd_from_e
+         IF( ibergs_to_send_w > 0 ) CALL mppsend( 13, obuffer_w%data, ibergs_to_send_w*pp_buffer_width, ipe_W, iml_req2 )
+         IF( ibergs_to_send_e > 0 ) CALL mppsend( 14, obuffer_e%data, ibergs_to_send_e*pp_buffer_width, ipe_E, iml_req3 )
+         IF( ibergs_rcvd_from_e > 0 ) THEN
+            CALL increase_ibuffer(ibuffer_e, ibergs_rcvd_from_e)
+            CALL mpprecv( 13, ibuffer_e%data, ibergs_rcvd_from_e*pp_buffer_width )
+         ENDIF
+         IF( ibergs_rcvd_from_w > 0 ) THEN
+            CALL increase_ibuffer(ibuffer_w, ibergs_rcvd_from_w)
+            CALL mpprecv( 14, ibuffer_w%data, ibergs_rcvd_from_w*pp_buffer_width )
+         ENDIF
+         IF( ibergs_to_send_w > 0 .AND. l_isend ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
+         IF( ibergs_to_send_e > 0 .AND. l_isend ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
+         DO i = 1, ibergs_rcvd_from_e
             IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',ktberg,' unpacking berg ',INT(ibuffer_e%data(16,i)),' from east'
+               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_e%data(16,i)),' from east'
                CALL flush( numicb )
             ENDIF
             CALL unpack_berg_from_buffer(first_berg, ibuffer_e, i)
          ENDDO
-         DO i = 1, nbergs_rcvd_from_w
+         DO i = 1, ibergs_rcvd_from_w
             IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',ktberg,' unpacking berg ',INT(ibuffer_w%data(16,i)),' from west'
+               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_w%data(16,i)),' from west'
                CALL flush( numicb )
             ENDIF
@@ -366,13 +366,13 @@
          ENDDO
       CASE(  1 )
-         IF( nbergs_to_send_w > 0 ) CALL mppsend( 13, obuffer_w%data, nbergs_to_send_w*buffer_width, pe_W, ml_req4 )
-         IF( nbergs_rcvd_from_w > 0 ) THEN
-            CALL increase_ibuffer(ibuffer_w, nbergs_rcvd_from_w)
-            CALL mpprecv( 14, ibuffer_w%data, nbergs_rcvd_from_w*buffer_width )
-         ENDIF
-         IF( nbergs_to_send_w > 0 .AND. l_isend ) CALL mpi_wait( ml_req4, ml_stat, ml_err )
-         DO i = 1, nbergs_rcvd_from_w
+         IF( ibergs_to_send_w > 0 ) CALL mppsend( 13, obuffer_w%data, ibergs_to_send_w*pp_buffer_width, ipe_W, iml_req4 )
+         IF( ibergs_rcvd_from_w > 0 ) THEN
+            CALL increase_ibuffer(ibuffer_w, ibergs_rcvd_from_w)
+            CALL mpprecv( 14, ibuffer_w%data, ibergs_rcvd_from_w*pp_buffer_width )
+         ENDIF
+         IF( ibergs_to_send_w > 0 .AND. l_isend ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
+         DO i = 1, ibergs_rcvd_from_w
             IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',ktberg,' unpacking berg ',INT(ibuffer_w%data(16,i)),' from west'
+               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_w%data(16,i)),' from west'
                CALL flush( numicb )
             ENDIF
@@ -390,24 +390,24 @@
          DO WHILE (ASSOCIATED(this))
             pt => this%current_point
-            jne = INT( pt%yj + 0.5 )
-            IF( pe_N >= 0 .AND. jne .GT. njmpp+icbej-1 ) THEN
+            ijne = INT( pt%yj + 0.5 )
+            IF( ipe_N >= 0 .AND. ijne .GT. njmpp+nicbej-1 ) THEN
                tmpberg => this
                this => this%next
-               nbergs_to_send_n = nbergs_to_send_n + 1
+               ibergs_to_send_n = ibergs_to_send_n + 1
                IF( nn_verbose_level >= 4 ) THEN
-                  WRITE(numicb,*) 'bergstep ',ktberg,' packing berg ',tmpberg%number(:),' for transfer to north'
+                  WRITE(numicb,*) 'bergstep ',nktberg,' packing berg ',tmpberg%number(:),' for transfer to north'
                   CALL flush( numicb )
                ENDIF
-               CALL pack_berg_into_buffer( tmpberg, obuffer_n, nbergs_to_send_n)
+               CALL pack_berg_into_buffer( tmpberg, obuffer_n, ibergs_to_send_n)
                CALL delete_iceberg_from_list(first_berg, tmpberg)
-            ELSE IF( pe_S >= 0 .AND. jne .LT. njmpp+icbdj-1 ) THEN
+            ELSE IF( ipe_S >= 0 .AND. ijne .LT. njmpp+nicbdj-1 ) THEN
                tmpberg => this
                this => this%next
-               nbergs_to_send_s = nbergs_to_send_s + 1
+               ibergs_to_send_s = ibergs_to_send_s + 1
                IF( nn_verbose_level >= 4 ) THEN
-                  WRITE(numicb,*) 'bergstep ',ktberg,' packing berg ',tmpberg%number(:),' for transfer to south'
+                  WRITE(numicb,*) 'bergstep ',nktberg,' packing berg ',tmpberg%number(:),' for transfer to south'
                   CALL flush( numicb )
                ENDIF
-               CALL pack_berg_into_buffer( tmpberg, obuffer_s, nbergs_to_send_s)
+               CALL pack_berg_into_buffer( tmpberg, obuffer_s, ibergs_to_send_s)
                CALL delete_iceberg_from_list(first_berg, tmpberg)
             ELSE
@@ -417,5 +417,5 @@
       ENDIF
       if( nn_verbose_level >= 3) then
-         write(numicb,*) 'bergstep ',ktberg,' send ns: ', nbergs_to_send_n, nbergs_to_send_s
+         write(numicb,*) 'bergstep ',nktberg,' send ns: ', ibergs_to_send_n, ibergs_to_send_s
          call flush(numicb)
       endif
@@ -426,29 +426,29 @@
       SELECT CASE ( nbondj )
       CASE( -1 )
-         snbergs(1) = nbergs_to_send_n
-         CALL mppsend( 16, snbergs(1), 1, pe_N, ml_req1)
-         CALL mpprecv( 15, nsbergs(2), 1 )
-         IF( l_isend ) CALL mpi_wait( ml_req1, ml_stat, ml_err )
-         nbergs_rcvd_from_n = INT( nsbergs(2) )
+         zsnbergs(1) = ibergs_to_send_n
+         CALL mppsend( 16, zsnbergs(1), 1, ipe_N, iml_req1)
+         CALL mpprecv( 15, znsbergs(2), 1 )
+         IF( l_isend ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
+         ibergs_rcvd_from_n = INT( znsbergs(2) )
       CASE(  0 )
-         nsbergs(1) = nbergs_to_send_s
-         snbergs(1) = nbergs_to_send_n
-         CALL mppsend( 15, nsbergs(1), 1, pe_S, ml_req2)
-         CALL mppsend( 16, snbergs(1), 1, pe_N, ml_req3)
-         CALL mpprecv( 15, nsbergs(2), 1 )
-         CALL mpprecv( 16, snbergs(2), 1 )
-         IF( l_isend ) CALL mpi_wait( ml_req2, ml_stat, ml_err )
-         IF( l_isend ) CALL mpi_wait( ml_req3, ml_stat, ml_err )
-         nbergs_rcvd_from_n = INT( nsbergs(2) )
-         nbergs_rcvd_from_s = INT( snbergs(2) )
+         znsbergs(1) = ibergs_to_send_s
+         zsnbergs(1) = ibergs_to_send_n
+         CALL mppsend( 15, znsbergs(1), 1, ipe_S, iml_req2)
+         CALL mppsend( 16, zsnbergs(1), 1, ipe_N, iml_req3)
+         CALL mpprecv( 15, znsbergs(2), 1 )
+         CALL mpprecv( 16, zsnbergs(2), 1 )
+         IF( l_isend ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
+         IF( l_isend ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
+         ibergs_rcvd_from_n = INT( znsbergs(2) )
+         ibergs_rcvd_from_s = INT( zsnbergs(2) )
       CASE(  1 )
-         nsbergs(1) = nbergs_to_send_s
-         CALL mppsend( 15, nsbergs(1), 1, pe_S, ml_req4)
-         CALL mpprecv( 16, snbergs(2), 1 )
-         IF( l_isend ) CALL mpi_wait( ml_req4, ml_stat, ml_err )
-         nbergs_rcvd_from_s = INT( snbergs(2) )
+         znsbergs(1) = ibergs_to_send_s
+         CALL mppsend( 15, znsbergs(1), 1, ipe_S, iml_req4)
+         CALL mpprecv( 16, zsnbergs(2), 1 )
+         IF( l_isend ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
+         ibergs_rcvd_from_s = INT( zsnbergs(2) )
       END SELECT
       if( nn_verbose_level >= 3) then
-         write(numicb,*) 'bergstep ',ktberg,' recv ns: ', nbergs_rcvd_from_s, nbergs_rcvd_from_n
+         write(numicb,*) 'bergstep ',nktberg,' recv ns: ', ibergs_rcvd_from_s, ibergs_rcvd_from_n
          call flush(numicb)
       endif
@@ -456,13 +456,13 @@
       SELECT CASE ( nbondj )
       CASE( -1 )
-         IF( nbergs_to_send_n > 0 ) CALL mppsend( 18, obuffer_n%data, nbergs_to_send_n*buffer_width, pe_N, ml_req1 )
-         IF( nbergs_rcvd_from_n > 0 ) THEN
-            CALL increase_ibuffer(ibuffer_n, nbergs_rcvd_from_n)
-            CALL mpprecv( 17, ibuffer_n%data, nbergs_rcvd_from_n*buffer_width )
-         ENDIF
-         IF( nbergs_to_send_n > 0 .AND. l_isend ) CALL mpi_wait( ml_req1, ml_stat, ml_err )
-         DO i = 1, nbergs_rcvd_from_n
+         IF( ibergs_to_send_n > 0 ) CALL mppsend( 18, obuffer_n%data, ibergs_to_send_n*pp_buffer_width, ipe_N, iml_req1 )
+         IF( ibergs_rcvd_from_n > 0 ) THEN
+            CALL increase_ibuffer(ibuffer_n, ibergs_rcvd_from_n)
+            CALL mpprecv( 17, ibuffer_n%data, ibergs_rcvd_from_n*pp_buffer_width )
+         ENDIF
+         IF( ibergs_to_send_n > 0 .AND. l_isend ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
+         DO i = 1, ibergs_rcvd_from_n
             IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',ktberg,' unpacking berg ',INT(ibuffer_n%data(16,i)),' from north'
+               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_n%data(16,i)),' from north'
                CALL flush( numicb )
             ENDIF
@@ -470,26 +470,26 @@
          ENDDO
       CASE(  0 )
-         IF( nbergs_to_send_s > 0 ) CALL mppsend( 17, obuffer_s%data, nbergs_to_send_s*buffer_width, pe_S, ml_req2 )
-         IF( nbergs_to_send_n > 0 ) CALL mppsend( 18, obuffer_n%data, nbergs_to_send_n*buffer_width, pe_N, ml_req3 )
-         IF( nbergs_rcvd_from_n > 0 ) THEN
-            CALL increase_ibuffer(ibuffer_n, nbergs_rcvd_from_n)
-            CALL mpprecv( 17, ibuffer_n%data, nbergs_rcvd_from_n*buffer_width )
-         ENDIF
-         IF( nbergs_rcvd_from_s > 0 ) THEN
-            CALL increase_ibuffer(ibuffer_s, nbergs_rcvd_from_s)
-            CALL mpprecv( 18, ibuffer_s%data, nbergs_rcvd_from_s*buffer_width )
-         ENDIF
-         IF( nbergs_to_send_s > 0 .AND. l_isend ) CALL mpi_wait( ml_req2, ml_stat, ml_err )
-         IF( nbergs_to_send_n > 0 .AND. l_isend ) CALL mpi_wait( ml_req3, ml_stat, ml_err )
-         DO i = 1, nbergs_rcvd_from_n
+         IF( ibergs_to_send_s > 0 ) CALL mppsend( 17, obuffer_s%data, ibergs_to_send_s*pp_buffer_width, ipe_S, iml_req2 )
+         IF( ibergs_to_send_n > 0 ) CALL mppsend( 18, obuffer_n%data, ibergs_to_send_n*pp_buffer_width, ipe_N, iml_req3 )
+         IF( ibergs_rcvd_from_n > 0 ) THEN
+            CALL increase_ibuffer(ibuffer_n, ibergs_rcvd_from_n)
+            CALL mpprecv( 17, ibuffer_n%data, ibergs_rcvd_from_n*pp_buffer_width )
+         ENDIF
+         IF( ibergs_rcvd_from_s > 0 ) THEN
+            CALL increase_ibuffer(ibuffer_s, ibergs_rcvd_from_s)
+            CALL mpprecv( 18, ibuffer_s%data, ibergs_rcvd_from_s*pp_buffer_width )
+         ENDIF
+         IF( ibergs_to_send_s > 0 .AND. l_isend ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
+         IF( ibergs_to_send_n > 0 .AND. l_isend ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
+         DO i = 1, ibergs_rcvd_from_n
             IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',ktberg,' unpacking berg ',INT(ibuffer_n%data(16,i)),' from north'
+               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_n%data(16,i)),' from north'
                CALL flush( numicb )
             ENDIF
             CALL unpack_berg_from_buffer(first_berg, ibuffer_n, i)
          ENDDO
-         DO i = 1, nbergs_rcvd_from_s
+         DO i = 1, ibergs_rcvd_from_s
             IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',ktberg,' unpacking berg ',INT(ibuffer_s%data(16,i)),' from south'
+               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_s%data(16,i)),' from south'
                CALL flush( numicb )
             ENDIF
@@ -497,13 +497,13 @@
          ENDDO
       CASE(  1 )
-         IF( nbergs_to_send_s > 0 ) CALL mppsend( 17, obuffer_s%data, nbergs_to_send_s*buffer_width, pe_S, ml_req4 )
-         IF( nbergs_rcvd_from_s > 0 ) THEN
-            CALL increase_ibuffer(ibuffer_s, nbergs_rcvd_from_s)
-            CALL mpprecv( 18, ibuffer_s%data, nbergs_rcvd_from_s*buffer_width )
-         ENDIF
-         IF( nbergs_to_send_s > 0 .AND. l_isend ) CALL mpi_wait( ml_req4, ml_stat, ml_err )
-         DO i = 1, nbergs_rcvd_from_s
+         IF( ibergs_to_send_s > 0 ) CALL mppsend( 17, obuffer_s%data, ibergs_to_send_s*pp_buffer_width, ipe_S, iml_req4 )
+         IF( ibergs_rcvd_from_s > 0 ) THEN
+            CALL increase_ibuffer(ibuffer_s, ibergs_rcvd_from_s)
+            CALL mpprecv( 18, ibuffer_s%data, ibergs_rcvd_from_s*pp_buffer_width )
+         ENDIF
+         IF( ibergs_to_send_s > 0 .AND. l_isend ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
+         DO i = 1, ibergs_rcvd_from_s
             IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',ktberg,' unpacking berg ',INT(ibuffer_s%data(16,i)),' from south'
+               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_s%data(16,i)),' from south'
                CALL flush( numicb )
             ENDIF
@@ -514,33 +514,33 @@
       IF( nn_verbose_level > 0 ) THEN
          ! compare the number of icebergs on this processor from the start to the end
-         nbergs_end = count_bergs()
-         i = ( nbergs_rcvd_from_n + nbergs_rcvd_from_s + nbergs_rcvd_from_e + nbergs_rcvd_from_w ) - &
-             ( nbergs_to_send_n + nbergs_to_send_s + nbergs_to_send_e + nbergs_to_send_w )
-         IF( nbergs_end-(nbergs_start+i) .NE. 0 ) THEN
+         ibergs_end = count_bergs()
+         i = ( ibergs_rcvd_from_n + ibergs_rcvd_from_s + ibergs_rcvd_from_e + ibergs_rcvd_from_w ) - &
+             ( ibergs_to_send_n + ibergs_to_send_s + ibergs_to_send_e + ibergs_to_send_w )
+         IF( ibergs_end-(ibergs_start+i) .NE. 0 ) THEN
             WRITE( numicb,*   ) 'send_bergs_to_other_pes: net change in number of icebergs'
-            WRITE( numicb,1000) 'send_bergs_to_other_pes: nbergs_end=', &
-                                nbergs_end,' on PE',narea
-            WRITE( numicb,1000) 'send_bergs_to_other_pes: nbergs_start=', &
-                                nbergs_start,' on PE',narea
+            WRITE( numicb,1000) 'send_bergs_to_other_pes: ibergs_end=', &
+                                ibergs_end,' on PE',narea
+            WRITE( numicb,1000) 'send_bergs_to_other_pes: ibergs_start=', &
+                                ibergs_start,' on PE',narea
             WRITE( numicb,1000) 'send_bergs_to_other_pes: delta=', &
                                 i,' on PE',narea
             WRITE( numicb,1000) 'send_bergs_to_other_pes: error=', &
-                                nbergs_end-(nbergs_start+i),' on PE',narea
-            WRITE( numicb,1000) 'send_bergs_to_other_pes: nbergs_to_send_n=', &
-                                nbergs_to_send_n,' on PE',narea
-            WRITE( numicb,1000) 'send_bergs_to_other_pes: nbergs_to_send_s=', &
-                                nbergs_to_send_s,' on PE',narea
-            WRITE( numicb,1000) 'send_bergs_to_other_pes: nbergs_to_send_e=', &
-                                nbergs_to_send_e,' on PE',narea
-            WRITE( numicb,1000) 'send_bergs_to_other_pes: nbergs_to_send_w=', &
-                                nbergs_to_send_w,' on PE',narea
-            WRITE( numicb,1000) 'send_bergs_to_other_pes: nbergs_rcvd_from_n=', &
-                                nbergs_rcvd_from_n,' on PE',narea
-            WRITE( numicb,1000) 'send_bergs_to_other_pes: nbergs_rcvd_from_s=', &
-                                nbergs_rcvd_from_s,' on PE',narea
-            WRITE( numicb,1000) 'send_bergs_to_other_pes: nbergs_rcvd_from_e=', &
-                                nbergs_rcvd_from_e,' on PE',narea
-            WRITE( numicb,1000) 'send_bergs_to_other_pes: nbergs_rcvd_from_w=', &
-                                nbergs_rcvd_from_w,' on PE',narea
+                                ibergs_end-(ibergs_start+i),' on PE',narea
+            WRITE( numicb,1000) 'send_bergs_to_other_pes: ibergs_to_send_n=', &
+                                ibergs_to_send_n,' on PE',narea
+            WRITE( numicb,1000) 'send_bergs_to_other_pes: ibergs_to_send_s=', &
+                                ibergs_to_send_s,' on PE',narea
+            WRITE( numicb,1000) 'send_bergs_to_other_pes: ibergs_to_send_e=', &
+                                ibergs_to_send_e,' on PE',narea
+            WRITE( numicb,1000) 'send_bergs_to_other_pes: ibergs_to_send_w=', &
+                                ibergs_to_send_w,' on PE',narea
+            WRITE( numicb,1000) 'send_bergs_to_other_pes: ibergs_rcvd_from_n=', &
+                                ibergs_rcvd_from_n,' on PE',narea
+            WRITE( numicb,1000) 'send_bergs_to_other_pes: ibergs_rcvd_from_s=', &
+                                ibergs_rcvd_from_s,' on PE',narea
+            WRITE( numicb,1000) 'send_bergs_to_other_pes: ibergs_rcvd_from_e=', &
+                                ibergs_rcvd_from_e,' on PE',narea
+            WRITE( numicb,1000) 'send_bergs_to_other_pes: ibergs_rcvd_from_w=', &
+                                ibergs_rcvd_from_w,' on PE',narea
   1000      FORMAT(a,i5,a,i4)
             CALL ctl_stop('send_bergs_to_other_pes: lost or gained an iceberg or two')
@@ -557,15 +557,15 @@
          DO WHILE (ASSOCIATED(this))
             pt => this%current_point
-            ine = INT( pt%xi + 0.5 )
-            jne = INT( pt%yj + 0.5 )
+            iine = INT( pt%xi + 0.5 )
+            ijne = INT( pt%yj + 0.5 )
 !           CALL check_position(grd, this, 'exchange (bot)')
-            IF( ine .LT. nimpp+icbdi-1 .OR. &
-                ine .GT. nimpp+icbei-1 .OR. &
-                jne .LT. njmpp+icbdj-1 .OR. &
-                jne .GT. njmpp+icbej-1) THEN
+            IF( iine .LT. nimpp+nicbdi-1 .OR. &
+                iine .GT. nimpp+nicbei-1 .OR. &
+                ijne .LT. njmpp+nicbdj-1 .OR. &
+                ijne .GT. njmpp+nicbej-1) THEN
                i = i + 1
-               WRITE(numicb,*) 'berg lost in halo: ', this%number(:),ine,jne
+               WRITE(numicb,*) 'berg lost in halo: ', this%number(:),iine,ijne
                WRITE(numicb,*) '                   ', nimpp, njmpp
-               WRITE(numicb,*) '                   ', icbdi, icbei, icbdj, icbej
+               WRITE(numicb,*) '                   ', nicbdi, nicbei, nicbdj, nicbej
                CALL flush( numicb )
             ENDIF
@@ -590,27 +590,27 @@
       TYPE(iceberg)         , POINTER     :: tmpberg, this
       TYPE(point)           , POINTER     :: pt
-      INTEGER                             :: nbergs_to_send
-      INTEGER                             :: nbergs_to_rcv
-      INTEGER                             :: jiglo, jjglo, jk, jn
-      INTEGER                             :: jfldproc, kproc, kpts
-      INTEGER                             :: ine, jne
-      REAL(wp), DIMENSION(2)              :: sbergs, nbergs
-      INTEGER                             :: ml_req1, ml_req2, ml_err
-      INTEGER, DIMENSION(MPI_STATUS_SIZE) :: ml_stat
+      INTEGER                             :: ibergs_to_send
+      INTEGER                             :: ibergs_to_rcv
+      INTEGER                             :: iiglo, ijglo, jk, jn
+      INTEGER                             :: ifldproc, iproc, ipts
+      INTEGER                             :: iine, ijne
+      REAL(wp), DIMENSION(2)              :: zsbergs, znbergs
+      INTEGER                             :: iml_req1, iml_req2, iml_err
+      INTEGER, DIMENSION(MPI_STATUS_SIZE) :: iml_stat
 
       ! set up indices of neighbouring processors
 
-      ! icbfldproc is a list of unique processor numbers that this processor
+      ! nicbfldproc is a list of unique processor numbers that this processor
       ! exchanges with (including itself), so we loop over this array; since
       ! its of fixed size, the first -1 marks end of list of processors
       !
       DO jn = 1, jpni
-         IF( icbfldproc(jn) == -1 ) EXIT
-         jfldproc = icbfldproc(jn)
-         nbergs_to_send = 0
+         IF( nicbfldproc(jn) == -1 ) EXIT
+         ifldproc = nicbfldproc(jn)
+         ibergs_to_send = 0
 
          ! Find number of bergs that need to be exchanged
-         ! Pick out exchanges with processor jfldproc
-         ! if jfldproc is this processor then don't send
+         ! Pick out exchanges with processor ifldproc
+         ! if ifldproc is this processor then don't send
          !
          IF( ASSOCIATED(first_berg) ) THEN
@@ -618,29 +618,29 @@
             DO WHILE (ASSOCIATED(this))
                pt => this%current_point
-               ine = INT( pt%xi + 0.5 )
-               jne = INT( pt%yj + 0.5 )
-               kpts  = icbfldpts (ine-nimpp+1)
-               kproc = icbflddest(ine-nimpp+1)
-               IF( jne .GT. njmpp+icbej-1 ) THEN
-                  IF( kproc == jfldproc ) THEN
+               iine = INT( pt%xi + 0.5 )
+               ijne = INT( pt%yj + 0.5 )
+               ipts  = nicbfldpts (iine-nimpp+1)
+               iproc = nicbflddest(iine-nimpp+1)
+               IF( ijne .GT. njmpp+nicbej-1 ) THEN
+                  IF( iproc == ifldproc ) THEN
                      !
                      ! moving across the cut line means both position and
                      ! velocity must change
-                     jjglo = INT( kpts/icbpack )
-                     jiglo = kpts - icbpack*jjglo
-                     pt%xi = jiglo - ( pt%xi - REAL(ine,wp) )
-                     pt%yj = jjglo - ( pt%yj - REAL(jne,wp) )
+                     ijglo = INT( ipts/nicbpack )
+                     iiglo = ipts - nicbpack*ijglo
+                     pt%xi = iiglo - ( pt%xi - REAL(iine,wp) )
+                     pt%yj = ijglo - ( pt%yj - REAL(ijne,wp) )
                      pt%uvel = -1._wp * pt%uvel
                      pt%vvel = -1._wp * pt%vvel
                      !
                      ! now remove berg from list and pack it into a buffer
-                     IF( kproc /= narea ) THEN
+                     IF( iproc /= narea ) THEN
                         tmpberg => this
-                        nbergs_to_send = nbergs_to_send + 1
+                        ibergs_to_send = ibergs_to_send + 1
                         IF( nn_verbose_level >= 4 ) THEN
-                           WRITE(numicb,*) 'bergstep ',ktberg,' packing berg ',tmpberg%number(:),' for north fold'
+                           WRITE(numicb,*) 'bergstep ',nktberg,' packing berg ',tmpberg%number(:),' for north fold'
                            CALL flush( numicb )
                         ENDIF
-                        CALL pack_berg_into_buffer( tmpberg, obuffer_f, nbergs_to_send)
+                        CALL pack_berg_into_buffer( tmpberg, obuffer_f, ibergs_to_send)
                         CALL delete_iceberg_from_list(first_berg, tmpberg)
                      ENDIF
@@ -652,5 +652,5 @@
          ENDIF
          if( nn_verbose_level >= 3) then
-            write(numicb,*) 'bergstep ',ktberg,' send nfld: ', nbergs_to_send
+            write(numicb,*) 'bergstep ',nktberg,' send nfld: ', ibergs_to_send
             call flush(numicb)
          endif
@@ -658,24 +658,24 @@
          ! if we're in this processor, then we've done everything we need to
          ! so go on to next element of loop
-         IF( jfldproc == narea ) CYCLE
-
-         sbergs(1) = nbergs_to_send
-         CALL mppsend( 21, sbergs(1), 1, jfldproc-1, ml_req1)
-         CALL mpprecv( 21, nbergs(2), 1 )
-         IF( l_isend ) CALL mpi_wait( ml_req1, ml_stat, ml_err )
-         nbergs_to_rcv = INT( nbergs(2) )
+         IF( ifldproc == narea ) CYCLE
+
+         zsbergs(1) = ibergs_to_send
+         CALL mppsend( 21, zsbergs(1), 1, ifldproc-1, iml_req1)
+         CALL mpprecv( 21, znbergs(2), 1 )
+         IF( l_isend ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
+         ibergs_to_rcv = INT( znbergs(2) )
 
          ! send bergs
 
-         IF( nbergs_to_send > 0 )  &
-             CALL mppsend( 12, obuffer_f%data, nbergs_to_send*buffer_width, jfldproc-1, ml_req2 )
-         IF( nbergs_to_rcv  > 0 ) THEN
-            CALL increase_ibuffer(ibuffer_f, nbergs_to_rcv)
-            CALL mpprecv( 12, ibuffer_f%data, nbergs_to_rcv*buffer_width )
-         ENDIF
-         IF( nbergs_to_send > 0 .AND. l_isend ) CALL mpi_wait( ml_req2, ml_stat, ml_err )
-         DO jk = 1, nbergs_to_rcv
+         IF( ibergs_to_send > 0 )  &
+             CALL mppsend( 12, obuffer_f%data, ibergs_to_send*pp_buffer_width, ifldproc-1, iml_req2 )
+         IF( ibergs_to_rcv  > 0 ) THEN
+            CALL increase_ibuffer(ibuffer_f, ibergs_to_rcv)
+            CALL mpprecv( 12, ibuffer_f%data, ibergs_to_rcv*pp_buffer_width )
+         ENDIF
+         IF( ibergs_to_send > 0 .AND. l_isend ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
+         DO jk = 1, ibergs_to_rcv
             IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',ktberg,' unpacking berg ',INT(ibuffer_f%data(16,jk)),' from north fold'
+               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_f%data(16,jk)),' from north fold'
                CALL flush( numicb )
             ENDIF
@@ -704,11 +704,11 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE dealloc_buffer(buff)
+   SUBROUTINE dealloc_buffer(pbuff)
       ! Arguments
-      TYPE(buffer), POINTER :: buff
-
-      IF( ASSOCIATED(buff) ) THEN
-         IF( ASSOCIATED(buff%data)) DEALLOCATE(buff%data)
-         DEALLOCATE(buff)
+      TYPE(buffer), POINTER :: pbuff
+
+      IF( ASSOCIATED(pbuff) ) THEN
+         IF( ASSOCIATED(pbuff%data)) DEALLOCATE(pbuff%data)
+         DEALLOCATE(pbuff)
       ENDIF
    END SUBROUTINE dealloc_buffer
@@ -716,35 +716,35 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE pack_berg_into_buffer(berg, buff, n)
+   SUBROUTINE pack_berg_into_buffer(berg, pbuff, kb)
       ! Arguments
       TYPE(iceberg),            POINTER :: berg
-      TYPE(buffer) ,            POINTER :: buff
-      INTEGER      , INTENT(in)         :: n
+      TYPE(buffer) ,            POINTER :: pbuff
+      INTEGER      , INTENT(in)         :: kb
       ! Local
       INTEGER                           :: k
 
-      IF( .NOT. ASSOCIATED(buff) ) CALL increase_buffer( buff, delta_buf )
-      IF( n .GT. buff%size ) CALL increase_buffer( buff, delta_buf )
+      IF( .NOT. ASSOCIATED(pbuff) ) CALL increase_buffer( pbuff, pp_delta_buf )
+      IF( kb .GT. pbuff%size ) CALL increase_buffer( pbuff, pp_delta_buf )
 
       !! pack points into buffer
 
-      buff%data( 1,n) = berg%current_point%lon
-      buff%data( 2,n) = berg%current_point%lat
-      buff%data( 3,n) = berg%current_point%uvel
-      buff%data( 4,n) = berg%current_point%vvel
-      buff%data( 5,n) = berg%current_point%xi
-      buff%data( 6,n) = berg%current_point%yj
-      buff%data( 7,n) = float(berg%current_point%year)
-      buff%data( 8,n) = berg%current_point%day
-      buff%data( 9,n) = berg%current_point%mass
-      buff%data(10,n) = berg%current_point%thickness
-      buff%data(11,n) = berg%current_point%width
-      buff%data(12,n) = berg%current_point%length
-      buff%data(13,n) = berg%current_point%mass_of_bits
-      buff%data(14,n) = berg%current_point%heat_density
-
-      buff%data(15,n) = berg%mass_scaling
+      pbuff%data( 1,kb) = berg%current_point%lon
+      pbuff%data( 2,kb) = berg%current_point%lat
+      pbuff%data( 3,kb) = berg%current_point%uvel
+      pbuff%data( 4,kb) = berg%current_point%vvel
+      pbuff%data( 5,kb) = berg%current_point%xi
+      pbuff%data( 6,kb) = berg%current_point%yj
+      pbuff%data( 7,kb) = float(berg%current_point%year)
+      pbuff%data( 8,kb) = berg%current_point%day
+      pbuff%data( 9,kb) = berg%current_point%mass
+      pbuff%data(10,kb) = berg%current_point%thickness
+      pbuff%data(11,kb) = berg%current_point%width
+      pbuff%data(12,kb) = berg%current_point%length
+      pbuff%data(13,kb) = berg%current_point%mass_of_bits
+      pbuff%data(14,kb) = berg%current_point%heat_density
+
+      pbuff%data(15,kb) = berg%mass_scaling
       DO k=1,nkounts
-         buff%data(15+k,n) = REAL( berg%number(k), wp )
+         pbuff%data(15+k,kb) = REAL( berg%number(k), wp )
       END DO
 
@@ -753,33 +753,32 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE unpack_berg_from_buffer(first, buff, n)
+   SUBROUTINE unpack_berg_from_buffer(first, pbuff, kb)
       ! Arguments
       TYPE(iceberg),             POINTER :: first
-      TYPE(buffer) ,             POINTER :: buff
-      INTEGER      , INTENT(in)          :: n
+      TYPE(buffer) ,             POINTER :: pbuff
+      INTEGER      , INTENT(in)          :: kb
       ! Local variables
-      LOGICAL                            :: lres
       TYPE(iceberg)                      :: currentberg
       TYPE(point)                        :: pt
-      INTEGER                           :: k
-
-      pt%lon            =      buff%data( 1,n)
-      pt%lat            =      buff%data( 2,n)
-      pt%uvel           =      buff%data( 3,n)
-      pt%vvel           =      buff%data( 4,n)
-      pt%xi             =      buff%data( 5,n)
-      pt%yj             =      buff%data( 6,n)
-      pt%year           = INT( buff%data( 7,n) )
-      pt%day            =      buff%data( 8,n)
-      pt%mass           =      buff%data( 9,n)
-      pt%thickness      =      buff%data(10,n)
-      pt%width          =      buff%data(11,n)
-      pt%length         =      buff%data(12,n)
-      pt%mass_of_bits   =      buff%data(13,n)
-      pt%heat_density   =      buff%data(14,n)
-
-      currentberg%mass_scaling =      buff%data(15,n)
-      DO k=1,nkounts
-         currentberg%number(k) = INT( buff%data(15+k,n) )
+      INTEGER                            :: ik
+
+      pt%lon            =      pbuff%data( 1,kb)
+      pt%lat            =      pbuff%data( 2,kb)
+      pt%uvel           =      pbuff%data( 3,kb)
+      pt%vvel           =      pbuff%data( 4,kb)
+      pt%xi             =      pbuff%data( 5,kb)
+      pt%yj             =      pbuff%data( 6,kb)
+      pt%year           = INT( pbuff%data( 7,kb) )
+      pt%day            =      pbuff%data( 8,kb)
+      pt%mass           =      pbuff%data( 9,kb)
+      pt%thickness      =      pbuff%data(10,kb)
+      pt%width          =      pbuff%data(11,kb)
+      pt%length         =      pbuff%data(12,kb)
+      pt%mass_of_bits   =      pbuff%data(13,kb)
+      pt%heat_density   =      pbuff%data(14,kb)
+
+      currentberg%mass_scaling =      pbuff%data(15,kb)
+      DO ik=1,nkounts
+         currentberg%number(ik) = INT( pbuff%data(15+ik,kb) )
       END DO
 
@@ -790,20 +789,20 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE increase_buffer(old,delta)
+   SUBROUTINE increase_buffer(old,kdelta)
       ! Arguments
       TYPE(buffer),             POINTER :: old
-      INTEGER     , INTENT(in)          :: delta
+      INTEGER     , INTENT(in)          :: kdelta
       ! Local variables
       TYPE(buffer),             POINTER :: new
-      INTEGER                           :: new_size
+      INTEGER                           :: inew_size
 
       IF( .NOT. ASSOCIATED(old) ) THEN
-         new_size = delta
+         inew_size = kdelta
       ELSE
-         new_size = old%size + delta
+         inew_size = old%size + kdelta
       ENDIF
       ALLOCATE( new )
-      ALLOCATE( new%data( buffer_width, new_size) )
-      new%size = new_size
+      ALLOCATE( new%data( pp_buffer_width, inew_size) )
+      new%size = inew_size
       IF( ASSOCIATED(old) ) THEN
          new%data(:,1:old%size) = old%data(:,1:old%size)
@@ -817,28 +816,28 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE increase_ibuffer(old,delta)
+   SUBROUTINE increase_ibuffer(old,kdelta)
       ! Arguments
       TYPE(buffer),            POINTER :: old
-      INTEGER     , INTENT(in)         :: delta
+      INTEGER     , INTENT(in)         :: kdelta
       ! Local variables
       TYPE(buffer),            POINTER :: new
-      INTEGER                          :: new_size, old_size
+      INTEGER                          :: inew_size, iold_size
 
       IF( .NOT. ASSOCIATED(old) ) THEN
-         new_size = delta + delta_buf
-         old_size = 0
+         inew_size = kdelta + pp_delta_buf
+         iold_size = 0
       ELSE
-         old_size = old%size
-         IF( delta .LT. old%size ) THEN
-            new_size = old%size + delta
+         iold_size = old%size
+         IF( kdelta .LT. old%size ) THEN
+            inew_size = old%size + kdelta
          ELSE
-            new_size = delta + delta_buf
-         ENDIF
-      ENDIF
-
-      IF( old_size .NE. new_size ) THEN
+            inew_size = kdelta + pp_delta_buf
+         ENDIF
+      ENDIF
+
+      IF( iold_size .NE. inew_size ) THEN
          ALLOCATE( new )
-         ALLOCATE( new%data( buffer_width, new_size) )
-         new%size = new_size
+         ALLOCATE( new%data( pp_buffer_width, inew_size) )
+         new%size = inew_size
          IF( ASSOCIATED(old) ) THEN
             new%data(:,1:old%size) = old%data(:,1:old%size)
@@ -847,5 +846,5 @@
          ENDIF
          old => new
-        !WRITE( numicb,*) 'increase_ibuffer',narea,' increased to',new_size
+        !WRITE( numicb,*) 'increase_ibuffer',narea,' increased to',inew_size
       ENDIF
 
Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbrst.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbrst.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbrst.F90	(revision 3359)
@@ -29,13 +29,14 @@
 
    REAL(wp), DIMENSION(:,:,:), PRIVATE, POINTER :: griddata => NULL()    ! need 2d array to read in with
-   INTEGER,  DIMENSION(3),     PRIVATE          :: strt3, lngth3
-   INTEGER,                    PRIVATE          :: lonid, latid, xid, yid, uvelid, vvelid
-   INTEGER,                    PRIVATE          :: massid, thicknessid, widthid, lengthid
-   INTEGER,                    PRIVATE          :: yearid, dayid
-   INTEGER,                    PRIVATE          :: scaling_id, mass_of_bits_id, heat_density_id, numberid
-   INTEGER,                    PRIVATE          :: siceid, sheatid, calvid, calvhid, kountid
-
-   PUBLIC   icebergs_read_restart       ! routine called in xxx.F90 module
-   PUBLIC   icebergs_write_restart      ! routine called in xxx.F90 module
+   INTEGER,  DIMENSION(3),     PRIVATE          :: nstrt3, nlngth3
+   INTEGER,                    PRIVATE          :: nlonid, nlatid, nxid, nyid, nuvelid, nvvelid
+   INTEGER,                    PRIVATE          :: nmassid, nthicknessid, nwidthid, nlengthid
+   INTEGER,                    PRIVATE          :: nyearid, ndayid
+   INTEGER,                    PRIVATE          :: nscaling_id, nmass_of_bits_id, nheat_density_id, numberid
+   INTEGER,                    PRIVATE          :: nsiceid, nsheatid, ncalvid, ncalvhid, nkountid
+   INTEGER,                    PRIVATE          :: nret, ncid, nc_dim
+
+   PUBLIC   icebergs_read_restart       ! routine called in icbini.F90 module
+   PUBLIC   icebergs_write_restart      ! routine called in icbrun.F90 module
 
 CONTAINS
@@ -47,122 +48,122 @@
 
       ! Local variables
-      INTEGER                               :: ndim, nvar, natt
-      INTEGER                               :: k, iret, ncid, unlim_dim, x_dim, y_dim, c_dim, nbergs_in_file
-      INTEGER                               :: mclass
-      INTEGER, DIMENSION(1)                 :: strt, lngth, idata
-      INTEGER, DIMENSION(2)                 :: strt2, lngth2
-      INTEGER, DIMENSION(nkounts)           :: idata2
-      REAL(wp), DIMENSION(1)                :: data                                         ! need 1d array to read in with
+      INTEGER                               ::   idim, ivar, iatt
+      INTEGER                               ::   jn, iunlim_dim, ibergs_in_file
+      INTEGER                               ::   iclass
+      INTEGER, DIMENSION(1)                 ::   istrt, ilngth, idata
+      INTEGER, DIMENSION(2)                 ::   istrt2, ilngth2
+      INTEGER, DIMENSION(nkounts)           ::   idata2
+      REAL(wp), DIMENSION(1)                ::   zdata                                         ! need 1d array to read in with
                                                                                             ! start and count arrays
-      LOGICAL                               :: lres, found_restart, multiPErestart=.FALSE.
-      CHARACTER(len=80)                     :: filename
-      CHARACTER(len=NF90_MAX_NAME)          :: dname
-      TYPE(iceberg)                         :: localberg ! NOT a pointer but an actual local variable
-      TYPE(point)                           :: localpt   ! NOT a pointer but an actual local variable
+      LOGICAL                               ::   ll_found_restart, ll_multiPErestart=.FALSE.
+      CHARACTER(len=80)                     ::   cl_filename
+      CHARACTER(len=NF90_MAX_NAME)          ::   cl_dname
+      TYPE(iceberg)                         ::   localberg ! NOT a pointer but an actual local variable
+      TYPE(point)                           ::   localpt   ! NOT a pointer but an actual local variable
 
       IF( .NOT. ASSOCIATED(griddata) ) ALLOCATE( griddata(jpi,jpj,1) )
 
       ! Find a restart file
-      multiPErestart=.FALSE.
+      ll_multiPErestart=.FALSE.
       DO
-         filename = ' '
-         filename = 'restart_icebergs.nc'
-         INQUIRE(file=TRIM(filename),exist=found_restart)
-         IF (found_restart) EXIT
-         filename = ' '
-         WRITE(filename,'("restart_icebergs_",I4.4,".nc")') narea-1
-         INQUIRE(file=TRIM(filename),exist=found_restart)
-         IF (found_restart) THEN
-            multiPErestart=.TRUE.
+         cl_filename = ' '
+         cl_filename = 'restart_icebergs.nc'
+         INQUIRE( file=TRIM(cl_filename), exist=ll_found_restart )
+         IF ( ll_found_restart ) EXIT
+         cl_filename = ' '
+         WRITE( cl_filename, '("restart_icebergs_",I4.4,".nc")' ) narea-1
+         INQUIRE( file=TRIM(cl_filename), exist=ll_found_restart )
+         IF ( ll_found_restart ) THEN
+            ll_multiPErestart = .TRUE.
             EXIT
          ENDIF
          IF (nn_verbose_level >= 0 .AND. lwp) &
-            WRITE(numout,'(a)') 'read_restart_bergs: no restart file found'
-         multiPErestart=.TRUE. ! force sanity checking in a multi-PE mode if no file found on this PE
+            WRITE( numout, '(a)' ) 'read_restart_bergs: no restart file found'
+         ll_multiPErestart = .TRUE.                         ! force checking in a MPP if no file found on this PE
          EXIT
       ENDDO
 
-      IF ( .NOT. found_restart) THEN ! only do the following if a file was found
+      IF ( .NOT. ll_found_restart) THEN                     ! only do the following if a file was found
          CALL ctl_stop('icebergs: no restart file found')
       ENDIF
 
       IF (nn_verbose_level >= 0 .AND. lwp)  &
-         WRITE(numout,'(2a)') 'icebergs, read_restart_bergs: found restart file = ',TRIM(filename)
-
-      iret = NF90_OPEN(TRIM(filename), NF90_NOWRITE, ncid)
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart_bergs: nf_open failed')
-
-      iret = nf90_inquire(ncid, ndim, nvar, natt, unlim_dim)
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart_bergs: nf_inquire failed')
-
-      IF( unlim_dim .NE. -1) THEN
-
-         iret = nf90_inquire_dimension(ncid, unlim_dim, dname, nbergs_in_file)
-         IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart_bergs: nf_inq_dimlen failed')
-
-         iret = NF90_INQ_VARID(ncid, 'number', numberid)
-         iret = NF90_INQ_VARID(ncid, 'mass_scaling', scaling_id)
-         iret = NF90_INQ_VARID(ncid, 'xi', xid)
-         iret = NF90_INQ_VARID(ncid, 'yj', yid)
-         iret = NF90_INQ_VARID(ncid, 'lon', lonid)
-         iret = NF90_INQ_VARID(ncid, 'lat', latid)
-         iret = NF90_INQ_VARID(ncid, 'uvel', uvelid)
-         iret = NF90_INQ_VARID(ncid, 'vvel', vvelid)
-         iret = NF90_INQ_VARID(ncid, 'mass', massid)
-         iret = NF90_INQ_VARID(ncid, 'thickness', thicknessid)
-         iret = NF90_INQ_VARID(ncid, 'width', widthid)
-         iret = NF90_INQ_VARID(ncid, 'length', lengthid)
-         iret = NF90_INQ_VARID(ncid, 'year', yearid)
-         iret = NF90_INQ_VARID(ncid, 'day', dayid)
-         iret = NF90_INQ_VARID(ncid, 'mass_of_bits', mass_of_bits_id)
-         iret = NF90_INQ_VARID(ncid, 'heat_density', heat_density_id)
-
-         lngth(1) = 1
-         strt2(1) = 1
-         lngth2(1) = nkounts
-         lngth2(2) = 1
-         DO k=1, nbergs_in_file
-
-            strt(1) = k
-            strt2(2) = k
-
-            iret = NF90_GET_VAR(ncid, numberid, idata2, strt2, lngth2 )
+         WRITE(numout,'(2a)') 'icebergs, read_restart_bergs: found restart file = ',TRIM(cl_filename)
+
+      nret = NF90_OPEN(TRIM(cl_filename), NF90_NOWRITE, ncid)
+      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart_bergs: nf_open failed')
+
+      nret = nf90_inquire(ncid, idim, ivar, iatt, iunlim_dim)
+      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart_bergs: nf_inquire failed')
+
+      IF( iunlim_dim .NE. -1) THEN
+
+         nret = nf90_inquire_dimension(ncid, iunlim_dim, cl_dname, ibergs_in_file)
+         IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart_bergs: nf_inq_dimlen failed')
+
+         nret = NF90_INQ_VARID(ncid, 'number', numberid)
+         nret = NF90_INQ_VARID(ncid, 'mass_scaling', nscaling_id)
+         nret = NF90_INQ_VARID(ncid, 'xi', nxid)
+         nret = NF90_INQ_VARID(ncid, 'yj', nyid)
+         nret = NF90_INQ_VARID(ncid, 'lon', nlonid)
+         nret = NF90_INQ_VARID(ncid, 'lat', nlatid)
+         nret = NF90_INQ_VARID(ncid, 'uvel', nuvelid)
+         nret = NF90_INQ_VARID(ncid, 'vvel', nvvelid)
+         nret = NF90_INQ_VARID(ncid, 'mass', nmassid)
+         nret = NF90_INQ_VARID(ncid, 'thickness', nthicknessid)
+         nret = NF90_INQ_VARID(ncid, 'width', nwidthid)
+         nret = NF90_INQ_VARID(ncid, 'length', nlengthid)
+         nret = NF90_INQ_VARID(ncid, 'year', nyearid)
+         nret = NF90_INQ_VARID(ncid, 'day', ndayid)
+         nret = NF90_INQ_VARID(ncid, 'mass_of_bits', nmass_of_bits_id)
+         nret = NF90_INQ_VARID(ncid, 'heat_density', nheat_density_id)
+
+         ilngth(1) = 1
+         istrt2(1) = 1
+         ilngth2(1) = nkounts
+         ilngth2(2) = 1
+         DO jn=1, ibergs_in_file
+
+            istrt(1) = jn
+            istrt2(2) = jn
+
+            nret = NF90_GET_VAR(ncid, numberid, idata2, istrt2, ilngth2 )
             localberg%number(:) = idata2(:)
 
-            iret = NF90_GET_VAR(ncid, scaling_id, data, strt, lngth )
-            localberg%mass_scaling = data(1)
-
-            iret = NF90_GET_VAR(ncid, lonid, data, strt, lngth)
-            localpt%lon = data(1)
-            iret = NF90_GET_VAR(ncid, latid, data, strt, lngth)
-            localpt%lat = data(1)
+            nret = NF90_GET_VAR(ncid, nscaling_id, zdata, istrt, ilngth )
+            localberg%mass_scaling = zdata(1)
+
+            nret = NF90_GET_VAR(ncid, nlonid, zdata, istrt, ilngth)
+            localpt%lon = zdata(1)
+            nret = NF90_GET_VAR(ncid, nlatid, zdata, istrt, ilngth)
+            localpt%lat = zdata(1)
             IF (nn_verbose_level >= 2 .AND. lwp) THEN
-               WRITE(numout,'(a,i5,a,2f10.4,a,i5)') 'icebergs, read_restart_bergs: berg ',k,' is at ', &
+               WRITE(numout,'(a,i5,a,2f10.4,a,i5)') 'icebergs, read_restart_bergs: berg ',jn,' is at ', &
                                               localpt%lon,localpt%lat,' on PE ',narea-1
             ENDIF
-            iret = NF90_GET_VAR(ncid, xid, data, strt, lngth)
-            localpt%xi = data(1)
-            iret = NF90_GET_VAR(ncid, yid, data, strt, lngth)
-            localpt%yj = data(1)
-            iret = NF90_GET_VAR(ncid, uvelid, data, strt, lngth )
-            localpt%uvel = data(1)
-            iret = NF90_GET_VAR(ncid, vvelid, data, strt, lngth )
-            localpt%vvel = data(1)
-            iret = NF90_GET_VAR(ncid, massid, data, strt, lngth )
-            localpt%mass = data(1)
-            iret = NF90_GET_VAR(ncid, thicknessid, data, strt, lngth )
-            localpt%thickness = data(1)
-            iret = NF90_GET_VAR(ncid, widthid, data, strt, lngth )
-            localpt%width = data(1)
-            iret = NF90_GET_VAR(ncid, lengthid, data, strt, lngth )
-            localpt%length = data(1)
-            iret = NF90_GET_VAR(ncid, yearid, idata, strt, lngth )
+            nret = NF90_GET_VAR(ncid, nxid, zdata, istrt, ilngth)
+            localpt%xi = zdata(1)
+            nret = NF90_GET_VAR(ncid, nyid, zdata, istrt, ilngth)
+            localpt%yj = zdata(1)
+            nret = NF90_GET_VAR(ncid, nuvelid, zdata, istrt, ilngth )
+            localpt%uvel = zdata(1)
+            nret = NF90_GET_VAR(ncid, nvvelid, zdata, istrt, ilngth )
+            localpt%vvel = zdata(1)
+            nret = NF90_GET_VAR(ncid, nmassid, zdata, istrt, ilngth )
+            localpt%mass = zdata(1)
+            nret = NF90_GET_VAR(ncid, nthicknessid, zdata, istrt, ilngth )
+            localpt%thickness = zdata(1)
+            nret = NF90_GET_VAR(ncid, nwidthid, zdata, istrt, ilngth )
+            localpt%width = zdata(1)
+            nret = NF90_GET_VAR(ncid, nlengthid, zdata, istrt, ilngth )
+            localpt%length = zdata(1)
+            nret = NF90_GET_VAR(ncid, nyearid, idata, istrt, ilngth )
             localpt%year = idata(1)
-            iret = NF90_GET_VAR(ncid, dayid, data, strt, lngth )
-            localpt%day = data(1)
-            iret = NF90_GET_VAR(ncid, mass_of_bits_id, data, strt, lngth )
-            localpt%mass_of_bits = data(1)
-            iret = NF90_GET_VAR(ncid, heat_density_id, data, strt, lngth )
-            localpt%heat_density = data(1)
+            nret = NF90_GET_VAR(ncid, ndayid, zdata, istrt, ilngth )
+            localpt%day = zdata(1)
+            nret = NF90_GET_VAR(ncid, nmass_of_bits_id, zdata, istrt, ilngth )
+            localpt%mass_of_bits = zdata(1)
+            nret = NF90_GET_VAR(ncid, nheat_density_id, zdata, istrt, ilngth )
+            localpt%heat_density = zdata(1)
             !
             CALL add_new_berg_to_list( localberg, localpt )
@@ -171,52 +172,52 @@
       ENDIF
 
-      iret = NF90_INQ_DIMID( ncid, 'c', c_dim )
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart: nf_inq_dimid c failed')
-
-      iret = NF90_INQUIRE_DIMENSION( ncid, c_dim, dname, mclass )
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart: nf_inquire_dimension failed')
-
-      iret = NF90_INQ_VARID(ncid, 'kount'       , kountid)
-      iret = NF90_INQ_VARID(ncid, 'calving'     , calvid)
-      iret = NF90_INQ_VARID(ncid, 'calving_hflx', calvhid)
-      iret = NF90_INQ_VARID(ncid, 'stored_ice'  , siceid)
-      iret = NF90_INQ_VARID(ncid, 'stored_heat' , sheatid)
-
-      strt3(1) = 1
-      strt3(2) = 1
-      lngth3(1) = jpi
-      lngth3(2) = jpj
-      lngth3(3) = 1
-
-      DO k=1,mclass
-
-         strt3(3) = k
-
-         iret = NF90_GET_VAR( ncid, siceid , griddata, strt3, lngth3 )
-         berg_grid%stored_ice(:,:,k) = griddata(:,:,1)
+      nret = NF90_INQ_DIMID( ncid, 'c', nc_dim )
+      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart: nf_inq_dimid c failed')
+
+      nret = NF90_INQUIRE_DIMENSION( ncid, nc_dim, cl_dname, iclass )
+      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart: nf_inquire_dimension failed')
+
+      nret = NF90_INQ_VARID(ncid, 'kount'       , nkountid)
+      nret = NF90_INQ_VARID(ncid, 'calving'     , ncalvid)
+      nret = NF90_INQ_VARID(ncid, 'calving_hflx', ncalvhid)
+      nret = NF90_INQ_VARID(ncid, 'stored_ice'  , nsiceid)
+      nret = NF90_INQ_VARID(ncid, 'stored_heat' , nsheatid)
+
+      nstrt3(1) = 1
+      nstrt3(2) = 1
+      nlngth3(1) = jpi
+      nlngth3(2) = jpj
+      nlngth3(3) = 1
+
+      DO jn=1,iclass
+
+         nstrt3(3) = jn
+
+         nret = NF90_GET_VAR( ncid, nsiceid , griddata, nstrt3, nlngth3 )
+         berg_grid%stored_ice(:,:,jn) = griddata(:,:,1)
 
       ENDDO
 
-      iret = NF90_GET_VAR( ncid, calvid , p_calving(:,:) )
-      iret = NF90_GET_VAR( ncid, calvhid, p_calving_hflx(:,:) )
-      iret = NF90_GET_VAR( ncid, sheatid, berg_grid%stored_heat(:,:) )
-      iret = NF90_GET_VAR( ncid, kountid, idata2(:) )
-      kount_bergs(:) = idata2(:)
+      nret = NF90_GET_VAR( ncid, ncalvid , src_calving(:,:) )
+      nret = NF90_GET_VAR( ncid, ncalvhid, src_calving_hflx(:,:) )
+      nret = NF90_GET_VAR( ncid, nsheatid, berg_grid%stored_heat(:,:) )
+      nret = NF90_GET_VAR( ncid, nkountid, idata2(:) )
+      num_bergs(:) = idata2(:)
 
       ! Finish up
-      iret = NF90_CLOSE(ncid)
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart: nf_close failed')
+      nret = NF90_CLOSE(ncid)
+      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, read_restart: nf_close failed')
 
       ! Sanity check
-      k = count_bergs()
+      jn = count_bergs()
       IF (nn_verbose_level >= 0)   &
-         WRITE(numout,'(2(a,i5))') 'icebergs, read_restart_bergs: # bergs =',k,' on PE',narea-1
+         WRITE(numout,'(2(a,i5))') 'icebergs, read_restart_bergs: # bergs =',jn,' on PE',narea-1
       IF( lk_mpp ) THEN
-         IF (multiPErestart) CALL mpp_sum(nbergs_in_file) ! In case PE 0 didn't open a file
-         CALL mpp_sum(k)
+         IF (ll_multiPErestart) CALL mpp_sum(ibergs_in_file) ! In case PE 0 didn't open a file
+         CALL mpp_sum(jn)
       ENDIF
       IF ( lwp ) THEN
-         WRITE(numout,'(a,i5,a,i5,a)') 'icebergs, read_restart_bergs: there were',nbergs_in_file, &
-                                       ' bergs in the restart file and', k,' bergs have been read'
+         WRITE(numout,'(a,i5,a,i5,a)') 'icebergs, read_restart_bergs: there were',ibergs_in_file, &
+                                       ' bergs in the restart file and', jn,' bergs have been read'
       ENDIF
 
@@ -232,6 +233,7 @@
       INTEGER, INTENT( in )                 :: kt
       ! Local variables
-      INTEGER                               :: iret, ncid, k_dim, n_dim, x_dim, y_dim, c_dim, k
-      CHARACTER(len=80)                     :: filename
+      INTEGER,                              :: ix_dim, iy_dim, ik_dim, in_dim
+      INTEGER                               :: jn
+      CHARACTER(len=80)                     :: cl_filename
       TYPE(iceberg), POINTER                :: this
       TYPE(point)  , POINTER                :: pt
@@ -239,44 +241,44 @@
       IF( .NOT. ASSOCIATED(griddata) ) ALLOCATE( griddata(jpi,jpj,1) )
 
-      WRITE(filename,'("icebergs_",I8.8,"_restart_",I4.4,".nc")') kt, narea-1
-      IF (nn_verbose_level >= 0) WRITE(numout,'(2a)') 'icebergs, write_restart: creating ',TRIM(filename)
-
-      iret = NF90_CREATE(TRIM(filename), NF90_CLOBBER, ncid)
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_create failed')
+      WRITE(cl_filename,'("icebergs_",I8.8,"_restart_",I4.4,".nc")') kt, narea-1
+      IF (nn_verbose_level >= 0) WRITE(numout,'(2a)') 'icebergs, write_restart: creating ',TRIM(cl_filename)
+
+      nret = NF90_CREATE(TRIM(cl_filename), NF90_CLOBBER, ncid)
+      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_create failed')
 
       ! Dimensions
-      iret = NF90_DEF_DIM(ncid, 'x', jpi, x_dim)
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim x failed')
-
-      iret = NF90_DEF_DIM(ncid, 'y', jpj, y_dim)
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim y failed')
-
-      iret = NF90_DEF_DIM(ncid, 'c', nclasses, c_dim)
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim c failed')
-
-      iret = NF90_DEF_DIM(ncid, 'k', nkounts, k_dim)
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim k failed')
+      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')
 
       IF (associated(first_berg)) then
-         iret = NF90_DEF_DIM(ncid, 'n', NF90_UNLIMITED, n_dim)
-         IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_def_dim n failed')
+         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
-      iret = NF90_DEF_VAR(ncid, 'kount'       , NF90_INT   , (/ k_dim /), kountid)
-      iret = NF90_DEF_VAR(ncid, 'calving'     , NF90_DOUBLE, (/ x_dim, y_dim /), calvid)
-      iret = NF90_DEF_VAR(ncid, 'calving_hflx', NF90_DOUBLE, (/ x_dim, y_dim /), calvhid)
-      iret = NF90_DEF_VAR(ncid, 'stored_ice'  , NF90_DOUBLE, (/ x_dim, y_dim, c_dim /), siceid)
-      iret = NF90_DEF_VAR(ncid, 'stored_heat' , NF90_DOUBLE, (/ x_dim, y_dim /), sheatid)
+      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
-      iret = NF90_PUT_ATT(ncid, calvid , 'long_name', 'iceberg calving')
-      iret = NF90_PUT_ATT(ncid, calvid , 'units', 'some')
-      iret = NF90_PUT_ATT(ncid, calvhid, 'long_name', 'heat flux associated with iceberg calving')
-      iret = NF90_PUT_ATT(ncid, calvhid, 'units', 'some')
-      iret = NF90_PUT_ATT(ncid, siceid , 'long_name', 'stored ice used to calve icebergs')
-      iret = NF90_PUT_ATT(ncid, siceid , 'units', 'kg/s')
-      iret = NF90_PUT_ATT(ncid, sheatid, 'long_name', 'heat in stored ice used to calve icebergs')
-      iret = NF90_PUT_ATT(ncid, sheatid, 'units', 'J/kg/s')
+      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
@@ -285,121 +287,121 @@
 
          ! Variables
-         iret = NF90_DEF_VAR(ncid, 'lon', NF90_DOUBLE, n_dim, lonid)
-         iret = NF90_DEF_VAR(ncid, 'lat', NF90_DOUBLE, n_dim, latid)
-         iret = NF90_DEF_VAR(ncid, 'xi', NF90_DOUBLE, n_dim, xid)
-         iret = NF90_DEF_VAR(ncid, 'yj', NF90_DOUBLE, n_dim, yid)
-         iret = NF90_DEF_VAR(ncid, 'uvel', NF90_DOUBLE, n_dim, uvelid)
-         iret = NF90_DEF_VAR(ncid, 'vvel', NF90_DOUBLE, n_dim, vvelid)
-         iret = NF90_DEF_VAR(ncid, 'mass', NF90_DOUBLE, n_dim, massid)
-         iret = NF90_DEF_VAR(ncid, 'thickness', NF90_DOUBLE, n_dim, thicknessid)
-         iret = NF90_DEF_VAR(ncid, 'width', NF90_DOUBLE, n_dim, widthid)
-         iret = NF90_DEF_VAR(ncid, 'length', NF90_DOUBLE, n_dim, lengthid)
-         iret = NF90_DEF_VAR(ncid, 'number', NF90_INT, (/k_dim,n_dim/), numberid)
-         iret = NF90_DEF_VAR(ncid, 'year', NF90_INT, n_dim, yearid)
-         iret = NF90_DEF_VAR(ncid, 'day', NF90_DOUBLE, n_dim, dayid)
-         iret = NF90_DEF_VAR(ncid, 'mass_scaling', NF90_DOUBLE, n_dim, scaling_id)
-         iret = NF90_DEF_VAR(ncid, 'mass_of_bits', NF90_DOUBLE, n_dim, mass_of_bits_id)
-         iret = NF90_DEF_VAR(ncid, 'heat_density', NF90_DOUBLE, n_dim, heat_density_id)
+         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
-         iret = NF90_PUT_ATT(ncid, lonid, 'long_name', 'longitude')
-         iret = NF90_PUT_ATT(ncid, lonid, 'units', 'degrees_E')
-         iret = NF90_PUT_ATT(ncid, latid, 'long_name', 'latitude')
-         iret = NF90_PUT_ATT(ncid, latid, 'units', 'degrees_N')
-         iret = NF90_PUT_ATT(ncid, xid, 'long_name', 'x grid box position')
-         iret = NF90_PUT_ATT(ncid, xid, 'units', 'fractional')
-         iret = NF90_PUT_ATT(ncid, yid, 'long_name', 'y grid box position')
-         iret = NF90_PUT_ATT(ncid, yid, 'units', 'fractional')
-         iret = NF90_PUT_ATT(ncid, uvelid, 'long_name', 'zonal velocity')
-         iret = NF90_PUT_ATT(ncid, uvelid, 'units', 'm/s')
-         iret = NF90_PUT_ATT(ncid, vvelid, 'long_name', 'meridional velocity')
-         iret = NF90_PUT_ATT(ncid, vvelid, 'units', 'm/s')
-         iret = NF90_PUT_ATT(ncid, massid, 'long_name', 'mass')
-         iret = NF90_PUT_ATT(ncid, massid, 'units', 'kg')
-         iret = NF90_PUT_ATT(ncid, thicknessid, 'long_name', 'thickness')
-         iret = NF90_PUT_ATT(ncid, thicknessid, 'units', 'm')
-         iret = NF90_PUT_ATT(ncid, widthid, 'long_name', 'width')
-         iret = NF90_PUT_ATT(ncid, widthid, 'units', 'm')
-         iret = NF90_PUT_ATT(ncid, lengthid, 'long_name', 'length')
-         iret = NF90_PUT_ATT(ncid, lengthid, 'units', 'm')
-         iret = NF90_PUT_ATT(ncid, numberid, 'long_name', 'iceberg number on this processor')
-         iret = NF90_PUT_ATT(ncid, numberid, 'units', 'count')
-         iret = NF90_PUT_ATT(ncid, yearid, 'long_name', 'calendar year of calving event')
-         iret = NF90_PUT_ATT(ncid, yearid, 'units', 'years')
-         iret = NF90_PUT_ATT(ncid, dayid, 'long_name', 'year day of calving event')
-         iret = NF90_PUT_ATT(ncid, dayid, 'units', 'days')
-         iret = NF90_PUT_ATT(ncid, scaling_id, 'long_name', 'scaling factor for mass of calving berg')
-         iret = NF90_PUT_ATT(ncid, scaling_id, 'units', 'none')
-         iret = NF90_PUT_ATT(ncid, mass_of_bits_id, 'long_name', 'mass of bergy bits')
-         iret = NF90_PUT_ATT(ncid, mass_of_bits_id, 'units', 'kg')
-         iret = NF90_PUT_ATT(ncid, heat_density_id, 'long_name', 'heat density')
-         iret = NF90_PUT_ATT(ncid, heat_density_id, 'units', 'J/kg')
+         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
-      iret = NF90_ENDDEF(ncid)
+      nret = NF90_ENDDEF(ncid)
 
       ! --------------------------------
       ! now write some data
 
-      strt3(1) = 1
-      strt3(2) = 1
-      lngth3(1) = jpi
-      lngth3(2) = jpj
-      lngth3(3) = 1
-
-      DO k=1,nclasses
-         griddata(:,:,1) = berg_grid%stored_ice(:,:,k)
-         strt3(3) = k
-         iret = NF90_PUT_VAR( ncid, siceid, griddata, strt3, lngth3 )
-         IF (iret .ne. NF90_NOERR) THEN
-            IF( lwp ) WRITE(numout,*) TRIM(NF90_STRERROR( iret ))
+      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(filename),' var: stored_ice  written'
-
-      iret = NF90_PUT_VAR( ncid, kountid, kount_bergs(:) )
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var kount failed')
-
-      iret = NF90_PUT_VAR( ncid, sheatid, berg_grid%stored_heat(:,:) )
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var stored_heat failed')
-      IF( lwp ) WRITE(numout,*) 'file: ',TRIM(filename),' var: stored_heat written'
-
-      iret = NF90_PUT_VAR( ncid, calvid , p_calving(:,:) )
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving failed')
-      iret = NF90_PUT_VAR( ncid, calvhid, p_calving_hflx(:,:) )
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_put_var calving_hflx failed')
-      IF( lwp ) WRITE(numout,*) 'file: ',TRIM(filename),' var: calving written'
+      IF( lwp ) WRITE(numout,*) 'file: ',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_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_filename),' var: calving written'
 
       IF ( ASSOCIATED(first_berg) ) THEN
 
          ! Write variables
-         ! sga - just write out the current point of the trajectory
+         ! just write out the current point of the trajectory
 
          this => first_berg
-         k = 0
+         jn = 0
          DO WHILE (ASSOCIATED(this))
             pt => this%current_point
-            k=k+1
-
-            iret = NF90_PUT_VAR(ncid, numberid, this%number, (/1,k/), (/nkounts,1/) )
-            iret = NF90_PUT_VAR(ncid, scaling_id, this%mass_scaling, (/ k /) )
-
-            iret = NF90_PUT_VAR(ncid, lonid, pt%lon, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, latid, pt%lat, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, xid, pt%xi, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, yid, pt%yj, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, uvelid, pt%uvel, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, vvelid, pt%vvel, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, massid, pt%mass, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, thicknessid, pt%thickness, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, widthid, pt%width, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, lengthid, pt%length, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, yearid, pt%year, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, dayid, pt%day, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, mass_of_bits_id, pt%mass_of_bits, (/ k /) )
-            iret = NF90_PUT_VAR(ncid, heat_density_id, pt%heat_density, (/ k /) )
+            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
@@ -409,6 +411,6 @@
 
       ! Finish up
-      iret = NF90_CLOSE(ncid)
-      IF (iret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_close failed')
+      nret = NF90_CLOSE(ncid)
+      IF (nret .ne. NF90_NOERR) CALL ctl_stop('icebergs, write_restart: nf_close failed')
 
    END SUBROUTINE icebergs_write_restart
Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbrun.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbrun.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbrun.F90	(revision 3359)
@@ -39,6 +39,6 @@
    PRIVATE
 
-   PUBLIC   icb_stp        ! routine called in xxx.F90 module
-   PUBLIC   icb_end        ! routine called in xxx.F90 module
+   PUBLIC   icb_stp        ! routine called in sbcmod.F90 module
+   PUBLIC   icb_end        ! routine called in nemogcm.F90 module
 
 CONTAINS
@@ -52,12 +52,12 @@
       !! ** Method  : - blah blah
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in )           ::  kt
+      INTEGER, INTENT( in )           ::   kt
       !
       INTEGER                         ::   iyr, imon, iday, ihr, imin, isec
-      LOGICAL                         ::   lerr, sample_traj, l_budget, l_verbose
+      LOGICAL                         ::   ll_sample_traj, ll_budget, ll_verbose
       !!----------------------------------------------------------------------
       !! start of timestep housekeeping
 
-      ktberg = kt
+      nktberg = kt
 
       ! read calving data
@@ -65,6 +65,6 @@
          !
          CALL fld_read ( kt, 1, sf_icb )
-         p_calving(:,:)      = sf_icb(1)%fnow(:,:,1)    ! calving in km^3/year (water equivalent)
-         p_calving_hflx(:,:) = 0._wp                    ! NO heat flux for now
+         src_calving(:,:)      = sf_icb(1)%fnow(:,:,1)    ! calving in km^3/year (water equivalent)
+         src_calving_hflx(:,:) = 0._wp                    ! NO heat flux for now
          !
       ENDIF
@@ -87,8 +87,8 @@
       current_yearday = yearday(imon, iday, ihr, imin, isec)
 
-      l_verbose = .FALSE.
+      ll_verbose = .FALSE.
       IF( nn_verbose_write .GT. 0 .AND. &
-          MOD(kt-1,nn_verbose_write ) == 0 ) l_verbose = nn_verbose_level >= 0
-      IF( l_verbose ) WRITE(numicb,9100) iyr, imon, iday, ihr, imin, isec, &
+          MOD(kt-1,nn_verbose_write ) == 0 ) ll_verbose = nn_verbose_level >= 0
+      IF( ll_verbose ) WRITE(numicb,9100) iyr, imon, iday, ihr, imin, isec, &
                                         current_year, current_yearday
  9100 FORMAT('y,m,d=',3i5,' h,m,s=',3i5,' yr,yrdy=',i5,f8.3)
@@ -112,7 +112,7 @@
 
       IF( lk_mpp ) THEN
-                                      CALL mpp_send_bergs ()     ! Send bergs to other PEs
+                                     CALL mpp_send_bergs ()     ! Send bergs to other PEs
       ELSE
-                                      CALL lbc_send_bergs()      ! Deal with any cyclic boundaries in non-mpp case
+                                     CALL lbc_send_bergs()      ! Deal with any cyclic boundaries in non-mpp case
       ENDIF
 
@@ -122,7 +122,7 @@
       !! end of timestep housekeeping
 
-      sample_traj = .FALSE.
-      IF( nn_sample_rate .GT. 0 .AND. MOD(kt-1,nn_sample_rate) == 0 )   sample_traj = .TRUE.
-      IF( sample_traj .AND.   &
+      ll_sample_traj = .FALSE.
+      IF( nn_sample_rate .GT. 0 .AND. MOD(kt-1,nn_sample_rate) == 0 )   ll_sample_traj = .TRUE.
+      IF( ll_sample_traj .AND.   &
           ASSOCIATED(first_berg) )   CALL traj_write    ( kt )  ! For each berg, record trajectory
 
@@ -142,7 +142,7 @@
 
       ! Diagnose budgets
-      l_budget = .FALSE.
-      IF( nn_verbose_write .GT. 0 .AND. MOD(kt-1,nn_verbose_write) == 0 )   l_budget = ln_bergdia
-      CALL icb_budget( l_budget )
+      ll_budget = .FALSE.
+      IF( nn_verbose_write .GT. 0 .AND. MOD(kt-1,nn_verbose_write) == 0 )   ll_budget = ln_bergdia
+      CALL icb_budget( ll_budget )
 
       IF( MOD(kt,nn_stock) == 0 ) THEN
@@ -175,5 +175,7 @@
       DEALLOCATE( ssh_e )
 
-      DEALLOCATE( icbfldpts )
+      DEALLOCATE( nicbfldpts )
+      DEALLOCATE( nicbflddest )
+      DEALLOCATE( nicbfldproc )
 
       IF( lk_mpp ) CALL dealloc_buffers()
@@ -206,6 +208,6 @@
       DEALLOCATE(berg_grid)
 
-      DEALLOCATE(initial_width)
-      DEALLOCATE(initial_length)
+      DEALLOCATE(first_width)
+      DEALLOCATE(first_length)
 
       IF (lwp) WRITE(numout,'(a,i6)') 'icebergs: icb_end complete',narea
Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbthm.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbthm.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbthm.F90	(revision 3359)
@@ -29,5 +29,5 @@
    PRIVATE
 
-   PUBLIC   thermodynamics ! routine called in xxx.F90 module
+   PUBLIC   thermodynamics ! routine called in icbrun.F90 module
 
 CONTAINS
@@ -43,9 +43,9 @@
       INTEGER                         ::   kt          ! timestep number, just passed to print_berg
       !
-      REAL(wp)                        ::   M, T, W, L, SST, Vol, Ln, Wn, Tn, nVol, IC, Dn
-      REAL(wp)                        ::   Mv, Me, Mb, melt, dvo, dva, dM, Ss, dMe, dMb, dMv
-      REAL(wp)                        ::   Mnew, Mnew1, Mnew2, heat
-      REAL(wp)                        ::   Mbits, nMbits, dMbitsE, dMbitsM, Lbits, Abits, Mbb
-      REAL(wp)                        ::   xi, yj, zff, z1_rday, z1_e1e2, zdt, z1_dt, z1_dt_e1e2
+      REAL(wp)                        ::   zM, zT, zW, zL, zSST, zVol, zLn, zWn, zTn, znVol, zIC, zDn
+      REAL(wp)                        ::   zMv, zMe, zMb, zmelt, zdvo, zdva, zdM, zSs, zdMe, zdMb, zdMv
+      REAL(wp)                        ::   zMnew, zMnew1, zMnew2, zheat
+      REAL(wp)                        ::   zMbits, znMbits, zdMbitsE, zdMbitsM, zLbits, zAbits, zMbb
+      REAL(wp)                        ::   zxi, zyj, zff, z1_rday, z1_e1e2, zdt, z1_dt, z1_dt_e1e2
       INTEGER                         ::   ii, ij
       TYPE(iceberg)         , POINTER ::   this, next
@@ -67,85 +67,86 @@
          !
          pt => this%current_point
-         knberg = this%number(1)
+         nknberg = this%number(1)
          CALL interp_flds( pt%xi, pt%e1, pt%uo, pt%ui, pt%ua, pt%ssh_x, &
-            &              pt%yj, pt%e2, pt%vo, pt%vi, pt%va, pt%ssh_y, pt%sst, pt%cn, pt%hi, zff )
-         !
-         SST = pt%sst
-         IC  = MIN( 1._wp, pt%cn + rn_sicn_shift )     ! Shift sea-ice concentration       !!gm ???
-         M   = pt%mass
-         T   = pt%thickness                               ! total thickness
-       ! D   = (rn_rho_bergs/rho_seawater)*T ! draught (keel depth)
-       ! F   = T - D ! freeboard
-         W   = pt%width
-         L   = pt%length
-         xi  = pt%xi                                      ! position in (i,j) referential
-         yj  = pt%yj
-         ii  = INT( xi + 0.5 ) - nimpp + 1                    ! t-cell of the berg
-         ij  = INT( yj + 0.5 ) - njmpp + 1
-         Vol = T * W * L
+         &                 pt%yj, pt%e2, pt%vo, pt%vi, pt%va, pt%ssh_y, &
+         &                 pt%sst, pt%cn, pt%hi, zff )
+         !
+         zSST = pt%sst
+         zIC  = MIN( 1._wp, pt%cn + rn_sicn_shift )     ! Shift sea-ice concentration       !!gm ???
+         zM   = pt%mass
+         zT   = pt%thickness                               ! total thickness
+       ! D   = (rn_rho_bergs/pp_rho_seawater)*zT ! draught (keel depth)
+       ! F   = zT - D ! freeboard
+         zW   = pt%width
+         zL   = pt%length
+         zxi  = pt%xi                                      ! position in (i,j) referential
+         zyj  = pt%yj
+         ii  = INT( zxi + 0.5 ) - nimpp + 1                    ! t-cell of the berg
+         ij  = INT( zyj + 0.5 ) - njmpp + 1
+         zVol = zT * zW * zL
          zdt = berg_dt   ;   z1_dt = 1._wp / zdt
 
          ! Environment
-         dvo = SQRT( (pt%uvel-pt%uo)**2 + (pt%vvel-pt%vo)**2 )
-         dva = SQRT( (pt%ua  -pt%uo)**2 + (pt%va  -pt%vo)**2 )
-         Ss  = 1.5 * SQRT( dva ) + 0.1 * dva                ! Sea state      (eqn M.A9)
+         zdvo = SQRT( (pt%uvel-pt%uo)**2 + (pt%vvel-pt%vo)**2 )
+         zdva = SQRT( (pt%ua  -pt%uo)**2 + (pt%va  -pt%vo)**2 )
+         zSs  = 1.5 * SQRT( zdva ) + 0.1 * zdva                ! Sea state      (eqn M.A9)
 
          ! Melt rates in m/s (i.e. division by rday)
-         Mv = MAX( 7.62e-3*SST+1.29e-3*(SST**2)            , 0._wp ) * z1_rday   ! Buoyant convection at sides (eqn M.A10)
-         Mb = MAX( 0.58*(dvo**0.8)*(SST+4.0)/(L**0.2)      , 0._wp ) * z1_rday   ! Basal turbulent melting     (eqn M.A7 )
-         Me = MAX( 1./12.*(SST+2.)*Ss*(1+cos(rpi*(IC**3))) , 0._wp ) * z1_rday   ! Wave erosion                (eqn M.A8 )
+         zMv = MAX( 7.62e-3*zSST+1.29e-3*(zSST**2)            , 0._wp ) * z1_rday   ! Buoyant convection at sides (eqn M.A10)
+         zMb = MAX( 0.58*(zdvo**0.8)*(zSST+4.0)/(zL**0.2)      , 0._wp ) * z1_rday   ! Basal turbulent melting     (eqn M.A7 )
+         zMe = MAX( 1./12.*(zSST+2.)*zSs*(1+cos(rpi*(zIC**3))) , 0._wp ) * z1_rday   ! Wave erosion                (eqn M.A8 )
 
          IF( ln_operator_splitting ) THEN      ! Operator split update of volume/mass
-            Tn    = MAX( T - Mb*zdt , 0._wp )         ! new total thickness (m)
-            nVol  = Tn * W * L                        ! new volume (m^3)
-            Mnew1 = (nVol/Vol) * M                    ! new mass (kg)
-            dMb   = M - Mnew1                         ! mass lost to basal melting (>0) (kg)
-            !
-            Ln    = MAX( L - Mv*zdt , 0._wp )         ! new length (m)
-            Wn    = MAX( W - Mv*zdt , 0._wp )         ! new width (m)
-            nVol  = Tn * Wn * Ln                      ! new volume (m^3)
-            Mnew2 = (nVol/Vol) * M                    ! new mass (kg)
-            dMv   = Mnew1 - Mnew2                     ! mass lost to buoyant convection (>0) (kg)
-            !
-            Ln    = MAX( Ln - Me*zdt , 0._wp )        ! new length (m)
-            Wn    = MAX( Wn - Me*zdt , 0._wp )        ! new width (m)
-            nVol  = Tn * Wn * Ln                      ! new volume (m^3)
-            Mnew  = ( nVol / Vol ) * M                ! new mass (kg)
-            dMe   = Mnew2 - Mnew                      ! mass lost to erosion (>0) (kg)
-            dM    = M - Mnew                          ! mass lost to all erosion and melting (>0) (kg)
+            zTn    = MAX( zT - zMb*zdt , 0._wp )         ! new total thickness (m)
+            znVol  = zTn * zW * zL                        ! new volume (m^3)
+            zMnew1 = (znVol/zVol) * zM                    ! new mass (kg)
+            zdMb   = zM - zMnew1                         ! mass lost to basal melting (>0) (kg)
+            !
+            zLn    = MAX( zL - zMv*zdt , 0._wp )         ! new length (m)
+            zWn    = MAX( zW - zMv*zdt , 0._wp )         ! new width (m)
+            znVol  = zTn * zWn * zLn                      ! new volume (m^3)
+            zMnew2 = (znVol/zVol) * zM                    ! new mass (kg)
+            zdMv   = zMnew1 - zMnew2                     ! mass lost to buoyant convection (>0) (kg)
+            !
+            zLn    = MAX( zLn - zMe*zdt , 0._wp )        ! new length (m)
+            zWn    = MAX( zWn - zMe*zdt , 0._wp )        ! new width (m)
+            znVol  = zTn * zWn * zLn                      ! new volume (m^3)
+            zMnew  = ( znVol / zVol ) * zM                ! new mass (kg)
+            zdMe   = zMnew2 - zMnew                      ! mass lost to erosion (>0) (kg)
+            zdM    = zM - zMnew                          ! mass lost to all erosion and melting (>0) (kg)
             !
          ELSE                                         ! Update dimensions of berg
-            Ln = MAX( L -(Mv+Me)*zdt ,0._wp )         ! (m)
-            Wn = MAX( W -(Mv+Me)*zdt ,0._wp )         ! (m)
-            Tn = MAX( T - Mb    *zdt ,0._wp )         ! (m)
+            zLn = MAX( zL -(zMv+zMe)*zdt ,0._wp )         ! (m)
+            zWn = MAX( zW -(zMv+zMe)*zdt ,0._wp )         ! (m)
+            zTn = MAX( zT - zMb    *zdt ,0._wp )         ! (m)
             ! Update volume and mass of berg
-            nVol = Tn*Wn*Ln                           ! (m^3)
-            Mnew = (nVol/Vol)*M                       ! (kg)
-            dM   = M - Mnew                           ! (kg)
-            dMb = (M/Vol) * (W*   L ) *Mb*zdt         ! approx. mass loss to basal melting (kg)
-            dMe = (M/Vol) * (T*(W+L)) *Me*zdt         ! approx. mass lost to erosion (kg)
-            dMv = (M/Vol) * (T*(W+L)) *Mv*zdt         ! approx. mass loss to buoyant convection (kg)
+            znVol = zTn*zWn*zLn                           ! (m^3)
+            zMnew = (znVol/zVol)*zM                       ! (kg)
+            zdM   = zM - zMnew                           ! (kg)
+            zdMb = (zM/zVol) * (zW*   zL ) *zMb*zdt         ! approx. mass loss to basal melting (kg)
+            zdMe = (zM/zVol) * (zT*(zW+zL)) *zMe*zdt         ! approx. mass lost to erosion (kg)
+            zdMv = (zM/zVol) * (zT*(zW+zL)) *zMv*zdt         ! approx. mass loss to buoyant convection (kg)
          ENDIF
 
          IF( rn_bits_erosion_fraction > 0._wp ) THEN      ! Bergy bits
             !
-            Mbits   = pt%mass_of_bits                                               ! mass of bergy bits (kg)
-            dMbitsE = rn_bits_erosion_fraction * dMe                        ! change in mass of bits (kg)
-            nMbits  = Mbits + dMbitsE                                               ! add new bergy bits to mass (kg)
-            Lbits   = MIN( L, W, T, 40._wp )                                        ! assume bergy bits are smallest dimension or 40 meters
-            Abits   = ( Mbits / rn_rho_bergs ) / Lbits                           ! Effective bottom area (assuming T=Lbits)
-            Mbb     = MAX( 0.58*(dvo**0.8)*(SST+2.0)/(Lbits**0.2), 0.) * z1_rday    ! Basal turbulent melting (for bits)
-            Mbb     = rn_rho_bergs * Abits * Mbb                                 ! in kg/s
-            dMbitsM = MIN( Mbb*zdt , nMbits )                                       ! bergy bits mass lost to melting (kg)
-            nMbits  = nMbits-dMbitsM                                                ! remove mass lost to bergy bits melt
-            IF( Mnew == 0._wp ) THEN                                                ! if parent berg has completely melted then
-               dMbitsM = dMbitsM + nMbits                                           ! instantly melt all the bergy bits
-               nMbits  = 0._wp
+            zMbits   = pt%mass_of_bits                                               ! mass of bergy bits (kg)
+            zdMbitsE = rn_bits_erosion_fraction * zdMe                        ! change in mass of bits (kg)
+            znMbits  = zMbits + zdMbitsE                                               ! add new bergy bits to mass (kg)
+            zLbits   = MIN( zL, zW, zT, 40._wp )                                        ! assume bergy bits are smallest dimension or 40 meters
+            zAbits   = ( zMbits / rn_rho_bergs ) / zLbits                           ! Effective bottom area (assuming T=Lbits)
+            zMbb     = MAX( 0.58*(zdvo**0.8)*(zSST+2.0)/(zLbits**0.2), 0.) * z1_rday    ! Basal turbulent melting (for bits)
+            zMbb     = rn_rho_bergs * zAbits * zMbb                                 ! in kg/s
+            zdMbitsM = MIN( zMbb*zdt , znMbits )                                       ! bergy bits mass lost to melting (kg)
+            znMbits  = znMbits-zdMbitsM                                                ! remove mass lost to bergy bits melt
+            IF( zMnew == 0._wp ) THEN                                                ! if parent berg has completely melted then
+               zdMbitsM = zdMbitsM + znMbits                                           ! instantly melt all the bergy bits
+               znMbits  = 0._wp
             ENDIF
          ELSE                                                     ! No bergy bits
-            Abits   = 0._wp
-            dMbitsE = 0._wp
-            dMbitsM = 0._wp
-            nMbits  = pt%mass_of_bits                             ! retain previous value incase non-zero
+            zAbits   = 0._wp
+            zdMbitsE = 0._wp
+            zdMbitsM = 0._wp
+            znMbits  = pt%mass_of_bits                             ! retain previous value incase non-zero
          ENDIF
 
@@ -154,9 +155,11 @@
             z1_e1e2    = 1._wp / e1e2t(ii,ij) * this%mass_scaling
             z1_dt_e1e2 = z1_dt * z1_e1e2
-            melt    = ( dM - ( dMbitsE - dMbitsM ) ) * z1_dt   ! kg/s
-            berg_grid%floating_melt(ii,ij) = berg_grid%floating_melt(ii,ij) + melt    * z1_e1e2    ! kg/m2/s
-            heat = melt * pt%heat_density              ! kg/s x J/kg = J/s
-            berg_grid%calving_hflx (ii,ij) = berg_grid%calving_hflx (ii,ij) + heat    * z1_e1e2    ! W/m2
-            CALL melt_budget(ii, ij, Mnew, heat, this%mass_scaling, dM, dMbitsE, dMbitsM, dMb, dMe, dMv, z1_dt_e1e2 )
+            zmelt    = ( zdM - ( zdMbitsE - zdMbitsM ) ) * z1_dt   ! kg/s
+            berg_grid%floating_melt(ii,ij) = berg_grid%floating_melt(ii,ij) + zmelt    * z1_e1e2    ! kg/m2/s
+            zheat = zmelt * pt%heat_density              ! kg/s x J/kg = J/s
+            berg_grid%calving_hflx (ii,ij) = berg_grid%calving_hflx (ii,ij) + zheat    * z1_e1e2    ! W/m2
+            CALL melt_budget( ii, ij, zMnew, zheat, this%mass_scaling,       &
+            &                         zdM, zdMbitsE, zdMbitsM, zdMb, zdMe,   &
+            &                         zdMv, z1_dt_e1e2 )
          ELSE
             WRITE(numout,*) 'thermodynamics: berg ',this%number(:),' appears to have grounded  at ',narea,ii,ij
@@ -167,17 +170,17 @@
 
          ! Rolling
-         Dn = ( rn_rho_bergs / rho_seawater ) * Tn       ! draught (keel depth)
-         IF( Dn > 0._wp .AND. MAX(Wn,Ln) < SQRT( 0.92*(Dn**2) + 58.32*Dn ) ) THEN
-            T  = Tn
-            Tn = Wn
-            Wn = T
+         zDn = ( rn_rho_bergs / pp_rho_seawater ) * zTn       ! draught (keel depth)
+         IF( zDn > 0._wp .AND. MAX(zWn,zLn) < SQRT( 0.92*(zDn**2) + 58.32*zDn ) ) THEN
+            zT  = zTn
+            zTn = zWn
+            zWn = zT
          endif
 
          ! Store the new state of iceberg (with L>W)
-         pt%mass         = Mnew
-         pt%mass_of_bits = nMbits
-         pt%thickness    = Tn
-         pt%width        = min(Wn,Ln)
-         pt%length       = max(Wn,Ln)
+         pt%mass         = zMnew
+         pt%mass_of_bits = znMbits
+         pt%thickness    = zTn
+         pt%width        = min(zWn,zLn)
+         pt%length       = max(zWn,zLn)
 
          next=>this%next
@@ -185,10 +188,11 @@
 !!gm  add a test to avoid over melting ?
 
-         IF( Mnew <= 0._wp ) THEN       ! Delete the berg if completely melted
+         IF( zMnew <= 0._wp ) THEN       ! Delete the berg if completely melted
             CALL delete_iceberg_from_list( first_berg, this )
             !
          ELSE                            ! Diagnose mass distribution on grid
             z1_e1e2                 = 1._wp / e1e2t(ii,ij) * this%mass_scaling
-            CALL size_budget(ii, ij, Wn, Ln, Abits, this%mass_scaling, Mnew, nMbits, z1_e1e2)
+            CALL size_budget( ii, ij, zWn, zLn, zAbits,   &
+            &                 this%mass_scaling, zMnew, znMbits, z1_e1e2)
          ENDIF
          !
Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbtrj.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbtrj.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbtrj.F90	(revision 3359)
@@ -26,19 +26,19 @@
    PRIVATE
 
-   INTEGER, PRIVATE   ::   kount_traj
-   INTEGER, PRIVATE   ::   n_dim, k_dim
-   INTEGER, PRIVATE   ::   trajid
-   INTEGER, PRIVATE   ::   numberid, stepid, scaling_id
-   INTEGER, PRIVATE   ::   lonid, latid, xid, yid, uvelid, vvelid, massid
-   INTEGER, PRIVATE   ::   uoid, void, uaid, vaid, uiid, viid
-   INTEGER, PRIVATE   ::   sshxid, sshyid, sstid, cntid, thkid
-   INTEGER, PRIVATE   ::   thicknessid, widthid, lengthid
-   INTEGER, PRIVATE   ::   yearid, dayid
-   INTEGER, PRIVATE   ::   mass_of_bits_id, heat_density_id
-
-   PUBLIC   traj_init           ! routine called in xxx.F90 module
-   PUBLIC   traj_write          ! routine called in xxx.F90 module
-   PUBLIC   traj_sync           ! routine called in xxx.F90 module
-   PUBLIC   traj_end            ! routine called in xxx.F90 module
+   INTEGER, PRIVATE   ::   num_traj
+   INTEGER, PRIVATE   ::   n_dim, m_dim
+   INTEGER, PRIVATE   ::   ntrajid
+   INTEGER, PRIVATE   ::   numberid, nstepid, nscaling_id
+   INTEGER, PRIVATE   ::   nlonid, nlatid, nxid, nyid, nuvelid, nvvelid, nmassid
+   INTEGER, PRIVATE   ::   nuoid, nvoid, nuaid, nvaid, nuiid, nviid
+   INTEGER, PRIVATE   ::   nsshxid, nsshyid, nsstid, ncntid, nthkid
+   INTEGER, PRIVATE   ::   nthicknessid, nwidthid, nlengthid
+   INTEGER, PRIVATE   ::   nyearid, ndayid
+   INTEGER, PRIVATE   ::   nmass_of_bits_id, nheat_density_id
+
+   PUBLIC   traj_init           ! routine called in icbini.F90 module
+   PUBLIC   traj_write          ! routine called in icbrun.F90 module
+   PUBLIC   traj_sync           ! routine called in icbrun.F90 module
+   PUBLIC   traj_end            ! routine called in icbrun.F90 module
 
 CONTAINS
@@ -46,120 +46,120 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE traj_init( nitend )
+   SUBROUTINE traj_init( ktend )
 
       ! local variables
-      INTEGER, INTENT( in )                 :: nitend
-      ! Local variables
-      INTEGER                               :: iret, k
-      CHARACTER(len=80)                     :: filename
+      INTEGER, INTENT( in )                 :: ktend
+      ! Local variables
+      INTEGER                               :: iret
+      CHARACTER(len=80)                     :: cl_filename
       TYPE(iceberg), POINTER                :: this
       TYPE(point)  , POINTER                :: pt
 
       IF( lk_mpp ) THEN
-         WRITE(filename,'("trajectory_icebergs_",I6.6,"_",I4.4,".nc")') nitend, narea-1
+         WRITE(cl_filename,'("trajectory_icebergs_",I6.6,"_",I4.4,".nc")') ktend, narea-1
       ELSE
-         WRITE(filename,'("trajectory_icebergs_",I6.6,".nc")') nitend
+         WRITE(cl_filename,'("trajectory_icebergs_",I6.6,".nc")') ktend
       ENDIF
-      IF ( lwp .AND. nn_verbose_level >= 0) WRITE(numout,'(2a)') 'icebergs, traj_init: creating ',TRIM(filename)
-
-      iret = NF90_CREATE(TRIM(filename), NF90_CLOBBER, trajid)
+      IF ( lwp .AND. nn_verbose_level >= 0) WRITE(numout,'(2a)') 'icebergs, traj_init: creating ',TRIM(cl_filename)
+
+      iret = NF90_CREATE(TRIM(cl_filename), NF90_CLOBBER, ntrajid)
       IF (iret .NE. NF90_NOERR) CALL ctl_stop('icebergs, traj_init: nf_create failed')
 
       ! Dimensions
-      iret = NF90_DEF_DIM(trajid, 'n', NF90_UNLIMITED, n_dim)
+      iret = NF90_DEF_DIM(ntrajid, 'n', NF90_UNLIMITED, n_dim)
       IF (iret .NE. NF90_NOERR) CALL ctl_stop('icebergs, traj_init: nf_def_dim n failed')
-      iret = NF90_DEF_DIM(trajid, 'k', nkounts, k_dim)
+      iret = NF90_DEF_DIM(ntrajid, 'k', nkounts, m_dim)
       IF (iret .NE. NF90_NOERR) CALL ctl_stop('icebergs, traj_init: nf_def_dim k failed')
 
       ! Variables
-      iret = NF90_DEF_VAR(trajid, 'iceberg_number', NF90_INT, (/k_dim,n_dim/), numberid)
-      iret = NF90_DEF_VAR(trajid, 'timestep', NF90_INT, n_dim, stepid)
-      iret = NF90_DEF_VAR(trajid, 'mass_scaling', NF90_DOUBLE, n_dim, scaling_id)
-      iret = NF90_DEF_VAR(trajid, 'lon', NF90_DOUBLE, n_dim, lonid)
-      iret = NF90_DEF_VAR(trajid, 'lat', NF90_DOUBLE, n_dim, latid)
-      iret = NF90_DEF_VAR(trajid, 'xi', NF90_DOUBLE, n_dim, xid)
-      iret = NF90_DEF_VAR(trajid, 'yj', NF90_DOUBLE, n_dim, yid)
-      iret = NF90_DEF_VAR(trajid, 'uvel', NF90_DOUBLE, n_dim, uvelid)
-      iret = NF90_DEF_VAR(trajid, 'vvel', NF90_DOUBLE, n_dim, vvelid)
-      iret = NF90_DEF_VAR(trajid, 'uto', NF90_DOUBLE, n_dim, uoid)
-      iret = NF90_DEF_VAR(trajid, 'vto', NF90_DOUBLE, n_dim, void)
-      iret = NF90_DEF_VAR(trajid, 'uta', NF90_DOUBLE, n_dim, uaid)
-      iret = NF90_DEF_VAR(trajid, 'vta', NF90_DOUBLE, n_dim, vaid)
-      iret = NF90_DEF_VAR(trajid, 'uti', NF90_DOUBLE, n_dim, uiid)
-      iret = NF90_DEF_VAR(trajid, 'vti', NF90_DOUBLE, n_dim, viid)
-      iret = NF90_DEF_VAR(trajid, 'ssh_x', NF90_DOUBLE, n_dim, sshyid)
-      iret = NF90_DEF_VAR(trajid, 'ssh_y', NF90_DOUBLE, n_dim, sshxid)
-      iret = NF90_DEF_VAR(trajid, 'sst', NF90_DOUBLE, n_dim, sstid)
-      iret = NF90_DEF_VAR(trajid, 'icnt', NF90_DOUBLE, n_dim, cntid)
-      iret = NF90_DEF_VAR(trajid, 'ithk', NF90_DOUBLE, n_dim, thkid)
-      iret = NF90_DEF_VAR(trajid, 'mass', NF90_DOUBLE, n_dim, massid)
-      iret = NF90_DEF_VAR(trajid, 'thickness', NF90_DOUBLE, n_dim, thicknessid)
-      iret = NF90_DEF_VAR(trajid, 'width', NF90_DOUBLE, n_dim, widthid)
-      iret = NF90_DEF_VAR(trajid, 'length', NF90_DOUBLE, n_dim, lengthid)
-      iret = NF90_DEF_VAR(trajid, 'year', NF90_INT, n_dim, yearid)
-      iret = NF90_DEF_VAR(trajid, 'day', NF90_DOUBLE, n_dim, dayid)
-      iret = NF90_DEF_VAR(trajid, 'mass_of_bits', NF90_DOUBLE, n_dim, mass_of_bits_id)
-      iret = NF90_DEF_VAR(trajid, 'heat_density', NF90_DOUBLE, n_dim, heat_density_id)
+      iret = NF90_DEF_VAR(ntrajid, 'iceberg_number', NF90_INT, (/m_dim,n_dim/), numberid)
+      iret = NF90_DEF_VAR(ntrajid, 'timestep', NF90_INT, n_dim, nstepid)
+      iret = NF90_DEF_VAR(ntrajid, 'mass_scaling', NF90_DOUBLE, n_dim, nscaling_id)
+      iret = NF90_DEF_VAR(ntrajid, 'lon', NF90_DOUBLE, n_dim, nlonid)
+      iret = NF90_DEF_VAR(ntrajid, 'lat', NF90_DOUBLE, n_dim, nlatid)
+      iret = NF90_DEF_VAR(ntrajid, 'xi', NF90_DOUBLE, n_dim, nxid)
+      iret = NF90_DEF_VAR(ntrajid, 'yj', NF90_DOUBLE, n_dim, nyid)
+      iret = NF90_DEF_VAR(ntrajid, 'uvel', NF90_DOUBLE, n_dim, nuvelid)
+      iret = NF90_DEF_VAR(ntrajid, 'vvel', NF90_DOUBLE, n_dim, nvvelid)
+      iret = NF90_DEF_VAR(ntrajid, 'uto', NF90_DOUBLE, n_dim, nuoid)
+      iret = NF90_DEF_VAR(ntrajid, 'vto', NF90_DOUBLE, n_dim, nvoid)
+      iret = NF90_DEF_VAR(ntrajid, 'uta', NF90_DOUBLE, n_dim, nuaid)
+      iret = NF90_DEF_VAR(ntrajid, 'vta', NF90_DOUBLE, n_dim, nvaid)
+      iret = NF90_DEF_VAR(ntrajid, 'uti', NF90_DOUBLE, n_dim, nuiid)
+      iret = NF90_DEF_VAR(ntrajid, 'vti', NF90_DOUBLE, n_dim, nviid)
+      iret = NF90_DEF_VAR(ntrajid, 'ssh_x', NF90_DOUBLE, n_dim, nsshyid)
+      iret = NF90_DEF_VAR(ntrajid, 'ssh_y', NF90_DOUBLE, n_dim, nsshxid)
+      iret = NF90_DEF_VAR(ntrajid, 'sst', NF90_DOUBLE, n_dim, nsstid)
+      iret = NF90_DEF_VAR(ntrajid, 'icnt', NF90_DOUBLE, n_dim, ncntid)
+      iret = NF90_DEF_VAR(ntrajid, 'ithk', NF90_DOUBLE, n_dim, nthkid)
+      iret = NF90_DEF_VAR(ntrajid, 'mass', NF90_DOUBLE, n_dim, nmassid)
+      iret = NF90_DEF_VAR(ntrajid, 'thickness', NF90_DOUBLE, n_dim, nthicknessid)
+      iret = NF90_DEF_VAR(ntrajid, 'width', NF90_DOUBLE, n_dim, nwidthid)
+      iret = NF90_DEF_VAR(ntrajid, 'length', NF90_DOUBLE, n_dim, nlengthid)
+      iret = NF90_DEF_VAR(ntrajid, 'year', NF90_INT, n_dim, nyearid)
+      iret = NF90_DEF_VAR(ntrajid, 'day', NF90_DOUBLE, n_dim, ndayid)
+      iret = NF90_DEF_VAR(ntrajid, 'mass_of_bits', NF90_DOUBLE, n_dim, nmass_of_bits_id)
+      iret = NF90_DEF_VAR(ntrajid, 'heat_density', NF90_DOUBLE, n_dim, nheat_density_id)
 
       ! Attributes
-      iret = NF90_PUT_ATT(trajid, numberid, 'long_name', 'iceberg number on this processor')
-      iret = NF90_PUT_ATT(trajid, numberid, 'units', 'count')
-      iret = NF90_PUT_ATT(trajid, stepid, 'long_name', 'timestep number kt')
-      iret = NF90_PUT_ATT(trajid, stepid, 'units', 'count')
-      iret = NF90_PUT_ATT(trajid, lonid, 'long_name', 'longitude')
-      iret = NF90_PUT_ATT(trajid, lonid, 'units', 'degrees_E')
-      iret = NF90_PUT_ATT(trajid, latid, 'long_name', 'latitude')
-      iret = NF90_PUT_ATT(trajid, latid, 'units', 'degrees_N')
-      iret = NF90_PUT_ATT(trajid, xid, 'long_name', 'x grid box position')
-      iret = NF90_PUT_ATT(trajid, xid, 'units', 'fractional')
-      iret = NF90_PUT_ATT(trajid, yid, 'long_name', 'y grid box position')
-      iret = NF90_PUT_ATT(trajid, yid, 'units', 'fractional')
-      iret = NF90_PUT_ATT(trajid, uvelid, 'long_name', 'zonal velocity')
-      iret = NF90_PUT_ATT(trajid, uvelid, 'units', 'm/s')
-      iret = NF90_PUT_ATT(trajid, vvelid, 'long_name', 'meridional velocity')
-      iret = NF90_PUT_ATT(trajid, vvelid, 'units', 'm/s')
-      iret = NF90_PUT_ATT(trajid, uoid, 'long_name', 'ocean u component')
-      iret = NF90_PUT_ATT(trajid, uoid, 'units', 'm/s')
-      iret = NF90_PUT_ATT(trajid, void, 'long_name', 'ocean v component')
-      iret = NF90_PUT_ATT(trajid, void, 'units', 'm/s')
-      iret = NF90_PUT_ATT(trajid, uaid, 'long_name', 'atmosphere u component')
-      iret = NF90_PUT_ATT(trajid, uaid, 'units', 'm/s')
-      iret = NF90_PUT_ATT(trajid, vaid, 'long_name', 'atmosphere v component')
-      iret = NF90_PUT_ATT(trajid, vaid, 'units', 'm/s')
-      iret = NF90_PUT_ATT(trajid, uiid, 'long_name', 'sea ice u component')
-      iret = NF90_PUT_ATT(trajid, uiid, 'units', 'm/s')
-      iret = NF90_PUT_ATT(trajid, viid, 'long_name', 'sea ice v component')
-      iret = NF90_PUT_ATT(trajid, viid, 'units', 'm/s')
-      iret = NF90_PUT_ATT(trajid, sshxid, 'long_name', 'sea surface height gradient from x points')
-      iret = NF90_PUT_ATT(trajid, sshxid, 'units', 'm/m')
-      iret = NF90_PUT_ATT(trajid, sshyid, 'long_name', 'sea surface height gradient from y points')
-      iret = NF90_PUT_ATT(trajid, sshyid, 'units', 'm/m')
-      iret = NF90_PUT_ATT(trajid, sstid, 'long_name', 'sea surface temperature')
-      iret = NF90_PUT_ATT(trajid, sstid, 'units', 'degC')
-      iret = NF90_PUT_ATT(trajid, cntid, 'long_name', 'sea ice concentration')
-      iret = NF90_PUT_ATT(trajid, cntid, 'units', 'degC')
-      iret = NF90_PUT_ATT(trajid, thkid, 'long_name', 'sea ice thickness')
-      iret = NF90_PUT_ATT(trajid, thkid, 'units', 'm')
-      iret = NF90_PUT_ATT(trajid, massid, 'long_name', 'mass')
-      iret = NF90_PUT_ATT(trajid, massid, 'units', 'kg')
-      iret = NF90_PUT_ATT(trajid, thicknessid, 'long_name', 'thickness')
-      iret = NF90_PUT_ATT(trajid, thicknessid, 'units', 'm')
-      iret = NF90_PUT_ATT(trajid, widthid, 'long_name', 'width')
-      iret = NF90_PUT_ATT(trajid, widthid, 'units', 'm')
-      iret = NF90_PUT_ATT(trajid, lengthid, 'long_name', 'length')
-      iret = NF90_PUT_ATT(trajid, lengthid, 'units', 'm')
-      iret = NF90_PUT_ATT(trajid, yearid, 'long_name', 'calendar year')
-      iret = NF90_PUT_ATT(trajid, yearid, 'units', 'years')
-      iret = NF90_PUT_ATT(trajid, dayid, 'long_name', 'day of year')
-      iret = NF90_PUT_ATT(trajid, dayid, 'units', 'days')
-      iret = NF90_PUT_ATT(trajid, scaling_id, 'long_name', 'scaling factor for mass of berg')
-      iret = NF90_PUT_ATT(trajid, scaling_id, 'units', 'none')
-      iret = NF90_PUT_ATT(trajid, mass_of_bits_id, 'long_name', 'mass of bergy bits')
-      iret = NF90_PUT_ATT(trajid, mass_of_bits_id, 'units', 'kg')
-      iret = NF90_PUT_ATT(trajid, heat_density_id, 'long_name', 'heat density')
-      iret = NF90_PUT_ATT(trajid, heat_density_id, 'units', 'J/kg')
+      iret = NF90_PUT_ATT(ntrajid, numberid, 'long_name', 'iceberg number on this processor')
+      iret = NF90_PUT_ATT(ntrajid, numberid, 'units', 'count')
+      iret = NF90_PUT_ATT(ntrajid, nstepid, 'long_name', 'timestep number kt')
+      iret = NF90_PUT_ATT(ntrajid, nstepid, 'units', 'count')
+      iret = NF90_PUT_ATT(ntrajid, nlonid, 'long_name', 'longitude')
+      iret = NF90_PUT_ATT(ntrajid, nlonid, 'units', 'degrees_E')
+      iret = NF90_PUT_ATT(ntrajid, nlatid, 'long_name', 'latitude')
+      iret = NF90_PUT_ATT(ntrajid, nlatid, 'units', 'degrees_N')
+      iret = NF90_PUT_ATT(ntrajid, nxid, 'long_name', 'x grid box position')
+      iret = NF90_PUT_ATT(ntrajid, nxid, 'units', 'fractional')
+      iret = NF90_PUT_ATT(ntrajid, nyid, 'long_name', 'y grid box position')
+      iret = NF90_PUT_ATT(ntrajid, nyid, 'units', 'fractional')
+      iret = NF90_PUT_ATT(ntrajid, nuvelid, 'long_name', 'zonal velocity')
+      iret = NF90_PUT_ATT(ntrajid, nuvelid, 'units', 'm/s')
+      iret = NF90_PUT_ATT(ntrajid, nvvelid, 'long_name', 'meridional velocity')
+      iret = NF90_PUT_ATT(ntrajid, nvvelid, 'units', 'm/s')
+      iret = NF90_PUT_ATT(ntrajid, nuoid, 'long_name', 'ocean u component')
+      iret = NF90_PUT_ATT(ntrajid, nuoid, 'units', 'm/s')
+      iret = NF90_PUT_ATT(ntrajid, nvoid, 'long_name', 'ocean v component')
+      iret = NF90_PUT_ATT(ntrajid, nvoid, 'units', 'm/s')
+      iret = NF90_PUT_ATT(ntrajid, nuaid, 'long_name', 'atmosphere u component')
+      iret = NF90_PUT_ATT(ntrajid, nuaid, 'units', 'm/s')
+      iret = NF90_PUT_ATT(ntrajid, nvaid, 'long_name', 'atmosphere v component')
+      iret = NF90_PUT_ATT(ntrajid, nvaid, 'units', 'm/s')
+      iret = NF90_PUT_ATT(ntrajid, nuiid, 'long_name', 'sea ice u component')
+      iret = NF90_PUT_ATT(ntrajid, nuiid, 'units', 'm/s')
+      iret = NF90_PUT_ATT(ntrajid, nviid, 'long_name', 'sea ice v component')
+      iret = NF90_PUT_ATT(ntrajid, nviid, 'units', 'm/s')
+      iret = NF90_PUT_ATT(ntrajid, nsshxid, 'long_name', 'sea surface height gradient from x points')
+      iret = NF90_PUT_ATT(ntrajid, nsshxid, 'units', 'm/m')
+      iret = NF90_PUT_ATT(ntrajid, nsshyid, 'long_name', 'sea surface height gradient from y points')
+      iret = NF90_PUT_ATT(ntrajid, nsshyid, 'units', 'm/m')
+      iret = NF90_PUT_ATT(ntrajid, nsstid, 'long_name', 'sea surface temperature')
+      iret = NF90_PUT_ATT(ntrajid, nsstid, 'units', 'degC')
+      iret = NF90_PUT_ATT(ntrajid, ncntid, 'long_name', 'sea ice concentration')
+      iret = NF90_PUT_ATT(ntrajid, ncntid, 'units', 'degC')
+      iret = NF90_PUT_ATT(ntrajid, nthkid, 'long_name', 'sea ice thickness')
+      iret = NF90_PUT_ATT(ntrajid, nthkid, 'units', 'm')
+      iret = NF90_PUT_ATT(ntrajid, nmassid, 'long_name', 'mass')
+      iret = NF90_PUT_ATT(ntrajid, nmassid, 'units', 'kg')
+      iret = NF90_PUT_ATT(ntrajid, nthicknessid, 'long_name', 'thickness')
+      iret = NF90_PUT_ATT(ntrajid, nthicknessid, 'units', 'm')
+      iret = NF90_PUT_ATT(ntrajid, nwidthid, 'long_name', 'width')
+      iret = NF90_PUT_ATT(ntrajid, nwidthid, 'units', 'm')
+      iret = NF90_PUT_ATT(ntrajid, nlengthid, 'long_name', 'length')
+      iret = NF90_PUT_ATT(ntrajid, nlengthid, 'units', 'm')
+      iret = NF90_PUT_ATT(ntrajid, nyearid, 'long_name', 'calendar year')
+      iret = NF90_PUT_ATT(ntrajid, nyearid, 'units', 'years')
+      iret = NF90_PUT_ATT(ntrajid, ndayid, 'long_name', 'day of year')
+      iret = NF90_PUT_ATT(ntrajid, ndayid, 'units', 'days')
+      iret = NF90_PUT_ATT(ntrajid, nscaling_id, 'long_name', 'scaling factor for mass of berg')
+      iret = NF90_PUT_ATT(ntrajid, nscaling_id, 'units', 'none')
+      iret = NF90_PUT_ATT(ntrajid, nmass_of_bits_id, 'long_name', 'mass of bergy bits')
+      iret = NF90_PUT_ATT(ntrajid, nmass_of_bits_id, 'units', 'kg')
+      iret = NF90_PUT_ATT(ntrajid, nheat_density_id, 'long_name', 'heat density')
+      iret = NF90_PUT_ATT(ntrajid, nheat_density_id, 'units', 'J/kg')
 
       ! End define mode
-      iret = NF90_ENDDEF(trajid)
+      iret = NF90_ENDDEF(ntrajid)
 
    END SUBROUTINE traj_init
@@ -173,6 +173,6 @@
       INTEGER, INTENT( in )                 :: kt
       ! Local variables
-      INTEGER                               :: iret, k
-      CHARACTER(len=80)                     :: filename
+      INTEGER                               :: iret, jn
+      CHARACTER(len=80)                     :: cl_filename
       TYPE(iceberg), POINTER                :: this
       TYPE(point)  , POINTER                :: pt
@@ -182,43 +182,43 @@
 
       this => first_berg
-      k = kount_traj
+      jn = num_traj
       DO WHILE (ASSOCIATED(this))
          pt => this%current_point
-         k=k+1
-
-         iret = NF90_PUT_VAR(trajid, numberid, this%number, (/1,k/), (/nkounts,1/) )
-         iret = NF90_PUT_VAR(trajid, stepid, kt, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, scaling_id, this%mass_scaling, (/ k /) )
-
-         iret = NF90_PUT_VAR(trajid, lonid, pt%lon, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, latid, pt%lat, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, xid, pt%xi, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, yid, pt%yj, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, uvelid, pt%uvel, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, vvelid, pt%vvel, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, uoid, pt%uo, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, void, pt%vo, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, uaid, pt%ua, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, vaid, pt%va, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, uiid, pt%ui, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, viid, pt%vi, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, sshxid, pt%ssh_x, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, sshyid, pt%ssh_y, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, sstid, pt%sst, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, cntid, pt%cn, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, thkid, pt%hi, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, massid, pt%mass, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, thicknessid, pt%thickness, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, widthid, pt%width, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, lengthid, pt%length, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, yearid, pt%year, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, dayid, pt%day, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, mass_of_bits_id, pt%mass_of_bits, (/ k /) )
-         iret = NF90_PUT_VAR(trajid, heat_density_id, pt%heat_density, (/ k /) )
+         jn=jn+1
+
+         iret = NF90_PUT_VAR(ntrajid, numberid, this%number, (/1,jn/), (/nkounts,1/) )
+         iret = NF90_PUT_VAR(ntrajid, nstepid, kt, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nscaling_id, this%mass_scaling, (/ jn /) )
+
+         iret = NF90_PUT_VAR(ntrajid, nlonid, pt%lon, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nlatid, pt%lat, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nxid, pt%xi, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nyid, pt%yj, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nuvelid, pt%uvel, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nvvelid, pt%vvel, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nuoid, pt%uo, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nvoid, pt%vo, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nuaid, pt%ua, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nvaid, pt%va, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nuiid, pt%ui, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nviid, pt%vi, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nsshxid, pt%ssh_x, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nsshyid, pt%ssh_y, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nsstid, pt%sst, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, ncntid, pt%cn, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nthkid, pt%hi, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nmassid, pt%mass, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nthicknessid, pt%thickness, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nwidthid, pt%width, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nlengthid, pt%length, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nyearid, pt%year, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, ndayid, pt%day, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nmass_of_bits_id, pt%mass_of_bits, (/ jn /) )
+         iret = NF90_PUT_VAR(ntrajid, nheat_density_id, pt%heat_density, (/ jn /) )
 
          this=>this%next
       ENDDO
-      IF( lwp .and. nn_verbose_level > 0 ) WRITE(numout,*) 'trajectory write to frame ', k
-      kount_traj = k
+      IF( lwp .and. nn_verbose_level > 0 ) WRITE(numout,*) 'trajectory write to frame ', jn
+      num_traj = jn
 
    END SUBROUTINE traj_write
@@ -231,5 +231,5 @@
 
       ! flush to file
-      iret = NF90_SYNC(trajid)
+      iret = NF90_SYNC(ntrajid)
       IF (iret .NE. NF90_NOERR) CALL ctl_stop('icebergs, traj_sync: nf_sync failed')
 
@@ -243,5 +243,5 @@
 
       ! Finish up
-      iret = NF90_CLOSE(trajid)
+      iret = NF90_CLOSE(ntrajid)
       IF (iret .NE. NF90_NOERR) CALL ctl_stop('icebergs, traj_end: nf_close failed')
 
Index: /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbutl.F90
===================================================================
--- /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbutl.F90	(revision 3358)
+++ /branches/2012/dev_r3337_NOCS10_ICB/NEMOGCM/NEMO/OPA_SRC/ICB/icbutl.F90	(revision 3359)
@@ -34,21 +34,21 @@
    PRIVATE
 
-   PUBLIC   copy_flds                ! routine called in xxx.F90 module
-   PUBLIC   interp_flds              ! routine called in xxx.F90 module
-   PUBLIC   bilin
-   PUBLIC   bilin_x
-   PUBLIC   bilin_e
-   PUBLIC   add_new_berg_to_list
-   PUBLIC   insert_berg_into_list
-   PUBLIC   delete_iceberg_from_list
-   PUBLIC   destroy_iceberg
-   PUBLIC   track_berg
-   PUBLIC   print_berg
-   PUBLIC   print_bergs
-   PUBLIC   count_bergs
-   PUBLIC   increment_kounter
-   PUBLIC   yearday
-   PUBLIC   sum_mass
-   PUBLIC   sum_heat
+   PUBLIC   copy_flds                    ! routine called in icbrun module
+   PUBLIC   interp_flds                  ! routine called in icbdyn, icbthm modules
+   PUBLIC   bilin                        ! routine called in icbini, icbdyn modules
+   PUBLIC   bilin_x                      ! routine called in icbdyn module
+   PRIVATE  bilin_e
+   PUBLIC   add_new_berg_to_list         ! routine called in icbini.F90, icbclv, icblbc and icbrst modules
+   PRIVATE  insert_berg_into_list
+   PUBLIC   delete_iceberg_from_list     ! routine called in icblbc, icbthm modules
+   PUBLIC   destroy_iceberg              ! routine called in icbrun module
+   PUBLIC   track_berg                   ! routine not currently used, retain just in case
+   PUBLIC   print_berg                   ! routine called in icbthm module
+   PUBLIC   print_bergs                  ! routine called in icbini, icbrun module
+   PUBLIC   count_bergs                  ! routine called in icbdia, icbini, icblbc, icbrst modules
+   PUBLIC   increment_kounter            ! routine called in icbini, icbclv modules
+   PUBLIC   yearday                      ! routine called in icbclv, icbrun module
+   PUBLIC   sum_mass                     ! routine called in icbdia module
+   PUBLIC   sum_heat                     ! routine called in icbdia module
 
    PRIVATE  create_iceberg
@@ -109,6 +109,7 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE interp_flds( pi, pe1, puo, pui, pua, pssh_i,                     &
-      &                    pj, pe2, pvo, pvi, pva, pssh_j, psst, pcn, phi, pff )
+   SUBROUTINE interp_flds( pi, pe1, puo, pui, pua, pssh_i,   &
+      &                    pj, pe2, pvo, pvi, pva, pssh_j,   &
+      &                    psst, pcn, phi, pff )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE interp_flds  ***
@@ -168,5 +169,5 @@
    !!-------------------------------------------------------------------------
 
-   REAL(wp) FUNCTION bilin( pfld, pi, pj, cd_type, jdi, jdj )
+   REAL(wp) FUNCTION bilin( pfld, pi, pj, cd_type, kdi, kdj )
       !!----------------------------------------------------------------------
       !!                  ***  FUNCTION bilin  ***
@@ -178,6 +179,6 @@
       !!
       !!----------------------------------------------------------------------
-      INTEGER                                         , INTENT(in) ::   jdi, jdj  ! extra halo on grid
-      REAL(wp), DIMENSION(1-jdi:jpi+jdi,1-jdj:jpj+jdj), INTENT(in) ::   pfld      ! field to be interpolated
+      INTEGER                                         , INTENT(in) ::   kdi, kdj  ! extra halo on grid
+      REAL(wp), DIMENSION(1-kdi:jpi+kdi,1-kdj:jpj+kdj), INTENT(in) ::   pfld      ! field to be interpolated
       REAL(wp)                                        , INTENT(in) ::   pi, pj    ! targeted coordinates in (i,j) referential
       CHARACTER(len=1)                                , INTENT(in) ::   cd_type   ! type of pfld array grid-points: = T , U , V or F points
@@ -424,14 +425,13 @@
    !!-------------------------------------------------------------------------
 
-   REAL(wp) FUNCTION yearday(imon, iday, ihr, imin, isec)
+   REAL(wp) FUNCTION yearday(kmon, kday, khr, kmin, ksec)
       ! sga - improved but still only applies to 365 day year, need to do this properly
       ! Arguments
-      INTEGER, intent(in)     :: imon, iday, ihr, imin, isec
+      INTEGER, intent(in)     :: kmon, kday, khr, kmin, ksec
       ! Local variables
-      INTEGER                 :: i
-      INTEGER, DIMENSION(12)  :: months = (/ 0,31,28,31,30,31,30,31,31,30,31,30 /)
-
-      yearday = FLOAT( SUM( months(1:imon) ) )
-      yearday = yearday + FLOAT(iday-1) + (FLOAT(ihr) + (FLOAT(imin) + FLOAT(isec)/60.)/60.)/24.
+      INTEGER, DIMENSION(12)  :: imonths = (/ 0,31,28,31,30,31,30,31,31,30,31,30 /)
+
+      yearday = FLOAT( SUM( imonths(1:kmon) ) )
+      yearday = yearday + FLOAT(kday-1) + (FLOAT(khr) + (FLOAT(kmin) + FLOAT(ksec)/60.)/60.)/24.
 
    END FUNCTION yearday
@@ -458,5 +458,5 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE destroy_iceberg(berg)
+   SUBROUTINE destroy_iceberg( berg )
       ! Arguments
       TYPE(iceberg), POINTER :: berg
@@ -472,8 +472,8 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE track_berg( num, label, kt )
+   SUBROUTINE track_berg( knum, cd_label, kt )
       ! Arguments
-      INTEGER, DIMENSION(nkounts)    :: num            ! iceberg number
-      CHARACTER(len=*)               :: label
+      INTEGER, DIMENSION(nkounts)    :: knum            ! iceberg number
+      CHARACTER(len=*)               :: cd_label
       INTEGER                        :: kt             ! timestep number
       ! Local variables
@@ -486,5 +486,5 @@
          match = .TRUE.
          DO k=1,nkounts
-            IF( this%number(k) /= num(k) ) match = .FALSE.
+            IF( this%number(k) /= knum(k) ) match = .FALSE.
          END DO
          IF( match ) CALL print_berg(this, kt)
@@ -513,15 +513,15 @@
    !!-------------------------------------------------------------------------
 
-   SUBROUTINE print_bergs( label, kt )
+   SUBROUTINE print_bergs( cd_label, kt )
       ! Arguments
-      CHARACTER(len=*)       :: label
+      CHARACTER(len=*)       :: cd_label
       INTEGER                :: kt             ! timestep number
       ! Local variables
-      INTEGER                :: nbergs, nnbergs
+      INTEGER                :: ibergs, inbergs
       TYPE(iceberg), POINTER :: this
 
       this => first_berg
       IF( ASSOCIATED(this) ) THEN
-         WRITE(numicb,'(a," pe=(",i3,")")' ) label, narea
+         WRITE(numicb,'(a," pe=(",i3,")")' ) cd_label, narea
          WRITE(numicb,'(a8,4x,a6,12x,a5,15x,a7,19x,a3,17x,a5,17x,a5,17x,a5)' )   &
                       'timestep', 'number', 'xi,yj','lon,lat','u,v','uo,vo','ua,va','ui,vi'
@@ -531,9 +531,9 @@
         this => this%next
       ENDDO
-      nbergs = count_bergs()
-      nnbergs = nbergs
-      IF( lk_mpp ) CALL mpp_sum(nnbergs)
-      IF ( nbergs .GT. 0 ) WRITE(numicb,'(a," there are",i5," bergs out of",i6," on PE ",i4)') &
-                                           label, nbergs, nnbergs, narea
+      ibergs = count_bergs()
+      inbergs = ibergs
+      IF( lk_mpp ) CALL mpp_sum(inbergs)
+      IF ( ibergs .GT. 0 ) WRITE(numicb,'(a," there are",i5," bergs out of",i6," on PE ",i4)') &
+                                           cd_label, ibergs, inbergs, narea
 
    END SUBROUTINE print_bergs
@@ -543,5 +543,5 @@
    SUBROUTINE increment_kounter()
       ! Small routine for coping with very large integer values labelling icebergs
-      ! kount_bergs is a array of integers
+      ! num_bergs is a array of integers
       ! the first member is incremented in steps of jpnij starting from narea
       ! this means each iceberg is labelled with a unique number
@@ -550,20 +550,20 @@
 
       ! Local variables
-      INTEGER                :: i, ibig
-
-      ibig = HUGE(kount_bergs(1))
-      IF( ibig-jpnij < kount_bergs(1) ) THEN
-         kount_bergs(1) = narea
-         DO i = 2,nkounts
-            IF( kount_bergs(i) == ibig ) THEN
-               kount_bergs(i) = 0
-               IF( i == nkounts ) CALL ctl_stop('Sorry, run out of iceberg number space')
+      INTEGER                :: ii, ibig
+
+      ibig = HUGE(num_bergs(1))
+      IF( ibig-jpnij < num_bergs(1) ) THEN
+         num_bergs(1) = narea
+         DO ii = 2,nkounts
+            IF( num_bergs(ii) == ibig ) THEN
+               num_bergs(ii) = 0
+               IF( ii == nkounts ) CALL ctl_stop('Sorry, run out of iceberg number space')
             ELSE
-               kount_bergs(i) = kount_bergs(i) + 1
+               num_bergs(ii) = num_bergs(ii) + 1
                EXIT
             ENDIF
          END DO
       ELSE
-         kount_bergs(1) = kount_bergs(1) + jpnij
+         num_bergs(1) = num_bergs(1) + jpnij
       ENDIF
 
