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 % 429 0
Test Date: 2025-11-11 15:19:17 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_lib
     263              :          type (binary_info), pointer :: b
     264              :          character(*), intent(in) :: filename
     265              :          integer, intent(out) :: ierr
     266              : 
     267            0 :          call read_binary_controls_file(b, filename, 1, ierr)
     268              : 
     269            0 :       end subroutine read_binary_controls
     270              : 
     271              : 
     272            0 :       recursive subroutine read_binary_controls_file(b, filename, level, ierr)
     273              :          use utils_lib
     274              :          character(*), intent(in) :: filename
     275              :          type (binary_info), pointer :: b
     276              :          integer, intent(in) :: level
     277              :          integer, intent(out) :: ierr
     278              :          logical, dimension(max_extra_inlists) :: read_extra
     279              :          character (len=strlen), dimension(max_extra_inlists) :: extra
     280              :          integer :: unit, i
     281              : 
     282            0 :          ierr = 0
     283              : 
     284            0 :          if (level >= 10) then
     285            0 :             write(*,*) 'ERROR: too many levels of nested extra binary controls inlist files'
     286            0 :             ierr = -1
     287            0 :             return
     288              :          end if
     289              : 
     290            0 :          if (len_trim(filename) > 0) then
     291            0 :             open(newunit=unit, file=trim(filename), action='read', delim='quote', status='old', iostat=ierr)
     292            0 :             if (ierr /= 0) then
     293            0 :                write(*, *) 'Failed to open binary control namelist file ', trim(filename)
     294            0 :                return
     295              :             end if
     296            0 :             read(unit, nml=binary_controls, iostat=ierr)
     297            0 :             close(unit)
     298            0 :             if (ierr /= 0) then
     299            0 :                write(*, *)
     300            0 :                write(*, *)
     301            0 :                write(*, *)
     302            0 :                write(*, *)
     303              :                write(*, '(a)') &
     304            0 :                   'Failed while trying to read binary control namelist file: ' // trim(filename)
     305              :                write(*, '(a)') &
     306            0 :                   'Perhaps the following runtime error message will help you find the problem.'
     307            0 :                write(*, *)
     308            0 :                open(newunit=unit, file=trim(filename), action='read', delim='quote', status='old', iostat=ierr)
     309            0 :                read(unit, nml=binary_controls)
     310            0 :                close(unit)
     311            0 :                return
     312              :             end if
     313              :          end if
     314              : 
     315            0 :          call store_binary_controls(b, ierr)
     316              : 
     317              :          ! recursive calls to read other inlists
     318            0 :          do i=1, max_extra_inlists
     319            0 :             read_extra(i) = read_extra_binary_controls_inlist(i)
     320            0 :             read_extra_binary_controls_inlist(i) = .false.
     321            0 :             extra(i) = extra_binary_controls_inlist_name(i)
     322            0 :             extra_binary_controls_inlist_name(i) = 'undefined'
     323              : 
     324            0 :             if (read_extra(i)) then
     325            0 :                call read_binary_controls_file(b, extra(i), level+1, ierr)
     326            0 :                if (ierr /= 0) return
     327              :             end if
     328              :          end do
     329              : 
     330              :       end subroutine read_binary_controls_file
     331              : 
     332              : 
     333            0 :       subroutine set_default_binary_controls
     334              :          include 'binary_controls.defaults'
     335            0 :       end subroutine set_default_binary_controls
     336              : 
     337              : 
     338            0 :       subroutine store_binary_controls(b, ierr)
     339              :          use utils_lib, only: mkdir
     340              :          type (binary_info), pointer :: b
     341              :          integer, intent(out) :: ierr
     342              : 
     343            0 :          ierr = 0
     344              : 
     345              :          ! specifications for starting model
     346            0 :          b% m1 = m1
     347            0 :          b% m2 = m2
     348            0 :          b% initial_period_in_days = initial_period_in_days
     349            0 :          b% initial_separation_in_Rsuns = initial_separation_in_Rsuns
     350            0 :          b% initial_eccentricity = initial_eccentricity
     351              : 
     352              :          ! controls for output
     353            0 :          b% history_name = history_name
     354            0 :          b% history_interval = history_interval
     355            0 :          b% append_to_star_history = append_to_star_history
     356            0 :          b% log_directory = log_directory
     357            0 :          CALL mkdir(b% log_directory)
     358            0 :          b% history_dbl_format = history_dbl_format
     359            0 :          b% history_int_format = history_int_format
     360            0 :          b% history_txt_format = history_txt_format
     361            0 :          b% photo_interval = photo_interval
     362            0 :          b% photo_digits = photo_digits
     363            0 :          b% photo_directory = photo_directory
     364            0 :          CALL mkdir(b% photo_directory)
     365            0 :          b% terminal_interval = terminal_interval
     366            0 :          b% write_header_frequency = write_header_frequency
     367            0 :          b% extra_binary_terminal_output_file = extra_binary_terminal_output_file
     368              : 
     369              :          ! timestep controls
     370            0 :          b% time_delta_coeff = time_delta_coeff
     371            0 :          b% fm = fm
     372            0 :          b% fm_hard = fm_hard
     373            0 :          b% fa = fa
     374            0 :          b% fa_hard = fa_hard
     375            0 :          b% fr = fr
     376            0 :          b% fr_hard = fr_hard
     377            0 :          b% fj = fj
     378            0 :          b% fj_hard = fj_hard
     379            0 :          b% fe = fe
     380            0 :          b% fe_hard = fe_hard
     381            0 :          b% fm_limit = fm_limit
     382            0 :          b% fr_limit = fr_limit
     383            0 :          b% fe_limit = fe_limit
     384            0 :          b% fr_dt_limit = fr_dt_limit
     385            0 :          b% fdm = fdm
     386            0 :          b% fdm_hard = fdm_hard
     387            0 :          b% dt_softening_factor = dt_softening_factor
     388            0 :          b% varcontrol_case_a = varcontrol_case_a
     389            0 :          b% varcontrol_case_b = varcontrol_case_b
     390            0 :          b% varcontrol_ms = varcontrol_ms
     391            0 :          b% varcontrol_post_ms = varcontrol_post_ms
     392            0 :          b% dt_reduction_factor_for_j = dt_reduction_factor_for_j
     393              : 
     394              :          ! when to stop
     395            0 :          b% accretor_overflow_terminate = accretor_overflow_terminate
     396            0 :          b% terminate_if_initial_overflow = terminate_if_initial_overflow
     397            0 :          b% terminate_if_L2_overflow = terminate_if_L2_overflow
     398              : 
     399              :          ! mass transfer controls
     400            0 :          b% mass_transfer_alpha = mass_transfer_alpha
     401            0 :          b% mass_transfer_beta = mass_transfer_beta
     402            0 :          b% mass_transfer_delta = mass_transfer_delta
     403            0 :          b% mass_transfer_gamma = mass_transfer_gamma
     404            0 :          b% limit_retention_by_mdot_edd = limit_retention_by_mdot_edd
     405            0 :          b% use_es_opacity_for_mdot_edd = use_es_opacity_for_mdot_edd
     406            0 :          b% use_this_for_mdot_edd_eta = use_this_for_mdot_edd_eta
     407            0 :          b% use_radiation_corrected_transfer_rate = use_radiation_corrected_transfer_rate
     408            0 :          b% initial_bh_spin = initial_bh_spin
     409            0 :          b% use_this_for_mdot_edd = use_this_for_mdot_edd
     410            0 :          b% mdot_scheme = mdot_scheme
     411            0 :          b% cur_mdot_frac = cur_mdot_frac
     412            0 :          b% max_explicit_abs_mdot = max_explicit_abs_mdot
     413            0 :          b% max_tries_to_achieve = max_tries_to_achieve
     414            0 :          b% solver_type = solver_type
     415            0 :          b% implicit_scheme_tolerance = implicit_scheme_tolerance
     416            0 :          b% implicit_scheme_tiny_factor = implicit_scheme_tiny_factor
     417            0 :          b% initial_change_factor = initial_change_factor
     418            0 :          b% change_factor_fraction = change_factor_fraction
     419            0 :          b% implicit_lambda = implicit_lambda
     420            0 :          b% max_change_factor = max_change_factor
     421            0 :          b% min_change_factor = min_change_factor
     422            0 :          b% num_tries_for_increase_change_factor = num_tries_for_increase_change_factor
     423            0 :          b% change_factor_increase = change_factor_increase
     424            0 :          b% starting_mdot = starting_mdot
     425            0 :          b% roche_min_mdot = roche_min_mdot
     426            0 :          b% min_mdot_for_implicit = min_mdot_for_implicit
     427            0 :          b% max_implicit_abs_mdot = max_implicit_abs_mdot
     428            0 :          b% report_rlo_solver_progress = report_rlo_solver_progress
     429            0 :          b% do_enhance_wind_1 = do_enhance_wind_1
     430            0 :          b% do_enhance_wind_2 = do_enhance_wind_2
     431            0 :          b% tout_B_wind_1 = tout_B_wind_1
     432            0 :          b% tout_B_wind_2 = tout_B_wind_2
     433            0 :          b% do_wind_mass_transfer_1 = do_wind_mass_transfer_1
     434            0 :          b% do_wind_mass_transfer_2 = do_wind_mass_transfer_2
     435            0 :          b% wind_BH_alpha_1 = wind_BH_alpha_1
     436            0 :          b% wind_BH_alpha_2 = wind_BH_alpha_2
     437            0 :          b% wind_BH_beta_1 = wind_BH_beta_1
     438            0 :          b% wind_BH_beta_2 = wind_BH_beta_2
     439            0 :          b% max_wind_transfer_fraction_1 = max_wind_transfer_fraction_1
     440            0 :          b% max_wind_transfer_fraction_2 = max_wind_transfer_fraction_2
     441              : 
     442              :          ! orbital jdot controls
     443            0 :          b% do_jdot_gr = do_jdot_gr
     444            0 :          b% do_jdot_ml = do_jdot_ml
     445            0 :          b% do_jdot_ls = do_jdot_ls
     446            0 :          b% do_jdot_missing_wind = do_jdot_missing_wind
     447            0 :          b% do_jdot_mb = do_jdot_mb
     448            0 :          b% include_accretor_mb = include_accretor_mb
     449            0 :          b% magnetic_braking_gamma = magnetic_braking_gamma
     450            0 :          b% keep_mb_on = keep_mb_on
     451            0 :          b% jdot_mb_min_qconv_env = jdot_mb_min_qconv_env
     452            0 :          b% jdot_mb_max_qconv_env = jdot_mb_max_qconv_env
     453            0 :          b% jdot_mb_max_qconv_core = jdot_mb_max_qconv_core
     454            0 :          b% jdot_mb_qlim_for_check_rad_core = jdot_mb_qlim_for_check_rad_core
     455            0 :          b% jdot_mb_qlim_for_check_conv_env = jdot_mb_qlim_for_check_conv_env
     456            0 :          b% jdot_mb_scale_for_low_qconv_env = jdot_mb_scale_for_low_qconv_env
     457            0 :          b% jdot_mb_mass_frac_for_scale = jdot_mb_mass_frac_for_scale
     458            0 :          b% jdot_multiplier = jdot_multiplier
     459              : 
     460              :          ! rotation and sync controls
     461            0 :          b% do_j_accretion = do_j_accretion
     462            0 :          b% do_tidal_sync = do_tidal_sync
     463            0 :          b% sync_type_1 = sync_type_1
     464            0 :          b% sync_type_2 = sync_type_2
     465            0 :          b% sync_mode_1 = sync_mode_1
     466            0 :          b% sync_mode_2 = sync_mode_2
     467            0 :          b% Ftid_1 = Ftid_1
     468            0 :          b% Ftid_2 = Ftid_2
     469            0 :          b% do_initial_orbit_sync_1 = do_initial_orbit_sync_1
     470            0 :          b% do_initial_orbit_sync_2 = do_initial_orbit_sync_2
     471            0 :          b% tidal_reduction = tidal_reduction
     472              : 
     473              :          ! eccentricity controls
     474            0 :          b% do_tidal_circ = do_tidal_circ
     475            0 :          b% circ_type_1 = circ_type_1
     476            0 :          b% circ_type_2 = circ_type_2
     477            0 :          b% use_eccentricity_enhancement = use_eccentricity_enhancement
     478            0 :          b% max_abs_edot_tidal = max_abs_edot_tidal
     479            0 :          b% max_abs_edot_enhance = max_abs_edot_enhance
     480            0 :          b% min_eccentricity = min_eccentricity
     481            0 :          b% max_eccentricity = max_eccentricity
     482            0 :          b% anomaly_steps = anomaly_steps
     483              : 
     484              :          ! irradiation controls
     485            0 :          b% accretion_powered_irradiation = accretion_powered_irradiation
     486            0 :          b% use_accretor_luminosity_for_irrad = use_accretor_luminosity_for_irrad
     487            0 :          b% col_depth_for_eps_extra = col_depth_for_eps_extra
     488            0 :          b% irrad_flux_at_std_distance = irrad_flux_at_std_distance
     489            0 :          b% std_distance_for_irradiation = std_distance_for_irradiation
     490            0 :          b% max_F_irr = max_F_irr
     491              : 
     492              :          !common envelope controls
     493            0 :          b% CE_alpha = CE_alpha
     494            0 :          b% CE_alpha_th = CE_alpha_th
     495            0 :          b% CE_alpha_core = CE_alpha_core
     496            0 :          b% CE_mass_loss_rate_high = CE_mass_loss_rate_high
     497            0 :          b% CE_mass_loss_rate_low = CE_mass_loss_rate_low
     498            0 :          b% CE_rel_rlo_for_detachment = CE_rel_rlo_for_detachment
     499            0 :          b% CE_years_detached_to_terminate = CE_years_detached_to_terminate
     500            0 :          b% CE_begin_at_max_implicit_abs_mdot = CE_begin_at_max_implicit_abs_mdot
     501            0 :          b% CE_xa_diff_to_terminate = CE_xa_diff_to_terminate
     502            0 :          b% CE_terminate_when_core_overflows = CE_terminate_when_core_overflows
     503            0 :          b% CE_min_period_in_minutes = CE_min_period_in_minutes
     504            0 :          b% CE_energy_factor_HII_toHI = CE_energy_factor_HII_toHI
     505            0 :          b% CE_energy_factor_HeII_toHeI = CE_energy_factor_HeII_toHeI
     506            0 :          b% CE_energy_factor_HeIII_toHeII = CE_energy_factor_HeIII_toHeII
     507            0 :          b% CE_energy_factor_H2 = CE_energy_factor_H2
     508            0 :          b% CE_fixed_lambda = CE_fixed_lambda
     509              : 
     510              :          ! miscellaneous controls
     511            0 :          b% keep_donor_fixed = keep_donor_fixed
     512            0 :          b% mdot_limit_donor_switch = mdot_limit_donor_switch
     513            0 :          b% use_tidal_deformation = use_tidal_deformation
     514            0 :          b% f_sync_switch_from_rot_defor = f_sync_switch_from_rot_defor
     515            0 :          b% f_sync_switch_width = f_sync_switch_width
     516            0 :          b% f_sync_switch_lim = f_sync_switch_lim
     517            0 :          b% use_other_tidal_deformation_switch_function = use_other_tidal_deformation_switch_function
     518            0 :          b% use_other_rlo_mdot = use_other_rlo_mdot
     519            0 :          b% use_other_check_implicit_rlo = use_other_check_implicit_rlo
     520            0 :          b% use_other_implicit_function_to_solve = use_other_implicit_function_to_solve
     521            0 :          b% use_other_tsync = use_other_tsync
     522            0 :          b% use_other_sync_spin_to_orbit = use_other_sync_spin_to_orbit
     523            0 :          b% use_other_mdot_edd = use_other_mdot_edd
     524            0 :          b% use_other_adjust_mdots = use_other_adjust_mdots
     525            0 :          b% use_other_accreted_material_j = use_other_accreted_material_j
     526            0 :          b% use_other_jdot_gr = use_other_jdot_gr
     527            0 :          b% use_other_jdot_ml = use_other_jdot_ml
     528            0 :          b% use_other_jdot_ls = use_other_jdot_ls
     529            0 :          b% use_other_jdot_missing_wind = use_other_jdot_missing_wind
     530            0 :          b% use_other_jdot_mb = use_other_jdot_mb
     531            0 :          b% use_other_extra_jdot = use_other_extra_jdot
     532            0 :          b% use_other_binary_wind_transfer = use_other_binary_wind_transfer
     533            0 :          b% use_other_edot_tidal = use_other_edot_tidal
     534            0 :          b% use_other_edot_enhance = use_other_edot_enhance
     535            0 :          b% use_other_extra_edot = use_other_extra_edot
     536            0 :          b% use_other_CE_init = use_other_CE_init
     537            0 :          b% use_other_CE_rlo_mdot = use_other_CE_rlo_mdot
     538            0 :          b% use_other_CE_binary_evolve_step = use_other_CE_binary_evolve_step
     539            0 :          b% use_other_CE_binary_finish_step = use_other_CE_binary_finish_step
     540              : 
     541            0 :          b% x_ctrl = x_ctrl
     542            0 :          b% x_integer_ctrl = x_integer_ctrl
     543            0 :          b% x_logical_ctrl = x_logical_ctrl
     544            0 :          b% x_character_ctrl = x_character_ctrl
     545              : 
     546            0 :       end subroutine store_binary_controls
     547              : 
     548              : 
     549            0 :       subroutine set_binary_controls_for_writing(b, ierr)
     550              :          type (binary_info), pointer :: b
     551              :          integer, intent(out) :: ierr
     552              : 
     553            0 :          ierr = 0
     554              : 
     555              :          ! specifications for starting model
     556            0 :          m1 = b% m1
     557            0 :          m2 = b% m2
     558            0 :          initial_period_in_days = b% initial_period_in_days
     559            0 :          initial_separation_in_Rsuns = b% initial_separation_in_Rsuns
     560            0 :          initial_eccentricity = b% initial_eccentricity
     561              : 
     562              :          ! controls for output
     563            0 :          history_name = b% history_name
     564            0 :          history_interval = b% history_interval
     565            0 :          append_to_star_history = b% append_to_star_history
     566            0 :          log_directory = b% log_directory
     567            0 :          history_dbl_format = b% history_dbl_format
     568            0 :          history_int_format = b% history_int_format
     569            0 :          history_txt_format = b% history_txt_format
     570            0 :          photo_interval = b% photo_interval
     571            0 :          photo_digits = b% photo_digits
     572            0 :          photo_directory = b% photo_directory
     573            0 :          terminal_interval = b% terminal_interval
     574            0 :          write_header_frequency = b% write_header_frequency
     575            0 :          extra_binary_terminal_output_file = b% extra_binary_terminal_output_file
     576              : 
     577              :          ! timestep controls
     578            0 :          time_delta_coeff = b% time_delta_coeff
     579            0 :          fm = b% fm
     580            0 :          fa = b% fa
     581            0 :          fr = b% fr
     582            0 :          fj = b% fj
     583            0 :          fe = b% fe
     584            0 :          fm_limit = b% fm_limit
     585            0 :          fr_limit = b% fr_limit
     586            0 :          fe_limit = b% fe_limit
     587            0 :          fr_dt_limit = b% fr_dt_limit
     588            0 :          fdm = b% fdm
     589            0 :          fdm_hard = b% fdm_hard
     590            0 :          dt_softening_factor = b% dt_softening_factor
     591            0 :          varcontrol_case_a = b% varcontrol_case_a
     592            0 :          varcontrol_case_b = b% varcontrol_case_b
     593            0 :          varcontrol_ms = b% varcontrol_ms
     594            0 :          varcontrol_post_ms = b% varcontrol_post_ms
     595            0 :          dt_reduction_factor_for_j = b% dt_reduction_factor_for_j
     596              : 
     597              :          ! when to stop
     598            0 :          accretor_overflow_terminate = b% accretor_overflow_terminate
     599            0 :          terminate_if_initial_overflow = b% terminate_if_initial_overflow
     600            0 :          terminate_if_L2_overflow = b% terminate_if_L2_overflow
     601              : 
     602              :          ! mass transfer controls
     603            0 :          mass_transfer_alpha = b% mass_transfer_alpha
     604            0 :          mass_transfer_beta = b% mass_transfer_beta
     605            0 :          mass_transfer_delta = b% mass_transfer_delta
     606            0 :          mass_transfer_gamma = b% mass_transfer_gamma
     607            0 :          limit_retention_by_mdot_edd = b% limit_retention_by_mdot_edd
     608            0 :          use_es_opacity_for_mdot_edd = b% use_es_opacity_for_mdot_edd
     609            0 :          use_this_for_mdot_edd_eta = b% use_this_for_mdot_edd_eta
     610            0 :          use_radiation_corrected_transfer_rate = b% use_radiation_corrected_transfer_rate
     611            0 :          initial_bh_spin = b% initial_bh_spin
     612            0 :          use_this_for_mdot_edd = b% use_this_for_mdot_edd
     613            0 :          mdot_scheme = b% mdot_scheme
     614            0 :          cur_mdot_frac = b% cur_mdot_frac
     615            0 :          max_explicit_abs_mdot = b% max_explicit_abs_mdot
     616            0 :          max_tries_to_achieve = b% max_tries_to_achieve
     617            0 :          solver_type = b% solver_type
     618            0 :          implicit_scheme_tolerance = b% implicit_scheme_tolerance
     619            0 :          implicit_scheme_tiny_factor = b% implicit_scheme_tiny_factor
     620            0 :          initial_change_factor = b% initial_change_factor
     621            0 :          change_factor_fraction = b% change_factor_fraction
     622            0 :          implicit_lambda = b% implicit_lambda
     623            0 :          max_change_factor = b% max_change_factor
     624            0 :          min_change_factor = b% min_change_factor
     625            0 :          num_tries_for_increase_change_factor = b% num_tries_for_increase_change_factor
     626            0 :          change_factor_increase = b% change_factor_increase
     627            0 :          starting_mdot = b% starting_mdot
     628            0 :          roche_min_mdot = b% roche_min_mdot
     629            0 :          min_mdot_for_implicit = b% min_mdot_for_implicit
     630            0 :          max_implicit_abs_mdot = b% max_implicit_abs_mdot
     631            0 :          report_rlo_solver_progress = b% report_rlo_solver_progress
     632            0 :          do_enhance_wind_1 = b% do_enhance_wind_1
     633            0 :          do_enhance_wind_2 = b% do_enhance_wind_2
     634            0 :          tout_B_wind_1 = b% tout_B_wind_1
     635            0 :          tout_B_wind_2 = b% tout_B_wind_2
     636            0 :          do_wind_mass_transfer_1 = b% do_wind_mass_transfer_1
     637            0 :          do_wind_mass_transfer_2 = b% do_wind_mass_transfer_2
     638            0 :          wind_BH_alpha_1 = b% wind_BH_alpha_1
     639            0 :          wind_BH_alpha_2 = b% wind_BH_alpha_2
     640            0 :          wind_BH_beta_1 = b% wind_BH_beta_1
     641            0 :          wind_BH_beta_2 = b% wind_BH_beta_2
     642            0 :          max_wind_transfer_fraction_1 = b% max_wind_transfer_fraction_1
     643            0 :          max_wind_transfer_fraction_2 = b% max_wind_transfer_fraction_2
     644              : 
     645              :          ! orbital jdot controls
     646            0 :          do_jdot_gr = b% do_jdot_gr
     647            0 :          do_jdot_ml = b% do_jdot_ml
     648            0 :          do_jdot_ls = b% do_jdot_ls
     649            0 :          do_jdot_missing_wind = b% do_jdot_missing_wind
     650            0 :          do_jdot_mb = b% do_jdot_mb
     651            0 :          include_accretor_mb = b% include_accretor_mb
     652            0 :          magnetic_braking_gamma = b% magnetic_braking_gamma
     653            0 :          keep_mb_on = b% keep_mb_on
     654            0 :          jdot_mb_min_qconv_env = b% jdot_mb_min_qconv_env
     655            0 :          jdot_mb_max_qconv_env = b% jdot_mb_max_qconv_env
     656            0 :          jdot_mb_max_qconv_core = b% jdot_mb_max_qconv_core
     657            0 :          jdot_mb_qlim_for_check_rad_core = b% jdot_mb_qlim_for_check_rad_core
     658            0 :          jdot_mb_qlim_for_check_conv_env = b% jdot_mb_qlim_for_check_conv_env
     659            0 :          jdot_mb_scale_for_low_qconv_env = b% jdot_mb_scale_for_low_qconv_env
     660            0 :          jdot_mb_mass_frac_for_scale = b% jdot_mb_mass_frac_for_scale
     661            0 :          jdot_multiplier = b% jdot_multiplier
     662              : 
     663              :          ! rotation and sync controls
     664            0 :          do_j_accretion = b% do_j_accretion
     665            0 :          do_tidal_sync = b% do_tidal_sync
     666            0 :          sync_type_1 = b% sync_type_1
     667            0 :          sync_type_2 = b% sync_type_2
     668            0 :          sync_mode_1 = b% sync_mode_1
     669            0 :          sync_mode_2 = b% sync_mode_2
     670            0 :          Ftid_1 = b% Ftid_1
     671            0 :          Ftid_2 = b% Ftid_2
     672            0 :          do_initial_orbit_sync_1 = b% do_initial_orbit_sync_1
     673            0 :          do_initial_orbit_sync_2 = b% do_initial_orbit_sync_2
     674            0 :          tidal_reduction = b% tidal_reduction
     675              : 
     676              :          ! eccentricity controls
     677            0 :          do_tidal_circ = b% do_tidal_circ
     678            0 :          circ_type_1 = b% circ_type_1
     679            0 :          circ_type_2 = b% circ_type_2
     680            0 :          use_eccentricity_enhancement = b% use_eccentricity_enhancement
     681            0 :          max_abs_edot_tidal = b% max_abs_edot_tidal
     682            0 :          max_abs_edot_enhance = b% max_abs_edot_enhance
     683            0 :          min_eccentricity = b% min_eccentricity
     684            0 :          max_eccentricity = b% max_eccentricity
     685            0 :          anomaly_steps = b% anomaly_steps
     686              : 
     687              :          ! irradiation controls
     688            0 :          accretion_powered_irradiation = b% accretion_powered_irradiation
     689            0 :          use_accretor_luminosity_for_irrad = b% use_accretor_luminosity_for_irrad
     690            0 :          col_depth_for_eps_extra = b% col_depth_for_eps_extra
     691            0 :          irrad_flux_at_std_distance = b% irrad_flux_at_std_distance
     692            0 :          std_distance_for_irradiation = b% std_distance_for_irradiation
     693            0 :          max_F_irr = b% max_F_irr
     694              : 
     695              :          !common envelope controls
     696            0 :          CE_alpha = b% CE_alpha
     697            0 :          CE_alpha_th = b% CE_alpha_th
     698            0 :          CE_alpha_core = b% CE_alpha_core
     699            0 :          CE_mass_loss_rate_high = b% CE_mass_loss_rate_high
     700            0 :          CE_mass_loss_rate_low = b% CE_mass_loss_rate_low
     701            0 :          CE_rel_rlo_for_detachment = b% CE_rel_rlo_for_detachment
     702            0 :          CE_years_detached_to_terminate = b% CE_years_detached_to_terminate
     703            0 :          CE_begin_at_max_implicit_abs_mdot = b% CE_begin_at_max_implicit_abs_mdot
     704            0 :          CE_xa_diff_to_terminate = b% CE_xa_diff_to_terminate
     705            0 :          CE_terminate_when_core_overflows = b% CE_terminate_when_core_overflows
     706            0 :          CE_min_period_in_minutes = b% CE_min_period_in_minutes
     707            0 :          CE_fixed_lambda = b% CE_fixed_lambda
     708              : 
     709              :          ! miscellaneous controls
     710            0 :          keep_donor_fixed = b% keep_donor_fixed
     711            0 :          mdot_limit_donor_switch = b% mdot_limit_donor_switch
     712            0 :          use_tidal_deformation = b% use_tidal_deformation
     713            0 :          f_sync_switch_from_rot_defor = b% f_sync_switch_from_rot_defor
     714            0 :          f_sync_switch_width = b% f_sync_switch_width
     715            0 :          f_sync_switch_lim = b% f_sync_switch_lim
     716            0 :          use_other_tidal_deformation_switch_function = b% use_other_tidal_deformation_switch_function
     717            0 :          use_other_rlo_mdot = b% use_other_rlo_mdot
     718            0 :          use_other_check_implicit_rlo = b% use_other_check_implicit_rlo
     719            0 :          use_other_implicit_function_to_solve = b% use_other_implicit_function_to_solve
     720            0 :          use_other_tsync = b% use_other_tsync
     721            0 :          use_other_sync_spin_to_orbit = b% use_other_sync_spin_to_orbit
     722            0 :          use_other_mdot_edd = b% use_other_mdot_edd
     723            0 :          use_other_adjust_mdots = b% use_other_adjust_mdots
     724            0 :          use_other_accreted_material_j = b% use_other_accreted_material_j
     725            0 :          use_other_jdot_gr = b% use_other_jdot_gr
     726            0 :          use_other_jdot_ml = b% use_other_jdot_ml
     727            0 :          use_other_jdot_ls = b% use_other_jdot_ls
     728            0 :          use_other_jdot_missing_wind = b% use_other_jdot_missing_wind
     729            0 :          use_other_jdot_mb = b% use_other_jdot_mb
     730            0 :          use_other_extra_jdot = b% use_other_extra_jdot
     731            0 :          use_other_binary_wind_transfer = b% use_other_binary_wind_transfer
     732            0 :          use_other_edot_tidal = b% use_other_edot_tidal
     733            0 :          use_other_edot_enhance = b% use_other_edot_enhance
     734            0 :          use_other_extra_edot = b% use_other_extra_edot
     735            0 :          use_other_CE_init = b% use_other_CE_init
     736            0 :          use_other_CE_rlo_mdot = b% use_other_CE_rlo_mdot
     737            0 :          use_other_CE_binary_evolve_step = b% use_other_CE_binary_evolve_step
     738            0 :          use_other_CE_binary_finish_step = b% use_other_CE_binary_finish_step
     739              : 
     740            0 :          x_ctrl = b% x_ctrl
     741            0 :          x_integer_ctrl = b% x_integer_ctrl
     742            0 :          x_logical_ctrl = b% x_logical_ctrl
     743            0 :          x_character_ctrl = b% x_character_ctrl
     744              : 
     745            0 :       end subroutine set_binary_controls_for_writing
     746              : 
     747            0 :       subroutine write_binary_controls(io,ierr)
     748              :          integer, intent(in) :: io
     749              :          integer, intent(out) :: ierr
     750            0 :          write(io, nml=binary_controls, iostat=ierr)
     751            0 :       end subroutine write_binary_controls
     752              : 
     753              : 
     754            0 :       subroutine get_binary_control(b, name, val, ierr)
     755              :          use utils_lib, only: StrUpCase
     756              :          type (binary_info), pointer :: b
     757              :          character(len=*),intent(in) :: name
     758              :          character(len=*), intent(out) :: val
     759              :          integer, intent(out) :: ierr
     760              : 
     761            0 :          character(len(name)) :: upper_name
     762              :          character(len=512) :: str
     763              :          integer :: iounit,iostat,ind,i
     764              : 
     765              : 
     766              :          ! First save current controls
     767            0 :          call set_binary_controls_for_writing(b, ierr)
     768            0 :          if(ierr/=0) return
     769              : 
     770              :          ! Write namelist to temporary file
     771            0 :          open(newunit=iounit,status='scratch')
     772            0 :          write(iounit,nml=binary_controls)
     773            0 :          rewind(iounit)
     774              : 
     775              :          ! Namelists get written in capitals
     776            0 :          upper_name = StrUpCase(name)
     777            0 :          val = ''
     778              :          ! Search for name inside namelist
     779              :          do
     780            0 :             read(iounit,'(A)',iostat=iostat) str
     781            0 :             ind = index(str,trim(upper_name))
     782            0 :             if( ind /= 0 ) then
     783            0 :                val = str(ind+len_trim(upper_name)+1:len_trim(str)-1)  ! Remove final comma and starting =
     784            0 :                do i=1,len(val)
     785            0 :                   if(val(i:i)=='"') val(i:i) = ' '
     786              :                end do
     787              :                exit
     788              :             end if
     789            0 :             if(is_iostat_end(iostat)) exit
     790              :          end do
     791              : 
     792            0 :          if(len_trim(val) == 0 .and. ind==0 ) ierr = -1
     793              : 
     794            0 :          close(iounit)
     795              : 
     796            0 :       end subroutine get_binary_control
     797              : 
     798            0 :       subroutine set_binary_control(b, name, val, ierr)
     799              :          type (binary_info), pointer :: b
     800              :          character(len=*), intent(in) :: name, val
     801            0 :          character(len=len(name)+len(val)+19) :: tmp
     802              :          integer, intent(out) :: ierr
     803              : 
     804              :          ! First save current controls
     805            0 :          call set_binary_controls_for_writing(b, ierr)
     806            0 :          if(ierr/=0) return
     807              : 
     808            0 :          tmp=''
     809            0 :          tmp = '&binary_controls '//trim(name)//'='//trim(val)//' /'
     810              : 
     811              :          ! Load into namelist
     812            0 :          read(tmp, nml=binary_controls)
     813              : 
     814              :          ! Add to star
     815            0 :          call store_binary_controls(b, ierr)
     816            0 :          if(ierr/=0) return
     817              : 
     818              :       end subroutine set_binary_control
     819              : 
     820              :       end module binary_ctrls_io
     821              : 
        

Generated by: LCOV version 2.0-1