Index: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/BDY/bdyini.F90
===================================================================
--- NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/BDY/bdyini.F90	(revision 10412)
+++ NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/BDY/bdyini.F90	(revision 10417)
@@ -1203,10 +1203,8 @@
             END DO
             IF( icount /= 0 ) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
+               WRITE(ctmp1,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
                   ' are not boundary points (flagu calculation). Check nbi, nbj, indices for boundary set ',ib_bdy
-               IF(lwp) WRITE(numout,*) ' ========== '
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
+               WRITE(ctmp2,*) ' ========== '
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ENDIF 
          END DO
@@ -1238,10 +1236,8 @@
             END DO
             IF( icount /= 0 ) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
+               WRITE(ctmp1,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
                   ' are not boundary points (flagv calculation). Check nbi, nbj, indices for boundary set ',ib_bdy
-               IF(lwp) WRITE(numout,*) ' ========== '
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
+               WRITE(ctmp2,*) ' ========== '
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ENDIF 
          END DO
@@ -1376,19 +1372,15 @@
                      icorns(ib2,1) = npckgw(ib1)
                   ELSEIF ((jpisft(ib2)==jpiwob(ib1)).AND.(jpjwft(ib1)==jpjsob(ib2))) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
-                     &                                     jpisft(ib2), jpjwft(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with West segment: ',npckgw(ib1), & 
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                        &                                     jpisft(ib2), jpjwft(ib1)
+                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
+                     WRITE(ctmp3,*) '             Crossing problem with West segment: ',npckgw(ib1), & 
+                        &                                        ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
                   ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check South and West Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1) , &
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop+1
+                     WRITE(ctmp1,*) ' E R R O R : Check South and West Open boundary indices'
+                     WRITE(ctmp2,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1) , &
+                        &                                         ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
                   END IF
                END IF
@@ -1412,19 +1404,15 @@
                      icorns(ib2,2) = npckge(ib1)
                   ELSEIF ((jpjeft(ib1)==jpjsob(ib2)).AND.(jpisdt(ib2)==jpieob(ib1)+1)) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
-                     &                                     jpisdt(ib2), jpjeft(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                        &                                     jpisdt(ib2), jpjeft(ib1)
+                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
+                     WRITE(ctmp3,*) '             Crossing problem with East segment: ',npckge(ib1), &
+                        &                                        ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
                   ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check South and East Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     WRITE(ctmp1,*) ' E R R O R : Check South and East Open boundary indices'
+                     WRITE(ctmp2,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
+                     &                                           ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
                   END IF
                END IF
@@ -1448,19 +1436,15 @@
                      icornn(ib2,1) = npckgw(ib1)
                   ELSEIF ((jpjwdt(ib1)==jpjnob(ib2)+1).AND.(jpinft(ib2)==jpiwob(ib1))) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
                      &                                     jpinft(ib2), jpjwdt(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with West segment: ',npckgw(ib1), &
+                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
+                     WRITE(ctmp3,*) '             Crossing problem with West segment: ',npckgw(ib1), &
                      &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
                   ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check North and West Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1), &
+                     WRITE(ctmp1,*) ' E R R O R : Check North and West Open boundary indices'
+                     WRITE(ctmp2,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1), &
                      &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
                   END IF
                END IF
@@ -1484,19 +1468,15 @@
                      icornn(ib2,2) = npckge(ib1)
                   ELSEIF ((jpjedt(ib1)==jpjnob(ib2)+1).AND.(jpindt(ib2)==jpieob(ib1)+1)) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
                      &                                     jpindt(ib2), jpjedt(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
+                     WRITE(ctmp3,*) '             Crossing problem with East segment: ',npckge(ib1), &
+                     &                                           ' and North segment: ',npckgn(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
                   ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check North and East Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
+                     WRITE(ctmp1,*) ' E R R O R : Check North and East Open boundary indices'
+                     WRITE(ctmp2,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
+                     &                                           ' and North segment: ',npckgn(ib2)
+                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
                   END IF
                END IF
@@ -1524,9 +1504,7 @@
          IF (ztestmask(1)==1) THEN 
             IF (icornw(ib,1)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgw(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
+               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgw(ib)
+               WRITE(ctmp2,*) ' ==========  does not start on land or on a corner'                                                  
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ELSE
                ! This is a corner
@@ -1538,9 +1516,7 @@
          IF (ztestmask(2)==1) THEN
             IF (icornw(ib,2)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgw(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
+               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgw(ib)
+               WRITE(ctmp2,*) ' ==========  does not end on land or on a corner'                                                  
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ELSE
                ! This is a corner
@@ -1568,9 +1544,7 @@
          IF (ztestmask(1)==1) THEN
             IF (icorne(ib,1)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckge(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1 
+               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckge(ib)
+               WRITE(ctmp2,*) ' ==========  does not start on land or on a corner'                                                  
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ELSE
                ! This is a corner
@@ -1582,9 +1556,7 @@
          IF (ztestmask(2)==1) THEN
             IF (icorne(ib,2)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckge(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
+               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckge(ib)
+               WRITE(ctmp2,*) ' ==========  does not end on land or on a corner'                                                  
+               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
             ELSE
                ! This is a corner
@@ -1611,16 +1583,12 @@
 
          IF ((ztestmask(1)==1).AND.(icorns(ib,1)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgs(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
+            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgs(ib)
+            WRITE(ctmp2,*) ' ==========  does not start on land or on a corner'                                                  
+            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
          ENDIF
          IF ((ztestmask(2)==1).AND.(icorns(ib,2)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgs(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
+            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgs(ib)
+            WRITE(ctmp2,*) ' ==========  does not end on land or on a corner'                                                  
+            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
          ENDIF
       END DO
@@ -1641,16 +1609,12 @@
 
          IF ((ztestmask(1)==1).AND.(icornn(ib,1)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgn(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not start on land'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
+            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgn(ib)
+            WRITE(ctmp2,*) ' ==========  does not start on land'                                                  
+            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
          ENDIF
          IF ((ztestmask(2)==1).AND.(icornn(ib,2)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgn(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not end on land'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
+            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgn(ib)
+            WRITE(ctmp2,*) ' ==========  does not end on land'                                                  
+            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
          ENDIF
       END DO
@@ -1691,8 +1655,7 @@
       !
       IF( itest>0 ) THEN
-         IF(lwp) WRITE(numout,*) ' E R R O R : Segments ', ib1, 'and ', ib2
-         IF(lwp) WRITE(numout,*) ' ==========  have different open bdy schemes'                                                  
-         IF(lwp) WRITE(numout,*)
-         nstop = nstop + 1
+         WRITE(ctmp1,*) ' E R R O R : Segments ', ib1, 'and ', ib2
+         WRITE(ctmp2,*) ' ==========  have different open bdy schemes'                                                  
+         CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
       ENDIF
       !
Index: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/DIA/diaharm.F90
===================================================================
--- NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/DIA/diaharm.F90	(revision 10412)
+++ NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/DIA/diaharm.F90	(revision 10417)
@@ -22,4 +22,5 @@
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE timing          ! preformance summary
+   USE lib_mpp           ! MPP library
 
    IMPLICIT NONE
@@ -126,7 +127,7 @@
       !
       IF (nb_ana > jpmax_harmo) THEN
-        IF(lwp) WRITE(numout,*) ' E R R O R dia_harm_init : nb_ana must be lower than jpmax_harmo, stop'
-        IF(lwp) WRITE(numout,*) ' jpmax_harmo= ', jpmax_harmo
-        nstop = nstop + 1
+         WRITE(ctmp1,*) 'Can not use XIOS in iom_g0d, file: '//TRIM(clname)//', var:'//TRIM(cdvar)
+         WRITE(ctmp2,*) ' jpmax_harmo= ', jpmax_harmo
+         CALL ctl_stop( 'dia_harm_init', ctmp1, ctmp2 )
       ENDIF
 
Index: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/IOM/iom.F90
===================================================================
--- NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/IOM/iom.F90	(revision 10412)
+++ NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/IOM/iom.F90	(revision 10417)
@@ -286,9 +286,6 @@
 !Warn if variable is not in defined in rst_wfields
    IF(.NOT.llis_set) THEN
-      IF(lwp) THEN
-         write(numout,cform_err)
-         write(numout,*) 'iom_set_rstw_var_active: variable ', field ,' is available for writing but not defined' 
-      ENDIF
-        nstop = nstop + 1
+      WRITE(ctmp1,*) 'iom_set_rstw_var_active: variable ', field ,' is available for writing but not defined' 
+      CALL ctl_stop( 'iom_set_rstw_var_active:', ctmp1 )
    ENDIF
 #else
@@ -518,6 +515,6 @@
 
         IF( i-1 > max_rst_fields) THEN
-        IF(lwp) write(numout,*) 'E R R O R : iom_set_rst_vars SIZE of RST_FIELD array is too small'
-        nstop = nstop + 1
+           WRITE(ctmp1,*) 'E R R O R : iom_set_rst_vars SIZE of RST_FIELD array is too small'
+           CALL ctl_stop( 'iom_set_rst_vars:', ctmp1 )
         ENDIF
    END SUBROUTINE iom_set_rst_vars
@@ -950,6 +947,6 @@
          CALL iom_swap( TRIM(cxios_context) )
 #else
-         nstop = nstop + 1 
-         clinfo = 'Can not use XIOS in iom_g0d, file: '//trim(clname)//', var:'//trim(cdvar)
+         WRITE(ctmp1,*) 'Can not use XIOS in iom_g0d, file: '//trim(clname)//', var:'//trim(cdvar)
+         CALL ctl_stop( 'iom_g0d', ctmp1 )
 #endif
       ENDIF
Index: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/LBC/lib_mpp.F90
===================================================================
--- NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/LBC/lib_mpp.F90	(revision 10412)
+++ NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/LBC/lib_mpp.F90	(revision 10417)
@@ -267,4 +267,5 @@
          !
       ELSEIF ( PRESENT(localComm) .AND. .NOT. mpi_was_called ) THEN
+         WRITE(ldtxt(ii),cform_err)                                                    ;   ii = ii + 1
          WRITE(ldtxt(ii),*) ' lib_mpp: You cannot provide a local communicator '          ;   ii = ii + 1
          WRITE(ldtxt(ii),*) '          without calling MPI_Init before ! '                ;   ii = ii + 1
@@ -1836,17 +1837,20 @@
       !
       nstop = nstop + 1
-      IF(lwp) THEN
-         WRITE(numout,cform_err)
-         IF( PRESENT(cd1 ) )   WRITE(numout,*) TRIM(cd1)
-         IF( PRESENT(cd2 ) )   WRITE(numout,*) TRIM(cd2)
-         IF( PRESENT(cd3 ) )   WRITE(numout,*) TRIM(cd3)
-         IF( PRESENT(cd4 ) )   WRITE(numout,*) TRIM(cd4)
-         IF( PRESENT(cd5 ) )   WRITE(numout,*) TRIM(cd5)
-         IF( PRESENT(cd6 ) )   WRITE(numout,*) TRIM(cd6)
-         IF( PRESENT(cd7 ) )   WRITE(numout,*) TRIM(cd7)
-         IF( PRESENT(cd8 ) )   WRITE(numout,*) TRIM(cd8)
-         IF( PRESENT(cd9 ) )   WRITE(numout,*) TRIM(cd9)
-         IF( PRESENT(cd10) )   WRITE(numout,*) TRIM(cd10)
-      ENDIF
+
+      ! force to open ocean.output file
+      IF( numout == 6 ) CALL ctl_opn( numout, 'ocean.output', 'APPEND', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
+       
+      WRITE(numout,cform_err)
+      IF( PRESENT(cd1 ) )   WRITE(numout,*) TRIM(cd1)
+      IF( PRESENT(cd2 ) )   WRITE(numout,*) TRIM(cd2)
+      IF( PRESENT(cd3 ) )   WRITE(numout,*) TRIM(cd3)
+      IF( PRESENT(cd4 ) )   WRITE(numout,*) TRIM(cd4)
+      IF( PRESENT(cd5 ) )   WRITE(numout,*) TRIM(cd5)
+      IF( PRESENT(cd6 ) )   WRITE(numout,*) TRIM(cd6)
+      IF( PRESENT(cd7 ) )   WRITE(numout,*) TRIM(cd7)
+      IF( PRESENT(cd8 ) )   WRITE(numout,*) TRIM(cd8)
+      IF( PRESENT(cd9 ) )   WRITE(numout,*) TRIM(cd9)
+      IF( PRESENT(cd10) )   WRITE(numout,*) TRIM(cd10)
+
                                CALL FLUSH(numout    )
       IF( numstp     /= -1 )   CALL FLUSH(numstp    )
@@ -1855,5 +1859,5 @@
       !
       IF( cd1 == 'STOP' ) THEN
-         IF(lwp) WRITE(numout,*)  'huge E-R-R-O-R : immediate stop'
+         WRITE(numout,*)  'huge E-R-R-O-R : immediate stop'
          CALL mppstop(ld_force_abort = .true.)
       ENDIF
Index: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/TRA/eosbn2.F90
===================================================================
--- NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/TRA/eosbn2.F90	(revision 10412)
+++ NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/TRA/eosbn2.F90	(revision 10417)
@@ -664,7 +664,6 @@
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'rab_3d:', ctmp1 )
          !
       END SELECT
@@ -779,7 +778,6 @@
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'rab_2d:', ctmp1 )
          !
       END SELECT
@@ -879,7 +877,6 @@
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'rab_0d:', ctmp1 )
          !
       END SELECT
@@ -1040,7 +1037,6 @@
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'eos_fzp_2d:', ctmp1 )
          !
       END SELECT      
@@ -1087,7 +1083,6 @@
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'eos_fzp_0d:', ctmp1 )
          !
       END SELECT
@@ -1213,7 +1208,6 @@
          !
       CASE DEFAULT
-         IF(lwp) WRITE(numout,cform_err)
-         IF(lwp) WRITE(numout,*) '          bad flag value for neos = ', neos
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '          bad flag value for neos = ', neos
+         CALL ctl_stop( 'eos_pen:', ctmp1 )
          !
       END SELECT
Index: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/stpctl.F90
===================================================================
--- NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/stpctl.F90	(revision 10412)
+++ NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/OCE/stpctl.F90	(revision 10417)
@@ -121,5 +121,5 @@
       ENDIF
       !
-      IF( lk_mpp .AND. ln_ctl ) THEN
+      IF( ln_ctl ) THEN
          CALL mpp_max( "stpctl", zmax )          ! max over the global domain
          nstop = NINT( zmax(7) )                 ! nstop indicator sheared among all local domains
@@ -160,27 +160,22 @@
             is2(:) = MAXLOC( tsn(:,:,:,jp_sal), mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /)
          ENDIF
-         IF( numout == 6 )   &   ! force to open ocean.output file
-            CALL ctl_opn( numout, 'ocean.output', 'APPEND', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-
-         WRITE(numout,cform_err)
-         WRITE(numout,*) ' stp_ctl: |ssh| > 10 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests'
-         WRITE(numout,*) ' ======= '
-         IF( lk_mpp .AND. .NOT. ln_ctl ) WRITE(numout,*) 'E R R O R message from sub-domain: ', narea
-         WRITE(numout,9100) kt,   zmax(1), ih(1) , ih(2)
-         WRITE(numout,9200) kt,   zmax(2), iu(1) , iu(2) , iu(3)
-         WRITE(numout,9300) kt, - zmax(3), is1(1), is1(2), is1(3)
-         WRITE(numout,9400) kt,   zmax(4), is2(1), is2(2), is2(3)
-         WRITE(numout,*)
-         WRITE(numout,*) '          output of last computed fields in output.abort.nc file'
+         
+         WRITE(ctmp1,*) ' stp_ctl: |ssh| > 10 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests'
+         WRITE(ctmp2,9100) kt,   zmax(1), ih(1) , ih(2)
+         WRITE(ctmp3,9200) kt,   zmax(2), iu(1) , iu(2) , iu(3)
+         WRITE(ctmp4,9300) kt, - zmax(3), is1(1), is1(2), is1(3)
+         WRITE(ctmp5,9400) kt,   zmax(4), is2(1), is2(2), is2(3)
+         WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort.nc file'
          
          CALL dia_wri_state( 'output.abort' )     ! create an output.abort file
          
-         IF( ln_ctl ) THEN
-            kindic = -3
-            nstop = nstop + 1                            ! increase nstop by 1 (on all local domains)
+         IF( .NOT. ln_ctl ) THEN
+            WRITE(ctmp8,*) 'E R R O R message from sub-domain: ', narea
+            CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp8, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ctmp6 )
          ELSE
-            CALL ctl_stop()
-            CALL mppstop(ld_force_abort = .true.)
+            CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6, ' ' )
          ENDIF
+
+         kindic = -3
          !
       ENDIF
Index: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/TOP/TRP/trdmxl_trc.F90
===================================================================
--- NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/TOP/TRP/trdmxl_trc.F90	(revision 10412)
+++ NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/TOP/TRP/trdmxl_trc.F90	(revision 10417)
@@ -776,14 +776,13 @@
 
       IF( ( lk_trdmxl_trc ) .AND. ( MOD( nitend-nittrc000+1, nn_trd_trc ) /= 0 ) ) THEN
-         WRITE(numout,cform_err)
-         WRITE(numout,*) '                Your nitend parameter, nitend = ', nitend
-         WRITE(numout,*) '                is no multiple of the trends diagnostics frequency        '
-         WRITE(numout,*) '                          you defined, nn_trd_trc   = ', nn_trd_trc
-         WRITE(numout,*) '                This will not allow you to restart from this simulation.  '
-         WRITE(numout,*) '                You should reconsider this choice.                        ' 
-         WRITE(numout,*) 
-         WRITE(numout,*) '                N.B. the nitend parameter is also constrained to be a     '
-         WRITE(numout,*) '                multiple of the sea-ice frequency parameter (typically 5) '
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '                Your nitend parameter, nitend = ', nitend
+         WRITE(ctmp2,*) '                is no multiple of the trends diagnostics frequency        '
+         WRITE(ctmp3,*) '                          you defined, nn_trd_trc   = ', nn_trd_trc
+         WRITE(ctmp4,*) '                This will not allow you to restart from this simulation.  '
+         WRITE(ctmp5,*) '                You should reconsider this choice.                        ' 
+         WRITE(ctmp6,*) 
+         WRITE(ctmp7,*) '                N.B. the nitend parameter is also constrained to be a     '
+         WRITE(ctmp8,*) '                multiple of the sea-ice frequency parameter (typically 5) '
+         CALL ctl_stop( ctmp1, ctmp2, ctmp3, ctmp4, ctmp5, ctmp6, ctmp7, ctmp8 )
       ENDIF
 
@@ -795,14 +794,12 @@
 
       IF( ( ln_trcadv_muscl .OR. ln_trcadv_muscl2 ) .AND. .NOT. ln_trdmxl_trc_instant ) THEN
-         WRITE(numout,cform_err)
-         WRITE(numout,*) '                Currently, you can NOT use simultaneously tracer MUSCL    '
-         WRITE(numout,*) '                advection and window averaged diagnostics of ML trends.   '
-         WRITE(numout,*) '                WHY? Everything in trdmxl_trc is coded for leap-frog, and '
-         WRITE(numout,*) '                MUSCL scheme is Euler forward for passive tracers (note   '
-         WRITE(numout,*) '                that MUSCL is leap-frog for active tracers T/S).          '
-         WRITE(numout,*) '                In particuliar, entrainment trend would be FALSE. However '
-         WRITE(numout,*) '                this residual is correct for instantaneous ML diagnostics.'
-         WRITE(numout,*) 
-         nstop = nstop + 1
+         WRITE(ctmp1,*) '                Currently, you can NOT use simultaneously tracer MUSCL    '
+         WRITE(ctmp2,*) '                advection and window averaged diagnostics of ML trends.   '
+         WRITE(ctmp3,*) '                WHY? Everything in trdmxl_trc is coded for leap-frog, and '
+         WRITE(ctmp4,*) '                MUSCL scheme is Euler forward for passive tracers (note   '
+         WRITE(ctmp5,*) '                that MUSCL is leap-frog for active tracers T/S).          '
+         WRITE(ctmp6,*) '                In particuliar, entrainment trend would be FALSE. However '
+         WRITE(ctmp7,*) '                this residual is correct for instantaneous ML diagnostics.'
+         CALL ctl_stop( ctmp1, ctmp2, ctmp3, ctmp4, ctmp5, ctmp6, ctmp7 )
       ENDIF
 
