Index: LMDZ5/branches/LMDZ5V2.0-dev/libf/phylmd/readaerosol.F90
===================================================================
--- LMDZ5/branches/LMDZ5V2.0-dev/libf/phylmd/readaerosol.F90	(revision 1455)
+++ LMDZ5/branches/LMDZ5V2.0-dev/libf/phylmd/readaerosol.F90	(revision 1484)
@@ -7,5 +7,5 @@
 CONTAINS
 
-SUBROUTINE readaerosol(name_aero, type, iyr_in, klev_src, pt_ap, pt_b, pt_out, psurf, load)
+SUBROUTINE readaerosol(name_aero, type, filename, iyr_in, klev_src, pt_ap, pt_b, pt_out, psurf, load)
 
 !****************************************************************************************
@@ -27,5 +27,6 @@
   ! Input arguments
   CHARACTER(len=7), INTENT(IN) :: name_aero
-  CHARACTER(len=*), INTENT(IN) :: type  ! correspond to aer_type in clesphys.h
+  CHARACTER(len=*), INTENT(IN) :: type  ! actuel, annuel, scenario or preind
+  CHARACTER(len=8), INTENT(IN) :: filename
   INTEGER, INTENT(IN)          :: iyr_in
 
@@ -58,5 +59,5 @@
      ! get_aero_fromfile returns pt_out allocated and initialized with data for 12 month 
      ! pt_out has dimensions (klon, klev_src, 12)
-     CALL get_aero_fromfile(name_aero, cyear, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
+     CALL get_aero_fromfile(name_aero, cyear, filename, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
      
 
@@ -67,5 +68,5 @@
      ! get_aero_fromfile returns pt_out allocated and initialized with data for 12 month 
      ! pt_out has dimensions (klon, klev_src, 12)
-     CALL get_aero_fromfile(name_aero, cyear, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
+     CALL get_aero_fromfile(name_aero, cyear, filename, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
      
   ELSE IF (type == 'annuel') THEN
@@ -76,5 +77,5 @@
      ! get_aero_fromfile returns pt_out allocated and initialized with data for nbr_tsteps month 
      ! pt_out has dimensions (klon, klev_src, 12)
-     CALL get_aero_fromfile(name_aero, cyear, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
+     CALL get_aero_fromfile(name_aero, cyear, filename, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
      
   ELSE IF (type == 'scenario') THEN
@@ -86,5 +87,5 @@
         ! get_aero_fromfile returns pt_out allocated and initialized with data for 12 month 
         ! pt_out has dimensions (klon, klev_src, 12)
-        CALL get_aero_fromfile(name_aero, cyear, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
+        CALL get_aero_fromfile(name_aero, cyear, filename, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
         
      ELSE IF (iyr_in .GE. 2100) THEN
@@ -93,5 +94,5 @@
         ! get_aero_fromfile returns pt_out allocated and initialized with data for 12 month 
         ! pt_out has dimensions (klon, klev_src, 12)
-        CALL get_aero_fromfile(name_aero, cyear, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
+        CALL get_aero_fromfile(name_aero, cyear, filename, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
         
      ELSE
@@ -113,5 +114,5 @@
         ! get_aero_fromfile returns pt_out allocated and initialized with data for 12 month 
         ! pt_out has dimensions (klon, klev_src, 12)
-        CALL get_aero_fromfile(name_aero, cyear, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
+        CALL get_aero_fromfile(name_aero, cyear, filename, klev_src, pt_ap, pt_b, p0, pt_out, psurf, load)
         
         ! If to read two decades:
@@ -125,5 +126,5 @@
            ! get_aero_fromfile returns pt_2 allocated and initialized with data for 12 month 
            ! pt_2 has dimensions (klon, klev_src, 12)
-           CALL get_aero_fromfile(name_aero, cyear, klev_src2, pt_ap, pt_b, p0, pt_2, psurf2, load2)
+           CALL get_aero_fromfile(name_aero, cyear, filename, klev_src2, pt_ap, pt_b, p0, pt_2, psurf2, load2)
            ! Test for same number of vertical levels
            IF (klev_src /= klev_src2) THEN
@@ -160,5 +161,5 @@
 
   ELSE
-     WRITE(lunout,*)'This option is not implemented : aer_type = ', type
+     WRITE(lunout,*)'This option is not implemented : aer_type = ', type,' name_aero=',name_aero
      CALL abort_gcm('readaerosol','Error : aer_type parameter not accepted',1)
   END IF ! type
@@ -168,5 +169,5 @@
 
 
-  SUBROUTINE get_aero_fromfile(varname, cyr, klev_src, pt_ap, pt_b, p0, pt_year, psurf_out, load_out)
+  SUBROUTINE get_aero_fromfile(varname, cyr, filename, klev_src, pt_ap, pt_b, p0, pt_year, psurf_out, load_out)
 !****************************************************************************************
 ! Read 12 month aerosol from file and distribute to local process on physical grid. 
@@ -200,4 +201,5 @@
     CHARACTER(len=7), INTENT(IN)          :: varname
     CHARACTER(len=4), INTENT(IN)          :: cyr
+    CHARACTER(len=8), INTENT(IN)          :: filename
 
 ! Output arguments
@@ -213,5 +215,4 @@
 ! Local variables
     CHARACTER(len=30)     :: fname
-    CHARACTER(len=8)      :: filename='aerosols'
     CHARACTER(len=30)     :: cvar
     INTEGER               :: ncid, dimid, varid
@@ -242,7 +243,8 @@
 ! 1) Open file 
 !****************************************************************************************
-       fname = filename//cyr//'.nc'
+! Add suffix to filename
+       fname = trim(filename)//cyr//'.nc'
   
-       WRITE(lunout,*) 'reading ', TRIM(fname)
+       WRITE(lunout,*) 'reading variable ',TRIM(varname),' in file ', TRIM(fname)
        CALL check_err( nf90_open(TRIM(fname), NF90_NOWRITE, ncid) )
 
@@ -283,14 +285,4 @@
           CALL abort_gcm('get_aero_fromfile', 'latitudes do not correspond between file and model',1)
        END IF
-
-! 1.5) Check number of month in file opened
-!
-!**************************************************************************************************
-       ierr = nf90_inq_dimid(ncid, 'TIME',dimid)
-       CALL check_err( nf90_inquire_dimension(ncid, dimid, len = nbr_tsteps) )
-!       IF (nbr_tsteps /= 12 .AND. nbr_tsteps /= 14) THEN
-       IF (nbr_tsteps /= 12 ) THEN
-         CALL abort_gcm('get_aero_fromfile', 'not the right number of months in aerosol file read (should be 12 for the moment)',1)
-       ENDIF
 
 
@@ -335,4 +327,12 @@
 
        IF (new_file) THEN
+! ++) Check number of month in file opened
+!**************************************************************************************************
+       ierr = nf90_inq_dimid(ncid, 'TIME',dimid)
+       CALL check_err( nf90_inquire_dimension(ncid, dimid, len = nbr_tsteps) )
+!       IF (nbr_tsteps /= 12 .AND. nbr_tsteps /= 14) THEN
+       IF (nbr_tsteps /= 12 ) THEN
+         CALL abort_gcm('get_aero_fromfile', 'not the right number of months in aerosol file read (should be 12 for the moment)',1)
+       ENDIF
 
 ! ++) Read the aerosol concentration month by month and concatenate to total variable varyear
