From 85fa831f8e4ff14e0d9eea3a69225811d1d27dfb Mon Sep 17 00:00:00 2001
From: Gaelle DELAUTIER <gaelle.delautier@meteo.fr>
Date: Fri, 15 Sep 2017 16:17:21 +0200
Subject: [PATCH] V.Masson 07/2017 : adds time step for output files writing

---
 src/MNH/default_desfmn.f90 |  6 +++++-
 src/MNH/modd_fmout.f90     |  2 ++
 src/MNH/modn_fmout.f90     |  3 ++-
 src/MNH/set_grid.f90       | 10 ++++++++++
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/MNH/default_desfmn.f90 b/src/MNH/default_desfmn.f90
index 6ec7ad809..618f2611a 100644
--- a/src/MNH/default_desfmn.f90
+++ b/src/MNH/default_desfmn.f90
@@ -219,6 +219,7 @@ END MODULE MODI_DEFAULT_DESFM_n
 !!                    10/2016 (C.Lac) Add droplet deposition
 !!                   10/2016  (R.Honnert and S.Riette) : Improvement of EDKF and adaptation to the grey zone
 !!                   10/2016  (F Brosse) add prod/loss terms computation for chemistry
+!!                   07/2017  (V. Masson) adds time step for output files writing.
 !-------------------------------------------------------------------------------
 !
 !*       0.    DECLARATIONS
@@ -492,7 +493,10 @@ XTNUDGING = 21600.
 !*      9.    SET DEFAULT VALUES FOR MODD_FMOUT and MODD_OUT_n :
 !             ------------------------------------------------
 !
-IF (KMI == 1) XFMOUT (:,:) = XUNDEF
+IF (KMI == 1) THEN
+  XFMOUT (:,:) = XUNDEF
+  XTSTEP_OUTPUT = XUNDEF
+END IF
 !
 !
 !-------------------------------------------------------------------------------
diff --git a/src/MNH/modd_fmout.f90 b/src/MNH/modd_fmout.f90
index 23a361358..108233c51 100644
--- a/src/MNH/modd_fmout.f90
+++ b/src/MNH/modd_fmout.f90
@@ -38,6 +38,7 @@
 !!    MODIFICATIONS
 !!    -------------
 !!      Original    26/07/96                     
+!!                   07/2017  (V. Masson) adds time step for output files writing.
 !-------------------------------------------------------------------------------
 !
 !*       0.   DECLARATIONS
@@ -47,6 +48,7 @@ USE MODD_PARAMETERS
 !
 IMPLICIT NONE
 !
+REAL                                       ::   XTSTEP_OUTPUT   ! constant timestep during each output
 REAL,SAVE, DIMENSION(JPMODELMAX,JPOUTMAX)  ::   XFMOUT    ! XFMOUT(m,i) array of 
 ! the increments in seconds from the beginning of the segment to the
 ! instant where the i-th fields output on FM-files is realized by model "m"
diff --git a/src/MNH/modn_fmout.f90 b/src/MNH/modn_fmout.f90
index 2168e5966..dc5d6c608 100644
--- a/src/MNH/modn_fmout.f90
+++ b/src/MNH/modn_fmout.f90
@@ -39,6 +39,7 @@
 !!    MODIFICATIONS
 !!    -------------
 !!      Original    26/07/96                      
+!!                   07/2017  (V. Masson) adds time step for output files writing.
 !-------------------------------------------------------------------------------
 !
 !*       0.   DECLARATIONS
@@ -48,6 +49,6 @@ USE MODD_FMOUT
 !
 IMPLICIT NONE
 !
-NAMELIST/NAM_FMOUT/XFMOUT
+NAMELIST/NAM_FMOUT/XFMOUT, XTSTEP_OUTPUT
 !
 END MODULE MODN_FMOUT
diff --git a/src/MNH/set_grid.f90 b/src/MNH/set_grid.f90
index e96bab607..ceaf6f3d0 100644
--- a/src/MNH/set_grid.f90
+++ b/src/MNH/set_grid.f90
@@ -231,6 +231,7 @@ END MODULE MODI_SET_GRID
 !!      J. STEIN    01/02/99  change the orography at the boundary for the
 !!                            grid-nesting lbc
 !!     V.MASSON 12/10/00 read of the orography in all cases, even if LFLAT=T
+!!     V. MASSON     07/2017  adds time step for output files writing.
 !-------------------------------------------------------------------------------
 !
 !*       0.    DECLARATIONS
@@ -514,6 +515,15 @@ KSTOP = NINT(PSEGLEN/PTSTEP)
 !
 !*       2.3    Temporal grid - outputs managment
 !
+!*       2.3.0  case of regular temporal outputs: initializes XFMOUT arrays (MODD_FMOUT)
+!
+IF (XTSTEP_OUTPUT /= XUNDEF .AND. XTSTEP_OUTPUT>0.) THEN
+  XFMOUT(:,:) = XUNDEF
+  DO JOUT=1,NINT(PSEGLEN/XTSTEP_OUTPUT)
+    XFMOUT(:,JOUT) = JOUT*XTSTEP_OUTPUT
+  END DO
+END IF
+!
 !*       2.3.1  a) synchronization between nested models through XFMOUT arrays (MODD_FMOUT)
 !
 DO JOUT = 1,JPOUTMAX
-- 
GitLab