Index: trunk/LMDZ.GENERIC/README
===================================================================
--- trunk/LMDZ.GENERIC/README	(revision 2403)
+++ trunk/LMDZ.GENERIC/README	(revision 2422)
@@ -1588,6 +1588,10 @@
 core, as it is obsolete with respect to the one provide in LMDZ.COMMON.
 
-
 == 09/07/2020 == DB
 Add kstar parameter to control kmin value (set value in the parameterization). kmin=1/lambda_max, to ensure the "subgrid scale" characteristic, we have to constrain the maximum GW's wavelength (lambda_max) by the size of the mesh. So, kmin=max(kstar, kmin prescribed value) 
 
+== 21/10/2020 == YJ
+Add possibility to read stellar spectra from input file in "ave_stelspec.F90" with option "startype==11" in "callphys.def".
+Input file need to be in "datagcm/stellar_spectra/" and called in "callphys.def" by "stelspec_file=...".
+File format have one and only one header line.
+With this option you also need to specify in "callphys.def" "tstellar==..."
Index: trunk/LMDZ.GENERIC/libf/phystd/ave_stelspec.F90
===================================================================
--- trunk/LMDZ.GENERIC/libf/phystd/ave_stelspec.F90	(revision 2403)
+++ trunk/LMDZ.GENERIC/libf/phystd/ave_stelspec.F90	(revision 2422)
@@ -27,4 +27,5 @@
       use datafile_mod, only: datadir
       use callkeys_mod, only: stelbbody,stelTbb,startype
+      use ioipsl_getin_p_mod, only: getin_p
 
       implicit none
@@ -41,6 +42,7 @@
       real dl
 
-      character(len=100)  :: file_id,file_id_lam
+      character(len=100) :: file_id,file_id_lam
       character(len=200) :: file_path,file_path_lam
+      character(len=150) :: stelspec_file
 
       real lam_temp
@@ -120,4 +122,49 @@
             file_id_lam='/stellar_spectra/lambda_Proxima.dat'
             Nfine=5000
+           Case(11)
+            ! look for a " stelspec_file= ..." option in def files
+            write(*,*) "Input stellar spectra files for radiative transfer is:"
+            stelspec_file = "sun.txt" ! default
+            call getin_p("stelspec_file",stelspec_file) ! default path
+            write(*,*) " stelspec_file = ",trim(stelspec_file)
+            write(*,*) 'Please use ',1,' and only ',1,' header line in ',trim(stelspec_file)
+            ! look for a " tstellar= ..." option in def files
+            write(*,*) "Input stellar temperature is:"
+            tstellar = -1. ! default
+            call getin_p("tstellar",tstellar) ! default path
+            write(*,*) " tstellar = ",tstellar
+            if (tstellar.eq.-1.) then
+              write(*,*)'Error: with startype 11 tstellar need to be specified'
+              write(*,*)'  Specified in callphys.def tstellar=...'
+              stop
+            end if
+   
+            ! Opening file
+            file_path = trim(datadir)//'/stellar_spectra/'//stelspec_file
+            print*, 'stellar flux : ', file_path
+            OPEN(UNIT=110,FILE=file_path,STATUS='old',iostat=ios)
+   
+            if (ios /= 0) THEN
+              write(*,*)'Error: cannot open stelspec_file file ', trim(stelspec_file)
+              write(*,*)'It should be in :',trim(datadir),'/stellar_spectra/'
+              write(*,*)'1) You can change the data directory in callphys.def'
+              write(*,*)'   with:'
+              write(*,*)'   datadir=/path/to/the/directory'
+              write(*,*)'2) You can change the input stelspec_file file name in'
+              write(*,*)'   callphys.def with:'
+              write(*,*)'   stelspec_file=filename'
+              stop
+            end if
+
+            ! Get number of line in the file
+            READ(110,*) ! skip header
+            Nfine = 0
+            do
+              read(110,*,iostat=ios)
+              if (ios<0) exit
+              Nfine = Nfine + 1
+            end do
+            rewind(110) ! Rewind file after counting lines
+            READ(110,*) ! skip header
 	   Case Default
             print*,'Error: unknown star type chosen'
@@ -128,4 +175,10 @@
 	 allocate(lam(Nfine),stel_f(Nfine))
 
+      if (startype.eq.11) then
+         do ifine=1,Nfine
+           read(110,*) lam(ifine), stel_f(ifine) ! lam [um] stel_f [per unit of wavelength] (integrated and normalized by Fat1AU)
+         enddo
+         close(110)
+      else
          file_path_lam=TRIM(datadir)//TRIM(file_id_lam)
          open(110,file=file_path_lam,form='formatted',status='old',iostat=ios)
@@ -163,4 +216,5 @@
            close(111)
          endif
+      end if
 !$OMP END MASTER
 !$OMP BARRIER
