@@ -143,8 +143,126 @@ program test_colors
143143 stop 1
144144 end if
145145
146- write (* ,* ) ' Colors module initialized successfully.'
147- write (* ,* ) ' Test passed!'
146+ ! enable photometry so how_many_colors_history_columns returns > 0
147+ cs% use_colors = .true.
148+ cs% mag_system = ' Vega'
149+
150+ n_cols = how_many_colors_history_columns(handle)
151+ if (n_cols == 0 ) then
152+ write (* ,* ) ' how_many_colors_history_columns returned 0'
153+ stop 1
154+ end if
155+
156+ allocate (col_names(n_cols), col_vals(n_cols))
157+ model_num = 0
158+
159+ ! -----------------------------------------------------------------------
160+ ! group 1: representative stellar types
161+ ! -----------------------------------------------------------------------
162+
163+ write (* ,' (a)' ) ' # group1 system=Vega grid=Kurucz2003 filters=Johnson'
164+ do j = 1 , n_cases
165+ model_num = model_num + 1
166+ call data_for_colors_history_columns( &
167+ test_teff(j), test_logg(j), test_R(j), test_meta(j), model_num, &
168+ handle, n_cols, col_names, col_vals, ierr)
169+ if (ierr /= 0 ) then
170+ write (* ,* ) ' data_for_colors_history_columns failed, group1 case' , j, ' , ierr =' , ierr
171+ stop 1
172+ end if
173+ write (* ,' (a, a)' ) ' # case: ' , trim (adjustl (labels(j)))
174+ do k = 1 , n_cols
175+ write (* ,' (a40, 1pe23.13)' ) trim (col_names(k)), col_vals(k)
176+ end do
177+ end do
178+
179+ ! -----------------------------------------------------------------------
180+ ! group 2a: vary [M/H]
181+ ! -----------------------------------------------------------------------
182+
183+ write (* ,' (a)' ) ' # group2a vary_MH Teff=5778 logg=4.44'
184+ do j = 1 , n_meta
185+ model_num = model_num + 1
186+ call data_for_colors_history_columns( &
187+ 5778d0 , 4.44d0 , rsun, sweep_meta(j), model_num, &
188+ handle, n_cols, col_names, col_vals, ierr)
189+ if (ierr /= 0 ) then
190+ write (* ,* ) ' data_for_colors_history_columns failed, group2a case' , j, ' , ierr =' , ierr
191+ stop 1
192+ end if
193+ write (* ,' (a, f6.2)' ) ' # MH= ' , sweep_meta(j)
194+ do k = 1 , n_cols
195+ write (* ,' (a40, 1pe23.13)' ) trim (col_names(k)), col_vals(k)
196+ end do
197+ end do
198+
199+ ! -----------------------------------------------------------------------
200+ ! group 2b: vary log g
201+ ! -----------------------------------------------------------------------
202+
203+ write (* ,' (a)' ) ' # group2b vary_logg Teff=5778 MH=0.0'
204+ do j = 1 , n_logg
205+ model_num = model_num + 1
206+ call data_for_colors_history_columns( &
207+ 5778d0 , sweep_logg(j), rsun, 0.0d0 , model_num, &
208+ handle, n_cols, col_names, col_vals, ierr)
209+ if (ierr /= 0 ) then
210+ write (* ,* ) ' data_for_colors_history_columns failed, group2b case' , j, ' , ierr =' , ierr
211+ stop 1
212+ end if
213+ write (* ,' (a, f6.2)' ) ' # logg= ' , sweep_logg(j)
214+ do k = 1 , n_cols
215+ write (* ,' (a40, 1pe23.13)' ) trim (col_names(k)), col_vals(k)
216+ end do
217+ end do
218+
219+ ! -----------------------------------------------------------------------
220+ ! group 2c: vary Teff
221+ ! -----------------------------------------------------------------------
222+
223+ write (* ,' (a)' ) ' # group2c vary_Teff logg=4.0 MH=0.0'
224+ do j = 1 , n_teff
225+ model_num = model_num + 1
226+ call data_for_colors_history_columns( &
227+ sweep_teff(j), 4.0d0 , rsun, 0.0d0 , model_num, &
228+ handle, n_cols, col_names, col_vals, ierr)
229+ if (ierr /= 0 ) then
230+ write (* ,* ) ' data_for_colors_history_columns failed, group2c case' , j, ' , ierr =' , ierr
231+ stop 1
232+ end if
233+ write (* ,' (a, f10.1)' ) ' # Teff= ' , sweep_teff(j)
234+ do k = 1 , n_cols
235+ write (* ,' (a40, 1pe23.13)' ) trim (col_names(k)), col_vals(k)
236+ end do
237+ end do
238+
239+ ! -----------------------------------------------------------------------
240+ ! SED comparison: solar case, n_sed_samples evenly spaced wavelength/flux
241+ ! -----------------------------------------------------------------------
242+
243+ sed_filepath = trim (mesa_dir)// trim (cs% stellar_atm)
244+ call calculate_bolometric( &
245+ cs, test_teff(1 ), test_logg(1 ), test_meta(1 ), test_R(1 ), d_10pc, &
246+ bol_mag, bol_flux, wavelengths, fluxes, sed_filepath, interp_rad)
247+
248+ n_wav = size (wavelengths)
249+ stride = max (1 , n_wav / n_sed_samples)
250+
251+ write (* ,' (a)' ) ' # SED sample case=solar columns=wavelength_AA flux_erg_s_cm2_AA'
252+ do i = 1 , n_wav, stride
253+ write (* ,' (1pe23.13, 1x, 1pe23.13)' ) wavelengths(i), fluxes(i)
254+ end do
255+
256+ ! -----------------------------------------------------------------------
257+ ! cleanup
258+ ! -----------------------------------------------------------------------
259+
260+ deallocate (col_names, col_vals)
261+ if (allocated (wavelengths)) deallocate (wavelengths)
262+ if (allocated (fluxes)) deallocate (fluxes)
263+
264+ call free_colors_handle(handle)
265+ call colors_shutdown()
148266
149267 write (* ,* ) ' test_colors: passed'
150268
0 commit comments