Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 2649)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 2651)
@@ -34,6 +34,6 @@
    PRIVATE
 
-   PUBLIC   dom_msk        ! routine called by inidom.F90
-   PUBLIC   dom_msk_alloc  ! routine called by nemogcm.F90
+   PUBLIC   dom_msk         ! routine called by inidom.F90
+   PUBLIC   dom_msk_alloc   ! routine called by nemogcm.F90
 
    !                            !!* Namelist namlbc : lateral boundary condition *
@@ -51,20 +51,14 @@
 CONTAINS
    
-   FUNCTION dom_msk_alloc()
+   INTEGER FUNCTION dom_msk_alloc()
       !!---------------------------------------------------------------------
-      !!                 ***  ROUTINE dom_msk_alloc  ***
+      !!                 ***  FUNCTION dom_msk_alloc  ***
       !!---------------------------------------------------------------------
-      INTEGER :: dom_msk_alloc
-
       dom_msk_alloc = 0
-
 #if defined key_noslip_accurate
-      ALLOCATE(icoord(jpi*jpj*jpk,3), Stat=dom_msk_alloc)
+      ALLOCATE(icoord(jpi*jpj*jpk,3), STAT=dom_msk_alloc)
 #endif
-
-      IF(dom_msk_alloc /= 0)THEN
-         CALL ctl_warn('dom_msk_alloc: failed to allocate icoord array.')
-      END IF
-
+      IF( dom_msk_alloc /= 0 )   CALL ctl_warn('dom_msk_alloc: failed to allocate icoord array')
+      !
    END FUNCTION dom_msk_alloc
 
@@ -131,7 +125,7 @@
       !!               tmask_i  : interior ocean mask
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
-      USE wrk_nemo, ONLY: zwf => wrk_2d_1
-      USE wrk_nemo, ONLY: imsk => iwrk_2d_1
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
+      USE wrk_nemo, ONLY:   zwf => wrk_2d_1
+      USE wrk_nemo, ONLY:   imsk => iwrk_2d_1
       !!
       INTEGER  ::   ji, jj, jk      ! dummy loop indices
@@ -142,8 +136,7 @@
       !!---------------------------------------------------------------------
       
-      IF( wrk_in_use(2,1) .OR. iwrk_in_use(2,1) )THEN
-         CALL ctl_stop('dom_msk: ERROR: requested workspace arrays unavailable.')
-         RETURN
-      END IF
+      IF( wrk_in_use(2, 1) .OR. iwrk_in_use(2, 1) )THEN
+         CALL ctl_stop('dom_msk: ERROR: requested workspace arrays unavailable')   ;   RETURN
+      ENDIF
 
       REWIND( numnam )              ! Namelist namlbc : lateral momentum boundary condition
@@ -443,7 +436,6 @@
       ENDIF
       !
-      IF( wrk_not_released(2,1) .OR. iwrk_not_released(2,1) )THEN
-         CALL ctl_stop('dom_msk: ERROR: failed to release workspace arrays.')
-      END IF
+      IF( wrk_not_released(2, 1) .OR.   &
+         iwrk_not_released(2, 1)   )   CALL ctl_stop('dom_msk: ERROR: failed to release workspace arrays')
       !
    END SUBROUTINE dom_msk
@@ -464,14 +456,13 @@
       !! ** Action :
       !!----------------------------------------------------------------------
-      INTEGER  :: ji, jj, jk, jl      ! dummy loop indices
+      INTEGER  ::   ji, jj, jk, jl      ! dummy loop indices
       INTEGER  ::   ine, inw, ins, inn, itest, ierror, iind, ijnd
       REAL(wp) ::   zaa
       !!---------------------------------------------------------------------
-      
 
       IF(lwp)WRITE(numout,*)
       IF(lwp)WRITE(numout,*) 'dom_msk_nsa : noslip accurate boundary condition'
       IF(lwp)WRITE(numout,*) '~~~~~~~~~~~   using Schchepetkin and O Brian scheme'
-      IF( lk_mpp ) CALL ctl_stop( ' mpp version is not yet implemented' )
+      IF( lk_mpp )   CALL ctl_stop( ' mpp version is not yet implemented' )
 
       ! mask for second order calculation of vorticity
@@ -628,5 +619,5 @@
          CALL ctl_stop( 'We stop...' )
       ENDIF
-
+      !
    END SUBROUTINE dom_msk_nsa
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBS/obs_readmdt.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBS/obs_readmdt.F90	(revision 2649)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/OBS/obs_readmdt.F90	(revision 2651)
@@ -4,61 +4,42 @@
    !! Observation diagnostics: Read the MDT for SLA data (skeleton for now)
    !!======================================================================
-
-   !!----------------------------------------------------------------------
-   !!   obs_rea_mdt : Driver for reading MDT
-   !!----------------------------------------------------------------------
-
-   !! * Modules used   
-   USE par_kind, ONLY : &       ! Precision variables
-      & wp, &
-      & dp, &
-      & sp
-   USE par_oce, ONLY : &        ! Domain parameters
-      & jpi, &
-      & jpj, &
-      & jpim1
-   USE in_out_manager, ONLY : & ! I/O manager
-      & lwp,    &
-      & numout 
-   USE obs_surf_def             ! Surface observation definitions
-   USE dom_oce, ONLY : &        ! Domain variables
-      & tmask, &
-      & tmask_i, &
-      & e1t,   &
-      & e2t,   &
-      & gphit, &
-      & glamt
-   USE obs_const, ONLY : &
-      & obfillflt              ! Fillvalue
-   USE oce, ONLY : &           ! Model variables
-      & sshn
-   USE obs_inter_sup           ! Interpolation support routines
-   USE obs_inter_h2d           ! 2D interpolation
-   USE obs_utils               ! Various observation tools
-   USE lib_mpp, only: &        ! MPP routines
-      & lk_mpp, &
-      & mpp_sum
-   USE iom_nf90   
-   USE netcdf                   ! NetCDF library
-   USE lib_mpp                  ! For ctl_warn/stop
+   !! History :      ! 2007-03 (K. Mogensen) Initial skeleton version
+   !!                ! 2007-04 (E. Remy) migration and improvement from OPAVAR
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   obs_rea_mdt    : Driver for reading MDT
+   !!   obs_offset_mdt : Remove the offset between the model MDT and the used one
+   !!----------------------------------------------------------------------
+   USE par_kind         ! Precision variables
+   USE par_oce          ! Domain parameters
+   USE in_out_manager   ! I/O manager
+   USE obs_surf_def     ! Surface observation definitions
+   USE obs_inter_sup    ! Interpolation support routines
+   USE obs_inter_h2d    ! 2D interpolation
+   USE obs_utils        ! Various observation tools
+   USE iom_nf90         ! IOM NetCDF
+   USE netcdf           ! NetCDF library
+   USE lib_mpp          ! MPP library
+   USE dom_oce, ONLY : &                  ! Domain variables
+      &                    tmask, tmask_i, e1t, e2t, gphit, glamt
+   USE obs_const, ONLY :   obfillflt      ! Fillvalue
+   USE oce      , ONLY :   sshn           ! Model variables
 
    IMPLICIT NONE
-
-   !! * Routine accessibility
    PRIVATE
-
-   INTEGER, PUBLIC :: nmsshc = 1        ! MDT correction scheme
-   REAL(wp), PUBLIC :: mdtcorr = 1.61   ! User specified MDT correction
-   REAL(wp), PUBLIC :: mdtcutoff = 65.0  ! MDT cutoff for computed correction
-   PUBLIC obs_rea_mdt     ! Read the MDT
-   PUBLIC obs_offset_mdt  ! Remove the offset between the model MDT and the 
-                          ! used one
+   
+   PUBLIC   obs_rea_mdt     ! called by ?
+   PUBLIC   obs_offset_mdt  ! called by ?
+
+   INTEGER , PUBLIC ::   nmsshc    = 1         ! MDT correction scheme
+   REAL(wp), PUBLIC ::   mdtcorr   = 1.61_wp   ! User specified MDT correction
+   REAL(wp), PUBLIC ::   mdtcutoff = 65.0_wp   ! MDT cutoff for computed correction
 
    !!----------------------------------------------------------------------
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -73,85 +54,45 @@
       !!
       !! ** Action  : 
-      !!
-      !! References :
-      !!
-      !! History :  
-      !!      ! :  2007-03 (K. Mogensen) Initial skeleton version
-      !!      ! :  2007-04 (E. Remy) migration and improvement from OPAVAR
-      !!----------------------------------------------------------------------
-      !! * Modules used
+      !!----------------------------------------------------------------------
       USE iom
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: z_mdt => wrk_2d_1,  &  ! Array to store the MDT values
-                        mdtmask => wrk_2d_2    ! Array to store the mask for the MDT
-      !!
-      !! * Arguments
-      INTEGER, INTENT(IN) :: kslano          ! Number of SLA Products
-      TYPE(obs_surf), DIMENSION(kslano), INTENT(INOUT) :: &
-         & sladata       ! SLA data
-      INTEGER, INTENT(IN) :: k2dint
-
-      !! * Local declarations
-
-      CHARACTER(LEN=12), PARAMETER :: &
-         & cpname = 'obs_rea_mdt'
-      CHARACTER(LEN=20), PARAMETER :: &
-         & mdtname = 'slaReferenceLevel.nc'
-
-      INTEGER :: jslano      ! Data set loop variable
-      INTEGER :: jobs        ! Obs loop variable
-      INTEGER :: jpimdt      ! Number of grid point in latitude for the MDT
-      INTEGER :: jpjmdt      ! Number of grid point in longitude for the MDT
-      INTEGER :: iico        ! Grid point indicies
-      INTEGER :: ijco 
-      INTEGER :: i_nx_id     ! Index to read the NetCDF file
-      INTEGER :: i_ny_id     ! 
-      INTEGER :: i_file_id   ! 
-      INTEGER :: i_var_id
-      INTEGER :: i_stat
-
-      REAL(wp), DIMENSION(1) :: &
-         & zext, &
-         & zobsmask
-      REAL(wp), DIMENSION(2,2,1) :: &
-         & zweig
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: &
-         & zmask, &
-         & zmdtl, &
-         & zglam, &
-         & zgphi
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   z_mdt   => wrk_2d_1   ! Array to store the MDT values
+      USE wrk_nemo, ONLY:   mdtmask => wrk_2d_2   ! Array to store the mask for the MDT
+      !
+      INTEGER                          , INTENT(IN)    ::   kslano    ! Number of SLA Products
+      TYPE(obs_surf), DIMENSION(kslano), INTENT(inout) ::   sladata   ! SLA data
+      INTEGER                          , INTENT(in)    ::   k2dint    ! ?
+      !
+      CHARACTER(LEN=12), PARAMETER ::   cpname  = 'obs_rea_mdt'
+      CHARACTER(LEN=20), PARAMETER ::   mdtname = 'slaReferenceLevel.nc'
+
+      INTEGER ::   jslano              ! Data set loop variable
+      INTEGER ::   jobs                ! Obs loop variable
+      INTEGER ::   jpimdt, jpjmdt      ! Number of grid point in lat/lon for the MDT
+      INTEGER ::   iico, ijco          ! Grid point indicies
+      INTEGER ::   i_nx_id, i_ny_id, i_file_id, i_var_id, i_stat
+      INTEGER ::   nummdt
+      !
+      REAL(wp), DIMENSION(1)     ::   zext, zobsmask
+      REAL(wp), DIMENSION(2,2,1) ::   zweig
+      !
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   zmask, zmdtl, zglam, zgphi
+      INTEGER , DIMENSION(:,:,:), ALLOCATABLE ::   igrdi, igrdj
          
-      REAL(wp) :: zlam
-      REAL(wp) :: zphi
-      REAL(wp) :: zfill
-      REAL(sp) :: zinfill
-      INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: &
-         & igrdi, &
-         & igrdj
-      INTEGER :: nummdt
-      !!----------------------------------------------------------------------
-
-      IF(wrk_in_use(2, 1,2))THEN
-         CALL ctl_stop('obs_rea_mdt : requested workspace array unavailable.')
-         RETURN
-      END IF
+      REAL(wp) :: zlam, zphi, zfill, zinfill    ! local scalar
+      !!----------------------------------------------------------------------
+
+      IF( wrk_in_use(2, 1,2) ) THEN
+         CALL ctl_stop('obs_rea_mdt : requested workspace array unavailable')   ;   RETURN
+      ENDIF
 
       IF(lwp)WRITE(numout,*) 
-      IF(lwp)WRITE(numout,*) ' obs_rea_mdt : '
+      IF(lwp)WRITE(numout,*) ' obs_rea_mdt : Read MDT for referencing altimeter anomalies'
       IF(lwp)WRITE(numout,*) ' ------------- '
-      IF(lwp)WRITE(numout,*) '   Read MDT for referencing altimeter', &
-         &                   '   anomalies'
-
-      ! Open the file
-      
-      CALL iom_open( mdtname, nummdt )
-      
-      ! Get the MDT data
-
-      CALL iom_get( nummdt, jpdom_data, 'sossheig', z_mdt(:,:), 1 )
-
-      ! Close the file
-
-      CALL iom_close(nummdt)     
+
+      CALL iom_open( mdtname, nummdt )       ! Open the file
+      !                                      ! Get the MDT data
+      CALL iom_get ( nummdt, jpdom_data, 'sossheig', z_mdt(:,:), 1 )
+      CALL iom_close(nummdt)                 ! Close the file
       
       ! Read in the fill value
@@ -163,21 +104,16 @@
       i_stat = nf90_close( nummdt )
 
-! setup mask based on tmask and MDT mask
-! set mask to 0 where the MDT is set to fillvalue
-
-      WHERE(z_mdt(:,:) /= zfill)
-         mdtmask(:,:)=tmask(:,:,1)
-      ELSEWHERE
-         mdtmask(:,:)=0
+      ! setup mask based on tmask and MDT mask
+      ! set mask to 0 where the MDT is set to fillvalue
+      WHERE(z_mdt(:,:) /= zfill)   ;   mdtmask(:,:) = tmask(:,:,1)
+      ELSE WHERE                   ;   mdtmask(:,:) = 0
       END WHERE
 
       ! Remove the offset between the MDT used with the sla and the model MDT
-
-      IF ( nmsshc == 1 .OR. nmsshc == 2 ) CALL obs_offset_mdt( z_mdt, zfill )
+      IF( nmsshc == 1 .OR. nmsshc == 2 )   CALL obs_offset_mdt( z_mdt, zfill )
 
       ! Intepolate the MDT already on the model grid at the observation point
   
       DO jslano = 1, kslano
-
          ALLOCATE( &
             & igrdi(2,2,sladata(jslano)%nsurf), &
@@ -202,12 +138,8 @@
          END DO
 
-         CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, &
-            &                  igrdi, igrdj, glamt, zglam )
-         CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, &
-            &                  igrdi, igrdj, gphit, zgphi )
-         CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, &
-            &                  igrdi, igrdj, mdtmask, zmask )
-         CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, &
-            &                  igrdi, igrdj, z_mdt, zmdtl )
+         CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, igrdi, igrdj, glamt  , zglam )
+         CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, igrdi, igrdj, gphit  , zgphi )
+         CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, igrdi, igrdj, mdtmask, zmask )
+         CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, igrdi, igrdj, z_mdt  , zmdtl )
 
          DO jobs = 1, sladata(jslano)%nsurf
@@ -220,11 +152,10 @@
                &                   zmask(:,:,jobs), zweig, zobsmask )
             
-            CALL obs_int_h2d( 1, 1,      &
-                   &              zweig, zmdtl(:,:,jobs),  zext )
+            CALL obs_int_h2d( 1, 1, zweig, zmdtl(:,:,jobs),  zext )
  
             sladata(jslano)%rext(jobs,2) = zext(1)
 
 ! mark any masked data with a QC flag
-            IF ( zobsmask(1) == 0 ) sladata(jslano)%nqc(jobs) = 11
+            IF( zobsmask(1) == 0 )   sladata(jslano)%nqc(jobs) = 11
 
          END DO
@@ -241,12 +172,10 @@
       END DO
 
-      IF(wrk_not_released(2, 1,2))THEN
-         CALL ctl_stop('obs_rea_mdt : failed to release workspace arrays.')
-      END IF
-
+      IF( wrk_not_released(2, 1,2) )   CALL ctl_stop('obs_rea_mdt: failed to release workspace arrays')
+      !
    END SUBROUTINE obs_rea_mdt
 
+
    SUBROUTINE obs_offset_mdt( mdt, zfill )
-
       !!---------------------------------------------------------------------
       !!
@@ -260,37 +189,19 @@
       !!
       !! ** Action  : 
-      !!
-      !! References :
-      !!
-      !! History :  
-      !!      ! :  2007-04 (E. Remy) migration from OPAVAR
-      !!----------------------------------------------------------------------
-      !! * Modules used
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, ONLY: zpromsk => wrk_2d_3
-      !!
-      !! * Arguments
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(INOUT) :: &
-         & mdt           ! MDT used on the model grid
-      REAL(wp), INTENT(IN) :: zfill 
-
-      !! * Local declarations 
-      REAL(wp) :: zdxdy
-      REAL(wp) :: zarea
-      REAL(wp) :: zeta1
-      REAL(wp) :: zeta2
-      REAL(wp) :: zcorr_mdt  
-      REAL(wp) :: zcorr_bcketa
-      REAL(wp) :: zcorr
-      INTEGER :: jj
-      INTEGER :: ji
-      CHARACTER(LEN=14), PARAMETER :: &
-         & cpname = 'obs_offset_mdt'
-      !!----------------------------------------------------------------------
-
-      IF(wrk_in_use(2, 3))THEN
-         CALL ctl_stop('obs_offset_mdt : requested workspace array unavailable.')
-         RETURN
-      END IF
+      !!----------------------------------------------------------------------
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zpromsk => wrk_2d_3
+      !
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   mdt     ! MDT used on the model grid
+      REAL(wp)                    , INTENT(in   ) ::   zfill 
+      ! 
+      INTEGER  :: ji, jj
+      REAL(wp) :: zdxdy, zarea, zeta1, zeta2, zcorr_mdt, zcorr_bcketa, zcorr     ! local scalar
+      CHARACTER(LEN=14), PARAMETER ::   cpname = 'obs_offset_mdt'
+      !!----------------------------------------------------------------------
+
+      IF( wrk_in_use(2, 3) ) THEN
+         CALL ctl_stop('obs_offset_mdt: requested workspace array unavailable')   ;   RETURN
+      ENDIF
 
       !  Initialize the local mask, for domain projection 
@@ -322,10 +233,10 @@
       END DO
 
-      IF( lk_mpp) CALL mpp_sum( zeta1 )
-      IF( lk_mpp) CALL mpp_sum( zeta2 )
-      IF( lk_mpp) CALL mpp_sum( zarea )
+      IF( lk_mpp)   CALL mpp_sum( zeta1 )
+      IF( lk_mpp)   CALL mpp_sum( zeta2 )
+      IF( lk_mpp)   CALL mpp_sum( zarea )
       
-      zcorr_mdt = zeta1 / zarea
-      zcorr_bcketa  = zeta2 / zarea
+      zcorr_mdt    = zeta1 / zarea
+      zcorr_bcketa = zeta2 / zarea
 
       !  Define correction term
@@ -335,9 +246,9 @@
       !  Correct spatial mean of the MSSH
 
-      IF ( nmsshc == 1 ) mdt(:,:) = mdt(:,:) - zcorr  
+      IF( nmsshc == 1 )   mdt(:,:) = mdt(:,:) - zcorr  
 
       ! User defined value : 1.6 m for the Rio MDT compared to ORCA2 MDT
 
-      IF ( nmsshc == 2 ) mdt(:,:) = mdt(:,:) - mdtcorr
+      IF( nmsshc == 2 )   mdt(:,:) = mdt(:,:) - mdtcorr
 
       IF(lwp) THEN
@@ -348,20 +259,14 @@
          WRITE(numout,*) '               zcorr         = ', zcorr
          WRITE(numout,*) '               nmsshc        = ', nmsshc
-         WRITE(numout,*) 
       ENDIF
 
-      IF ( nmsshc == 0 ) WRITE(numout,*) &
-         &                 '           MSSH correction is not applied'
-      IF ( nmsshc == 1 ) WRITE(numout,*) &
-         &                 '           MSSH correction is applied'
-      IF ( nmsshc == 2 ) WRITE(numout,*) &
-         &                 '           User defined MSSH correction' 
-
-
-      IF(wrk_not_released(2, 3))THEN
-         CALL ctl_stop('obs_offset_mdt : failed to release workspace array.')
-      END IF
-
+      IF ( nmsshc == 0 ) WRITE(numout,*) '           MSSH correction is not applied'
+      IF ( nmsshc == 1 ) WRITE(numout,*) '           MSSH correction is applied'
+      IF ( nmsshc == 2 ) WRITE(numout,*) '           User defined MSSH correction' 
+
+      IF( wrk_not_released(2, 3) )   CALL ctl_stop('obs_offset_mdt: failed to release workspace array')
+      !
    END SUBROUTINE obs_offset_mdt
  
+   !!======================================================================
 END MODULE obs_readmdt
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 2649)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 2651)
@@ -502,11 +502,10 @@
       !! ** Method  :
       !!----------------------------------------------------------------------
-      USE par_oce
       INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have
-      ! Local variables
+      !
       INTEGER, PARAMETER :: nfactmax = 20
       INTEGER :: nfact ! The no. of factors returned
       INTEGER :: ierr  ! Error flag
-      INTEGER :: i
+      INTEGER :: ji
       INTEGER :: idiff, mindiff, imin ! For choosing pair of factors that are closest in value
       INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors
@@ -526,10 +525,10 @@
          mindiff = 1000000
          imin    = 1
-         DO i=1,nfact-1,2
-            idiff = ABS(ifact(i) - ifact(i+1))
-            IF(idiff < mindiff)THEN
+         DO ji = 1, nfact-1, 2
+            idiff = ABS( ifact(ji) - ifact(ji+1) )
+            IF( idiff < mindiff ) THEN
                mindiff = idiff
-               imin = i
-            END IF
+               imin = ji
+            ENDIF
          END DO
          jpnj = ifact(imin)
@@ -543,63 +542,62 @@
 
 
-   SUBROUTINE factorise( ifax, maxfax, nfax, n, ierr )
+   SUBROUTINE factorise( kfax, kmaxfax, knfax, kn, kerr )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE factorise  ***
       !!
       !! ** Purpose :   return the prime factors of n.
-      !!                nfax factors are returned in array ifax which is of 
-      !!                maximum dimension maxfax.
+      !!                knfax factors are returned in array kfax which is of 
+      !!                maximum dimension kmaxfax.
       !! ** Method  :
       !!----------------------------------------------------------------------
-      INTEGER, INTENT(in)  :: n, maxfax
-      INTEGER, INTENT(Out) :: ierr, nfax
-      INTEGER, INTENT(out) :: ifax(maxfax)
-      ! Local variables.
-      INTEGER :: i, ifac, l, nu
+      INTEGER                    , INTENT(in   ) ::   kn, kmaxfax
+      INTEGER                    , INTENT(  out) ::   kerr, knfax
+      INTEGER, DIMENSION(kmaxfax), INTENT(  out) ::   kfax
+      !
+      INTEGER :: ifac, jl, inu
       INTEGER, PARAMETER :: ntest = 14
-      INTEGER :: lfax(ntest)
+      INTEGER :: ilfax(ntest)
 
       ! lfax contains the set of allowed factors.
-      data (lfax(i),i=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256,  &
-         &                         128,   64,   32,   16,    8,   4,   2  /
+      data (ilfax(jl),jl=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256,  &
+         &                            128,   64,   32,   16,    8,   4,   2  /
       !!----------------------------------------------------------------------
 
       ! Clear the error flag and initialise output vars
-      ierr = 0
-      ifax = 1
-      nfax = 0
+      kerr = 0
+      kfax = 1
+      knfax = 0
 
       ! Find the factors of n.
-      IF( n == 1 ) GOTO 20
+      IF( kn == 1 )   GOTO 20
 
       ! nu holds the unfactorised part of the number.
-      ! nfax holds the number of factors found.
+      ! knfax holds the number of factors found.
       ! l points to the allowed factor list.
       ! ifac holds the current factor.
 
-      nu   = n
-      nfax = 0
-
-      DO l = ntest, 1, -1
+      inu   = kn
+      knfax = 0
+
+      DO jl = ntest, 1, -1
          !
-         ifac = lfax(l)
-         IF(ifac > nu)CYCLE
+         ifac = ilfax(jl)
+         IF( ifac > inu )   CYCLE
 
          ! Test whether the factor will divide.
 
-         IF( MOD(nu,ifac) == 0 ) THEN
+         IF( MOD(inu,ifac) == 0 ) THEN
             !
-            nfax = nfax+1            ! Add the factor to the list
-            IF( nfax > maxfax ) THEN
-               ierr = 6
-               write (*,*) 'FACTOR: insufficient space in factor array ',nfax
+            knfax = knfax + 1            ! Add the factor to the list
+            IF( knfax > kmaxfax ) THEN
+               kerr = 6
+               write (*,*) 'FACTOR: insufficient space in factor array ', knfax
                return
             ENDIF
-            ifax(nfax) = ifac
+            kfax(knfax) = ifac
             ! Store the other factor that goes with this one
-            nfax = nfax + 1
-            ifax(nfax) = nu / ifac
-            !WRITE (*,*) 'ARPDBG, factors ',nfax-1,' & ',nfax,' are ', &
-            !            ifax(nfax-1),' and ',ifax(nfax)
+            knfax = knfax + 1
+            kfax(knfax) = inu / ifac
+            !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax)
          ENDIF
          !
@@ -608,6 +606,4 @@
    20 CONTINUE      ! Label 20 is the exit point from the factor search loop.
       !
-      RETURN
-      !
    END SUBROUTINE factorise
 
Index: branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90
===================================================================
--- branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 2649)
+++ branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 2651)
@@ -57,7 +57,7 @@
       !!
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
-      USE wrk_nemo, zemps  => wrk_2d_1
-      USE wrk_nemo, ztrtrd => wrk_3d_1
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
+      USE wrk_nemo, ONLY:   zemps  => wrk_2d_1
+      USE wrk_nemo, ONLY:   ztrtrd => wrk_3d_1
       !
       INTEGER, INTENT( in ) ::   kt          ! ocean time-step index
