Subroutine to read pfasst options from file and command line define the namelist for reading set local variables to pf_pfasst defaults open the file "fname" and read the pfasst namelist overwrite parameters defined on command line re-assign the pfasst internals Sanity check
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(pf_pfasst_t), | intent(inout) | :: | pf | |||
logical, | intent(in) | :: | read_cmd | |||
character(len=*), | intent(in), | optional | :: | fname |
subroutine pf_read_opts(pf, read_cmd, fname)
type(pf_pfasst_t), intent(inout) :: pf
logical, intent(in ) :: read_cmd
character(len=*), intent(in ), optional :: fname
! local versions of pfasst parameters
integer :: niters, nlevels, qtype
integer :: nsweeps(PF_MAXLEVS)
integer :: nsweeps_pred(PF_MAXLEVS)
integer :: nnodes(PF_MAXLEVS)
integer :: nsteps_rk(PF_MAXLEVS)
real(pfdp) :: abs_res_tol, rel_res_tol
logical :: PFASST_pred, RK_pred, pipeline_pred
integer :: nsweeps_burn, q0_style, taui0
logical :: Vcycle,Finterp, use_LUq
logical :: echo_timings, debug, save_results, use_rk_stepper
! stuff for reading the command line
integer, parameter :: un = 9
integer :: i, ios
character(len=32) :: arg
character(len=255) :: istring ! stores command line argument
character(len=255) :: message ! use for i/o error messages
character(len=512) :: outdir
!> define the namelist for reading
namelist /pf_params/ niters, nlevels, qtype, nsweeps, nsweeps_pred, nnodes, nsteps_rk, abs_res_tol, rel_res_tol
namelist /pf_params/ PFASST_pred, RK_pred, pipeline_pred, nsweeps_burn, q0_style, taui0
namelist /pf_params/ Vcycle,Finterp, use_LUq, echo_timings, debug, save_results, use_rk_stepper
!> set local variables to pf_pfasst defaults
nlevels = pf%nlevels
niters = pf%niters
qtype = pf%qtype
nsweeps = pf%nsweeps
nsweeps_pred = pf%nsweeps_pred
nnodes = pf%nnodes
abs_res_tol = pf%abs_res_tol
rel_res_tol = pf%rel_res_tol
pfasst_pred = pf%pfasst_pred
pipeline_pred= pf%pipeline_pred
nsweeps_burn = pf%nsweeps_burn
q0_style = pf%q0_style
Vcycle = pf%Vcycle
Finterp = pf%Finterp
use_LUq = pf%use_LUq
taui0 = pf%taui0
outdir = pf%outdir
debug = pf%debug
save_results = pf%save_results
echo_timings = pf%echo_timings
nsteps_rk = pf%nsteps_rk
rk_pred = pf%rk_pred
use_rk_stepper= pf%use_rk_stepper
!> open the file "fname" and read the pfasst namelist
if (present(fname)) then
open(unit=un, file=fname, status='old', action='read')
read(unit=un, nml=pf_params)
close(unit=un)
end if
!> overwrite parameters defined on command line
if (read_cmd) then
i = 0
do
call get_command_argument(i, arg)
if (len_trim(arg) == 0) exit
if (i > 0) then
istring="&pf_params " // trim(arg) // " /"
read(istring, nml=pf_params, iostat=ios, iomsg=message) ! internal read of namelist
end if
i = i+1
end do
end if
!> re-assign the pfasst internals
pf%nlevels = nlevels
pf%niters = niters
pf%qtype = qtype
pf%nsweeps = nsweeps
pf%nsweeps_pred = nsweeps_pred
pf%nnodes = nnodes
pf%abs_res_tol = abs_res_tol
pf%rel_res_tol = rel_res_tol
pf%pfasst_pred = pfasst_pred
pf%pipeline_pred= pipeline_pred
pf%nsweeps_burn = nsweeps_burn
pf%q0_style = q0_style
pf%Vcycle = Vcycle
pf%Finterp = Finterp
pf%use_LUq = use_LUq
pf%taui0 = taui0
pf%echo_timings = echo_timings
pf%outdir = outdir
pf%debug = debug
pf%save_results = save_results
pf%echo_timings = echo_timings
pf%use_rk_stepper=use_rk_stepper
pf%nsteps_rk = nsteps_rk
pf%rk_pred = rk_pred
!> Sanity check
if (pf%nlevels < 1) then
print *,'pf%nlevels = ',pf%nlevels
stop 'Bad specification for nlevels'
endif
end subroutine pf_read_opts