Index: LMDZ5/trunk/libf/phylmd/aeropt_2bands.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/aeropt_2bands.F90	(revision 2632)
+++ LMDZ5/trunk/libf/phylmd/aeropt_2bands.F90	(revision 2634)
@@ -12,5 +12,4 @@
   USE phys_local_var_mod, only: absvisaer
   USE pres2lev_mod
-
 
   !    Yves Balkanski le 12 avril 2006
@@ -128,11 +127,7 @@
   REAL :: zrho
   REAL :: fac
-  REAL :: zdp1(klon,klev) 
-  REAL, PARAMETER ::  gravit = 9.80616    ! m2/s
+  REAL :: zdh(klon,klev) 
   INTEGER, ALLOCATABLE, DIMENSION(:)   :: aerosol_name
   INTEGER :: nb_aer
-  REAL, DIMENSION(klon,klev,naero_tot) :: mass_temp
-!RAF
-  REAL, DIMENSION(klon,klev,naero_tot) :: mass_temp_pi
 
   !
@@ -587,11 +582,8 @@
   END IF ! firstcall
 
-
   DO k=1, klev
     DO i=1, klon
-      zrho=pplay(i,k)/t_seri(i,k)/RD                  ! kg/m3
-      mass_temp(i,k,:) = m_allaer(i,k,:) / zrho / 1.e+9
-      mass_temp_pi(i,k,:) = m_allaer_pi(i,k,:) / zrho / 1.e+9
-      zdp1(i,k)=pdel(i,k)/(gravit*delt)      ! air mass auxiliary  variable --> zdp1 [kg/(m^2 *s)]
+      zrho=pplay(i,k)/t_seri(i,k)/RD    ! kg/m3
+      zdh(i,k)=pdel(i,k)/(RG*zrho)      ! m
     ENDDO
   ENDDO
@@ -645,6 +637,4 @@
   !      compute optical_thickness_at_gridpoint_per_species
 
-
-
 !CDIR ON_ADB(fact_RH)
 !CDIR SHORTLOOP
@@ -660,5 +650,4 @@
       IF (rh(i,k).GT.85.) RH_num(i,k)=10
       IF (rh(i,k).GT.90.) RH_num(i,k)=11
-      
       DELTA(i,k)=(rh(i,k)-RH_tab(RH_num(i,k)))*fact_RH(RH_num(i,k))
     ENDDO
@@ -718,5 +707,4 @@
     used_aer(id)=.TRUE.
 
-     
     IF (soluble) THEN
 
@@ -739,8 +727,10 @@
 !CDIR ON_ADB(C1_ASSSM_b2)
 !CDIR ON_ADB(C2_ASSSM_b2)
+
               DO i=1, KLON
+
                 H=rh(i,k)/100
-                tmp_var=mass_temp(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
-                tmp_var_pi=mass_temp_pi(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
+                tmp_var=m_allaer(i,k,spsol)/1.e6*zdh(i,k)*fac
+                tmp_var_pi=m_allaer_pi(i,k,spsol)/1.e6*zdh(i,k)*fac
 
                 ! band 1
@@ -784,8 +774,10 @@
 !CDIR ON_ADB(C1_CSSSM_b2)
 !CDIR ON_ADB(C2_CSSSM_b2)
+
               DO i=1, KLON
+
                 H=rh(i,k)/100
-                tmp_var=mass_temp(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
-                tmp_var_pi=mass_temp_pi(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
+                tmp_var=m_allaer(i,k,spsol)/1.e6*zdh(i,k)*fac
+                tmp_var_pi=m_allaer_pi(i,k,spsol)/1.e6*zdh(i,k)*fac
                 ! band 1
                 tau_ae2b_int=A1_CSSSM_b1(k)+A2_CSSSM_b1(k)*H+A3_CSSSM_b1(k)/(H-1.05)
@@ -828,8 +820,10 @@
 !CDIR ON_ADB(C1_SSSSM_b2)
 !CDIR ON_ADB(C2_SSSSM_b2)
+
               DO i=1, KLON
+
                 H=rh(i,k)/100
-                tmp_var=mass_temp(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
-                tmp_var_pi=mass_temp_pi(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
+                tmp_var=m_allaer(i,k,spsol)/1.e6*zdh(i,k)*fac
+                tmp_var_pi=m_allaer_pi(i,k,spsol)/1.e6*zdh(i,k)*fac
 
                 ! band 1 
@@ -864,6 +858,6 @@
           DO k=1, KLEV
             DO i=1, KLON
-              tmp_var=mass_temp(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
-              tmp_var_pi=mass_temp_pi(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
+              tmp_var=m_allaer(i,k,spsol)/1.e6*zdh(i,k)*fac
+              tmp_var_pi=m_allaer_pi(i,k,spsol)/1.e6*zdh(i,k)*fac
 !CDIR UNROLL=nbands
               DO inu=1,nbands
@@ -899,6 +893,6 @@
         DO k=1, KLEV
           DO i=1, KLON
-            tmp_var=mass_temp(i,k,naero_soluble+ spinsol)*1000.*zdp1(i,k)*delt*fac
-            tmp_var_pi=mass_temp_pi(i,k,naero_soluble+spinsol)*1000.*zdp1(i,k)*delt*fac
+            tmp_var=m_allaer(i,k,naero_soluble+spinsol)/1.e6*zdh(i,k)*fac
+            tmp_var_pi=m_allaer_pi(i,k,naero_soluble+spinsol)/1.e6*zdh(i,k)*fac
 !CDIR UNROLL=nbands
             DO inu=1,nbands
@@ -931,6 +925,10 @@
 
   DO inu=1, nbands
-    DO mrfspecies=1,naero_grp
+
+    !!DO mrfspecies=1,naero_grp
+    DO mrfspecies=2,3    !--only deal with total and natural aerosols
+
       IF (mrfspecies .EQ. 2) THEN             ! = total aerosol AER	 
+
         DO k=1, KLEV
           DO i=1, KLON
@@ -1026,4 +1024,5 @@
                    
       ELSEIF (mrfspecies .EQ. 4) THEN             ! = BC
+
         DO k=1, KLEV
           DO i=1, KLON
@@ -1128,5 +1127,5 @@
   ENDDO
 
-  inu=1         ! visible wavaband
+  inu=1         ! visible waveband
   mrfspecies=2  ! total aerosol AER	 
   DO i=1, KLON
Index: LMDZ5/trunk/libf/phylmd/aeropt_5wv.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/aeropt_5wv.F90	(revision 2632)
+++ LMDZ5/trunk/libf/phylmd/aeropt_5wv.F90	(revision 2634)
@@ -13,5 +13,4 @@
   USE phys_local_var_mod, only: od550aer,od865aer,ec550aer,od550lt1aer
   USE pres2lev_mod
-
 
   !
@@ -66,9 +65,7 @@
   ! Output arguments:
   !
-  REAL, DIMENSION(klon), INTENT(out)          :: ai      ! POLDER aerosol index 
+  REAL, DIMENSION(klon), INTENT(out)          :: ai      ! POLDER aerosol index
   REAL, DIMENSION(klon,nwave,naero_tot), INTENT(out)      :: tausum
   REAL, DIMENSION(klon,klev,nwave,naero_tot), INTENT(out) :: tau
-
-
   !
   ! Local
@@ -134,15 +131,13 @@
   REAL :: cg_ae5wv_int  ! Intermediate asymmetry parameter aerosol
   REAL, PARAMETER :: RH_MAX=95.
-  REAL :: taue670(KLON)       ! epaisseur optique aerosol absorption 550 nm
-  REAL :: taue865(KLON)       ! epaisseur optique aerosol extinction 865 nm
+  REAL :: taue670(klon)       ! epaisseur optique aerosol absorption 550 nm
+  REAL :: taue865(klon)       ! epaisseur optique aerosol extinction 865 nm
   REAL :: fac
-  REAL :: zdp1(klon,klev) 
-  REAL, PARAMETER ::  gravit = 9.80616    ! m2/s
   INTEGER, ALLOCATABLE, DIMENSION(:)  :: aerosol_name
   INTEGER :: nb_aer
   
-  REAL :: tau3d(KLON,KLEV), piz3d(KLON,KLEV), cg3d(KLON,KLEV)
-  REAL :: abs3d(KLON,KLEV)     ! epaisseur optique d'absorption
-  REAL :: dh(KLON,KLEV)
+  REAL :: tau3d(klon,klev), piz3d(klon,klev), cg3d(klon,klev)
+  REAL :: abs3d(klon,klev)     ! epaisseur optique d'absorption
+  REAL :: dh(klon,klev)
   
   REAL :: alpha_aers_5wv(nbre_RH,las,naero_soluble)   ! ext. coeff. Soluble comp. units *** m2/g 
@@ -155,12 +150,7 @@
    !  1- BC soluble; 2- POM soluble; 3- SO4 acc.; 4- SO4 coarse; 5 seasalt super-C; 6 seasalt coarse; 7 seasalt acc.
   REAL :: piz_aeri_5wv(las,naero_insoluble)           ! Insoluble comp. 1- Dust: 2- BC; 3- POM
-
-  REAL, DIMENSION(klon,klev,naero_tot) :: mass_temp
-  
   !
   ! Proprietes optiques
   !
-  REAL :: radry = 287.054
-  REAL :: tau_tmp                     ! dry air mass constant
   REAL :: fact_RH(nbre_RH)
   LOGICAL :: used_tau(naero_spc)
@@ -303,8 +293,4 @@
 !*********************************************************************
 !
-!
-! 
-! 
-!  
 ! 
 ! From here on we look at the optical parameters at 5 wavelengths:  
@@ -478,5 +464,4 @@
       0.737,0.750,0.765,0.775,0.787,0.803/
  !
-
   DATA cg_aeri_5wv/&
      ! dust insoluble
@@ -616,20 +601,15 @@
   END IF ! firstcall
 
-
   ! Initialisations
-  ai(:) = 0.
-  tausum(:,:,:) = 0.
-
+  tau(:,:,:,:) =0.
+  tausum(:,:,:)= 0.
+  ai(:)=0.0
 
   DO k=1, klev
     DO i=1, klon
-      zrho=pplay(i,k)/t_seri(i,k)/RD                  ! kg/m3
-      dh(i,k)=pdel(i,k)/(gravit*zrho)
-      mass_temp(i,k,:) = m_allaer(i,k,:) / zrho / 1.e+9
-      zdp1(i,k)=pdel(i,k)/(gravit*delt)     ! air mass auxiliary  variable --> zdp1 [kg/(m^2 *s)]
-
+      zrho=pplay(i,k)/t_seri(i,k)/RD     ! kg/m3
+      dh(i,k)=pdel(i,k)/(RG*zrho)    ! m
     ENDDO
   ENDDO
-
 
   IF (flag_aerosol .EQ. 1) THEN 
@@ -680,22 +660,18 @@
   !      compute optical_thickness_at_gridpoint_per_species
   
-
   !
   ! Calculations that need to be done since we are not in the subroutines INCA
   !      
 
-!CDIR ON_ADB(RH_tab)
-!CDIR ON_ADB(fact_RH)
-!CDIR NOVECTOR
   DO n=1,nbre_RH-1
     fact_RH(n)=1./(RH_tab(n+1)-RH_tab(n))
   ENDDO
    
-  DO k=1, KLEV
-!CDIR ON_ADB(RH_tab)
-!CDIR ON_ADB(fact_RH)
-    DO i=1, KLON
+  DO k=1, klev
+    DO i=1, klon
       rh(i,k)=MIN(RHcl(i,k)*100.,RH_MAX)
       RH_num(i,k) = INT( rh(i,k)/10. + 1.)
+!--test olivier pour pas de reindicage
+!      RH_num(i,k) =1
       IF (rh(i,k).GT.85.) RH_num(i,k)=10
       IF (rh(i,k).GT.90.) RH_num(i,k)=11
@@ -704,5 +680,4 @@
   ENDDO
 
-!CDIR SHORTLOOP  
   used_tau(:)=.FALSE.
     
@@ -765,17 +740,16 @@
     DO la=1,las
 
+    !--only 550 and 865 nm are used
+    IF (la.NE.la550.AND.la.NE.la865) CYCLE
+
       IF (soluble) THEN
 
-        IF((la.EQ.2).AND.(spss.NE.0)) THEN !la=2 corresponds to 550 nm
+        IF ((la.EQ.2).AND.(spss.NE.0)) THEN !la=2 corresponds to 550 nm
           IF (spss.EQ.1) THEN !accumulation mode
-            DO k=1, KLEV
-!CDIR ON_ADB(A1_ASSSM)
-!CDIR ON_ADB(A2_ASSSM)
-!CDIR ON_ADB(A3_ASSSM)
-              DO i=1, KLON
-                H=rh(i,k)/100
+            DO k=1, klev
+              DO i=1, klon
+                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,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)   &
-                                   *tau_ae5wv_int*delt*fac
+                tau(i,k,la,aerindex) = m_allaer(i,k,aerindex)/1.e6*dh(i,k)*tau_ae5wv_int*fac
                 tausum(i,la,aerindex)=tausum(i,la,aerindex)+tau(i,k,la,aerindex)
               ENDDO
@@ -784,28 +758,9 @@
   
           IF (spss.EQ.2) THEN !coarse mode
-            DO k=1, KLEV
-!CDIR ON_ADB(A1_CSSSM)
-!CDIR ON_ADB(A2_CSSSM)
-!CDIR ON_ADB(A3_CSSSM)
-              DO i=1, KLON
-                H=rh(i,k)/100
+            DO k=1, klev
+              DO i=1, klon
+                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,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)  &
-                                   *tau_ae5wv_int*delt*fac
-                tausum(i,la,aerindex) = tausum(i,la,aerindex)+tau(i,k,la,aerindex)
-              ENDDO
-            ENDDO
-          ENDIF
-
-          IF (spss.EQ.3) THEN !super coarse mode
-            DO k=1, KLEV
-!CDIR ON_ADB(A1_SSSSM)
-!CDIR ON_ADB(A2_SSSSM)
-!CDIR ON_ADB(A3_SSSSM)
-              DO i=1, KLON
-                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,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)  &
-                                   *tau_ae5wv_int*delt*fac
+                tau(i,k,la,aerindex) = m_allaer(i,k,aerindex)/1.e6*dh(i,k)*tau_ae5wv_int*fac
                 tausum(i,la,aerindex)=tausum(i,la,aerindex)+tau(i,k,la,aerindex)
               ENDDO
@@ -813,14 +768,22 @@
           ENDIF
 
+          IF (spss.EQ.3) THEN !super coarse mode
+            DO k=1, klev
+              DO i=1, klon
+                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,aerindex) = m_allaer(i,k,aerindex)/1.e6*dh(i,k)*tau_ae5wv_int*fac
+                tausum(i,la,aerindex)=tausum(i,la,aerindex)+tau(i,k,la,aerindex)
+              ENDDO
+            ENDDO
+          ENDIF
+
         ELSE
-          DO k=1, KLEV
-!CDIR ON_ADB(alpha_aers_5wv)
-            DO i=1, KLON
+          DO k=1, klev
+            DO i=1, klon
               tau_ae5wv_int = alpha_aers_5wv(RH_num(i,k),la,spsol)+DELTA(i,k)* &
                              (alpha_aers_5wv(RH_num(i,k)+1,la,spsol) - & 
                               alpha_aers_5wv(RH_num(i,k),la,spsol))
-
-              tau(i,k,la,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)   &
-                                 *tau_ae5wv_int*delt*fac
+              tau(i,k,la,aerindex) = m_allaer(i,k,aerindex)/1.e6*dh(i,k)*tau_ae5wv_int*fac
               tausum(i,la,aerindex)=tausum(i,la,aerindex)+tau(i,k,la,aerindex)
             ENDDO
@@ -829,14 +792,15 @@
 
       ELSE                                                  ! For insoluble aerosol
-        DO k=1, KLEV
-!CDIR ON_ADB(alpha_aeri_5wv)
-          DO i=1, KLON
+
+        DO k=1, klev
+          DO i=1, klon
             tau_ae5wv_int = alpha_aeri_5wv(la,spinsol)
-            tau(i,k,la,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)* &
-                                                tau_ae5wv_int*delt*fac
-            tausum(i,la,aerindex)= tausum(i,la,aerindex)+tau(i,k,la,aerindex)
+            tau(i,k,la,aerindex) = m_allaer(i,k,aerindex)/1.e6*dh(i,k)*tau_ae5wv_int*fac
+            tausum(i,la,aerindex)=tausum(i,la,aerindex)+tau(i,k,la,aerindex)
           ENDDO
         ENDDO
+
       ENDIF
+
     ENDDO   ! boucle sur les longueurs d'onde
   ENDDO     ! Boucle  sur les masses de traceurs
@@ -845,40 +809,16 @@
     IF (.NOT.used_tau(m)) tau(:,:,:,m)=0.
   ENDDO  
-!
-!
-!  taue670(:) = SUM(tausum(:,la670,:),dim=2) 
-!  taue865(:) = SUM(tausum(:,la865,:),dim=2) 
-!
-!  DO i=1, klon
-!    ai(i)=-LOG(MAX(taue670(i),0.0001)/ &
-!       MAX(taue865(i),0.0001))/LOG(670./865.)
-!  ENDDO
-
-  DO i=1, klon
-     od550aer(i)=0.
-     DO m=1,naero_spc
-        od550aer(i)=od550aer(i)+tausum(i,2,m)
-     ENDDO
-  ENDDO
-
-  DO i=1, klon
-     od865aer(i)=0.
-     DO m=1,naero_spc
-        od865aer(i)=od865aer(i)+tausum(i,5,m)
-     ENDDO
-  ENDDO
-
-  DO i=1, klon
-     DO k=1, KLEV
-        ec550aer(i,k)=0.
-        DO m=1,naero_spc
-           ec550aer(i,k)=ec550aer(i,k)+tau(i,k,2,m)/dh(i,k)
-        ENDDO
-     ENDDO
-  ENDDO
+
+!--AOD calculations for diagnostics
+  od550aer(:)=SUM(tausum(:,la550,:),dim=2)
+  od865aer(:)=SUM(tausum(:,la865,:),dim=2)
+
+!--extinction coefficient for diagnostic
+  ec550aer(:,:)=SUM(tau(:,:,la550,:),dim=3)/dh(:,:)
   
-   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)
+!--acc mode AOD calculation for diagnostic
+  od550lt1aer(:)=tausum(:,la550,id_ASSO4M_phy)+tausum(:,la550,id_ASBCM_phy)+tausum(:,la550,id_AIBCM_phy)+  &
+                 tausum(:,la550,id_ASPOMM_phy)+tausum(:,la550,id_AIPOMM_phy)+tausum(:,la550,id_ASSSM_phy)+ &
+                 0.03*tausum(:,la550,id_CSSSM_phy)+0.4*tausum(:,la550,id_CIDUSTM_phy)
 
   DEALLOCATE(aerosol_name) 
Index: LMDZ5/trunk/libf/phylmd/rrtm/aeropt_5wv_rrtm.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/rrtm/aeropt_5wv_rrtm.F90	(revision 2632)
+++ LMDZ5/trunk/libf/phylmd/rrtm/aeropt_5wv_rrtm.F90	(revision 2634)
@@ -94,10 +94,9 @@
   REAL :: od670aer(klon)  ! epaisseur optique aerosol extinction 670 nm
   REAL :: fac
-  REAL :: zdp1(klon,klev) 
   INTEGER, ALLOCATABLE, DIMENSION(:)  :: aerosol_name
   INTEGER :: nb_aer, itau
   LOGICAL :: ok_itau
   
-  REAL :: dh(KLON,KLEV)
+  REAL :: zdh(klon,klev)
   
    ! Soluble components 1- BC soluble; 2- POM soluble; 3- SO4 acc.; 4- SO4 coarse; 5 seasalt super-coarse; 6 seasalt coarse; 7 seasalt acc.
@@ -106,11 +105,8 @@
   REAL :: alpha_aeri_5wv(las,naero_insoluble)         ! Ext. coeff. ** m2/g 
 
-  REAL, DIMENSION(klon,klev,naero_tot) :: mass_temp
-  
   !
   ! Proprietes optiques
   !
   REAL :: fact_RH(nbre_RH)
-  LOGICAL :: used_tau(naero_tot)
   INTEGER :: n
 
@@ -209,12 +205,10 @@
   ai(:) = 0.
   tausum(:,:,:) = 0.
+  tau(:,:,:,:)=0.
 
   DO k=1, klev
     DO i=1, klon
       zrho=pplay(i,k)/t_seri(i,k)/RD                  ! kg/m3
-      dh(i,k)=pdel(i,k)/(RG*zrho)
-!CDIR UNROLL=naero_spc
-      mass_temp(i,k,:) = m_allaer(i,k,:) / zrho / 1.e+9
-      zdp1(i,k)=pdel(i,k)/(RG*delt)     ! air mass auxiliary  variable --> zdp1 [kg/(m^2 *s)]
+      zdh(i,k)=pdel(i,k)/(RG*zrho)                    ! m
     ENDDO
   ENDDO
@@ -270,15 +264,10 @@
   !      
 
-!CDIR ON_ADB(RH_tab)
-!CDIR ON_ADB(fact_RH)
-!CDIR NOVECTOR
   DO n=1,nbre_RH-1
     fact_RH(n)=1./(RH_tab(n+1)-RH_tab(n))
   ENDDO
    
-  DO k=1, KLEV
-!CDIR ON_ADB(RH_tab)
-!CDIR ON_ADB(fact_RH)
-    DO i=1, KLON
+  DO k=1, klev
+    DO i=1, klon
       rh(i,k)=MIN(RHcl(i,k)*100.,RH_MAX)
       RH_num(i,k) = INT( rh(i,k)/10. + 1.)
@@ -289,7 +278,4 @@
   ENDDO
 
-!CDIR SHORTLOOP  
-  used_tau(:)=.FALSE.
-    
   DO m=1,nb_aer   ! tau is only computed for each mass    
     fac=1.0
@@ -330,23 +316,19 @@
     ENDIF
 
-    IF (soluble) then
-      used_tau(spsol)=.TRUE.
-    ELSE
-      used_tau(naero_soluble+spinsol)=.TRUE.
-    ENDIF
-
     aerindex=aerosol_name(m)
 
     DO la=1,las
 
+    !--only 550, 670 and 865 nm are used
+    IF (la.NE.la550.AND.la.NE.la670.AND.la.NE.la865) CYCLE
+
       IF (soluble) THEN            ! For soluble aerosol
 
-          DO k=1, KLEV
-            DO i=1, KLON
+          DO k=1, klev
+            DO i=1, klon
               tau_ae5wv_int = alpha_aers_5wv(RH_num(i,k),la,spsol)+DELTA(i,k)* &
                              (alpha_aers_5wv(RH_num(i,k)+1,la,spsol) - & 
                               alpha_aers_5wv(RH_num(i,k),la,spsol))
-              tau(i,k,la,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)*   &
-                                    tau_ae5wv_int*delt*fac
+              tau(i,k,la,aerindex) = m_allaer(i,k,aerindex)/1.e6*zdh(i,k)*tau_ae5wv_int*fac
               tausum(i,la,aerindex)=tausum(i,la,aerindex)+tau(i,k,la,aerindex)
             ENDDO
@@ -355,9 +337,8 @@
       ELSE                         ! For insoluble aerosol
 
-        DO k=1, KLEV
-          DO i=1, KLON
+        DO k=1, klev
+          DO i=1, klon
             tau_ae5wv_int = alpha_aeri_5wv(la,spinsol)
-            tau(i,k,la,aerindex) = mass_temp(i,k,aerindex)*1000.*zdp1(i,k)* &
-                                   tau_ae5wv_int*delt*fac
+            tau(i,k,la,aerindex) = m_allaer(i,k,aerindex)/1.e6*zdh(i,k)*tau_ae5wv_int*fac
             tausum(i,la,aerindex)= tausum(i,la,aerindex)+tau(i,k,la,aerindex)
           ENDDO
@@ -369,41 +350,14 @@
   ENDDO     ! Boucle sur les masses de traceurs
 
-  DO m=1,naero_tot
-    IF (.NOT.used_tau(m)) tau(:,:,:,m)=0.
-  ENDDO  
-
-  DO i=1, klon
-     od550aer(i)=0.
-     DO m=1,naero_tot
-        od550aer(i)=od550aer(i)+tausum(i,la550,m)
-     END DO
-  END DO
-
-  DO i=1, klon
-     od670aer(i)=0.
-     DO m=1,naero_tot
-        od670aer(i)=od670aer(i)+tausum(i,la670,m)
-     END DO
-  END DO
-
-  DO i=1, klon
-     od865aer(i)=0.
-     DO m=1,naero_tot
-        od865aer(i)=od865aer(i)+tausum(i,la865,m)
-     END DO
-  END DO
-
-  DO i=1, klon
-     DO k=1, KLEV
-        ec550aer(i,k)=0.
-        DO m=1,naero_tot
-           ec550aer(i,k)=ec550aer(i,k)+tau(i,k,la550,m)/dh(i,k)
-        END DO
-     END DO
-  END DO
-  
-  DO i=1, klon
-    ai(i)=-LOG(MAX(od670aer(i),1.e-8)/MAX(od865aer(i),1.e-8))/LOG(670./865.)
-  ENDDO
+!--AOD calculations for diagnostics
+  od550aer(:)=SUM(tausum(:,la550,:),dim=2)
+  od670aer(:)=SUM(tausum(:,la670,:),dim=2)
+  od865aer(:)=SUM(tausum(:,la865,:),dim=2)
+
+!--extinction coefficient for diagnostic
+  ec550aer(:,:)=SUM(tau(:,:,la550,:),dim=3)/zdh(:,:)
+
+!--aerosol index
+  ai(:)=-LOG(MAX(od670aer(:),1.e-8)/MAX(od865aer(:),1.e-8))/LOG(670./865.)
 
   od550lt1aer(:)=tausum(:,la550,id_ASSO4M_phy)+tausum(:,la550,id_ASBCM_phy) +tausum(:,la550,id_AIBCM_phy)+ &
Index: LMDZ5/trunk/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90
===================================================================
--- LMDZ5/trunk/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90	(revision 2632)
+++ LMDZ5/trunk/libf/phylmd/rrtm/aeropt_6bands_rrtm.F90	(revision 2634)
@@ -36,6 +36,6 @@
   !
   ! Output arguments:
-  ! 1= total aerosols 
-  ! 2= natural aerosols
+  ! 2= total aerosols 
+  ! 1= natural aerosols
   !
   REAL, DIMENSION(klon,klev,2,nbands_sw_rrtm), INTENT(out) :: tau_allaer ! epaisseur optique aerosol
@@ -66,16 +66,12 @@
   REAL :: Fact_RH(nbre_RH)
   REAL :: fac
-  REAL :: zdp1(klon,klev) 
+  REAL :: zdh(klon,klev) 
   INTEGER, ALLOCATABLE, DIMENSION(:)   :: aerosol_name
   INTEGER :: nb_aer
 
-  REAL, DIMENSION(klon,klev,naero_tot) :: mass_temp
-  REAL, DIMENSION(klon,klev,naero_tot) :: mass_temp_pi
   REAL, DIMENSION(klon,klev,naero_tot,nbands_sw_rrtm) ::  tau_ae
   REAL, DIMENSION(klon,klev,naero_tot,nbands_sw_rrtm) ::  tau_ae_pi
   REAL, DIMENSION(klon,klev,naero_tot,nbands_sw_rrtm) ::  piz_ae
   REAL, DIMENSION(klon,klev,naero_tot,nbands_sw_rrtm) ::  cg_ae
-
-
   !
   ! Proprietes optiques
@@ -89,5 +85,4 @@
 
   INTEGER :: id
-  LOGICAL :: used_aer(naero_tot)
   REAL :: tmp_var, tmp_var_pi
 
@@ -277,4 +272,5 @@
   spsol = 0
   spinsol = 0 
+
   IF (NSW.NE.nbands_sw_rrtm) THEN
      print *,'Erreur NSW doit etre egal a 6 pour cette routine'
@@ -282,13 +278,5 @@
   ENDIF
 
-  DO k=1, klev
-    DO i=1, klon
-!CDIR UNROLL=naero_tot
-      mass_temp(i,k,:) = m_allaer(i,k,:) / zrho(i,k) / 1.e+9  !--kg/kg
-!CDIR UNROLL=naero_tot
-      mass_temp_pi(i,k,:) = m_allaer_pi(i,k,:) / zrho(i,k) / 1.e+9
-      zdp1(i,k)=pdel(i,k)/(RG*delt)      ! air mass auxiliary  variable --> zdp1 [kg/(m^2 *s)]
-    ENDDO
-  ENDDO
+  zdh(:,:)=pdel(:,:)/(RG*zrho(:,:))      ! m
 
   IF (flag_aerosol .EQ. 1) THEN 
@@ -339,14 +327,10 @@
   !      compute optical_thickness_at_gridpoint_per_species
 
-!!CDIR ON_ADB(RH_tab)
-!CDIR ON_ADB(fact_RH)
-!CDIR SHORTLOOP
   DO n=1,nbre_RH-1
     fact_RH(n)=1./(RH_tab(n+1)-RH_tab(n))
   ENDDO
    
-  DO k=1, KLEV
-!CDIR ON_ADB(fact_RH)
-    DO i=1, KLON
+  DO k=1, klev
+    DO i=1, klon
       rh(i,k)=MIN(RHcl(i,k)*100.,RH_MAX)
       RH_num(i,k) = INT(rh(i,k)/10. + 1.)
@@ -357,5 +341,8 @@
   ENDDO
 
-  used_aer(:)=.FALSE.
+  tau_ae(:,:,:,:)=0.
+  tau_ae_pi(:,:,:,:)=0.
+  piz_ae(:,:,:,:)=0.
+  cg_ae(:,:,:,:)=0.
     
   DO m=1,nb_aer   ! tau is only computed for each mass
@@ -398,12 +385,11 @@
 
     id=aerosol_name(m)
-    used_aer(id)=.TRUE.
 
     IF (soluble) THEN
 
-       DO k=1, KLEV
-         DO i=1, KLON
-           tmp_var=mass_temp(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
-           tmp_var_pi=mass_temp_pi(i,k,spsol)*1000.*zdp1(i,k)*delt*fac
+       DO k=1, klev
+         DO i=1, klon
+           tmp_var=m_allaer(i,k,spsol)/1.e6*zdh(i,k)*fac
+           tmp_var_pi=m_allaer_pi(i,k,spsol)/1.e6*zdh(i,k)*fac
 
            DO inu=1,NSW
@@ -432,8 +418,8 @@
      ELSE    ! For all aerosol insoluble components
 
-       DO k=1, KLEV
-         DO i=1, KLON
-           tmp_var=mass_temp(i,k,naero_soluble+ spinsol)*1000.*zdp1(i,k)*delt*fac
-           tmp_var_pi=mass_temp_pi(i,k,naero_soluble+spinsol)*1000.*zdp1(i,k)*delt*fac
+       DO k=1, klev
+         DO i=1, klon
+           tmp_var=m_allaer(i,k,naero_soluble+spinsol)/1.e6*zdh(i,k)*fac
+           tmp_var_pi=m_allaer_pi(i,k,naero_soluble+spinsol)/1.e6*zdh(i,k)*fac
 
            DO inu=1,NSW
@@ -454,16 +440,7 @@
   ENDDO  ! nb_aer  
 
-  DO m=1,naero_tot
-    IF (.NOT. used_aer(m)) THEN
-      tau_ae(:,:,m,:)=0.
-      tau_ae_pi(:,:,m,:)=0.
-      piz_ae(:,:,m,:)=0.
-      cg_ae(:,:,m,:)=0.
-    ENDIF
-  ENDDO
-
   DO inu=1, NSW 
-     DO k=1, KLEV
-       DO i=1, KLON
+     DO k=1, klev
+       DO i=1, klon
 !--anthropogenic aerosol
          tau_allaer(i,k,2,inu)=tau_ae(i,k,id_ASSO4M_phy,inu)+tau_ae(i,k,id_CSSO4M_phy,inu)+ &
@@ -536,9 +513,9 @@
     ENDDO
    
-!--???????
-  inu=1
-  DO i=1, KLON
-     absvisaer(i)=SUM((1-piz_allaer(i,:,:,inu))*tau_allaer(i,:,:,inu))
-  END DO	
+!--waveband 2 and all aerosol
+  inu=2
+  DO i=1, klon
+     absvisaer(i)=SUM((1-piz_allaer(i,:,2,inu))*tau_allaer(i,:,2,inu))
+  ENDDO
 
   DEALLOCATE(aerosol_name) 
