Index: /branches/ORCHIDEE_EXT/ORCHIDEE/src_sechiba/condveg.f90
===================================================================
--- /branches/ORCHIDEE_EXT/ORCHIDEE/src_sechiba/condveg.f90	(revision 385)
+++ /branches/ORCHIDEE_EXT/ORCHIDEE/src_sechiba/condveg.f90	(revision 386)
@@ -682,5 +682,5 @@
   ALLOCATE(lat_rel(iml,jml), STAT=ALLOC_ERR)
   IF (ALLOC_ERR/=0) THEN
-     PRINT *,"ERROR IN ALLOCATION of lat_rel : ",ALLOC_ERR
+     WRITE(numout,*) "ERROR IN ALLOCATION of lat_rel : ",ALLOC_ERR
      STOP 
   ENDIF
@@ -688,5 +688,5 @@
   ALLOCATE(lon_rel(iml,jml), STAT=ALLOC_ERR)
   IF (ALLOC_ERR/=0) THEN
-     PRINT *,"ERROR IN ALLOCATION of lon_rel : ",ALLOC_ERR
+     WRITE(numout,*) "ERROR IN ALLOCATION of lon_rel : ",ALLOC_ERR
      STOP 
   ENDIF
@@ -694,5 +694,5 @@
   ALLOCATE(mask(iml,jml), STAT=ALLOC_ERR)
   IF (ALLOC_ERR/=0) THEN
-     PRINT *,"ERROR IN ALLOCATION of mask : ",ALLOC_ERR
+     WRITE(numout,*) "ERROR IN ALLOCATION of mask : ",ALLOC_ERR
      STOP 
   ENDIF
@@ -700,5 +700,5 @@
   ALLOCATE(soilcol(iml,jml), STAT=ALLOC_ERR)
   IF (ALLOC_ERR/=0) THEN
-     PRINT *,"ERROR IN ALLOCATION of soiltext : ",ALLOC_ERR
+     WRITE(numout,*) "ERROR IN ALLOCATION of soiltext : ",ALLOC_ERR
      STOP 
   ENDIF
@@ -739,5 +739,5 @@
      ALLOCATE(sub_area(nbpt,nbvmax), STAT=ALLOC_ERR)
      IF (ALLOC_ERR/=0) THEN
-        PRINT *,"ERROR IN ALLOCATION of sub_area : ",ALLOC_ERR
+         WRITE(numout,*) "ERROR IN ALLOCATION of sub_area : ",ALLOC_ERR
         STOP 
      ENDIF
@@ -746,5 +746,5 @@
      ALLOCATE(sub_index(nbpt,nbvmax,2), STAT=ALLOC_ERR)
      IF (ALLOC_ERR/=0) THEN
-        PRINT *,"ERROR IN ALLOCATION of sub_index : ",ALLOC_ERR
+        WRITE(numout,*) "ERROR IN ALLOCATION of sub_index : ",ALLOC_ERR
         STOP 
      ENDIF
Index: /branches/ORCHIDEE_EXT/ORCHIDEE/src_sechiba/slowproc.f90
===================================================================
--- /branches/ORCHIDEE_EXT/ORCHIDEE/src_sechiba/slowproc.f90	(revision 385)
+++ /branches/ORCHIDEE_EXT/ORCHIDEE/src_sechiba/slowproc.f90	(revision 386)
@@ -536,5 +536,5 @@
     ALLOCATE(frac_nobio_nextyear(kjpindex, nnobio), STAT=ier)
     IF (ier/=0) THEN
-      PRINT *,"ERROR IN ALLOCATION of frac_nobio_nextyear : ",ier
+      WRITE(numout,*) "ERROR IN ALLOCATION of frac_nobio_nextyear : ",ier
       STOP 
     ENDIF
@@ -544,5 +544,5 @@
     ALLOCATE(totfrac_nobio_nextyear(kjpindex), STAT=ier)
     IF (ier/=0) THEN
-      PRINT *,"ERROR IN ALLOCATION of totfrac_nobio_nextyear : ",ier
+      WRITE(numout,*) "ERROR IN ALLOCATION of totfrac_nobio_nextyear : ",ier
       STOP 
     ENDIF
@@ -871,14 +871,17 @@
                       IF (natural(jv)) THEN 
                          veget_max(:,jv)=zero
-                      ELSE
-                         sum_veget_max = zero
-                         DO ji = 1, kjpindex
-                            ! we sum only on the indexes corresponding to the non_natural pfts
+                      ENDIF
+                   ENDDO
+                   !
+                   sum_veget_max = zero
+                   DO ji = 1, kjpindex
+                      ! we sum only on the indexes corresponding to the non_natural pfts
+                      DO jv = 2,nvm
+                         IF (.NOT. natural(jv)) THEN
                             sum_veget_max = sum_veget_max + veget_max(ji,jv)
-!                            veget_max(ji,1) = un - SUM(veget_max(ji,jv))-SUM(frac_nobio(ji,:))
-                         ENDDO
-                         veget_max(ji,1) = un - sum_veget_max - SUM(frac_nobio(ji,:))
-                      ENDIF
-                   ENDDO !- end loop nvm
+                         ENDIF
+                      ENDDO
+                      veget_max(ji,1) = un - sum_veget_max - SUM(frac_nobio(ji,:))
+                   ENDDO
                 ELSE
                    veget_max(:,:) = zero
@@ -908,13 +911,16 @@
                       IF (natural(jv)) THEN 
                          veget_max(:,jv)=zero
-                      ELSE
-                         ! Add 15/03/2011
-                         sum_veget_max = zero
-                         DO ji = 1, kjpindex
+                      ENDIF
+                   ENDDO
+                   !
+                   sum_veget_max = zero
+                   DO ji = 1, kjpindex
+                      DO jv = 2, nvm
+                         IF(.NOT. natural(jv)) THEN
                             sum_veget_max = sum_veget_max + veget_max(ji,jv)
-                         ENDDO                            
-                         veget_max(ji,1) = un - sum_veget_max- SUM(frac_nobio(ji,:))   
-                      ENDIF
-                   ENDDO !- end loop nvm
+                         ENDIF
+                      ENDDO
+                      veget_max(ji,1) = un - sum_veget_max- SUM(frac_nobio(ji,:))   
+                   ENDDO
                 ELSE
                    veget_max(:,:) = zero
@@ -929,6 +935,6 @@
              !
        ELSE
-             ! WITH restarts for vegetation and DGVM and NO AGRICULTURE
-             IF ( control%ok_dgvm  ) THEN
+          ! WITH restarts for vegetation and DGVM and NO AGRICULTURE
+          IF ( control%ok_dgvm  ) THEN
              !
              ! If we are dealing with dynamic vegetation then all
@@ -937,19 +943,12 @@
              ! set to 0 as well
              !
-!             IF (.NOT. agriculture) THEN
-!                DO ji = 1, kjpindex
-!                   veget_max(ji,1) = veget_max(ji,1) + SUM(veget_max(ji,nvm-1:nvm))
-!                ENDDO
-!                veget_max(ji,nvm-1:nvm) = zero
-!             ENDIF
-
 !$$$ 25/10/10 :: Modif DS & NV :: attention garde t'on la masse de C !!!
              IF (.NOT. agriculture) THEN
                 DO jv = 2, nvm  
                    DO ji = 1, kjpindex
-                        IF ( .NOT. natural (jv))  THEN
+                      IF ( .NOT. natural (jv))  THEN
                          veget_max(ji,1) = veget_max(ji,1) + veget_max(ji,jv)
                          veget_max(ji,jv) = zero
-                        ENDIF  
+                      ENDIF
                    ENDDO
                 ENDDO
@@ -2727,5 +2726,5 @@
     CHARACTER(LEN=80) :: filename
     INTEGER(i_std) :: iml, jml, lml, tml, fid, ib, ip, jp, vid
-    REAL(r_std) :: lev(1), date, dt, coslat, pi
+    REAL(r_std) :: lev(1), date, dt, coslat
     INTEGER(i_std) :: itau(1)
     REAL(r_std), ALLOCATABLE, DIMENSION(:) :: lat_ful, lon_ful, vegmap
@@ -3963,5 +3962,4 @@
     INTEGER(i_std), INTENT(out)                  :: inear
 
-!    REAL(r_std)                                  :: pi
     REAL(r_std)                                  :: pa, p
     REAL(r_std)                                  :: coscolat, sincolat
Index: /branches/ORCHIDEE_EXT/ORCHIDEE/src_stomate/stomate_alloc.f90
===================================================================
--- /branches/ORCHIDEE_EXT/ORCHIDEE/src_stomate/stomate_alloc.f90	(revision 385)
+++ /branches/ORCHIDEE_EXT/ORCHIDEE/src_stomate/stomate_alloc.f90	(revision 386)
@@ -152,5 +152,10 @@
     !
     L0 = 1. - R0 - S0  ! defined in constantes.f90
-    IF ((L0 .LT. zero) .OR. (S0 .EQ. un)) STOP 'L0 negative or division by zero if S0 = 1' 
+    IF ((L0 .LT. zero) .OR. (S0 .EQ. un)) THEN
+       CALL ipslerr (3,'in module stomate_alloc', &
+            &           'Something wrong happened', &
+            &           'L0 negative or division by zero if S0 = 1', &
+            &           '(Check your parameters.)')
+    ENDIF
 
     !
