From 84e045a42a10c7a74682ee0a324f26088f92e3a5 Mon Sep 17 00:00:00 2001
From: Gaelle Tanguy <gaelle.tanguy@meteo.fr>
Date: Mon, 24 Nov 2014 09:24:30 +0000
Subject: [PATCH] S.Bielli 24/11/2014 : bug when writing netcdf file with
 LTURB_DIAG=T and LTURB_FLX=F or conversely

---
 src/MNH/write_phys_param.f90 | 120 +++++++++++++++++------------------
 1 file changed, 59 insertions(+), 61 deletions(-)

diff --git a/src/MNH/write_phys_param.f90 b/src/MNH/write_phys_param.f90
index c24a3e753..eb23f8283 100644
--- a/src/MNH/write_phys_param.f90
+++ b/src/MNH/write_phys_param.f90
@@ -945,38 +945,6 @@ IF (CTURBDIM=='3DIM') THEN
   END IF
 END IF
 !!
-IF ( LTURB_DIAG ) THEN
-! stores the mixing length
-!
-  YRECFM  ='LM'
-  YCOMMENT='X_Y_Z_LM (M)'
-  IGRID   = 1
-  ILENCH=LEN(YCOMMENT)
-  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
-!!
-  IF (NRR /= 0) THEN
-!
-! stores the conservative potential temperature
-!
-    YRECFM  ='THLM'
-    YCOMMENT='X_Y_Z_THLM (KELVIN)'
-    IGRID   = 1
-    ILENCH=LEN(YCOMMENT)
-    CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
-!!
-  ! stores the conservative mixing ratio
-  !
-    YRECFM  ='RNPM'
-    YCOMMENT='X_Y_Z_RNPM (KG/KG)'
-    IGRID   = 1
-    ILENCH=LEN(YCOMMENT)
-    CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,       &
-                           YCOMMENT,IRESP)
-  END IF
-!!
-!!
-END IF
-!!!!!! turb_hor_uw
 IF ( LTURB_FLX ) THEN
   ! stores  <U W>
   YRECFM  ='UW_HFLX'
@@ -1014,6 +982,36 @@ IF ( LTURB_FLX ) THEN
  END DO
 END IF
 !!
+IF ( LTURB_DIAG ) THEN
+  ! stores the dynamic production
+  YRECFM  ='DP'
+  YCOMMENT='X_Y_Z_DP (M**2/S**3)'
+  IGRID   = 1
+  ILENCH=LEN(YCOMMENT)
+  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
+!!
+  ! stores the thermal production
+  YRECFM  ='TP'
+  YCOMMENT='X_Y_Z_TP (M**2/S**3)'
+  IGRID   = 1
+  ILENCH=LEN(YCOMMENT)
+  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
+!!
+  ! stores the whole turbulent transport
+  YRECFM  ='TR'
+  YCOMMENT='X_Y_Z_TR (M**2/S**3)'
+  IGRID   = 1
+  ILENCH=LEN(YCOMMENT)
+  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
+!!
+  ! stores the dissipation of TKE
+  YRECFM  ='DISS'
+  YCOMMENT='X_Y_Z_DISS (M**2/S**3)'
+  IGRID   = 1
+  ILENCH=LEN(YCOMMENT)
+  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
+END IF
+!
 IF ( LTURB_DIAG ) THEN
  ! stores the mixing length
  YRECFM  ='LM'
@@ -1061,35 +1059,35 @@ IF ( LTURB_DIAG ) THEN
 !!
 END IF
 !!!! tke_eps_sources
-IF ( LTURB_DIAG ) THEN
-  ! stores the dynamic production
-  YRECFM  ='DP'
-  YCOMMENT='X_Y_Z_DP (M**2/S**3)'
-  IGRID   = 1
-  ILENCH=LEN(YCOMMENT)
-  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
-!!
-  ! stores the thermal production
-  YRECFM  ='TP'
-  YCOMMENT='X_Y_Z_TP (M**2/S**3)'
-  IGRID   = 1
-  ILENCH=LEN(YCOMMENT)
-  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
-!!
-  ! stores the whole turbulent transport
-  YRECFM  ='TR'
-  YCOMMENT='X_Y_Z_TR (M**2/S**3)'
-  IGRID   = 1
-  ILENCH=LEN(YCOMMENT)
-  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
-!!
-  ! stores the dissipation of TKE
-  YRECFM  ='DISS'
-  YCOMMENT='X_Y_Z_DISS (M**2/S**3)'
-  IGRID   = 1
-  ILENCH=LEN(YCOMMENT)
-  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
-END IF
+!IF ( LTURB_DIAG ) THEN
+!  ! stores the dynamic production
+!  YRECFM  ='DP'
+!  YCOMMENT='X_Y_Z_DP (M**2/S**3)'
+!  IGRID   = 1
+!  ILENCH=LEN(YCOMMENT)
+!  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
+!!!
+!  ! stores the thermal production
+!  YRECFM  ='TP'
+!  YCOMMENT='X_Y_Z_TP (M**2/S**3)'
+!  IGRID   = 1
+!  ILENCH=LEN(YCOMMENT)
+!  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
+!!!
+!  ! stores the whole turbulent transport
+!  YRECFM  ='TR'
+!  YCOMMENT='X_Y_Z_TR (M**2/S**3)'
+!  IGRID   = 1
+!  ILENCH=LEN(YCOMMENT)
+!  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
+!!!
+!  ! stores the dissipation of TKE
+!  YRECFM  ='DISS'
+!  YCOMMENT='X_Y_Z_DISS (M**2/S**3)'
+!  IGRID   = 1
+!  ILENCH=LEN(YCOMMENT)
+!  CALL FMWRIT(HFMFILE,YRECFM,CLUOUT,'XY',ZSTORE_3D,IGRID,ILENCH,YCOMMENT,IRESP)
+!END IF
 !!
 !!!!!!!!! Shallow_mf_pack
 IF (CSCONV == 'EDKF') THEN
-- 
GitLab