1 | subroutine ave_stelspec(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 | ! Generalized to very late spectral types (and Brown dwarfs) Jeremy Leconte (2012) |
---|
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 |
---|
27 | use datafile_mod, only: datadir |
---|
28 | |
---|
29 | implicit none |
---|
30 | |
---|
31 | real*8 STELLAR(L_NSPECTV) |
---|
32 | integer startype |
---|
33 | |
---|
34 | integer Nfine |
---|
35 | integer,parameter :: Nfineband=200 |
---|
36 | integer ifine,band |
---|
37 | |
---|
38 | real,allocatable,save :: lam(:),stel_f(:) !read by master |
---|
39 | real lamm,lamp |
---|
40 | real dl |
---|
41 | |
---|
42 | character(len=100) :: file_id,file_id_lam |
---|
43 | character(len=200) :: file_path,file_path_lam |
---|
44 | |
---|
45 | real lam_temp |
---|
46 | double precision stel_temp |
---|
47 | |
---|
48 | integer :: ios ! file opening/reading status |
---|
49 | |
---|
50 | character(len=100) :: message |
---|
51 | character(len=10),parameter :: subname="avestelspc" |
---|
52 | |
---|
53 | STELLAR(:)=0.0 |
---|
54 | |
---|
55 | print*,'enter ave_stellspec' |
---|
56 | |
---|
57 | !! Sun only |
---|
58 | startype=1 |
---|
59 | ! load high resolution stellar data |
---|
60 | file_id='/stellar_spectra/sol.txt' |
---|
61 | tstellar=5800. |
---|
62 | file_id_lam='/stellar_spectra/lam.txt' |
---|
63 | Nfine=5000 |
---|
64 | |
---|
65 | !$OMP MASTER |
---|
66 | allocate(lam(Nfine),stel_f(Nfine)) |
---|
67 | |
---|
68 | file_path_lam=TRIM(datadir)//TRIM(file_id_lam) |
---|
69 | open(110,file=file_path_lam,form='formatted',status='old',iostat=ios) |
---|
70 | if (ios.ne.0) then ! file not found |
---|
71 | write(*,*) 'Error from ave_stelspec' |
---|
72 | write(*,*) 'Data file ',trim(file_id_lam),' not found.' |
---|
73 | write(*,*)'Check that your path to datagcm:',trim(datadir) |
---|
74 | write(*,*)' is correct. You can change it in callphys.def with:' |
---|
75 | write(*,*)' datadir = /absolute/path/to/datagcm' |
---|
76 | write(*,*)' Also check that there is a ',trim(file_id_lam),' there.' |
---|
77 | message='Error from ave_stelspec' |
---|
78 | call abort_physic(subname,message,1) |
---|
79 | else |
---|
80 | do ifine=1,Nfine |
---|
81 | read(110,*) lam(ifine) |
---|
82 | enddo |
---|
83 | close(110) |
---|
84 | endif |
---|
85 | |
---|
86 | |
---|
87 | ! load high resolution wavenumber data |
---|
88 | file_path=TRIM(datadir)//TRIM(file_id) |
---|
89 | open(111,file=file_path,form='formatted',status='old',iostat=ios) |
---|
90 | if (ios.ne.0) then ! file not found |
---|
91 | write(*,*) 'Error from ave_stelspec' |
---|
92 | write(*,*) 'Data file ',trim(file_id),' not found.' |
---|
93 | write(*,*)'Check that your path to datagcm:',trim(datadir) |
---|
94 | write(*,*)' is correct. You can change it in callphys.def with:' |
---|
95 | write(*,*)' datadir = /absolute/path/to/datagcm' |
---|
96 | write(*,*)' Also check that there is a ',trim(file_id),' there.' |
---|
97 | message='Error from ave_stelspec' |
---|
98 | call abort_physic(subname,message,1) |
---|
99 | else |
---|
100 | do ifine=1,Nfine |
---|
101 | read(111,*) stel_f(ifine) |
---|
102 | enddo |
---|
103 | close(111) |
---|
104 | endif |
---|
105 | !$OMP END MASTER |
---|
106 | !$OMP BARRIER |
---|
107 | |
---|
108 | ! sum data by band |
---|
109 | band=1 |
---|
110 | Do while(lam(1).lt. real(10000.0/BWNV(band+1))) |
---|
111 | if (band.gt.L_NSPECTV-1) exit |
---|
112 | band=band+1 |
---|
113 | enddo |
---|
114 | dl=lam(2)-lam(1) |
---|
115 | STELLAR(band)=STELLAR(band)+stel_f(1)*dl |
---|
116 | do ifine = 2,Nfine |
---|
117 | if(lam(ifine) .gt. real(10000.0/BWNV(band)))then |
---|
118 | band=band-1 |
---|
119 | endif |
---|
120 | if(band .lt. 1) exit |
---|
121 | dl=lam(ifine)-lam(ifine-1) |
---|
122 | STELLAR(band)=STELLAR(band)+stel_f(ifine)*dl |
---|
123 | end do |
---|
124 | |
---|
125 | |
---|
126 | STELLAR(1:L_NSPECTV)=STELLAR(1:L_NSPECTV)/sum(STELLAR(1:L_NSPECTV)) |
---|
127 | !$OMP BARRIER |
---|
128 | !$OMP MASTER |
---|
129 | if (allocated(lam)) deallocate(lam) |
---|
130 | if (allocated(stel_f)) deallocate(stel_f) |
---|
131 | !$OMP END MASTER |
---|
132 | !$OMP BARRIER |
---|
133 | |
---|
134 | end subroutine ave_stelspec |
---|