subroutine ave_stelspec(startype,STELLAR) !================================================================== ! ! Purpose ! ------- ! Average the chosen high resolution stellar spectrum over the ! visible bands in the model. ! ! Authors ! ------- ! Robin Wordsworth (2010). ! ! Called by ! --------- ! setspv.F ! ! Calls ! ----- ! none ! !================================================================== use radinc_h, only: L_NSPECTV use radcommon_h, only: BWNV, DWNV, tstellar use datafile_mod, only: datadir implicit none real*8 STELLAR(L_NSPECTV) integer startype integer Nfine parameter(Nfine=5000) integer ifine real lam(Nfine) real stel_f(Nfine) integer band real dl character(len=50) :: file_id character(len=100) :: file_path STELLAR(:)=0.0 ! load high resolution wavenumber data (lambda) file_id='/stellar_spectra/lam.txt' file_path=TRIM(datadir)//TRIM(file_id) open(110,file=file_path,form='formatted') do ifine=1,Nfine read(110,*) lam(ifine) enddo close(110) dl=lam(2)-lam(1) ! load high resolution stellar data if(startype.eq.1)then file_id='/stellar_spectra/sol.txt' tstellar=5800. elseif(startype.eq.2)then file_id='/stellar_spectra/gl581.txt' tstellar=3200. elseif(startype.eq.3)then file_id='/stellar_spectra/adleo.txt' tstellar=3200. elseif(startype.eq.4)then file_id='/stellar_spectra/gj644.txt' print*,'Find out tstellar before using this star!' call abort elseif(startype.eq.5)then file_id='/stellar_spectra/hd128167.txt' tstellar=6700. ! Segura et al. (2003) else print*,'Error: unknown star type chosen' call abort endif file_path=TRIM(datadir)//TRIM(file_id) open(111,file=file_path,form='formatted') do ifine=1,Nfine read(111,*) stel_f(ifine) enddo close(111) ! sum data by band band=1 do ifine = 1,Nfine if(lam(Nfine-ifine+1) .lt. real(10000.0/BWNV(band+1)))then band=band+1 endif if(band .gt. L_NSPECTV)then goto 9999 ! ok, ok, I know they're evil endif STELLAR(band)=STELLAR(band)+stel_f(Nfine-ifine+1)*dl end do 9999 continue STELLAR=STELLAR/sum(STELLAR) ! write(18,*)'stellar',STELLAR end subroutine ave_stelspec