Index: /branches/NERC/dev_r5518_GO6_Carb_Fail_from_GO6_9163/NEMOGCM/NEMO/OPA_SRC/stpctl.F90
===================================================================
--- /branches/NERC/dev_r5518_GO6_Carb_Fail_from_GO6_9163/NEMOGCM/NEMO/OPA_SRC/stpctl.F90	(revision 9244)
+++ /branches/NERC/dev_r5518_GO6_Carb_Fail_from_GO6_9163/NEMOGCM/NEMO/OPA_SRC/stpctl.F90	(revision 9245)
@@ -58,5 +58,6 @@
       INTEGER  ::   ii, ij, ik              ! temporary integers
       REAL(wp) ::   zumax, zsmin, zssh2     ! temporary scalars
-      REAL(wp) ::   ztmax, ztmin            ! temporary scalars
+      REAL(wp) ::   ztmax, ztmin            ! Scalar to get temperature extreme
+                                            ! values and warn if they're out of Range
       INTEGER, DIMENSION(3) ::   ilocu      ! 
       INTEGER, DIMENSION(2) ::   ilocs      ! 
Index: /branches/NERC/dev_r5518_GO6_Carb_Fail_from_GO6_9163/NEMOGCM/NEMO/TOP_SRC/MEDUSA/air_sea.F90
===================================================================
--- /branches/NERC/dev_r5518_GO6_Carb_Fail_from_GO6_9163/NEMOGCM/NEMO/TOP_SRC/MEDUSA/air_sea.F90	(revision 9244)
+++ /branches/NERC/dev_r5518_GO6_Carb_Fail_from_GO6_9163/NEMOGCM/NEMO/TOP_SRC/MEDUSA/air_sea.F90	(revision 9245)
@@ -92,5 +92,5 @@
 # endif
       USE lib_mpp,           ONLY: ctl_stop
-      USE trcstat 
+      USE trcstat,           ONLY: trc_rst_dia_stat 
 
    !!* Substitution
@@ -157,10 +157,10 @@
                   !!! 
                   !!! Jpalm test on atm xCO2
-                  IF ( (f_xco2a(ji,jj) > 1500 ).OR.(f_xco2a(ji,jj) < 100 ) ) THEN
+                  IF ( (f_xco2a(ji,jj) > 1500.0 ).OR.(f_xco2a(ji,jj) < 100.0 ) ) THEN
                     IF(lwp) THEN 
                        WRITE(numout,*) ' atm xCO2 = ',f_xco2a(ji,jj),          &
                                        ' -- ji =', mig(ji),' jj = ', mjg(jj)
-                       CALL ctl_stop( 'MEDUSA - Air-Sea :', 'unrealistic atm xCO2 ' )
-                    ENDIF 
+                    ENDIF
+                    CALL ctl_stop( 'MEDUSA - Air-Sea :', 'unrealistic atm xCO2 ' )
                  ENDIF 
                ENDIF
@@ -207,5 +207,5 @@
                !! Jpalm -- 12-09-2017 -- add extra check after reccurent
                !!          carbonate failure in the coupled run.
-               !!          must be associated to air-sea flux or air xCO2...i
+               !!          must be associated to air-sea flux or air xCO2...
                !!          Check MOCSY inputs
                IF ( (zsal(ji,jj) > 75.0 ).OR.(zsal(ji,jj) < 0.0 ) .OR.        &
@@ -229,7 +229,7 @@
                                        ' kt = ', kt 
                       WRITE(numout,*) 'MEDUSA - Air-Sea INPUT: unrealistic surface Carb. Chemistry'
-                      CALL ctl_stop( 'MEDUSA - Air-Sea INPUT: ',             &
-                                     'unrealistic surface Carb. Chemistry -- INPUTS' )
                   ENDIF     
+                  CALL ctl_stop( 'MEDUSA - Air-Sea INPUT: ',             &
+                                 'unrealistic surface Carb. Chemistry -- INPUTS' )
                ENDIF     
                !!
@@ -259,6 +259,6 @@
                !! Jpalm -- 12-09-2017 -- add extra check after reccurent
                !!          carbonate failure in the coupled run.
-               !!          must be associated to air-sea flux or air xCO2...i
-               !!          Check MOCSY inputs
+               !!          must be associated to air-sea flux or air xCO2...
+               !!          Check MOCSY outputs
               IF ( (f_pco2w(ji,jj) > 1.E4 ).OR.(f_pco2w(ji,jj) < 0.0 ) .OR.     &
                    (f_fco2w(ji,jj) > 1.E4 ).OR.(f_fco2w(ji,jj) < 0.0 ) .OR.     &   
@@ -281,7 +281,7 @@
                                        ' kt = ', kt     
                      WRITE(numout,*) 'MEDUSA - Air-Sea OUTPUT: unrealistic surface Carb. Chemistry'
-                     CALL ctl_stop( 'MEDUSA - Air-Sea OUTPUT: ',            &
-                                    'unrealistic surface Carb. Chemistry -- OUTPUTS' )
                  ENDIF     
+                 CALL ctl_stop( 'MEDUSA - Air-Sea OUTPUT: ',            &
+                                'unrealistic surface Carb. Chemistry -- OUTPUTS' )
               ENDIF     
             ENDIF
Index: /branches/NERC/dev_r5518_GO6_Carb_Fail_from_GO6_9163/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcbio_medusa.F90
===================================================================
--- /branches/NERC/dev_r5518_GO6_Carb_Fail_from_GO6_9163/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcbio_medusa.F90	(revision 9244)
+++ /branches/NERC/dev_r5518_GO6_Carb_Fail_from_GO6_9163/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcbio_medusa.F90	(revision 9245)
@@ -89,5 +89,7 @@
 # endif
       USE lbclnk,                     ONLY: lbc_lnk
-      USE lib_mpp  
+      USE lib_mpp,                    ONLY: mpp_max, mpp_maxloc, 
+                                            mpp_min, mpp_minloc,            &
+                                            ctl_stop, ctl_warn 
       USE oce,                        ONLY: tsb, tsn
       USE par_kind,                   ONLY: wp
@@ -117,5 +119,5 @@
       
       PUBLIC   trc_bio_medusa    ! called in trcsms_medusa.F90
-      PUBLIC   trc_bio_exceptional_fix ! here 
+      PUBLIC   trc_bio_exceptionnal_fix ! here 
 
    !!* Substitution
@@ -497,5 +499,5 @@
          !! ---------------------------------------------
          !! JPALM -- 14-12-2017 -- Here, before any exeptionnal crazy value is
-         !!              removed, we want to tell to the Master Node that this 
+         !!              removed, we want to tell to the Master Processor that this 
          !!              Exceptionnal value did exist
          !!
@@ -514,5 +516,5 @@
          !! ocean.output file; the error reporting below is strictly local
          !! to the relevant ocean.output_XXXX file so will not be visible
-         !! unless all nodes are reporting output
+         !! unless all processors are reporting output
          !!================================================================
          !!
@@ -527,31 +529,33 @@
                      !!
                      !! all tracer values are reported in the event of any excursion
-                     write(charout,*)  ' Tmp = ', ztmp(ji,jj)
-                     write(charout2,*) ' Sal = ', zsal(ji,jj)
-                     write(charout3,*) ' DIC = ', zdic(ji,jj)
-                     write(charout4,*) ' Alk = ', zalk(ji,jj)
-                     write(charout5,*) mig(ji), mjg(jj), jk, kt 
-                     IF (lwp) CALL ctl_warn( 'trc_bio_medusa: carbonate chemistry WARNING:',  &
-                        TRIM(charout),TRIM(charout2),TRIM(charout3),TRIM(charout4),           & 
-                        'at i, j, k, kt:', TRIM(charout5) )
+                     IF (lwp) THEN
+                         WRITE(charout,*)  ' Tmp = ', ztmp(ji,jj)
+                         WRITE(charout2,*) ' Sal = ', zsal(ji,jj)
+                         WRITE(charout3,*) ' DIC = ', zdic(ji,jj)
+                         WRITE(charout4,*) ' Alk = ', zalk(ji,jj)
+                         WRITE(charout5,*) mig(ji), mjg(jj), jk, kt 
+                         CALL ctl_warn( 'trc_bio_medusa: carbonate chemistry WARNING:',  &
+                            TRIM(charout),TRIM(charout2),TRIM(charout3),TRIM(charout4),  & 
+                            'at i, j, k, kt:', TRIM(charout5) )
+                     ENDIF
                      !!
                      !! Detect, report and correct tracer excursions
                      IF ( (ztmp(ji,jj) .LT. -3.0) .OR. (ztmp(ji,jj) .GT.  40.0) )             &
-                        CALL trc_bio_exceptional_fix(                                         &
+                        CALL trc_bio_exceptionnal_fix(                                         &
                         tsn(ji-1:ji+1,jj-1:jj+1,jk,jp_tem), tmask(ji-1:ji+1,jj-1:jj+1,jk),    &
                         'Tmp', -3.0, 40.0, ztmp(ji,jj) )
                      !!
                      IF ( (zsal(ji,jj) .LE. 0.0) .OR. (zsal(ji,jj) .GT.  50.0)  )             &
-                        CALL trc_bio_exceptional_fix(                                         &
+                        CALL trc_bio_exceptionnal_fix(                                         &
                         tsn(ji-1:ji+1,jj-1:jj+1,jk,jp_sal), tmask(ji-1:ji+1,jj-1:jj+1,jk),    &
                         'Sal', 1.0, 50.0, zsal(ji,jj) )
                      !!
                      IF ( (zdic(ji,jj) .LE. 0.0) .OR. (zdic(ji,jj) .GT. 4.0E3)  )             &
-                        CALL trc_bio_exceptional_fix(                                         &
+                        CALL trc_bio_exceptionnal_fix(                                         &
                         trn(ji-1:ji+1,jj-1:jj+1,jk,jpdic), tmask(ji-1:ji+1,jj-1:jj+1,jk),     &
                         'DIC', 100.0, 4.0E3, zdic(ji,jj) )
                      !!
                      IF ( (zalk(ji,jj) .LE. 0.0) .OR. (zalk(ji,jj) .GT. 4.0E3)  )             &
-                        CALL trc_bio_exceptional_fix(                                         &
+                        CALL trc_bio_exceptionnal_fix(                                         &
                         trn(ji-1:ji+1,jj-1:jj+1,jk,jpalk), tmask(ji-1:ji+1,jj-1:jj+1,jk),     &
                         'Alk', 100.0, 4.0E3, zalk(ji,jj) )
@@ -719,5 +723,5 @@
 
 
-   SUBROUTINE trc_bio_exceptional_fix(tiny_var, tiny_mask, var_nm, mini, maxi, varout)
+   SUBROUTINE trc_bio_exceptionnal_fix(tiny_var, tiny_mask, var_nm, mini, maxi, varout)
       !! JPALM (27/10/17): This function is called only when abnormal values that 
       !! could break the model's carbonate system are fed to MEDUSA
@@ -745,23 +749,24 @@
       !! Print surounding values to check if isolated Crazy value or 
       !! General error
-      IF(lwp) WRITE(numout,*)                                 &
-         '----------------------------------------------------------------------'
-      IF(lwp) WRITE(numout,*)                                 &
-         'trc_bio_medusa: 3x3 neighbourhood surrounding abnormal ', TRIM(var_nm)
-      IF(lwp) WRITE(numout,9100)                              &
-         3, tiny_var(ii-1,ij+1), tiny_var(ii  ,ij+1), tiny_var(ii+1,ij+1)
-      IF(lwp) WRITE(numout,9100)                              &
-         2, tiny_var(ii-1,ij  ), tiny_var(ii  ,ij  ), tiny_var(ii+1,ij  )
-      IF(lwp) WRITE(numout,9100)                              &
-         1, tiny_var(ii-1,ij-1), tiny_var(ii  ,ij-1), tiny_var(ii+1,ij-1)
-      IF(lwp) WRITE(numout,*)                                 &
-         'trc_bio_medusa: 3x3 land-sea neighbourhood, tmask'
-      IF(lwp) WRITE(numout,9100)                              &
-         3, tiny_mask(ii-1,ij+1), tiny_mask(ii  ,ij+1), tiny_mask(ii+1,ij+1)
-      IF(lwp) WRITE(numout,9100)                              &
-         2, tiny_mask(ii-1,ij  ), tiny_mask(ii  ,ij  ), tiny_mask(ii+1,ij  )
-      IF(lwp) WRITE(numout,9100)                              &
-         1, tiny_mask(ii-1,ij-1), tiny_mask(ii  ,ij-1), tiny_mask(ii+1,ij-1)
-
+      IF(lwp) THEN 
+          WRITE(numout,*)                                 &
+            '----------------------------------------------------------------------'
+          WRITE(numout,*)                                 &
+            'trc_bio_medusa: 3x3 neighbourhood surrounding abnormal ', TRIM(var_nm)
+          WRITE(numout,9100)                              &
+            3, tiny_var(ii-1,ij+1), tiny_var(ii  ,ij+1), tiny_var(ii+1,ij+1)
+          WRITE(numout,9100)                              &
+            2, tiny_var(ii-1,ij  ), tiny_var(ii  ,ij  ), tiny_var(ii+1,ij  )
+          WRITE(numout,9100)                              &
+            1, tiny_var(ii-1,ij-1), tiny_var(ii  ,ij-1), tiny_var(ii+1,ij-1)
+          WRITE(numout,*)                                 &
+            'trc_bio_medusa: 3x3 land-sea neighbourhood, tmask'
+          WRITE(numout,9100)                              &
+            3, tiny_mask(ii-1,ij+1), tiny_mask(ii  ,ij+1), tiny_mask(ii+1,ij+1)
+          WRITE(numout,9100)                              &
+            2, tiny_mask(ii-1,ij  ), tiny_mask(ii  ,ij  ), tiny_mask(ii+1,ij  )
+          WRITE(numout,9100)                              &
+            1, tiny_mask(ii-1,ij-1), tiny_mask(ii  ,ij-1), tiny_mask(ii+1,ij-1)
+      ENDIF
       !! Correct out of range values
       sumtsn = ( tiny_mask(ii-1,ij+1) * tiny_var(ii-1,ij+1) ) +  &
@@ -787,19 +792,19 @@
       ENDIF
       !!
-      write(charout1,9200) tiny_var(ii,ij)
-      write(charout2,9200) varout
-      write(charout3,*) ' ', charout1, ' -> ', charout2
-      write(charout4,*) ' Tracer: ', trim(var_nm)
-      IF(lwp) WRITE(numout,*) 'trc_bio_medusa: ** EXCEPTIONAL VALUE SWITCHING **'
-      IF(lwp) WRITE(numout,*) charout4 
-      IF(lwp) WRITE(numout,*) charout3
-      IF(lwp) WRITE(numout,*)                                 &
-         '----------------------------------------------------------------------'
-      IF(lwp) WRITE(numout,*)                                 &
-         ' '
+      IF (lwp) THEN 
+          WRITE(charout1,9200) tiny_var(ii,ij)
+          WRITE(charout2,9200) varout
+          WRITE(charout3,*) ' ', charout1, ' -> ', charout2
+          WRITE(charout4,*) ' Tracer: ', trim(var_nm)
+      !!
+          WRITE(numout,*) 'trc_bio_medusa: ** EXCEPTIONAL VALUE SWITCHING **'
+          WRITE(numout,*) charout4 
+          WRITE(numout,*) charout3
+          WRITE(numout,*) '----------------------------------------------------------------------'
+          WRITE(numout,*) ' '
 9100  FORMAT('Row:', i1, '  ', e16.6, ' ', e16.6, ' ', e16.6)
 9200  FORMAT(e16.6)
 
-   END SUBROUTINE trc_bio_exceptional_fix 
+   END SUBROUTINE trc_bio_exceptionnal_fix 
 
    SUBROUTINE trc_bio_check(kt)
@@ -808,5 +813,5 @@
       !!                     problem. The model is now able to correct a local
       !!                     crazy value. but does it silently.
-      !!                     We need to spread the word to the master node. we
+      !!                     We need to spread the word to the master processor. we
       !!                     don't want the model  to correct values without telling us
       !!                     This module will tell at least when crazy DIC or
