Skip to content

Commit

Permalink
Making FFN and NNU rates global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jaharris87 committed Jul 1, 2024
1 parent 65c93ad commit 96626e7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 28 deletions.
66 changes: 41 additions & 25 deletions source/xnet_data.f90
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ Subroutine read_nuclear_data(data_dir,data_desc)
mm = aa / avn! + mex(:)*epmev/(clt*clt)
!mm(:) = zz(:)*(m_p+m_e) + nn(:)*m_n - be(:)*epmev/(clt*clt)

Allocate (gg(0:ny,nzevolve))
If ( iheat > 0 ) Allocate (dlngdt9(0:ny,nzevolve))
Allocate (gg(0:ny,nzevolve),dlngdt9(0:ny,nzevolve))

Return
End Subroutine read_nuclear_data
Expand Down Expand Up @@ -530,9 +529,9 @@ Subroutine read_reaction_data(data_dir)
Use nuclear_data, Only: ny, izmax, nname, zz
Use xnet_constants, Only: five3rd
Use xnet_controls, Only: iheat, iscrn, lun_stderr, nzevolve, iweak0
Use xnet_ffn, Only: ffnsum, ffnenu, ngrid, read_ffn_data
Use xnet_ffn, Only: ffn_ec, ffn_beta, ffn_qval, has_logft
Use xnet_nnu, Only: read_nnu_data, nnu_match, ntnu, nnuspec, sigmanu
Use xnet_ffn, Only: read_ffn_data, ffnsum, ffnenu, ffn_ec, ffn_beta, ffn_qval, has_logft, &
& ngrid, rffn, dlnrffndt9
Use xnet_nnu, Only: read_nnu_data, nnu_match, ntnu, nnuspec, sigmanu, rnnu
Use xnet_parallel, Only: parallel_bcast, parallel_IOProcessor
Use xnet_types, Only: dp
Use xnet_util, Only: xnet_terminate
Expand Down Expand Up @@ -577,27 +576,40 @@ Subroutine read_reaction_data(data_dir)
Else
Allocate (ffnsum(nffn,ngrid),ffnenu(nffn,ngrid))
Allocate (has_logft(nffn))
If (iweak0 == 2) Then
!Additional data for logft rates
Allocate (ffn_ec(nffn,ngrid),ffn_beta(nffn,ngrid))
Allocate (ffn_qval(nffn))
Endif
ffnsum = 0.0
ffnenu = 0.0
has_logft = 0
If ( abs(iweak0) == 2 ) Then
! Additional data for logft rates
Allocate (ffn_ec(nffn,ngrid),ffn_beta(nffn,ngrid))
Allocate (ffn_qval(nffn))
ffn_ec = 0.0
ffn_beta = 0.0
ffn_qval = 0.0
EndIf
EndIf
Call parallel_bcast(ffnsum)
Call parallel_bcast(ffnenu)
Call parallel_bcast(has_logft)
If (iweak0 == 2) Then
!Additional data for logft rates
If ( abs(iweak0) == 2 ) Then
! Additional data for logft rates
Call parallel_bcast(ffn_ec)
Call parallel_bcast(ffn_beta)
Call parallel_bcast(ffn_qval)
Endif
EndIf
Else
Allocate(ffnsum(1,ngrid),ffnenu(1,ngrid))
!Additional arrays for logft rates
If (iweak0 == 2) Then
Allocate (has_logft(1))
ffnsum = 0.0
ffnenu = 0.0
has_logft = 0
! Additional arrays for logft rates
If ( abs(iweak0) == 2 ) Then
Allocate (ffn_ec(1,ngrid),ffn_beta(1,ngrid))
Allocate (ffn_qval(1))
ffn_ec = 0.0
ffn_beta = 0.0
ffn_qval = 0.0
Endif
Endif

Expand All @@ -607,10 +619,12 @@ Subroutine read_reaction_data(data_dir)
Call read_nnu_data(nnnu,data_dir)
Else
Allocate (sigmanu(nnnu,ntnu))
sigmanu = 0.0
EndIf
Call parallel_bcast(sigmanu)
Else
Allocate (sigmanu(1,ntnu))
sigmanu = 0.0
EndIf

! Read in reaction arrays for 1 reactant reactions
Expand Down Expand Up @@ -762,20 +776,22 @@ Subroutine read_reaction_data(data_dir)
EndDo
EndDo

Allocate (csect1(nr1,nzevolve))
Allocate (csect2(nr2,nzevolve))
Allocate (csect3(nr3,nzevolve))
Allocate (csect4(nr4,nzevolve))
Allocate (b1(nan(1),nzevolve))
Allocate (b2(nan(2),nzevolve))
Allocate (b3(nan(3),nzevolve))
Allocate (b4(nan(4),nzevolve))
If ( iheat > 0 ) Then
Allocate (dcsect1dt9(nr1,nzevolve))
Allocate (dcsect2dt9(nr2,nzevolve))
Allocate (dcsect3dt9(nr3,nzevolve))
Allocate (dcsect4dt9(nr4,nzevolve))
EndIf
Allocate (csect1(nr1,nzevolve))
Allocate (csect2(nr2,nzevolve))
Allocate (csect3(nr3,nzevolve))
Allocate (csect4(nr4,nzevolve))
Allocate (dcsect1dt9(nr1,nzevolve))
Allocate (dcsect2dt9(nr2,nzevolve))
Allocate (dcsect3dt9(nr3,nzevolve))
Allocate (dcsect4dt9(nr4,nzevolve))

Allocate (rffn(max(1,nffn),nzevolve))
Allocate (dlnrffndt9(max(1,nffn),nzevolve))
Allocate (rnnu(max(1,nnnu),nnuspec,nzevolve))

Return
End Subroutine read_reaction_data
Expand Down
3 changes: 3 additions & 0 deletions source/xnet_ffn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Module xnet_ffn
Real(dp), Allocatable :: ffn_qval(:)
Integer, Allocatable :: has_logft(:)

Real(dp), Allocatable :: rffn(:,:) ! FFN reaction rates
Real(dp), Allocatable :: dlnrffndt9(:,:) ! log FFN reaction rates

Contains

Subroutine read_ffn_data(nffn,data_dir)
Expand Down
13 changes: 10 additions & 3 deletions source/xnet_nnu.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Module xnet_nnu
Integer, Allocatable :: irl(:) ! Reaclib Chapter 1 index of reaction
Integer, Allocatable :: nuspec(:) ! The neutrino species involved in the reaction

Real(dp), Dimension(:,:), Allocatable :: sigmanu ! dim(nnnu,ntnu)
Real(dp), Allocatable :: sigmanu(:,:) ! dim(nnnu,ntnu)
Real(dp), Allocatable :: rnnu(:,:,:)

Contains

Expand All @@ -48,6 +49,8 @@ Subroutine read_nnu_data(nnnu,data_dir)
Integer :: i, j, lun_nnu

Allocate (sigmanu(nnnu,ntnu))
sigmanu = 0.0

Open(newunit=lun_nnu, file=trim(data_dir)//"/netneutr", status='old', action='read')
Do i = 1, nnnu
Read(lun_nnu,*)
Expand Down Expand Up @@ -123,7 +126,7 @@ Subroutine nnu_rate(nnnu,time,rate,mask_in)
Real(dp), Intent(in) :: time(nzevolve)

! Output variables
Real(dp), Intent(out), Dimension(nnnu,nnuspec,zb_lo:zb_hi) :: rate
Real(dp), Intent(out) :: rate(nnnu,nnuspec,zb_lo:zb_hi)

! Optional variables
Logical, Optional, Target, Intent(in) :: mask_in(zb_lo:zb_hi)
Expand All @@ -148,7 +151,11 @@ Subroutine nnu_rate(nnnu,time,rate,mask_in)
If ( ineutrino == 0 ) Then
Do izb = zb_lo, zb_hi
If ( mask(izb) ) Then
rate(:,:,izb) = 0.0
Do j = 1, nnuspec
Do k = 1, nnnu
rate(k,j,izb) = 0.0
EndDo
EndDo
EndIf
EndDo
Else
Expand Down

0 comments on commit 96626e7

Please sign in to comment.