[135] | 1 | subroutine ave_stelspec(startype,STELLAR) |
---|
| 2 | |
---|
| 3 | !================================================================== |
---|
| 4 | ! |
---|
| 5 | ! Purpose |
---|
| 6 | ! ------- |
---|
| 7 | ! Average the chosen high resolution stellar spectrum over the |
---|
| 8 | ! visible bands in the model. |
---|
| 9 | ! |
---|
| 10 | ! Authors |
---|
| 11 | ! ------- |
---|
| 12 | ! Robin Wordsworth (2010). |
---|
| 13 | ! |
---|
| 14 | ! Called by |
---|
| 15 | ! --------- |
---|
| 16 | ! setspv.F |
---|
| 17 | ! |
---|
| 18 | ! Calls |
---|
| 19 | ! ----- |
---|
| 20 | ! none |
---|
| 21 | ! |
---|
| 22 | !================================================================== |
---|
| 23 | |
---|
| 24 | use radinc_h, only: L_NSPECTV |
---|
| 25 | use radcommon_h, only: BWNV, DWNV, tstellar |
---|
| 26 | |
---|
| 27 | implicit none |
---|
| 28 | |
---|
| 29 | #include "datafile.h" |
---|
| 30 | |
---|
| 31 | real*8 STELLAR(L_NSPECTV) |
---|
| 32 | integer startype |
---|
| 33 | |
---|
| 34 | integer Nfine |
---|
| 35 | parameter(Nfine=5000) |
---|
| 36 | integer ifine |
---|
| 37 | |
---|
| 38 | real lam(Nfine) |
---|
| 39 | real stel_f(Nfine) |
---|
| 40 | real band |
---|
| 41 | real dl |
---|
| 42 | |
---|
| 43 | character(len=50) :: file_id |
---|
| 44 | character(len=100) :: file_path |
---|
| 45 | |
---|
| 46 | STELLAR(:)=0.0 |
---|
| 47 | |
---|
| 48 | ! load high resolution wavenumber data |
---|
| 49 | file_id='/stellar_spectra/lam.txt' |
---|
| 50 | file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id)) |
---|
| 51 | |
---|
| 52 | open(110,file=file_path,form='formatted') |
---|
| 53 | do ifine=1,Nfine |
---|
| 54 | read(110,*) lam(ifine) |
---|
| 55 | enddo |
---|
| 56 | close(110) |
---|
| 57 | |
---|
| 58 | dl=lam(2)-lam(1) |
---|
| 59 | |
---|
| 60 | ! load high resolution stellar data |
---|
| 61 | if(startype.eq.1)then |
---|
| 62 | file_id='/stellar_spectra/sol.txt' |
---|
| 63 | tstellar=5800. |
---|
| 64 | elseif(startype.eq.2)then |
---|
| 65 | file_id='/stellar_spectra/gl581.txt' |
---|
| 66 | tstellar=3200. |
---|
| 67 | elseif(startype.eq.3)then |
---|
| 68 | file_id='/stellar_spectra/adleo.txt' |
---|
| 69 | tstellar=3200. |
---|
| 70 | elseif(startype.eq.4)then |
---|
| 71 | file_id='/stellar_spectra/gj644.txt' |
---|
| 72 | print*,'Find out tstellar before using this star!' |
---|
| 73 | call abort |
---|
| 74 | elseif(startype.eq.5)then |
---|
| 75 | file_id='/stellar_spectra/hd128167.txt' |
---|
| 76 | tstellar=6700. ! Segura et al. (2003) |
---|
| 77 | else |
---|
| 78 | print*,'Error: unknown star type chosen' |
---|
| 79 | call abort |
---|
| 80 | endif |
---|
| 81 | file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id)) |
---|
| 82 | |
---|
| 83 | open(111,file=file_path,form='formatted') |
---|
| 84 | do ifine=1,Nfine |
---|
| 85 | read(111,*) stel_f(ifine) |
---|
| 86 | enddo |
---|
| 87 | close(111) |
---|
| 88 | |
---|
| 89 | ! sum data by band |
---|
| 90 | band=1 |
---|
| 91 | do ifine = 1,Nfine |
---|
| 92 | |
---|
| 93 | if(lam(Nfine-ifine+1) .lt. real(10000.0/BWNV(band+1)))then |
---|
| 94 | band=band+1 |
---|
| 95 | endif |
---|
| 96 | if(band .gt. L_NSPECTV)then |
---|
| 97 | goto 9999 ! ok, ok, I know they're evil |
---|
| 98 | endif |
---|
| 99 | STELLAR(band)=STELLAR(band)+stel_f(Nfine-ifine+1)*dl |
---|
| 100 | |
---|
| 101 | end do |
---|
| 102 | |
---|
| 103 | 9999 continue |
---|
| 104 | STELLAR=STELLAR/sum(STELLAR) |
---|
| 105 | |
---|
| 106 | end subroutine ave_stelspec |
---|