Index: trunk/LMDZ.MARS/README
===================================================================
--- trunk/LMDZ.MARS/README	(revision 2326)
+++ trunk/LMDZ.MARS/README	(revision 2327)
@@ -3059,2 +3059,6 @@
 - List of input files removed from code and put as input
 
+== 18/05/2020 == AB
+Some improvements in aeroptical.F90 :
+1) add the possibility to input a diagfi_P.nc file (with pressure as altitude coordinates) ;
+2) replace all "title" attributes into "long_name" attributes in accordance with ticket #48
Index: trunk/LMDZ.MARS/util/aeroptical.F90
===================================================================
--- trunk/LMDZ.MARS/util/aeroptical.F90	(revision 2326)
+++ trunk/LMDZ.MARS/util/aeroptical.F90	(revision 2327)
@@ -74,6 +74,6 @@
 character(len=16) :: tmpvarname                  ! temporarily stores a variable name
 real,dimension(:,:,:,:,:),allocatable :: opa_aer ! Aerosols opacities [1/km]
-real :: missval                                  ! Value to put in outfile when the reff is out of bounds
-PARAMETER(missval=1E+20)
+real,dimension(:),allocatable :: missval         ! Value to put in outfile when the reff is out of bounds
+                                                 ! or when there is a mising value in input file
 
 
@@ -179,4 +179,8 @@
 allocate(mmr(naerkind,lonlen,latlen,altlen,timelen))
 allocate(reff(naerkind,lonlen,latlen,altlen,timelen))
+
+! Initialize missing value
+allocate(missval(naerkind))
+missval(:)=1.e+20
 
 ! Initialize aerok to .true. for all aerosols
@@ -201,4 +205,9 @@
   call status_check(ierr,error_text)
   write(*,*) "Dust mass mixing ratio loaded from "//trim(gcmfile)
+  ! Get missing value
+  ierr=nf90_get_att(gcmfid,tmpvarid,"missing_value",missval(1))
+  if (ierr.ne.nf90_noerr) then
+    missval(1) = 1.e+20
+  endif
 endif
 
@@ -238,4 +247,9 @@
   call status_check(ierr,error_text)
   write(*,*) "Water ice mass mixing ratio loaded from "//trim(gcmfile)
+  ! Get missing value
+  ierr=nf90_get_att(gcmfid,tmpvarid,"missing_value",missval(2))
+  if (ierr.ne.nf90_noerr) then
+    missval(2) = 1.e+20
+  endif
 endif
 
@@ -532,6 +546,6 @@
     ierr=nf90_put_att(outfid,tmpvaridout,"units","opacity/km")
     ierr=nf90_put_att(outfid,tmpvaridout,"refwavelength",wvl_val)
-    ierr=nf90_put_att(outfid,tmpvaridout,"missing_value",missval)
-    write(*,*)"with missing value = ",missval
+    ierr=nf90_put_att(outfid,tmpvaridout,"missing_value",missval(iaer))
+    write(*,*)"with missing value = ",missval(iaer)
     
     ! End netcdf define mode
@@ -557,5 +571,10 @@
 
            ! NB: this should especially handle cases when reff=0
-           opa_aer(iaer,ilon,ilat,ialt,it)=missval
+           opa_aer(iaer,ilon,ilat,ialt,it)=missval(iaer)
+           
+         else if (mmr(iaer,ilon,ilat,ialt,it).eq.missval(iaer)) then
+           ! if there is a missing value in input file
+           opa_aer(iaer,ilon,ilat,ialt,it)=missval(iaer)
+           
          else
            if (radiusdyn(isize).eq.reff(iaer,ilon,ilat,ialt,it)) then
@@ -1049,5 +1068,5 @@
 integer, intent(in) :: lonlen ! # of grid points along longitude
 integer, intent(in) :: latlen ! # of grid points along latitude
-integer, intent(in) :: altlen ! # of grid points along latitude
+integer, intent(in) :: altlen ! # of grid points along altitude
 integer, intent(in) :: GCM_layers ! # of GCM atmospheric layers
 integer, intent(in) :: outfid ! NetCDF output file ID
@@ -1204,5 +1223,5 @@
 
 !==============================================================================
-! 2.2. Hybrid coordinates ap() , bp(), aps() and bps()
+! 2.1 Hybrid coordinates ap() , bp(), aps() and bps()
 !==============================================================================
 if(hybrid) then 
@@ -1216,5 +1235,5 @@
   endif
   ! Write the attributes
-  ierr=nf90_put_att(outfid,tmpvarid,"title","hybrid pressure at midlayers")
+  ierr=nf90_put_att(outfid,tmpvarid,"long_name","hybrid pressure at midlayers")
   ierr=nf90_put_att(outfid,tmpvarid,"units"," ")
   ! End netcdf define mode
@@ -1236,5 +1255,5 @@
   endif
   ! Write the attributes
-  ierr=nf90_put_att(outfid,tmpvarid,"title","hybrid sigma at midlayers")
+  ierr=nf90_put_att(outfid,tmpvarid,"long_name","hybrid sigma at midlayers")
   ierr=nf90_put_att(outfid,tmpvarid,"units"," ")
   ! End netcdf define mode
@@ -1258,5 +1277,5 @@
     endif
     ! Write the attributes
-    ierr=nf90_put_att(outfid,tmpvarid,"title","hybrid sigma at interlayers")
+    ierr=nf90_put_att(outfid,tmpvarid,"long_name","hybrid sigma at interlayers")
     ierr=nf90_put_att(outfid,tmpvarid,"units"," ")
     ! End netcdf define mode
@@ -1279,5 +1298,5 @@
     endif
     ! Write the attributes
-    ierr=nf90_put_att(outfid,tmpvarid,"title","hybrid sigma at interlayers")
+    ierr=nf90_put_att(outfid,tmpvarid,"long_name","hybrid sigma at interlayers")
     ierr=nf90_put_att(outfid,tmpvarid,"units"," ")
     ! End netcdf define mode
@@ -1301,5 +1320,5 @@
   endif
   ! Write the attributes
-  ierr=nf90_put_att(outfid,tmpvarid,"title","sigma at midlayers")
+  ierr=nf90_put_att(outfid,tmpvarid,"long_name","sigma at midlayers")
   ierr=nf90_put_att(outfid,tmpvarid,"units"," ")
   ! End netcdf define mode
@@ -1314,5 +1333,5 @@
 
 !==============================================================================
-! 2.2. aire() and phisinit()
+! 2.2 aire() and phisinit()
 !==============================================================================
 
@@ -1327,5 +1346,5 @@
   endif
   ! Write the attributes
-  ierr=nf90_put_att(outfid,tmpvarid,"title","Mesh area")
+  ierr=nf90_put_att(outfid,tmpvarid,"long_name","Mesh area")
   ierr=nf90_put_att(outfid,tmpvarid,"units","m2")
   ! End netcdf define mode
@@ -1339,5 +1358,5 @@
 endif ! of if (area)
 
-IF (phis) THEN
+if (phis) then
 
   ! Switch to netcdf define mode
@@ -1349,5 +1368,5 @@
   endif
   ! Write the attributes
-  ierr=nf90_put_att(outfid,tmpvarid,"title","Ground level geopotential")
+  ierr=nf90_put_att(outfid,tmpvarid,"long_name","Ground level geopotential")
   ierr=nf90_put_att(outfid,tmpvarid,"units"," ")
   ! End netcdf define mode
@@ -1360,5 +1379,5 @@
   endif
 
-ENDIF ! of IF (phis)
+endif ! of if (phis)
 
 
