Create a PFASST object gather some input from a file and command line fname present, read inputs from a file (and maybe command line) fname not present, only call read_opts if we want command line read set communicator
Set up the mpi communicator allocate level pointers loop over levels to set parameters allocate hooks allocate status
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(pf_pfasst_t), | intent(inout) | :: | pf | Main pfasst object |
||
type(pf_comm_t), | intent(inout), | target | :: | comm | Communicator |
|
integer, | intent(in), | optional | :: | nlevels | number of pfasst levels |
|
character(len=*), | intent(in), | optional | :: | fname | Input file for pfasst parameters |
|
logical, | intent(in), | optional | :: | nocmd | Determines if command line variables are to be read |
subroutine pf_pfasst_create(pf, comm, nlevels, fname, nocmd)
use pf_mod_hooks, only: PF_MAX_HOOK
type(pf_pfasst_t), intent(inout) :: pf !! Main pfasst object
type(pf_comm_t), intent(inout), target :: comm !! Communicator
integer, intent(in ), optional :: nlevels !! number of pfasst levels
character(len=*), intent(in ), optional :: fname !! Input file for pfasst parameters
logical, intent(in ), optional :: nocmd !! Determines if command line variables are to be read
logical :: read_cmd !! Local version of nocmd
integer :: ierr
integer :: l !! Loop variable for levels
if (present(nlevels)) pf%nlevels = nlevels
pf%outdir = ""
!> gather some input from a file and command line
read_cmd = .true.
if (present(nocmd)) then
if (nocmd) read_cmd = .false.
end if
if (present(fname)) then !! fname present, read inputs from a file (and maybe command line)
call pf_read_opts(pf, read_cmd, fname)
else !! fname not present, only call read_opts if we want command line read
if (read_cmd) call pf_read_opts(pf, read_cmd)
end if
!> set communicator
pf%comm => comm
!> Set up the mpi communicator
call pf_mpi_setup(pf%comm, pf,ierr)
if (ierr /=0 ) stop "ERROR: mpi_setup failed"
if (pf%rank < 0) then
stop 'Invalid PF rank: did you call setup correctly?'
end if
!> allocate level pointers
allocate(pf%levels(pf%nlevels),stat=ierr)
if (ierr /= 0) stop "allocate error levels"
!> loop over levels to set parameters
do l = 1, pf%nlevels
pf%levels(l)%index = l
pf%levels(l)%nsweeps = pf%nsweeps(l)
pf%levels(l)%nsweeps_pred = pf%nsweeps_pred(l)
pf%levels(l)%nnodes = pf%nnodes(l)
pf%levels(l)%Finterp = pf%Finterp
pf%levels(l)%nsteps_rk = pf%nsteps_rk(l)
end do
!> allocate hooks
allocate(pf%hooks(pf%nlevels, PF_MAX_HOOK, PF_MAX_HOOKS),stat=ierr)
if (ierr /= 0) stop "allocate error hooks"
allocate(pf%nhooks(pf%nlevels, PF_MAX_HOOK),stat=ierr)
if (ierr /= 0) stop "allocate error nhooks"
pf%nhooks = 0
!> allocate status
allocate(pf%state,stat=ierr)
if (ierr /= 0) stop "allocate error state"
pf%state%pstatus = 0
pf%state%status = 0
end subroutine pf_pfasst_create