valid_mesh_size Function

public pure function valid_mesh_size(npoint) result(nmesh)

Smallest supported mesh size not below the requested number of points

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: npoint

Requested number of mesh points

Return Value integer

Supported number of mesh points


Source Code

pure function valid_mesh_size(npoint) result(nmesh)

   !> Requested number of mesh points
   integer, intent(in) :: npoint

   !> Supported number of mesh points
   integer :: nmesh
   integer :: pow3, candidate

   nmesh = 1
   do while (nmesh < npoint)
      nmesh = 2 * nmesh
   end do

   pow3 = 3
   do while (pow3 < nmesh)
      candidate = pow3
      do while (candidate < npoint)
         candidate = 2 * candidate
      end do
      nmesh = min(nmesh, candidate)
      pow3 = 3 * pow3
   end do

end function valid_mesh_size