LCOV - code coverage report
Current view: top level - net/public - net_def.f90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 74.2 % 163 121
Test Date: 2025-05-08 18:23:42 Functions: 53.3 % 15 8

            Line data    Source code
       1              : ! ***********************************************************************
       2              : !
       3              : !   Copyright (C) 2010  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 net_def
      21              : 
      22              :       use const_def, only: dp, qp, i8
      23              : 
      24              :       implicit none
      25              : 
      26              :       ! reaction_kind array in Net_General_Info
      27              :          integer, parameter :: neut_kind = 1  ! involves neut but no prot
      28              :          integer, parameter :: prot_kind = neut_kind + 1  ! involves prot and perhaps neut
      29              :          integer, parameter :: other_strong_kind = prot_kind + 1  ! strong, no neut or prot
      30              :          integer, parameter :: weak_kind = other_strong_kind + 1
      31              :          integer, parameter :: num_kinds = weak_kind
      32              : 
      33              :       ! for reaction_reaclib_kind array in Net_General_Info
      34              :          integer, parameter :: other_kind = 0
      35              :             ! includes weak reactions and reactions that don't have reverse in net
      36              :             ! and one of each pair of 2 to 2 reactions (including np, pa, na)
      37              :          integer, parameter :: ng_kind = other_kind + 1
      38              :          integer, parameter :: pn_kind = ng_kind + 1
      39              :          integer, parameter :: pg_kind = pn_kind + 1
      40              :          integer, parameter :: ap_kind = pg_kind + 1
      41              :          integer, parameter :: an_kind = ap_kind + 1
      42              :          integer, parameter :: ag_kind = an_kind + 1
      43              :          integer, parameter :: general_one_one_kind = ag_kind + 1  ! 1 species in and 1 out (e.g., 3alfa)
      44              :          integer, parameter :: general_two_one_kind = general_one_one_kind + 1  ! 2 species in and 1 out
      45              :          integer, parameter :: general_two_two_kind = general_two_one_kind + 1  ! 2 species in and 2 out
      46              :          integer, parameter :: max_kind = general_two_two_kind
      47              : 
      48              : 
      49              :       type Net_General_Info  ! things that are constant for the particular net
      50              :       ! it is okay to have multiple threads using the same instance of this simultaneously.
      51              : 
      52              :          integer :: num_isos  ! total number in current net
      53              :          integer :: num_reactions  ! total number of reactions for current net
      54              : 
      55              :          logical :: doing_approx21, add_co56_to_approx21
      56              : 
      57              :          integer :: approx21_ye_iso  ! e.g., icr56 for fake fe56ec
      58              :          integer :: fe56ec_n_neut  ! number of neutrons consumed per fake fe56ec
      59              : 
      60              :          character (len=32) :: cache_suffix
      61              : 
      62              :          ! isotopes
      63              :          integer, pointer :: net_iso(:)  ! maps chem id to net iso number
      64              :          ! index from 1 to num_chem_isos
      65              :          ! value is 0 if the iso is not in the current net
      66              :          ! else is value between 1 and num_isos in current net
      67              :          integer, pointer :: chem_id(:)  ! maps net iso number to chem id
      68              :          ! index from 1 to num_isos in current net
      69              :          ! value is between 1 and num_chem_isos
      70              : 
      71              :          ! reactions
      72              : 
      73              :          integer, pointer :: net_reaction(:)  ! maps reaction id to net reaction number
      74              :          ! index from 1 to rates_reaction_id_max (in rates_def)
      75              :          ! value is 0 if the reaction is not in the current net
      76              :          ! else is value between 1 and num_reactions in current net
      77              :          integer, allocatable :: reaction_id(:)  ! maps net reaction number to reaction id
      78              :          ! index from 1 to num_reactions in current net
      79              :          ! value is between 1 and rates_reaction_id_max (in rates_def)
      80              : 
      81              :          integer, allocatable :: reaction_kind(:)
      82              : 
      83              :          integer, pointer :: reaction_reaclib_kind(:)
      84              :          integer, pointer :: reverse_id_for_kind_ne_other(:)
      85              : 
      86              :          integer, allocatable :: reaction_max_Z(:)
      87              :          integer, allocatable:: reaction_max_Z_plus_N_for_max_Z(:)
      88              : 
      89              :          ! extra info
      90              : 
      91              :          ! strong rates cutoff smoothly for logT < logTcut_lim
      92              :          real(dp) :: logTcut_lim
      93              :          ! strong rates are zero logT < logTcut_lo
      94              :          real(dp) :: logTcut_lo
      95              : 
      96              :          ! equilibrium eps_nuc cancellation for ng, pg, pn reactions
      97              :          ! at high T, these reactions are assumed in equilibrium with their reverses,
      98              :          ! so no net eps_nuc from the pair
      99              :          real(dp) :: logT_lo_eps_nuc_cancel  ! no cancellation for logT <= this
     100              :          real(dp) :: logT_hi_eps_nuc_cancel  ! full cancellation for logT >= this
     101              : 
     102              :          real(dp) :: fe56ec_fake_factor, min_T_for_fe56ec_fake_factor
     103              : 
     104              :          ! the following is private info for the implementation
     105              : 
     106              :          ! tables for screen5
     107              :          real(dp), allocatable :: zs13(:)  ! (num_reactions) ! zs13 = (z1+z2)**(1./3.)
     108              :          real(dp), allocatable :: zhat(:)  ! (num_reactions)
     109              :          real(dp), allocatable :: zhat2(:)  ! (num_reactions)
     110              :          real(dp), allocatable :: lzav(:)  ! (num_reactions)
     111              :          real(dp), allocatable :: aznut(:)  ! (num_reactions)
     112              :          real(dp), allocatable :: zs13inv(:)  ! (num_reactions) ! zs13inv = 1 / zs13
     113              : 
     114              :          ! info for evaluation of the raw reaction rates
     115              :          real(dp), pointer :: rate_table(:,:)  ! (nrate_table,num_reactions)
     116              :          real(dp), pointer :: rattab_f1(:)  ! =(4,nrattab,num_reactions) ! for interpolation
     117              :          real(dp), allocatable  :: ttab(:)  ! (nrate_table)
     118              :          real(dp), allocatable  :: logttab(:)  ! (nrate_table)
     119              : 
     120              :          ! Precomputed powers of Z
     121              :          real(dp), allocatable :: &  ! (num_isos)
     122              :                            z158(:), &  ! screen z**1.58
     123              :                            z52(:)  ! columb z**5/2
     124              : 
     125              :          real(dp), allocatable, dimension(:) :: mion  ! (num_isos) Mass excess in ergs
     126              : 
     127              : 
     128              :          ! info for evaluation of weak rates
     129              :          integer :: num_wk_reactions  ! number of weak reactions in the current net
     130              :          integer, pointer :: &
     131              :             weaklib_ids(:), &  ! (1:num_wk_reactions) = num in 1:num_weak_reactions from rates_def
     132              :                ! get_weak_rate_id from rates_lib
     133              :                ! set for rates in weak_info_list file and weakreactions.tables
     134              :             weak_reaction_index(:), &  ! (1:num_reactions) = num in 1:num_wk_reactions
     135              :             weak_reaction_num(:), &  ! (1:num_wk_reactions) = num in 1:num_reactions
     136              :             reaction_id_for_weak_reactions(:)  ! (1:num_wk_reactions) = rates reaction id
     137              : 
     138              :          ! top level file name for net
     139              :          character (len=256) :: net_filename
     140              : 
     141              :          ! timing
     142              :          logical :: doing_timing
     143              :          ! the following are sums of results from system_clock.
     144              :          ! divide by clock_rate to get seconds.
     145              :          ! must set all of these to 0 before change doing_timing to true.
     146              :          integer(i8) :: clock_net_eval
     147              :          integer(i8) :: clock_net_weak_rates
     148              :          integer(i8) :: clock_net_rate_tables
     149              :          integer(i8) :: clock_net_screen
     150              :          integer(i8) :: clock_net_derivs
     151              :          integer(i8) :: clock_derivs_select
     152              :          integer(i8) :: clock_derivs_setup
     153              :          integer(i8) :: clock_derivs_general
     154              :          integer(i8) :: clock_net_get
     155              : 
     156              :          ! bookkeeping
     157              :          integer :: handle
     158              :          logical :: net_has_been_defined
     159              :          logical :: in_use
     160              : 
     161              :          logical :: use_3a_fl87  ! Whether triple alpha should use Fushiki and Lamb 1987
     162              : 
     163              :          ! Array initialization
     164              :          logical :: fill_arrays_with_nans = .false.
     165              : 
     166              :       end type Net_General_Info
     167              : 
     168              :       integer, parameter :: num_weak_info_arrays_in_Net_Info = 9  ! weaklib results
     169              : 
     170              : 
     171              :       type Net_Info
     172              :          ! this is working storage for the nuclear reaction calculations
     173              : 
     174              :          ! pointers to caller supplied arrays ----------------------------------
     175              : 
     176              :          real(dp), pointer :: reaction_Qs(:)  ! if null, use standard values
     177              :          real(dp), pointer :: reaction_neuQs(:)  ! if null, use standard values
     178              : 
     179              :          real(dp), allocatable :: eps_nuc_categories(:)  ! (num_categories)
     180              :          ! eps_nuc subtotals for each reaction category
     181              : 
     182              :          real(dp), allocatable, dimension(:) :: &
     183              :             rate_screened, rate_screened_dT, rate_screened_dRho  ! (num_rates)
     184              :          ! the units here depend on the number of reactants.
     185              :          ! in all cases, the rate_screened times as many molar fractions as there are reactants
     186              :             ! gives a number with the same units as dy/dt.
     187              :          ! so for a 2-body reaction, there are 2 Y factors, each with units [moles/gram]
     188              :             ! and the rate_screened units for such a reaction are [grams/(mole-sec)],
     189              :             ! which when multiplied by [moles/gram]^2 gives the same units as dydt.
     190              :          ! for a 1-body reaction (e.g., a decay),
     191              :          ! there is only 1 Y factor, so the units are [1/second].
     192              :          ! similarly, a 3 body reaction will have rate_screened
     193              :          ! with units of [gram^2/(mole^2-sec)].
     194              : 
     195              :          real(dp), allocatable, dimension(:) :: &
     196              :             rate_raw, rate_raw_dT, rate_raw_dRho  ! (num_rates)
     197              :          ! raw rates are unscreened (but include density factors)
     198              : 
     199              :          real(dp), allocatable,dimension(:) :: rate_factors  ! (num_rates)
     200              : 
     201              :          ! pointers into work array ----------------------------------
     202              : 
     203              :          ! molar fractions and their rates of change
     204              :          real(dp), allocatable :: y(:)  ! units [moles/gram]     (num_isos)
     205              :          real(dp), allocatable :: d_dydt_dy(:,:)  ! units [1/second] (num_isos, num_isos)
     206              :          real(dp), allocatable :: d_eps_nuc_dy(:)  ! (num_isos)
     207              :          real(dp), allocatable :: x(:)  ! mass fraction
     208              : 
     209              :          ! approx21 arrays
     210              :          real(dp), allocatable,dimension(:,:) :: dfdy
     211              :          real(dp), allocatable,dimension(:) :: dratdumdy1, dratdumdy2, &
     212              :             d_epsnuc_dy, d_epsneu_dy, dydt1, dfdT, dfdRho
     213              : 
     214              :          ! weaklib results
     215              :          real(dp), dimension(:), allocatable :: &
     216              :             lambda, dlambda_dlnT, dlambda_dlnRho, &
     217              :             Q, dQ_dlnT, dQ_dlnRho, &
     218              :             Qneu, dQneu_dlnT, dQneu_dlnRho
     219              : 
     220              :          type (Net_General_Info), pointer  :: g
     221              : 
     222              :          integer :: screening_mode
     223              : 
     224              :          real(dp) :: temp, logT, rho, logRho
     225              : 
     226              :          real(dp) :: abar, zbar, z2bar, ye, eta, d_eta_dlnt, d_eta_dlnrho
     227              : 
     228              :          real(dp) :: fII
     229              : 
     230              :          real(dp) :: eps_nuc, eps_total, eps_neu_total
     231              :          real(dp) :: d_eps_nuc_dT, deps_total_dT, deps_neu_dT
     232              :          real(dp) :: d_eps_nuc_dRho, deps_total_dRho, deps_neu_dRho
     233              :          real(dp) :: weak_rate_factor
     234              : 
     235              :          real(dp),allocatable,dimension(:) :: d_dxdt_dRho, d_dxdt_dT, d_eps_nuc_dx, dxdt
     236              :          real(qp), allocatable,dimension(:,:) :: dydt
     237              :          real(dp), allocatable,dimension(:,:) :: d_dxdt_dx
     238              : 
     239              :          ! These contain the rates after being mutlplied by th various density and composition factors
     240              :          ! but would still need to be mulipled by the zone mass for the absolute value
     241              :          real(dp), allocatable,dimension(:) :: raw_rate, screened_rate, eps_nuc_rate, eps_neu_rate
     242              : 
     243              : 
     244              :          ! Passed in by star
     245              :          integer :: star_id = -1, zone = -1
     246              : 
     247              :       end type Net_Info
     248              : 
     249              : 
     250              :       ! Interface for net hooks
     251              :       interface
     252              :          subroutine other_net_derivs_interface( &
     253              :             n, dydt, eps_nuc_MeV, eta, ye, logtemp, temp, den, abar, zbar, &
     254              :             num_reactions, rate_factors, &
     255              :             symbolic, just_dydt, ierr)
     256              :          import dp, qp, Net_Info
     257              :          implicit none
     258              : 
     259              :          type(Net_Info) :: n
     260              :          real(qp), intent(inout) :: dydt(:,:)
     261              :          real(qp), intent(out) :: eps_nuc_MeV(:)
     262              :          integer, intent(in) :: num_reactions
     263              :          real(dp), intent(in) ::eta, ye, logtemp, temp, den, abar, zbar, &
     264              :             rate_factors(:)
     265              :          logical, intent(in) :: symbolic, just_dydt
     266              :          integer, intent(out) :: ierr
     267              : 
     268              :          end subroutine other_net_derivs_interface
     269              : 
     270              :       end interface
     271              : 
     272              :       ! Other net_derivs handling
     273              :       procedure(other_net_derivs_interface), pointer  :: &
     274              :          net_other_net_derivs => null()
     275              : 
     276              : 
     277              :    ! private to the implementation
     278              :       integer, parameter :: max_net_handles = 10
     279              :       type (Net_General_Info), target :: net_handles(max_net_handles)
     280              : 
     281              :       character (len=256) :: net_dir
     282              : 
     283              :       integer :: weak_rate_id_for_ni56_ec, weak_rate_id_for_co56_ec
     284              : 
     285              : 
     286              :       ! parameters for net burn
     287              : 
     288              :       integer, parameter :: i_burn_caller_id = 1
     289              :       integer, parameter :: i_net_handle = 2
     290              :       integer, parameter :: i_screening_mode = 3
     291              :       integer, parameter :: i_eos_handle = 4
     292              :       integer, parameter :: i_sparse_format = 5
     293              :       integer, parameter :: i_clip = 6
     294              :       integer, parameter :: i_ntimes = 7
     295              : 
     296              :       integer, parameter :: burn_lipar = i_ntimes
     297              : 
     298              :       ! Note: We need  burn_lrpar /= burn_const_P_lrpar so that we can determine whether we are doing a normal burn or
     299              :       ! one at const_P. This is needed in burn_solout in mod_one_zone_burn.
     300              :       integer, parameter :: r_burn_temp = 1
     301              :       integer, parameter :: r_burn_lgT = 2
     302              :       integer, parameter :: r_burn_rho = 3
     303              :       integer, parameter :: r_burn_lgRho = 4
     304              :       integer, parameter :: r_burn_eta = 5
     305              :       integer, parameter :: r_burn_theta = 6
     306              :       integer, parameter :: r_burn_time_net = 7
     307              :       integer, parameter :: r_burn_prev_lgT = 8
     308              :       integer, parameter :: r_burn_prev_lgRho = 9
     309              :       integer, parameter :: r_burn_prev_eta = 10
     310              : 
     311              :       integer, parameter :: burn_lrpar = r_burn_prev_eta
     312              : 
     313              :       integer, parameter :: r_burn_const_P_rho = 1
     314              :       integer, parameter :: r_burn_const_P_pressure = 2
     315              :       integer, parameter :: r_burn_const_P_init_rho = 3
     316              :       integer, parameter :: r_burn_const_P_time_net = 4
     317              :       integer, parameter :: r_burn_const_P_time_eos = 5
     318              :       integer, parameter :: r_burn_const_P_temperature = 6
     319              :       integer, parameter :: r_burn_const_P_init_lnS = 7
     320              :       integer, parameter :: r_burn_const_P_lnS = 8
     321              : 
     322              :       integer, parameter :: burn_const_P_lrpar = r_burn_const_P_lnS
     323              : 
     324              :       logical :: net_test_partials
     325              :       real(dp) :: net_test_partials_val, net_test_partials_dval_dx
     326              :       integer :: net_test_partials_i, net_test_partials_iother
     327              : 
     328              : 
     329              :       contains
     330              : 
     331              : 
     332           19 :       subroutine do_net_def_init
     333              :          use const_def, only: mesa_data_dir
     334              :          use rates_lib, only: get_weak_rate_id
     335              :          integer :: i
     336              : 
     337           19 :          net_test_partials = .false.
     338           19 :          net_dir = trim(mesa_data_dir) // '/net_data'
     339          209 :          do i=1, max_net_handles
     340          190 :             net_handles(i)% handle = i
     341          190 :             net_handles(i)% in_use = .false.
     342          190 :             net_handles(i)% net_has_been_defined = .false.
     343          190 :             net_handles(i)% num_isos = 0
     344          209 :             net_handles(i)% num_reactions = 0
     345              :          end do
     346              : 
     347           19 :          weak_rate_id_for_ni56_ec = get_id('ni56','co56')
     348           19 :          weak_rate_id_for_co56_ec = get_id('co56','fe56')
     349              : 
     350              :          contains
     351              : 
     352           38 :          integer function get_id(iso1, iso2)
     353              :             character(len=*), intent(in) :: iso1, iso2
     354              :             include 'formats'
     355           38 :             get_id = get_weak_rate_id(iso1, iso2)
     356           38 :             if (get_id == 0) then
     357              :                write(*,2) 'failed to find weak reaction for ' // trim(iso1) &
     358            0 :                   // ' to ' // trim(iso2)
     359              :             end if
     360           38 :          end function get_id
     361              : 
     362              :       end subroutine do_net_def_init
     363              : 
     364              : 
     365           19 :       integer function do_alloc_net(ierr)
     366              :          integer, intent(out) :: ierr
     367              :          integer :: i
     368           19 :          ierr = 0
     369           19 :          do_alloc_net = -1
     370           38 : !$omp critical (net_handle)
     371           19 :          do i = 1, max_net_handles
     372           19 :             if (.not. net_handles(i)% in_use) then
     373           19 :                net_handles(i)% in_use = .true.
     374           19 :                do_alloc_net = i
     375           19 :                exit
     376              :             end if
     377              :          end do
     378              : !$omp end critical (net_handle)
     379           19 :          if (do_alloc_net == -1) then
     380            0 :             ierr = -1
     381            0 :             return
     382              :          end if
     383           19 :          if (net_handles(do_alloc_net)% handle /= do_alloc_net) then
     384            0 :             ierr = -1
     385            0 :             return
     386              :          end if
     387           19 :          call init_net_handle_data(do_alloc_net)
     388           19 :       end function do_alloc_net
     389              : 
     390              : 
     391           19 :       subroutine init_net_handle_data(handle)
     392              :          use rates_def
     393              :          integer, intent(in) :: handle
     394              :          type (Net_General_Info), pointer :: g
     395           19 :          g => net_handles(handle)
     396           19 :          call do_free_net(handle)
     397           19 :          g% in_use = .true.
     398           19 :          g% doing_approx21 = .false.
     399           19 :          g% add_co56_to_approx21 = .false.
     400           19 :          g% approx21_ye_iso = -1
     401           19 :          g% doing_timing = .false.
     402           19 :          g% logTcut_lo = rattab_tlo
     403           19 :          g% logTcut_lim = rattab_tlo + 0.1d0
     404           19 :          g% logT_lo_eps_nuc_cancel = 9.4d0
     405           19 :          g% logT_hi_eps_nuc_cancel = 9.5d0
     406           19 :          g% fe56ec_fake_factor = 1d-4
     407           19 :          g% min_T_for_fe56ec_fake_factor = 3d9
     408           19 :          g% cache_suffix = '0'
     409           19 :       end subroutine init_net_handle_data
     410              : 
     411           34 :       subroutine do_free_net(handle)
     412           19 :          use rates_def
     413              :          integer, intent(in) :: handle
     414              :          type (Net_General_Info), pointer :: g
     415           34 :          if (handle >= 1 .and. handle <= max_net_handles) then
     416           34 :             g => net_handles(handle)
     417           34 :             if (associated(g% net_iso)) then
     418           19 :                deallocate(g% net_iso)
     419              :                   nullify(g% net_iso)
     420              :             end if
     421           34 :             if (associated(g% chem_id)) then
     422           19 :                deallocate(g% chem_id)
     423              :                   nullify(g% chem_id)
     424              :             end if
     425           34 :             if (associated(g% net_reaction)) then
     426           19 :                deallocate(g% net_reaction)
     427              :                   nullify(g% net_reaction)
     428              :             end if
     429           34 :             if (allocated(g% reaction_id)) then
     430           19 :                deallocate(g% reaction_id)
     431              :             end if
     432           34 :             if (allocated(g% reaction_kind)) then
     433           19 :                deallocate(g% reaction_kind)
     434              :             end if
     435              : 
     436           34 :             if(allocated(g% mion)) then
     437           19 :                deallocate(g% mion)
     438              :             end if
     439              : 
     440           34 :             if (associated(g% reaction_reaclib_kind)) then
     441           19 :                deallocate(g% reaction_reaclib_kind)
     442              :                   nullify(g% reaction_reaclib_kind)
     443              :             end if
     444           34 :             if (associated(g% reaction_id_for_weak_reactions)) then
     445           19 :                deallocate(g% reaction_id_for_weak_reactions)
     446              :                   nullify(g% reaction_id_for_weak_reactions)
     447              :             end if
     448           34 :             if (associated(g% reverse_id_for_kind_ne_other)) then
     449           19 :                deallocate(g% reverse_id_for_kind_ne_other)
     450              :                   nullify(g% reverse_id_for_kind_ne_other)
     451              :             end if
     452              : 
     453           34 :             if (allocated(g% reaction_max_Z)) then
     454           19 :                deallocate(g% reaction_max_Z)
     455              :             end if
     456           34 :             if (allocated(g% reaction_max_Z_plus_N_for_max_Z)) then
     457           19 :                deallocate(g% reaction_max_Z_plus_N_for_max_Z)
     458              :             end if
     459           34 :             if (allocated(g% zs13)) then
     460           19 :                deallocate(g% zs13)
     461              :             end if
     462           34 :             if (allocated(g% zhat)) then
     463           19 :                deallocate(g% zhat)
     464              :             end if
     465           34 :             if (allocated(g% zhat2)) then
     466           19 :                deallocate(g% zhat2)
     467              :             end if
     468           34 :             if (allocated(g% lzav)) then
     469           19 :                deallocate(g% lzav)
     470              :             end if
     471           34 :             if (allocated(g% aznut)) then
     472           19 :                deallocate(g% aznut)
     473              :             end if
     474           34 :             if (allocated(g% zs13inv)) then
     475           19 :                deallocate(g% zs13inv)
     476              :             end if
     477           34 :             if (allocated(g% z158)) then
     478           19 :                deallocate(g% z158)
     479              :             end if
     480           34 :             if (allocated(g% z52)) then
     481           19 :                deallocate(g% z52)
     482              :             end if
     483           34 :             if (associated(g% rate_table)) then
     484           19 :                deallocate(g% rate_table)
     485              :                   nullify(g% rate_table)
     486              :             end if
     487           34 :             if (allocated(g% ttab)) then
     488           19 :                deallocate(g% ttab)
     489              :             end if
     490           34 :             if (allocated(g% logttab)) then
     491           19 :                deallocate(g% logttab)
     492              :             end if
     493           34 :             if (associated(g% rattab_f1)) then
     494           19 :                deallocate(g% rattab_f1)
     495              :                   nullify(g% rattab_f1)
     496              :             end if
     497           34 :             if (associated(g% weaklib_ids)) then
     498           19 :                deallocate(g% weaklib_ids)
     499              :                   nullify(g% weaklib_ids)
     500              :             end if
     501           34 :             if (associated(g% weak_reaction_num)) then
     502           19 :                deallocate(g% weak_reaction_num)
     503              :                   nullify(g% weak_reaction_num)
     504              :             end if
     505           34 :             if (associated(g% weak_reaction_index)) then
     506           19 :                deallocate(g% weak_reaction_index)
     507              :                   nullify(g% weak_reaction_index)
     508              :             end if
     509           34 :             g% in_use = .false.
     510           34 :             g% net_has_been_defined = .false.
     511           34 :             g% num_isos = 0
     512           34 :             g% num_reactions = 0
     513           34 :             g% num_wk_reactions = 0
     514              :          end if
     515              : 
     516              : 
     517           34 :       end subroutine do_free_net
     518              : 
     519              : 
     520       167790 :       subroutine get_net_ptr(handle, g, ierr)
     521              :          integer, intent(in) :: handle
     522              :          type (Net_General_Info), pointer :: g
     523              :          integer, intent(out):: ierr
     524       167788 :          if (handle < 1 .or. handle > max_net_handles) then
     525            0 :             ierr = -1
     526            0 :             return
     527              :          end if
     528       167790 :          g => net_handles(handle)
     529       167790 :          ierr = 0
     530           34 :       end subroutine get_net_ptr
     531              : 
     532              : 
     533            0 :       integer function get_net_timing_total(handle, ierr)
     534              :          integer, intent(in) :: handle
     535              :          type (Net_General_Info), pointer :: g
     536              :          integer, intent(inout) :: ierr
     537              :          ierr = 0
     538            0 :          call get_net_ptr(handle, g, ierr)
     539            0 :          if (ierr /= 0) then
     540            0 :             write(*,*) 'invalid handle for net_set_logTcut'
     541            0 :             return
     542              :          end if
     543            0 :          get_net_timing_total = 0
     544            0 :          if (.not. g% doing_timing) return
     545              :          get_net_timing_total = &
     546              :             g% clock_net_eval + &
     547              :             g% clock_net_weak_rates + &
     548              :             g% clock_net_rate_tables + &
     549              :             g% clock_net_screen + &
     550            0 :             g% clock_net_derivs
     551            0 :       end function get_net_timing_total
     552              : 
     553              : 
     554            0 :       subroutine zero_net_timing(handle,ierr)
     555              :          integer, intent(in) :: handle
     556              :          type (Net_General_Info), pointer :: g
     557              :          integer, intent(inout) :: ierr
     558              :          ierr = 0
     559            0 :          call get_net_ptr(handle, g, ierr)
     560            0 :          if (ierr /= 0) then
     561            0 :             write(*,*) 'invalid handle for net_set_logTcut'
     562            0 :             return
     563              :          end if
     564              : 
     565            0 :          g% clock_net_eval = 0
     566            0 :          g% clock_net_weak_rates = 0
     567            0 :          g% clock_net_rate_tables = 0
     568            0 :          g% clock_net_screen = 0
     569            0 :          g% clock_net_derivs = 0
     570              : 
     571            0 :          g% clock_derivs_setup = 0
     572            0 :          g% clock_derivs_select = 0
     573            0 :          g% clock_derivs_general = 0
     574            0 :          g% clock_net_get = 0
     575              :       end subroutine zero_net_timing
     576              : 
     577            2 :       subroutine do_net_set_fe56ec_fake_factor( &
     578              :             handle, fe56ec_fake_factor, min_T_for_fe56ec_fake_factor, ierr)
     579              :          integer, intent(in) :: handle
     580              :          real(dp), intent(in) :: fe56ec_fake_factor, min_T_for_fe56ec_fake_factor
     581              :          integer, intent(out) :: ierr
     582              :          type (Net_General_Info), pointer :: g
     583            1 :          call get_net_ptr(handle, g, ierr)
     584            1 :          if (ierr /= 0) then
     585            0 :             write(*,*) 'invalid handle for do_net_set_fe56ec_fake_factor'
     586            0 :             return
     587              :          end if
     588            1 :          g% fe56ec_fake_factor = fe56ec_fake_factor
     589            1 :          g% min_T_for_fe56ec_fake_factor = min_T_for_fe56ec_fake_factor
     590              :       end subroutine do_net_set_fe56ec_fake_factor
     591              : 
     592              : 
     593            2 :       subroutine do_net_set_logTcut(handle, logTcut_lo, logTcut_lim, ierr)
     594              :          integer, intent(in) :: handle
     595              :          real(dp), intent(in) :: logTcut_lo
     596              :          real(dp), intent(in) :: logTcut_lim
     597              :          integer, intent(out) :: ierr
     598              :          type (Net_General_Info), pointer :: g
     599            1 :          call get_net_ptr(handle, g, ierr)
     600            1 :          if (ierr /= 0) then
     601            0 :             write(*,*) 'invalid handle for net_set_logTcut'
     602            0 :             return
     603              :          end if
     604            1 :          g% logTcut_lo = logTcut_lo
     605            1 :          g% logTcut_lim = logTcut_lim
     606              :       end subroutine do_net_set_logTcut
     607              : 
     608              : 
     609            0 :       subroutine do_net_set_eps_nuc_cancel( &
     610              :             handle, logT_lo_eps_nuc_cancel, logT_hi_eps_nuc_cancel, ierr)
     611              :          integer, intent(in) :: handle
     612              :          real(dp), intent(in) :: logT_lo_eps_nuc_cancel
     613              :          real(dp), intent(in) :: logT_hi_eps_nuc_cancel
     614              :          integer, intent(out) :: ierr
     615              :          type (Net_General_Info), pointer :: g
     616            0 :          call get_net_ptr(handle, g, ierr)
     617            0 :          if (ierr /= 0) then
     618            0 :             write(*,*) 'invalid handle for net_set_eps_nuc_cancel'
     619            0 :             return
     620              :          end if
     621            0 :          g% logT_lo_eps_nuc_cancel = logT_lo_eps_nuc_cancel
     622            0 :          g% logT_hi_eps_nuc_cancel = logT_hi_eps_nuc_cancel
     623              :       end subroutine do_net_set_eps_nuc_cancel
     624              : 
     625            0 :       end module net_def
        

Generated by: LCOV version 2.0-1