LCOV - code coverage report
Current view: top level - binary/private - binary_ctrls_io.f90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 402 0
Test Date: 2026-08-20 21:51:39 Functions: 0.0 % 9 0

            Line data    Source code
       1              : ! ***********************************************************************
       2              : !
       3              : !   Copyright (C) 2010  Pablo Marchant & The MESA Team
       4              : !
       5              : !   This program is free software: you can redistribute it and/or modify
       6              : !   it under the terms of the GNU Lesser General Public License
       7              : !   as published by the Free Software Foundation,
       8              : !   either version 3 of the License, or (at your option) any later version.
       9              : !
      10              : !   This program is distributed in the hope that it will be useful,
      11              : !   but WITHOUT ANY WARRANTY; without even the implied warranty of
      12              : !   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      13              : !   See the GNU Lesser General Public License for more details.
      14              : !
      15              : !   You should have received a copy of the GNU Lesser General Public License
      16              : !   along with this program. If not, see <https://www.gnu.org/licenses/>.
      17              : !
      18              : ! ***********************************************************************
      19              : 
      20              :       module binary_ctrls_io
      21              : 
      22              :       use const_def, only: dp
      23              :       use binary_def
      24              : 
      25              :       implicit none
      26              : 
      27              :       include "binary_controls.inc"
      28              : 
      29              :       logical, dimension(max_extra_inlists) :: read_extra_binary_controls_inlist
      30              :       character (len=strlen), dimension(max_extra_inlists) :: extra_binary_controls_inlist_name
      31              : 
      32              :       namelist /binary_controls/ &
      33              :          ! specifications for starting model
      34              :          m1, &
      35              :          m2, &
      36              :          initial_period_in_days, &
      37              :          initial_separation_in_Rsuns, &
      38              :          initial_eccentricity, &
      39              : 
      40              :          ! controls for output
      41              :          history_name, &
      42              :          history_interval, &
      43              :          append_to_star_history, &
      44              :          log_directory, &
      45              :          history_dbl_format, &
      46              :          history_int_format, &
      47              :          history_txt_format, &
      48              :          photo_interval, &
      49              :          photo_digits, &
      50              :          photo_directory, &
      51              :          terminal_interval, &
      52              :          write_header_frequency, &
      53              :          extra_binary_terminal_output_file, &
      54              : 
      55              :          ! timestep controls
      56              :          time_delta_coeff, &
      57              :          fm, &
      58              :          fm_hard, &
      59              :          fa, &
      60              :          fa_hard, &
      61              :          fr, &
      62              :          fr_hard, &
      63              :          fj, &
      64              :          fj_hard, &
      65              :          fe, &
      66              :          fe_hard, &
      67              :          fm_limit, &
      68              :          fr_limit, &
      69              :          fe_limit, &
      70              :          fr_dt_limit, &
      71              :          fdm, &
      72              :          fdm_hard, &
      73              :          dt_softening_factor, &
      74              :          varcontrol_case_a, &
      75              :          varcontrol_case_b, &
      76              :          varcontrol_ms, &
      77              :          varcontrol_post_ms, &
      78              :          dt_reduction_factor_for_j, &
      79              : 
      80              :          ! when to stop
      81              :          accretor_overflow_terminate, &
      82              :          terminate_if_initial_overflow, &
      83              :          terminate_if_L2_overflow, &
      84              : 
      85              :          ! mass transfer controls
      86              :          mass_transfer_alpha, &
      87              :          mass_transfer_beta, &
      88              :          mass_transfer_delta, &
      89              :          mass_transfer_gamma, &
      90              :          limit_retention_by_mdot_edd, &
      91              :          use_es_opacity_for_mdot_edd, &
      92              :          use_this_for_mdot_edd_eta, &
      93              :          use_radiation_corrected_transfer_rate, &
      94              :          initial_bh_spin, &
      95              :          use_this_for_mdot_edd, &
      96              :          mdot_scheme, &
      97              :          cur_mdot_frac, &
      98              :          max_explicit_abs_mdot, &
      99              :          max_tries_to_achieve, &
     100              :          solver_type, &
     101              :          implicit_scheme_tolerance, &
     102              :          implicit_scheme_tiny_factor, &
     103              :          initial_change_factor, &
     104              :          change_factor_fraction, &
     105              :          implicit_lambda, &
     106              :          max_change_factor, &
     107              :          min_change_factor, &
     108              :          num_tries_for_increase_change_factor, &
     109              :          change_factor_increase, &
     110              :          starting_mdot, &
     111              :          roche_min_mdot, &
     112              :          min_mdot_for_implicit, &
     113              :          max_implicit_abs_mdot, &
     114              :          report_rlo_solver_progress, &
     115              :          do_enhance_wind_1, &
     116              :          do_enhance_wind_2, &
     117              :          tout_B_wind_1, &
     118              :          tout_B_wind_2, &
     119              :          do_wind_mass_transfer_1, &
     120              :          do_wind_mass_transfer_2, &
     121              :          wind_BH_alpha_1, &
     122              :          wind_BH_alpha_2, &
     123              :          wind_BH_beta_1, &
     124              :          wind_BH_beta_2, &
     125              :          max_wind_transfer_fraction_1, &
     126              :          max_wind_transfer_fraction_2, &
     127              : 
     128              :          ! orbital jdot controls
     129              :          do_jdot_gr, &
     130              :          do_jdot_ml, &
     131              :          do_jdot_ls, &
     132              :          do_jdot_missing_wind, &
     133              :          do_jdot_mb, &
     134              :          include_accretor_mb, &
     135              :          magnetic_braking_gamma, &
     136              :          keep_mb_on, &
     137              :          jdot_mb_min_qconv_env, &
     138              :          jdot_mb_max_qconv_env, &
     139              :          jdot_mb_max_qconv_core, &
     140              :          jdot_mb_qlim_for_check_rad_core, &
     141              :          jdot_mb_qlim_for_check_conv_env, &
     142              :          jdot_mb_scale_for_low_qconv_env, &
     143              :          jdot_mb_mass_frac_for_scale, &
     144              :          jdot_multiplier, &
     145              : 
     146              :          ! rotation and sync controls
     147              :          do_j_accretion, &
     148              :          do_tidal_sync, &
     149              :          sync_type_1, &
     150              :          sync_type_2, &
     151              :          sync_mode_1, &
     152              :          sync_mode_2, &
     153              :          Ftid_1, &
     154              :          Ftid_2, &
     155              :          do_initial_orbit_sync_1, &
     156              :          do_initial_orbit_sync_2, &
     157              :          tidal_reduction, &
     158              : 
     159              :          ! eccentricity controls
     160              :          do_tidal_circ, &
     161              :          circ_type_1, &
     162              :          circ_type_2, &
     163              :          use_eccentricity_enhancement, &
     164              :          max_abs_edot_tidal, &
     165              :          max_abs_edot_enhance, &
     166              :          min_eccentricity, &
     167              :          max_eccentricity, &
     168              :          anomaly_steps, &
     169              : 
     170              :          ! irradiation controls
     171              :          accretion_powered_irradiation, &
     172              :          col_depth_for_eps_extra, &
     173              :          use_accretor_luminosity_for_irrad, &
     174              :          irrad_flux_at_std_distance, &
     175              :          std_distance_for_irradiation, &
     176              :          max_F_irr, &
     177              : 
     178              :          !common envelope controls
     179              :          CE_alpha, &
     180              :          CE_alpha_th, &
     181              :          CE_alpha_core, &
     182              :          CE_mass_loss_rate_high, &
     183              :          CE_mass_loss_rate_low, &
     184              :          CE_rel_rlo_for_detachment, &
     185              :          CE_years_detached_to_terminate, &
     186              :          CE_begin_at_max_implicit_abs_mdot, &
     187              :          CE_xa_diff_to_terminate, &
     188              :          CE_terminate_when_core_overflows, &
     189              :          CE_min_period_in_minutes, &
     190              :          CE_energy_factor_HII_toHI, &
     191              :          CE_energy_factor_HeII_toHeI, &
     192              :          CE_energy_factor_HeIII_toHeII, &
     193              :          CE_energy_factor_H2, &
     194              :          CE_fixed_lambda, &
     195              : 
     196              :          ! miscellaneous controls
     197              :          keep_donor_fixed, &
     198              :          mdot_limit_donor_switch, &
     199              :          use_tidal_deformation, &
     200              :          f_sync_switch_from_rot_defor, &
     201              :          f_sync_switch_width, &
     202              :          f_sync_switch_lim, &
     203              :          use_other_tidal_deformation_switch_function, &
     204              :          use_other_rlo_mdot, &
     205              :          use_other_check_implicit_rlo, &
     206              :          use_other_implicit_function_to_solve, &
     207              :          use_other_tsync, &
     208              :          use_other_sync_spin_to_orbit, &
     209              :          use_other_mdot_edd, &
     210              :          use_other_adjust_mdots, &
     211              :          use_other_accreted_material_j, &
     212              :          use_other_jdot_gr, &
     213              :          use_other_jdot_ml, &
     214              :          use_other_jdot_ls, &
     215              :          use_other_jdot_missing_wind, &
     216              :          use_other_jdot_mb, &
     217              :          use_other_extra_jdot, &
     218              :          use_other_binary_wind_transfer, &
     219              :          use_other_edot_tidal, &
     220              :          use_other_edot_enhance, &
     221              :          use_other_extra_edot, &
     222              :          use_other_CE_init, &
     223              :          use_other_CE_rlo_mdot, &
     224              :          use_other_CE_binary_evolve_step, &
     225              :          use_other_CE_binary_finish_step, &
     226              :          x_ctrl, &
     227              :          x_integer_ctrl, &
     228              :          x_logical_ctrl, &
     229              :          x_character_ctrl, &
     230              : 
     231              :          ! extra files
     232              :          read_extra_binary_controls_inlist, extra_binary_controls_inlist_name
     233              : 
     234              :       contains
     235              : 
     236              : 
     237            0 :       subroutine do_one_binary_setup(b, inlist, ierr)
     238              :          use utils_lib
     239              :          type (binary_info), pointer :: b
     240              :          character (len=*), intent(in) :: inlist
     241              :          integer, intent(out) :: ierr
     242              : 
     243              :          include 'formats'
     244              : 
     245            0 :          call set_default_binary_controls
     246            0 :          call read_binary_controls(b, inlist, ierr)
     247              : 
     248              :          ! open additional file for binary output
     249            0 :          if (len_trim(b% extra_binary_terminal_output_file) /= 0) then
     250              :             open(newunit=b% extra_binary_terminal_iounit, file=trim(b% extra_binary_terminal_output_file), &
     251            0 :                      action='write', status='replace',iostat=ierr)
     252            0 :             if (ierr /= 0) then
     253            0 :                write(*,*) 'failed to open ' // trim(b% extra_binary_terminal_output_file)
     254            0 :                return
     255              :             end if
     256              :          end if
     257              : 
     258              :       end subroutine do_one_binary_setup
     259              : 
     260              : 
     261            0 :       subroutine read_binary_controls(b, filename, ierr)
     262              :          use utils_namelist, only: read_namelist, missing_namelist_error
     263              :          type (binary_info), pointer :: b
     264              :          character(*), intent(in) :: filename
     265              :          integer, intent(out) :: ierr
     266              : 
     267            0 :          call read_namelist(filename, read_binary_controls_file, "binary_controls", ierr, missing_namelist_error)
     268              : 
     269            0 :          if (ierr /= 0) return
     270              : 
     271            0 :          call store_binary_controls(b)
     272              : 
     273              :       end subroutine read_binary_controls
     274              : 
     275            0 :       subroutine read_binary_controls_file(unit, iostat, iomsg, extra_inlists, extra_inlists_mask)
     276              :          use const_def, only: strlen
     277              :          use utils_namelist, only: max_extra_inlists
     278              : 
     279              :          integer, intent(in) :: unit
     280              :          integer, intent(out) :: iostat
     281              :          character(len=strlen), intent(out) :: iomsg
     282              :          character(len=strlen), dimension(max_extra_inlists), intent(out) :: extra_inlists
     283              :          logical, dimension(max_extra_inlists), intent(out) :: extra_inlists_mask
     284              : 
     285              :          integer :: i
     286              : 
     287            0 :          read_extra_binary_controls_inlist(:) = .false.
     288              : 
     289            0 :          read(unit, nml=binary_controls, iostat=iostat, iomsg=iomsg)
     290              : 
     291            0 :          if (iostat /= 0) then
     292              :             return
     293              :          end if
     294              : 
     295            0 :          do i=1, max_extra_inlists
     296            0 :             extra_inlists(i) = extra_binary_controls_inlist_name(i)
     297            0 :             extra_inlists_mask(i) = read_extra_binary_controls_inlist(i)
     298              :          end do
     299              : 
     300              :       end subroutine read_binary_controls_file
     301              : 
     302            0 :       subroutine set_default_binary_controls
     303              :          include 'binary_controls.defaults'
     304            0 :       end subroutine set_default_binary_controls
     305              : 
     306              : 
     307            0 :       subroutine store_binary_controls(b)
     308              :          use utils_lib, only: mkdir
     309              :          type (binary_info), pointer :: b
     310              : 
     311              :          ! specifications for starting model
     312            0 :          b% m1 = m1
     313            0 :          b% m2 = m2
     314            0 :          b% initial_period_in_days = initial_period_in_days
     315            0 :          b% initial_separation_in_Rsuns = initial_separation_in_Rsuns
     316            0 :          b% initial_eccentricity = initial_eccentricity
     317              : 
     318              :          ! controls for output
     319            0 :          b% history_name = history_name
     320            0 :          b% history_interval = history_interval
     321            0 :          b% append_to_star_history = append_to_star_history
     322            0 :          b% log_directory = log_directory
     323            0 :          CALL mkdir(b% log_directory)
     324            0 :          b% history_dbl_format = history_dbl_format
     325            0 :          b% history_int_format = history_int_format
     326            0 :          b% history_txt_format = history_txt_format
     327            0 :          b% photo_interval = photo_interval
     328            0 :          b% photo_digits = photo_digits
     329            0 :          b% photo_directory = photo_directory
     330            0 :          CALL mkdir(b% photo_directory)
     331            0 :          b% terminal_interval = terminal_interval
     332            0 :          b% write_header_frequency = write_header_frequency
     333            0 :          b% extra_binary_terminal_output_file = extra_binary_terminal_output_file
     334              : 
     335              :          ! timestep controls
     336            0 :          b% time_delta_coeff = time_delta_coeff
     337            0 :          b% fm = fm
     338            0 :          b% fm_hard = fm_hard
     339            0 :          b% fa = fa
     340            0 :          b% fa_hard = fa_hard
     341            0 :          b% fr = fr
     342            0 :          b% fr_hard = fr_hard
     343            0 :          b% fj = fj
     344            0 :          b% fj_hard = fj_hard
     345            0 :          b% fe = fe
     346            0 :          b% fe_hard = fe_hard
     347            0 :          b% fm_limit = fm_limit
     348            0 :          b% fr_limit = fr_limit
     349            0 :          b% fe_limit = fe_limit
     350            0 :          b% fr_dt_limit = fr_dt_limit
     351            0 :          b% fdm = fdm
     352            0 :          b% fdm_hard = fdm_hard
     353            0 :          b% dt_softening_factor = dt_softening_factor
     354            0 :          b% varcontrol_case_a = varcontrol_case_a
     355            0 :          b% varcontrol_case_b = varcontrol_case_b
     356            0 :          b% varcontrol_ms = varcontrol_ms
     357            0 :          b% varcontrol_post_ms = varcontrol_post_ms
     358            0 :          b% dt_reduction_factor_for_j = dt_reduction_factor_for_j
     359              : 
     360              :          ! when to stop
     361            0 :          b% accretor_overflow_terminate = accretor_overflow_terminate
     362            0 :          b% terminate_if_initial_overflow = terminate_if_initial_overflow
     363            0 :          b% terminate_if_L2_overflow = terminate_if_L2_overflow
     364              : 
     365              :          ! mass transfer controls
     366            0 :          b% mass_transfer_alpha = mass_transfer_alpha
     367            0 :          b% mass_transfer_beta = mass_transfer_beta
     368            0 :          b% mass_transfer_delta = mass_transfer_delta
     369            0 :          b% mass_transfer_gamma = mass_transfer_gamma
     370            0 :          b% limit_retention_by_mdot_edd = limit_retention_by_mdot_edd
     371            0 :          b% use_es_opacity_for_mdot_edd = use_es_opacity_for_mdot_edd
     372            0 :          b% use_this_for_mdot_edd_eta = use_this_for_mdot_edd_eta
     373            0 :          b% use_radiation_corrected_transfer_rate = use_radiation_corrected_transfer_rate
     374            0 :          b% initial_bh_spin = initial_bh_spin
     375            0 :          b% use_this_for_mdot_edd = use_this_for_mdot_edd
     376            0 :          b% mdot_scheme = mdot_scheme
     377            0 :          b% cur_mdot_frac = cur_mdot_frac
     378            0 :          b% max_explicit_abs_mdot = max_explicit_abs_mdot
     379            0 :          b% max_tries_to_achieve = max_tries_to_achieve
     380            0 :          b% solver_type = solver_type
     381            0 :          b% implicit_scheme_tolerance = implicit_scheme_tolerance
     382            0 :          b% implicit_scheme_tiny_factor = implicit_scheme_tiny_factor
     383            0 :          b% initial_change_factor = initial_change_factor
     384            0 :          b% change_factor_fraction = change_factor_fraction
     385            0 :          b% implicit_lambda = implicit_lambda
     386            0 :          b% max_change_factor = max_change_factor
     387            0 :          b% min_change_factor = min_change_factor
     388            0 :          b% num_tries_for_increase_change_factor = num_tries_for_increase_change_factor
     389            0 :          b% change_factor_increase = change_factor_increase
     390            0 :          b% starting_mdot = starting_mdot
     391            0 :          b% roche_min_mdot = roche_min_mdot
     392            0 :          b% min_mdot_for_implicit = min_mdot_for_implicit
     393            0 :          b% max_implicit_abs_mdot = max_implicit_abs_mdot
     394            0 :          b% report_rlo_solver_progress = report_rlo_solver_progress
     395            0 :          b% do_enhance_wind_1 = do_enhance_wind_1
     396            0 :          b% do_enhance_wind_2 = do_enhance_wind_2
     397            0 :          b% tout_B_wind_1 = tout_B_wind_1
     398            0 :          b% tout_B_wind_2 = tout_B_wind_2
     399            0 :          b% do_wind_mass_transfer_1 = do_wind_mass_transfer_1
     400            0 :          b% do_wind_mass_transfer_2 = do_wind_mass_transfer_2
     401            0 :          b% wind_BH_alpha_1 = wind_BH_alpha_1
     402            0 :          b% wind_BH_alpha_2 = wind_BH_alpha_2
     403            0 :          b% wind_BH_beta_1 = wind_BH_beta_1
     404            0 :          b% wind_BH_beta_2 = wind_BH_beta_2
     405            0 :          b% max_wind_transfer_fraction_1 = max_wind_transfer_fraction_1
     406            0 :          b% max_wind_transfer_fraction_2 = max_wind_transfer_fraction_2
     407              : 
     408              :          ! orbital jdot controls
     409            0 :          b% do_jdot_gr = do_jdot_gr
     410            0 :          b% do_jdot_ml = do_jdot_ml
     411            0 :          b% do_jdot_ls = do_jdot_ls
     412            0 :          b% do_jdot_missing_wind = do_jdot_missing_wind
     413            0 :          b% do_jdot_mb = do_jdot_mb
     414            0 :          b% include_accretor_mb = include_accretor_mb
     415            0 :          b% magnetic_braking_gamma = magnetic_braking_gamma
     416            0 :          b% keep_mb_on = keep_mb_on
     417            0 :          b% jdot_mb_min_qconv_env = jdot_mb_min_qconv_env
     418            0 :          b% jdot_mb_max_qconv_env = jdot_mb_max_qconv_env
     419            0 :          b% jdot_mb_max_qconv_core = jdot_mb_max_qconv_core
     420            0 :          b% jdot_mb_qlim_for_check_rad_core = jdot_mb_qlim_for_check_rad_core
     421            0 :          b% jdot_mb_qlim_for_check_conv_env = jdot_mb_qlim_for_check_conv_env
     422            0 :          b% jdot_mb_scale_for_low_qconv_env = jdot_mb_scale_for_low_qconv_env
     423            0 :          b% jdot_mb_mass_frac_for_scale = jdot_mb_mass_frac_for_scale
     424            0 :          b% jdot_multiplier = jdot_multiplier
     425              : 
     426              :          ! rotation and sync controls
     427            0 :          b% do_j_accretion = do_j_accretion
     428            0 :          b% do_tidal_sync = do_tidal_sync
     429            0 :          b% sync_type_1 = sync_type_1
     430            0 :          b% sync_type_2 = sync_type_2
     431            0 :          b% sync_mode_1 = sync_mode_1
     432            0 :          b% sync_mode_2 = sync_mode_2
     433            0 :          b% Ftid_1 = Ftid_1
     434            0 :          b% Ftid_2 = Ftid_2
     435            0 :          b% do_initial_orbit_sync_1 = do_initial_orbit_sync_1
     436            0 :          b% do_initial_orbit_sync_2 = do_initial_orbit_sync_2
     437            0 :          b% tidal_reduction = tidal_reduction
     438              : 
     439              :          ! eccentricity controls
     440            0 :          b% do_tidal_circ = do_tidal_circ
     441            0 :          b% circ_type_1 = circ_type_1
     442            0 :          b% circ_type_2 = circ_type_2
     443            0 :          b% use_eccentricity_enhancement = use_eccentricity_enhancement
     444            0 :          b% max_abs_edot_tidal = max_abs_edot_tidal
     445            0 :          b% max_abs_edot_enhance = max_abs_edot_enhance
     446            0 :          b% min_eccentricity = min_eccentricity
     447            0 :          b% max_eccentricity = max_eccentricity
     448            0 :          b% anomaly_steps = anomaly_steps
     449              : 
     450              :          ! irradiation controls
     451            0 :          b% accretion_powered_irradiation = accretion_powered_irradiation
     452            0 :          b% use_accretor_luminosity_for_irrad = use_accretor_luminosity_for_irrad
     453            0 :          b% col_depth_for_eps_extra = col_depth_for_eps_extra
     454            0 :          b% irrad_flux_at_std_distance = irrad_flux_at_std_distance
     455            0 :          b% std_distance_for_irradiation = std_distance_for_irradiation
     456            0 :          b% max_F_irr = max_F_irr
     457              : 
     458              :          !common envelope controls
     459            0 :          b% CE_alpha = CE_alpha
     460            0 :          b% CE_alpha_th = CE_alpha_th
     461            0 :          b% CE_alpha_core = CE_alpha_core
     462            0 :          b% CE_mass_loss_rate_high = CE_mass_loss_rate_high
     463            0 :          b% CE_mass_loss_rate_low = CE_mass_loss_rate_low
     464            0 :          b% CE_rel_rlo_for_detachment = CE_rel_rlo_for_detachment
     465            0 :          b% CE_years_detached_to_terminate = CE_years_detached_to_terminate
     466            0 :          b% CE_begin_at_max_implicit_abs_mdot = CE_begin_at_max_implicit_abs_mdot
     467            0 :          b% CE_xa_diff_to_terminate = CE_xa_diff_to_terminate
     468            0 :          b% CE_terminate_when_core_overflows = CE_terminate_when_core_overflows
     469            0 :          b% CE_min_period_in_minutes = CE_min_period_in_minutes
     470            0 :          b% CE_energy_factor_HII_toHI = CE_energy_factor_HII_toHI
     471            0 :          b% CE_energy_factor_HeII_toHeI = CE_energy_factor_HeII_toHeI
     472            0 :          b% CE_energy_factor_HeIII_toHeII = CE_energy_factor_HeIII_toHeII
     473            0 :          b% CE_energy_factor_H2 = CE_energy_factor_H2
     474            0 :          b% CE_fixed_lambda = CE_fixed_lambda
     475              : 
     476              :          ! miscellaneous controls
     477            0 :          b% keep_donor_fixed = keep_donor_fixed
     478            0 :          b% mdot_limit_donor_switch = mdot_limit_donor_switch
     479            0 :          b% use_tidal_deformation = use_tidal_deformation
     480            0 :          b% f_sync_switch_from_rot_defor = f_sync_switch_from_rot_defor
     481            0 :          b% f_sync_switch_width = f_sync_switch_width
     482            0 :          b% f_sync_switch_lim = f_sync_switch_lim
     483            0 :          b% use_other_tidal_deformation_switch_function = use_other_tidal_deformation_switch_function
     484            0 :          b% use_other_rlo_mdot = use_other_rlo_mdot
     485            0 :          b% use_other_check_implicit_rlo = use_other_check_implicit_rlo
     486            0 :          b% use_other_implicit_function_to_solve = use_other_implicit_function_to_solve
     487            0 :          b% use_other_tsync = use_other_tsync
     488            0 :          b% use_other_sync_spin_to_orbit = use_other_sync_spin_to_orbit
     489            0 :          b% use_other_mdot_edd = use_other_mdot_edd
     490            0 :          b% use_other_adjust_mdots = use_other_adjust_mdots
     491            0 :          b% use_other_accreted_material_j = use_other_accreted_material_j
     492            0 :          b% use_other_jdot_gr = use_other_jdot_gr
     493            0 :          b% use_other_jdot_ml = use_other_jdot_ml
     494            0 :          b% use_other_jdot_ls = use_other_jdot_ls
     495            0 :          b% use_other_jdot_missing_wind = use_other_jdot_missing_wind
     496            0 :          b% use_other_jdot_mb = use_other_jdot_mb
     497            0 :          b% use_other_extra_jdot = use_other_extra_jdot
     498            0 :          b% use_other_binary_wind_transfer = use_other_binary_wind_transfer
     499            0 :          b% use_other_edot_tidal = use_other_edot_tidal
     500            0 :          b% use_other_edot_enhance = use_other_edot_enhance
     501            0 :          b% use_other_extra_edot = use_other_extra_edot
     502            0 :          b% use_other_CE_init = use_other_CE_init
     503            0 :          b% use_other_CE_rlo_mdot = use_other_CE_rlo_mdot
     504            0 :          b% use_other_CE_binary_evolve_step = use_other_CE_binary_evolve_step
     505            0 :          b% use_other_CE_binary_finish_step = use_other_CE_binary_finish_step
     506              : 
     507            0 :          b% x_ctrl = x_ctrl
     508            0 :          b% x_integer_ctrl = x_integer_ctrl
     509            0 :          b% x_logical_ctrl = x_logical_ctrl
     510            0 :          b% x_character_ctrl = x_character_ctrl
     511              : 
     512            0 :       end subroutine store_binary_controls
     513              : 
     514              : 
     515            0 :       subroutine set_binary_controls_for_writing(b, ierr)
     516              :          type (binary_info), pointer :: b
     517              :          integer, intent(out) :: ierr
     518              : 
     519            0 :          ierr = 0
     520              : 
     521              :          ! specifications for starting model
     522            0 :          m1 = b% m1
     523            0 :          m2 = b% m2
     524            0 :          initial_period_in_days = b% initial_period_in_days
     525            0 :          initial_separation_in_Rsuns = b% initial_separation_in_Rsuns
     526            0 :          initial_eccentricity = b% initial_eccentricity
     527              : 
     528              :          ! controls for output
     529            0 :          history_name = b% history_name
     530            0 :          history_interval = b% history_interval
     531            0 :          append_to_star_history = b% append_to_star_history
     532            0 :          log_directory = b% log_directory
     533            0 :          history_dbl_format = b% history_dbl_format
     534            0 :          history_int_format = b% history_int_format
     535            0 :          history_txt_format = b% history_txt_format
     536            0 :          photo_interval = b% photo_interval
     537            0 :          photo_digits = b% photo_digits
     538            0 :          photo_directory = b% photo_directory
     539            0 :          terminal_interval = b% terminal_interval
     540            0 :          write_header_frequency = b% write_header_frequency
     541            0 :          extra_binary_terminal_output_file = b% extra_binary_terminal_output_file
     542              : 
     543              :          ! timestep controls
     544            0 :          time_delta_coeff = b% time_delta_coeff
     545            0 :          fm = b% fm
     546            0 :          fa = b% fa
     547            0 :          fr = b% fr
     548            0 :          fj = b% fj
     549            0 :          fe = b% fe
     550            0 :          fm_limit = b% fm_limit
     551            0 :          fr_limit = b% fr_limit
     552            0 :          fe_limit = b% fe_limit
     553            0 :          fr_dt_limit = b% fr_dt_limit
     554            0 :          fdm = b% fdm
     555            0 :          fdm_hard = b% fdm_hard
     556            0 :          dt_softening_factor = b% dt_softening_factor
     557            0 :          varcontrol_case_a = b% varcontrol_case_a
     558            0 :          varcontrol_case_b = b% varcontrol_case_b
     559            0 :          varcontrol_ms = b% varcontrol_ms
     560            0 :          varcontrol_post_ms = b% varcontrol_post_ms
     561            0 :          dt_reduction_factor_for_j = b% dt_reduction_factor_for_j
     562              : 
     563              :          ! when to stop
     564            0 :          accretor_overflow_terminate = b% accretor_overflow_terminate
     565            0 :          terminate_if_initial_overflow = b% terminate_if_initial_overflow
     566            0 :          terminate_if_L2_overflow = b% terminate_if_L2_overflow
     567              : 
     568              :          ! mass transfer controls
     569            0 :          mass_transfer_alpha = b% mass_transfer_alpha
     570            0 :          mass_transfer_beta = b% mass_transfer_beta
     571            0 :          mass_transfer_delta = b% mass_transfer_delta
     572            0 :          mass_transfer_gamma = b% mass_transfer_gamma
     573            0 :          limit_retention_by_mdot_edd = b% limit_retention_by_mdot_edd
     574            0 :          use_es_opacity_for_mdot_edd = b% use_es_opacity_for_mdot_edd
     575            0 :          use_this_for_mdot_edd_eta = b% use_this_for_mdot_edd_eta
     576            0 :          use_radiation_corrected_transfer_rate = b% use_radiation_corrected_transfer_rate
     577            0 :          initial_bh_spin = b% initial_bh_spin
     578            0 :          use_this_for_mdot_edd = b% use_this_for_mdot_edd
     579            0 :          mdot_scheme = b% mdot_scheme
     580            0 :          cur_mdot_frac = b% cur_mdot_frac
     581            0 :          max_explicit_abs_mdot = b% max_explicit_abs_mdot
     582            0 :          max_tries_to_achieve = b% max_tries_to_achieve
     583            0 :          solver_type = b% solver_type
     584            0 :          implicit_scheme_tolerance = b% implicit_scheme_tolerance
     585            0 :          implicit_scheme_tiny_factor = b% implicit_scheme_tiny_factor
     586            0 :          initial_change_factor = b% initial_change_factor
     587            0 :          change_factor_fraction = b% change_factor_fraction
     588            0 :          implicit_lambda = b% implicit_lambda
     589            0 :          max_change_factor = b% max_change_factor
     590            0 :          min_change_factor = b% min_change_factor
     591            0 :          num_tries_for_increase_change_factor = b% num_tries_for_increase_change_factor
     592            0 :          change_factor_increase = b% change_factor_increase
     593            0 :          starting_mdot = b% starting_mdot
     594            0 :          roche_min_mdot = b% roche_min_mdot
     595            0 :          min_mdot_for_implicit = b% min_mdot_for_implicit
     596            0 :          max_implicit_abs_mdot = b% max_implicit_abs_mdot
     597            0 :          report_rlo_solver_progress = b% report_rlo_solver_progress
     598            0 :          do_enhance_wind_1 = b% do_enhance_wind_1
     599            0 :          do_enhance_wind_2 = b% do_enhance_wind_2
     600            0 :          tout_B_wind_1 = b% tout_B_wind_1
     601            0 :          tout_B_wind_2 = b% tout_B_wind_2
     602            0 :          do_wind_mass_transfer_1 = b% do_wind_mass_transfer_1
     603            0 :          do_wind_mass_transfer_2 = b% do_wind_mass_transfer_2
     604            0 :          wind_BH_alpha_1 = b% wind_BH_alpha_1
     605            0 :          wind_BH_alpha_2 = b% wind_BH_alpha_2
     606            0 :          wind_BH_beta_1 = b% wind_BH_beta_1
     607            0 :          wind_BH_beta_2 = b% wind_BH_beta_2
     608            0 :          max_wind_transfer_fraction_1 = b% max_wind_transfer_fraction_1
     609            0 :          max_wind_transfer_fraction_2 = b% max_wind_transfer_fraction_2
     610              : 
     611              :          ! orbital jdot controls
     612            0 :          do_jdot_gr = b% do_jdot_gr
     613            0 :          do_jdot_ml = b% do_jdot_ml
     614            0 :          do_jdot_ls = b% do_jdot_ls
     615            0 :          do_jdot_missing_wind = b% do_jdot_missing_wind
     616            0 :          do_jdot_mb = b% do_jdot_mb
     617            0 :          include_accretor_mb = b% include_accretor_mb
     618            0 :          magnetic_braking_gamma = b% magnetic_braking_gamma
     619            0 :          keep_mb_on = b% keep_mb_on
     620            0 :          jdot_mb_min_qconv_env = b% jdot_mb_min_qconv_env
     621            0 :          jdot_mb_max_qconv_env = b% jdot_mb_max_qconv_env
     622            0 :          jdot_mb_max_qconv_core = b% jdot_mb_max_qconv_core
     623            0 :          jdot_mb_qlim_for_check_rad_core = b% jdot_mb_qlim_for_check_rad_core
     624            0 :          jdot_mb_qlim_for_check_conv_env = b% jdot_mb_qlim_for_check_conv_env
     625            0 :          jdot_mb_scale_for_low_qconv_env = b% jdot_mb_scale_for_low_qconv_env
     626            0 :          jdot_mb_mass_frac_for_scale = b% jdot_mb_mass_frac_for_scale
     627            0 :          jdot_multiplier = b% jdot_multiplier
     628              : 
     629              :          ! rotation and sync controls
     630            0 :          do_j_accretion = b% do_j_accretion
     631            0 :          do_tidal_sync = b% do_tidal_sync
     632            0 :          sync_type_1 = b% sync_type_1
     633            0 :          sync_type_2 = b% sync_type_2
     634            0 :          sync_mode_1 = b% sync_mode_1
     635            0 :          sync_mode_2 = b% sync_mode_2
     636            0 :          Ftid_1 = b% Ftid_1
     637            0 :          Ftid_2 = b% Ftid_2
     638            0 :          do_initial_orbit_sync_1 = b% do_initial_orbit_sync_1
     639            0 :          do_initial_orbit_sync_2 = b% do_initial_orbit_sync_2
     640            0 :          tidal_reduction = b% tidal_reduction
     641              : 
     642              :          ! eccentricity controls
     643            0 :          do_tidal_circ = b% do_tidal_circ
     644            0 :          circ_type_1 = b% circ_type_1
     645            0 :          circ_type_2 = b% circ_type_2
     646            0 :          use_eccentricity_enhancement = b% use_eccentricity_enhancement
     647            0 :          max_abs_edot_tidal = b% max_abs_edot_tidal
     648            0 :          max_abs_edot_enhance = b% max_abs_edot_enhance
     649            0 :          min_eccentricity = b% min_eccentricity
     650            0 :          max_eccentricity = b% max_eccentricity
     651            0 :          anomaly_steps = b% anomaly_steps
     652              : 
     653              :          ! irradiation controls
     654            0 :          accretion_powered_irradiation = b% accretion_powered_irradiation
     655            0 :          use_accretor_luminosity_for_irrad = b% use_accretor_luminosity_for_irrad
     656            0 :          col_depth_for_eps_extra = b% col_depth_for_eps_extra
     657            0 :          irrad_flux_at_std_distance = b% irrad_flux_at_std_distance
     658            0 :          std_distance_for_irradiation = b% std_distance_for_irradiation
     659            0 :          max_F_irr = b% max_F_irr
     660              : 
     661              :          !common envelope controls
     662            0 :          CE_alpha = b% CE_alpha
     663            0 :          CE_alpha_th = b% CE_alpha_th
     664            0 :          CE_alpha_core = b% CE_alpha_core
     665            0 :          CE_mass_loss_rate_high = b% CE_mass_loss_rate_high
     666            0 :          CE_mass_loss_rate_low = b% CE_mass_loss_rate_low
     667            0 :          CE_rel_rlo_for_detachment = b% CE_rel_rlo_for_detachment
     668            0 :          CE_years_detached_to_terminate = b% CE_years_detached_to_terminate
     669            0 :          CE_begin_at_max_implicit_abs_mdot = b% CE_begin_at_max_implicit_abs_mdot
     670            0 :          CE_xa_diff_to_terminate = b% CE_xa_diff_to_terminate
     671            0 :          CE_terminate_when_core_overflows = b% CE_terminate_when_core_overflows
     672            0 :          CE_min_period_in_minutes = b% CE_min_period_in_minutes
     673            0 :          CE_fixed_lambda = b% CE_fixed_lambda
     674              : 
     675              :          ! miscellaneous controls
     676            0 :          keep_donor_fixed = b% keep_donor_fixed
     677            0 :          mdot_limit_donor_switch = b% mdot_limit_donor_switch
     678            0 :          use_tidal_deformation = b% use_tidal_deformation
     679            0 :          f_sync_switch_from_rot_defor = b% f_sync_switch_from_rot_defor
     680            0 :          f_sync_switch_width = b% f_sync_switch_width
     681            0 :          f_sync_switch_lim = b% f_sync_switch_lim
     682            0 :          use_other_tidal_deformation_switch_function = b% use_other_tidal_deformation_switch_function
     683            0 :          use_other_rlo_mdot = b% use_other_rlo_mdot
     684            0 :          use_other_check_implicit_rlo = b% use_other_check_implicit_rlo
     685            0 :          use_other_implicit_function_to_solve = b% use_other_implicit_function_to_solve
     686            0 :          use_other_tsync = b% use_other_tsync
     687            0 :          use_other_sync_spin_to_orbit = b% use_other_sync_spin_to_orbit
     688            0 :          use_other_mdot_edd = b% use_other_mdot_edd
     689            0 :          use_other_adjust_mdots = b% use_other_adjust_mdots
     690            0 :          use_other_accreted_material_j = b% use_other_accreted_material_j
     691            0 :          use_other_jdot_gr = b% use_other_jdot_gr
     692            0 :          use_other_jdot_ml = b% use_other_jdot_ml
     693            0 :          use_other_jdot_ls = b% use_other_jdot_ls
     694            0 :          use_other_jdot_missing_wind = b% use_other_jdot_missing_wind
     695            0 :          use_other_jdot_mb = b% use_other_jdot_mb
     696            0 :          use_other_extra_jdot = b% use_other_extra_jdot
     697            0 :          use_other_binary_wind_transfer = b% use_other_binary_wind_transfer
     698            0 :          use_other_edot_tidal = b% use_other_edot_tidal
     699            0 :          use_other_edot_enhance = b% use_other_edot_enhance
     700            0 :          use_other_extra_edot = b% use_other_extra_edot
     701            0 :          use_other_CE_init = b% use_other_CE_init
     702            0 :          use_other_CE_rlo_mdot = b% use_other_CE_rlo_mdot
     703            0 :          use_other_CE_binary_evolve_step = b% use_other_CE_binary_evolve_step
     704            0 :          use_other_CE_binary_finish_step = b% use_other_CE_binary_finish_step
     705              : 
     706            0 :          x_ctrl = b% x_ctrl
     707            0 :          x_integer_ctrl = b% x_integer_ctrl
     708            0 :          x_logical_ctrl = b% x_logical_ctrl
     709            0 :          x_character_ctrl = b% x_character_ctrl
     710              : 
     711            0 :       end subroutine set_binary_controls_for_writing
     712              : 
     713            0 :       subroutine write_binary_controls(io,ierr)
     714              :          integer, intent(in) :: io
     715              :          integer, intent(out) :: ierr
     716            0 :          write(io, nml=binary_controls, iostat=ierr)
     717            0 :       end subroutine write_binary_controls
     718              : 
     719              : 
     720            0 :       subroutine get_binary_control(b, name, val, ierr)
     721              :          use utils_lib, only: StrUpCase
     722              :          type (binary_info), pointer :: b
     723              :          character(len=*),intent(in) :: name
     724              :          character(len=*), intent(out) :: val
     725              :          integer, intent(out) :: ierr
     726              : 
     727            0 :          character(len(name)) :: upper_name
     728              :          character(len=512) :: str
     729              :          integer :: iounit,iostat,ind,i
     730              : 
     731              : 
     732              :          ! First save current controls
     733            0 :          call set_binary_controls_for_writing(b, ierr)
     734            0 :          if(ierr/=0) return
     735              : 
     736              :          ! Write namelist to temporary file
     737            0 :          open(newunit=iounit,status='scratch')
     738            0 :          write(iounit,nml=binary_controls)
     739            0 :          rewind(iounit)
     740              : 
     741              :          ! Namelists get written in capitals
     742            0 :          upper_name = StrUpCase(name)
     743            0 :          val = ''
     744              :          ! Search for name inside namelist
     745              :          do
     746            0 :             read(iounit,'(A)',iostat=iostat) str
     747            0 :             ind = index(str,trim(upper_name))
     748            0 :             if( ind /= 0 ) then
     749            0 :                val = str(ind+len_trim(upper_name)+1:len_trim(str)-1)  ! Remove final comma and starting =
     750            0 :                do i=1,len(val)
     751            0 :                   if(val(i:i)=='"') val(i:i) = ' '
     752              :                end do
     753              :                exit
     754              :             end if
     755            0 :             if(is_iostat_end(iostat)) exit
     756              :          end do
     757              : 
     758            0 :          if(len_trim(val) == 0 .and. ind==0 ) ierr = -1
     759              : 
     760            0 :          close(iounit)
     761              : 
     762            0 :       end subroutine get_binary_control
     763              : 
     764            0 :       subroutine set_binary_control(b, name, val, ierr)
     765              :          type (binary_info), pointer :: b
     766              :          character(len=*), intent(in) :: name, val
     767            0 :          character(len=len(name)+len(val)+19) :: tmp
     768              :          integer, intent(out) :: ierr
     769              : 
     770              :          ! First save current controls
     771            0 :          call set_binary_controls_for_writing(b, ierr)
     772            0 :          if(ierr/=0) return
     773              : 
     774            0 :          tmp=''
     775            0 :          tmp = '&binary_controls '//trim(name)//'='//trim(val)//' /'
     776              : 
     777              :          ! Load into namelist
     778            0 :          read(tmp, nml=binary_controls)
     779              : 
     780              :          ! Add to star
     781            0 :          call store_binary_controls(b)
     782            0 :          if(ierr/=0) return
     783              : 
     784              :       end subroutine set_binary_control
     785              : 
     786              :       end module binary_ctrls_io
     787              : 
        

Generated by: LCOV version 2.0-1