Index: /LMDZ6/trunk/libf/dyn3d/advtrac.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3d/advtrac.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3d/advtrac.F90	(revision 5258)
@@ -1,6 +1,4 @@
 ! $Id$
 
-#define DEBUG_IO
-#undef DEBUG_IO
 SUBROUTINE advtrac(pbaru, pbarv, p, masse,q,iapptrac,teta, flxw, pk)
    !     Auteur :  F. Hourdin
@@ -14,5 +12,6 @@
    USE control_mod,  ONLY: iapp_tracvl, day_step
    USE comconst_mod, ONLY: dtvr
-
+   USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
+   USE strings_mod, ONLY: int2str
    IMPLICIT NONE
    !
@@ -202,5 +201,5 @@
    CALL massbar(massem,massebx,masseby)
 
-#ifdef DEBUG_IO    
+IF (CPPKEY_DEBUGIO) THEN
    CALL WriteField_u('massem',massem)
    CALL WriteField_u('wg',wg)
@@ -213,5 +212,5 @@
       CALL WriteField_u('q_adv'//trim(int2str(iq)),q(:,:,iq))
    END DO
-#endif
+END IF
 
    IF(isoCheck) WRITE(*,*) 'advtrac 227'
Index: /LMDZ6/trunk/libf/dyn3dmem/advect_new_loc.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/advect_new_loc.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/advect_new_loc.F90	(revision 5258)
@@ -9,5 +9,5 @@
   USE comconst_mod, ONLY: daysec
   USE logic_mod, ONLY: conser
-
+  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
   IMPLICIT NONE
   !=======================================================================
@@ -250,7 +250,7 @@
   if (pole_nord) ijb=ijb+iip1
   if (pole_sud)  ije=ije-iip1
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
    CALL WriteField_u('du_bis',du)
-#endif
+END IF
 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
   DO l=1,llm
@@ -264,9 +264,9 @@
   ENDDO
 !$OMP END DO NOWAIT
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   CALL WriteField_u('du1',du1)
   CALL WriteField_u('du2',du2)
   CALL WriteField_u('du_bis',du)
-#endif
+END IF
   ijb=ij_begin
   ije=ij_end
Index: /LMDZ6/trunk/libf/dyn3dmem/advtrac_loc.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/advtrac_loc.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/advtrac_loc.F90	(revision 5258)
@@ -1,5 +1,3 @@
 
-#define DEBUG_IO
-#undef DEBUG_IO
 SUBROUTINE advtrac_loc(pbarug, pbarvg, wg, p, massem, q, teta, pk)
    !     Auteur :  F. Hourdin
@@ -21,5 +19,6 @@
    USE times
    USE advtrac_mod, ONLY: finmasse
-
+   USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
+   USE strings_mod, ONLY: int2str
    IMPLICIT NONE
    !
@@ -109,5 +108,5 @@
 !ym   ----> Reverifier lors de la parallelisation des autres schemas
 
-#ifdef DEBUG_IO    
+IF (CPPKEY_DEBUGIO) THEN
    CALL WriteField_u('massem',massem)
    CALL WriteField_u('wg',wg)
@@ -120,5 +119,5 @@
       CALL WriteField_u('q_adv'//trim(int2str(iq)),q(:,:,iq))
    END DO
-#endif
+END IF
 
 !          
@@ -132,9 +131,9 @@
    CALL vlspltgen_loc(q, 2., massem, wg, pbarug, pbarvg, dtvr, p, pk, teta )
 
-#ifdef DEBUG_IO     
+IF (CPPKEY_DEBUGIO) THEN
    DO iq = 1, nqtot
       CALL WriteField_u('q_adv'//trim(int2str(iq)),q(:,:,iq))
    END DO
-#endif
+END IF
          
    GOTO 1234     
Index: /LMDZ6/trunk/libf/dyn3dmem/caladvtrac_loc.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/caladvtrac_loc.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/caladvtrac_loc.F90	(revision 5258)
@@ -16,5 +16,5 @@
   USE Vampir
   USE write_field_loc
-  !
+  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
   IMPLICIT NONE
   !
@@ -131,9 +131,9 @@
 !$OMP ENDDO NOWAIT
 
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
      CALL WriteField_u('pbarug1',pbarug)
      CALL WriteField_v('pbarvg1',pbarvg)
      CALL WriteField_u('wg1',wg)
-#endif
+END IF
 
 !$OMP BARRIER
@@ -178,9 +178,9 @@
 
 
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
      CALL WriteField_u('pbarug1',pbarug_adv)
      CALL WriteField_v('pbarvg1',pbarvg_adv)
      CALL WriteField_u('wg1',wg_adv)
-#endif
+END IF
   ! !write(*,*) 'caladvtrac 185'
   CALL advtrac_loc( pbarug_adv,pbarvg_adv,wg_adv, &
Index: /LMDZ6/trunk/libf/dyn3dmem/caldyn_loc.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/caldyn_loc.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/caldyn_loc.F90	(revision 5258)
@@ -1,8 +1,2 @@
-!
-! $Id: $
-!
-#undef DEBUG_IO
-!#define DEBUG_IO
-
 SUBROUTINE caldyn_loc &
         (itau,ucov,vcov,teta,ps,masse,pk,pkf,phis , &
@@ -13,5 +7,5 @@
         vorpot, ecin, bern, massebxy, convm
   USE comvert_mod, ONLY: ap, bp
-
+  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
   IMPLICIT NONE
 
@@ -90,5 +84,5 @@
   CALL convmas2_loc  (   convm                      )
 !$OMP BARRIER
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   call WriteField_u('ucont',ucont)
   call WriteField_v('vcont',vcont)
@@ -102,5 +96,5 @@
   call WriteField_u('dteta',dteta)
   call WriteField_u('convm',convm)
-#endif
+END IF
 
 !$OMP BARRIER
@@ -122,10 +116,10 @@
   CALL dudv1_loc   ( vorpot , pbaru , pbarv     , du     , dv  )
 
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   call WriteField_u('w',w)
   call WriteField_v('vorpot',vorpot)
   call WriteField_u('du',du)
   call WriteField_v('dv',dv)
-#endif
+END IF
 
   ! ! compute kinetic energy ecin()
@@ -136,5 +130,5 @@
   CALL dudv2_loc   ( teta   , pkf   , bern      , du     , dv  )
 
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   call WriteField_u('ecin',ecin)
   call WriteField_u('bern',bern)
@@ -142,5 +136,5 @@
   call WriteField_v('dv',dv)
   call WriteField_u('pkf',pkf)
-#endif
+END IF
 
   ijb=ij_begin-iip1
Index: /LMDZ6/trunk/libf/dyn3dmem/call_calfis_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/call_calfis_mod.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/call_calfis_mod.F90	(revision 5258)
@@ -88,6 +88,6 @@
   USE comvert_mod, ONLY: ap, bp, pressure_exner
   USE temps_mod, ONLY: day_ini, day_ref, jd_ref, jh_ref, start_time
-  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS
-
+  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_PHYS, CPPKEY_DEBUGIO
+  USE strings_mod, ONLY: int2str
   
   IMPLICIT NONE
@@ -118,5 +118,5 @@
     
     
-#ifdef DEBUG_IO    
+IF (CPPKEY_DEBUGIO) THEN
     CALL WriteField_u('ucovfi',ucov)
     CALL WriteField_v('vcovfi',vcov)
@@ -127,5 +127,5 @@
       CALL WriteField_u('qfi'//trim(int2str(iq)),q(:,:,iq))
     ENDDO
-#endif
+END IF
 
 !
@@ -169,5 +169,5 @@
   !$OMP END MASTER
 
-#ifdef DEBUG_IO    
+IF (CPPKEY_DEBUGIO) THEN
     CALL WriteField_u('ucovfi',ucov)
     CALL WriteField_v('vcovfi',vcov)
@@ -175,5 +175,5 @@
     CALL WriteField_u('pfi',p)
     CALL WriteField_u('pkfi',pk)
-#endif
+END IF
     
     CALL SetTag(Request_physic,800)
@@ -219,5 +219,5 @@
   
   
-#ifdef DEBUG_IO    
+IF (CPPKEY_DEBUGIO) THEN
     CALL WriteField_u('ucovfi',ucov)
     CALL WriteField_v('vcovfi',vcov)
@@ -228,5 +228,5 @@
       CALL WriteField_u('qfi'//trim(int2str(iq)),q(:,:,iq))
     ENDDO
-#endif
+END IF
 
   !$OMP BARRIER
@@ -302,7 +302,7 @@
         
         
-#ifdef DEBUG_IO           
+IF (CPPKEY_DEBUGIO) THEN
     CALL WriteField_u('dufi',dufi)
-    CALL WriteField_v('dvfi',dvfi) 
+    CALL WriteField_v('dvfi',dvfi)
     CALL WriteField_u('dtetafi',dtetafi)
     CALL WriteField_u('dpfi',dpfi)
@@ -310,5 +310,5 @@
       CALL WriteField_u('dqfi'//trim(int2str(iq)),dqfi(:,:,iq))
     ENDDO
-#endif
+END IF
 
   !$OMP BARRIER
@@ -316,5 +316,5 @@
 !      ajout des tendances physiques:
 !      ------------------------------
-#ifdef DEBUG_IO    
+IF (CPPKEY_DEBUGIO) THEN
     CALL WriteField_u('ucovfi',ucov)
     CALL WriteField_v('vcovfi',vcov)
@@ -324,7 +324,7 @@
       CALL WriteField_u('qfi'//trim(int2str(iq)),q(:,:,iq))
     ENDDO
-#endif
-
-#ifdef DEBUG_IO           
+END IF
+
+IF (CPPKEY_DEBUGIO) THEN
     CALL WriteField_u('ucovfi',ucov)
     CALL WriteField_v('vcovfi',vcov)
@@ -334,5 +334,5 @@
       CALL WriteField_u('qfi'//trim(int2str(iq)),q(:,:,iq))
     ENDDO
-#endif
+END IF
 
     CALL addfi_loc( dtphys, leapf, forward   ,              &
@@ -351,5 +351,5 @@
 !$OMP BARRIER
 
-#ifdef DEBUG_IO    
+IF (CPPKEY_DEBUGIO) THEN
     CALL WriteField_u('ucovfi',ucov)
     CALL WriteField_v('vcovfi',vcov)
@@ -359,5 +359,5 @@
       CALL WriteField_u('qfi'//trim(int2str(iq)),q(:,:,iq))
     ENDDO
-#endif
+END IF
 
     IF (ok_strato) THEN
@@ -398,5 +398,5 @@
     ENDIF 
 
-#ifdef DEBUG_IO    
+IF (CPPKEY_DEBUGIO) THEN
     CALL WriteField_u('ucovfi',ucov_dyn)
     CALL WriteField_v('vcovfi',vcov_dyn)
@@ -406,5 +406,5 @@
       CALL WriteField_u('qfi'//trim(int2str(iq)),q_dyn(:,:,iq))
     ENDDO
-#endif
+END IF
 
 
Index: /LMDZ6/trunk/libf/dyn3dmem/call_dissip_mod.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/call_dissip_mod.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/call_dissip_mod.F90	(revision 5258)
@@ -87,4 +87,5 @@
   USE vampir
   USE write_field_loc
+  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
   IMPLICIT NONE
     INCLUDE 'comgeom.h'
@@ -144,9 +145,9 @@
     CALL dissip_loc(vcov,ucov,teta,p,dvdis,dudis,dtetadis)
 
-#ifdef DEBUG_IO    
+IF (CPPKEY_DEBUGIO) THEN
     CALL WriteField_u('dudis',dudis)
     CALL WriteField_v('dvdis',dvdis)
     CALL WriteField_u('dtetadis',dtetadis)
-#endif
+END IF
  
 !      CALL FTRACE_REGION_END("dissip")
Index: /LMDZ6/trunk/libf/dyn3dmem/dissip_loc.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/dissip_loc.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/dissip_loc.F90	(revision 5258)
@@ -8,4 +8,5 @@
   USE dissip_mod, ONLY: dissip_allocate
   USE comconst_mod, ONLY: dtdiss
+  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
   IMPLICIT NONE
 
@@ -116,8 +117,8 @@
   ENDIF
 
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   call WriteField_u('gdx',gdx)
   call WriteField_v('gdy',gdy)
-#endif
+END IF
 
   ijb=ij_begin
@@ -161,8 +162,8 @@
   ENDIF
 
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   call WriteField_u('grx',grx)
   call WriteField_v('gry',gry)
-#endif
+END IF
 
 
@@ -215,7 +216,7 @@
   ENDIF
 
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   call WriteField_u('gdx',gdx)
-#endif
+END IF
 
 
Index: /LMDZ6/trunk/libf/dyn3dmem/exner_hyb_loc_m.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/exner_hyb_loc_m.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/exner_hyb_loc_m.F90	(revision 5258)
@@ -37,5 +37,5 @@
     USE comconst_mod, ONLY: cpp, kappa, r, jmp1
     USE comvert_mod, ONLY: preff
-    
+    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
     IMPLICIT NONE
     !
@@ -185,12 +185,12 @@
        jjb=jj_begin
        jje=jj_end
-#ifdef DEBUG_IO    
+IF (CPPKEY_DEBUGIO) THEN
        call WriteField_u('pkf',pkf)
-#endif
+END IF
        CALL filtreg_p ( pkf,jjb_u,jje_u,jjb,jje, jmp1, llm, &
             2, 1, .TRUE., 1 )
-#ifdef DEBUG_IO    
+IF (CPPKEY_DEBUGIO) THEN
        call WriteField_u('pkf',pkf)
-#endif     
+END IF
     end if
 
Index: /LMDZ6/trunk/libf/dyn3dmem/groupe_loc.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/groupe_loc.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/groupe_loc.F90	(revision 5258)
@@ -4,4 +4,5 @@
   USE groupe_mod
   USE comconst_mod, ONLY: ngroup
+  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
   implicit none
 
@@ -71,11 +72,11 @@
 !$OMP END DO NOWAIT
 
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   CALL WriteField_v('pbarvm',reshape(pbarvm,(/ip1jm,llm/)))
-#endif
+END IF
   call groupeun_loc(jjm,llm,jjb_v,jje_v,jjb,jje,pbarvm)
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   CALL WriteField_v('pbarvm',reshape(pbarvm,(/ip1jm,llm/)))
-#endif
+END IF
   !   Champs 3D
 
Index: /LMDZ6/trunk/libf/dyn3dmem/integrd_loc.f90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/integrd_loc.f90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/integrd_loc.f90	(revision 5258)
@@ -15,5 +15,5 @@
   USE comvert_mod, ONLY: ap, bp
   USE temps_mod, ONLY: dt
-
+  USE strings_mod, ONLY: int2str
   IMPLICIT NONE
 
Index: /LMDZ6/trunk/libf/dyn3dmem/leapfrog_loc.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/leapfrog_loc.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/leapfrog_loc.F90	(revision 5258)
@@ -1,11 +1,2 @@
-!
-! $Id$
-!
-!
-!
-#define DEBUG_IO
-#undef DEBUG_IO
-
-
 SUBROUTINE leapfrog_loc(ucov0,vcov0,teta0,ps0, &
         masse0,phis0,q0,time_0)
@@ -46,5 +37,6 @@
          xios_set_current_context, &
          using_xios
-   USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA, CPPKEY_REPROBUS
+   USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA, CPPKEY_REPROBUS, CPPKEY_DEBUGIO
+   USE strings_mod, ONLY: int2str
 
   IMPLICIT NONE
@@ -696,5 +688,5 @@
 !$OMP END MASTER
 
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   call WriteField_u('du',du)
   call WriteField_v('dv',dv)
@@ -707,5 +699,5 @@
   call WriteField_u('masse',masse)
   call WriteField_u('pk',pk)
-#endif
+END IF
   !-----------------------------------------------------------------------
   !   calcul des tendances advection des traceurs (dont l'humidite)
@@ -747,5 +739,5 @@
    call VTb(VTintegre)
 !$OMP END MASTER
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   if (true_itau>20) then
   call WriteField_u('ucovm1',ucovm1)
@@ -758,5 +750,5 @@
   call WriteField_u('ps_int',ps)
   endif
-#endif
+END IF
 !$OMP BARRIER
     ! CALL FTRACE_REGION_BEGIN("integrd")
@@ -775,5 +767,5 @@
     ! CALL FTRACE_REGION_END("integrd")
 !$OMP BARRIER
-#ifdef DEBUG_IO
+IF (CPPKEY_DEBUGIO) THEN
   call WriteField_u('ucovm1',ucovm1)
   call WriteField_v('vcovm1',vcovm1)
@@ -784,5 +776,5 @@
   call WriteField_u('teta_int',teta)
   call WriteField_u('ps_int',ps)
-#endif
+END IF
 
   call check_isotopes(q,ijb_u,ije_u,'leapfrog 775')
Index: /LMDZ6/trunk/libf/dyn3dmem/vlspltgen_loc.F90
===================================================================
--- /LMDZ6/trunk/libf/dyn3dmem/vlspltgen_loc.F90	(revision 5257)
+++ /LMDZ6/trunk/libf/dyn3dmem/vlspltgen_loc.F90	(revision 5258)
@@ -33,4 +33,5 @@
   USE comconst_mod, ONLY: cpp
   USE logic_mod, ONLY: adv_qsat_liq
+  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
   IMPLICIT NONE
 
@@ -187,11 +188,4 @@
   ENDDO
 
-#ifdef DEBUG_IO
-   CALL WriteField_u('mu',mu)
-   CALL WriteField_v('mv',mv)
-   CALL WriteField_u('mw',mw)
-   CALL WriteField_u('qsat',qsat)
-#endif
-
   ! ! verif temporaire
   ijb=ij_begin
@@ -204,8 +198,4 @@
     IF(tracers(iq)%parent /= 'air') CYCLE
     ! !write(*,*) 'vlspltgen 192: iq,iadv=',iq,tracers(iq)%iadv
-#ifdef DEBUG_IO
-    CALL WriteField_u('zq',zq(:,:,iq))
-    CALL WriteField_u('zm',zm(:,:,iq))
-#endif
     SELECT CASE(tracers(iq)%iadv)
       CASE(0); CYCLE
@@ -340,8 +330,4 @@
    IF(tracers(iq)%parent /= 'air') CYCLE
    ! !write(*,*) 'vlspltgen 321: iq=',iq
-#ifdef DEBUG_IO
-   CALL WriteField_u('zq',zq(:,:,iq))
-   CALL WriteField_u('zm',zm(:,:,iq))
-#endif
 
     SELECT CASE(tracers(iq)%iadv)
@@ -360,8 +346,4 @@
    IF(tracers(iq)%parent /= 'air') CYCLE
   ! !write(*,*) 'vlspltgen 349: iq=',iq
-#ifdef DEBUG_IO
-   CALL WriteField_u('zq',zq(:,:,iq))
-   CALL WriteField_u('zm',zm(:,:,iq))
-#endif
     SELECT CASE(tracers(iq)%iadv)
       CASE(0); CYCLE
@@ -462,8 +444,4 @@
     IF(tracers(iq)%parent /= 'air') CYCLE
   ! !write(*,*) 'vlspltgen 449: iq=',iq
-#ifdef DEBUG_IO
-   CALL WriteField_u('zq',zq(:,:,iq))
-   CALL WriteField_u('zm',zm(:,:,iq))
-#endif
     SELECT CASE(tracers(iq)%iadv)
       CASE(0); CYCLE
@@ -481,8 +459,4 @@
     IF(tracers(iq)%parent /= 'air') CYCLE
   ! !write(*,*) 'vlspltgen 477: iq=',iq
-#ifdef DEBUG_IO
-   CALL WriteField_u('zq',zq(:,:,iq))
-   CALL WriteField_u('zm',zm(:,:,iq))
-#endif
     SELECT CASE(tracers(iq)%iadv)
       CASE(0); CYCLE
@@ -508,8 +482,4 @@
   DO iq=1,nqtot
    ! !write(*,*) 'vlspltgen_loc 561, iq=',iq
-#ifdef DEBUG_IO
-   CALL WriteField_u('zq',zq(:,:,iq))
-   CALL WriteField_u('zm',zm(:,:,iq))
-#endif
 !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
     DO l=1,llm
