Index: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts/std_ts_S.pro
===================================================================
--- branches/2012/dev_NOC_2012_rev3555/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts/std_ts_S.pro	(revision 3609)
+++ branches/2012/dev_NOC_2012_rev3555/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts/std_ts_S.pro	(revision 3610)
@@ -31,5 +31,5 @@
 
 ; read exp1 data
-  std_ts_read, vsal, date1, date2, prefix, suffix, ts_Sal, ts_z $
+  std_ts_read, vsal, date1, date2, prefix, suffix, ts_Sal, ts_z, masknp $
                , WITHSSH = vssh, SSHPREFIX = sshprefix, SSHSUFFIX = sshsuffix, LEVZ = levz
 
@@ -62,5 +62,5 @@
 ; read exp2 data
     tsave = time
-    std_ts_read, vsal2, date1_2, date2_2, prefix2, suffix2, ts_Sal2, ts_z2 $
+    std_ts_read, vsal2, date1_2, date2_2, prefix2, suffix2, ts_Sal2, ts_z2, masknp $
                  , WITHSSH = vssh2, SSHPREFIX = sshprefix2, SSHSUFFIX = sshsuffix2, LEVZ = levz
     time = tsave   &   IF n_elements(time) NE jpt THEN stop
Index: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts/std_ts_T.pro
===================================================================
--- branches/2012/dev_NOC_2012_rev3555/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts/std_ts_T.pro	(revision 3609)
+++ branches/2012/dev_NOC_2012_rev3555/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts/std_ts_T.pro	(revision 3610)
@@ -31,5 +31,5 @@
 
 ; read exp1 data
-  std_ts_read, vtemp, date1, date2, prefix, suffix, ts_Temp, ts_z $
+  std_ts_read, vtemp, date1, date2, prefix, suffix, ts_Temp, ts_z, masknp $
                , WITHSSH = vssh, SSHPREFIX = sshprefix, SSHSUFFIX = sshsuffix, LEVZ = levz
 
@@ -62,5 +62,5 @@
 ; read exp2 data
     tsave = time
-    std_ts_read, vtemp2, date1_2, date2_2, prefix2, suffix2, ts_Temp2, ts_z2 $
+    std_ts_read, vtemp2, date1_2, date2_2, prefix2, suffix2, ts_Temp2, ts_z2, masknp $
                  , WITHSSH = vssh2, SSHPREFIX = sshprefix2, SSHSUFFIX = sshsuffix2, LEVZ = levz
     time = tsave   &   IF n_elements(time) NE jpt THEN stop
Index: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts/std_ts_read.pro
===================================================================
--- branches/2012/dev_NOC_2012_rev3555/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts/std_ts_read.pro	(revision 3609)
+++ branches/2012/dev_NOC_2012_rev3555/NEMOGCM/CONFIG/ORCA2_LIM/IDL_scripts/std_ts_read.pro	(revision 3610)
@@ -1,3 +1,3 @@
-PRO std_ts_read, var_name, dt1, dt2, prefix, suffix, ts, ts_z $
+PRO std_ts_read, var_name, dt1, dt2, prefix, suffix, ts, ts_z, masknp $
                  , WITHSSH = withssh, SSHPREFIX = sshprefix, SSHSUFFIX = sshsuffix, LEVZ = levz
 
Index: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/mod_interface_ioipsl.f90
===================================================================
--- branches/2012/dev_NOC_2012_rev3555/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/mod_interface_ioipsl.f90	(revision 3609)
+++ branches/2012/dev_NOC_2012_rev3555/NEMOGCM/EXTERNAL/XMLIO_SERVER/src/IOSERVER/mod_interface_ioipsl.f90	(revision 3610)
@@ -38,4 +38,5 @@
   USE ioipsl
   USE xmlio
+  USE mod_ioserver_namelist
   IMPLICIT NONE
     INTEGER,INTENT(IN)  :: nb_server
@@ -88,5 +89,5 @@
                        pt_zoom%ibegin_loc, pt_zoom%ni_loc,pt_zoom%jbegin_loc,pt_zoom%nj_loc,         &
                        initial_timestep, initial_date, timestep_value,                               &
-                       ioipsl_hori_id, ioipsl_file_id)
+                       ioipsl_hori_id, ioipsl_file_id, snc4chunks=snc4ioset)
            ELSE                                              
 
@@ -95,5 +96,5 @@
                        pt_zoom%ibegin_loc, pt_zoom%ni_loc,pt_zoom%jbegin_loc,pt_zoom%nj_loc,          &
                        initial_timestep, initial_date, timestep_value,                                &
-                       ioipsl_hori_id, ioipsl_file_id,domain_id=ioipsl_domain_id)                                              
+                       ioipsl_hori_id, ioipsl_file_id,domain_id=ioipsl_domain_id, snc4chunks=snc4ioset)                                              
           
            ENDIF
@@ -142,5 +143,5 @@
             ENDIF
           ENDDO
-          CALL histend(ioipsl_file_id)
+          CALL histend(ioipsl_file_id, snc4chunks=snc4ioset)
         ENDIF
         CALL sorted_list__delete(axis_id)
Index: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90
===================================================================
--- branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90	(revision 3609)
+++ branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/LIM_SRC_3/limistate.F90	(revision 3610)
@@ -460,4 +460,10 @@
       ! 4) Moments for advection
       !--------------------------------------------------------------------
+
+      sxopw (:,:) = 0.e0 
+      syopw (:,:) = 0.e0 
+      sxxopw(:,:) = 0.e0 
+      syyopw(:,:) = 0.e0 
+      sxyopw(:,:) = 0.e0
 
       sxice (:,:,:)  = 0.e0   ;   sxsn (:,:,:)  = 0.e0   ;   sxa  (:,:,:)  = 0.e0
Index: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90
===================================================================
--- branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90	(revision 3609)
+++ branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/LIM_SRC_3/limthd_dif.F90	(revision 3610)
@@ -102,44 +102,7 @@
       INTEGER ::   nconv       ! number of iterations in iterative procedure
       INTEGER ::   minnumeqmin, maxnumeqmax
-
-      INTEGER , POINTER, DIMENSION(:) ::   numeqmin   ! reference number of top equation
-      INTEGER , POINTER, DIMENSION(:) ::   numeqmax   ! reference number of bottom equation
-      INTEGER , POINTER, DIMENSION(:) ::   isnow      ! switch for presence (1) or absence (0) of snow
-
-      !! * New local variables       
-      REAL(wp), POINTER, DIMENSION(:,:) ::   ztcond_i   !Ice thermal conductivity
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zradtr_i   !Radiation transmitted through the ice
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zradab_i   !Radiation absorbed in the ice
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zkappa_i   !Kappa factor in the ice
-
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zradtr_s   !Radiation transmited through the snow
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zradab_s   !Radiation absorbed in the snow
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zkappa_s   !Kappa factor in the snow
-
-      REAL(wp), POINTER, DIMENSION(:,:) ::   ztiold      !Old temperature in the ice
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zeta_i      !Eta factor in the ice 
-      REAL(wp), POINTER, DIMENSION(:,:) ::   ztitemp     !Temporary temperature in the ice to check the convergence
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zspeche_i   !Ice specific heat
-      REAL(wp), POINTER, DIMENSION(:,:) ::   z_i         !Vertical cotes of the layers in the ice
-
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zeta_s      !Eta factor in the snow
-      REAL(wp), POINTER, DIMENSION(:,:) ::   ztstemp     !Temporary temperature in the snow to check the convergence
-      REAL(wp), POINTER, DIMENSION(:,:) ::   ztsold      !Temporary temperature in the snow
-      REAL(wp), POINTER, DIMENSION(:,:) ::   z_s         !Vertical cotes of the layers in the snow
-
-      REAL(wp), POINTER, DIMENSION(:,:)   ::   zindterm    ! Independent term
-      REAL(wp), POINTER, DIMENSION(:,:)   ::   zindtbis    ! temporary independent term
-      REAL(wp), POINTER, DIMENSION(:,:)   ::   zdiagbis
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztrid       ! tridiagonal system terms
-
-      REAL(wp), POINTER, DIMENSION(:) ::   ztfs        ! ice melting point
-      REAL(wp), POINTER, DIMENSION(:) ::   ztsuold     ! old surface temperature (before the iterative procedure )
-      REAL(wp), POINTER, DIMENSION(:) ::   ztsuoldit   ! surface temperature at previous iteration
-      REAL(wp), POINTER, DIMENSION(:) ::   zh_i        ! ice layer thickness
-      REAL(wp), POINTER, DIMENSION(:) ::   zh_s        ! snow layer thickness
-      REAL(wp), POINTER, DIMENSION(:) ::   zfsw        ! solar radiation absorbed at the surface
-      REAL(wp), POINTER, DIMENSION(:) ::   zf          ! surface flux function
-      REAL(wp), POINTER, DIMENSION(:) ::   dzf         ! derivative of the surface flux function
-
+      INTEGER, DIMENSION(kiut) ::   numeqmin   ! reference number of top equation
+      INTEGER, DIMENSION(kiut) ::   numeqmax   ! reference number of bottom equation
+      INTEGER, DIMENSION(kiut) ::   isnow      ! switch for presence (1) or absence (0) of snow
       REAL(wp) ::   zeps      =  1.e-10_wp    !
       REAL(wp) ::   zg1s      =  2._wp        ! for the tridiagonal system
@@ -150,21 +113,41 @@
       REAL(wp) ::   zkimin    =  0.10_wp      ! minimum ice thermal conductivity
       REAL(wp) ::   zht_smin  =  1.e-4_wp     ! minimum snow depth
-
       REAL(wp) ::   ztmelt_i    ! ice melting temperature
       REAL(wp) ::   zerritmax   ! current maximal error on temperature 
-      REAL(wp), POINTER, DIMENSION(:) ::   zerrit       ! current error on temperature 
-      REAL(wp), POINTER, DIMENSION(:) ::   zdifcase     ! case of the equation resolution (1->4)
-      REAL(wp), POINTER, DIMENSION(:) ::   zftrice      ! solar radiation transmitted through the ice
-      REAL(wp), POINTER, DIMENSION(:) ::   zihic, zhsu
+      REAL(wp), DIMENSION(kiut) ::   ztfs        ! ice melting point
+      REAL(wp), DIMENSION(kiut) ::   ztsuold     ! old surface temperature (before the iterative procedure )
+      REAL(wp), DIMENSION(kiut) ::   ztsuoldit   ! surface temperature at previous iteration
+      REAL(wp), DIMENSION(kiut) ::   zh_i        ! ice layer thickness
+      REAL(wp), DIMENSION(kiut) ::   zh_s        ! snow layer thickness
+      REAL(wp), DIMENSION(kiut) ::   zfsw        ! solar radiation absorbed at the surface
+      REAL(wp), DIMENSION(kiut) ::   zf          ! surface flux function
+      REAL(wp), DIMENSION(kiut) ::   dzf         ! derivative of the surface flux function
+      REAL(wp), DIMENSION(kiut) ::   zerrit      ! current error on temperature
+      REAL(wp), DIMENSION(kiut) ::   zdifcase    ! case of the equation resolution (1->4)
+      REAL(wp), DIMENSION(kiut) ::   zftrice     ! solar radiation transmitted through the ice
+      REAL(wp), DIMENSION(kiut) ::   zihic, zhsu
+      REAL(wp), DIMENSION(kiut,0:nlay_i) ::   ztcond_i    ! Ice thermal conductivity
+      REAL(wp), DIMENSION(kiut,0:nlay_i) ::   zradtr_i    ! Radiation transmitted through the ice
+      REAL(wp), DIMENSION(kiut,0:nlay_i) ::   zradab_i    ! Radiation absorbed in the ice
+      REAL(wp), DIMENSION(kiut,0:nlay_i) ::   zkappa_i    ! Kappa factor in the ice
+      REAL(wp), DIMENSION(kiut,0:nlay_i) ::   ztiold      ! Old temperature in the ice
+      REAL(wp), DIMENSION(kiut,0:nlay_i) ::   zeta_i      ! Eta factor in the ice
+      REAL(wp), DIMENSION(kiut,0:nlay_i) ::   ztitemp     ! Temporary temperature in the ice to check the convergence
+      REAL(wp), DIMENSION(kiut,0:nlay_i) ::   zspeche_i   ! Ice specific heat
+      REAL(wp), DIMENSION(kiut,0:nlay_i) ::   z_i         ! Vertical cotes of the layers in the ice
+      REAL(wp), DIMENSION(kiut,0:nlay_s) ::   zradtr_s    ! Radiation transmited through the snow
+      REAL(wp), DIMENSION(kiut,0:nlay_s) ::   zradab_s    ! Radiation absorbed in the snow
+      REAL(wp), DIMENSION(kiut,0:nlay_s) ::   zkappa_s    ! Kappa factor in the snow
+      REAL(wp), DIMENSION(kiut,0:nlay_s) ::   zeta_s       ! Eta factor in the snow
+      REAL(wp), DIMENSION(kiut,0:nlay_s) ::   ztstemp      ! Temporary temperature in the snow to check the convergence
+      REAL(wp), DIMENSION(kiut,0:nlay_s) ::   ztsold       ! Temporary temperature in the snow
+      REAL(wp), DIMENSION(kiut,0:nlay_s) ::   z_s          ! Vertical cotes of the layers in the snow
+      REAL(wp), DIMENSION(kiut,jkmax+2) ::   zindterm   ! Independent term
+      REAL(wp), DIMENSION(kiut,jkmax+2) ::   zindtbis   ! temporary independent term
+      REAL(wp), DIMENSION(kiut,jkmax+2) ::   zdiagbis
+      REAL(wp), DIMENSION(kiut,jkmax+2,3) ::   ztrid   ! tridiagonal system terms
       !!------------------------------------------------------------------
-      !
-      CALL wrk_alloc( kiut, numeqmin, numeqmax, isnow )   ! integer
-      CALL wrk_alloc( kiut,nlay_i+1, ztcond_i, zradtr_i, zradab_i, zkappa_i, ztiold, zeta_i, ztitemp, zspeche_i, z_i, kjstart=0 )
-      CALL wrk_alloc( kiut,nlay_s+1, zradtr_s, zradab_s, zkappa_s, zeta_s, ztstemp, ztsold, z_s, kjstart=0 )
-      CALL wrk_alloc( kiut,jkmax+2, zindterm, zindtbis, zdiagbis )
-      CALL wrk_alloc( kiut,jkmax+2,3, ztrid )
-      CALL wrk_alloc( kiut, ztfs, ztsuold, ztsuoldit, zh_i, zh_s, zfsw, zf, dzf )
-      CALL wrk_alloc( kiut, zerrit, zdifcase, zftrice, zihic, zhsu )
-
+      
+      ! 
       !------------------------------------------------------------------------------!
       ! 1) Initialization                                                            !
@@ -772,12 +755,4 @@
       ENDIF
       !
-      CALL wrk_dealloc( kiut, numeqmin, numeqmax, isnow )   ! integer
-      CALL wrk_dealloc( kiut,nlay_i+1, ztcond_i, zradtr_i, zradab_i, zkappa_i, ztiold, zeta_i, ztitemp, zspeche_i, z_i, kjstart=0 )
-      CALL wrk_dealloc( kiut,nlay_s+1, zradtr_s, zradab_s, zkappa_s, zeta_s, ztstemp, ztsold, z_s, kjstart=0 )
-      CALL wrk_dealloc( kiut,jkmax+2, zindterm, zindtbis, zdiagbis )
-      CALL wrk_dealloc( kiut,jkmax+2,3, ztrid )
-      CALL wrk_dealloc( kiut, ztfs, ztsuold, ztsuoldit, zh_i, zh_s, zfsw, zf, dzf )
-      CALL wrk_dealloc( kiut, zerrit, zdifcase, zftrice, zihic, zhsu )
-
    END SUBROUTINE lim_thd_dif
 
Index: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice_lim2.F90
===================================================================
--- branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice_lim2.F90	(revision 3609)
+++ branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice_lim2.F90	(revision 3610)
@@ -53,5 +53,5 @@
             CYCLE
          CASE(jp_frs)
-            CALL bdy_ice_frs( idx_bdy(ib_bdy), dta_idx(ib_bdy) )
+            CALL bdy_ice_frs( idx_bdy(ib_bdy), dta_bdy(ib_bdy) )
          CASE DEFAULT
             CALL ctl_stop( 'bdy_ice_lim_2 : unrecognised option for open boundaries for ice fields' )
Index: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/DIA/diaptr.F90
===================================================================
--- branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/DIA/diaptr.F90	(revision 3609)
+++ branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/DIA/diaptr.F90	(revision 3610)
@@ -332,5 +332,5 @@
       !!----------------------------------------------------------------------
       USE oce,     vt  =>   ua   ! use ua as workspace
-      USE oce,     vs  =>   ua   ! use ua as workspace
+      USE oce,     vs  =>   va   ! use va as workspace
       IMPLICIT none
       !!
@@ -378,6 +378,6 @@
                      zv = ( vn(ji,jj,jk) + vn(ji,jj-1,jk) ) * 0.5_wp
 #endif 
-                     vt(:,jj,jk) = zv * tsn(:,jj,jk,jp_tem)
-                     vs(:,jj,jk) = zv * tsn(:,jj,jk,jp_sal)
+                     vt(ji,jj,jk) = zv * tsn(ji,jj,jk,jp_tem)
+                     vs(ji,jj,jk) = zv * tsn(ji,jj,jk,jp_sal)
                   END DO
                END DO
Index: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90
===================================================================
--- branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90	(revision 3609)
+++ branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90	(revision 3610)
@@ -227,6 +227,8 @@
       ENDIF
       !
-      !                              ! allocate zdfddm arrays
+      !                               ! allocate zdfddm arrays
       IF( zdf_ddm_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_ddm_init : unable to allocate arrays' )
+      !                               ! initialization to masked Kz
+      avs(:,:,:) = rn_avt0 * tmask(:,:,:) 
       !
    END SUBROUTINE zdf_ddm_init
Index: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 3609)
+++ branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 3610)
@@ -412,4 +412,5 @@
          WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
          WRITE(numout,*) '      benchmark parameter (0/1)       nn_bench   = ', nn_bench
+         WRITE(numout,*) '      timing activated    (0/1)       nn_timing  = ', nn_timing
       ENDIF
       !
Index: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/timing.F90
===================================================================
--- branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/timing.F90	(revision 3609)
+++ branches/2012/dev_NOC_2012_rev3555/NEMOGCM/NEMO/OPA_SRC/timing.F90	(revision 3610)
@@ -76,5 +76,4 @@
    LOGICAL :: ln_onefile = .TRUE. 
    LOGICAL :: lwriter
-
    !!----------------------------------------------------------------------
    !! NEMO/OPA 4.0 , NEMO Consortium (2011)
@@ -322,6 +321,6 @@
       IF( lwriter ) WRITE(numtime,*) 'Total timing (sum) :'
       IF( lwriter ) WRITE(numtime,*) '--------------------'
-      IF( lwriter ) WRITE(numtime,*) 'Elapsed Time (s)  ','CPU Time (s)'
-      IF( lwriter ) WRITE(numtime,'(5x,f12.3,2x,f12.3)')  tot_etime, tot_ctime
+      IF( lwriter ) WRITE(numtime,"('Elapsed Time (s)  CPU Time (s)')")
+      IF( lwriter ) WRITE(numtime,'(5x,f12.3,1x,f12.3)')  tot_etime, tot_ctime
       IF( lwriter ) WRITE(numtime,*) 
 #if defined key_mpp_mpi
@@ -406,13 +405,23 @@
       TYPE(timer), POINTER :: sl_timer_ave      => NULL()
       INTEGER :: icode
+      INTEGER :: ierr
       LOGICAL :: ll_ord           
       CHARACTER(len=200) :: clfmt              
                  
       ! Initialised the global strucutre   
-      ALLOCATE(sl_timer_glob_root)
-      ALLOCATE(sl_timer_glob_root%cname     (jpnij))
-      ALLOCATE(sl_timer_glob_root%tsum_cpu  (jpnij))
-      ALLOCATE(sl_timer_glob_root%tsum_clock(jpnij))
-      ALLOCATE(sl_timer_glob_root%niter     (jpnij))
+      ALLOCATE(sl_timer_glob_root, Stat=ierr)
+      IF(ierr /= 0)THEN
+         WRITE(numtime,*) 'Failed to allocate global timing structure in waver_info'
+         RETURN
+      END IF
+
+      ALLOCATE(sl_timer_glob_root%cname     (jpnij), &
+               sl_timer_glob_root%tsum_cpu  (jpnij), &
+               sl_timer_glob_root%tsum_clock(jpnij), &
+               sl_timer_glob_root%niter     (jpnij), Stat=ierr)
+      IF(ierr /= 0)THEN
+         WRITE(numtime,*) 'Failed to allocate global timing structure in waver_info'
+         RETURN
+      END IF
       sl_timer_glob_root%cname(:)       = ''
       sl_timer_glob_root%tsum_cpu(:)   = 0._wp
@@ -421,9 +430,11 @@
       sl_timer_glob_root%next => NULL()
       sl_timer_glob_root%prev => NULL()
-      ALLOCATE(sl_timer_glob)
-      ALLOCATE(sl_timer_glob%cname     (jpnij))
-      ALLOCATE(sl_timer_glob%tsum_cpu  (jpnij))
-      ALLOCATE(sl_timer_glob%tsum_clock(jpnij))
-      ALLOCATE(sl_timer_glob%niter     (jpnij))
+      !ARPDBG - don't need to allocate a pointer that's immediately then
+      !         set to point to some other object.
+      !ALLOCATE(sl_timer_glob)
+      !ALLOCATE(sl_timer_glob%cname     (jpnij))
+      !ALLOCATE(sl_timer_glob%tsum_cpu  (jpnij))
+      !ALLOCATE(sl_timer_glob%tsum_clock(jpnij))
+      !ALLOCATE(sl_timer_glob%niter     (jpnij))
       sl_timer_glob => sl_timer_glob_root
       !
@@ -451,5 +462,5 @@
          sl_timer_ave => sl_timer_ave_root            
       ENDIF 
-      
+
       ! Gather info from all processors
       s_timer => s_timer_root
@@ -467,4 +478,5 @@
                          sl_timer_glob%niter, 1, MPI_INTEGER,   &
                          0, MPI_COMM_OPA, icode)
+
          IF( narea == 1 .AND. ASSOCIATED(s_timer%next) ) THEN
             ALLOCATE(sl_timer_glob%next)
@@ -479,4 +491,6 @@
          s_timer => s_timer%next
       END DO      
+
+         WRITE(*,*) 'ARPDBG: timing: done gathers'
       
       IF( narea == 1 ) THEN    
@@ -500,7 +514,9 @@
             ENDIF
             sl_timer_glob => sl_timer_glob%next                                
-         END DO         
+         END DO
+
+         WRITE(*,*) 'ARPDBG: timing: done computing stats'
       
-         ! reorder the avearged list by CPU time      
+         ! reorder the averaged list by CPU time      
          s_wrk => NULL()
          sl_timer_ave => sl_timer_ave_root
@@ -509,30 +525,34 @@
             sl_timer_ave => sl_timer_ave_root
             DO WHILE( ASSOCIATED( sl_timer_ave%next ) )
-            IF( .NOT. ASSOCIATED(sl_timer_ave%next) ) EXIT
+
+               IF( .NOT. ASSOCIATED(sl_timer_ave%next) ) EXIT
+
                IF ( sl_timer_ave%tsum_clock < sl_timer_ave%next%tsum_clock ) THEN 
                   ALLOCATE(s_wrk)
+                  ! Copy data into the new object pointed to by s_wrk
                   s_wrk = sl_timer_ave%next
+                  ! Insert this new timer object before our current position
                   CALL insert  (sl_timer_ave, sl_timer_ave_root, s_wrk)
+                  ! Remove the old object from the list
                   CALL suppress(sl_timer_ave%next)            
                   ll_ord = .FALSE.
                   CYCLE            
                ENDIF           
-            IF( ASSOCIATED(sl_timer_ave%next) ) sl_timer_ave => sl_timer_ave%next
+               IF( ASSOCIATED(sl_timer_ave%next) ) sl_timer_ave => sl_timer_ave%next
             END DO         
-           IF( ll_ord ) EXIT
+            IF( ll_ord ) EXIT
          END DO
 
          ! write averaged info
-         WRITE(numtime,*) 'Averaged timing on all processors :'
-         WRITE(numtime,*) '-----------------------------------'
-         WRITE(numtime,*) 'Section             ',                &
-         &   'Elapsed Time (s)  ','Elapsed Time (%)  ',          &
-         &   'CPU Time(s)  ','CPU Time (%)  ','CPU/Elapsed  ',   &
-         &   'Max Elapsed (%)  ','Min elapsed (%)  ',            &           
-         &   'Frequency' 
+         WRITE(numtime,"('Averaged timing on all processors :')")
+         WRITE(numtime,"('-----------------------------------')")
+         WRITE(numtime,"('Section',13x,'Elap. Time(s)',2x,'Elap. Time(%)',2x, &
+         &   'CPU Time(s)',2x,'CPU Time(%)',2x,'CPU/Elap',1x,   &
+         &   'Max elap(%)',2x,'Min elap(%)',2x,            &           
+         &   'Freq')")
          sl_timer_ave => sl_timer_ave_root  
-         clfmt = '(1x,a,4x,f12.3,6x,f12.3,x,f12.3,2x,f12.3,6x,f7.3,5x,f12.3,5x,f12.3,2x,f9.2)'
+         clfmt = '((A),E15.7,2x,f6.2,5x,f12.2,5x,f6.2,5x,f7.2,2x,f12.2,4x,f6.2,2x,f9.2)'
          DO WHILE ( ASSOCIATED(sl_timer_ave) )
-            WRITE(numtime,TRIM(clfmt))   sl_timer_ave%cname,                            &
+            WRITE(numtime,TRIM(clfmt))   sl_timer_ave%cname(1:18),                            &
             &   sl_timer_ave%tsum_clock,sl_timer_ave%tsum_clock*100.*jpnij/tot_etime,   &
             &   sl_timer_ave%tsum_cpu  ,sl_timer_ave%tsum_cpu*100.*jpnij/tot_ctime  ,   &
@@ -712,9 +732,9 @@
       !!----------------------------------------------------------------------
       l_initdone = .TRUE. 
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'timing_reset : instrumented routines for timing'
-      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
-      CALL timing_list(s_timer_root)
-      WRITE(numout,*)
+!      IF(lwp) WRITE(numout,*)
+!      IF(lwp) WRITE(numout,*) 'timing_reset : instrumented routines for timing'
+!      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
+!      CALL timing_list(s_timer_root)
+!      WRITE(numout,*)
       !
    END SUBROUTINE timing_reset
@@ -734,5 +754,5 @@
       !!----------------------------------------------------------------------
       !!               ***  ROUTINE insert  ***
-      !! ** Purpose :   insert an element in  imer structure
+      !! ** Purpose :   insert an element in timer structure
       !!----------------------------------------------------------------------
       TYPE(timer), POINTER, INTENT(inout) :: sd_current, sd_root, sd_ptr
@@ -740,4 +760,6 @@
      
       IF( ASSOCIATED( sd_current, sd_root ) ) THEN
+         ! If our current element is the root element then
+         ! replace it with the one being inserted
          sd_root => sd_ptr
       ELSE
@@ -747,4 +769,8 @@
       sd_ptr%prev     => sd_current%prev
       sd_current%prev => sd_ptr
+      ! Nullify the pointer to the new element now that it is held
+      ! within the list. If we don't do this then a subsequent call
+      ! to ALLOCATE memory to this pointer will fail.
+      sd_ptr => NULL()
       !    
    END SUBROUTINE insert
@@ -764,4 +790,5 @@
       IF ( ASSOCIATED(sl_temp%next) ) sl_temp%next%prev => sl_temp%prev
       DEALLOCATE(sl_temp)
+      sl_temp => NULL()
       !
     END SUBROUTINE suppress
