Skip to content

Commit 3f50b61

Browse files
authored
colors: don't load data when use_colors = .false.
Also contains a minor bugfix for RSP
1 parent c79eae5 commit 3f50b61

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

colors/public/colors_lib.f90

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ integer function alloc_colors_handle(ierr) result(handle)
7777
end function alloc_colors_handle
7878

7979
integer function alloc_colors_handle_using_inlist(inlist, ierr) result(handle)
80-
use colors_def, only: do_alloc_colors, colors_is_initialized
80+
use colors_def, only: Colors_General_Info, do_alloc_colors, colors_is_initialized, get_colors_ptr
8181
use colors_ctrls_io, only: read_namelist
8282
character(len=*), intent(in) :: inlist ! empty means just use defaults.
8383
integer, intent(out) :: ierr ! 0 means AOK.
84+
type(Colors_General_Info), pointer :: rq
8485
ierr = 0
8586
handle = -1
8687
if (.not. colors_is_initialized) then
@@ -91,6 +92,10 @@ integer function alloc_colors_handle_using_inlist(inlist, ierr) result(handle)
9192
if (ierr /= 0) return
9293
call read_namelist(handle, inlist, ierr)
9394
if (ierr /= 0) return
95+
call get_colors_ptr(handle, rq, ierr)
96+
if (ierr /= 0) return
97+
! skip colors table setup and hooks if use_colors = .false.
98+
if (.not. rq%use_colors) return
9499
call colors_setup_tables(handle, ierr)
95100
call colors_setup_hooks(handle, ierr)
96101
end function alloc_colors_handle_using_inlist
@@ -313,4 +318,4 @@ real(dp) function get_lum_band_by_id(id, log_Teff, log_g, M_div_h, lum, ierr)
313318
get_lum_band_by_id = -99.d0
314319
end function get_lum_band_by_id
315320

316-
end module colors_lib
321+
end module colors_lib

colors/test/src/test_colors.f90

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ program test_colors
4141
use colors_lib, only: &
4242
colors_init, colors_shutdown, &
4343
alloc_colors_handle_using_inlist, free_colors_handle, colors_ptr, &
44-
how_many_colors_history_columns, data_for_colors_history_columns, &
45-
calculate_bolometric
44+
colors_setup_tables, colors_setup_hooks, how_many_colors_history_columns, &
45+
data_for_colors_history_columns, calculate_bolometric
4646
use colors_def, only: Colors_General_Info
4747
use const_def, only: dp, rsun, boltz_sigma
4848
use utils_lib, only: mesa_error
@@ -149,9 +149,23 @@ program test_colors
149149
stop 1
150150
end if
151151

152-
! enable photometry so how_many_colors_history_columns returns > 0
152+
! enable photometry and explicitly load colors data, since the default
153+
! namelist leaves use_colors = .false. and skips setup at handle.
154+
! To do : This could be replaced by reading from an inlist instead in the future.
153155
cs%use_colors = .true.
154156
cs%mag_system = 'Vega'
157+
call colors_setup_tables(handle, ierr)
158+
if (ierr /= 0) then
159+
write(*,*) 'colors_setup_tables failed, ierr =', ierr
160+
stop 1
161+
end if
162+
163+
! probably unecessary since this is empty right now.
164+
call colors_setup_hooks(handle, ierr)
165+
if (ierr /= 0) then
166+
write(*,*) 'colors_setup_hooks failed, ierr =', ierr
167+
stop 1
168+
end if
155169

156170
n_cols = how_many_colors_history_columns(handle)
157171
if (n_cols == 0) then

star/private/rsp.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,10 +972,11 @@ subroutine check_cycle_completed(s,cycle_complete)
972972
TET = s% time
973973
cycle_complete = .false.
974974
UN=s% v(1)
975+
! ULL is not set for the first model.
976+
if (s% model_number==1) return
975977
if(UN>0.d0.and.ULL<=0.d0) then
976978
RMIN=s% r(1)/SUNR
977979
end if
978-
if (s% model_number==1) return
979980
if (.not. s% RSP_have_set_velocities) return
980981
if (s% r(1)/SUNR < s% RSP_min_max_R_for_periods) return
981982
if (UN/s% csound(1) > VMAX) then

0 commit comments

Comments
 (0)