Index: trunk/mesoscale/LMD_MM_MARS/SRC/WRFV2/dyn_em/solve_em.F
===================================================================
--- trunk/mesoscale/LMD_MM_MARS/SRC/WRFV2/dyn_em/solve_em.F	(revision 32)
+++ trunk/mesoscale/LMD_MM_MARS/SRC/WRFV2/dyn_em/solve_em.F	(revision 34)
@@ -863,4 +863,7 @@
      &        ,CST_AL=config_flags%init_AL  &
      &        ,CST_TI=config_flags%init_TI  &
+     &        ,ISFFLX=config_flags%isfflx   &
+     &        ,DIFF_OPT=config_flags%diff_opt     &
+     &        ,KM_OPT=config_flags%km_opt         &
            ! additional diagnostics
      &        ,UAVE=grid%em_uave, USTD=grid%em_ustd &
Index: trunk/mesoscale/LMD_MM_MARS/SRC/WRFV2/phys/module_lmd_driver.F
===================================================================
--- trunk/mesoscale/LMD_MM_MARS/SRC/WRFV2/phys/module_lmd_driver.F	(revision 32)
+++ trunk/mesoscale/LMD_MM_MARS/SRC/WRFV2/phys/module_lmd_driver.F	(revision 34)
@@ -38,4 +38,7 @@
         CST_AL, &
         CST_TI, &
+        isfflx, &
+        diff_opt, &
+        km_opt, &
         UAVE, USTD, &
         VAVE, VSTD, &
@@ -46,4 +49,8 @@
         SLPX,SLPY)
 ! NB: module_lmd_driver_output1.inc : output arguments generated from Registry
+
+
+
+
 
 !==================================================================
@@ -92,4 +99,5 @@
 ! Scalars
 INTEGER, INTENT(IN  ) :: JULDAY, itimestep, julyr,id,max_dom,MARS_MODE
+INTEGER, INTENT(IN  ) :: isfflx,diff_opt,km_opt
 REAL, INTENT(IN  ) :: GMT,dt,dx,dy,RADT,CUDT
 REAL, INTENT(IN  ) :: CST_AL, CST_TI 
@@ -110,5 +118,5 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 REAL, DIMENSION( ims:ime, NUM_SOIL_LAYERS, jms:jme ), INTENT(IN   )  :: &
-     MARS_TSOIL
+     MARS_TSOIL 
 #ifdef NEWPHYS
 REAL, DIMENSION( ims:ime, NUM_SOIL_LAYERS, jms:jme ), INTENT(IN   )  :: &
@@ -165,5 +173,5 @@
    ! v--- can they be modified ?
    REAL,DIMENSION(:),ALLOCATABLE :: wtsurf,wco2ice,wemis
-   REAL,DIMENSION(:,:),ALLOCATABLE :: wq2,wqsurf,wtsoil
+   REAL,DIMENSION(:,:),ALLOCATABLE :: wq2,wqsurf,wtsoil 
 #ifdef NEWPHYS
    REAL,DIMENSION(:,:),ALLOCATABLE :: wisoil,wdsoil
@@ -220,5 +228,27 @@
 !==================================================================
 
-flag_LES = .false.  ! "True" LES is not available in this version 
+IF (JULYR .ne. 9999) THEN
+    flag_LES = .false.  ! "True" LES is not available in this version
+    PRINT *, '*** REAL-CASE SIMULATION ***'
+ELSE
+     PRINT *, '*** IDEALIZED SIMULATION ***'
+     IF ((diff_opt .eq. 2) .and. (km_opt .eq. 2)) THEN
+          PRINT *, '*** type: LES ***'
+          PRINT *, '*** diff_opt = 2 *** km_opt = 2'
+          PRINT *, '*** forcing is isfflx = ',isfflx 
+          flag_LES = .true.
+          !! SPECIAL LES
+     ELSE
+          PRINT *, '*** type: not LES ***'
+          PRINT *, '*** diff_opt = ',diff_opt
+          PRINT *, '*** km_opt = ',km_opt
+          flag_LES = .false.
+          !! IDEALIZED, no LES
+          !! cependant, ne veut-on pas pouvoir
+          !! prescrire un flux en idealise ??
+     ENDIF
+ENDIF
+
+
 print *,'** Mars ** DOMAIN',id
 
@@ -231,17 +261,26 @@
 jte = j_end(num_tiles)
 !!
-relax=0
-sponge_top=0               ! another value than 0 triggers instabilities  
-IF (id .gt. 1) relax=2     ! fix to avoid noise in nesting simulations ; 1 >> too much noise ...
+IF (flag_LES .eq. .false.) THEN
+ relax=0
+ sponge_top=0               ! another value than 0 triggers instabilities  
+ IF (id .gt. 1) relax=2     ! fix to avoid noise in nesting simulations ; 1 >> too much noise ...
+ENDIF
 ips=its
 ipe=ite
 jps=jts
 jpe=jte
-IF (ips .eq. ids)   ips=its+relax !! IF tests necesary for parallel runs
-IF (ipe .eq. ide-1) ipe=ite-relax
-IF (jps .eq. jds)   jps=jts+relax
-IF (jpe .eq. jde-1) jpe=jte-relax
+IF (flag_LES .eq. .false.) THEN
+ IF (ips .eq. ids)   ips=its+relax !! IF tests necesary for parallel runs
+ IF (ipe .eq. ide-1) ipe=ite-relax
+ IF (jps .eq. jds)   jps=jts+relax
+ IF (jpe .eq. jde-1) jpe=jte-relax
+ENDIF
 kps=kts         !! start at surface 
-kpe=kte-sponge_top
+IF (flag_LES .eq. .false.) THEN
+ kpe=kte-sponge_top
+ELSE
+ PRINT *, '*** IDEALIZED SIMULATION: LES *** kpe=kte'
+ kpe=kte !-sponge_top
+ENDIF
 
 !----------------------------!
@@ -267,4 +306,9 @@
 
 
+PRINT *, ips, ipe, jps, jpe
+PRINT *, ngrid
+
+
+
 elaps = (float(itimestep)-1.)*dt  ! elapsed seconds of simulation
 !----------------------------------------------!
@@ -287,6 +331,6 @@
 !! put here some general information you'd like to print just once
     print *, 'TILES: ', i_start,i_end, j_start, j_end  ! numbers for simple runs, arrays for parallel runs
-    print *, 'DOMAIN: ', ide, ids, jds, jde 
-    print *, 'MEMORY: ', ime, ims, jms, jme
+    print *, 'DOMAIN: ', ids, ide, jds, jde 
+    print *, 'MEMORY: ', ims, ime, jms, jme
     print *, 'ADVECTED TRACERS: ', num_3d_s-1
     print *, 'PHYSICS IS CALLED EACH...',wappel_phys
@@ -328,4 +372,5 @@
   !
   PRINT *,'** Mars ** IDEALIZED SIMULATION'
+  PRINT *,'** Mars ** BEWARE: input_coord must be here'
   open(unit=14,file='input_coord',form='formatted',status='old')
   rewind(14)
@@ -352,4 +397,5 @@
 !        PRINT *,'******************   CRASH   *******************'
 !        PRINT *,'Irrealistic temperature...', MAXLOC(t), MINLOC(t)
+!PRINT *, t
 !        PRINT *,'************************************************'
 !        STOP
@@ -411,4 +457,14 @@
 !        PRINT *,'OK OK OK OK'
 !ENDIF
+!ENDIF
+        !IF (          ANY(isNaN(u)) &
+        !         .OR. ANY(isNaN(v)) &
+        !         .OR. ANY(isNaN(t)) ) THEN
+        ! >>> ne marche qu'avec g95
+!print *, 'check dynamics'
+!print *, 'u', MAXVAL(u), MINVAL(u)
+!print *, 'v', MAXVAL(v), MINVAL(v)
+!print *, 't', MAXVAL(t), MINVAL(t, MASK = t > 0) 
+
 
 
@@ -536,5 +592,4 @@
 !th_prof(:) = th(i,kps:kpe,j)       ! pot. temperature half level (K)
 
-
 !--------------------------------!
 ! specific treatment for tracers !
@@ -567,6 +622,14 @@
 ! Mass-point latitude and longitude (radians) !
 !---------------------------------------------!
-lat_val = XLAT(i,j)*DEGRAD
-lon_val = XLONG(i,j)*DEGRAD
+IF (JULYR .ne. 9999) THEN
+ lat_val = XLAT(i,j)*DEGRAD
+ lon_val = XLONG(i,j)*DEGRAD
+ELSE
+ !!! IDEALIZED CASE
+ IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** IDEALIZED SIMULATION lat: ',lat_input
+ IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** IDEALIZED SIMULATION lon: ',lon_input
+ lat_val = lat_input*DEGRAD
+ lon_val = lon_input*DEGRAD
+ENDIF
 
 !-----------------------------------------!
@@ -574,24 +637,40 @@
 ! NB: usually 0 in mesoscale applications !
 !-----------------------------------------!
-zmea_val=MARS_GW(i,1,j)
-zstd_val=MARS_GW(i,2,j)
-zsig_val=MARS_GW(i,3,j)
-zgam_val=MARS_GW(i,4,j)
-zthe_val=MARS_GW(i,5,j)
+IF (JULYR .ne. 9999) THEN
+ zmea_val=MARS_GW(i,1,j)
+ zstd_val=MARS_GW(i,2,j)
+ zsig_val=MARS_GW(i,3,j)
+ zgam_val=MARS_GW(i,4,j)
+ zthe_val=MARS_GW(i,5,j)
+ELSE
+ IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** IDEALIZED SIMULATION GWdrag OFF'
+ zmea_val=0.
+ zstd_val=0.
+ zsig_val=0.
+ zgam_val=0.
+ zthe_val=0.
+ENDIF
 
 !---------------------------------!
 ! Ground albedo & Thermal Inertia !
 !---------------------------------!
-IF (CST_AL == 0) THEN 
-albedodat_val=MARS_ALB(i,j) 
-ELSE 
-albedodat_val=CST_AL
-IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** SET CONSTANT ALBEDO ', albedodat_val
-ENDIF
-IF (CST_TI == 0) THEN 
-inertiedat_val=MARS_TI(i,j) 
-ELSE 
-inertiedat_val=CST_TI
-IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** SET CONSTANT THERMAL INERTIA ', inertiedat_val
+IF (JULYR .ne. 9999) THEN
+ IF (CST_AL == 0) THEN 
+ albedodat_val=MARS_ALB(i,j) 
+ ELSE 
+ albedodat_val=CST_AL
+ IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** SET CONSTANT ALBEDO ', albedodat_val
+ ENDIF
+ IF (CST_TI == 0) THEN 
+ inertiedat_val=MARS_TI(i,j) 
+ ELSE 
+ inertiedat_val=CST_TI
+ IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** SET CONSTANT THERMAL INERTIA ', inertiedat_val
+ ENDIF
+ELSE
+ IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** IDEALIZED SIMULATION albedo: ', CST_AL
+ IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** IDEALIZED SIMULATION inertia: ',CST_TI
+ albedodat_val=CST_AL
+ inertiedat_val=CST_TI
 ENDIF
 
@@ -612,9 +691,17 @@
 ! Deep soil temperatures ! 
 !------------------------!
-IF (MARS_TSOIL(i,1,j) .gt. 0.) THEN
-tsoil_val(:)=MARS_TSOIL(i,:,j)
+IF (JULYR .ne. 9999) THEN
+  IF (MARS_TSOIL(i,1,j) .gt. 0.) THEN
+   tsoil_val(:)=MARS_TSOIL(i,:,j)
+  ELSE
+   tsoil_val = tsoil_val*0. + tsurf_val
+  ENDIF
 ELSE
-tsoil_val = tsoil_val*0. + tsurf_val
-ENDIF
+  IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** IDEALIZED SIMULATION tsoil is set to tsurf'
+  do k=1,nsoil
+   tsoil_val(k) = tsurf_val
+  enddo
+ENDIF
+
 #ifdef NEWPHYS
 isoil_val(:)=MARS_ISOIL(i,:,j)
@@ -625,17 +712,27 @@
 ! Slope inclination !
 !-------------------!
-theta_val=atan(sqrt( (1000.*SLPX(i,j))**2 + (1000.*SLPY(i,j))**2 ))
-theta_val=theta_val/DEGRAD
+IF (JULYR .ne. 9999) THEN
+  theta_val=atan(sqrt( (1000.*SLPX(i,j))**2 + (1000.*SLPY(i,j))**2 ))
+  theta_val=theta_val/DEGRAD
+ELSE
+  IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** IDEALIZED SIMULATION slope inclination is 0'
+  theta_val=0.
+ENDIF
 
 !-------------------------------------------!
 ! Slope orientation; 0 is north, 90 is east !
 !-------------------------------------------!
-psi_val=-90.*DEGRAD-atan(SLPY(i,j)/SLPX(i,j))
-if (SLPX(i,j) .ge. 0.) then
-   psi_val=psi_val-180.*DEGRAD
-endif
-psi_val=360.*DEGRAD+psi_val
-psi_val=psi_val/DEGRAD
-psi_val = MODULO(psi_val+180.,360.)
+IF (JULYR .ne. 9999) THEN
+  psi_val=-90.*DEGRAD-atan(SLPY(i,j)/SLPX(i,j))
+  if (SLPX(i,j) .ge. 0.) then
+    psi_val=psi_val-180.*DEGRAD
+  endif
+  psi_val=360.*DEGRAD+psi_val
+  psi_val=psi_val/DEGRAD
+  psi_val = MODULO(psi_val+180.,360.)
+ELSE
+  IF ( (i == ips) .AND. (j == jps) ) PRINT *,'** Mars ** IDEALIZED SIMULATION slope orientation is 0 (well, whatever)'
+  psi_val=0.
+ENDIF
 
 !-----------------!
@@ -643,21 +740,23 @@
 !-----------------!
 IF ( (i == ips) .AND. (j == jps) ) THEN
- PRINT *,'lat/lon ', lat_val/DEGRAD, lon_val/DEGRAD
- PRINT *,'emiss ', emis_val
- PRINT *,'phi ',phisfi_val
- PRINT *,'tsurf ',tsurf_val
- PRINT *,'aire ',aire_val
- PRINT *,'z_prof ',z_prof
- PRINT *,'dz8w_prof',dz8w_prof
- PRINT *,'p8w_prof ',p8w_prof
- PRINT *,'p_prof ',p_prof 
- PRINT *,'t_prof ',t_prof
- PRINT *,'t8w_prof ',t8w_prof
- PRINT *,'u_prof ',u_prof
- PRINT *,'v_prof ',v_prof
- PRINT *,'tsoil ',tsoil_val
+PRINT *,'lat/lon ', lat_val/DEGRAD, lon_val/DEGRAD
+PRINT *,'emiss ', emis_val
+PRINT *,'albedo ', albedodat_val
+PRINT *,'inertie ', inertiedat_val
+PRINT *,'phi ',phisfi_val
+PRINT *,'tsurf ',tsurf_val
+PRINT *,'aire ',aire_val
+PRINT *,'z_prof ',z_prof
+PRINT *,'dz8w_prof',dz8w_prof
+PRINT *,'p8w_prof ',p8w_prof
+PRINT *,'p_prof ',p_prof
+PRINT *,'t_prof ',t_prof
+PRINT *,'t8w_prof ',t8w_prof
+PRINT *,'u_prof ',u_prof
+PRINT *,'v_prof ',v_prof
+PRINT *,'tsoil ',tsoil_val 
 #ifdef NEWPHYS
- PRINT *,'isoil ',isoil_val
- PRINT *,'dsoil ',dsoil_val
+PRINT *,'isoil ',isoil_val
+PRINT *,'dsoil ',dsoil_val
 #endif
 ENDIF
@@ -719,8 +818,12 @@
 pv(subs,:) = v_prof(:)
 pw(subs,:) = 0   !! NB: not used in the physics, only diagnostic...
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 !! for IDEALIZED CASES ONLY
 IF (JULYR .eq. 9999) pplev(subs,nlayer+1)=0.  !! pplev(subs,nlayer+1)=ptop >> NO !
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+! NOTE:
+! IF ( pplev(subs,nlayer+1) .le. 0 ) pplev(subs,nlayer+1)=ptop
+! cree des diagnostics delirants et aleatoires dans le transfert radiatif 
 
 !---------!
@@ -847,9 +950,9 @@
 #include "module_lmd_driver_output3.inc"  
        !  ^-- generated from Registry
+!TSK(i,j) = output_tab2d(subs,ind_TSURF)
 ENDDO
 ENDDO
 DEALLOCATE(output_tab2d)
 DEALLOCATE(output_tab3d)
-
 
 !---------------------------------------------------------------------------------!
@@ -955,7 +1058,7 @@
 DEALLOCATE(pdq)
 
-!---------!
-! display !
-!---------!
+!!---------!
+!! display !
+!!---------!
 PRINT *, '** Mars ** Results from LMD physics'
 PRINT *, 'u non-zero tendencies'
@@ -995,5 +1098,5 @@
 !c  Local:
       double precision xref,zx0,zteta,zz
-!c      xref: mean anomaly, zteta: true anomaly, zx0: eccentric anomaly
+!c	xref: mean anomaly, zteta: true anomaly, zx0: eccentric anomaly
       double precision year_day 
       double precision peri_day,timeperi,e_elips
@@ -1030,2 +1133,3 @@
 
 END MODULE module_lmd_driver
+
