Index: /dynamico_lmdz/simple_physics/phyparam/physics/astronomy.F90
===================================================================
--- /dynamico_lmdz/simple_physics/phyparam/physics/astronomy.F90	(revision 4193)
+++ /dynamico_lmdz/simple_physics/phyparam/physics/astronomy.F90	(revision 4194)
@@ -1,3 +1,6 @@
 MODULE astronomy
+  
+#include "use_logging.h"
+
   IMPLICIT NONE
   SAVE
@@ -79,7 +82,8 @@
     
     IF (lwrite) THEN
-       PRINT*,'jour de l"annee   :',pday
-       PRINT*,'distance au soleil (en unite astronomique) :',pdist_sol
-       PRINT*,'declinaison (en degres) :',pdecli*180./pi
+       WRITELOG(*,*) 'jour de l"annee   :',pday
+       WRITELOG(*,*) 'distance au soleil (en unite astronomique) :',pdist_sol
+       WRITELOG(*,*) 'declinaison (en degres) :',pdecli*180./pi
+       CALL flush_log
     ENDIF
     
@@ -124,14 +128,14 @@
     !-----------------------------------------------------------------------
     
-    PRINT*,'Perihelie en Mkm  ',periheli
-    PRINT*,'Aphelise  en Mkm  ',aphelie 
-    PRINT*,'obliquite en degres  :',obliquit
+    WRITELOG(*,*) 'Perihelie en Mkm  ',periheli
+    WRITELOG(*,*) 'Aphelise  en Mkm  ',aphelie 
+    WRITELOG(*,*) 'obliquite en degres  :',obliquit
     
     e_elips=(aphelie-periheli)/(periheli+aphelie)
     p_elips=0.5*(periheli+aphelie)*(1-e_elips*e_elips)/unitastr
     
-    print*,'e_elips',e_elips
-    print*,'p_elips',p_elips
-    
+    WRITELOG(*,*) 'e_elips',e_elips
+    WRITELOG(*,*) 'p_elips',p_elips
+
     !-----------------------------------------------------------------------
     ! calcul de l'angle polaire et de la distance au soleil :
@@ -143,5 +147,5 @@
     zanom=2.*pi*(zz-nint(zz))
     zxref=abs(zanom)
-    PRINT*,'zanom  ',zanom
+    WRITELOG(*,*) 'zanom  ',zanom
     
     !  resolution de l'equation horaire  zx0 - e * sin (zx0) = zxref
@@ -157,11 +161,12 @@
     zx0=zx0+zdx
     if(zanom.lt.0.) zx0=-zx0
-    PRINT*,'zx0   ',zx0
+    WRITELOG(*,*) 'zx0   ',zx0
     
     ! zteta est la longitude solaire
     
     timeperi=2.*atan(sqrt((1.+e_elips)/(1.-e_elips))*tan(zx0/2.))
-    PRINT*,'longitude solaire du perihelie timeperi = ',timeperi
-    
+    WRITELOG(*,*) 'longitude solaire du perihelie timeperi = ',timeperi
+    
+    CALL flush_log
     
   END SUBROUTINE iniorbit
Index: /dynamico_lmdz/simple_physics/phyparam/physics/logging.F90
===================================================================
--- /dynamico_lmdz/simple_physics/phyparam/physics/logging.F90	(revision 4194)
+++ /dynamico_lmdz/simple_physics/phyparam/physics/logging.F90	(revision 4194)
@@ -0,0 +1,42 @@
+MODULE logging
+
+  ! see also logging.h
+  ! macro LOGBUF accumulates log output into logging_buffer
+  ! flush_plugin points to a procedure pointer that typically prints all lines in the buffer and prepends tags
+  ! This module provides a default implementation of flush_plugin but the top-level driver is welcome to override it.
+
+  IMPLICIT NONE
+  SAVE
+  PRIVATE
+
+  INTERFACE 
+     SUBROUTINE plugin(buf)
+       CHARACTER(*), INTENT(IN) :: buf(:)
+     END SUBROUTINE plugin
+  END INTERFACE
+
+  PROCEDURE(plugin), POINTER :: flush_plugin => default_flush_plugin
+
+  INTEGER, PARAMETER :: bufsize=10000
+  CHARACTER(bufsize) :: logging_buf(100)
+
+  INTEGER :: logging_lineno=0
+
+  PUBLIC :: logging_buf, logging_lineno, flush_log, flush_plugin
+
+CONTAINS
+
+  SUBROUTINE flush_log
+    CALL flush_plugin(logging_buf(1:logging_lineno))
+    logging_lineno=0
+  END SUBROUTINE flush_log
+
+  SUBROUTINE default_flush_plugin(buf)
+    CHARACTER(*), INTENT(IN) :: buf(:)
+    INTEGER :: i
+    DO i=1, SIZE(buf)
+       PRINT *, 'INFO : ', TRIM(buf(i))
+    END DO
+  END SUBROUTINE default_flush_plugin
+  
+END MODULE logging
Index: /dynamico_lmdz/simple_physics/phyparam/physics/use_logging.h
===================================================================
--- /dynamico_lmdz/simple_physics/phyparam/physics/use_logging.h	(revision 4194)
+++ /dynamico_lmdz/simple_physics/phyparam/physics/use_logging.h	(revision 4194)
@@ -0,0 +1,2 @@
+   USE logging
+#define WRITELOG(junk, fmt) logging_lineno = logging_lineno+1 ; WRITE(logging_buf(logging_lineno), fmt)
Index: /dynamico_lmdz/simple_physics/phyparam/physics/vdif_mod.F90
===================================================================
--- /dynamico_lmdz/simple_physics/phyparam/physics/vdif_mod.F90	(revision 4193)
+++ /dynamico_lmdz/simple_physics/phyparam/physics/vdif_mod.F90	(revision 4194)
@@ -1,7 +1,10 @@
 MODULE vdif_mod
+  
+#include "use_logging.h"
+
   IMPLICIT NONE
   SAVE
   PRIVATE
-  
+
   REAL, PARAMETER :: karman=0.4
   REAL :: lmixmin=100., emin_turb=1e-8  
@@ -249,14 +252,15 @@
     IF(lwrite) THEN
        ig=ngrid/2+1
-       PRINT*,'Pression (mbar) ,altitude (km),u,v,theta, rho dz'
+       WRITELOG(*,*) 'Pression (mbar) ,altitude (km),u,v,theta, rho dz'
        DO ilay=1,nlay
-          WRITE(*,*) .01*pplay(ig,ilay),.001*pzlay(ig,ilay), &
+          WRITELOG(*,*) .01*pplay(ig,ilay),.001*pzlay(ig,ilay), &
                pu(ig,ilay),pv(ig,ilay),ph(ig,ilay),za(ig,ilay)
        ENDDO
-       PRINT*,'Pression (mbar) ,altitude (km),zb'
+       WRITELOG(*,*) 'Pression (mbar) ,altitude (km),zb'
        DO ilev=1,nlay
-          WRITE(*,*) .01*pplev(ig,ilev),.001*pzlev(ig,ilev), &
+          WRITELOG(*,*) .01*pplev(ig,ilev),.001*pzlev(ig,ilev), &
                zb0(ig,ilev)
        ENDDO
+       CALL flush_log
     ENDIF
     
@@ -287,7 +291,7 @@
     
     IF(lwrite) THEN
-       PRINT*
-       PRINT*,'Diagnostique diffusion verticale'
-       print*,'LMIXMIN',lmixmin
+       
+       WRITELOG(*,*) 'Diagnostique diffusion verticale'
+       WRITELOG(*,*) 'LMIXMIN',lmixmin
        PRINT*,'coefficients Cd pour v et h'
        PRINT*,zcdv(ngrid/2+1),zcdh(ngrid/2+1)
@@ -296,4 +300,5 @@
           PRINT*,zkv(ngrid/2+1,ilev),zkh(ngrid/2+1,ilev)
        ENDDO
+       CALL flush_log
     ENDIF
     
