Index: /trunk/LMDZ.MARS/changelog.txt
===================================================================
--- /trunk/LMDZ.MARS/changelog.txt	(revision 3091)
+++ /trunk/LMDZ.MARS/changelog.txt	(revision 3092)
@@ -4257,3 +4257,11 @@
 is correctly handled (i.e. on lon-lat grid outputs polar mesh area must
 be adjusted to account for the replicated polar meshes).
- 
+
+== 10/10/2023 == EM+JBC
+Follow-up of r3078 which broke the 1D model.
+Also added initialisation of non-oro GW tendencies stored in startfi.nc when in 1D.
+
+== 18/10/2023 == JBC
+    - Correction of a bug in "writediagfi.F": the case of using the 1D model with parallelization was not anticipated so that the "diagfi.nc" file was filled with NaNf;
+    - Addition of the file "start1D.txt" as an example in the directory deftank/;
+    - Some "cosmetic" modifications in "improvedclouds_mod.F", "write_output_mod.F90" and "testphys1d.F90".
Index: /trunk/LMDZ.MARS/deftank/start1D.txt
===================================================================
--- /trunk/LMDZ.MARS/deftank/start1D.txt	(revision 3092)
+++ /trunk/LMDZ.MARS/deftank/start1D.txt	(revision 3092)
@@ -0,0 +1,11 @@
+ ps   15844.910967918002     
+ co2                              0.0000000000000000       0.99806873526322104       0.99806873526322093       0.99806873526322071       0.99806873526322049       0.99806873526321993       0.99806873526321904       0.99806873526321660       0.99806873526321194       0.99806873526320383       0.99806873526318929       0.99806873526316264       0.99806873526311735       0.99806873526304407       0.99806873526292728       0.99806873526274265       0.99806873526245643       0.99806873526200479       0.99806873526124928       0.99806873525982065       0.99806873525618467       0.99806873523022577       0.99806873520941064       0.99806873519925610       0.99806873518649675       0.99806873517068784       0.99806873515200578       0.99806873513094219       0.99806873510863758       0.99806873510863758     
+ h2o_vap                          7.2725246193759237E-059   5.8820100507640916E-005   5.8820100688353599E-005   5.8820102755633127E-005   5.8820116010573458E-005   5.8820174882493682E-005   5.8820377808845918E-005   5.8820963205398175E-005   5.8822437714700769E-005   5.8825760304503722E-005   5.8832611449481862E-005   5.8845802606717229E-005   5.8869894659825426E-005   5.8912403186450224E-005   5.8986517484320695E-005   5.9118018232116458E-005   5.9339869879177149E-005   5.9118164371551599E-005   4.8106282131383099E-005   2.5397278973802698E-005   6.3061481836226679E-006   9.3802884750568872E-007   9.7516958519586652E-007   1.0089444459472081E-006   1.0459331125368584E-006   1.0833310711125330E-006   1.1209015686700208E-006   1.1577207352404221E-006   1.1925864567746269E-006   1.1925864567746269E-006
+ h2o_ice                          7.2725246193759237E-059   1.2278899576264690E-057   1.6315181302798064E-057   2.5441790828268903E-057   4.2239110487880329E-055   2.8557485049211623E-053   2.9688260186503111E-049   1.7949152547667348E-043   9.3631379898865452E-040   2.6379228226787604E-038   0.0000000000000000        1.8758830304057299E-025   2.3609586616864940E-016   1.0472188694732230E-014   2.0788822907050202E-013   2.9182716021300108E-011   1.6472227685943954E-010   5.7106584131899193E-008   3.4526182417955551E-006   8.5543632485348008E-006   6.0999521119023684E-006   4.5510207393867132E-007   5.5488154372924425E-009   1.0221427037701964E-010   8.9779605439961759E-013   5.5538516514912759E-015   1.7859437496423380E-016   0.0000000000000000        0.0000000000000000        0.0000000000000000     
+ ccn_number                       211059535298932.69        1849.4576440198794        1849.4582566053705        1849.4586744268302        1849.4589956111556        1849.4593008861555        1849.4596232822048        1849.4598351982863        1849.4597297222563        1849.4595214127285        1849.4594914571794        1849.3724116475139        1849.5916529580068        1850.0560517435595        1856.5748077355204        279.98827629407265        366.29923119992930        47081.990892276313        12841391.040254256        238487943.23776314        726442991.38934684        1562680885.2700438        24277639.690400742        514973.30873089907        5114.8672520673344        134.33051200098083        333.61003114880236        1755.9927731048235        75.257675414930645        75.257675414930645     
+ ccn_mass                         984.06104526159436        1.8494576440198791E-017   1.8494582566053700E-017   1.8494586744268300E-017   1.8494589956111556E-017   1.8494593008861554E-017   1.8494596232822046E-017   1.8494598351982859E-017   1.8494597297222565E-017   1.8494595214127284E-017   1.8494594914571792E-017   1.8493724116475137E-017   1.8495916529580064E-017   1.8500560517435601E-017   1.4711524959196136E-015   1.9831509427745010E-013   5.5817990092541446E-013   6.9670583653778338E-011   1.9003293251800345E-008   3.5269180055120037E-007   1.0736789870862268E-006   2.3052678060375135E-006   3.5814177946918155E-008   7.5960801734492301E-010   7.4446918734484585E-012   4.4207908660675703E-014   1.4793308207097557E-015   1.6746694382287890E-017   1.3699270266221628E-018   1.3699270266221628E-018
+ dust_number                      5978578170980206.0        114369652204.76767        114356549748.81723        114323177293.41280        114250666838.47505        114115899392.29398        113892552929.69894        113552275477.26718        113063989597.62381        112389451883.25011        111509512210.17575        110430121000.77000        109153391663.72237        107673187440.13013        105965302756.97717        103972323657.46086        101572442894.97495        98503858010.630646        94094766154.813080        85779619300.476898        65148281211.421646        6229648260.9592543        814981632.96982491        197504796.99926114        35613192.480257481        4526764.2866460187        407349.75764916284        25148.155974179361        1604.9267530796474        1604.9267530796474     
+ dust_mass                        501.78869604461329        1.4555946664115001E-003   1.4544322931485786E-003   1.4516334906308965E-003   1.4455755160826605E-003   1.4343809409522598E-003   1.4159936615391615E-003   1.3883839989329550E-003   1.3496583475955031E-003   1.2980270209245006E-003   1.2339122767718103E-003   1.1600958433408263E-003   1.0793391808118474E-003   9.9404666452155318E-004   9.0587859819659137E-004   8.1544923989119642E-004   7.2195266840599168E-004   6.2232326175664016E-004   5.0875482685035374E-004   3.6208336229652212E-004   1.6009516955363409E-004   7.8111971715851268E-006   3.2512390916310862E-007   2.5437139874963564E-008   1.4501610853348091E-009   5.8744110938064371E-011   1.7209978498883730E-012   3.6676996075393140E-014   6.4901243491176011E-016   6.4901243491176011E-016
+ u   7.5996042233788010        7.6607046721354672        7.8182459568095410        8.1291326500216989        8.6003563912308749        9.1420699610852250        9.5971521808874876        9.8621303873952506        9.9658631538211928        9.9937508498778946        9.9991371629304844        9.9999090223895077        9.9999925678432433        9.9999995189646960        9.9999999746999979        9.9999999988992716        9.9999999999604992        9.9999999999988844        9.9999999999999840        10.000000000000004        9.9999999999999964        9.9999999999999982        10.000000000000002        9.9999999999999982        9.9999999999999964        10.000000000000004        10.000000000000002        10.000000000000004        10.000000000000004     
+ v   0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000        0.0000000000000000     
+ teta   255.36959122864869        262.94217129296442        262.86430823135720        262.65847466328324        262.21226857023794        261.37519598684537        259.94715098753250        257.67169898854451        254.34198389155611        250.07191983143383        245.22819265605887        239.99356815622977        234.45448519851908        228.69553782978173        222.71987927059794        216.40633765983554        209.50964495825343        201.82994000256119        193.66575283846379        185.52006334300367        172.11180547112119        154.22292138123350        152.26555642130651        151.86053274326906        153.28065584964054        154.47278979490088        153.89566817514981        151.07020093026608        144.95314172553861        137.21496977935399     
Index: /trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90	(revision 3091)
+++ /trunk/LMDZ.MARS/libf/phymars/dyn1d/testphys1d.F90	(revision 3092)
@@ -34,5 +34,5 @@
 !   and a file describing the sigma layers (e.g. "z2sig.def")
 !
-!   author: Frederic Hourdin, R.Fournier,F.Forget
+!   author: Frederic Hourdin, R. Fournier, F. Forget
 !   -------
 !
@@ -90,7 +90,7 @@
 real, dimension(1)      :: latitude, longitude, cell_area
 logical                 :: there
-character(len = 2)      :: str2
-character(len = 7)      :: str7
-character(len = 44)     :: txt
+character(2)            :: str2
+character(7)            :: str7
+character(44)           :: txt
 
 ! RV & JBC: Use of starting files for 1D
Index: /trunk/LMDZ.MARS/libf/phymars/improvedclouds_mod.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/improvedclouds_mod.F	(revision 3091)
+++ /trunk/LMDZ.MARS/libf/phymars/improvedclouds_mod.F	(revision 3092)
@@ -613,62 +613,4 @@
       print*, 'count is ',countcells, ' i.e. ',
      &     countcells*100/(nlay*ngrid), '% for microphys computation'
-
-#ifndef MESOSCALE
-!      IF (ngrid.ne.1) THEN ! 3D
-!         call WRITEDIAGFI(ngrid,"satu","ratio saturation","",3,
-!     &                    satu_out)
-!         call WRITEDIAGFI(ngrid,"dM","ccn variation","kg/kg",3,
-!     &                    dM_out)
-!         call WRITEDIAGFI(ngrid,"dN","ccn variation","#",3,
-!     &                    dN_out)
-!         call WRITEDIAGFI(ngrid,"error","dichotomy max error","%",2,
-!     &                    error2d)
-!         call WRITEDIAGFI(ngrid,"zqsat","zqsat","kg",3,
-!     &                    zqsat)
-!      ENDIF
-
-!      IF (ngrid.eq.1) THEN ! 1D
-!         call WRITEDIAGFI(ngrid,"error","incertitude sur glace","%",1,
-!     &                    error_out)
-         call WRITEdiagfi(ngrid,"resist","resistance","s/m2",1,
-     &                    res_out)
-         call WRITEdiagfi(ngrid,"satu_bf","satu before","kg/kg",1,
-     &                    satubf)
-         call WRITEdiagfi(ngrid,"satu_af","satu after","kg/kg",1,
-     &                    satuaf)
-         call WRITEdiagfi(ngrid,"vapbf","h2ovap before","kg/kg",1,
-     &                    zq0(1,1,igcm_h2o_vap))
-         call WRITEdiagfi(ngrid,"vapaf","h2ovap after","kg/kg",1,
-     &                    zq(1,1,igcm_h2o_vap))
-         call WRITEdiagfi(ngrid,"icebf","h2oice before","kg/kg",1,
-     &                    zq0(1,1,igcm_h2o_ice))
-         call WRITEdiagfi(ngrid,"iceaf","h2oice after","kg/kg",1,
-     &                    zq(1,1,igcm_h2o_ice))
-         call WRITEdiagfi(ngrid,"ccnbf","ccn before","/kg",1,
-     &                    zq0(1,1,igcm_ccn_number))
-         call WRITEdiagfi(ngrid,"ccnaf","ccn after","/kg",1,
-     &                    zq(1,1,igcm_ccn_number))
-c         call WRITEDIAGFI(ngrid,"growthrate","growth rate","m^2/s",1,
-c     &                    gr_out)
-c         call WRITEDIAGFI(ngrid,"nuclearate","nucleation rate","",1,
-c     &                    rate_out)
-c         call WRITEDIAGFI(ngrid,"dM","ccn variation","kg",1,
-c     &                    dM_out)
-c         call WRITEDIAGFI(ngrid,"dN","ccn variation","#",1,
-c     &                    dN_out)
-         call WRITEdiagfi(ngrid,"zqsat","p vap sat","kg/kg",1,
-     &                    zqsat)
-!         call WRITEDIAGFI(ngrid,"satu","ratio saturation","",1,
-!     &                    satu_out)
-         call WRITEdiagfi(ngrid,"rice","ice radius","m",1,
-     &                    rice)
-!         call WRITEDIAGFI(ngrid,"rdust_sca","rdust","m",1,
-!     &                    rdust)
-!         call WRITEDIAGFI(ngrid,"rsedcloud","rsedcloud","m",1,
-!     &                    rsedcloud)
-!         call WRITEDIAGFI(ngrid,"rhocloud","rhocloud","kg.m-3",1,
-!     &                    rhocloud)
-!      ENDIF
-#endif
       
       ENDIF ! endif test_flag
Index: /trunk/LMDZ.MARS/libf/phymars/write_output_mod.F90
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/write_output_mod.F90	(revision 3091)
+++ /trunk/LMDZ.MARS/libf/phymars/write_output_mod.F90	(revision 3092)
@@ -1,16 +1,19 @@
 MODULE write_output_mod
-    IMPLICIT NONE
+
+IMPLICIT NONE
+
 PRIVATE
-    
-    INTERFACE write_output
-      MODULE PROCEDURE write_output_d0,write_output_d1,write_output_d2, &
-                       write_output_i0,write_output_i1,write_output_i2, &
-                       write_output_l0,write_output_l1,write_output_l2
-
-    END INTERFACE write_output
-
-    PUBLIC write_output
-    
+
+INTERFACE write_output
+    MODULE PROCEDURE write_output_d0, write_output_d1, write_output_d2, &
+                     write_output_i0, write_output_i1, write_output_i2, &
+                     write_output_l0, write_output_l1, write_output_l2
+END INTERFACE write_output
+
+PUBLIC write_output
+
+!----------------------------------------------------------------------
 CONTAINS
+!----------------------------------------------------------------------
 
   SUBROUTINE write_output_d0(field_name,title,units,field)
@@ -28,7 +31,7 @@
   CHARACTER(LEN=*),INTENT(IN)    :: units
   REAL,INTENT(IN)                :: field
-  
+
   call writediagfi(ngrid,field_name,title,units,0,field)
-#ifdef CPP_XIOS 
+#ifdef CPP_XIOS
   if (xios_is_active_field(field_name)) then
     ! only send the field to xios if the user asked for it
@@ -36,7 +39,9 @@
   endif
 #endif
-  
+
   END SUBROUTINE write_output_d0
 
+!----------------------------------------------------------------------
+
   SUBROUTINE write_output_d1(field_name,title,units,field)
   ! For a surface field
@@ -53,7 +58,7 @@
   CHARACTER(LEN=*),INTENT(IN)    :: units
   REAL,INTENT(IN)                :: field(:)
- 
+
   call writediagfi(ngrid,field_name,title,units,2,field)
-#ifdef CPP_XIOS 
+#ifdef CPP_XIOS
   if (xios_is_active_field(field_name)) then
     ! only send the field to xios if the user asked for it
@@ -61,6 +66,8 @@
   endif
 #endif
-  
+
   END SUBROUTINE write_output_d1
+
+!----------------------------------------------------------------------
 
   SUBROUTINE write_output_d2(field_name,title,units,field)
@@ -83,8 +90,8 @@
   if(size(field(:,:),2).eq.nsoilmx) then
     call writediagsoil(ngrid,field_name,title,units,3,field)
-  else 
+  else
     call writediagfi(ngrid,field_name,title,units,3,field(:,:))
   endif
-#ifdef CPP_XIOS 
+#ifdef CPP_XIOS
   if (xios_is_active_field(field_name)) then
     ! only send the field to xios if the user asked for it
@@ -92,7 +99,9 @@
   endif
 #endif
-  
+
   END SUBROUTINE write_output_d2
 
+!----------------------------------------------------------------------
+
   SUBROUTINE write_output_i0(field_name,title,units,field)
   ! For a surface field
@@ -109,7 +118,7 @@
   CHARACTER(LEN=*),INTENT(IN)    :: units
   INTEGER,INTENT(IN)             :: field
-  
+
   call writediagfi(ngrid,field_name,title,units,0,real(field))
-#ifdef CPP_XIOS 
+#ifdef CPP_XIOS
   if (xios_is_active_field(field_name)) then
     ! only send the field to xios if the user asked for it
@@ -117,7 +126,9 @@
   endif
 #endif
-  
+
   END SUBROUTINE write_output_i0
 
+!----------------------------------------------------------------------
+
   SUBROUTINE write_output_i1(field_name,title,units,field)
   ! For a surface field
@@ -134,7 +145,7 @@
   CHARACTER(LEN=*),INTENT(IN)    :: units
   INTEGER,INTENT(IN)             :: field(:)
- 
+
   call writediagfi(ngrid,field_name,title,units,2,real(field))
-#ifdef CPP_XIOS 
+#ifdef CPP_XIOS
   if (xios_is_active_field(field_name)) then
     ! only send the field to xios if the user asked for it
@@ -142,6 +153,8 @@
   endif
 #endif
-  
+
   END SUBROUTINE write_output_i1
+
+!----------------------------------------------------------------------
 
   SUBROUTINE write_output_i2(field_name,title,units,field)
@@ -164,8 +177,8 @@
   if(size(field(:,:),2).eq.nsoilmx) then
     call writediagsoil(ngrid,field_name,title,units,3,real(field))
-  else 
+  else
     call writediagfi(ngrid,field_name,title,units,3,real(field(:,:)))
   endif
-#ifdef CPP_XIOS 
+#ifdef CPP_XIOS
   if (xios_is_active_field(field_name)) then
     ! only send the field to xios if the user asked for it
@@ -173,6 +186,8 @@
   endif
 #endif
-  
+
   END SUBROUTINE write_output_i2
+
+!----------------------------------------------------------------------
 
   SUBROUTINE write_output_l0(field_name,title,units,field)
@@ -195,7 +210,7 @@
   field_real=0
   if(field) field_real=1
-  
+
   call writediagfi(ngrid,field_name,title,units,0,field_real)
-#ifdef CPP_XIOS 
+#ifdef CPP_XIOS
   if (xios_is_active_field(field_name)) then
     ! only send the field to xios if the user asked for it
@@ -203,6 +218,8 @@
   endif
 #endif
-  
+
   END SUBROUTINE write_output_l0
+
+!----------------------------------------------------------------------
 
   SUBROUTINE write_output_l1(field_name,title,units,field)
@@ -228,7 +245,7 @@
     if(field(i)) field_real(i)=1.
   ENDDO
- 
+
   call writediagfi(ngrid,field_name,title,units,2,field_real(:))
-#ifdef CPP_XIOS 
+#ifdef CPP_XIOS
   if (xios_is_active_field(field_name)) then
     ! only send the field to xios if the user asked for it
@@ -236,6 +253,8 @@
   endif
 #endif
-  
+
   END SUBROUTINE write_output_l1
+
+!----------------------------------------------------------------------
 
   SUBROUTINE write_output_l2(field_name,title,units,field)
@@ -270,9 +289,9 @@
   if(size(field(:,:),2).eq.nsoilmx) then
     call writediagsoil(ngrid,field_name,title,units,3,field_real)
-  else 
+  else
     call writediagfi(ngrid,field_name,title,units,3,field_real(:,:))
   endif
 
-#ifdef CPP_XIOS 
+#ifdef CPP_XIOS
   if (xios_is_active_field(field_name)) then
     ! only send the field to xios if the user asked for it
@@ -280,5 +299,5 @@
   endif
 #endif
-  
+
   deallocate(field_real)
 
Index: /trunk/LMDZ.MARS/libf/phymars/writediagfi.F
===================================================================
--- /trunk/LMDZ.MARS/libf/phymars/writediagfi.F	(revision 3091)
+++ /trunk/LMDZ.MARS/libf/phymars/writediagfi.F	(revision 3092)
@@ -312,4 +312,5 @@
         if (dim.eq.3) then
 
+          IF (klon_glo>1) THEN ! General case
 #ifdef CPP_PARA
           ! Gather field on a "global" (without redundant longitude) array
@@ -327,5 +328,4 @@
 !         Passage variable physique -->  variable dynamique
 !         recast (copy) variable from physics grid to dynamics grid
-          IF (klon_glo>1) THEN ! General case
            DO l=1,nbp_lev
              DO i=1,nbp_lon+1
@@ -341,8 +341,8 @@
              ENDDO
            ENDDO
+#endif
           ELSE ! 1D model case
            dx3_1d(1,1:nbp_lev)=px(1,1:nbp_lev)
           ENDIF
-#endif
 !         Ecriture du champs
 
@@ -416,4 +416,5 @@
         else if (dim.eq.2) then
 
+          IF (klon_glo>1) THEN ! General case
 #ifdef CPP_PARA
           ! Gather field on a "global" (without redundant longitude) array
@@ -433,5 +434,4 @@
 !         Passage variable physique -->  physique dynamique
 !         recast (copy) variable from physics grid to dynamics grid
-          IF (klon_glo>1) THEN ! General case
              DO i=1,nbp_lon+1
                 dx2(i,1)=px(1,1)
@@ -445,8 +445,8 @@
                 dx2(nbp_lon+1,j)=dx2(1,j)
              ENDDO
+#endif
           ELSE ! 1D model case
             dx2_1d=px(1,1)
           ENDIF
-#endif
 
           if (is_master) then
