Skip to content

Commit

Permalink
(grtde) reduce verboseness of log when running phantomsetup; add init…
Browse files Browse the repository at this point in the history
…ial separation to the .setup file for grtde with parabolic orbits (#576)
  • Loading branch information
danieljprice committed Jan 21, 2025
1 parent 2157470 commit b0d28fc
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 64 deletions.
12 changes: 6 additions & 6 deletions src/main/eos.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ end subroutine write_headeropts_eos
!-----------------------------------------------------------------------
subroutine read_headeropts_eos(ieos,hdr,ierr)
use dump_utils, only:dump_h, extract
use io, only:iprint,id,master
use io, only:iprint,id,master,iverbose
use dim, only:use_krome,maxvxyzu
integer, intent(in) :: ieos
type(dump_h), intent(in) :: hdr
Expand All @@ -1512,12 +1512,12 @@ subroutine read_headeropts_eos(ieos,hdr,ierr)
if (id==master) then
if (maxvxyzu >= 4) then
if (use_krome) then
write(iprint,*) 'KROME eos: initial gamma = 1.666667'
if (iverbose >= 0) write(iprint,*) 'KROME eos: initial gamma = 1.666667'
else
write(iprint,*) 'adiabatic eos: gamma = ',gamma
if (iverbose >= 0) write(iprint,*) 'adiabatic eos: gamma = ',gamma
endif
else
write(iprint,*) 'setting isothermal sound speed^2 (polyk) = ',polyk,' gamma = ',gamma
if (iverbose >= 0) write(iprint,*) 'setting isothermal sound speed^2 (polyk) = ',polyk,' gamma = ',gamma
if (polyk <= tiny(polyk)) write(iprint,*) 'WARNING! sound speed zero in dump!, polyk = ',polyk
endif
endif
Expand All @@ -1536,7 +1536,7 @@ subroutine read_headeropts_eos(ieos,hdr,ierr)
if (id==master) write(iprint,*) 'ERROR: qfacdisc <= 0'
ierr = 2
else
if (id==master) write(iprint,*) 'qfacdisc = ',qfacdisc
if (id==master .and. iverbose >= 0) write(iprint,*) 'qfacdisc = ',qfacdisc
endif
endif

Expand All @@ -1549,7 +1549,7 @@ subroutine read_headeropts_eos(ieos,hdr,ierr)
if (id==master) write(iprint,*) 'ERROR: qfacdisc2 == 0'
ierr = 2
else
if (id==master) write(iprint,*) 'qfacdisc2 = ',qfacdisc2
if (id==master .and. iverbose >= 0) write(iprint,*) 'qfacdisc2 = ',qfacdisc2
endif
endif

Expand Down
12 changes: 5 additions & 7 deletions src/main/readwrite_dumps_common.f90
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ subroutine unfill_header(hdr,phantomdump,got_tags,nparttot, &
nblocks,npart,npartoftype, &
tfile,hfactfile,alphafile,iprint,id,nprocs,ierr)
use dim, only:maxdustlarge,use_dust
use io, only:master ! check this
use io, only:master,iverbose ! check this
use eos, only:isink
use part, only:maxtypes,igas,idust,ndustsmall,ndustlarge,ndusttypes,&
npartoftypetot
Expand Down Expand Up @@ -203,7 +203,7 @@ subroutine unfill_header(hdr,phantomdump,got_tags,nparttot, &
if (nblocks==1) then
npart = int(nparttoti)
nparttot = npart
if (id==master) write (iprint,*) 'npart = ',npart
if (id==master .and. iverbose >= 0) write (iprint,*) 'npart = ',npart
endif
if (got_tags) then
call extract('ntypes',ntypesinfile8,hdr,ierr1)
Expand All @@ -218,7 +218,7 @@ subroutine unfill_header(hdr,phantomdump,got_tags,nparttot, &
if (nblocks > 1) then
call extract('npartoftype',npartoftype(1:ntypesinfile),hdr,ierr1)
endif
if (id==master) write(*,*) 'npart(total) = ',nparttot
if (id==master .and. iverbose >= 0) write(*,*) 'npart(total) = ',nparttot
!
!--number of dust species
!
Expand Down Expand Up @@ -250,7 +250,7 @@ subroutine unfill_header(hdr,phantomdump,got_tags,nparttot, &
tfile,hfactfile,alphafile,iprint,ierr)
if (ierr /= 0) return

if (id==master) write(iprint,*) 'time = ',tfile
if (id==master .and. iverbose >= 0) write(iprint,*) 'time = ',tfile

end subroutine unfill_header

Expand Down Expand Up @@ -363,6 +363,7 @@ subroutine fill_header(sphNGdump,t,nparttot,npartoftypetot,nblocks,nptmass,hdr,i
call add_to_rheader(rho_bkg_ini,'rho_bkg_ini',hdr,ierr)
endif
call add_to_rheader(get_conserv,'get_conserv',hdr,ierr)
call add_to_rheader(mtot_in,'mtot_in',hdr,ierr)
call add_to_rheader(etot_in,'etot_in',hdr,ierr)
call add_to_rheader(angtot_in,'angtot_in',hdr,ierr)
call add_to_rheader(totmom_in,'totmom_in',hdr,ierr)
Expand All @@ -371,9 +372,6 @@ subroutine fill_header(sphNGdump,t,nparttot,npartoftypetot,nblocks,nptmass,hdr,i
call add_to_rheader(grainsize(1:ndusttypes),'grainsize',hdr,ierr)
call add_to_rheader(graindens(1:ndusttypes),'graindens',hdr,ierr)
endif
if (use_apr) then
call add_to_rheader(mtot_in,'mtot_in',hdr,ierr)
endif
endif

! real*8
Expand Down
12 changes: 6 additions & 6 deletions src/main/readwrite_dumps_fortran.f90
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ subroutine read_dump_fortran(dumpfile,tfile,hfactfile,idisk1,iprint,id,nprocs,ie
type(dump_h) :: hdr
integer :: i,ierrh

if (id==master) write(iprint,"(/,1x,a,i3)") '>>> reading setup from file: '//trim(dumpfile)//' on unit ',idisk1
if (id==master .and. iverbose >= 0) write(iprint,"(/,1x,a,i3)") '>>> reading setup from file: '//trim(dumpfile)//' on unit ',idisk1
opened_full_dump_fortran = .true.
dt_read_in_fortran = .false.
!
Expand Down Expand Up @@ -558,7 +558,7 @@ subroutine read_dump_fortran(dumpfile,tfile,hfactfile,idisk1,iprint,id,nprocs,ie
close(idisk1)
return
endif
if (id==master) write(iprint,*) trim(fileidentr)
if (id==master .and. iverbose >= 0) write(iprint,*) trim(fileidentr)

! extract file type from the fileid string
call get_options_from_fileid(fileidentr,tagged,phantomdump,smalldump,use_dustfrac,ierr)
Expand Down Expand Up @@ -672,7 +672,7 @@ subroutine read_dump_fortran(dumpfile,tfile,hfactfile,idisk1,iprint,id,nprocs,ie
elseif (npartread > 0) then
string = ''
if (nprocs > 1) write(string,'(a,i5)') 'thread',iblock
write(*,"(2(a,i10),a,i5,a,i10,'-',i10)") trim(string)//' reading particles ',noffset+1,&
if (iverbose >= 0) write(*,"(2(a,i10),a,i5,a,i10,'-',i10)") trim(string)//' reading particles ',noffset+1,&
':',noffset+npartread,', from block ',iblock,' lims=',i1,i2
else
write(*,"(a,i10,a)") ' WARNING! block contains no SPH particles, reading ',nptmass,' point mass particles only'
Expand Down Expand Up @@ -722,9 +722,9 @@ subroutine read_dump_fortran(dumpfile,tfile,hfactfile,idisk1,iprint,id,nprocs,ie
endif

if (narraylengths >= 4) then
if (id==master) write(iprint,"(a,/)") ' <<< finished reading (MHD) file '
if (id==master .and. iverbose >= 0) write(iprint,"(a,/)") ' <<< finished reading (MHD) file '
else
if (id==master) write(iprint,"(a,/)") ' <<< finished reading (hydro) file '
if (id==master .and. iverbose >= 0) write(iprint,"(a,/)") ' <<< finished reading (hydro) file '
endif
close(idisk1)
return
Expand Down Expand Up @@ -802,7 +802,7 @@ subroutine read_smalldump_fortran(dumpfile,tfile,hfactfile,idisk1,iprint,id,npro
ierr = 1
return
endif
if (id==master) write(iprint,*) trim(fileidentr)
if (id==master .and. iverbose >= 0) write(iprint,*) trim(fileidentr)

! extract file type from the fileid string
call get_options_from_fileid(fileidentr,tagged,phantomdump,smalldump,use_dustfrac,ierr)
Expand Down
14 changes: 9 additions & 5 deletions src/setup/readwrite_kepler.f90
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@ end subroutine read_kepler_file
!
!+
!-----------------------------------------------------------------------
subroutine write_kepler_comp(composition,comp_label,columns_compo,r,&
subroutine write_kepler_comp(filename,composition,comp_label,columns_compo,r,&
xyzh,npart,npts,composition_exists,npin)

use table_utils, only:yinterp
character(len=*), intent(in) :: filename
integer, intent(in) :: columns_compo,npart,npts
real, intent(in) :: xyzh(:,:)
real, allocatable,intent(in) :: r(:)
Expand All @@ -212,7 +213,7 @@ subroutine write_kepler_comp(composition,comp_label,columns_compo,r,&
integer, intent(in), optional :: npin
real , allocatable :: compositioni(:,:)
real, allocatable :: comp(:)
integer :: i,j,iu,i1
integer :: i,j,iu,i1,ierr
real :: ri

composition_exists = .false.
Expand All @@ -226,9 +227,13 @@ subroutine write_kepler_comp(composition,comp_label,columns_compo,r,&
endif

if (composition_exists) then
print*, 'Writing the stellar composition for each particle into ','kepler.comp'
print*, 'Writing the stellar composition for each particle into '//trim(filename)

open(newunit=iu,file='kepler.comp')
open(newunit=iu,file=trim(filename),status='replace',form='formatted',iostat=ierr)
if (ierr /= 0) then
print*,' ERROR writing to '//trim(filename)
return
endif
write(iu,"('#',50(1x,'[',1x,a7,']',2x))") &
comp_label
!Now setting the composition of star if the case used was ikepler
Expand All @@ -246,7 +251,6 @@ subroutine write_kepler_comp(composition,comp_label,columns_compo,r,&
(compositioni(j,1),j=1,columns_compo)
enddo
close(iu)
print*, '>>>>>> done'
endif

end subroutine write_kepler_comp
Expand Down
9 changes: 6 additions & 3 deletions src/setup/relax_star.f90
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ end subroutine set_options_for_relaxation
subroutine check_for_existing_file(filename,npart,mgas,xyzh,vxyzu,restart,ierr)
use dump_utils, only:open_dumpfile_r,read_header,dump_h,lenid,extract
use fileutils, only:getnextfilename
use io, only:idump,idisk1,id,nprocs,iprint
use io, only:idump,idisk1,id,nprocs,iprint,iverbose
use readwrite_dumps, only:read_dump
character(len=*), intent(inout) :: filename
integer, intent(in) :: npart
Expand All @@ -537,7 +537,7 @@ subroutine check_for_existing_file(filename,npart,mgas,xyzh,vxyzu,restart,ierr)
character(len=len(filename)) :: restart_file,filetmp
character(len=lenid) :: fileid
type(dump_h) :: hdr
integer :: npartfile
integer :: npartfile,iverboseprev
real :: hfactfile,tfile,mfile
!
! check for the last file in the list relax_00000, relax_00001 etc
Expand All @@ -556,7 +556,8 @@ subroutine check_for_existing_file(filename,npart,mgas,xyzh,vxyzu,restart,ierr)
enddo
if (len_trim(restart_file) <= 0) return

print "(/,1x,a)",'>> RESTARTING relaxation from '//trim(restart_file)
print "(/,1x,a,/)",'>> RESTARTING relaxation from '//trim(restart_file)
iverboseprev = iverbose
call open_dumpfile_r(idump,restart_file,fileid,ierr)
call read_header(idump,hdr,ierr)
close(idump)
Expand All @@ -578,13 +579,15 @@ subroutine check_for_existing_file(filename,npart,mgas,xyzh,vxyzu,restart,ierr)
ierr = 3
return
else
iverbose = -1
restart = .true.
call read_dump(restart_file,tfile,hfactfile,&
idisk1,iprint,id,nprocs,ierr)
filename = restart_file
endif
endif
endif
iverbose = iverboseprev

end subroutine check_for_existing_file

Expand Down
12 changes: 7 additions & 5 deletions src/setup/set_star.f90
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module setstar
real :: ui_coef
real :: polyk
real :: initialtemp
character(len=120) :: input_profile,dens_profile
character(len=120) :: input_profile,dens_profile,compfile
character(len=120) :: outputfilename ! outputfilename is the path to the cored profile
character(len=2) :: label ! used to rename relax_star snapshots to relax1, relax2 etc.
end type star_t
Expand Down Expand Up @@ -102,6 +102,7 @@ subroutine set_defaults_star(star)
star%input_profile = 'P12_Phantom_Profile.data'
star%outputfilename = 'mysoftenedstar.dat'
star%dens_profile = 'density.profile'
star%compfile = 'kepler.comp'
star%label = ''

end subroutine set_defaults_star
Expand Down Expand Up @@ -338,8 +339,10 @@ subroutine set_star(id,master,star,xyzh,vxyzu,eos_vars,rad,&
!
! Write .comp file containing composition of each particle after interpolation
!
if (star%iprofile==iKepler) call write_kepler_comp(composition,comp_label,ncols_compo,r,&
xyzh,npart,npts,composition_exists,npin=npart_old)
if (star%iprofile==iKepler) then
call write_kepler_comp(star%compfile,composition,comp_label,ncols_compo,r,&
xyzh,npart,npts,composition_exists,npin=npart_old)
endif
!
! set the internal energy and temperature
!
Expand Down Expand Up @@ -404,8 +407,6 @@ subroutine set_star(id,master,star,xyzh,vxyzu,eos_vars,rad,&
write(*,'(1x,a,2(es12.5,a))') 'rho_mean = ', rhozero*unit_density, ' g/cm^3 = '&
, rhozero, ' code units'
write(*,'(1x,a,es12.5,a)') 'free fall time = ', sqrt(3.*pi/(32.*rhozero))*utime,' s'

if (composition_exists) write(*,'(a)') 'Composition written to .comp file.'
write(*,"(70('='))")
endif

Expand Down Expand Up @@ -875,6 +876,7 @@ subroutine read_options_star(star,db,nerr,label)
if (present(label)) c = trim(adjustl(label))
star%label = trim(c)
star%dens_profile = 'relax'//trim(c)//'.profile'
star%compfile = 'relax'//trim(c)//'.comp'

call read_inopt(star%iprofile,'iprofile'//trim(c),db,errcount=nerr,min=0,max=nprofile_opts)
call set_defaults_given_profile(star%iprofile,star%input_profile,star%m,star%polyk)
Expand Down
Loading

0 comments on commit b0d28fc

Please sign in to comment.