Index: branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/stpctl.F90
===================================================================
--- branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/stpctl.F90	(revision 9440)
+++ branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/stpctl.F90	(revision 9441)
@@ -26,8 +26,11 @@
    USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy
 
+   USE netcdf          ! NetCDF library
    IMPLICIT NONE
    PRIVATE
 
    PUBLIC stp_ctl           ! routine called by step.F90
+
+   INTEGER  ::   idrun, idtime, idssh, idu, ids, istatus
    !!----------------------------------------------------------------------
    !! NEMO/OPA 4.0 , NEMO Consortium (2017)
@@ -75,4 +78,14 @@
          !                                ! open run.stat file
          CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+
+         IF( lwm ) THEN
+            istatus = NF90_CREATE( 'run.stat.nc', NF90_CLOBBER, idrun )
+            istatus = NF90_DEF_DIM( idrun, 'time', NF90_UNLIMITED, idtime )
+            istatus = NF90_DEF_VAR( idrun, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), idssh )
+            istatus = NF90_DEF_VAR( idrun,   'abs_u_max', NF90_DOUBLE, (/ idtime /), idu )
+            istatus = NF90_DEF_VAR( idrun,       's_min', NF90_DOUBLE, (/ idtime /), ids )
+            istatus = NF90_ENDDEF(idrun)
+         ENDIF
+         
       ENDIF
       !
@@ -141,6 +154,13 @@
       !                                            !==  run statistics  ==!   ("run.stat" file)
       IF(lwp) WRITE(numrun,9400) kt, zmax(1), zmax(2), - zmax(3)
+      IF( lwm ) THEN
+         istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) )
+         istatus = NF90_PUT_VAR( idrun,   idu, (/ zmax(2)/), (/kt/), (/1/) )
+         istatus = NF90_PUT_VAR( idrun,   ids, (/-zmax(3)/), (/kt/), (/1/) )
+         IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun)
+         IF( kt == nitend         ) istatus = NF90_CLOSE(idrun)
+      END IF
       !
-9400  FORMAT(' it :', i8, '    |ssh|_max: ', e16.10, ' |U|_max: ',e16.10,' S_min: ',e16.10)
+9400  FORMAT(' it :', i8, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16)
       !
    END SUBROUTINE stp_ctl
Index: branches/2017/dev_merge_2017/NEMOGCM/NEMO/SAS_SRC/stpctl.F90
===================================================================
--- branches/2017/dev_merge_2017/NEMOGCM/NEMO/SAS_SRC/stpctl.F90	(revision 9440)
+++ branches/2017/dev_merge_2017/NEMOGCM/NEMO/SAS_SRC/stpctl.F90	(revision 9441)
@@ -25,8 +25,11 @@
    USE lib_mpp         ! distributed memory computing
 
+   USE netcdf          ! NetCDF library
    IMPLICIT NONE
    PRIVATE
 
    PUBLIC stp_ctl           ! routine called by step.F90
+
+   INTEGER  ::   idrun, idtime, idssh, idu, ids, istatus
    !!----------------------------------------------------------------------
    !! NEMO/OPA 4.0 , NEMO Consortium (2017)
@@ -64,4 +67,14 @@
          !                                ! open run.stat file
          CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+
+         IF( lwm ) THEN
+            istatus = NF90_CREATE( 'run.stat.nc', NF90_CLOBBER, idrun )
+            istatus = NF90_DEF_DIM( idrun, 'time', NF90_UNLIMITED, idtime )
+            istatus = NF90_DEF_VAR( idrun, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), idssh )
+            istatus = NF90_DEF_VAR( idrun,   'abs_u_max', NF90_DOUBLE, (/ idtime /), idu )
+            istatus = NF90_DEF_VAR( idrun,       's_min', NF90_DOUBLE, (/ idtime /), ids )
+            istatus = NF90_ENDDEF(idrun)
+         ENDIF
+         
       ENDIF
       !
@@ -84,7 +97,14 @@
 
       !                                            !==  run statistics  ==!   ("run.stat" file)
-      IF(lwp) WRITE(numrun,9400) kt, zmax(1), zmax(2), -zmax(3)
+      IF(lwp) WRITE(numrun,9400) kt, zmax(1), zmax(2), - zmax(3)
+      IF( lwm ) THEN
+         istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) )
+         istatus = NF90_PUT_VAR( idrun,   idu, (/ zmax(2)/), (/kt/), (/1/) )
+         istatus = NF90_PUT_VAR( idrun,   ids, (/-zmax(3)/), (/kt/), (/1/) )
+         IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun)
+         IF( kt == nitend         ) istatus = NF90_CLOSE(idrun)
+      END IF
       !
-9400  FORMAT(' it :', i8, '    vt_i_max: ', e16.10, ' |u_ice|_max: ',e16.10,' tm_i_min: ',e16.10)
+9400  FORMAT(' it :', i8, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16)
       !
    END SUBROUTINE stp_ctl
