Index: /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90
===================================================================
--- /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 7571)
+++ /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 7572)
@@ -40,4 +40,8 @@
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   sn0          ! initial salinity
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   tn0          ! initial temperature
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sshthster_mat         ! ssh_thermosteric height
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sshhlster_mat         ! ssh_halosteric height
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sshsteric_mat         ! ssh_steric height
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   zbotpres_mat          ! bottom pressure
       
    !! * Substitutions
@@ -57,5 +61,7 @@
       !!----------------------------------------------------------------------
       !
-      ALLOCATE( area(jpi,jpj), thick0(jpi,jpj) , sn0(jpi,jpj,jpk), tn0(jpi,jpj,jpk) , STAT=dia_ar5_alloc )
+      ALLOCATE( area(jpi,jpj), thick0(jpi,jpj) , sn0(jpi,jpj,jpk), tn0(jpi,jpj,jpk) , &
+          & sshthster_mat(jpi,jpj),sshhlster_mat(jpi,jpj),sshsteric_mat(jpi,jpj), &
+          & zbotpres_mat(jpi,jpj),STAT=dia_ar5_alloc )
       !
       IF( lk_mpp             )   CALL mpp_sum ( dia_ar5_alloc )
@@ -86,4 +92,9 @@
       CALL wrk_alloc( jpi , jpj , jpk        , zrhd      , zrhop    )
       CALL wrk_alloc( jpi , jpj , jpk , jpts , ztsn                 )
+      
+      sshthster_mat(:,:) = 0._wp  
+      sshhlster_mat(:,:) = 0._wp  
+      sshsteric_mat(:,:) = 0._wp  
+      zbotpres_mat(:,:)  = 0._wp  
 
       zarea_ssh(:,:) = area(:,:) * sshn(:,:)
@@ -122,5 +133,6 @@
       zssh_steric = - zarho / area_tot
       CALL iom_put( 'sshthster', zssh_steric )
-      CALL iom_put( 'sshthster_mat', -zbotpres )
+      sshthster_mat(:,:) =  -zbotpres(:,:)
+      CALL iom_put( 'sshthster_mat', sshthster_mat )
 
       !                     
@@ -150,5 +162,6 @@
       CALL iom_put( 'sshhlster', zssh_steric )
       !JT
-      CALL iom_put( 'sshhlster_mat', -zbotpres )
+      sshhlster_mat(:,:) = -zbotpres(:,:)
+      CALL iom_put( 'sshhlster_mat', sshhlster_mat )
       !JT
       
@@ -183,5 +196,6 @@
       CALL iom_put( 'sshsteric', zssh_steric )
       !JT
-      CALL iom_put( 'sshsteric_mat', -zbotpres )
+      sshsteric_mat(:,:) = -zbotpres(:,:) 
+      CALL iom_put( 'sshsteric_mat', sshsteric_mat )
       !JT
       
@@ -189,5 +203,6 @@
       zztmp = rau0 * grav * 1.e-4_wp               ! recover pressure from pressure anomaly and cover to dbar = 1.e4 Pa
       zbotpres(:,:) = zztmp * ( zbotpres(:,:) + sshn(:,:) + thick0(:,:) )
-      CALL iom_put( 'botpres', zbotpres )
+      zbotpres_mat(:,:) = zbotpres(:,:)
+      CALL iom_put( 'botpres', zbotpres_mat )
 
       !                                         ! Mean density anomalie, temperature and salinity
Index: /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90
===================================================================
--- /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 7571)
+++ /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 7572)
@@ -34,5 +34,6 @@
   USE dom_oce         ! ocean space and time domain
   USE phycst          ! physical constants
-  USE in_out_manager  ! I/O manager
+  USE in_out_manager  ! I/O units
+  USE iom             ! I/0 library
   USE daymod          ! calendar
   USE dianam          ! build name of file
@@ -170,11 +171,4 @@
      
      
-     !NAMELIST/namdct/nn_dct,nn_dctwri,nn_secdebug
-
-     !IF( nn_timing == 1 )   CALL timing_start('dia_dct_init')
-
-     !read namelist
-     !REWIND( numnam )
-     !READ  ( numnam, namdct )
 
      IF( ln_NOOS ) THEN
@@ -214,5 +208,4 @@
      CALL readsec
      
-     !IF (lwp) write(numout,*) 'dct after readsec'
      
 
@@ -277,6 +270,4 @@
      
      
-     !WRITE(numout,*) "diadct ind ii: ",kt,nproc, narea, mig(1),mig(jpi),nlci
-     !WRITE(numout,*) "diadct ind jj: ",kt,nproc, narea, mjg(1),mig(jpj),nlcj
 
      
@@ -319,8 +310,6 @@
            CALL transport(secs(jsec),lldebug,jsec) 
            
-           !IF( lwp ) WRITE(numout,*) "diadct: call transport subroutine (kt, jsec) : ",kt,jsec
 
         ENDDO
-        !IF( lwp ) WRITE(numout,*) "diadct: called transport subroutine (kt, nb_sec) : ",kt, nb_sec
              
         IF( MOD(kt,nn_dctwri)==0 )THEN
@@ -368,6 +357,4 @@
      ENDIF
      IF ( MOD(kt,nn_dct_h)==0 ) THEN            ! compute transport every nn_dct_h time steps
-     !IF ( MOD(kt,nn_dct)==0 .or. &               ! compute transport every nn_dct time steps
-     !    (ln_NOOS .and. kt==nn_it000 ) )  THEN   ! also include first time step when calculating NOOS 25 hour averages
 
         DO jsec=1,nb_sec
@@ -409,7 +396,5 @@
 
               IF( lwp .and. ln_NOOS ) THEN
-                !WRITE(numout,*) "diadct: call dia_dct_wri_NOOS_h (kt,nn_dctwri_h, kt/nn_dctwri_h,jsec) : ",kt,nn_dctwri_h, kt/nn_dctwri_h,jsec
                 CALL dia_dct_wri_NOOS_h(kt/nn_dctwri_h,jsec,secs(jsec))   ! use NOOS specific formatting
-                !WRITE(numout,*) "diadct: called dia_dct_wri_NOOS_h (kt,jsec) : ",kt,jsec
               endif
               !nullify transports values after writing
@@ -466,23 +451,18 @@
      !open input file
      !---------------
-     !IF (lwp) THEN
-       !write(numout,*) 'dct low-level pre open: little endian '
-       !OPEN(UNIT=107,FILE='section_ijglobal.diadct', FORM='UNFORMATTED', ACCESS='SEQUENTIAL', STATUS='OLD',convert='LITTLE_ENDIAN')
-       
-       write(numout,*) 'dct low-level pre open: big endian :',nproc,narea
-       OPEN(UNIT=107,FILE='section_ijglobal.diadct', FORM='UNFORMATTED', ACCESS='SEQUENTIAL', STATUS='OLD',convert='BIG_ENDIAN')
-       
-       !write(numout,*) 'dct low-level pre open: SWAP '
-       !OPEN(UNIT=107,FILE='section_ijglobal.diadct', FORM='UNFORMATTED', ACCESS='SEQUENTIAL', STATUS='OLD',convert='SWAP')
-       
-       !write(numout,*) 'dct low-level pre open: NATIVE '
-       !OPEN(UNIT=107,FILE='section_ijglobal.diadct', FORM='UNFORMATTED', ACCESS='SEQUENTIAL', STATUS='OLD',convert='NATIVE')
-       
-       write(numout,*) 'dct low-level opened :',nproc,narea
-       READ(107) isec
-       write(numout,*) 'dct low-level isec ', isec,nproc,narea
-       CLOSE(107)
-     !ENDIF
-     
+     !write(numout,*) 'dct low-level pre open: little endian '
+     !OPEN(UNIT=107,FILE='section_ijglobal.diadct', FORM='UNFORMATTED', ACCESS='SEQUENTIAL', STATUS='OLD',convert='LITTLE_ENDIAN')
+     
+     write(numout,*) 'dct low-level pre open: big endian :',nproc,narea
+     OPEN(UNIT=107,FILE='section_ijglobal.diadct', FORM='UNFORMATTED', ACCESS='SEQUENTIAL', STATUS='OLD',convert='BIG_ENDIAN')
+     
+     !write(numout,*) 'dct low-level pre open: SWAP '
+     !OPEN(UNIT=107,FILE='section_ijglobal.diadct', FORM='UNFORMATTED', ACCESS='SEQUENTIAL', STATUS='OLD',convert='SWAP')
+     
+     !write(numout,*) 'dct low-level pre open: NATIVE '
+     !OPEN(UNIT=107,FILE='section_ijglobal.diadct', FORM='UNFORMATTED', ACCESS='SEQUENTIAL', STATUS='OLD',convert='NATIVE')
+     
+     READ(107) isec
+     CLOSE(107)
      
      CALL ctl_opn( numdct_in, 'section_ijglobal.diadct', 'OLD', 'UNFORMATTED', 'SEQUENTIAL', -1, numout, .TRUE. )
@@ -501,55 +481,31 @@
         !---------------
         secs(jsec)%name=''
-        !IF( lwp )  write(numout,*)  secs(jsec)%name
         secs(jsec)%llstrpond      = .FALSE.
-        !IF( lwp )  write(numout,*) secs(jsec)%llstrpond 
         secs(jsec)%ll_ice_section = .FALSE.
-        !IF( lwp )  write(numout,*) secs
         secs(jsec)%ll_date_line   = .FALSE.
-        !IF( lwp )  write(numout,*) secs(jsec)%ll_date_line
         secs(jsec)%nb_class       = 0
-        !IF( lwp )  write(numout,*) secs(jsec)%nb_class
         secs(jsec)%zsigi          = 99._wp
-        !IF( lwp )  write(numout,*) secs(jsec)%zsigi
         secs(jsec)%zsigp          = 99._wp
-        !IF( lwp )  write(numout,*)  secs(jsec)%zsigp
         secs(jsec)%zsal           = 99._wp
-        !IF( lwp )  write(numout,*) secs(jsec)%zsal
         secs(jsec)%ztem           = 99._wp
-        !IF( lwp )  write(numout,*) secs(jsec)%ztem
         secs(jsec)%zlay           = 99._wp
-        !IF( lwp )  write(numout,*) secs(jsec)%zlay
         secs(jsec)%transport      =  0._wp
-        !IF( lwp )  write(numout,*) secs(jsec)%transport
         secs(jsec)%transport_h    =  0._wp
-        !IF( lwp )  write(numout,*) secs(jsec)%transport_h
         secs(jsec)%nb_point       = 0
-        !IF( lwp )  write(numout,*) secs(jsec)%nb_point 
 
         !read section's number / name / computing choices / classes / slopeSection / points number
         !-----------------------------------------------------------------------------------------
         
-        !write(numout,*) 'dct isec ', isec
-        !write(numout,*) 'dct numdct_in ', numdct_in
         READ(numdct_in,iostat=iost) isec
-        !write(numout,*) 'dct iost ', iost
-        !IF (iost .NE. 0 ) EXIT
         IF (iost .NE. 0 ) then
           write(numout,*) 'unable to read section_ijglobal.diadct. iost = ',iost
-          !nb_sec = 2
           EXIT !end of file 
         ENDIF
         
-        !write(numout,*) 'dct isec', isec
         
         WRITE(cltmp,'(a,i4.4,a,i4.4)')'diadct: read sections : Problem of section number: isec= ',isec,' and jsec= ',jsec
-        !WRITE(numout,'(a,i4.4,a,i4.4)')'diadct: read sections : Problem of section number: isec= ',isec,' and jsec= ',jsec
-        
-        !write(numout,*) 'dct isec, jsec', isec,jsec
         
         
         IF( jsec .NE. isec )  CALL ctl_stop( cltmp )
-
-        !IF( lwp .AND. ( jsec==nn_secdebug .OR. nn_secdebug==-1 ) )WRITE(numout,*)"isec ",isec 
 
         READ(numdct_in)secs(jsec)%name
@@ -599,5 +555,4 @@
               coordtemp(jpt)%I = i1 
               coordtemp(jpt)%J = i2
-              !WRITE(numout,*)'diadct: coordtemp:', jpt,i1,i2
            ENDDO
            READ(numdct_in)directemp(1:iptglo)
@@ -622,25 +577,11 @@
               IF( iiglo==jpidta .AND. nimpp==1 ) iiglo = 2
               
-              !WRITE(numout,*)"diadct readsec: reg/glo domain:",narea,nlci,nimpp,mig(1),nlcj,njmpp,mjg(1)
-
-      !diadct init: reg/glo domain: 3*1,  24,  22,  24,  22,  2*1
               iiloc=iiglo-jpizoom+1-nimpp+1   ! local coordinates of the point
               ijloc=ijglo-jpjzoom+1-njmpp+1   !  "
-              !WRITE(numout,*)"      List of limits of each processor:",jpt,nimpp,iiloc,iiglo,jpizoom+1,nimpp+1,ijloc,ijglo,jpjzoom+1,njmpp+1,nlei,nlej
-
-               
-              !WRITE(*,*)"diadct readsec: ii: ",narea, jpt,iiglo,mig(1),mig(jpi),nlci
-              !WRITE(*,*)"diadct readsec: jj: ",narea, jpt,ijglo,mjg(1),mjg(jpj),nlcj
-              !WRITE(*,*)"diadct readsec: log: ",narea, iiglo .GE. mig(1),iiglo .LE. mig(1)+nlci-1 ,ijglo .GE. mjg(1),ijglo .LE. mjg(1)+nlcj-1  
-              !WRITE(*,*)"diadct readsec: log: ",narea, iiglo .GE. mig(1),iiglo .LE. mig(jpi),ijglo .GE. mjg(1),ijglo .LE. mjg(jpj)
+
               !verify if the point is on the local domain:(1,nlei)*(1,nlej)
               IF( iiloc .GE. 1 .AND. iiloc .LE. nlei .AND. &
-                  ijloc .GE. 1 .AND. ijloc .LE. nlej       )THEN
-              !IF( iiglo .GE. mig(1) .AND. iiglo .LE. mig(1)+nlci-1 .AND. &
-              !    ijglo .GE. mjg(1) .AND. ijglo .LE. mjg(1)+nlcj-1       )THEN
-                  
-                  
-              !IF( iiglo .GE. mig(1) .AND. iiglo .LE. mig(jpi) .AND. &
-              !    ijglo .GE. mjg(1) .AND. ijglo .LE. mjg(jpj)       )THEN
+              ijloc .GE. 1 .AND. ijloc .LE. nlej       )THEN
+
                   WRITE(*,*)"diadct readsec: assigned proc!",narea,nproc,jpt
                   
@@ -709,12 +650,7 @@
      ENDDO !end of the loop on jsec
      
-     !IF (lwp) write(numout,*) 'dct end of readsec loop, after exit'
- 
      nb_sec = jsec-1   !number of section read in the file
 
      CALL wrk_dealloc( nb_point_max, directemp )
-     
-     !IF (lwp) write(numout,*) 'dct after dealloc'
-     
      !
   END SUBROUTINE readsec
@@ -1150,6 +1086,4 @@
               END SELECT
 
-              !JT zfsdep= gdept(k%I,k%J,jk)
-              !JT zfsdep= gdept_0(k%I,k%J,jk)
               zfsdep= fsdept(k%I,k%J,jk)
  
@@ -1324,6 +1258,4 @@
               END SELECT
 
-              !JT zfsdep= gdept(k%I,k%J,jk)
-              !JT zfsdep= gdept_0(k%I,k%J,jk)
               zfsdep= fsdept(k%I,k%J,jk) 
  
@@ -1541,6 +1473,4 @@
               END SELECT
 
-              !JT zfsdep= gdept(k%I,k%J,jk)
-              !JT zfsdep= gdept_0(k%I,k%J,jk)
               zfsdep= fsdept(k%I,k%J,jk)
  
@@ -1686,8 +1616,13 @@
      INTEGER               :: jclass,ji             ! Dummy loop
      CHARACTER(len=2)      :: classe             ! Classname 
+     
      REAL(wp)              :: zbnd1,zbnd2        ! Class bounds
      REAL(wp)              :: zslope             ! section's slope coeff
      !
      REAL(wp), POINTER, DIMENSION(:):: zsumclasses ! 1D workspace 
+     CHARACTER(len=3)      :: noos_sect_name             ! Classname 
+     REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   noos_iom_dummy
+     INTEGER               :: IERR
+     
      !!------------------------------------------------------------- 
      
@@ -1713,14 +1648,209 @@
      zbnd1   = 0._wp
      zbnd2   = 0._wp
-
+     
+     
+     
+     write (noos_sect_name, "(I0.3)")  ksec
+     
+     !ALLOCATE( noos_iom_dummy(jpi,jpj,1),  STAT= ierr )
+     !   IF( ierr /= 0 )   CALL ctl_stop( 'dia_dct_wri_NOOS: failed to allocate noos_iom_dummy array' )
+        
+        
+!      ALLOCATE( noos_iom_dummy(jpi,jpj,9),  STAT= ierr )
+!         IF( ierr /= 0 )   CALL ctl_stop( 'dia_dct_wri_NOOS: failed to allocate noos_iom_dummy array' )
+
+     ALLOCATE( noos_iom_dummy(jpi,jpj,3),  STAT= ierr )
+        IF( ierr /= 0 )   CALL ctl_stop( 'dia_dct_wri_NOOS: failed to allocate noos_iom_dummy array' )
+        
+     
+
+     !IF( lwp ) THEN
+     !
+     !   WRITE(numout,*) "dia_dct_wri_NOOS: kt, jpi,jpj,3", kt, jpi,jpj,3
+     !
+     !ENDIF
      IF ( zslope .gt. 0._wp .and. zslope .ne. 10000._wp ) THEN
         WRITE(numdct_NOOS,'(9e12.4E2)') -(zsumclasses( 1)+zsumclasses( 2)), -zsumclasses( 2),-zsumclasses( 1),   &
                                         -(zsumclasses( 7)+zsumclasses( 8)), -zsumclasses( 8),-zsumclasses( 7),   &
                                         -(zsumclasses( 9)+zsumclasses(10)), -zsumclasses(10),-zsumclasses( 9)
+!          
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = -(zsumclasses( 1)+zsumclasses( 2))
+!          noos_iom_dummy(:,:,2) = -zsumclasses( 2)
+!          noos_iom_dummy(:,:,3) = -zsumclasses( 1)
+!          noos_iom_dummy(:,:,4) = -(zsumclasses( 7)+zsumclasses( 8))
+!          noos_iom_dummy(:,:,5) = -zsumclasses( 8)
+!          noos_iom_dummy(:,:,6) = -zsumclasses( 7)
+!          noos_iom_dummy(:,:,7) = -(zsumclasses( 9)+zsumclasses( 10))
+!          noos_iom_dummy(:,:,8) = -zsumclasses( 10)
+!          noos_iom_dummy(:,:,9) = -zsumclasses( 9)
+!          
+!          CALL iom_put( "noos_" // trim(noos_sect_name),  noos_iom_dummy )  
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+         
+         
+         
+         noos_iom_dummy(:,:,:) = 0.
+         
+         noos_iom_dummy(:,:,1) = -(zsumclasses( 1)+zsumclasses( 2))
+         noos_iom_dummy(:,:,2) = -zsumclasses( 2)
+         noos_iom_dummy(:,:,3) = -zsumclasses( 1)
+         !IF( lwp ) WRITE(numout,*) "dia_dct_wri_NOOS +ve : kt, trans", kt, &
+         !   & noos_iom_dummy(10,10,1), noos_iom_dummy(10,10,2), noos_iom_dummy(10,10,3)         
+      !CALL iom_put( "noos_" // trim(noos_sect_name) // '_trans',  noos_iom_dummy )
+         noos_iom_dummy(:,:,:) = 0.
+         
+         noos_iom_dummy(:,:,1) = -(zsumclasses( 7)+zsumclasses( 8))
+         noos_iom_dummy(:,:,2) = -zsumclasses( 8)
+         noos_iom_dummy(:,:,3) = -zsumclasses( 7)
+         !IF( lwp ) WRITE(numout,*) "dia_dct_wri_NOOS +ve : kt, heat", kt, &
+         !   & noos_iom_dummy(10,10,1), noos_iom_dummy(10,10,2), noos_iom_dummy(10,10,3)         
+      !CALL iom_put( "noos_" // trim(noos_sect_name) // '_heat',  noos_iom_dummy )
+         noos_iom_dummy(:,:,:) = 0.
+         
+         noos_iom_dummy(:,:,1) = -(zsumclasses( 9)+zsumclasses( 10))
+         noos_iom_dummy(:,:,2) = -zsumclasses( 10)
+         noos_iom_dummy(:,:,3) = -zsumclasses( 9)
+         !IF( lwp ) WRITE(numout,*) "dia_dct_wri_NOOS +ve : kt, salt", kt, &
+         !   & noos_iom_dummy(10,10,1), noos_iom_dummy(10,10,2), noos_iom_dummy(10,10,3)         
+      !CALL iom_put( "noos_" // trim(noos_sect_name) // '_salt',  noos_iom_dummy )
+         noos_iom_dummy(:,:,:) = 0.
+         
+         
+!          
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = -(zsumclasses( 1)+zsumclasses( 2))
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_trans_tot',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = -zsumclasses( 2)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_trans_pos',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = -zsumclasses( 1)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_trans_neg',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = -(zsumclasses( 7)+zsumclasses( 8))
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_heat_tot',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = -zsumclasses( 8)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_heat_pos',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = -zsumclasses( 7)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_heat_neg',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = -(zsumclasses( 9)+zsumclasses( 10))
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_salt_tot',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = -zsumclasses( 10)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_salt_pos',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = -zsumclasses( 9)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_salt_neg',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+         
+         
      ELSE
         WRITE(numdct_NOOS,'(9e12.4E2)')   zsumclasses( 1)+zsumclasses( 2) ,  zsumclasses( 1), zsumclasses( 2),   &
                                           zsumclasses( 7)+zsumclasses( 8) ,  zsumclasses( 7), zsumclasses( 8),   &
                                           zsumclasses( 9)+zsumclasses(10) ,  zsumclasses( 9), zsumclasses(10)
+                                          
+                                          
+                                          
+!                                           
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = (zsumclasses( 1)+zsumclasses( 2))
+!          noos_iom_dummy(:,:,2) = zsumclasses( 1)
+!          noos_iom_dummy(:,:,3) = zsumclasses( 2)
+!          noos_iom_dummy(:,:,4) = (zsumclasses( 7)+zsumclasses( 8))
+!          noos_iom_dummy(:,:,5) = zsumclasses( 7)
+!          noos_iom_dummy(:,:,6) = zsumclasses( 8)
+!          noos_iom_dummy(:,:,7) = (zsumclasses( 9)+zsumclasses( 10))
+!          noos_iom_dummy(:,:,8) = zsumclasses( 9)
+!          noos_iom_dummy(:,:,9) = zsumclasses( 10)
+!          
+!          CALL iom_put( "noos_" // trim(noos_sect_name),  noos_iom_dummy )  
+         
+         
+         
+         
+         noos_iom_dummy(:,:,1) = (zsumclasses( 1)+zsumclasses( 2))
+         noos_iom_dummy(:,:,2) = zsumclasses( 1)
+         noos_iom_dummy(:,:,3) = zsumclasses( 2)
+         !IF( lwp ) WRITE(numout,*) "dia_dct_wri_NOOS -ve : kt, trans", kt, &
+         !   & noos_iom_dummy(10,10,1), noos_iom_dummy(10,10,2), noos_iom_dummy(10,10,3)
+      !CALL iom_put( "noos_" // trim(noos_sect_name) // '_trans',  noos_iom_dummy )
+         noos_iom_dummy(:,:,:) = 0.
+         
+         noos_iom_dummy(:,:,1) = (zsumclasses( 7)+zsumclasses( 8))
+         noos_iom_dummy(:,:,2) = zsumclasses( 7)
+         noos_iom_dummy(:,:,3) = zsumclasses( 8)
+         !IF( lwp ) WRITE(numout,*) "dia_dct_wri_NOOS -ve : kt, heat", kt, &
+         !   & noos_iom_dummy(10,10,1), noos_iom_dummy(10,10,2), noos_iom_dummy(10,10,3)
+      !CALL iom_put( "noos_" // trim(noos_sect_name) // '_heat',  noos_iom_dummy )      
+         noos_iom_dummy(:,:,:) = 0.
+         
+         noos_iom_dummy(:,:,1) = (zsumclasses( 9)+zsumclasses( 10))
+         noos_iom_dummy(:,:,2) = zsumclasses( 9)
+         noos_iom_dummy(:,:,3) = zsumclasses( 10)
+         !IF( lwp ) WRITE(numout,*) "dia_dct_wri_NOOS -ve : kt, salt", kt, &
+         !   & noos_iom_dummy(10,10,1), noos_iom_dummy(10,10,2), noos_iom_dummy(10,10,3)
+      !CALL iom_put( "noos_" // trim(noos_sect_name) // '_salt',  noos_iom_dummy )
+         noos_iom_dummy(:,:,:) = 0.
+         
+!                                           
+!                                           
+!          
+!          noos_iom_dummy(:,:,1) = (zsumclasses( 1)+zsumclasses( 2))
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_trans_tot',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = zsumclasses( 1)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_trans_pos',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = zsumclasses( 2)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_trans_neg',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = (zsumclasses( 7)+zsumclasses( 8))
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_heat_tot',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = zsumclasses( 7)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_heat_pos',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = zsumclasses( 8)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_heat_neg',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = (zsumclasses( 9)+zsumclasses( 10))
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_salt_tot',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = zsumclasses( 9)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_salt_pos',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+!          
+!          noos_iom_dummy(:,:,1) = zsumclasses( 10)
+!          CALL iom_put( "noos_" // trim(noos_sect_name) // '_salt_neg',  noos_iom_dummy )
+!          noos_iom_dummy(:,:,:) = 0.
+         
      ENDIF 
+     
+     
+      DEALLOCATE(noos_iom_dummy)
 
      DO jclass=1,MAX(1,sec%nb_class-1)
@@ -1779,5 +1909,5 @@
      ENDDO
      
-     !CALL FLUSH(numdct_NOOS)
+     CALL FLUSH(numdct_NOOS)
 
      CALL wrk_dealloc(nb_type , zsumclasses )  
@@ -1810,4 +1940,8 @@
      !
      REAL(wp), POINTER, DIMENSION(:):: zsumclasses ! 1D workspace 
+     CHARACTER(len=3)      :: noos_sect_name             ! Classname 
+     REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   noos_iom_dummy
+     INTEGER               :: IERR
+     
      !!------------------------------------------------------------- 
 
@@ -1819,4 +1953,14 @@
      
      CALL wrk_alloc(nb_type , zsumclasses ) 
+     
+     
+     write (noos_sect_name, "(I03)")  ksec
+     
+     ALLOCATE( noos_iom_dummy(jpi,jpj),  STAT= ierr )
+        IF( ierr /= 0 )   CALL ctl_stop( 'dia_dct_wri_NOOS_h: failed to allocate noos_iom_dummy array' )
+
+
+
+     
 
      zsumclasses(:)=0._wp
@@ -1850,4 +1994,10 @@
 
      CALL wrk_dealloc(nb_type , zsumclasses )
+     
+     DEALLOCATE(noos_iom_dummy)
+
+
+
+
 
   END SUBROUTINE dia_dct_wri_NOOS_h
@@ -2069,5 +2219,4 @@
   REAL(wp):: zet1, zet2                                        ! weight for interpolation 
   REAL(wp):: zdep1,zdep2                                       ! differences of depth
-  REAL(wp):: zmsk                                              ! mask value
   !!----------------------------------------------------------------------
 
@@ -2078,5 +2227,4 @@
      zet1=e1t(ii1,ij1)
      zet2=e1t(ii2,ij2)
-     zmsk=umask(ii1,ij1,kk)
   
 
@@ -2087,5 +2235,4 @@
      zet1=e2t(ii1,ij1)
      zet2=e2t(ii2,ij2)
-     zmsk=vmask(ii1,ij1,kk)
 
   ENDIF
@@ -2102,5 +2249,4 @@
   
      ! result
-     !JT interp = zmsk * ( zwgt2 *  ptab(ii1,ij1,kk) + zwgt1 *  ptab(ii1,ij1,kk) ) / ( zwgt2 + zwgt1 )   
      interp = umask(ii1,ij1,kk) * ( zwgt2 *  ptab(ii1,ij1,kk) + zwgt1 *  ptab(ii1,ij1,kk) ) / ( zwgt2 + zwgt1 )   
 
@@ -2128,5 +2274,4 @@
            zbis = ptab(ii2,ij2,kk) + zwgt1 * ( ptab(ii2,ij2,kk-1) - ptab(ii2,ij2,kk) ) 
            ! result
-            !JT interp = zmsk * ( zet2 * ptab(ii1,ij1,kk) + zet1 * zbis )/( zet1 + zet2 )
             interp = umask(ii1,ij1,kk) * ( zet2 * ptab(ii1,ij1,kk) + zet1 * zbis )/( zet1 + zet2 )
         ELSE
@@ -2134,10 +2279,8 @@
            zbis = ptab(ii1,ij1,kk) + zwgt2 * ( ptab(ii1,ij1,kk-1) - ptab(ii1,ij2,kk) )
            ! result
-           !JT interp = zmsk * ( zet2 * zbis + zet1 * ptab(ii2,ij2,kk) )/( zet1 + zet2 )
            interp = umask(ii1,ij1,kk) * ( zet2 * zbis + zet1 * ptab(ii2,ij2,kk) )/( zet1 + zet2 )
         ENDIF    
 
      ELSE
-        !JT interp = zmsk * (  zet2 * ptab(ii1,ij1,kk) + zet1 * ptab(ii2,ij2,kk) )/( zet1 + zet2 )
         interp = umask(ii1,ij1,kk) * (  zet2 * ptab(ii1,ij1,kk) + zet1 * ptab(ii2,ij2,kk) )/( zet1 + zet2 )
      ENDIF
Index: /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diaregmean.F90
===================================================================
--- /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diaregmean.F90	(revision 7571)
+++ /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diaregmean.F90	(revision 7572)
@@ -14,5 +14,8 @@
    USE diapea          ! Top,middle,bottom output
    USE zdfmxl          ! MLD
-
+   USE sbc_oce
+#if defined key_diaar5 
+   USE diaar5
+#endif
    IMPLICIT NONE
    PRIVATE
@@ -31,4 +34,8 @@
    LOGICAL :: ln_diaregmean_bin  ! region mean calculation binary output
    LOGICAL :: ln_diaregmean_nc  ! region mean calculation netcdf output
+   LOGICAL :: ln_diaregmean_diaar5  ! region mean calculation including AR5 SLR terms
+   LOGICAL :: ln_diaregmean_diasbc  ! region mean calculation including Surface BC
+   LOGICAL :: ln_diaregmean_karamld  ! region mean calculation including kara mld terms
+   LOGICAL :: ln_diaregmean_pea  ! region mean calculation including pea terms
    
    REAL(wp), SAVE, ALLOCATABLE,   DIMENSION(:,:,:)  ::   tmp_region_mask_real   ! tempory region_mask of reals
@@ -38,5 +45,10 @@
    
    REAL(wp),  ALLOCATABLE,   DIMENSION(:,:,:) ::   tmp_field_mat !: temporary region_mask
+   REAL(wp),  ALLOCATABLE,   DIMENSION(:,:,:) ::   tmp_field_karamld_mat !: temporary region_mask
+   REAL(wp),  ALLOCATABLE,   DIMENSION(:,:,:) ::   tmp_field_pea_mat !: temporary region_mask
+   REAL(wp),  ALLOCATABLE,   DIMENSION(:,:,:) ::   tmp_field_AR5_mat !: temporary region_mask
+   REAL(wp),  ALLOCATABLE,   DIMENSION(:,:,:) ::   tmp_field_SBC_mat !: temporary region_mask
    INTEGER  ::   tmp_field_cnt                                   ! tmp_field_cnt integer
+   INTEGER  ::   num_reg_vars                                    ! number of vars in regions mean
    !!----------------------------------------------------------------------
    !! NEMO/OPA 3.6 , NEMO Consortium (2014)
@@ -68,5 +80,7 @@
       INTEGER               ::   zndims   ! number of dimensions in an array (i.e. 3, )
       !
-      NAMELIST/nam_diaregmean/ ln_diaregmean,ln_diaregmean_ascii,ln_diaregmean_bin,ln_diaregmean_nc
+      NAMELIST/nam_diaregmean/ ln_diaregmean,ln_diaregmean_ascii,ln_diaregmean_bin,ln_diaregmean_nc,&
+        & ln_diaregmean_karamld, ln_diaregmean_pea,ln_diaregmean_diaar5,ln_diaregmean_diasbc
+      
       
       ! read in Namelist. 
@@ -91,13 +105,44 @@
           WRITE(numout,*) 'Switch for regmean binary output (T) or not (F)  ln_diaregmean_bin  = ', ln_diaregmean_bin
           WRITE(numout,*) 'Switch for regmean netcdf output (T) or not (F)  ln_diaregmean_nc  = ', ln_diaregmean_nc
+          WRITE(numout,*) 'Switch for regmean kara mld terms (T) or not (F)  ln_diaregmean_karamld  = ', ln_diaregmean_karamld
+          WRITE(numout,*) 'Switch for regmean PEA terms (T) or not (F)  ln_diaregmean_pea  = ', ln_diaregmean_pea
+          WRITE(numout,*) 'Switch for regmean AR5 SLR terms (T) or not (F)  ln_diaregmean_diaar5  = ', ln_diaregmean_diaar5
+          WRITE(numout,*) 'Switch for regmean Surface forcing terms (T) or not (F)  ln_diaregmean_diasbc  = ', ln_diaregmean_diasbc
       ENDIF
       
-      !ALLOCATE( tmp_field_mat(jpi,jpj,9),  STAT= ierr )
-      !ALLOCATE( tmp_field_mat(jpi,jpj,7),  STAT= ierr ) !SS/NB/DT T/S, SSH
-      !ALLOCATE( tmp_field_mat(jpi,jpj,8),  STAT= ierr ) !SS/NB/DT T/S, SSH, MLD
-      ALLOCATE( tmp_field_mat(jpi,jpj,11),  STAT= ierr ) !SS/NB/DT T/S, SSH, MLD, PEA, PEAT, PEAS
+      num_reg_vars = 7
+      
+      ALLOCATE( tmp_field_mat(jpi,jpj,num_reg_vars),  STAT= ierr ) !SS/NB/DT T/S, SSH, MLD, PEA, PEAT, PEAS
           IF( ierr /= 0 )   CALL ctl_stop( 'tmp_field_mat: failed to allocate tmp_region_mask_real array' )
       tmp_field_mat(:,:,:) = 0.
       tmp_field_cnt = 0
+      
+      IF(ln_diaregmean_karamld) THEN   
+        ALLOCATE( tmp_field_karamld_mat(jpi,jpj,1),  STAT= ierr ) !SS/NB/DT T/S, SSH, MLD, PEA, PEAT, PEAS
+            IF( ierr /= 0 )   CALL ctl_stop( 'tmp_field_karamld_mat: failed to allocate tmp_region_mask_real array' )
+        tmp_field_karamld_mat(:,:,:) = 0.
+      ENDIF
+      
+      IF(ln_diaregmean_pea) THEN   
+        ALLOCATE( tmp_field_pea_mat(jpi,jpj,3),  STAT= ierr ) !SS/NB/DT T/S, SSH, MLD, PEA, PEAT, PEAS
+            IF( ierr /= 0 )   CALL ctl_stop( 'tmp_field_pea_mat: failed to allocate tmp_region_mask_real array' )
+        tmp_field_pea_mat(:,:,:) = 0.
+      ENDIF
+      
+      IF(ln_diaregmean_diaar5) THEN   
+        ALLOCATE( tmp_field_AR5_mat(jpi,jpj,4),  STAT= ierr ) !SS/NB/DT T/S, SSH, MLD, PEA, PEAT, PEAS
+            IF( ierr /= 0 )   CALL ctl_stop( 'tmp_field_AR5_mat: failed to allocate tmp_region_mask_real array' )
+        tmp_field_AR5_mat(:,:,:) = 0.
+      ENDIF
+      
+      IF(ln_diaregmean_diasbc) THEN   
+        ALLOCATE( tmp_field_SBC_mat(jpi,jpj,7),  STAT= ierr ) !SS/NB/DT T/S, SSH, MLD, PEA, PEAT, PEAS
+            IF( ierr /= 0 )   CALL ctl_stop( 'tmp_field_SBC_mat: failed to allocate tmp_region_mask_real array' )
+        tmp_field_SBC_mat(:,:,:) = 0.
+      ENDIF
+      
+      
+      
+      
       
       IF (ln_diaregmean) THEN
@@ -272,19 +317,34 @@
           tmp_field_mat(:,:,6) = tmp_field_mat(:,:,6) + zwtmbS(:,:,3)
           tmp_field_mat(:,:,7) = tmp_field_mat(:,:,7) + sshn(:,:)
-          tmp_field_mat(:,:,8) = tmp_field_mat(:,:,8) + hmld_kara(:,:)!hmlp(:,:)
-          tmp_field_mat(:,:,9) = tmp_field_mat(:,:,9) + pea(:,:)
-          tmp_field_mat(:,:,10) = tmp_field_mat(:,:,10) + peat(:,:)
-          tmp_field_mat(:,:,11) = tmp_field_mat(:,:,11) + peas(:,:)
-          
-          
-          !tmp_field_mat(:,:,1) = tmp_field_mat(:,:,1) + zwtmbT(:,:,1)
-          !tmp_field_mat(:,:,2) = tmp_field_mat(:,:,2) + zwtmbT(:,:,2)
-          !tmp_field_mat(:,:,3) = tmp_field_mat(:,:,3) + zwtmbT(:,:,3)
-          !tmp_field_mat(:,:,4) = tmp_field_mat(:,:,4) + zwtmbT(:,:,4)
-          !tmp_field_mat(:,:,5) = tmp_field_mat(:,:,5) + zwtmbS(:,:,1)
-          !tmp_field_mat(:,:,6) = tmp_field_mat(:,:,6) + zwtmbS(:,:,2)
-          !tmp_field_mat(:,:,7) = tmp_field_mat(:,:,7) + zwtmbS(:,:,3)
-          !tmp_field_mat(:,:,8) = tmp_field_mat(:,:,8) + zwtmbS(:,:,4)
-          !tmp_field_mat(:,:,9) = tmp_field_mat(:,:,9) + sshn(:,:)
+          
+          IF( ln_diaregmean_karamld  ) THEN
+            tmp_field_karamld_mat(:,:,1) = tmp_field_karamld_mat(:,:,1) + hmld_kara(:,:)!hmlp(:,:)
+          ENDIF
+          
+          IF( ln_diaregmean_pea  ) THEN
+            tmp_field_pea_mat(:,:,1) = tmp_field_pea_mat(:,:,1) + pea(:,:)
+            tmp_field_pea_mat(:,:,2) = tmp_field_pea_mat(:,:,2) + peat(:,:)
+            tmp_field_pea_mat(:,:,3) = tmp_field_pea_mat(:,:,3) + peas(:,:)
+          ENDIF
+          
+          
+          IF( ln_diaregmean_diaar5  ) THEN
+            tmp_field_AR5_mat(:,:,1) = tmp_field_AR5_mat(:,:,1) + sshsteric_mat(:,:)
+            tmp_field_AR5_mat(:,:,2) = tmp_field_AR5_mat(:,:,2) + sshthster_mat(:,:)
+            tmp_field_AR5_mat(:,:,3) = tmp_field_AR5_mat(:,:,3) + sshhlster_mat(:,:)
+            tmp_field_AR5_mat(:,:,4) = tmp_field_AR5_mat(:,:,4) + zbotpres_mat(:,:)
+          ENDIF
+          
+          IF( ln_diaregmean_diasbc  ) THEN
+          
+            tmp_field_SBC_mat(:,:,1) = tmp_field_SBC_mat(:,:,1) + ((qsr  + qns)*tmask(:,:,1))
+            tmp_field_SBC_mat(:,:,2) = tmp_field_SBC_mat(:,:,2) + (qsr*tmask(:,:,1))
+            tmp_field_SBC_mat(:,:,3) = tmp_field_SBC_mat(:,:,3) + (qns*tmask(:,:,1))
+            tmp_field_SBC_mat(:,:,4) = tmp_field_SBC_mat(:,:,4) + (emp*tmask(:,:,1))
+            tmp_field_SBC_mat(:,:,5) = tmp_field_SBC_mat(:,:,5) + (wndm*tmask(:,:,1))
+            tmp_field_SBC_mat(:,:,6) = tmp_field_SBC_mat(:,:,6) + (pressnow*tmask(:,:,1))
+            tmp_field_SBC_mat(:,:,7) = tmp_field_SBC_mat(:,:,7) + (rnf*tmask(:,:,1))
+            
+          ENDIF
           
           tmp_field_cnt = tmp_field_cnt + 1
@@ -292,23 +352,4 @@
           IF( MOD( kt, i_steps ) == 0  .and. kt .ne. nn_it000 ) THEN
 
-              
-              
-              !CALL dia_wri_region_mean(kt, "sst" , tmp_field_mat(:,:,1)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
-              !!CALL dia_wri_region_mean(kt, "mdt" , tmp_field_mat(:,:,2)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
-              !CALL dia_wri_region_mean(kt, "nbt" , tmp_field_mat(:,:,3)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
-              !CALL dia_wri_region_mean(kt, "dft" , tmp_field_mat(:,:,4)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
-!
-!              CALL dia_wri_region_mean(kt, "sss" , tmp_field_mat(:,:,5)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Salinity 
-!              !CALL dia_wri_region_mean(kt, "mds" , tmp_field_mat(:,:,6)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Salinity
-!              CALL dia_wri_region_mean(kt, "nbs" , tmp_field_mat(:,:,7)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Salinity
-!              CALL dia_wri_region_mean(kt, "dfs" , tmp_field_mat(:,:,8)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Salinity;
-!
-!              CALL dia_wri_region_mean(kt, "ssh" , tmp_field_mat(:,:,9)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
-              
-              
-
-              
-              
-              !CALL cpu_time(start_reg_mean_sub)
               
               CALL dia_wri_region_mean(kt, "sst" , tmp_field_mat(:,:,1)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
@@ -322,15 +363,46 @@
               CALL dia_wri_region_mean(kt, "ssh" , tmp_field_mat(:,:,7)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
               
-              CALL dia_wri_region_mean(kt, "mldkara" , tmp_field_mat(:,:,8)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
-
-              CALL dia_wri_region_mean(kt, "pea" , tmp_field_mat(:,:,9)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
-              CALL dia_wri_region_mean(kt, "peat" , tmp_field_mat(:,:,10)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
-              CALL dia_wri_region_mean(kt, "peas" , tmp_field_mat(:,:,11)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
-              
-              !CALL cpu_time(finish_reg_mean_sub)          
-              !WRITE(numout,'("kt = ",i05,";  Reg_mean_sub Time = ",f10.3," milliseconds: ",f6.3,";  ",f6.3)') &
-              !  & kt,(finish_reg_mean_sub-start_reg_mean_sub)*1000.,finish_reg_mean_sub,start_reg_mean_sub
-              
+              IF( ln_diaregmean_karamld  ) THEN
+              
+                  CALL dia_wri_region_mean(kt, "mldkara" , tmp_field_karamld_mat(:,:,1)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                  
+              ENDIF
+              
+              IF( ln_diaregmean_pea  ) THEN
+              
+                  CALL dia_wri_region_mean(kt, "pea"  , tmp_field_pea_mat(:,:,1)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                  CALL dia_wri_region_mean(kt, "peat" , tmp_field_pea_mat(:,:,2)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                  CALL dia_wri_region_mean(kt, "peas" , tmp_field_pea_mat(:,:,3)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                  
+              ENDIF
+              
+              IF( ln_diaregmean_diaar5  ) THEN
+              
+                CALL dia_wri_region_mean(kt, "ssh_steric" ,      tmp_field_AR5_mat(:,:,1)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                CALL dia_wri_region_mean(kt, "ssh_thermosteric", tmp_field_AR5_mat(:,:,2)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                CALL dia_wri_region_mean(kt, "ssh_halosteric" ,  tmp_field_AR5_mat(:,:,3)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                CALL dia_wri_region_mean(kt, "bot_pres" ,        tmp_field_AR5_mat(:,:,4)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                
+              ENDIF
+              
+              IF( ln_diaregmean_diasbc  ) THEN
+              
+                CALL dia_wri_region_mean(kt, "qt"   , tmp_field_SBC_mat(:,:,1)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                CALL dia_wri_region_mean(kt, "qsr"  , tmp_field_SBC_mat(:,:,2)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                CALL dia_wri_region_mean(kt, "qns"  , tmp_field_SBC_mat(:,:,3)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                CALL dia_wri_region_mean(kt, "emp"  , tmp_field_SBC_mat(:,:,4)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                CALL dia_wri_region_mean(kt, "wspd" , tmp_field_SBC_mat(:,:,5)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                CALL dia_wri_region_mean(kt, "mslp" , tmp_field_SBC_mat(:,:,6)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                CALL dia_wri_region_mean(kt, "rnf"  , tmp_field_SBC_mat(:,:,7)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
+                
+              ENDIF
+              
+              
+              IF( ln_diaregmean_karamld ) tmp_field_karamld_mat(:,:,:) = 0.
+              IF( ln_diaregmean_pea     ) tmp_field_pea_mat(:,:,:) = 0.
+              IF( ln_diaregmean_diaar5  ) tmp_field_AR5_mat(:,:,:) = 0.
+              IF( ln_diaregmean_diasbc  ) tmp_field_SBC_mat(:,:,:) = 0.
               tmp_field_mat(:,:,:) = 0.
+              
               tmp_field_cnt = 0
       
@@ -353,4 +425,8 @@
                   ENDIF
               DEALLOCATE( region_mask, nreg_mat, tmp_field_mat)
+              IF( ln_diaregmean_karamld ) DEALLOCATE( tmp_field_karamld_mat)
+              IF( ln_diaregmean_pea     ) DEALLOCATE( tmp_field_pea_mat)
+              IF( ln_diaregmean_diaar5  ) DEALLOCATE( tmp_field_AR5_mat)
+              IF( ln_diaregmean_diasbc  ) DEALLOCATE( tmp_field_SBC_mat)
               ENDIF
           ENDIF
@@ -382,5 +458,5 @@
       
       INTEGER, INTENT(in) ::   kt
-      CHARACTER (len=15) , INTENT(IN   ) ::    name
+      CHARACTER (len=60) , INTENT(IN   ) ::    name
       REAL(wp), DIMENSION(jpi, jpj), INTENT(IN   ) :: infield    ! Input 3d field and mask
       
@@ -399,5 +475,5 @@
       INTEGER  ::   ierr      
       REAL(wp)  :: tmpreal
-      CHARACTER(LEN=80) :: FormatString,nreg_string
+      CHARACTER(LEN=180) :: FormatString,nreg_string
       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   dummy_zrmet
       
@@ -408,19 +484,4 @@
       
       !Allocate output arrays for iomput, set to zmdi, and set a region counter = 1
-      
-      !ALLOCATE( zrmet_ave(jpi,jpj,n_regions_output),  STAT= ierr )
-      !  IF( ierr /= 0 )   CALL ctl_stop( 'dia_wri_region_mean: failed to allocate zrmet_ave array' )
-      !ALLOCATE( zrmet_tot(jpi,jpj,n_regions_output),  STAT= ierr )
-      !  IF( ierr /= 0 )   CALL ctl_stop( 'dia_wri_region_mean: failed to allocate zrmet_tot array' )
-      !ALLOCATE( zrmet_var(jpi,jpj,n_regions_output),  STAT= ierr )
-      !  IF( ierr /= 0 )   CALL ctl_stop( 'dia_wri_region_mean: failed to allocate zrmet_var array' )
-      !ALLOCATE( zrmet_cnt(jpi,jpj,n_regions_output),  STAT= ierr )
-      !  IF( ierr /= 0 )   CALL ctl_stop( 'dia_wri_region_mean: failed to allocate zrmet_cnt array' )
-      !ALLOCATE( zrmet_mask_id(jpi,jpj,n_regions_output),  STAT= ierr )
-      !  IF( ierr /= 0 )   CALL ctl_stop( 'dia_wri_region_mean: failed to allocate zrmet_mask_id array' )
-      !ALLOCATE( zrmet_reg_id(jpi,jpj,n_regions_output),  STAT= ierr )
-      !  IF( ierr /= 0 )   CALL ctl_stop( 'dia_wri_region_mean: failed to allocate zrmet_reg_id array' )
-      
-      
       ALLOCATE( zrmet_ave(n_regions_output),  STAT= ierr )
         IF( ierr /= 0 )   CALL ctl_stop( 'dia_wri_region_mean: failed to allocate zrmet_ave array' )
@@ -439,11 +500,4 @@
         IF( ierr /= 0 )   CALL ctl_stop( 'dia_wri_region_mean: failed to allocate zrmet_reg_id array' )
       
-      !zrmet_ave(:,:,:) = zmdi
-      !zrmet_tot(:,:,:) = zmdi
-      !zrmet_var(:,:,:) = zmdi
-      !zrmet_cnt(:,:,:) = zmdi
-      !zrmet_mask_id(:,:,:) = zmdi
-      !zrmet_reg_id(:,:,:) = zmdi
-      
       
       zrmet_ave(:) = zmdi
@@ -470,7 +524,4 @@
           ALLOCATE( tot_mat(nreg),      STAT= ierr )
           IF( ierr /= 0 )   CALL ctl_stop( 'dia_wri_region_mean: failed to allocate tot_mat array' )
-          !ALLOCATE( tot_mat_2(nreg),  STAT= ierr )
-          !IF( ierr /= 0 )   CALL ctl_stop( 'dia_wri_region_mean: failed to allocate tot_mat_2 array' )
-          
           ALLOCATE( num_mat(nreg),  STAT= ierr )
           IF( ierr /= 0 )   CALL ctl_stop( 'dia_wri_region_mean: failed to allocate num_mat array' )
@@ -511,56 +562,9 @@
               END DO
           END DO
-          !CALL cpu_time(finish_reg_mean_loop)          
-          !WRITE(numout,'("kt = ",i05,"; maskno = ",i02,";  Reg_mean_loop Time = ",f6.3," milliseconds.",f6.3,";, ",f6.3)') &
-          !      &  kt,maskno,(finish_reg_mean_loop-start_reg_mean_loop)*1000.,finish_reg_mean_loop,start_reg_mean_loop
-          
-          ! sum the totals, the counts, and the squares across the processors
-          !CALL cpu_time(start_reg_mean_mpp)
-          
-          
-          
-          !IF( lk_mpp ) THEN
-          !    DO jj = 1,nreg
-          !        tmpreal = tot_mat(jj)
-          !        CALL mpp_sum( tmpreal )
-          !        tot_mat(jj) = tmpreal
-          !        
-          !        tmpreal = ssq_mat(jj)
-          !        CALL mpp_sum( tmpreal )
-          !        ssq_mat(jj) = tmpreal
-          !        
-          !        tmpreal = cnt_mat(jj)
-          !        CALL mpp_sum( tmpreal )
-          !        cnt_mat(jj) = tmpreal
-          !    END DO
-          !ENDIF
-          
-          
-          
-          !if (lwp) WRITE(numout,*) "mpp_sum loop tot_mat",tot_mat
-          !CALL cpu_time(finish_reg_mean_mpp)          
-          !WRITE(numout,'("kt = ",i05,"; maskno = ",i02,";  Reg_mean_mpp Time = ",f6.3," milliseconds.",f6.3,";, ",f6.3)') &
-          !      &  kt,maskno,(finish_reg_mean_loop-start_reg_mean_mpp)*1000.,finish_reg_mean_mpp,start_reg_mean_mpp
-          
-          !DO jj = 1,nreg
-          !   tot_mat_2(jj) = tot_mat(jj)
-          !enddo
-          !CALL cpu_time( start_reg_mean_mpp_mat )
-          
-          
+          ! sum the totals, the counts, and the squares across the processors          
           CALL mpp_sum( tot_mat,nreg )
           CALL mpp_sum( ssq_mat,nreg )
           CALL mpp_sum( cnt_mat,nreg )
           
-          
-          
-          !CALL cpu_time(finish_reg_mean_mpp_mat)          
-          !WRITE(numout,'("kt = ",i05,"; maskno = ",i02,";  Reg_mean_mpp_mat Time = ",f6.3," milliseconds.",f6.3,";, ",f6.3)') &
-          !      &  kt,maskno,(finish_reg_mean_mpp_mat-start_reg_mean_mpp_mat)*1000.,finish_reg_mean_loop,start_reg_mean_mpp_mat
-                
-          
-          !DO jj = 1,nreg
-          !    WRITE(numout,*) "mpp_sum array tot_mat",jj,tot_mat(jj),ssq_mat(jj),cnt_mat(jj)
-          !enddo
           
           !calculate the mean and variance from the total, sum of squares and the count. 
@@ -608,11 +612,4 @@
               
               DO jm = 1,nreg
-                  !zrmet_ave(    :,:,reg_ind_cnt) =     ave_mat(jm)
-                  !zrmet_tot(    :,:,reg_ind_cnt) =     tot_mat(jm)
-                  !zrmet_var(    :,:,reg_ind_cnt) =     var_mat(jm)
-                  !zrmet_cnt(    :,:,reg_ind_cnt) =     cnt_mat(jm)
-                  !zrmet_reg_id( :,:,reg_ind_cnt) =  reg_id_mat(jm)
-                  !zrmet_mask_id(:,:,reg_ind_cnt) = mask_id_mat(jm)
-                  
                   zrmet_ave(    reg_ind_cnt) =     ave_mat(jm)
                   zrmet_tot(    reg_ind_cnt) =     tot_mat(jm)
@@ -637,11 +634,4 @@
       
       
-      
-          !CALL iom_put( "reg_" // trim(name) // '_ave', zrmet_ave )
-          !CALL iom_put( "reg_" // trim(name) // '_tot', zrmet_tot )
-          !CALL iom_put( "reg_" // trim(name) // '_var', zrmet_var )
-          !CALL iom_put( "reg_" // trim(name) // '_cnt', zrmet_cnt )
-          !CALL iom_put( "reg_" // trim(name) // '_reg_id', zrmet_reg_id )
-          !CALL iom_put( "reg_" // trim(name) // '_mask_id', zrmet_mask_id )
       
           DO jm = 1,n_regions_output
Index: /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 7571)
+++ /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 7572)
@@ -57,9 +57,6 @@
    
    
-   !JT REGION MEANS
-   !INTEGER , PUBLIC ::   n_regions_output = 100
    
    INTEGER , PUBLIC ::   n_regions_output
-   !JT REGION MEANS
    
    PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
@@ -116,6 +113,4 @@
       
       
-      !JT REGION MEANS
-      !! read namelist to see if the region mask code is called, if so read the region mask, and count the regions. 
       
       
@@ -133,8 +128,14 @@
       LOGICAL :: ln_diaregmean_bin  ! region mean calculation binary output
       LOGICAL :: ln_diaregmean_nc  ! region mean calculation netcdf output
+      LOGICAL :: ln_diaregmean_karamld  ! region mean calculation including kara mld terms
+      LOGICAL :: ln_diaregmean_pea  ! region mean calculation including pea terms
+      LOGICAL :: ln_diaregmean_diaar5  ! region mean calculation including AR5 SLR terms
+      LOGICAL :: ln_diaregmean_diasbc  ! region mean calculation including Surface BC
     
-      
-      
-      NAMELIST/nam_diaregmean/ ln_diaregmean,ln_diaregmean_ascii,ln_diaregmean_bin,ln_diaregmean_nc
+      ! Read the number region mask to work out how many regions are needed.
+      
+      NAMELIST/nam_diaregmean/ ln_diaregmean,ln_diaregmean_ascii,ln_diaregmean_bin,ln_diaregmean_nc,&
+        & ln_diaregmean_karamld, ln_diaregmean_pea,ln_diaregmean_diaar5,ln_diaregmean_diasbc
+      
       
       ! read in Namelist. 
@@ -187,9 +188,4 @@
       
       
-      !JT REGION MEANS
-      
-      
-      
-      
 #if ! defined key_xios2
       ALLOCATE( z_bnds(jpk,2) )
@@ -319,5 +315,8 @@
       CALL iom_set_axis_attr( "region", (/ (REAL(ji,wp), ji=1,n_regions_output) /) )
 
-      !CALL iom_set_axis_attr( "region", (/ (REAL(ji,wp), ji=1,100) /) )
+      !JT CALL iom_set_axis_attr( "noos", (/ (REAL(ji,wp), ji=1,9) /) )
+      !JT CALL iom_set_axis_attr( "noos", (/ (REAL(ji,wp), ji=1,1) /) )
+      !JT CALL iom_set_axis_attr( "noos", (/ (REAL(1,wp)) /) )
+      CALL iom_set_axis_attr( "noos", (/ (REAL(ji,wp), ji=1,3) /) )
 
       
