Skip to content

Commit

Permalink
Merge pull request #7 from mabruzzo/gen2024-dev
Browse files Browse the repository at this point in the history
Convert `logical` to `MASK_TYPE` (aka `integer*4`)
  • Loading branch information
brittonsmith authored Dec 18, 2024
2 parents 370b7bd + 234a676 commit 185635a
Show file tree
Hide file tree
Showing 13 changed files with 283 additions and 242 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
> [!IMPORTANT]
> This is a special version of the [brittonsmith:gen2024](https://github.com/brittonsmith/grackle/tree/gen2024) branch (i.e. the branch of changes proposed for merging in the grackle-project/grackle#177 Pull Request).
>
> This branch includes additional changes that are needed to simplify the transcription process to C++. There are pending PRs to merge all of these changes into the gen2024 branch ([see this list of PRs](https://github.com/brittonsmith/grackle/pulls/mabruzzo))

# Grackle

[![Users' Mailing List](https://img.shields.io/badge/Users-List-lightgrey.svg)](https://groups.google.com/forum/#!forum/grackle-cooling-users)
Expand Down
11 changes: 7 additions & 4 deletions src/clib/calc_grain_size_increment_1d.F
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ subroutine calc_grain_size_increment_1d(

! in
integer in, jn, kn, is, ie, j, k
logical itmask(in)
MASK_TYPE itmask(in)
integer immulti, imabund, idspecies, igrgr
real*8 dom
R_PREC d(in,jn,kn)
Expand Down Expand Up @@ -369,7 +369,7 @@ subroutine calc_grain_size_increment_1d(
endif

do i = is+1, ie+1
if ( itmask(i) ) then
if ( itmask(i) .ne. MASK_FALSE ) then

if (idspecies .gt. 0) then
sgtot (i) = sgMgSiO3 (i)
Expand Down Expand Up @@ -434,9 +434,12 @@ subroutine calc_grain_size_increment_species_1d(


implicit NONE

#include "grackle_fortran_types.def"

! input
integer in, jn, kn, is, ie, j, k
logical itmask(in)
MASK_TYPE itmask(in)
integer igrgr
integer iSN, nSN, SN0_N
real*8 dom
Expand Down Expand Up @@ -477,7 +480,7 @@ subroutine calc_grain_size_increment_species_1d(
! enddo

do i = is+1, ie+1
if ( itmask(i) ) then
if ( itmask(i) .ne. MASK_FALSE ) then
!!!!!!!!!!!!!
!!!! if( dsp(i,j,k) .gt. 1.d-15*d(i,j,k) ) then
!!!!!!!!!!!!!
Expand Down
44 changes: 22 additions & 22 deletions src/clib/calc_tdust_1d_g.F
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ subroutine calc_tdust_1d_g(

! Iteration mask

logical itmask(in)
MASK_TYPE itmask(in)

! Parameters

Expand Down Expand Up @@ -89,7 +89,7 @@ subroutine calc_tdust_1d_g(
& slope(in), tdplus(in), tdustnow(in), tdustold(in),
& pert(in),
& bi_t_mid(in), bi_t_high(in)
logical nm_itmask(in), bi_itmask(in)
MASK_TYPE nm_itmask(in), bi_itmask(in)

!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////
!=======================================================================
Expand All @@ -105,7 +105,7 @@ subroutine calc_tdust_1d_g(
Td_N(1) = gr_N(2)
Td_Size = gr_N(2)
do i = is+1, ie+1
if ( itmask(i) ) then
if ( itmask(i) .ne. MASK_FALSE ) then
logalsp(:,i) = log10(alsp(:,i))
endif
enddo
Expand All @@ -119,25 +119,25 @@ subroutine calc_tdust_1d_g(
! Set local iteration mask and initial guess

do i = is+1, ie+1
if ( itmask(i) ) then
if ( itmask(i) .ne. MASK_FALSE ) then
gamma_isrf(i) = isrf(i) * gamma_isrfa(i)
endif
enddo

do i = is+1, ie+1
nm_itmask(i) = itmask(i)
bi_itmask(i) = itmask(i)
if ( nm_itmask(i) ) then
if ( nm_itmask(i) .ne. MASK_FALSE ) then

if (trad .ge. tgas(i)) then
tdustnow(i) = trad
nm_itmask(i) = .false.
bi_itmask(i) = .false.
nm_itmask(i) = MASK_FALSE
bi_itmask(i) = MASK_FALSE
c_done = c_done + 1
nm_done = nm_done + 1
else if (tgas(i) .gt. t_subl) then
! Use bisection if T_gas > grain sublimation temperature.
nm_itmask(i) = .false.
nm_itmask(i) = MASK_FALSE
nm_done = nm_done + 1
else
tdustnow(i) = max(trad,
Expand All @@ -158,7 +158,7 @@ subroutine calc_tdust_1d_g(
! Loop over slice
do i = is+1, ie+1
if ( nm_itmask(i) ) then
if ( nm_itmask(i) .ne. MASK_FALSE ) then
tdplus(i) = max(1.e-3_DKIND, ((1._DKIND + pert(i))
& * tdustnow(i)))
Expand All @@ -185,7 +185,7 @@ subroutine calc_tdust_1d_g(
& gamma_isrf, nh, nm_itmask, solplus, in, is, ie)
do i = is+1, ie+1
if ( nm_itmask(i) ) then
if ( nm_itmask(i) .ne. MASK_FALSE ) then
! Use Newton's method to solve for Tdust

Expand All @@ -203,13 +203,13 @@ subroutine calc_tdust_1d_g(

! If negative solution calculated, give up and wait for bisection step.
if (tdustnow(i) .lt. trad) then
nm_itmask(i) = .false.
nm_itmask(i) = MASK_FALSE
nm_done = nm_done + 1
! Check for convergence of solution
else if (abs(sol(i) / solplus(i)) .lt. tol) then
nm_itmask(i) = .false.
nm_itmask(i) = MASK_FALSE
c_done = c_done + 1
bi_itmask(i) = .false.
bi_itmask(i) = MASK_FALSE
nm_done = nm_done + 1
endif

Expand All @@ -234,7 +234,7 @@ subroutine calc_tdust_1d_g(
! If iteration count exceeded, try once more with bisection
if (c_done .lt. c_total) then
do i = is+1, ie+1
if ( bi_itmask(i) ) then
if ( bi_itmask(i) .ne. MASK_FALSE ) then
tdustnow(i) = trad
! bi_t_high(i) = tgas(i)
bi_t_high(i) = 3e3_DKIND
Expand All @@ -244,7 +244,7 @@ subroutine calc_tdust_1d_g(
do iter = 1, bi_itmax
do i = is+1, ie+1
if ( bi_itmask(i) ) then
if ( bi_itmask(i) .ne. MASK_FALSE ) then
bi_t_mid(i) = 0.5_DKIND * (tdustnow(i) + bi_t_high(i))
if (iter .eq. 1) then
Expand All @@ -262,7 +262,7 @@ subroutine calc_tdust_1d_g(
& gamma_isrf, nh, bi_itmask, sol, in, is, ie)
do i = is+1, ie+1
if ( bi_itmask(i) ) then
if ( bi_itmask(i) .ne. MASK_FALSE ) then
if (sol(i) .gt. 0._DKIND) then
tdustnow(i) = bi_t_mid(i)
Expand All @@ -272,7 +272,7 @@ subroutine calc_tdust_1d_g(
if ((abs(bi_t_high(i) - tdustnow(i)) / tdustnow(i))
& .le. bi_tol) then
bi_itmask(i) = .false.
bi_itmask(i) = MASK_FALSE
c_done = c_done + 1
endif
Expand Down Expand Up @@ -308,7 +308,7 @@ subroutine calc_tdust_1d_g(
! Copy values back to thrown slice
do i = is+1, ie+1
if ( itmask(i) ) then
if ( itmask(i) .ne. MASK_FALSE ) then
! Check for bad solutions
if (tdustnow(i) .lt. 0._DKIND) then
Expand Down Expand Up @@ -379,7 +379,7 @@ subroutine calc_kappa_gr_g(
! Iteration mask
logical itmask(in)
MASK_TYPE itmask(in)
! Parameters
Expand Down Expand Up @@ -407,7 +407,7 @@ subroutine calc_kappa_gr_g(
!=======================================================================
do i = is+1, ie+1
if ( itmask(i) ) then
if ( itmask(i) .ne. MASK_FALSE ) then
if(idspecies.eq.0) then
Expand Down Expand Up @@ -492,7 +492,7 @@ subroutine calc_gr_balance_g(
! Iteration mask
logical itmask(in)
MASK_TYPE itmask(in)
! Parameters
Expand All @@ -510,7 +510,7 @@ subroutine calc_gr_balance_g(
!=======================================================================
do i = is+1, ie+1
if ( itmask(i) ) then
if ( itmask(i) .ne. MASK_FALSE ) then
sol(i) = gamma_isrf(i) + radf * kgr(i) *
& (trad4 - tdust(i)**4) +
Expand Down
10 changes: 5 additions & 5 deletions src/clib/calc_tdust_3d_g.F
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ subroutine calc_tdust_3d_g(
& vibh(in)
! Iteration mask for multi_cool

logical itmask(in)
MASK_TYPE itmask(in)

!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////
!=======================================================================
Expand Down Expand Up @@ -377,7 +377,7 @@ subroutine calc_tdust_3d_g(

! Set itmask to all true

itmask(i) = .true.
itmask(i) = MASK_TRUE

enddo

Expand All @@ -386,7 +386,7 @@ subroutine calc_tdust_3d_g(
if (imetal .eq. 1) then
do i = is+1, ie + 1
if (metal(i,j,k) .lt. 1.e-9_DKIND * d(i,j,k)) then
itmask(i) = .false.
itmask(i) = MASK_FALSE
endif
enddo
endif
Expand Down Expand Up @@ -430,7 +430,7 @@ subroutine calc_tdust_3d_g(
endif

do i = is+1, ie+1
if(itmask(i)) then
if(itmask(i) .ne. MASK_FALSE) then
! Calculate metallicity

if (imetal .eq. 1) then
Expand Down Expand Up @@ -720,7 +720,7 @@ subroutine calc_tdust_3d_g(
! Copy slice values back to grid

do i = is+1, ie+1
if (itmask(i)) then
if (itmask(i) .ne. MASK_FALSE) then
if (itdmulti .eq. 0) then
dust_temp(i,j,k) = tdust(i)
else
Expand Down
6 changes: 3 additions & 3 deletions src/clib/calc_temp1d_cloudy_g.F
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ subroutine calc_temp1d_cloudy_g(d, metal, e, rhoH,

! Iteration mask

logical itmask(in)
MASK_TYPE itmask(in)

! Parameters

Expand Down Expand Up @@ -147,14 +147,14 @@ subroutine calc_temp1d_cloudy_g(d, metal, e, rhoH,
endif

do i=is+1, ie+1
if ( itmask(i) ) then
if ( itmask(i) .ne. MASK_FALSE ) then
! Calculate proper log(n_H)
log_n_h(i) = log10(rhoH(i) * dom)
endif
enddo

do i=is+1, ie+1
if ( itmask(i) ) then
if ( itmask(i) .ne. MASK_FALSE ) then
munew = 1._DKIND
do ti = 1, ti_max
muold = munew
Expand Down
4 changes: 2 additions & 2 deletions src/clib/calc_temp_cloudy_g.F
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ subroutine calc_temp_cloudy_g(d, e, metal, temperature,

! Iteration mask

logical itmask(in)
MASK_TYPE itmask(in)
!
!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////
!=======================================================================
Expand Down Expand Up @@ -144,7 +144,7 @@ subroutine calc_temp_cloudy_g(d, e, metal, temperature,
! Initialize iteration mask to true for all cells.

do i = is+1, ie+1
itmask(i) = .true.
itmask(i) = MASK_TRUE

rhoH(i) = fh * d(i,j,k)
enddo
Expand Down
4 changes: 2 additions & 2 deletions src/clib/cool1d_cloudy_g.F
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ subroutine cool1d_cloudy_g(d, rhoH, metallicity,

! Iteration mask

logical itmask(in)
MASK_TYPE itmask(in)

! Parameters

Expand Down Expand Up @@ -115,7 +115,7 @@ subroutine cool1d_cloudy_g(d, rhoH, metallicity,
endif

do i=is+1, ie+1
if ( itmask(i) ) then
if (itmask(i) .ne. MASK_FALSE) then

log10tem(i) = logtem(i) * inv_log10

Expand Down
4 changes: 2 additions & 2 deletions src/clib/cool1d_cloudy_old_tables_g.F
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ subroutine cool1D_cloudy_old_tables_g(d, de, rhoH, metallicity,

! Iteration mask

logical itmask(in)
MASK_TYPE itmask(in)

! Parameters

Expand Down Expand Up @@ -124,7 +124,7 @@ subroutine cool1D_cloudy_old_tables_g(d, de, rhoH, metallicity,
endif

do i=is+1, ie+1
if ( itmask(i) ) then
if ( itmask(i) .ne. MASK_FALSE ) then

log10tem(i) = logtem(i) * inv_log10

Expand Down
Loading

0 comments on commit 185635a

Please sign in to comment.