Skip to content

Commit

Permalink
Merge pull request #607 from danieljprice/fix_readwrite_mesa
Browse files Browse the repository at this point in the history
Small fix to readwrite mesa
  • Loading branch information
danieljprice authored Dec 10, 2024
2 parents e1c297a + ae88261 commit 917950e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/setup/readwrite_mesa.f90
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ subroutine read_mesa(filepath,rho,r,pres,m,ene,temp,X_in,Z_in,Xfrac,Yfrac,Mstar,
if (nlabels /= ncols) print*,' WARNING: different number of labels compared to columns'

allocate(m(lines))
m = -1d0
m = -1.
allocate(r,pres,rho,ene,temp,Xfrac,Yfrac,source=m)

over_directions: do idir=1,2 ! try backwards, then forwards
Expand Down Expand Up @@ -143,11 +143,11 @@ subroutine read_mesa(filepath,rho,r,pres,m,ene,temp,X_in,Z_in,Xfrac,Yfrac,Mstar,
if (ismesafile .or. maxval(m) < 1.e-10*solarm) m = m * solarm ! If reading MESA profile, 'mass' is in units of Msun
case('rho','density')
rho = dat(1:lines,i)
case('logrho','logRho')
case('logrho')
rho = 10**(dat(1:lines,i))
case('energy','e_int','e_internal')
ene = dat(1:lines,i)
case('logE')
case('loge')
ene = 10**dat(1:lines,i)
case('radius_cm')
r = dat(1:lines,i)
Expand All @@ -156,23 +156,23 @@ subroutine read_mesa(filepath,rho,r,pres,m,ene,temp,X_in,Z_in,Xfrac,Yfrac,Mstar,
case('radius','r')
r = dat(1:lines,i)
if (ismesafile .or. maxval(r) < 1e-10*solarr) r = r * solarr
case('logr','logR')
case('logr')
r = (10**dat(1:lines,i)) * solarr
case('logR_cm')
case('logr_cm')
r = 10**dat(1:lines,i)
case('pressure','p')
pres = dat(1:lines,i)
case('logP')
case('logp')
pres = 10**dat(1:lines,i)
case('temperature','t')
temp = dat(1:lines,i)
case('logT')
case('logt')
temp = 10**dat(1:lines,i)
case('x_mass_fraction_h','x_mass_fraction_H','x','xfrac','h1')
case('x_mass_fraction_h','x','xfrac','h1')
Xfrac = dat(1:lines,i)
case('log_x')
Xfrac = 10**dat(1:lines,i)
case('y_mass_fraction_he','y_mass_fraction_He','y','yfrac','he4')
case('y_mass_fraction_he','y','yfrac','he4')
Yfrac = dat(1:lines,i)
case('log_y')
Yfrac = 10**dat(1:lines,i)
Expand All @@ -194,7 +194,7 @@ subroutine read_mesa(filepath,rho,r,pres,m,ene,temp,X_in,Z_in,Xfrac,Yfrac,Mstar,
enddo over_directions
close(iu)

if(min(minval(m),minval(r),minval(pres),minval(rho),minval(ene))<0d0)ierr = 1
if(min(minval(pres),minval(rho))<0d0)ierr = 1

if (ierr /= 0) then
print "(a,/)",' ERROR reading MESA file [missing required columns]'
Expand Down

0 comments on commit 917950e

Please sign in to comment.