Index: /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90
===================================================================
--- /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 7592)
+++ /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diadct.F90	(revision 7593)
@@ -48,4 +48,5 @@
   USE timing          ! preformance summary
   USE wrk_nemo        ! working arrays
+  
 
   IMPLICIT NONE
@@ -66,4 +67,6 @@
   !! * Shared module variables
   LOGICAL, PUBLIC, PARAMETER ::   lk_diadct = .TRUE.   !: model-data diagnostics flag
+  LOGICAL, PUBLIC ::   ln_dct_calc_noos_25h !: Calcuate noos 25 h means
+  LOGICAL, PUBLIC ::   ln_dct_calc_noos_hr !: Calcuate noos hourly means
 
   !! * Module variables
@@ -150,5 +153,5 @@
      !!
      !!---------------------------------------------------------------------
-     NAMELIST/namdct/nn_dct,nn_dctwri,nn_secdebug
+     NAMELIST/namdct/nn_dct,nn_dctwri,nn_secdebug,ln_dct_calc_noos_25h,ln_dct_calc_noos_hr
      INTEGER  ::   ios                 ! Local integer output status for namelist read
 
@@ -175,4 +178,5 @@
         nn_dct=3600./rdt         ! hard coded for NOOS transects, to give 25 hour means 
         nn_dctwri=86400./rdt
+        
         nn_dct_h=1       ! hard coded for NOOS transects, to give hourly data
         nn_dctwri_h=3600./rdt
@@ -184,4 +188,6 @@
         WRITE(numout,*) "~~~~~~~~~~~~~~~~~~~~~"
         IF( ln_NOOS ) THEN
+           WRITE(numout,*) "       Calculate NOOS hourly output: ln_dct_calc_noos_hr = ",ln_dct_calc_noos_hr
+           WRITE(numout,*) "       Calculate NOOS 25 hour mean output: ln_dct_calc_noos_hr = ",ln_dct_calc_noos_25h
            WRITE(numout,*) "       Frequency of computation hard coded to be every hour: nn_dct    = ",nn_dct
            WRITE(numout,*) "       Frequency of write hard coded to average 25 instantaneous hour values: nn_dctwri = ",nn_dctwri
@@ -213,6 +219,6 @@
      IF( lwp ) THEN
         IF( ln_NOOS ) THEN
-           CALL ctl_opn( numdct_NOOS  ,'NOOS_transport'  , 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
-           CALL ctl_opn( numdct_NOOS_h,'NOOS_transport_h', 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
+           if ( ln_dct_calc_noos_25h ) CALL ctl_opn( numdct_NOOS  ,'NOOS_transport'  , 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
+           if ( ln_dct_calc_noos_hr ) CALL ctl_opn( numdct_NOOS_h,'NOOS_transport_h', 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
         ELSE
            CALL ctl_opn( numdct_vol , 'volume_transport', 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
@@ -264,10 +270,10 @@
      REAL(wp), POINTER, DIMENSION(:)    :: zwork    !   " 
      REAL(wp), POINTER, DIMENSION(:,:,:):: zsum     !   "
-
-
-
      !!---------------------------------------------------------------------    
      
      
+      
+        !i_steps = 1
+        
 
      
@@ -296,117 +302,133 @@
          WRITE(numout,*) "nb_class_max = ",nb_class_max
      ENDIF
-
- 
-     ! Compute transport and write only at nn_dctwri
-     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
-
-           lldebug=.FALSE.
-           IF( (jsec==nn_secdebug .OR. nn_secdebug==-1) .AND.  kt==nit000+nn_dct-1 .AND. lwp ) lldebug=.TRUE. 
-
-           !Compute transport through section  
-           CALL transport(secs(jsec),lldebug,jsec) 
-           
-
-        ENDDO
-             
-        IF( MOD(kt,nn_dctwri)==0 )THEN
-
-           IF( lwp .AND. kt==nit000+nn_dctwri-1 )WRITE(numout,*)"      diadct: average and write at kt = ",kt         
-  
-           !! divide arrays by nn_dctwri/nn_dct to obtain average
-           transports_3d(:,:,:,:)=transports_3d(:,:,:,:)/(nn_dctwri/nn_dct)
-           transports_2d(:,:,:)  =transports_2d(:,:,:)  /(nn_dctwri/nn_dct)
-
-           ! Sum over each class
-           DO jsec=1,nb_sec
-              CALL dia_dct_sum(secs(jsec),jsec)
-           ENDDO
- 
-           !Sum on all procs 
-           IF( lk_mpp )THEN
-              zsum(:,:,:)=0.0_wp
-              ish(1)  =  nb_sec_max*nb_type*nb_class_max 
-              ish2    = (/nb_sec_max,nb_type,nb_class_max/)
-              DO jsec=1,nb_sec ; zsum(jsec,:,:) = secs(jsec)%transport(:,:) ; ENDDO
-              zwork(:)= RESHAPE(zsum(:,:,:), ish )
-              CALL mpp_sum(zwork, ish(1))
-              zsum(:,:,:)= RESHAPE(zwork,ish2)
-              DO jsec=1,nb_sec ; secs(jsec)%transport(:,:) = zsum(jsec,:,:) ; ENDDO
-           ENDIF
-
-           !Write the transport
-           DO jsec=1,nb_sec
-
-              IF( lwp .and. .not. ln_NOOS )CALL dia_dct_wri(kt,jsec,secs(jsec))
-              IF( lwp .and.       ln_NOOS )CALL dia_dct_wri_NOOS(kt,jsec,secs(jsec))   ! use NOOS specific formatting
+    
+    
+    IF ( ln_dct_calc_noos_25h ) THEN
+ 
+        ! Compute transport and write only at nn_dctwri
+        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
             
             
-              !nullify transports values after writing
-              transports_3d(:,jsec,:,:)=0.0
-              transports_2d(:,jsec,:  )=0.0
-              secs(jsec)%transport(:,:)=0.  
-              IF ( ln_NOOS ) CALL transport(secs(jsec),lldebug,jsec)  ! reinitialise for next 25 hour instantaneous average (overlapping values)
-
-           ENDDO
-
-        ENDIF 
-
+
+            DO jsec=1,nb_sec
+
+              lldebug=.FALSE.
+              IF( (jsec==nn_secdebug .OR. nn_secdebug==-1) .AND.  kt==nit000+nn_dct-1 .AND. lwp ) lldebug=.TRUE. 
+
+              !Compute transport through section  
+              CALL transport(secs(jsec),lldebug,jsec) 
+              
+
+            ENDDO
+                
+            IF( MOD(kt,nn_dctwri)==0 )THEN
+            
+            
+
+              IF( lwp .AND. kt==nit000+nn_dctwri-1 )WRITE(numout,*)"      diadct: average and write at kt = ",kt         
+      
+              !! divide arrays by nn_dctwri/nn_dct to obtain average
+              transports_3d(:,:,:,:)=transports_3d(:,:,:,:)/(nn_dctwri/nn_dct)
+              transports_2d(:,:,:)  =transports_2d(:,:,:)  /(nn_dctwri/nn_dct)
+
+              ! Sum over each class
+              DO jsec=1,nb_sec
+                  CALL dia_dct_sum(secs(jsec),jsec)
+              ENDDO
+    
+              !Sum on all procs 
+              IF( lk_mpp )THEN
+                  zsum(:,:,:)=0.0_wp
+                  ish(1)  =  nb_sec_max*nb_type*nb_class_max 
+                  ish2    = (/nb_sec_max,nb_type,nb_class_max/)
+                  DO jsec=1,nb_sec ; zsum(jsec,:,:) = secs(jsec)%transport(:,:) ; ENDDO
+                  zwork(:)= RESHAPE(zsum(:,:,:), ish )
+                  CALL mpp_sum(zwork, ish(1))
+                  zsum(:,:,:)= RESHAPE(zwork,ish2)
+                  DO jsec=1,nb_sec ; secs(jsec)%transport(:,:) = zsum(jsec,:,:) ; ENDDO
+              ENDIF
+
+              !Write the transport
+              DO jsec=1,nb_sec
+
+                  IF( lwp .and. .not. ln_NOOS )CALL dia_dct_wri(kt,jsec,secs(jsec))
+                  !IF( lwp .and.       ln_NOOS )CALL dia_dct_wri_NOOS(kt,jsec,secs(jsec))   ! use NOOS specific formatting
+                  IF(  ln_NOOS )CALL dia_dct_wri_NOOS(kt,jsec,secs(jsec))   ! use NOOS specific formatting
+                
+                
+                  !nullify transports values after writing
+                  transports_3d(:,jsec,:,:)=0.0
+                  transports_2d(:,jsec,:  )=0.0
+                  secs(jsec)%transport(:,:)=0.  
+                  
+                  
+                  IF ( ln_NOOS ) CALL transport(secs(jsec),lldebug,jsec)  ! reinitialise for next 25 hour instantaneous average (overlapping values)
+
+
+
+              ENDDO
+
+            ENDIF 
+
+        ENDIF
+        
+    ENDIF
+    IF ( ln_dct_calc_noos_hr ) THEN
+        IF ( MOD(kt,nn_dct_h)==0 ) THEN            ! compute transport every nn_dct_h time steps
+
+            DO jsec=1,nb_sec
+
+              lldebug=.FALSE.
+              IF( (jsec==nn_secdebug .OR. nn_secdebug==-1) .AND.  kt==nit000+nn_dct_h-1 .AND. lwp ) lldebug=.TRUE. 
+
+              !Compute transport through section  
+              CALL transport_h(secs(jsec),lldebug,jsec) 
+
+            ENDDO
+                
+            IF( MOD(kt,nn_dctwri_h)==0 )THEN
+
+              IF( lwp .AND. kt==nit000+nn_dctwri_h-1 )WRITE(numout,*)"      diadct: average and write hourly files at kt = ",kt         
+      
+              !! divide arrays by nn_dctwri/nn_dct to obtain average
+              transports_3d_h(:,:,:,:)=transports_3d_h(:,:,:,:)/(nn_dctwri_h/nn_dct_h)
+              transports_2d_h(:,:,:)  =transports_2d_h(:,:,:)  /(nn_dctwri_h/nn_dct_h)
+
+              ! Sum over each class
+              DO jsec=1,nb_sec
+                  CALL dia_dct_sum_h(secs(jsec),jsec)
+              ENDDO
+
+              !Sum on all procs 
+              IF( lk_mpp )THEN
+                  ish(1)  =  nb_sec_max*nb_type*nb_class_max 
+                  ish2    = (/nb_sec_max,nb_type,nb_class_max/)
+                  DO jsec=1,nb_sec ; zsum(jsec,:,:) = secs(jsec)%transport_h(:,:) ; ENDDO
+                  zwork(:)= RESHAPE(zsum(:,:,:), ish )
+                  CALL mpp_sum(zwork, ish(1))
+                  zsum(:,:,:)= RESHAPE(zwork,ish2)
+                  DO jsec=1,nb_sec ; secs(jsec)%transport_h(:,:) = zsum(jsec,:,:) ; ENDDO
+              ENDIF
+
+              !Write the transport
+              DO jsec=1,nb_sec
+
+                  IF( lwp .and. ln_NOOS ) THEN
+                    CALL dia_dct_wri_NOOS_h(kt/nn_dctwri_h,jsec,secs(jsec))   ! use NOOS specific formatting
+                  endif
+                  !nullify transports values after writing
+                  transports_3d_h(:,jsec,:,:)=0.0
+                  transports_2d_h(:,jsec,:)=0.0
+                  secs(jsec)%transport_h(:,:)=0.  
+                  IF ( ln_NOOS ) CALL transport_h(secs(jsec),lldebug,jsec)  ! reinitialise for next 25 hour instantaneous average (overlapping values)
+
+              ENDDO
+
+            ENDIF 
+
+        ENDIF    
+        
      ENDIF
-     IF ( MOD(kt,nn_dct_h)==0 ) THEN            ! compute transport every nn_dct_h time steps
-
-        DO jsec=1,nb_sec
-
-           lldebug=.FALSE.
-           IF( (jsec==nn_secdebug .OR. nn_secdebug==-1) .AND.  kt==nit000+nn_dct_h-1 .AND. lwp ) lldebug=.TRUE. 
-
-           !Compute transport through section  
-           CALL transport_h(secs(jsec),lldebug,jsec) 
-
-        ENDDO
-             
-        IF( MOD(kt,nn_dctwri_h)==0 )THEN
-
-           IF( lwp .AND. kt==nit000+nn_dctwri_h-1 )WRITE(numout,*)"      diadct: average and write hourly files at kt = ",kt         
-  
-           !! divide arrays by nn_dctwri/nn_dct to obtain average
-           transports_3d_h(:,:,:,:)=transports_3d_h(:,:,:,:)/(nn_dctwri_h/nn_dct_h)
-           transports_2d_h(:,:,:)  =transports_2d_h(:,:,:)  /(nn_dctwri_h/nn_dct_h)
-
-           ! Sum over each class
-           DO jsec=1,nb_sec
-              CALL dia_dct_sum_h(secs(jsec),jsec)
-           ENDDO
- 
-           !Sum on all procs 
-          IF( lk_mpp )THEN
-              ish(1)  =  nb_sec_max*nb_type*nb_class_max 
-              ish2    = (/nb_sec_max,nb_type,nb_class_max/)
-              DO jsec=1,nb_sec ; zsum(jsec,:,:) = secs(jsec)%transport_h(:,:) ; ENDDO
-              zwork(:)= RESHAPE(zsum(:,:,:), ish )
-              CALL mpp_sum(zwork, ish(1))
-              zsum(:,:,:)= RESHAPE(zwork,ish2)
-              DO jsec=1,nb_sec ; secs(jsec)%transport_h(:,:) = zsum(jsec,:,:) ; ENDDO
-           ENDIF
-
-           !Write the transport
-           DO jsec=1,nb_sec
-
-              IF( lwp .and. ln_NOOS ) THEN
-                CALL dia_dct_wri_NOOS_h(kt/nn_dctwri_h,jsec,secs(jsec))   ! use NOOS specific formatting
-              endif
-              !nullify transports values after writing
-              transports_3d_h(:,jsec,:,:)=0.0
-              transports_2d_h(:,jsec,:)=0.0
-              secs(jsec)%transport_h(:,:)=0.  
-              IF ( ln_NOOS ) CALL transport_h(secs(jsec),lldebug,jsec)  ! reinitialise for next 25 hour instantaneous average (overlapping values)
-
-           ENDDO
-
-        ENDIF 
-
-     ENDIF    
 
      IF( lk_mpp )THEN
@@ -476,5 +498,5 @@
 
         IF ( lwp .AND. ( jsec==nn_secdebug .OR. nn_secdebug==-1 ) ) &
-           & WRITE(numout,*)'debuging for section number: ',jsec 
+           & WRITE(numout,*)'debugging for section number: ',jsec 
 
         !initialization
@@ -1622,4 +1644,5 @@
      REAL(wp), POINTER, DIMENSION(:):: zsumclasses ! 1D workspace 
      CHARACTER(len=3)      :: noos_sect_name             ! Classname 
+     CHARACTER(len=25)      :: noos_var_sect_name
      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   noos_iom_dummy
      INTEGER               :: IERR
@@ -1639,6 +1662,7 @@
      zslope = sec%slopeSection       
 
-     WRITE(numdct_NOOS,'(I4,a1,I2,a1,I2,a12,i3,a17,i3,a10,a25)') nyear,'.',nmonth,'.',nday,'   Transect:',ksec-1,'   No. of layers:',sec%nb_class-1,'   Name: ',sec%name
-
+     IF( lwp ) THEN
+       WRITE(numdct_NOOS,'(I4,a1,I2,a1,I2,a12,i3,a17,i3,a10,a25)') nyear,'.',nmonth,'.',nday,'   Transect:',ksec-1,'   No. of layers:',sec%nb_class-1,'   Name: ',sec%name
+     ENDIF   
      DO jclass=1,MAX(1,sec%nb_class-1)
         zsumclasses(1:nb_type)=zsumclasses(1:nb_type)+sec%transport(1:nb_type,jclass)
@@ -1653,11 +1677,4 @@
      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' )
@@ -1665,31 +1682,12 @@
      
 
-     !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
+     
+     IF( lwp ) 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.
-!          
-         
-         
+    endif
+
          
          noos_iom_dummy(:,:,:) = 0.
@@ -1698,7 +1696,8 @@
          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_var_sect_name = "noos_" // trim(noos_sect_name) // '_trans'
+         if ( lwp ) WRITE(numout,*) 'dia_dct_wri_NOOS iom_put: ', kt,ksec, noos_var_sect_name
+      CALL iom_put( noos_var_sect_name,  noos_iom_dummy )
          noos_iom_dummy(:,:,:) = 0.
          
@@ -1706,7 +1705,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_var_sect_name =  "noos_" // trim(noos_sect_name) // '_heat'
+         if ( lwp ) WRITE(numout,*) 'dia_dct_wri_NOOS iom_put: ', kt,ksec, noos_var_sect_name
+      CALL iom_put( noos_var_sect_name,  noos_iom_dummy )
          noos_iom_dummy(:,:,:) = 0.
          
@@ -1714,82 +1714,24 @@
          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_var_sect_name =  "noos_" // trim(noos_sect_name) // '_salt'
+         if ( lwp ) WRITE(numout,*) 'dia_dct_wri_NOOS iom_put: ', kt,ksec, noos_var_sect_name
+      CALL iom_put( noos_var_sect_name,  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)
+      IF( lwp ) THEN
+          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)
+      endif
                                           
-                                          
-                                          
-!                                           
-!          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_var_sect_name = "noos_" // trim(noos_sect_name) // '_trans'
+         if ( lwp ) WRITE(numout,*) 'dia_dct_wri_NOOS iom_put: ', kt,ksec, noos_var_sect_name
+      CALL iom_put( noos_var_sect_name,  noos_iom_dummy )
          noos_iom_dummy(:,:,:) = 0.
          
@@ -1797,7 +1739,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_var_sect_name =  "noos_" // trim(noos_sect_name) // '_heat'
+         if ( lwp ) WRITE(numout,*) 'dia_dct_wri_NOOS iom_put: ', kt,ksec, noos_var_sect_name
+      CALL iom_put(noos_var_sect_name,  noos_iom_dummy )      
          noos_iom_dummy(:,:,:) = 0.
          
@@ -1805,52 +1748,14 @@
          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_var_sect_name = "noos_" // trim(noos_sect_name) // '_salt'
+         if ( lwp ) WRITE(numout,*) 'dia_dct_wri_NOOS iom_put: ', kt,ksec, noos_var_sect_name
+      CALL iom_put(noos_var_sect_name,  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)
+     DEALLOCATE(noos_iom_dummy)
 
      DO jclass=1,MAX(1,sec%nb_class-1)
@@ -1897,17 +1802,20 @@
                   
         !write volume transport per class
-        IF ( zslope .gt. 0._wp .and. zslope .ne. 10000._wp ) THEN
-           WRITE(numdct_NOOS,'(9e12.4E2)') -(sec%transport( 1,jclass)+sec%transport( 2,jclass)),-sec%transport( 2,jclass),-sec%transport( 1,jclass), &
-                                           -(sec%transport( 7,jclass)+sec%transport( 8,jclass)),-sec%transport( 8,jclass),-sec%transport( 7,jclass), &
-                                           -(sec%transport( 9,jclass)+sec%transport(10,jclass)),-sec%transport(10,jclass),-sec%transport( 9,jclass)
-        ELSE
-           WRITE(numdct_NOOS,'(9e12.4E2)')   sec%transport( 1,jclass)+sec%transport( 2,jclass) , sec%transport( 1,jclass), sec%transport( 2,jclass), &
-                                             sec%transport( 7,jclass)+sec%transport( 8,jclass) , sec%transport( 7,jclass), sec%transport( 8,jclass), &
-                                             sec%transport( 9,jclass)+sec%transport(10,jclass) , sec%transport( 9,jclass), sec%transport(10,jclass)
+        
+        IF( lwp ) THEN
+            IF ( zslope .gt. 0._wp .and. zslope .ne. 10000._wp ) THEN
+              WRITE(numdct_NOOS,'(9e12.4E2)') -(sec%transport( 1,jclass)+sec%transport( 2,jclass)),-sec%transport( 2,jclass),-sec%transport( 1,jclass), &
+                                              -(sec%transport( 7,jclass)+sec%transport( 8,jclass)),-sec%transport( 8,jclass),-sec%transport( 7,jclass), &
+                                              -(sec%transport( 9,jclass)+sec%transport(10,jclass)),-sec%transport(10,jclass),-sec%transport( 9,jclass)
+            ELSE
+              WRITE(numdct_NOOS,'(9e12.4E2)')   sec%transport( 1,jclass)+sec%transport( 2,jclass) , sec%transport( 1,jclass), sec%transport( 2,jclass), &
+                                                sec%transport( 7,jclass)+sec%transport( 8,jclass) , sec%transport( 7,jclass), sec%transport( 8,jclass), &
+                                                sec%transport( 9,jclass)+sec%transport(10,jclass) , sec%transport( 9,jclass), sec%transport(10,jclass)
+            ENDIF
         ENDIF
 
      ENDDO
      
-     CALL FLUSH(numdct_NOOS)
+     if ( lwp ) CALL FLUSH(numdct_NOOS)
 
      CALL wrk_dealloc(nb_type , zsumclasses )  
@@ -1929,5 +1837,5 @@
      !!------------------------------------------------------------- 
      !!arguments
-     INTEGER, INTENT(IN)          :: hr          ! hour
+     INTEGER, INTENT(IN)          :: hr          ! hour => effectively kt/12
      TYPE(SECTION), INTENT(INOUT) :: sec         ! section to write   
      INTEGER ,INTENT(IN)          :: ksec        ! section number
@@ -1941,5 +1849,6 @@
      REAL(wp), POINTER, DIMENSION(:):: zsumclasses ! 1D workspace 
      CHARACTER(len=3)      :: noos_sect_name             ! Classname 
-     REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   noos_iom_dummy
+     CHARACTER(len=25)      :: noos_var_sect_name
+     REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   noos_iom_dummy
      INTEGER               :: IERR
      
@@ -1957,5 +1866,5 @@
      write (noos_sect_name, "(I03)")  ksec
      
-     ALLOCATE( noos_iom_dummy(jpi,jpj),  STAT= ierr )
+     ALLOCATE( noos_iom_dummy(jpi,jpj,3),  STAT= ierr )
         IF( ierr /= 0 )   CALL ctl_stop( 'dia_dct_wri_NOOS_h: failed to allocate noos_iom_dummy array' )
 
Index: /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diaregmean.F90
===================================================================
--- /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diaregmean.F90	(revision 7592)
+++ /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/DIA/diaregmean.F90	(revision 7593)
@@ -24,6 +24,4 @@
    PUBLIC   dia_regmean_init            ! routine called by nemogcm.F90
    PUBLIC   dia_regmean                 ! routine called by diawri.F90
-   !PUBLIC   dia_wri_region_mean         
-   !PUBLIC   dia_calctmb_region_mean
    
    
@@ -45,10 +43,7 @@
    
    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)
@@ -111,22 +106,10 @@
       ENDIF
       
-      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
+      
+      !ALLOCATE( tmp_field_mat(jpi,jpj,7),  STAT= ierr ) !SS/NB/DT T/S, SSH, MLD, PEA, PEAT, PEAS
+      ALLOCATE( tmp_field_mat(jpi,jpj,11),  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   
@@ -142,12 +125,6 @@
       ENDIF
       
-      
-      
-      
-      
       IF (ln_diaregmean) THEN
       
-      
-         
           ! Open region mask for region means, and retrieve the size of the mask (number of levels)          
           CALL iom_open ( 'region_mask.nc', inum )
@@ -284,58 +261,57 @@
       INTEGER                          ::   i_steps, ierr         ! no of timesteps per hour, allocation error index
       INTEGER                          ::   maskno,jj,ji,jm,nreg ! indices of mask, i and j, and number of regions
-      REAL(wp)                         ::   start_reg_mean_sub,finish_reg_mean_sub
       
       zmdi=1.e+20 !missing data indicator for maskin
 
       IF (ln_diaregmean) THEN
-          ! If regional mean calculations required by namelist
-          ! -----------------
-          ! identify hourly time steps (not used)
-          zdt = rdt
-          IF( nacc == 1 ) zdt = rdtmin
-
-          IF( MOD( 3600,INT(zdt) ) == 0 ) THEN
-              i_steps = 3600/INT(zdt)
-          ELSE
-              CALL ctl_stop('STOP', 'dia_regmean: timestep must give MOD(3600,rdt) = 0 otherwise no hourly values are possible')
-          ENDIF
-          
-          !i_steps = 1
-          
-          !Extract 2d fields from 3d T and S with dia_calctmb_region_mean
-          CALL wrk_alloc( jpi , jpj, 3 , zwtmbT )
-          CALL wrk_alloc( jpi , jpj, 3 , zwtmbS )
-              
-          CALL dia_calctmb_region_mean(  tsn(:,:,:,jp_tem),zwtmbT)
-          CALL dia_calctmb_region_mean(  tsn(:,:,:,jp_sal),zwtmbS)
-              
-          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) + zwtmbS(:,:,1)
-          tmp_field_mat(:,:,5) = tmp_field_mat(:,:,5) + zwtmbS(:,:,2)
-          tmp_field_mat(:,:,6) = tmp_field_mat(:,:,6) + zwtmbS(:,:,3)
-          tmp_field_mat(:,:,7) = tmp_field_mat(:,:,7) + 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
-          
+        ! If regional mean calculations required by namelist
+        ! -----------------
+        ! identify hourly time steps (not used)
+        zdt = rdt
+        IF( nacc == 1 ) zdt = rdtmin
+
+        IF( MOD( 3600,INT(zdt) ) == 0 ) THEN
+            i_steps = 3600/INT(zdt)
+        ELSE
+            CALL ctl_stop('STOP', 'dia_regmean: timestep must give MOD(3600,rdt) = 0 otherwise no hourly values are possible')
+        ENDIF
+        
+        !i_steps = 1
+        
+        !Extract 2d fields from 3d T and S with dia_calctmb_region_mean
+        CALL wrk_alloc( jpi , jpj, 3 , zwtmbT )
+        CALL wrk_alloc( jpi , jpj, 3 , zwtmbS )
+            
+        CALL dia_calctmb_region_mean(  tsn(:,:,:,jp_tem),zwtmbT)
+        CALL dia_calctmb_region_mean(  tsn(:,:,:,jp_sal),zwtmbS)
+            
+          tmp_field_mat(:,:,1) = tmp_field_mat(:,:,1) + (zwtmbT(:,:,1)*tmask(:,:,1))
+          tmp_field_mat(:,:,2) = tmp_field_mat(:,:,2) + (zwtmbT(:,:,2)*tmask(:,:,1))
+          tmp_field_mat(:,:,3) = tmp_field_mat(:,:,3) + (zwtmbT(:,:,3)*tmask(:,:,1))
+          tmp_field_mat(:,:,4) = tmp_field_mat(:,:,4) + (zwtmbS(:,:,1)*tmask(:,:,1))
+          tmp_field_mat(:,:,5) = tmp_field_mat(:,:,5) + (zwtmbS(:,:,2)*tmask(:,:,1))
+          tmp_field_mat(:,:,6) = tmp_field_mat(:,:,6) + (zwtmbS(:,:,3)*tmask(:,:,1))
+          tmp_field_mat(:,:,7) = tmp_field_mat(:,:,7) + (sshn(:,:)*tmask(:,:,1))
+        
+        
+        IF( ln_diaregmean_karamld  ) THEN
+          tmp_field_mat(:,:,8) = tmp_field_mat(:,:,8) + (hmld_kara(:,:)*tmask(:,:,1)) !hmlp(:,:)
+        ENDIF
+        IF( ln_diaregmean_pea  ) THEN
+          tmp_field_mat(:,:,9) = tmp_field_mat(:,:,9) + (pea(:,:)*tmask(:,:,1))
+          tmp_field_mat(:,:,10) = tmp_field_mat(:,:,10) + (peat(:,:)*tmask(:,:,1))
+          tmp_field_mat(:,:,11) = tmp_field_mat(:,:,11) + (peas(:,:)*tmask(:,:,1))
+        ENDIF
+          
+        IF( ln_diaregmean_diaar5  ) THEN
+            tmp_field_AR5_mat(:,:,1) = tmp_field_AR5_mat(:,:,1) + (sshsteric_mat(:,:)*tmask(:,:,1))
+            tmp_field_AR5_mat(:,:,2) = tmp_field_AR5_mat(:,:,2) + (sshthster_mat(:,:)*tmask(:,:,1))
+            tmp_field_AR5_mat(:,:,3) = tmp_field_AR5_mat(:,:,3) + (sshhlster_mat(:,:)*tmask(:,:,1))
+            tmp_field_AR5_mat(:,:,4) = tmp_field_AR5_mat(:,:,4) + (zbotpres_mat(:,:)*tmask(:,:,1))
+
+        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))
@@ -345,94 +321,84 @@
             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
+        
+        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))
+          CALL dia_wri_region_mean(kt, "nbt" , tmp_field_mat(:,:,2)/real(tmp_field_cnt,wp))
+          CALL dia_wri_region_mean(kt, "dft" , tmp_field_mat(:,:,3)/real(tmp_field_cnt,wp))
+
+          CALL dia_wri_region_mean(kt, "sss" , tmp_field_mat(:,:,4)/real(tmp_field_cnt,wp))
+          CALL dia_wri_region_mean(kt, "nbs" , tmp_field_mat(:,:,5)/real(tmp_field_cnt,wp))
+          CALL dia_wri_region_mean(kt, "dfs" , tmp_field_mat(:,:,6)/real(tmp_field_cnt,wp))
+
+          CALL dia_wri_region_mean(kt, "ssh" , tmp_field_mat(:,:,7)/real(tmp_field_cnt,wp))
+          
+          
+        IF( ln_diaregmean_karamld  ) THEN
+          
+          CALL dia_wri_region_mean(kt, "mldkara" , tmp_field_mat(:,:,8)/real(tmp_field_cnt,wp)) ! tm
+        ENDIF
+        IF( ln_diaregmean_pea  ) THEN
+          
+          CALL dia_wri_region_mean(kt, "pea"  , tmp_field_mat(:,:,9)/real(tmp_field_cnt,wp))
+          CALL dia_wri_region_mean(kt, "peat" , tmp_field_mat(:,:,10)/real(tmp_field_cnt,wp))
+          CALL dia_wri_region_mean(kt, "peas" , tmp_field_mat(:,:,11)/real(tmp_field_cnt,wp)) ! tmb
+        ENDIF
+          
+          tmp_field_mat(:,:,:) = 0.
+          
+          IF( ln_diaregmean_diaar5  ) THEN
+          
+            CALL dia_wri_region_mean(kt, "ssh_steric" ,      tmp_field_AR5_mat(:,:,1)/real(tmp_field_cnt,wp))
+            CALL dia_wri_region_mean(kt, "ssh_thermosteric", tmp_field_AR5_mat(:,:,2)/real(tmp_field_cnt,wp))
+            CALL dia_wri_region_mean(kt, "ssh_halosteric" ,  tmp_field_AR5_mat(:,:,3)/real(tmp_field_cnt,wp))
+            CALL dia_wri_region_mean(kt, "bot_pres" ,        tmp_field_AR5_mat(:,:,4)/real(tmp_field_cnt,wp))
+            tmp_field_AR5_mat(:,:,:) = 0.
+          ENDIF
+          
+          IF( ln_diaregmean_diasbc  ) THEN
+          
+            CALL dia_wri_region_mean(kt, "qt"   , tmp_field_SBC_mat(:,:,1)/real(tmp_field_cnt,wp))
+            CALL dia_wri_region_mean(kt, "qsr"  , tmp_field_SBC_mat(:,:,2)/real(tmp_field_cnt,wp))
+            CALL dia_wri_region_mean(kt, "qns"  , tmp_field_SBC_mat(:,:,3)/real(tmp_field_cnt,wp))
+            CALL dia_wri_region_mean(kt, "emp"  , tmp_field_SBC_mat(:,:,4)/real(tmp_field_cnt,wp))
+            CALL dia_wri_region_mean(kt, "wspd" , tmp_field_SBC_mat(:,:,5)/real(tmp_field_cnt,wp))
+            CALL dia_wri_region_mean(kt, "mslp" , tmp_field_SBC_mat(:,:,6)/real(tmp_field_cnt,wp))
+            CALL dia_wri_region_mean(kt, "rnf"  , tmp_field_SBC_mat(:,:,7)/real(tmp_field_cnt,wp))
+            tmp_field_SBC_mat(:,:,:) = 0.
+          ENDIF
+          
+          tmp_field_cnt = 0
+  
+        ENDIF
+        
+        
+        ! If on the last time step, close binary and ascii files. 
+        IF( kt == nitend ) THEN
+          IF(lwp) THEN
+            IF ( ln_diaregmean_bin ) THEN
+              !Closing binary files for regional mean time series.
+              CLOSE(73)
+            ENDIF
+            IF ( ln_diaregmean_ascii ) THEN
+              !Closing text files for regional mean time series.
+              CLOSE(37)
+            ENDIF
             
+            DEALLOCATE( region_mask, nreg_mat, tmp_field_mat)
+            IF( ln_diaregmean_diaar5  ) DEALLOCATE( tmp_field_AR5_mat)
+            IF( ln_diaregmean_diasbc  ) DEALLOCATE( tmp_field_SBC_mat)
           ENDIF
-          
-          tmp_field_cnt = tmp_field_cnt + 1
-          
-          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, "nbt" , 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, "dft" , 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, "sss" , tmp_field_mat(:,:,4)/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(:,:,5)/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(:,:,6)/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(:,:,7)/real(tmp_field_cnt,wp))!,region_mask,nreg_mat(:,:,maskno),maskno,nreg_mat(maskno)  )    ! tmb Temperature
-              
-              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
-      
-          ENDIF
-          
-          
-          
-          
-          
-          ! If on the last time step, close binary and ascii files. 
-          IF( kt == nitend ) THEN
-              IF(lwp) THEN
-                  IF ( ln_diaregmean_bin ) THEN
-                      !Closing binary files for regional mean time series.
-                      CLOSE(73)
-                  ENDIF
-                  IF ( ln_diaregmean_ascii ) THEN
-                      !Closing text files for regional mean time series.
-                      CLOSE(37)
-                  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
-            
+        ENDIF
+          
           
       ELSE
-          CALL ctl_warn('dia_regmean: regmean diagnostic is set to false you should not have seen this')
+        CALL ctl_warn('dia_regmean: regmean diagnostic is set to false you should not have seen this')
       ENDIF
       
@@ -466,6 +432,5 @@
       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   zrmet_out
       REAL(wp), ALLOCATABLE,   DIMENSION(:) ::   ave_mat,tot_mat,num_mat,var_mat,ssq_mat,cnt_mat,reg_id_mat,mask_id_mat   !: region_mask
-      !REAL(wp), ALLOCATABLE,   DIMENSION(:) ::   tot_mat_2
-      !REAL(wp), ALLOCATABLE,   DIMENSION(:) ::      !: region_mask
+      
       REAL(wp)                         ::   zmdi      ! set masked values
       INTEGER :: maskno,nreg  ! ocean time-step indexocean time step            
@@ -477,8 +442,4 @@
       CHARACTER(LEN=180) :: FormatString,nreg_string
       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   dummy_zrmet
-      
-      !REAL(wp) ::     start_reg_mean_loop,finish_reg_mean_loop,start_reg_mean_mpp, finish_reg_mean_mpp,start_reg_mean_mpp_mat,finish_reg_mean_mpp_mat
-      
-      
       zmdi=1.e+20 !missing data indicator for maskin
       
@@ -545,5 +506,4 @@
           reg_id_mat(:) = 0.
           mask_id_mat(:) = 0.
-          
           
           ! loop though the array. for each sea grid box where tmask == 1), 
@@ -599,6 +559,6 @@
 
                   WRITE(nreg_string, "(I5)") nreg
-                  FormatString = "(A11,"//trim(nreg_string)//"F15.3)"
-                  WRITE(37, FMT="(A4,I6,I6)") name,kt,maskno            
+                  FormatString = "(A17,"//trim(nreg_string)//"F15.3)"
+                  WRITE(37, FMT="(A17,I6,I6)") name,kt,maskno            
                   WRITE(37, FMT=trim(FormatString)) trim(name)//" "//"ave_mat:", ave_mat
                   WRITE(37, FMT=trim(FormatString)) trim(name)//" "//"tot_mat:", tot_mat
Index: /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 7592)
+++ /branches/UKMO/CO6_shelfclimate/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 7593)
@@ -180,6 +180,4 @@
           
         
-        WRITE(numout,*)  'IOM: n_regions_output: ',n_regions_output
-        
       ELSE
         n_regions_output = 1
@@ -312,10 +310,6 @@
       
       
-      ! JT Region means. 
       CALL iom_set_axis_attr( "region", (/ (REAL(ji,wp), ji=1,n_regions_output) /) )
 
-      !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) /) )
 
@@ -1340,17 +1334,6 @@
       REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) ::   bounds
       
-      !INTEGER :: iind_JT
-      
-      
-      !write(numout,*) 'IOM/iom.F90:iom_set_axis_attr: ',cdid
-      
       IF ( PRESENT(paxis) ) THEN
       
-        !write(numout,*) 'IOM/iom.F90:iom_set_axis_attr paxis size for: ',cdid,SIZE(paxis)
-        !write(numout,*) 'IOM/iom.F90:iom_set_axis_attr paxis values for: ',cdid,paxis
-        !do iind_JT = 1,SIZE(paxis)        
-        !  write(numout,*) 'IOM/iom.F90:iom_set_axis_attr paxis individual values for: ',cdid,iind_JT,paxis(iind_JT)
-        !end do
-        
 #if ! defined key_xios2
          IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, size=SIZE(paxis), value=paxis )
