Index: /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/wrk_nemo.F90
===================================================================
--- /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/wrk_nemo.F90	(revision 2597)
+++ /branches/dev_r2586_dynamic_mem/NEMOGCM/NEMO/OPA_SRC/wrk_nemo.F90	(revision 2598)
@@ -17,23 +17,22 @@
    PUBLIC wrk_release, llwrk_release, iwrk_release, wrk_release_xz
 
-   INTEGER, PARAMETER :: num_1d_wrkspaces  = 27 ! No. of 1D workspace arrays ( MAX(jpi*jpj,jpi*jpk,jpj*jpk) )
-   INTEGER, PARAMETER :: num_2d_wrkspaces  = 35 ! No. of 2D workspace arrays (jpi,jpj)
-   INTEGER, PARAMETER :: num_3d_wrkspaces  = 15 ! No. of 3D workspace arrays (jpi,jpj,jpk)
-   INTEGER, PARAMETER :: num_4d_wrkspaces  = 4 ! No. of 4D workspace arrays (jpi,jpj,jpk,jpts)
-
-   INTEGER, PARAMETER :: num_xz_wrkspaces  = 4 ! No. of 2D, xz workspace arrays (jpi,jpk)
-
-   INTEGER, PARAMETER :: num_1d_lwrkspaces = 0 ! No. of 1D logical workspace arrays
-   INTEGER, PARAMETER :: num_2d_lwrkspaces = 3 ! No. of 2D logical workspace arrays
-   INTEGER, PARAMETER :: num_3d_lwrkspaces = 1 ! No. of 3D logical workspace arrays
-   INTEGER, PARAMETER :: num_4d_lwrkspaces = 0 ! No. of 4D logical workspace arrays
-
-   INTEGER, PARAMETER :: num_1d_iwrkspaces = 0 ! No. of 1D integer workspace arrays
-   INTEGER, PARAMETER :: num_2d_iwrkspaces = 1 ! No. of 2D integer workspace arrays
-   INTEGER, PARAMETER :: num_3d_iwrkspaces = 0 ! No. of 3D integer workspace arrays
-   INTEGER, PARAMETER :: num_4d_iwrkspaces = 0 ! No. of 4D integer workspace arrays
+   INTEGER, PARAMETER :: num_1d_wrkspaces  = 27   ! No. of 1D workspace arrays ( MAX(jpi*jpj,jpi*jpk,jpj*jpk) )
+   INTEGER, PARAMETER :: num_2d_wrkspaces  = 35   ! No. of 2D workspace arrays (jpi,jpj)
+   INTEGER, PARAMETER :: num_3d_wrkspaces  = 15   ! No. of 3D workspace arrays (jpi,jpj,jpk)
+   INTEGER, PARAMETER :: num_4d_wrkspaces  = 4   ! No. of 4D workspace arrays (jpi,jpj,jpk,jpts)
+
+   INTEGER, PARAMETER :: num_xz_wrkspaces  = 4   ! No. of 2D, xz workspace arrays (jpi,jpk)
+
+   INTEGER, PARAMETER :: num_1d_lwrkspaces = 0   ! No. of 1D logical workspace arrays
+   INTEGER, PARAMETER :: num_2d_lwrkspaces = 3   ! No. of 2D logical workspace arrays
+   INTEGER, PARAMETER :: num_3d_lwrkspaces = 1   ! No. of 3D logical workspace arrays
+   INTEGER, PARAMETER :: num_4d_lwrkspaces = 0   ! No. of 4D logical workspace arrays
+
+   INTEGER, PARAMETER :: num_1d_iwrkspaces = 0   ! No. of 1D integer workspace arrays
+   INTEGER, PARAMETER :: num_2d_iwrkspaces = 1   ! No. of 2D integer workspace arrays
+   INTEGER, PARAMETER :: num_3d_iwrkspaces = 0   ! No. of 3D integer workspace arrays
+   INTEGER, PARAMETER :: num_4d_iwrkspaces = 0   ! No. of 4D integer workspace arrays
    ! Maximum no. of workspaces of any one dimensionality that can be
-   ! requested - MAX(num_1d_wrkspaces, num_2d_wrkspaces, num_3d_wrkspaces,
-   ! num_4d_wrkspaces) 
+   ! requested - MAX(num_1d_wrkspaces, num_2d_wrkspaces, num_3d_wrkspaces, num_4d_wrkspaces) 
    INTEGER, PARAMETER :: max_num_wrkspaces = 35
 
@@ -41,90 +40,45 @@
    ! num_Xd_wrkspaces parameter above and to allocate them in wrk_alloc()
 
-   ! 1D, REAL(wp) workspaces
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_1,  wrk_1d_2
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_3,  wrk_1d_4
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_5,  wrk_1d_6 
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_7,  wrk_1d_8
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_9,  wrk_1d_10
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_11, wrk_1d_12
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_13, wrk_1d_14
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_15, wrk_1d_16
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_17, wrk_1d_18
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_19, wrk_1d_20
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_21, wrk_1d_22
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_23, wrk_1d_24
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_25, wrk_1d_26
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:), TARGET, PUBLIC :: wrk_1d_27
-
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_1 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_2 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_3 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_4 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_5 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_6 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_7 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_8 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_9 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_10 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_11 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_12 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_13 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_14 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_15 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_16 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_17 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_18 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_19 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_20 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_21 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_22 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_23 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_24 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_25 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_26 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_27 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_28 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_29 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_30 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_31 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_32 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_33 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_34 !: 2D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET, PUBLIC :: wrk_2d_35 !: 2D real workspace
-
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_1   !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_2   !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_3   !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_4   !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_5   !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_6   !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_7   !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_8   !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_9   !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_10  !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_11  !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_12  !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_13  !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_14  !: 3D real workspace
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC ::  wrk_3d_15  !: 3D real workspace
-
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:), PUBLIC :: wrk_4d_1, wrk_4d_2, wrk_4d_3, wrk_4d_4   !: 4D real workspace
-
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), PUBLIC :: wrk_xz_1, wrk_xz_2, wrk_xz_3, wrk_xz_4 !: 2D, x-z workspaces
-
-   LOGICAL,  ALLOCATABLE, SAVE, DIMENSION(:,:)    , PUBLIC :: llwrk_2d_1, llwrk_2d_2, llwrk_2d_3 !: 2D logical workspace
-   LOGICAL,  ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET, PUBLIC :: llwrk_3d_1 !: 3D logical workspace
-
-   INTEGER,  ALLOCATABLE, SAVE, DIMENSION(:,:)    , PUBLIC :: iwrk_2d_1 !: 2D integer workspace
-
-
-   LOGICAL, DIMENSION(num_1d_wrkspaces)  :: in_use_1d   !: Flags to track which 1D workspace arrays are in use  
-   LOGICAL, DIMENSION(num_2d_wrkspaces)  :: in_use_2d   !: Flags to track which 2D workspace arrays are in use
-   LOGICAL, DIMENSION(num_3d_wrkspaces)  :: in_use_3d   !: Flags to track which 3D workspace arrays are in use
-   LOGICAL, DIMENSION(num_4d_wrkspaces)  :: in_use_4d   !: Flags to track which 4D workspace arrays are in use
-   LOGICAL, DIMENSION(num_xz_wrkspaces)  :: in_use_xz   !: Flags to track which 2D, xz workspace arrays are in use
-   LOGICAL, DIMENSION(num_2d_lwrkspaces) :: in_use_2dll !: Flags to track which 2D, logical workspace arrays are in use
-   LOGICAL, DIMENSION(num_3d_lwrkspaces) :: in_use_3dll !: Flags to track which 3D, logical workspace arrays are in use
-   LOGICAL, DIMENSION(num_2d_iwrkspaces) :: in_use_2di  !: Flags to track which 2D, integer workspace arrays are in use
+   !                                                                    !!**  1D, REAL(wp) workspaces  **
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)      , TARGET, PUBLIC ::   wrk_1d_1 , wrk_1d_2 , wrk_1d_3 , wrk_1d_4 , wrk_1d_5
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)      , TARGET, PUBLIC ::   wrk_1d_6 , wrk_1d_7 , wrk_1d_8 , wrk_1d_9 , wrk_1d_10
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)      , TARGET, PUBLIC ::   wrk_1d_11, wrk_1d_12, wrk_1d_13, wrk_1d_14, wrk_1d_15
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)      , TARGET, PUBLIC ::   wrk_1d_16, wrk_1d_17, wrk_1d_18, wrk_1d_19, wrk_1d_20
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)      , TARGET, PUBLIC ::   wrk_1d_21, wrk_1d_22, wrk_1d_23, wrk_1d_24, wrk_1d_25
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)      , TARGET, PUBLIC ::   wrk_1d_26, wrk_1d_27
+
+   !                                                                    !!**  2D, x-y, REAL(wp) workspaces  **
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)    , TARGET, PUBLIC ::   wrk_2d_1 , wrk_2d_2 , wrk_2d_3 , wrk_2d_4 , wrk_2d_5
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)    , TARGET, PUBLIC ::   wrk_2d_6 , wrk_2d_7 , wrk_2d_8 , wrk_2d_9 , wrk_2d_10
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)    , TARGET, PUBLIC ::   wrk_2d_11, wrk_2d_12, wrk_2d_13, wrk_2d_14, wrk_2d_15
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)    , TARGET, PUBLIC ::   wrk_2d_16, wrk_2d_17, wrk_2d_18, wrk_2d_19, wrk_2d_20
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)    , TARGET, PUBLIC ::   wrk_2d_21, wrk_2d_22, wrk_2d_23, wrk_2d_24, wrk_2d_25
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)    , TARGET, PUBLIC ::   wrk_2d_26, wrk_2d_27, wrk_2d_28, wrk_2d_29, wrk_2d_30
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)    , TARGET, PUBLIC ::   wrk_2d_31, wrk_2d_32, wrk_2d_33, wrk_2d_34, wrk_2d_35
+
+   !                                                                    !!**  2D, x-z, REAL(wp) workspaces  **
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)            , PUBLIC ::   wrk_xz_1, wrk_xz_2, wrk_xz_3, wrk_xz_4 
+   
+   !                                                                    !!**  3D, x-y-z, REAL(wp) workspaces  **
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  , TARGET, PUBLIC ::   wrk_3d_1 , wrk_3d_2 , wrk_3d_3 , wrk_3d_4 , wrk_3d_5
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  , TARGET, PUBLIC ::   wrk_3d_6 , wrk_3d_7 , wrk_3d_8 , wrk_3d_9 , wrk_3d_10
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)  , TARGET, PUBLIC ::   wrk_3d_11, wrk_3d_12, wrk_3d_13, wrk_3d_14, wrk_3d_15
+
+   !                                                                    !!**  4D, x-y-z-tra, REAL(wp) workspaces  **
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:), TARGET, PUBLIC ::   wrk_4d_1, wrk_4d_2, wrk_4d_3, wrk_4d_4 
+
+
+   LOGICAL , ALLOCATABLE, SAVE, DIMENSION(:,:)            , PUBLIC ::   llwrk_2d_1, llwrk_2d_2, llwrk_2d_3 !: 2D logical workspace
+   LOGICAL , ALLOCATABLE, SAVE, DIMENSION(:,:,:)  , TARGET, PUBLIC ::   llwrk_3d_1 !: 3D logical workspace
+   INTEGER , ALLOCATABLE, SAVE, DIMENSION(:,:)            , PUBLIC ::   iwrk_2d_1 !: 2D integer workspace
+
+   LOGICAL, DIMENSION(num_1d_wrkspaces)  :: in_use_1d     !: Flags to track which 1D workspace arrays are in use  
+   LOGICAL, DIMENSION(num_2d_wrkspaces)  :: in_use_2d     !: Flags to track which 2D workspace arrays are in use
+   LOGICAL, DIMENSION(num_3d_wrkspaces)  :: in_use_3d     !: Flags to track which 3D workspace arrays are in use
+   LOGICAL, DIMENSION(num_4d_wrkspaces)  :: in_use_4d     !: Flags to track which 4D workspace arrays are in use
+   LOGICAL, DIMENSION(num_xz_wrkspaces)  :: in_use_xz     !: Flags to track which 2D, xz workspace arrays are in use
+   LOGICAL, DIMENSION(num_2d_lwrkspaces) :: in_use_2dll   !: Flags to track which 2D, logical workspace arrays are in use
+   LOGICAL, DIMENSION(num_3d_lwrkspaces) :: in_use_3dll   !: Flags to track which 3D, logical workspace arrays are in use
+   LOGICAL, DIMENSION(num_2d_iwrkspaces) :: in_use_2di    !: Flags to track which 2D, integer workspace arrays are in use
 
    ! Labels for specifying workspace type in call to print_in_use_list()
@@ -134,5 +88,5 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2010)
+   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -140,8 +94,7 @@
 CONTAINS
 
-
   FUNCTION wrk_alloc()
       !!----------------------------------------------------------------------
-      !!                   ***  ROUTINE wrk_alloc  ***
+      !!                   ***  FUNCTION wrk_alloc  ***
       !!
       !! ** Purpose :   Define in memory once for all the NEMO 2D, 3D and 4d 
@@ -153,247 +106,193 @@
       !!----------------------------------------------------------------------
       !
-      ! Extent to use for 1D work arrays - find the maximum product of
-      ! jpi*jpj, jpi*jpk and jpj*jpk and use that
-      IF(jpi < jpj .AND. jpi < jpk)THEN
-         extent_1d = jpj*jpk
-      ELSE IF(jpj < jpi .AND. jpj < jpk)THEN
-         extent_1d = jpi*jpk
-      ELSE
-         extent_1d = jpi*jpj
+      ! Extent to use for 1D work arrays - find the maximum product of jpi*jpj, jpi*jpk and jpj*jpk and use that
+      IF    ( jpi < jpj .AND. jpi < jpk ) THEN   ;   extent_1d = jpj*jpk
+      ELSEIF( jpj < jpi .AND. jpj < jpk ) THEN   ;   extent_1d = jpi*jpk
+      ELSE                                       ;   extent_1d = jpi*jpj
       END IF
       !
       ! Initialise the 'in use' flags for each work-space array
-      in_use_1d(:) = .FALSE.
-
-      in_use_2d(:) = .FALSE.
-
-      in_use_3d(:) = .FALSE.
-
-      in_use_4d(:) = .FALSE.
-
-      in_use_xz(:) = .FALSE.
-
+      in_use_1d  (:) = .FALSE.
+      in_use_2d  (:) = .FALSE.
+      in_use_3d  (:) = .FALSE.
+      in_use_4d  (:) = .FALSE.
+      in_use_xz  (:) = .FALSE.
       in_use_2dll(:) = .FALSE.
-
       in_use_3dll(:) = .FALSE.
-
-      in_use_2di(:) = .FALSE.
-
+      in_use_2di (:) = .FALSE.
+      
       ierror(:) = 0
 
-      ALLOCATE(wrk_1d_1(extent_1d)        , wrk_1d_2(extent_1d)       ,  &
-               wrk_1d_3(extent_1d)        , wrk_1d_4(extent_1d)       ,  &
-               wrk_1d_5(extent_1d)        , wrk_1d_6(extent_1d)       ,  &
-               wrk_1d_7(extent_1d)        , wrk_1d_8(extent_1d)       ,  &
-               wrk_1d_9(extent_1d)        , wrk_1d_10(extent_1d)      ,  &
-               wrk_1d_11(extent_1d)       , wrk_1d_12(extent_1d)      ,  &
-               wrk_1d_13(extent_1d)       , wrk_1d_14(extent_1d)      ,  &
-               wrk_1d_15(extent_1d)       , wrk_1d_16(extent_1d)      ,  &
-               wrk_1d_17(extent_1d)       , wrk_1d_18(extent_1d)      ,  &
-               wrk_1d_19(extent_1d)       , wrk_1d_20(extent_1d)      ,  &
-               wrk_1d_21(extent_1d)       , wrk_1d_22(extent_1d)      ,  &
-               wrk_1d_23(extent_1d)       , wrk_1d_24(extent_1d)      ,  &
-               wrk_1d_25(extent_1d)       , wrk_1d_26(extent_1d)      ,  &
-               wrk_1d_27(extent_1d)       , Stat=ierror(1))
-      !
-      ALLOCATE(wrk_2d_1(jpi,jpj)          , wrk_2d_2(jpi,jpj)         ,  &
-               wrk_2d_3(jpi,jpj)          , wrk_2d_4(jpi,jpj)         ,  & 
-               wrk_2d_5(jpi,jpj)          , wrk_2d_6(jpi,jpj)         ,  &
-               wrk_2d_7(jpi,jpj)          , wrk_2d_8(jpi,jpj)         ,  &
-               wrk_2d_9(jpi,jpj)          , wrk_2d_10(jpi,jpj)        ,  &
-               wrk_2d_11(jpi,jpj)         , wrk_2d_12(jpi,jpj)        ,  &
-               wrk_2d_13(jpi,jpj)         , wrk_2d_14(jpi,jpj)        ,  &
-               wrk_2d_15(jpi,jpj)         , wrk_2d_16(jpi,jpj)        ,  &
-               wrk_2d_17(jpi,jpj)         , wrk_2d_18(jpi,jpj)        ,  &
-               wrk_2d_19(jpi,jpj)         , wrk_2d_20(jpi,jpj)        ,  &
-               wrk_2d_21(jpi,jpj)         , wrk_2d_22(jpi,jpj)        ,  &
-               wrk_2d_23(jpi,jpj)         , wrk_2d_24(jpi,jpj)        ,  &
-               wrk_2d_25(jpi,jpj)         , wrk_2d_26(jpi,jpj)        ,  &
-               wrk_2d_27(jpi,jpj)         , wrk_2d_28(jpi,jpj)        ,  &
-               wrk_2d_29(jpi,jpj)         , wrk_2d_30(jpi,jpj)        ,  &
-               wrk_2d_31(jpi,jpj)         , wrk_2d_32(jpi,jpj)        ,  &
-               wrk_2d_33(jpi,jpj)         , wrk_2d_34(jpi,jpj)        ,  &
-               wrk_2d_35(jpi,jpj)         , Stat=ierror(2))
-      !
-      ALLOCATE(wrk_3d_1(jpi,jpj,jpk)      , wrk_3d_2(jpi,jpj,jpk)     ,  &
-               wrk_3d_3(jpi,jpj,jpk)      , wrk_3d_4(jpi,jpj,jpk)     ,  &
-               wrk_3d_5(jpi,jpj,jpk)      , wrk_3d_6(jpi,jpj,jpk)     ,  &
-               wrk_3d_7(jpi,jpj,jpk)      , wrk_3d_8(jpi,jpj,jpk)     ,  &
-               wrk_3d_9(jpi,jpj,jpk)      , wrk_3d_10(jpi,jpj,jpk)    ,  & 
-               wrk_3d_11(jpi,jpj,jpk)     , wrk_3d_12(jpi,jpj,jpk)    ,  & 
-               wrk_3d_13(jpi,jpj,jpk)     , wrk_3d_14(jpi,jpj,jpk)    ,  & 
-               wrk_3d_15(jpi,jpj,jpk)     , Stat=ierror(3))
-      !
-      ALLOCATE(wrk_4d_1(jpi,jpj,jpk,jpts) , wrk_4d_2(jpi,jpj,jpk,jpts),  &
-               wrk_4d_3(jpi,jpj,jpk,jpts) , wrk_4d_4(jpi,jpj,jpk,jpts),  &
-               Stat=ierror(4) )
-      !
-      ALLOCATE(wrk_xz_1(jpi,jpk)          , wrk_xz_2(jpi,jpk),           &
-               wrk_xz_3(jpi,jpk)          , wrk_xz_4(jpi,jpk),           &
-               Stat=ierror(5))
-      !
-      ALLOCATE(llwrk_2d_1(jpi,jpj)        , llwrk_2d_2(jpi,jpj),         &
-               llwrk_2d_3(jpi,jpj)        , Stat=ierror(6))
-      !
-      ALLOCATE(llwrk_3d_1(jpi,jpj,jpk)    , Stat=ierror(7))
-      !
-      ALLOCATE(iwrk_2d_1(jpi,jpj)         , Stat=ierror(8))
-      !
-      wrk_alloc = MAXVAL(ierror)
+      ALLOCATE( wrk_1d_1 (extent_1d) , wrk_1d_2 (extent_1d) , wrk_1d_3 (extent_1d) , wrk_1d_4 (extent_1d) ,     &
+         &      wrk_1d_5 (extent_1d) , wrk_1d_6 (extent_1d) , wrk_1d_7 (extent_1d) , wrk_1d_8 (extent_1d) ,     &
+         &      wrk_1d_9 (extent_1d) , wrk_1d_10(extent_1d)                                               ,     &
+         &      wrk_1d_11(extent_1d) , wrk_1d_12(extent_1d) , wrk_1d_13(extent_1d) , wrk_1d_14(extent_1d) ,     &
+         &      wrk_1d_15(extent_1d) , wrk_1d_16(extent_1d) , wrk_1d_17(extent_1d) , wrk_1d_18(extent_1d) ,     &
+         &      wrk_1d_19(extent_1d) , wrk_1d_20(extent_1d)                                               ,     &
+         &      wrk_1d_21(extent_1d) , wrk_1d_22(extent_1d) , wrk_1d_23(extent_1d) , wrk_1d_24(extent_1d) ,     &
+         &      wrk_1d_25(extent_1d) , wrk_1d_26(extent_1d) , wrk_1d_27(extent_1d)                        , STAT=ierror(1) )
+      !
+      ALLOCATE( wrk_2d_1 (jpi,jpj) , wrk_2d_2 (jpi,jpj) , wrk_2d_3 (jpi,jpj) , wrk_2d_4 (jpi,jpj) ,     & 
+         &      wrk_2d_5 (jpi,jpj) , wrk_2d_6 (jpi,jpj) , wrk_2d_7 (jpi,jpj) , wrk_2d_8 (jpi,jpj) ,     &
+         &      wrk_2d_9 (jpi,jpj) , wrk_2d_10(jpi,jpj)                                           ,     &
+         &      wrk_2d_11(jpi,jpj) , wrk_2d_12(jpi,jpj) , wrk_2d_13(jpi,jpj) , wrk_2d_14(jpi,jpj) ,     &
+         &      wrk_2d_15(jpi,jpj) , wrk_2d_16(jpi,jpj) , wrk_2d_17(jpi,jpj) , wrk_2d_18(jpi,jpj) ,     &
+         &      wrk_2d_19(jpi,jpj) , wrk_2d_20(jpi,jpj)                                           ,     &
+         &      wrk_2d_21(jpi,jpj) , wrk_2d_22(jpi,jpj) , wrk_2d_23(jpi,jpj) , wrk_2d_24(jpi,jpj) ,     &
+         &      wrk_2d_25(jpi,jpj) , wrk_2d_26(jpi,jpj) , wrk_2d_27(jpi,jpj) , wrk_2d_28(jpi,jpj) ,     &
+         &      wrk_2d_29(jpi,jpj) , wrk_2d_30(jpi,jpj)                                           ,     &
+         &      wrk_2d_31(jpi,jpj) , wrk_2d_32(jpi,jpj) , wrk_2d_33(jpi,jpj) , wrk_2d_34(jpi,jpj) ,     &
+         &      wrk_2d_35(jpi,jpj)                                                                , STAT=ierror(2) )
+      !
+      ALLOCATE( wrk_3d_1 (jpi,jpj,jpk) , wrk_3d_2 (jpi,jpj,jpk) , wrk_3d_3 (jpi,jpj,jpk) , wrk_3d_4 (jpi,jpj,jpk) ,     &
+         &      wrk_3d_5 (jpi,jpj,jpk) , wrk_3d_6 (jpi,jpj,jpk) , wrk_3d_7 (jpi,jpj,jpk) , wrk_3d_8 (jpi,jpj,jpk) ,     &
+         &      wrk_3d_9 (jpi,jpj,jpk) , wrk_3d_10(jpi,jpj,jpk)                                                   ,     & 
+         &      wrk_3d_11(jpi,jpj,jpk) , wrk_3d_12(jpi,jpj,jpk) , wrk_3d_13(jpi,jpj,jpk) , wrk_3d_14(jpi,jpj,jpk) ,     & 
+         &      wrk_3d_15(jpi,jpj,jpk)                                                                            , STAT=ierror(3) )
+      !
+      ALLOCATE( wrk_4d_1(jpi,jpj,jpk,jpts) , wrk_4d_2(jpi,jpj,jpk,jpts),     &
+         &      wrk_4d_3(jpi,jpj,jpk,jpts) , wrk_4d_4(jpi,jpj,jpk,jpts), STAT=ierror(4) )
+      !
+      ALLOCATE( wrk_xz_1(jpi,jpk) , wrk_xz_2(jpi,jpk) , wrk_xz_3(jpi,jpk) , wrk_xz_4(jpi,jpk) , STAT=ierror(5) )
+      !
+      ALLOCATE( llwrk_2d_1(jpi,jpj) , llwrk_2d_2(jpi,jpj) , llwrk_2d_3(jpi,jpj)               , STAT=ierror(6) )
+      !
+      ALLOCATE( llwrk_3d_1(jpi,jpj,jpk) , STAT=ierror(7) )
+      !
+      ALLOCATE( iwrk_2d_1(jpi,jpj)      , STAT=ierror(8) )
+      !
+      wrk_alloc = MAXVAL( ierror )
 
       ! Calling routine, nemo_alloc(), checks for errors and takes 
       ! appropriate action - we just print a warning message
-      IF(wrk_alloc /= 0)THEN
-         CALL ctl_warn('wrk_alloc: allocation of workspace arrays failed')
-      END IF
-
+      IF( wrk_alloc /= 0 )   CALL ctl_warn('wrk_alloc: allocation of workspace arrays failed')
+      !
    END FUNCTION wrk_alloc
 
 
-   FUNCTION wrk_use(ndim,    index1,  index2,  index3,  index4,  &
-                    index5,  index6,  index7,  index8,  index9,  &
-                    index10, index11, index12, index13, index14, &
-                    index15, index16, index17, index18, index19, &
-                    index20, index21, index22, index23, index24, &
-                    index25, index26, index27)
-      !!----------------------------------------------------------------------
-      !!                   ***  ROUTINE wrk_use  ***
+   FUNCTION wrk_use( kdim,    index1,  index2,  index3,  index4,    &
+      &              index5,  index6,  index7,  index8,  index9,    &
+      &              index10, index11, index12, index13, index14,   &
+      &              index15, index16, index17, index18, index19,   &
+      &              index20, index21, index22, index23, index24,   &
+      &              index25, index26, index27)
+      !!----------------------------------------------------------------------
+      !!                   ***  FUNCTION wrk_use  ***
       !!
       !! ** Purpose :   Request a set of KIND(wp) workspaces to use. Returns 
-      !!                .TRUE. if all those requested are available, .FALSE. 
-      !!                otherwise. 
-      !!
-      !! ** Method  :   Sets
-      !!                internal flags to signal that requested workspaces
-      !!                are in use.
-      !!----------------------------------------------------------------------
-      IMPLICIT none
-      LOGICAL             :: wrk_use     ! Return value
-      INTEGER, INTENT(in) :: ndim        ! Dimensionality of requested workspace(s)
-      INTEGER, INTENT(in) :: index1      ! Index of first requested workspace
-      INTEGER, OPTIONAL, INTENT(in) :: index2, index3,   index4,  index5,  &
-                                       index6, index7,   index8,  index9,  &
-                                       index10, index11, index12, index13, &
-                                       index14, index15, index16, index17, &
-                                       index18, index19, index20, index21, &
-                                       index22, index23, index24, index25, &
-                                       index26, index27
-      ! Local variables
-      INTEGER :: iarg, iptr
+      !!                .TRUE. if all those requested are available, .FALSE. otherwise. 
+      !!
+      !! ** Method  :   Sets internal flags to signal that requested workspaces are in use.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kdim        ! Dimensionality of requested workspace(s)
+      INTEGER, INTENT(in) ::   index1      ! Index of first requested workspace
+      INTEGER, OPTIONAL, INTENT(in) ::            index2 , index3 , index4 , index5 , index6 , index7 , index8 , index9, index10
+      INTEGER, OPTIONAL, INTENT(in) ::   index11, index12, index13, index14, index15, index16, index17, index18, index19, index20
+      INTEGER, OPTIONAL, INTENT(in) ::   index21, index22, index23, index24, index25, index26, index27
+      !
+      LOGICAL ::   wrk_use      ! Return value
+      INTEGER ::   iarg, iptr   ! local integer
       !!----------------------------------------------------------------------
 
       wrk_use = .TRUE.
-
-      iptr = index1
-      iarg = 1
-      DO WHILE(wrk_use .AND. iarg <= max_num_wrkspaces)
-
-         IF(ndim == 1)THEN
-
-            IF(iptr > num_1d_wrkspaces)THEN
+      iptr    = index1
+      iarg    = 1
+      
+      DO WHILE( wrk_use .AND. iarg <= max_num_wrkspaces )
+         !
+         IF( kdim == 1 ) THEN
+            IF( iptr > num_1d_wrkspaces ) THEN
                CALL ctl_stop('wrk_use - more 1D workspace arrays requested than defined in wrk_nemo module')
                wrk_use = .FALSE.
                EXIT
-            ELSE IF( in_use_1d(iptr) )THEN
+            ELSEIF( in_use_1d(iptr) ) THEN
                wrk_use = .FALSE.
                CALL print_in_use_list(1, REAL_TYPE, in_use_1d)
-            END IF
-
+            ENDIF
             in_use_1d(iptr) = .TRUE.
-
-         ELSE IF(ndim == 2)THEN
-
-            IF(iptr > num_2d_wrkspaces)THEN
+            !
+         ELSEIF( kdim == 2 ) THEN
+            IF( iptr > num_2d_wrkspaces ) THEN
                CALL ctl_stop('wrk_use - more 2D workspace arrays requested than defined in wrk_nemo module')
                wrk_use = .FALSE.
                EXIT
-            ELSE IF( in_use_2d(iptr) )THEN
+            ELSEIF( in_use_2d(iptr) ) THEN
                wrk_use = .FALSE.
                CALL print_in_use_list(2, REAL_TYPE, in_use_2d)
-            END IF
-
+            ENDIF
             in_use_2d(iptr) = .TRUE.
-
-         ELSE IF (ndim == 3)THEN
-
-            IF(iptr > num_3d_wrkspaces)THEN
-               CALL ctl_stop('wrk_use - more 3D workspace arrays requested than defined in wrk_nemo module')
+            !
+         ELSEIF( kdim == 3 ) THEN
+            IF( iptr > num_3d_wrkspaces ) THEN
+               CALL ctl_stop( 'wrk_use - more 3D workspace arrays requested than defined in wrk_nemo module' )
                wrk_use = .FALSE.
                EXIT
-            ELSE IF( in_use_3d(iptr) )THEN
+            ELSEIF( in_use_3d(iptr) ) THEN
                wrk_use = .FALSE.
                CALL print_in_use_list(3, REAL_TYPE, in_use_3d)
-            END IF
-
+            ENDIF
             in_use_3d(iptr) = .TRUE.
-
-         ELSE IF (ndim == 4) THEN
-
+            !
+         ELSEIF( kdim == 4 ) THEN
             IF(iptr > num_4d_wrkspaces)THEN
-               CALL ctl_stop('wrk_use - more 4D workspace arrays requested than defined in wrk_nemo module')
+               CALL ctl_stop( 'wrk_use - more 4D workspace arrays requested than defined in wrk_nemo module' )
                wrk_use = .FALSE.
                EXIT
-            ELSE IF( in_use_4d(iptr) )THEN
+            ELSEIF( in_use_4d(iptr) ) THEN
                wrk_use = .FALSE.
-               CALL print_in_use_list(4, REAL_TYPE, in_use_4d)
-            END IF
-
+               CALL print_in_use_list( 4, REAL_TYPE, in_use_4d )
+            ENDIF
+            !
             in_use_4d(iptr) = .TRUE.
-
+            !
          ELSE 
-            IF(lwp) WRITE(numout,*) 'wrk_use: unsupported value of ndim = ',ndim
-            CALL ctl_stop('wrk_use: unrecognised value for number of dimensions')
+            IF(lwp) WRITE(numout,*) 'wrk_use: unsupported value of kdim = ',kdim
+            CALL ctl_stop( 'wrk_use: unrecognised value for number of dimensions' )
          END IF
 
-         CALL get_next_arg(iarg  ,  iptr  ,  index2,  index3,  index4,  &
-                           index5,  index6,  index7,  index8,  index9,  &
-                           index10, index11, index12, index13, index14, &
-                           index15, index16, index17, index18, index19, &
-                           index20, index21, index22, index23, index24, &
-                           index25, index26, index27)
-
-         IF(iarg == -1)THEN
-            ! We've checked all of the arguments and are done
-            EXIT
-         ELSE IF(iarg == -99)THEN
-            CALL ctl_stop('wrk_use - ERROR, caught unexpected argument count - BUG')
+         CALL get_next_arg( iarg  ,  iptr  ,  index2,  index3,  index4,    &
+            &               index5,  index6,  index7,  index8,  index9,    &
+            &               index10, index11, index12, index13, index14,   &
+            &               index15, index16, index17, index18, index19,   &
+            &               index20, index21, index22, index23, index24,   &
+            &               index25, index26, index27)
+
+         IF( iarg == -1 ) THEN      ! We've checked all of the arguments and are done
+            EXIT
+         ELSEIF( iarg == -99 ) THEN
+            CALL ctl_stop( 'wrk_use - ERROR, caught unexpected argument count - BUG' )
             EXIT
          END IF
-
+         !
       END DO ! end of DO WHILE()
-
+      !
     END FUNCTION wrk_use
 
 
-    FUNCTION llwrk_use(ndim,   index1, index2, index3, index4, &
-                       index5, index6, index7, index8, index9)
-      !!----------------------------------------------------------------------
-      !!                   ***  ROUTINE llwrk_use  ***
+   FUNCTION llwrk_use( kdim,   index1, index2, index3, index4,   &
+      &                index5, index6, index7, index8, index9)
+      !!----------------------------------------------------------------------
+      !!                   ***  FUNCTION llwrk_use  ***
       !!
       !! ** Purpose :   Request a set of LOGICAL workspaces to use. Returns 
-      !!                .TRUE. if all those requested are available, .FALSE. 
-      !!                otherwise. 
-      !!
-      !! ** Method  :   Sets
-      !!                internal flags to signal that requested workspaces
-      !!                are in use.
-      !!----------------------------------------------------------------------
-      LOGICAL             :: llwrk_use     ! Return value
-      INTEGER, INTENT(in) :: ndim        ! Dimensionality of requested workspace(s)
-      INTEGER, INTENT(in) :: index1      ! Index of first requested workspace
-      INTEGER, OPTIONAL, INTENT(in) :: index2, index3, index4, index5, &
-                                       index6, index7, index8, index9
-      ! Local variables
-      INTEGER :: iarg, iptr
-      !!----------------------------------------------------------------------
-
+      !!                .TRUE. if all those requested are available, .FALSE. otherwise. 
+      !!
+      !! ** Method  :   Sets internal flags to signal that requested workspaces are in use.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kdim     ! Dimensionality of requested workspace(s)
+      INTEGER, INTENT(in) ::   index1   ! Index of first requested workspace
+      INTEGER, OPTIONAL, INTENT(in) :: index2, index3, index4, index5, index6, index7, index8, index9
+      !
+      LOGICAL ::   llwrk_use     ! Return value
+      INTEGER ::   iarg, iptr    ! local integers
+      !!----------------------------------------------------------------------
+      !
       llwrk_use = .TRUE.
-
-      iptr = index1
-      iarg = 1
-      DO WHILE(llwrk_use .AND. iarg <= max_num_wrkspaces)
-
-         IF(ndim == 2)THEN
-
+      iptr      = index1
+      iarg      = 1
+      !
+      DO WHILE( llwrk_use .AND. iarg <= max_num_wrkspaces )
+         !
+         IF( kdim == 2 ) THEN
             IF(iptr > num_2d_lwrkspaces)THEN
                CALL ctl_stop('llwrk_use - more 2D workspace arrays requested than defined in wrk_nemo module')
@@ -404,9 +303,8 @@
                CALL print_in_use_list(2, REAL_TYPE, in_use_2d)
             END IF
-
             in_use_2dll(iptr) = .TRUE.
-
-         ELSE IF (ndim == 3)THEN
-
+            !
+         ELSE IF (kdim == 3)THEN
+            !
             IF(iptr > num_3d_lwrkspaces)THEN
                CALL ctl_stop('llwrk_use - more 3D workspace arrays requested than defined in wrk_nemo module')
@@ -417,69 +315,62 @@
                CALL print_in_use_list(3, REAL_TYPE, in_use_3d)
             END IF
-
+            !
             in_use_3dll(iptr) = .TRUE.
          ELSE 
-            IF(lwp) WRITE(numout,*) 'llwrk_use: unsupported value of ndim = ',ndim
+            IF(lwp) WRITE(numout,*) 'llwrk_use: unsupported value of kdim = ',kdim
             CALL ctl_stop('llwrk_use: unrecognised value for number of dimensions')
          END IF
 
-         CALL get_next_arg(iarg  , iptr  , index2, index3, index4, &
-                           index5, index6, index7, index8, index9)
-
-         IF(iarg == -1)THEN
-            ! We've checked all of the arguments and are done
-            EXIT
-         ELSE IF(iarg == -99)THEN
-            CALL ctl_stop('llwrk_use - ERROR, caught unexpected argument count - BUG')
-            EXIT
-         END IF
-
+         CALL get_next_arg( iarg  , iptr  , index2, index3, index4, &
+            &               index5, index6, index7, index8, index9)
+
+         IF( iarg == -1 ) THEN      ! We've checked all of the arguments and are done
+            EXIT
+         ELSEIF( iarg == -99 ) THEN
+            CALL ctl_stop( 'llwrk_use - ERROR, caught unexpected argument count - BUG' )
+            EXIT
+         ENDIF
+         !
       END DO ! while(llwrk_use .AND. iarg <= max_num_wrkspaces)
-
-    END FUNCTION llwrk_use
-
-
-    FUNCTION iwrk_use(ndim,   index1, index2, index3, index4, &
-                      index5, index6, index7)
-      !!----------------------------------------------------------------------
-      !!                   ***  ROUTINE iwrk_use  ***
+      !
+   END FUNCTION llwrk_use
+
+
+   FUNCTION iwrk_use( kdim, index1, index2, index3, index4,   &
+      &                     index5, index6, index7 )
+      !!----------------------------------------------------------------------
+      !!                   ***  FUNCTION iwrk_use  ***
       !!
       !! ** Purpose :   Request a set of INTEGER workspaces to use. Returns 
-      !!                .TRUE. if all those requested are available, .FALSE. 
-      !!                otherwise. 
-      !!
-      !! ** Method  :   Sets
-      !!                internal flags to signal that requested workspaces
-      !!                are in use.
-      !!----------------------------------------------------------------------
+      !!                .TRUE. if all those requested are available, .FALSE. otherwise. 
+      !!
+      !! ** Method  :   Sets internal flags to signal that requested workspaces are in use.
+      !!----------------------------------------------------------------------
+      INTEGER          , INTENT(in) :: kdim        ! Dimensionality of requested workspace(s)
+      INTEGER          , INTENT(in) :: index1      ! Index of first requested workspace
+      INTEGER, OPTIONAL, INTENT(in) ::   index2, index3, index4, index5, index6, index7
+      !
       LOGICAL             :: iwrk_use    ! Return value
-      INTEGER, INTENT(in) :: ndim        ! Dimensionality of requested workspace(s)
-      INTEGER, INTENT(in) :: index1      ! Index of first requested workspace
-      INTEGER, OPTIONAL, INTENT(in) :: index2, index3, index4, index5, &
-                                       index6, index7
-      ! Local variables
       INTEGER :: iarg, iptr
       !!----------------------------------------------------------------------
 
       iwrk_use = .TRUE.
-
-      iptr = index1
-      iarg = 1
-      DO WHILE(iwrk_use .AND. iarg <= max_num_wrkspaces)
-
-         IF(ndim == 2)THEN
-
-            IF(iptr > num_2d_wrkspaces)THEN
-               CALL ctl_stop('wrk_use - more 2D workspace arrays requested than defined in wrk_nemo module')
+      iptr     = index1
+      iarg     = 1
+      
+      DO WHILE( iwrk_use .AND. iarg <= max_num_wrkspaces )
+         !
+         IF( kdim == 2 ) THEN
+            IF( iptr > num_2d_wrkspaces ) THEN
+               CALL ctl_stop( 'wrk_use - more 2D workspace arrays requested than defined in wrk_nemo module' )
                iwrk_use = .FALSE.
-            ELSE IF( in_use_2di(iptr) )THEN
+            ELSEIF( in_use_2di(iptr) ) THEN
                iwrk_use = .FALSE.
-               CALL print_in_use_list(2, INTEGER_TYPE, in_use_2di)
-            END IF
-
+               CALL print_in_use_list( 2, INTEGER_TYPE, in_use_2di )
+            END IF
             in_use_2di(iptr) = .TRUE.
-
+            !
          ELSE
-            IF(lwp) WRITE(numout,*) 'iwrk_use: unsupported value of ndim = ',ndim
+            IF(lwp) WRITE(numout,*) 'iwrk_use: unsupported value of kdim = ',kdim
             CALL ctl_stop('iwrk_use: unsupported value for number of dimensions')
          END IF
@@ -488,61 +379,43 @@
          SELECT CASE (iarg)
          CASE ( 1 )
-            IF(.not. PRESENT(index2))THEN
-               EXIT
-            ELSE
-               iarg = 2
-               iptr = index2
+            IF( .NOT. PRESENT(index2) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 2   ;   iptr = index2
             END IF
          CASE ( 2 )
-            IF(.not. PRESENT(index3))THEN
-               EXIT
-            ELSE
-               iarg = 3
-               iptr = index3
+            IF( .NOT. PRESENT(index3) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 3   ;   iptr = index3
             END IF
          CASE ( 3 )
-            IF(.not. PRESENT(index4))THEN
-               EXIT
-            ELSE
-               iarg = 4
-               iptr = index4
+            IF( .NOT. PRESENT(index4) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 4   ;   iptr = index4
             END IF
          CASE ( 4 )
-            IF(.not. PRESENT(index5))THEN
-               EXIT
-            ELSE
-               iarg = 5
-               iptr = index5
+            IF( .NOT. PRESENT(index5) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 5   ;   iptr = index5
             END IF
          CASE ( 5 )
-            IF(.not. PRESENT(index6))THEN
-               EXIT
-            ELSE
-               iarg = 6
-               iptr = index6
+            IF( .NOT. PRESENT(index6) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 6   ;   iptr = index6
             END IF
          CASE ( 6 )
-            IF(.not. PRESENT(index7))THEN
-               EXIT
-            ELSE
-               iarg = 7
-               iptr = index7
+            IF( .NOT. PRESENT(index7) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 7   ;   iptr = index7
             END IF
          CASE ( 7 )
             EXIT
          CASE DEFAULT
-            CALL ctl_stop('iwrk_use - ERROR, caught unexpected argument count - BUG')
+            CALL ctl_stop( 'iwrk_use - ERROR, caught unexpected argument count - BUG' )
             EXIT
          END SELECT
-
+         !
       END DO ! end of DO WHILE()
-
+      !
     END FUNCTION iwrk_use
 
 
-    FUNCTION wrk_use_xz(index1, index2, index3, index4, &
-                        index5, index6, index7, index8, index9)
-      !!----------------------------------------------------------------------
-      !!                   ***  ROUTINE wrk_use_xz  ***
+   FUNCTION wrk_use_xz( index1, index2, index3, index4,   &
+      &                 index5, index6, index7, index8, index9 )
+      !!----------------------------------------------------------------------
+      !!                   ***  FUNCTION wrk_use_xz  ***
       !!
       !! ** Purpose :   Request a set of 2D, xz (jpi,jpk) workspaces to use. 
@@ -550,645 +423,494 @@
       !!                .FALSE. otherwise. 
       !!
-      !! ** Method  :   Sets
-      !!                internal flags to signal that requested workspaces
-      !!                are in use.
-      !!----------------------------------------------------------------------
-      LOGICAL             :: wrk_use_xz     ! Return value
-      INTEGER, INTENT(in) :: index1      ! Index of first requested workspace
-      INTEGER, OPTIONAL, INTENT(in) :: index2, index3, index4, index5, &
-                                       index6, index7, index8, index9
+      !! ** Method  :   Sets internal flags to signal that requested workspaces are in use.
+      !!----------------------------------------------------------------------
+      INTEGER          , INTENT(in) :: index1      ! Index of first requested workspace
+      INTEGER, OPTIONAL, INTENT(in) :: index2, index3, index4, index5, index6, index7, index8, index9
       ! Local variables
+      LOGICAL ::   wrk_use_xz   ! Return value
+      INTEGER ::   iarg, iptr   ! local integer
+      !!----------------------------------------------------------------------
+
+      wrk_use_xz = .TRUE.
+      iptr       = index1
+      iarg       = 1
+       
+      DO WHILE( wrk_use_xz .AND. iarg <= max_num_wrkspaces )
+         !
+         IF(iptr > num_xz_wrkspaces)THEN
+            CALL ctl_stop('wrk_use_xz - more 2D xz workspace arrays requested than defined in wrk_nemo module')
+            wrk_use_xz = .FALSE.
+            EXIT
+         ELSE IF( in_use_xz(iptr) )THEN
+            wrk_use_xz = .FALSE.
+            CALL print_in_use_list(2, REAL_TYPE, in_use_xz) !ARPDBG - bug
+         END IF
+         !
+         in_use_xz(iptr) = .TRUE.
+         !
+         CALL get_next_arg(iarg  , iptr  , index2, index3, index4, &
+            &              index5, index6, index7, index8, index9)
+         !
+         IF( iarg == -1 ) THEN      ! We've checked all of the arguments and are done
+            EXIT
+         ELSEIF( iarg == -99 ) THEN
+            CALL ctl_stop( 'wrk_use_xz - ERROR, caught unexpected argument count - BUG' )   ;   EXIT
+         END IF
+         !
+      END DO ! while(wrk_use_xz .AND. iarg <= max_num_wrkspaces)
+      !
+   END FUNCTION wrk_use_xz
+
+
+   FUNCTION wrk_release( kdim,    index1,  index2,  index3,  index4,  &
+      &                  index5,  index6,  index7,  index8,  index9,  &
+      &                  index10, index11, index12, index13, index14, &
+      &                  index15, index16, index17, index18, index19, &
+      &                  index20, index21, index22, index23, index24, &
+      &                  index25, index26, index27)
+      !!----------------------------------------------------------------------
+      !!                 ***  FUNCTION wrk_release  ***
+      !!
+      !! ** Purpose :   Flag that the specified workspace arrays are no-longer in use.
+      !!----------------------------------------------------------------------
+      LOGICAL             :: wrk_release ! Return value
+      INTEGER, INTENT(in) :: kdim             ! Dimensionality of workspace(s)
+      INTEGER, INTENT(in) :: index1           ! Index of 1st workspace to release
+      INTEGER, OPTIONAL, INTENT(in) ::            index2 , index3 , index4 , index5 , index6 , index7 , index8 , index9 , index10
+      INTEGER, OPTIONAL, INTENT(in) ::   index11, index12, index13, index14, index15, index16, index17, index18, index19, index20
+      INTEGER, OPTIONAL, INTENT(in) ::   index21, index22, index23, index24, index25, index26, index27
+      !
       INTEGER :: iarg, iptr
       !!----------------------------------------------------------------------
 
-      wrk_use_xz = .TRUE.
-
+      wrk_release = .TRUE.
       iptr = index1
       iarg = 1
-      DO WHILE(wrk_use_xz .AND. iarg <= max_num_wrkspaces)
-
-            IF(iptr > num_xz_wrkspaces)THEN
-               CALL ctl_stop('wrk_use_xz - more 2D xz workspace arrays requested than defined in wrk_nemo module')
-               wrk_use_xz = .FALSE.
+
+      DO WHILE( iarg <= max_num_wrkspaces )
+         !
+         IF( kdim == 1 ) THEN
+            IF( iptr > num_1d_wrkspaces ) THEN
+               CALL ctl_stop( 'wrk_release - ERROR - attempt to release a non-existant 1D workspace array' )
+               wrk_release = .FALSE.
+            ELSE
+               in_use_1d(iptr) = .FALSE.
+            ENDIF
+            !
+         ELSE IF(kdim == 2)THEN
+            IF( iptr > num_2d_wrkspaces ) THEN
+               CALL ctl_stop( 'wrk_release - ERROR - attempt to release a non-existant 2D workspace array' )
+               wrk_release = .FALSE.
+            ENDIF
+            in_use_2d(iptr) = .FALSE.
+            !
+         ELSEIF( kdim == 3 ) THEN
+            IF( iptr > num_3d_wrkspaces ) THEN
+               CALL ctl_stop('wrk_release - ERROR - attempt to release a non-existant 3D workspace array')
+               wrk_release = .FALSE.
+            END IF
+            in_use_3d(iptr) = .FALSE.
+            !
+          ELSEIF( kdim == 4 ) THEN
+            IF(iptr > num_4d_wrkspaces)THEN
+               CALL ctl_stop('wrk_release - ERROR - attempt to release a non-existant 4D workspace array')
+               wrk_release = .FALSE.
+            END IF
+            in_use_4d(iptr) = .FALSE.
+            !
+         ELSE 
+            IF(lwp) WRITE(numout,*) 'wrk_release: unsupported value of kdim = ',kdim
+            CALL ctl_stop('wrk_release: unrecognised value for number of dimensions')
+         ENDIF
+         
+         ! Move on to next optional argument
+         CALL get_next_arg( iarg  ,  iptr  ,  index2,  index3,  index4,   &
+            &               index5,  index6,  index7,  index8,  index9,   &
+            &               index10, index11, index12, index13,           &
+            &               index14, index15, index16, index17,           &
+            &               index18, index19, index20, index21,           &
+            &               index22, index23, index24, index25,           &
+            &               index26, index27 )
+
+         IF( iarg == -1 ) THEN      ! We've checked all of the arguments and are done
+            EXIT
+         ELSEIF( iarg == -99 ) THEN
+             CALL ctl_stop('wrk_release - caught unexpected argument count - BUG')   ;   EXIT
+         END IF
+         !
+      END DO ! end of DO WHILE()
+      !
+   END FUNCTION wrk_release
+
+
+   FUNCTION llwrk_release( kdim, index1, index2, index3, index4, index5,   &
+      &                          index6, index7, index8, index9 )
+      !!----------------------------------------------------------------------
+      !!                 ***  FUNCTION wrk_release  ***
+      !!----------------------------------------------------------------------
+      INTEGER          , INTENT(in) ::   kdim             ! Dimensionality of workspace(s)
+      INTEGER          , INTENT(in) ::   index1           ! Index of 1st workspace to release
+      INTEGER, OPTIONAL, INTENT(in) ::   index2, index3, index4, index5, index6, index7, index8, index9
+      !
+      LOGICAL ::   llwrk_release   ! Return value
+      INTEGER ::   iarg, iptr      ! local integer
+      !!----------------------------------------------------------------------
+      !
+      llwrk_release = .TRUE.
+      iptr = index1
+      iarg = 1
+      !
+      DO WHILE(iarg <= max_num_wrkspaces)
+         !
+         IF( kdim == 2 ) THEN
+            !
+            IF( iptr > num_2d_lwrkspaces ) THEN
+               CALL ctl_stop( 'llwrk_release - ERROR - attempt to release a non-existant 2D workspace array' )
+               llwrk_release = .FALSE.
                EXIT
-            ELSE IF( in_use_xz(iptr) )THEN
-               wrk_use_xz = .FALSE.
-               CALL print_in_use_list(2, REAL_TYPE, in_use_xz) !ARPDBG - bug
-            END IF
-
-            in_use_xz(iptr) = .TRUE.
-
-         CALL get_next_arg(iarg  , iptr  , index2, index3, index4, &
-                           index5, index6, index7, index8, index9)
-
-         IF(iarg == -1)THEN
-            ! We've checked all of the arguments and are done
-            EXIT
-         ELSE IF(iarg == -99)THEN
-            CALL ctl_stop('wrk_use_xz - ERROR, caught unexpected argument count - BUG')
-            EXIT
+            ENDIF
+            in_use_2dll(iptr) = .FALSE.
+            !
+         ELSEIF( kdim == 3 ) THEN
+            IF( iptr > num_3d_lwrkspaces ) THEN
+               CALL ctl_stop('llwrk_release - ERROR - attempt to release a non-existant 3D workspace array')
+               llwrk_release = .FALSE.
+               EXIT
+            ENDIF
+            in_use_3dll(iptr) = .FALSE.
+            !
+         ELSE 
+            IF(lwp) WRITE(numout,*) 'llwrk_release: unsupported value of kdim = ', kdim
+            CALL ctl_stop( 'llwrk_release: unrecognised value for number of dimensions' )
          END IF
-
-      END DO ! while(wrk_use_xz .AND. iarg <= max_num_wrkspaces)
-
-    END FUNCTION wrk_use_xz
-
-
-    FUNCTION wrk_release(ndim,    index1,  index2,  index3,  index4,  &
-                         index5,  index6,  index7,  index8,  index9,  &
-                         index10, index11, index12, index13, index14, &
-                         index15, index16, index17, index18, index19, &
-                         index20, index21, index22, index23, index24, &
-                         index25, index26, index27)
-       !!----------------------------------------------------------------------
-       !!                 ***  ROUTINE wrk_release  ***
-       !!
-       !! ** Purpose :   Flag that the specified workspace arrays are no-longer
-       !!                in use.
-       !!----------------------------------------------------------------------
-       LOGICAL             :: wrk_release ! Return value
-       INTEGER, INTENT(in) :: ndim             ! Dimensionality of workspace(s)
-       INTEGER, INTENT(in) :: index1           ! Index of 1st workspace to release
-       INTEGER, OPTIONAL, INTENT(in) :: index2,  index3,  index4,  index5,  &
-                                        index6,  index7,  index8,  index9,  &
-                                        index10, index11, index12, index13, &
-                                        index14, index15, index16, index17, &
-                                        index18, index19, index20, index21, &
-                                        index22, index23, index24, index25, &
-                                        index26, index27
-       ! Local variables
-       INTEGER :: iarg, iptr
-       !!----------------------------------------------------------------------
-
-       wrk_release = .TRUE.
-       iptr = index1
-       iarg = 1
-
-       DO WHILE(iarg <= max_num_wrkspaces)
-
-          IF(ndim == 1)THEN
-
-             IF(iptr > num_1d_wrkspaces)THEN
-                CALL ctl_stop('wrk_release - ERROR - attempt to release a non-existant 1D workspace array')
-                wrk_release = .FALSE.
-             ELSE
-                in_use_1d(iptr) = .FALSE.
-             END IF
-
-          ELSE IF(ndim == 2)THEN
-
-             IF(iptr > num_2d_wrkspaces)THEN
-                CALL ctl_stop('wrk_release - ERROR - attempt to release a non-existant 2D workspace array')
-                wrk_release = .FALSE.
-             END IF
-
-             in_use_2d(iptr) = .FALSE.
-
-          ELSE IF (ndim == 3)THEN
-
-             IF(iptr > num_3d_wrkspaces)THEN
-                CALL ctl_stop('wrk_release - ERROR - attempt to release a non-existant 3D workspace array')
-                wrk_release = .FALSE.
-             END IF
-
-             in_use_3d(iptr) = .FALSE.
-
-          ELSE IF (ndim == 4) THEN
-
-             IF(iptr > num_4d_wrkspaces)THEN
-                CALL ctl_stop('wrk_release - ERROR - attempt to release a non-existant 4D workspace array')
-                wrk_release = .FALSE.
-             END IF
-
-             in_use_4d(iptr) = .FALSE.
-
-          ELSE 
-             IF(lwp) WRITE(numout,*) 'wrk_release: unsupported value of ndim = ',ndim
-             CALL ctl_stop('wrk_release: unrecognised value for number of dimensions')
-          END IF
-
-          ! Move on to next optional argument
-          CALL get_next_arg(iarg  ,  iptr  ,  index2,  index3,  index4, &
-                            index5,  index6,  index7,  index8,  index9, &
-                            index10, index11, index12, index13,         &
-                            index14, index15, index16, index17,         &
-                            index18, index19, index20, index21,         &
-                            index22, index23, index24, index25,         &
-                            index26, index27)
-
-          IF(iarg == -1)THEN
-             ! We've checked all of the arguments and are done
+         !
+         ! Move on to next optional argument
+         CALL get_next_arg(iarg, iptr, index2, index3, index4,   &
+            &                          index5, index6, index7, index8, index9)
+         !
+         IF( iarg == -1 ) THEN         ! We've checked all of the arguments and are done
              EXIT
-          ELSE IF(iarg == -99)THEN
-             CALL ctl_stop('wrk_release - caught unexpected argument count - BUG')
-             EXIT
-          END IF
-
+         ELSEIF( iarg == -99 ) THEN
+            CALL ctl_stop( 'llwrk_release - ERROR, caught unexpected argument count - BUG' )   ;   EXIT
+         ENDIF
+         !
+      END DO ! while (iarg <= max_num_wrkspaces)
+      !
+   END FUNCTION llwrk_release
+
+
+   FUNCTION iwrk_release( kdim, index1, index2, index3, index4,   &
+      &                         index5, index6, index7 )
+      !!----------------------------------------------------------------------
+      !!                 ***  FUNCTION iwrk_release  ***
+      !!
+      !! ** Purpose :   Flag that the specified INTEGER workspace arrays are
+      !!                no-longer in use.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kdim             ! Dimensionality of workspace(s)
+      INTEGER, INTENT(in) ::   index1           ! Index of 1st workspace to release
+      INTEGER, OPTIONAL, INTENT(in) :: index2, index3, index4, index5, index6, index7
+      !
+      LOGICAL :: iwrk_release   ! Return value
+      INTEGER :: iarg, iptr     ! local integer
+      !!----------------------------------------------------------------------
+      !
+      iwrk_release = .TRUE.
+      iptr         = index1
+      iarg         = 1
+      !
+      DO WHILE(iarg <= max_num_wrkspaces)
+         !
+         IF( kdim == 2 ) THEN
+            IF( iptr > num_2d_iwrkspaces ) THEN
+               CALL ctl_stop('iwrk_release - ERROR - attempt to release a non-existant 2D workspace array')
+               iwrk_release = .FALSE.
+            ENDIF
+            in_use_2di(iptr) = .FALSE.
+         ELSE 
+            IF(lwp) WRITE(numout,*) 'iwrk_release: unsupported value of kdim = ',kdim
+            CALL ctl_stop('iwrk_release: unsupported value for number of dimensions')
+         ENDIF
+         !
+         ! Move on to next optional argument
+         SELECT CASE (iarg)
+         CASE ( 1 )
+            IF( .NOT. PRESENT(index2) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 2   ;   iptr = index2
+            END IF
+         CASE ( 2 )
+            IF( .NOT. PRESENT(index3) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 3   ;   iptr = index3
+            END IF
+         CASE ( 3 )
+            IF( .NOT. PRESENT(index4) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 4   ;   iptr = index4
+            END IF
+         CASE ( 4 )
+            IF( .NOT. PRESENT(index5) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 5   ;   iptr = index5
+            END IF
+         CASE ( 5 )
+            IF( .NOT. PRESENT(index6) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 6   ;   iptr = index6
+            END IF
+         CASE ( 6 )
+            IF( .NOT. PRESENT(index7) ) THEN   ;   EXIT
+            ELSE                               ;   iarg = 7   ;   iptr = index7
+            END IF
+         CASE ( 7 )
+            EXIT
+         CASE DEFAULT
+            CALL ctl_stop( 'iwrk_release - ERROR, caught unexpected argument count - BUG' )
+            EXIT
+         END SELECT
+         !
       END DO ! end of DO WHILE()
-
-    END FUNCTION wrk_release
-
-
-    FUNCTION llwrk_release(ndim,   index1, index2, index3, index4, index5, &
-                           index6, index7, index8, index9)
-       LOGICAL             :: llwrk_release ! Return value
-       INTEGER, INTENT(in) :: ndim             ! Dimensionality of workspace(s)
-       INTEGER, INTENT(in) :: index1           ! Index of 1st workspace to release
-       INTEGER, OPTIONAL, INTENT(in) :: index2, index3, index4, index5, &
-                                        index6, index7, index8, index9
-       ! Local variables
-       INTEGER :: iarg, iptr
-       !!----------------------------------------------------------------------
-
-       llwrk_release = .TRUE.
-       iptr = index1
-       iarg = 1
-
-       DO WHILE(iarg <= max_num_wrkspaces)
-
-          IF(ndim == 2)THEN
-
-             IF(iptr > num_2d_lwrkspaces)THEN
-                CALL ctl_stop('llwrk_release - ERROR - attempt to release a non-existant 2D workspace array')
-                llwrk_release = .FALSE.
-                EXIT
-             END IF
-
-             in_use_2dll(iptr) = .FALSE.
-
-          ELSE IF (ndim == 3)THEN
-
-             IF(iptr > num_3d_lwrkspaces)THEN
-                CALL ctl_stop('llwrk_release - ERROR - attempt to release a non-existant 3D workspace array')
-                llwrk_release = .FALSE.
-                EXIT
-             END IF
-
-             in_use_3dll(iptr) = .FALSE.
-
-          ELSE 
-             IF(lwp) WRITE(numout,*) 'llwrk_release: unsupported value of ndim = ',ndim
-             CALL ctl_stop('llwrk_release: unrecognised value for number of dimensions')
-          END IF
-
-          ! Move on to next optional argument
-          CALL get_next_arg(iarg  , iptr  , index2, index3, index4, &
-                            index5, index6, index7, index8, index9)
-
-          IF(iarg == -1)THEN
-             ! We've checked all of the arguments and are done
-             EXIT
-          ELSE IF(iarg == -99)THEN
-             CALL ctl_stop('llwrk_release - ERROR, caught unexpected argument count - BUG')
-             EXIT
-          END IF
-
-       END DO ! while (iarg <= max_num_wrkspaces)
-
-    END FUNCTION llwrk_release
-
-
-    FUNCTION iwrk_release(ndim, index1, index2, index3, index4, index5, &
-                           index6, index7)
-       !!----------------------------------------------------------------------
-       !!                 ***  ROUTINE iwrk_release  ***
-       !!
-       !! ** Purpose :   Flag that the specified INTEGER workspace arrays are
-       !!                no-longer in use.
-       !!----------------------------------------------------------------------
-       LOGICAL             :: iwrk_release     ! Return value
-       INTEGER, INTENT(in) :: ndim             ! Dimensionality of workspace(s)
-       INTEGER, INTENT(in) :: index1           ! Index of 1st workspace to release
-       INTEGER, OPTIONAL, INTENT(in) :: index2, index3, index4, index5, &
-                                        index6, index7
-       ! Local variables
-       INTEGER :: iarg, iptr
-       !!----------------------------------------------------------------------
-
-       iwrk_release = .TRUE.
-       iptr = index1
-       iarg = 1
-
-       DO WHILE(iarg <= max_num_wrkspaces)
-
-          IF(ndim == 2)THEN
-
-             IF(iptr > num_2d_iwrkspaces)THEN
-                CALL ctl_stop('iwrk_release - ERROR - attempt to release a non-existant 2D workspace array')
-                iwrk_release = .FALSE.
-             END IF
-
-             in_use_2di(iptr) = .FALSE.
-          ELSE 
-             IF(lwp) WRITE(numout,*) 'iwrk_release: unsupported value of ndim = ',ndim
-             CALL ctl_stop('iwrk_release: unsupported value for number of dimensions')
-          END IF
-
-          ! Move on to next optional argument
-          SELECT CASE (iarg)
-          CASE ( 1 )
-             IF(.not. PRESENT(index2))THEN
-                EXIT
-             ELSE
-                iarg = 2
-                iptr = index2
-             END IF
-          CASE ( 2 )
-             IF(.not. PRESENT(index3))THEN
-                EXIT
-             ELSE
-                iarg = 3
-                iptr = index3
-             END IF
-          CASE ( 3 )
-             IF(.not. PRESENT(index4))THEN
-                EXIT
-             ELSE
-                iarg = 4
-                iptr = index4
-             END IF
-          CASE ( 4 )
-             IF(.not. PRESENT(index5))THEN
-                EXIT
-             ELSE
-                iarg = 5
-                iptr = index5
-             END IF
-          CASE ( 5 )
-             IF(.not. PRESENT(index6))THEN
-                EXIT
-             ELSE
-                iarg = 6
-                iptr = index6
-             END IF
-          CASE ( 6 )
-             IF(.not. PRESENT(index7))THEN
-                EXIT
-             ELSE
-                iarg = 7
-                iptr = index7
-             END IF
-          CASE ( 7 )
-             EXIT
-          CASE DEFAULT
-             CALL ctl_stop('iwrk_release - ERROR, caught unexpected argument count - BUG')
-             EXIT
-          END SELECT
-
-       END DO ! end of DO WHILE()
-
-    END FUNCTION iwrk_release
-
-
-    FUNCTION wrk_release_xz(index1, index2, index3, index4, index5, &
-                            index6, index7, index8, index9)
-       LOGICAL             :: wrk_release_xz   ! Return value
-       INTEGER, INTENT(in) :: index1           ! Index of 1st workspace to release
-       INTEGER, OPTIONAL, INTENT(in) :: index2, index3, index4, index5, &
-                                        index6, index7, index8, index9
-       ! Local variables
-       INTEGER :: iarg, iptr
-       !!----------------------------------------------------------------------
-
-       wrk_release_xz = .TRUE.
-       iptr = index1
-       iarg = 1
-
-       DO WHILE(iarg <= max_num_wrkspaces)
-
-             IF(iptr > num_xz_wrkspaces)THEN
-                CALL ctl_stop('wrk_release_xz - ERROR - attempt to release a non-existant 2D xz workspace array')
-                wrk_release_xz = .FALSE.
-                EXIT
-             END IF
-
-             in_use_xz(iptr) = .FALSE.
-
-
-          ! Move on to next optional argument
-          CALL get_next_arg(iarg  , iptr  , index2, index3, index4, &
-                            index5, index6, index7, index8, index9)
-
-          IF(iarg == -1)THEN
-             ! We've checked all of the arguments and are done
-             EXIT
-          ELSE IF(iarg == -99)THEN
-             CALL ctl_stop('wrk_release_xz - ERROR, caught unexpected argument count - BUG')
-             EXIT
-          END IF
-
-       END DO ! while (iarg <= max_num_wrkspaces)
-
-    END FUNCTION wrk_release_xz
-
-
-    SUBROUTINE print_in_use_list(ndim, itype, in_use_list)
-       !!----------------------------------------------------------------------
-       !!                 *** routine print_in_use_list ***
-       !!
-       !!    Purpose: to print out the table holding which workspace arrays
-       !!             are currently marked as in use.
-       !!----------------------------------------------------------------------
-       IMPLICIT none
-       INTEGER,               INTENT(in) :: ndim
-       INTEGER,               INTENT(in) :: itype
-       LOGICAL, DIMENSION(:), INTENT(in) :: in_use_list
-       ! Locals
-       INTEGER          :: ii, icount
-       CHARACTER(LEN=7) :: type_string
-       !!----------------------------------------------------------------------
-
-       IF(.NOT. lwp) RETURN
-
-       SELECT CASE (ndim)
-
-       CASE (1)
-
-          SELECT CASE (itype)
-
-          CASE (INTEGER_TYPE)
-             icount = num_1d_iwrkspaces
-          CASE (LOGICAL_TYPE)
-             icount = num_1d_lwrkspaces
-          CASE (REAL_TYPE)
-             icount = num_1d_wrkspaces
-          END SELECT
-
-       CASE (2)
-
-          SELECT CASE (itype)
-
-          CASE (INTEGER_TYPE)
-             icount = num_2d_iwrkspaces
-          CASE (LOGICAL_TYPE)
-             icount = num_2d_lwrkspaces
-          CASE (REAL_TYPE)
-             icount = num_2d_wrkspaces
-          END SELECT
-
-       CASE (3)
-
-          SELECT CASE (itype)
-
-          CASE (INTEGER_TYPE)
-             icount = num_3d_iwrkspaces
-          CASE (LOGICAL_TYPE)
-             icount = num_3d_lwrkspaces
-          CASE (REAL_TYPE)
-             icount = num_3d_wrkspaces
-          END SELECT
-
-       CASE (4)
-          SELECT CASE (itype)
-
-          CASE (INTEGER_TYPE)
-             icount = num_4d_iwrkspaces
-          CASE (LOGICAL_TYPE)
-             icount = num_4d_lwrkspaces
-          CASE (REAL_TYPE)
-             icount = num_4d_wrkspaces
-          END SELECT
-
-       CASE DEFAULT
-          RETURN
-
-       END SELECT
-
-       ! Set character string with type of workspace
-       SELECT CASE (itype)
-
-       CASE (INTEGER_TYPE)
-          type_string = "INTEGER" 
-       CASE (LOGICAL_TYPE)
-          type_string = "LOGICAL"
-       CASE (REAL_TYPE)
-          type_string = "REAL" 
-       END SELECT
-
-       WRITE(numout,*)
-       WRITE(numout,"('------------------------------------------')")
-       WRITE(numout,"('Table of ',I1,'D ',(A),' workspaces currently in use:')") ndim, TRIM(type_string)
-       WRITE(numout,"('Workspace   In use')")
-       DO ii=1,icount, 1
-          WRITE(numout,"(4x,I2,8x,L1)") ii, in_use_list(ii)
-       END DO
-       WRITE(numout,"('------------------------------------------')")
-       WRITE(numout,*)
-
-    END SUBROUTINE print_in_use_list
-
-
-    SUBROUTINE get_next_arg(iargidx, iargval, index2,  index3,  index4,  &
-                            index5 , index6,  index7,  index8,  index9,  &
-                            index10, index11, index12, index13, index14, &
-                            index15, index16, index17, index18, index19, &
-                            index20, index21, index22, index23, index24, &
-                            index25, index26, index27)
-       !!----------------------------------------------------------------------
-       INTEGER, INTENT(inout) :: iargidx ! Index of current arg
-       INTEGER, INTENT(inout) :: iargval ! Value of current arg
-       INTEGER, OPTIONAL, INTENT(in) :: index2, index3, index4, index5,     &
-                                        index6, index7, index8, index9,     &
-                                        index10, index11, index12, index13, &
-                                        index14, index15, index16, index17, &
-                                        index18, index19, index20, index21, &
-                                        index22, index23, index24, index25, &
-                                        index26, index27
-       !!----------------------------------------------------------------------
-
-       ! Move on to next optional argument
-       SELECT CASE (iargidx)
-       CASE ( 1 )
-          IF(.not. PRESENT(index2))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 2
-             iargval = index2
-          END IF
-       CASE ( 2 )
-          IF(.not. PRESENT(index3))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 3
-             iargval = index3
-          END IF
-       CASE ( 3 )
-          IF(.not. PRESENT(index4))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 4
-             iargval = index4
-          END IF
-       CASE ( 4 )
-          IF(.not. PRESENT(index5))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 5
-             iargval = index5
-          END IF
-       CASE ( 5 )
-          IF(.not. PRESENT(index6))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 6
-             iargval = index6
-          END IF
-       CASE ( 6 )
-          IF(.not. PRESENT(index7))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 7
-             iargval = index7
-          END IF
-       CASE ( 7 )
-          IF(.not. PRESENT(index8))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 8
-             iargval = index8
-          END IF
-       CASE ( 8 )
-          IF(.not. PRESENT(index9))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 9
-             iargval = index9
-          END IF
-       CASE ( 9 )
-          IF(.not. PRESENT(index10))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 10
-             iargval = index10
-          END IF
-       CASE ( 10 )
-          IF(.not. PRESENT(index11))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 11
-             iargval = index11
-          END IF
-       CASE ( 11 )
-          IF(.not. PRESENT(index12))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 12
-             iargval = index12
-          END IF
-       CASE ( 12 )
-          IF(.not. PRESENT(index13))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 13
-             iargval = index13
-          END IF
-       CASE ( 13 )
-          IF(.not. PRESENT(index14))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 14
-             iargval = index14
-          END IF
-       CASE ( 14 )
-          IF(.not. PRESENT(index15))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 15
-             iargval = index15
-          END IF
-       CASE ( 15 )
-          IF(.not. PRESENT(index16))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 16
-             iargval = index16
-          END IF
-       CASE ( 16 )
-          IF(.not. PRESENT(index17))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 17
-             iargval = index17
-          END IF
-       CASE ( 17 )
-          IF(.not. PRESENT(index18))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 18
-             iargval = index18
-          END IF
-       CASE ( 18 )
-          IF(.not. PRESENT(index19))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 19
-             iargval = index19
-          END IF
-       CASE ( 19 )
-          IF(.not. PRESENT(index20))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 20
-             iargval = index20
-          END IF
-       CASE ( 20 )
-          IF(.not. PRESENT(index21))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 21
-             iargval = index21
-          END IF
-       CASE ( 21 )
-          IF(.not. PRESENT(index22))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 22
-             iargval = index22
-          END IF
-       CASE ( 22 )
-          IF(.not. PRESENT(index23))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 23
-             iargval = index23
-          END IF
-       CASE ( 23 )
-          IF(.not. PRESENT(index24))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 24
-             iargval = index24
-          END IF
-       CASE ( 24 )
-          IF(.not. PRESENT(index25))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 25
-             iargval = index25
-          END IF
-       CASE ( 25 )
-          IF(.not. PRESENT(index26))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 26
-             iargval = index26
-          END IF
-       CASE ( 26 )
-          IF(.not. PRESENT(index27))THEN
-             iargidx = -1
-          ELSE
-             iargidx = 27
-             iargval = index27
-          END IF
-       CASE ( 27 )
-          iargidx = -1
-       CASE DEFAULT
-          ! BUG - iargidx shouldn't take any other values!
-          ! Flag error for calling routine
-          iargidx = -99
-       END SELECT
-
-    END SUBROUTINE get_next_arg
-
-
+      !
+   END FUNCTION iwrk_release
+
+
+   FUNCTION wrk_release_xz( index1, index2, index3, index4, index5,   &
+      &                     index6, index7, index8, index9 )
+      !!----------------------------------------------------------------------
+      !!                 ***  FUNCTION wrk_release_xz  ***
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: index1           ! Index of 1st workspace to release
+      INTEGER, OPTIONAL, INTENT(in) :: index2, index3, index4, index5, index6, index7, index8, index9
+      !
+      LOGICAL ::   wrk_release_xz   ! Return value
+      INTEGER ::   iarg, iptr       ! local integer
+      !!----------------------------------------------------------------------
+      !
+      wrk_release_xz = .TRUE.
+      iptr           = index1
+      iarg           = 1
+      !
+      DO WHILE( iarg <= max_num_wrkspaces )
+         !
+         IF( iptr > num_xz_wrkspaces ) THEN
+            CALL ctl_stop('wrk_release_xz - ERROR - attempt to release a non-existant 2D xz workspace array')
+            wrk_release_xz = .FALSE.
+            EXIT
+         ENDIF
+         in_use_xz(iptr) = .FALSE.
+         !
+         ! Move on to next optional argument
+         CALL get_next_arg( iarg, iptr, index2, index3, index4,   &
+            &                           index5, index6, index7, index8, index9)
+         !
+         IF(  iarg == -1 ) THEN     ! We've checked all of the arguments and are done
+            EXIT
+         ELSEIF( iarg == -99 ) THEN
+            CALL ctl_stop('wrk_release_xz - ERROR, caught unexpected argument count - BUG')
+            EXIT
+         END IF
+         !
+      END DO ! while (iarg <= max_num_wrkspaces)
+      !
+   END FUNCTION wrk_release_xz
+
+
+   SUBROUTINE print_in_use_list( kdim, itype, in_use_list )
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE print_in_use_list ***
+      !!
+      !!    Purpose: to print out the table holding which workspace arrays
+      !!             are currently marked as in use.
+      !!----------------------------------------------------------------------
+      INTEGER,               INTENT(in) :: kdim
+      INTEGER,               INTENT(in) :: itype
+      LOGICAL, DIMENSION(:), INTENT(in) :: in_use_list
+      !
+      INTEGER          ::   ji, icount
+      CHARACTER(LEN=7) ::   type_string
+      !!----------------------------------------------------------------------
+
+      IF(.NOT. lwp)   RETURN
+
+      SELECT CASE ( kdim )
+      !
+      CASE (1)
+         SELECT CASE (itype)
+         CASE (INTEGER_TYPE)   ;   icount = num_1d_iwrkspaces
+         CASE (LOGICAL_TYPE)   ;   icount = num_1d_lwrkspaces
+         CASE (REAL_TYPE   )   ;   icount = num_1d_wrkspaces
+         END SELECT
+         !
+      CASE (2)
+         SELECT CASE (itype)
+         CASE (INTEGER_TYPE)   ;   icount = num_2d_iwrkspaces
+         CASE (LOGICAL_TYPE)   ;   icount = num_2d_lwrkspaces
+         CASE (REAL_TYPE   )   ;   icount = num_2d_wrkspaces
+         END SELECT
+         !
+      CASE (3)
+         SELECT CASE (itype)
+         CASE (INTEGER_TYPE)   ;   icount = num_3d_iwrkspaces
+         CASE (LOGICAL_TYPE)   ;   icount = num_3d_lwrkspaces
+         CASE (REAL_TYPE   )   ;   icount = num_3d_wrkspaces
+         END SELECT
+         !
+      CASE (4)
+         SELECT CASE (itype)
+         CASE (INTEGER_TYPE)   ;   icount = num_4d_iwrkspaces
+         CASE (LOGICAL_TYPE)   ;   icount = num_4d_lwrkspaces
+         CASE (REAL_TYPE   )   ;   icount = num_4d_wrkspaces
+         END SELECT
+         !
+      CASE DEFAULT   ;   RETURN
+      !
+      END SELECT
+
+      ! Set character string with type of workspace
+      SELECT CASE (itype)
+      CASE (INTEGER_TYPE)   ;   type_string = "INTEGER" 
+      CASE (LOGICAL_TYPE)   ;   type_string = "LOGICAL"
+      CASE (REAL_TYPE   )   ;   type_string = "REAL" 
+      END SELECT
+
+      WRITE(numout,*)
+      WRITE(numout,"('------------------------------------------')")
+      WRITE(numout,"('Table of ',I1,'D ',(A),' workspaces currently in use:')") kdim, TRIM(type_string)
+      WRITE(numout,"('Workspace   In use')")
+      DO ji = 1, icount, 1
+         WRITE(numout,"(4x,I2,8x,L1)") ji, in_use_list(ji)
+      END DO
+      WRITE(numout,"('------------------------------------------')")
+      WRITE(numout,*)
+      !
+   END SUBROUTINE print_in_use_list
+
+
+   SUBROUTINE get_next_arg( iargidx, iargval, index2,  index3,  index4,  &
+      &                     index5 , index6,  index7,  index8,  index9,  &
+      &                     index10, index11, index12, index13, index14, &
+      &                     index15, index16, index17, index18, index19, &
+      &                     index20, index21, index22, index23, index24, &
+      &                     index25, index26, index27 )
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(inout) :: iargidx ! Index of current arg
+      INTEGER, INTENT(inout) :: iargval ! Value of current arg
+      INTEGER, OPTIONAL, INTENT(in) ::            index2 , index3 , index4 , index5 , index6 , index7 , index8 , index9 , index10
+      INTEGER, OPTIONAL, INTENT(in) ::   index11, index12, index13, index14, index15, index16, index17, index18, index19, index20
+      INTEGER, OPTIONAL, INTENT(in) ::   index21, index22, index23, index24, index25, index26, index27
+      !!----------------------------------------------------------------------
+
+      SELECT CASE (iargidx)       ! Move on to next optional argument
+      CASE ( 1 )
+         IF( .NOT. PRESENT(index2 ) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx =  2   ;   iargval = index2
+         ENDIF
+      CASE ( 2 )
+         IF( .NOT. PRESENT(index3 ) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx =  3   ;   iargval = index3
+         ENDIF
+      CASE ( 3 )
+         IF( .NOT. PRESENT(index4 ) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx =  4   ;   iargval = index4
+         ENDIF
+      CASE ( 4 )
+         IF( .NOT. PRESENT(index5 ) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx =  5   ;   iargval = index5
+         ENDIF
+      CASE ( 5 )
+         IF( .NOT. PRESENT(index6 ) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx =  6   ;   iargval = index6
+         ENDIF
+      CASE ( 6 )
+         IF( .NOT. PRESENT(index7 ) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx =  7   ;   iargval = index7
+         ENDIF
+      CASE ( 7 )
+         IF( .NOT. PRESENT(index8 ) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx =  8   ;   iargval = index8
+         ENDIF
+      CASE ( 8 )
+         IF( .NOT. PRESENT(index2 ) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx =  9   ;   iargval = index9
+         ENDIF
+      CASE ( 9 )
+         IF( .NOT. PRESENT(index10) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 10   ;   iargval = index10
+         ENDIF
+      CASE ( 10 )
+         IF( .NOT. PRESENT(index11) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 11   ;   iargval = index11
+         ENDIF
+      CASE ( 11 )
+         IF( .NOT. PRESENT(index12) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 12   ;   iargval = index12
+         ENDIF
+      CASE ( 12 )
+         IF( .NOT. PRESENT(index13) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx =  13   ;   iargval = index13
+         ENDIF
+      CASE ( 13 )
+         IF( .NOT. PRESENT(index14) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 14   ;   iargval = index14
+         ENDIF
+      CASE ( 14 )
+         IF( .NOT. PRESENT(index15) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 15   ;   iargval = index15
+         ENDIF
+      CASE ( 15 )
+         IF( .NOT. PRESENT(index16) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 16   ;   iargval = index16
+         ENDIF
+      CASE ( 16 )
+         IF( .NOT. PRESENT(index17) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 17   ;   iargval = index17
+         END IF
+      CASE ( 17 )
+         IF( .NOT. PRESENT(index18) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 18   ;   iargval = index18
+         ENDIF
+      CASE ( 18 )
+         IF( .NOT. PRESENT(index19) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 19   ;   iargval = index19
+         ENDIF
+      CASE ( 19 )
+         IF( .NOT. PRESENT(index20) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 20   ;   iargval = index20
+         ENDIF
+      CASE ( 20 )
+         IF( .NOT. PRESENT(index21) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 21   ;   iargval = index21
+         ENDIF
+      CASE ( 21 )
+         IF( .NOT. PRESENT(index22) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 22   ;   iargval = index22
+         ENDIF
+      CASE ( 22 )
+         IF( .NOT. PRESENT(index23) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 23   ;   iargval = index23
+         ENDIF
+      CASE ( 23 )
+         IF( .NOT. PRESENT(index24) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 24   ;   iargval = index24
+         ENDIF
+      CASE ( 24 )
+         IF( .NOT. PRESENT(index25) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 25   ;   iargval = index25
+         ENDIF
+      CASE ( 25 )
+         IF( .NOT. PRESENT(index26) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 26   ;   iargval = index26
+         ENDIF
+      CASE ( 26 )
+         IF( .NOT. PRESENT(index27) ) THEN   ;   iargidx = -1
+         ELSE                                ;   iargidx = 27   ;   iargval = index27
+         ENDIF
+      CASE ( 27 )
+         iargidx = -1
+      CASE DEFAULT
+         ! BUG - iargidx shouldn't take any other values!
+         ! Flag error for calling routine
+         iargidx = -99
+      END SELECT
+      !
+   END SUBROUTINE get_next_arg
+
+   !!=====================================================================
 END MODULE wrk_nemo
