Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fix to readwrite mesa #607

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading