Index: trunk/LMDZ.GENERIC/libf/phy_common/abort_physic.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/phy_common/abort_physic.F90	(revision 1673)
+++ trunk/LMDZ.GENERIC/libf/phy_common/abort_physic.F90	(revision 1673)
@@ -0,0 +1,50 @@
+! $Id: $
+      SUBROUTINE abort_physic(modname, message, ierr)
+     
+#ifdef CPP_IOIPSL
+      USE IOIPSL
+#else
+! if not using IOIPSL, we still need to use (a local version of) getin_dump
+      USE ioipsl_getincom
+#endif
+      USE mod_phys_lmdz_para
+      USE print_control_mod, ONLY: lunout
+      IMPLICIT NONE
+!
+! Stops the simulation cleanly, closing files and printing various
+! comments
+!
+!  Input: modname = name of calling program
+!         message = stuff to print
+!         ierr    = severity of situation ( = 0 normal )
+
+      character(len=*), intent(in):: modname
+      integer ierr, ierror_mpi
+      character(len=*), intent(in):: message
+
+      write(lunout,*) 'in abort_physic'
+#ifdef CPP_IOIPSL
+!$OMP MASTER
+      call histclo
+      call restclo
+      if (mpi_rank .eq. 0) then
+         call getin_dump
+      endif
+!$OMP END MASTER
+#endif
+
+      write(lunout,*) 'Stopping in ', modname
+      write(lunout,*) 'Reason = ',message
+      if (ierr .eq. 0) then
+        write(lunout,*) 'Everything is cool'
+      else
+        write(lunout,*) 'Houston, we have a problem, ierr = ', ierr
+#ifdef CPP_MPI
+!$OMP CRITICAL (MPI_ABORT_PHYSIC)
+        call MPI_ABORT(COMM_LMDZ_PHY, 1, ierror_mpi)
+!$OMP END CRITICAL (MPI_ABORT_PHYSIC)
+#else
+        stop 1
+#endif          
+      endif
+      END
Index: trunk/LMDZ.GENERIC/libf/phy_common/print_control_mod.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/phy_common/print_control_mod.F90	(revision 1673)
+++ trunk/LMDZ.GENERIC/libf/phy_common/print_control_mod.F90	(revision 1673)
@@ -0,0 +1,63 @@
+! $Id: $
+MODULE print_control_mod
+
+  INTEGER,SAVE :: lunout ! default output file identifier (6==screen)
+  INTEGER,SAVE :: prt_level ! debug output level
+  LOGICAL,SAVE :: debug ! flag to specify if in "debug mode"
+!$OMP THREADPRIVATE(lunout,prt_level,debug)
+
+CONTAINS
+
+  SUBROUTINE init_print_control
+  USE ioipsl_getin_p_mod, ONLY : getin_p
+  USE mod_phys_lmdz_para, ONLY: is_omp_root, is_master
+  IMPLICIT NONE
+
+    LOGICAL :: opened
+    INTEGER :: number
+    
+    !Config  Key  = prt_level
+    !Config  Desc = niveau d'impressions de débogage
+    !Config  Def  = 0
+    !Config  Help = Niveau d'impression pour le débogage
+    !Config         (0 = minimum d'impression)
+    prt_level = 0
+    CALL getin_p('prt_level',prt_level)
+
+    !Config  Key  = lunout
+    !Config  Desc = unite de fichier pour les impressions
+    !Config  Def  = 6
+    !Config  Help = unite de fichier pour les impressions 
+    !Config         (defaut sortie standard = 6)
+    lunout=6
+    CALL getin_p('lunout', lunout)
+
+    IF (is_omp_root) THEN
+      IF (lunout /= 5 .and. lunout /= 6) THEN
+         INQUIRE(FILE='lmdz.out_0000',OPENED=opened,NUMBER=number)
+         IF (opened) THEN
+           lunout=number
+         ELSE
+           OPEN(UNIT=lunout,FILE='lmdz.out_0000',ACTION='write',  &
+                STATUS='unknown',FORM='formatted')
+         ENDIF
+      ENDIF
+    ENDIF
+
+    !Config  Key  = debug
+    !Config  Desc = mode debogage
+    !Config  Def  = false
+    !Config  Help = positionne le mode debogage
+
+    debug = .FALSE.
+    CALL getin_p('debug',debug)
+    
+    IF (is_master) THEN
+      WRITE(lunout,*)"init_print_control: prt_level=",prt_level
+      WRITE(lunout,*)"init_print_control: lunout=",lunout
+      WRITE(lunout,*)"init_print_control: debug=",debug      
+    ENDIF
+    
+  END SUBROUTINE init_print_control  
+
+END MODULE print_control_mod
