[253] | 1 | subroutine ave_stelspec(STELLAR) |
---|
[135] | 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). |
---|
[773] | 13 | ! Generalized to very late spectral types (and Brown dwarfs) Jeremy Leconte (2012) |
---|
[135] | 14 | ! |
---|
| 15 | ! Called by |
---|
| 16 | ! --------- |
---|
| 17 | ! setspv.F |
---|
| 18 | ! |
---|
| 19 | ! Calls |
---|
| 20 | ! ----- |
---|
| 21 | ! none |
---|
| 22 | ! |
---|
| 23 | !================================================================== |
---|
| 24 | |
---|
| 25 | use radinc_h, only: L_NSPECTV |
---|
| 26 | use radcommon_h, only: BWNV, DWNV, tstellar |
---|
[374] | 27 | use datafile_mod, only: datadir |
---|
[135] | 28 | |
---|
| 29 | implicit none |
---|
| 30 | |
---|
[253] | 31 | #include "callkeys.h" |
---|
[135] | 32 | |
---|
| 33 | real*8 STELLAR(L_NSPECTV) |
---|
[253] | 34 | ! integer startype |
---|
[135] | 35 | |
---|
| 36 | integer Nfine |
---|
[773] | 37 | integer,parameter :: Nfineband=200 |
---|
[135] | 38 | integer ifine |
---|
| 39 | |
---|
[773] | 40 | real,allocatable :: lam(:),stel_f(:) |
---|
| 41 | real band,lamm,lamp |
---|
[135] | 42 | real dl |
---|
| 43 | |
---|
[773] | 44 | character(len=100) :: file_id,file_id_lam |
---|
| 45 | character(len=200) :: file_path,file_path_lam |
---|
[135] | 46 | |
---|
[253] | 47 | real lam_temp |
---|
| 48 | double precision stel_temp |
---|
[374] | 49 | |
---|
| 50 | integer :: ios ! file opening/reading status |
---|
[253] | 51 | |
---|
[135] | 52 | STELLAR(:)=0.0 |
---|
| 53 | |
---|
[773] | 54 | print*,'enter ave_stellspec' |
---|
[253] | 55 | if(stelbbody)then |
---|
| 56 | tstellar=stelTbb |
---|
[773] | 57 | Nfine=L_NSPECTV*Nfineband |
---|
| 58 | do band=1,L_NSPECTV |
---|
| 59 | lamm=10000.0/BWNV(band+1) |
---|
| 60 | lamp=10000.0/BWNV(band) |
---|
| 61 | dl=(lamp-lamm)/(Nfineband) |
---|
| 62 | do ifine=1,Nfineband |
---|
| 63 | lam_temp=lamm+(lamp-lamm)*(ifine-1.)/(Nfineband) |
---|
| 64 | call blackl(dble(lam_temp*1e-6),dble(tstellar),stel_temp) |
---|
| 65 | STELLAR(band)=STELLAR(band)+stel_temp*dl |
---|
| 66 | enddo |
---|
| 67 | end do |
---|
| 68 | STELLAR(1:L_NSPECTV)=STELLAR(1:L_NSPECTV)/sum(STELLAR(1:L_NSPECTV)) |
---|
[135] | 69 | else |
---|
[253] | 70 | ! load high resolution stellar data |
---|
[773] | 71 | Select Case(startype) |
---|
| 72 | Case(1) |
---|
[253] | 73 | file_id='/stellar_spectra/sol.txt' |
---|
| 74 | tstellar=5800. |
---|
[773] | 75 | file_id_lam='/stellar_spectra/lam.txt' |
---|
| 76 | Nfine=5000 |
---|
| 77 | Case(2) |
---|
[253] | 78 | file_id='/stellar_spectra/gl581.txt' |
---|
| 79 | tstellar=3200. |
---|
[773] | 80 | file_id_lam='/stellar_spectra/lam.txt' |
---|
| 81 | Nfine=5000 |
---|
| 82 | Case(3) |
---|
[253] | 83 | file_id='/stellar_spectra/adleo.txt' |
---|
| 84 | tstellar=3200. |
---|
[773] | 85 | file_id_lam='/stellar_spectra/lam.txt' |
---|
| 86 | Nfine=5000 |
---|
| 87 | Case(4) |
---|
[253] | 88 | file_id='/stellar_spectra/gj644.txt' |
---|
| 89 | print*,'Find out tstellar before using this star!' |
---|
| 90 | call abort |
---|
[773] | 91 | file_id_lam='/stellar_spectra/lam.txt' |
---|
| 92 | Nfine=5000 |
---|
| 93 | Case(5) |
---|
[253] | 94 | file_id='/stellar_spectra/hd128167.txt' |
---|
| 95 | tstellar=6700. ! Segura et al. (2003) |
---|
[773] | 96 | file_id_lam='/stellar_spectra/lam.txt' |
---|
| 97 | Nfine=5000 |
---|
| 98 | Case(6) |
---|
| 99 | file_id='/stellar_spectra/BD_Teff-1600K.txt' |
---|
| 100 | tstellar=1600. ! Segura et al. (2003) |
---|
| 101 | file_id_lam='/stellar_spectra/lamBD.txt' |
---|
| 102 | Nfine=5000 |
---|
| 103 | Case(7) |
---|
| 104 | file_id='/stellar_spectra/BD_Teff-1000K.txt' |
---|
| 105 | tstellar=1000. ! Segura et al. (2003) |
---|
| 106 | file_id_lam='/stellar_spectra/lamBD.txt' |
---|
| 107 | Nfine=5000 |
---|
| 108 | Case Default |
---|
[253] | 109 | print*,'Error: unknown star type chosen' |
---|
| 110 | call abort |
---|
[773] | 111 | End Select |
---|
| 112 | |
---|
| 113 | allocate(lam(Nfine),stel_f(Nfine)) |
---|
| 114 | |
---|
| 115 | file_path_lam=TRIM(datadir)//TRIM(file_id_lam) |
---|
| 116 | open(110,file=file_path_lam,form='formatted',status='old',iostat=ios) |
---|
| 117 | if (ios.ne.0) then ! file not found |
---|
| 118 | write(*,*) 'Error from ave_stelspec' |
---|
| 119 | write(*,*) 'Data file ',trim(file_id_lam),' not found.' |
---|
| 120 | write(*,*)'Check that your path to datagcm:',trim(datadir) |
---|
| 121 | write(*,*)' is correct. You can change it in callphys.def with:' |
---|
| 122 | write(*,*)' datadir = /absolute/path/to/datagcm' |
---|
| 123 | write(*,*)' Also check that there is a ',trim(file_id_lam),' there.' |
---|
| 124 | call abort |
---|
| 125 | else |
---|
| 126 | do ifine=1,Nfine |
---|
| 127 | read(110,*) lam(ifine) |
---|
| 128 | enddo |
---|
| 129 | close(110) |
---|
[253] | 130 | endif |
---|
[773] | 131 | |
---|
| 132 | |
---|
| 133 | ! load high resolution wavenumber data |
---|
[374] | 134 | file_path=TRIM(datadir)//TRIM(file_id) |
---|
| 135 | open(111,file=file_path,form='formatted',status='old',iostat=ios) |
---|
| 136 | if (ios.ne.0) then ! file not found |
---|
| 137 | write(*,*) 'Error from ave_stelspec' |
---|
| 138 | write(*,*) 'Data file ',trim(file_id),' not found.' |
---|
| 139 | write(*,*)'Check that your path to datagcm:',trim(datadir) |
---|
| 140 | write(*,*)' is correct. You can change it in callphys.def with:' |
---|
| 141 | write(*,*)' datadir = /absolute/path/to/datagcm' |
---|
| 142 | write(*,*)' Also check that there is a ',trim(file_id),' there.' |
---|
| 143 | call abort |
---|
| 144 | else |
---|
| 145 | do ifine=1,Nfine |
---|
| 146 | read(111,*) stel_f(ifine) |
---|
| 147 | enddo |
---|
| 148 | close(111) |
---|
| 149 | endif |
---|
[773] | 150 | |
---|
| 151 | ! sum data by band |
---|
| 152 | band=1 |
---|
| 153 | Do while(lam(1).lt. real(10000.0/BWNV(band+1))) |
---|
[786] | 154 | if (band.gt.L_NSPECTV-1) exit |
---|
[773] | 155 | band=band+1 |
---|
| 156 | enddo |
---|
| 157 | dl=lam(2)-lam(1) |
---|
| 158 | STELLAR(band)=STELLAR(band)+stel_f(1)*dl |
---|
| 159 | do ifine = 2,Nfine |
---|
| 160 | if(lam(ifine) .gt. real(10000.0/BWNV(band)))then |
---|
| 161 | band=band-1 |
---|
| 162 | endif |
---|
| 163 | if(band .lt. 1) exit |
---|
| 164 | dl=lam(ifine)-lam(ifine-1) |
---|
| 165 | STELLAR(band)=STELLAR(band)+stel_f(ifine)*dl |
---|
| 166 | end do |
---|
| 167 | |
---|
| 168 | |
---|
| 169 | STELLAR(1:L_NSPECTV)=STELLAR(1:L_NSPECTV)/sum(STELLAR(1:L_NSPECTV)) |
---|
| 170 | deallocate(lam,stel_f) |
---|
| 171 | |
---|
[135] | 172 | endif |
---|
| 173 | |
---|
| 174 | end subroutine ave_stelspec |
---|