Index: LMDZ5/branches/testing/libf/phylmd/aeropt_5wv.F90
===================================================================
--- LMDZ5/branches/testing/libf/phylmd/aeropt_5wv.F90	(revision 1910)
+++ LMDZ5/branches/testing/libf/phylmd/aeropt_5wv.F90	(revision 2160)
@@ -57,5 +57,5 @@
   REAL, DIMENSION(klon,klev), INTENT(in)   :: pdel
   REAL, INTENT(in)                         :: delt
-  REAL, DIMENSION(klon,klev,naero_spc), INTENT(in) :: m_allaer
+  REAL, DIMENSION(klon,klev,naero_tot), INTENT(in) :: m_allaer
   REAL, DIMENSION(klon,klev), INTENT(in)   :: RHcl     ! humidite relative ciel clair
   INTEGER,INTENT(in)                       :: flag_aerosol
@@ -67,6 +67,8 @@
   !
   REAL, DIMENSION(klon), INTENT(out)          :: ai      ! POLDER aerosol index 
-  REAL, DIMENSION(klon,nwave,naero_spc), INTENT(out)      :: tausum
-  REAL, DIMENSION(klon,klev,nwave,naero_spc), INTENT(out) :: tau
+!  REAL, DIMENSION(klon,nwave,naero_spc), INTENT(out)      :: tausum
+!  REAL, DIMENSION(klon,klev,nwave,naero_spc), INTENT(out) :: tau
+  REAL, DIMENSION(klon,nwave,naero_tot), INTENT(out)      :: tausum
+  REAL, DIMENSION(klon,klev,nwave,naero_tot), INTENT(out) :: tau
 
 
@@ -77,5 +79,5 @@
   LOGICAL :: soluble
   
-  INTEGER :: i, k, ierr, m
+  INTEGER :: i, k, ierr, m, aerindex
   INTEGER :: spsol, spinsol, spss, la
   INTEGER :: RH_num(klon,klev)
@@ -156,5 +158,5 @@
   REAL :: piz_aeri_5wv(las,naero_insoluble)           ! Insoluble comp. 1- Dust: 2- BC; 3- POM
 
-  REAL, DIMENSION(klon,klev,naero_spc) :: mass_temp
+  REAL, DIMENSION(klon,klev,naero_tot) :: mass_temp
   
   !
@@ -639,39 +641,39 @@
      nb_aer = 2
      ALLOCATE (aerosol_name(nb_aer)) 
-     aerosol_name(1) = id_ASSO4M
-     aerosol_name(2) = id_CSSO4M
+     aerosol_name(1) = id_ASSO4M_phy
+     aerosol_name(2) = id_CSSO4M_phy
   ELSEIF (flag_aerosol .EQ. 2) THEN
      nb_aer = 2
      ALLOCATE (aerosol_name(nb_aer)) 
-     aerosol_name(1) = id_ASBCM
-     aerosol_name(2) = id_AIBCM
+     aerosol_name(1) = id_ASBCM_phy
+     aerosol_name(2) = id_AIBCM_phy
   ELSEIF (flag_aerosol .EQ. 3) THEN 
      nb_aer = 2
      ALLOCATE (aerosol_name(nb_aer)) 
-     aerosol_name(1) = id_ASPOMM
-     aerosol_name(2) = id_AIPOMM
+     aerosol_name(1) = id_ASPOMM_phy
+     aerosol_name(2) = id_AIPOMM_phy
   ELSEIF (flag_aerosol .EQ. 4) THEN 
      nb_aer = 3
      ALLOCATE (aerosol_name(nb_aer)) 
-     aerosol_name(1) = id_CSSSM
-     aerosol_name(2) = id_SSSSM
-     aerosol_name(3) = id_ASSSM
+     aerosol_name(1) = id_CSSSM_phy
+     aerosol_name(2) = id_SSSSM_phy
+     aerosol_name(3) = id_ASSSM_phy
   ELSEIF (flag_aerosol .EQ. 5) THEN 
      nb_aer = 1
      ALLOCATE (aerosol_name(nb_aer)) 
-     aerosol_name(1) = id_CIDUSTM
+     aerosol_name(1) = id_CIDUSTM_phy
   ELSEIF (flag_aerosol .EQ. 6) THEN 
      nb_aer = 10
      ALLOCATE (aerosol_name(nb_aer)) 
-     aerosol_name(1) = id_ASSO4M      
-     aerosol_name(2) = id_ASBCM
-     aerosol_name(3) = id_AIBCM
-     aerosol_name(4) = id_ASPOMM
-     aerosol_name(5) = id_AIPOMM
-     aerosol_name(6) = id_CSSSM
-     aerosol_name(7) = id_SSSSM
-     aerosol_name(8) = id_ASSSM
-     aerosol_name(9) = id_CIDUSTM
-     aerosol_name(10) = id_CSSO4M
+     aerosol_name(1) = id_ASSO4M_phy
+     aerosol_name(2) = id_ASBCM_phy
+     aerosol_name(3) = id_AIBCM_phy
+     aerosol_name(4) = id_ASPOMM_phy
+     aerosol_name(5) = id_AIPOMM_phy
+     aerosol_name(6) = id_CSSSM_phy
+     aerosol_name(7) = id_SSSSM_phy
+     aerosol_name(8) = id_ASSSM_phy
+     aerosol_name(9) = id_CIDUSTM_phy
+     aerosol_name(10) = id_CSSO4M_phy
   ENDIF
 
@@ -712,43 +714,43 @@
   DO m=1,nb_aer   ! tau is only computed for each mass    
     fac=1.0
-    IF (aerosol_name(m).EQ.id_ASBCM) THEN
+    IF (aerosol_name(m).EQ.id_ASBCM_phy) THEN
         soluble=.TRUE.
         spsol=1
         spss=0
-    ELSEIF (aerosol_name(m).EQ.id_ASPOMM) THEN 
+    ELSEIF (aerosol_name(m).EQ.id_ASPOMM_phy) THEN 
         soluble=.TRUE.
         spsol=2 
         spss=0
-    ELSEIF (aerosol_name(m).EQ.id_ASSO4M) THEN
+    ELSEIF (aerosol_name(m).EQ.id_ASSO4M_phy) THEN
         soluble=.TRUE.
         spsol=3
         spss=0
         fac=1.375    ! (NH4)2-SO4/SO4 132/96 mass conversion factor for OD
-    ELSEIF (aerosol_name(m).EQ.id_CSSO4M) THEN
+    ELSEIF (aerosol_name(m).EQ.id_CSSO4M_phy) THEN
         soluble=.TRUE.
         spsol=4
         spss=0
         fac=1.375    ! (NH4)2-SO4/SO4 132/96 mass conversion factor for OD
-    ELSEIF (aerosol_name(m).EQ.id_SSSSM) THEN 
+    ELSEIF (aerosol_name(m).EQ.id_SSSSM_phy) THEN 
         soluble=.TRUE.
         spsol=5
         spss=3
-    ELSEIF (aerosol_name(m).EQ.id_CSSSM) THEN 
+    ELSEIF (aerosol_name(m).EQ.id_CSSSM_phy) THEN 
         soluble=.TRUE.
         spsol=6
         spss=2
-    ELSEIF (aerosol_name(m).EQ.id_ASSSM) THEN
+    ELSEIF (aerosol_name(m).EQ.id_ASSSM_phy) THEN
         soluble=.TRUE.
         spsol=7
         spss=1
-    ELSEIF (aerosol_name(m).EQ.id_CIDUSTM) THEN 
+    ELSEIF (aerosol_name(m).EQ.id_CIDUSTM_phy) THEN 
         soluble=.FALSE.
         spinsol=1
         spss=0
-    ELSEIF  (aerosol_name(m).EQ.id_AIBCM) THEN 
+    ELSEIF  (aerosol_name(m).EQ.id_AIBCM_phy) THEN 
         soluble=.FALSE.
         spinsol=2
         spss=0
-    ELSEIF (aerosol_name(m).EQ.id_AIPOMM) THEN 
+    ELSEIF (aerosol_name(m).EQ.id_AIPOMM_phy) THEN 
         soluble=.FALSE.
         spinsol=3
@@ -765,4 +767,6 @@
       used_tau(naero_soluble+spinsol)=.TRUE.
     ENDIF
+
+    aerindex=aerosol_name(m)
 
     DO la=1,las
@@ -779,7 +783,7 @@
                 H=rh(i,k)/100
                 tau_ae5wv_int=A1_ASSSM(k)+A2_ASSSM(k)*H+A3_ASSSM(k)/(H-1.05)
-                tau(i,k,la,spsol) = mass_temp(i,k,spsol)*1000.*zdp1(i,k)   &
+                tau(i,k,la,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)   &
                                    *tau_ae5wv_int*delt*fac
-                tausum(i,la,spsol)=tausum(i,la,spsol)+tau(i,k,la,spsol)
+                tausum(i,la,aerindex)=tausum(i,la,aerindex)+tau(i,k,la,aerindex)
               ENDDO
             ENDDO
@@ -794,7 +798,7 @@
                 H=rh(i,k)/100
                 tau_ae5wv_int=A1_CSSSM(k)+A2_CSSSM(k)*H+A3_CSSSM(k)/(H-1.05)
-                tau(i,k,la,spsol) = mass_temp(i,k,spsol)*1000.*zdp1(i,k)  &
+                tau(i,k,la,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)  &
                                    *tau_ae5wv_int*delt*fac
-                tausum(i,la,spsol) = tausum(i,la,spsol)+tau(i,k,la,spsol)
+                tausum(i,la,aerindex) = tausum(i,la,aerindex)+tau(i,k,la,aerindex)
               ENDDO
             ENDDO
@@ -809,7 +813,7 @@
                 H=rh(i,k)/100
                 tau_ae5wv_int=A1_SSSSM(k)+A2_SSSSM(k)*H+A3_SSSSM(k)/(H-1.05)
-                tau(i,k,la,spsol) = mass_temp(i,k,spsol)*1000.*zdp1(i,k)  &
+                tau(i,k,la,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)  &
                                    *tau_ae5wv_int*delt*fac
-                tausum(i,la,spsol)=tausum(i,la,spsol)+tau(i,k,la,spsol)
+                tausum(i,la,aerindex)=tausum(i,la,aerindex)+tau(i,k,la,aerindex)
               ENDDO
             ENDDO
@@ -824,7 +828,7 @@
                               alpha_aers_5wv(RH_num(i,k),la,spsol))
 
-              tau(i,k,la,spsol) = mass_temp(i,k,spsol)*1000.*zdp1(i,k)   &
+              tau(i,k,la,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)   &
                                  *tau_ae5wv_int*delt*fac
-              tausum(i,la,spsol)=tausum(i,la,spsol)+tau(i,k,la,spsol)
+              tausum(i,la,aerindex)=tausum(i,la,aerindex)+tau(i,k,la,aerindex)
             ENDDO
           ENDDO
@@ -836,8 +840,7 @@
           DO i=1, KLON
             tau_ae5wv_int = alpha_aeri_5wv(la,spinsol)
-            tau(i,k,la,naero_soluble+spinsol) = mass_temp(i,k,naero_soluble+spinsol)*1000.*zdp1(i,k)* &
+            tau(i,k,la,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)* &
                                                 tau_ae5wv_int*delt*fac
-            tausum(i,la,naero_soluble+spinsol)= tausum(i,la,naero_soluble+spinsol)  &
-                                               +tau(i,k,la,naero_soluble+spinsol)
+            tausum(i,la,aerindex)= tausum(i,la,aerindex)+tau(i,k,la,aerindex)
           ENDDO
         ENDDO
@@ -880,7 +883,7 @@
   END DO
   
-   od550lt1aer(:)=tausum(:,2,id_ASSO4M)+tausum(:,2,id_ASBCM)+tausum(:,2,id_AIBCM)+ &
-	tausum(:,2,id_ASPOMM)+tausum(:,2,id_AIPOMM)+tausum(:,2,id_ASSSM)+ &
-	0.03*tausum(:,2,id_CSSSM)+0.4*tausum(:,2,id_CIDUSTM)
+   od550lt1aer(:)=tausum(:,2,id_ASSO4M_phy)+tausum(:,2,id_ASBCM_phy)+tausum(:,2,id_AIBCM_phy)+ &
+	tausum(:,2,id_ASPOMM_phy)+tausum(:,2,id_AIPOMM_phy)+tausum(:,2,id_ASSSM_phy)+ &
+	0.03*tausum(:,2,id_CSSSM_phy)+0.4*tausum(:,2,id_CIDUSTM_phy)
 
 
