Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
utils Module Reference

Utilities. More...

Data Types

interface  c_mkdir
 
interface  neko_error
 
interface  read_duration
 
interface  throw_intf
 Interface for the throw procedure. Follows pFunit conventions. More...
 

Functions/Subroutines

subroutine, public default_throw_warning (filename, line_number, message)
 Default throw method for warnings. Does nothing.
 
subroutine, public default_throw_error (filename, line_number, message)
 Default throw method that stops execution.
 
pure integer function, public filename_suffix_pos (fname)
 Find position (in the string) of a filename's suffix.
 
pure integer function, public filename_tslash_pos (fname)
 Find position (in the string) of a filename's trailing slash.
 
subroutine, public filename_path (fname, path)
 Extract the path to a file.
 
subroutine, public filename_name (fname, name)
 Extract the base name of a file (without path and suffix)
 
subroutine, public filename_suffix (fname, suffix)
 Extract a filename's suffix.
 
subroutine, public filename_split (fname, path, name, suffix)
 Extract file name components.
 
subroutine, public filename_chsuffix (fname, new_fname, new_suffix)
 Change a filename's suffix.
 
recursive subroutine, public mkdir (path, mode)
 Recursively create a directory and all parent directories if they do not exist. This should be safer than the ‘execute_command_line('mkdir -p ’ // path)approach, which can be used to execute arbitrary code ifpath` is not properly sanitized.
 
integer function, public extract_fld_file_index (fld_filename, default_index)
 Extracts the index of a field file. For example, "myfield.f00045" will return 45. If the suffix of the file name is invalid, returns a default index value.
 
character(len=100) function, dimension(:), allocatable, public split_string (string, delimiter)
 Split a string based on delimiter (tokenizer) OBS: very hacky, this should really be improved, it is rather embarrasing code.
 
pure integer function, public linear_index (i, j, k, l, lx, ly, lz)
 Compute the address of a (i,j,k,l) array with sizes (1:lx, 1:ly, 1:lz, :)
 
pure integer function, dimension(4), public nonlinear_index (linear_index, lx, ly, lz)
 Compute (i,j,k,l) array given linear index with sizes (1:lx, 1:ly, 1:lz, :)
 
pure logical function, public index_is_on_facet (i, j, k, lx, ly, lz, facet)
 
subroutine neko_error_plain (error_code)
 Reports an error and calls throw_error, which stops execution by default.
 
subroutine neko_error_msg (error_msg)
 Reports an error and calls throw_error, which stops execution by default.
 
subroutine, public neko_type_error (base_type, wrong_type, known_types)
 Reports an error allocating a type for a particular base pointer class.
 
subroutine, public neko_type_registration_error (base_type, wrong_type, known)
 
subroutine, public neko_warning (warning_msg)
 Reports a warning to standard output.
 
character(:) function, allocatable, public concat_string_array (array, sep, prepend)
 Concatenate an array of strings into one string with array items separated by spaces.
 
subroutine read_duration_scalar (runtime_string, runtime_seconds, ierr)
 Parse runtime string to total seconds. Supported formats are:
 
subroutine read_duration_components (runtime_string, runtime_values, ierr)
 Parse runtime string to components. The output array maps to the largest unit available based on size:
 
real(kind=dp) function read_duration_internal (runtime_string, ierr)
 Parse runtime string to total seconds.
 
subroutine set_error_or_throw (message, ierr)
 Raise parser error or set ierr, depending on call mode.
 

Variables

integer, parameter, public neko_fname_len = 1024
 
integer, parameter, public neko_varname_len = 256
 
procedure(throw_intf), pointer, public throw_error => null()
 Pointer to the throw procedure.
 
procedure(throw_intf), pointer, public throw_warning => null()
 Same as above, but for warnings. Does nothing by default.
 

Detailed Description

Various utility functions

Function/Subroutine Documentation

◆ concat_string_array()

character(:) function, allocatable, public utils::concat_string_array ( character(len=*), dimension(:), intent(in)  array,
character(len=*), intent(in)  sep,
logical, intent(in)  prepend 
)
Parameters
arrayThe array of strings.
sepThe separator put between the strings in the array.
prependWhether to also prepend the string with the separator.

Definition at line 465 of file utils.f90.

◆ default_throw_error()

subroutine, public utils::default_throw_error ( character(len=*), intent(in)  filename,
integer, intent(in)  line_number,
character(len=*), intent(in), optional  message 
)

pFUnit will highjack this method during testing to catch exceptions.

Definition at line 101 of file utils.f90.

Here is the caller graph for this function:

◆ default_throw_warning()

subroutine, public utils::default_throw_warning ( character(len=*), intent(in)  filename,
integer, intent(in)  line_number,
character(len=*), intent(in), optional  message 
)

Definition at line 92 of file utils.f90.

Here is the caller graph for this function:

◆ extract_fld_file_index()

integer function, public utils::extract_fld_file_index ( character(len=*), intent(in)  fld_filename,
integer, intent(in)  default_index 
)
Parameters
fld_filenameName of the fld file, e.g. myfield0.f00035.
default_indexThe index to return in case the suffix of fld_filename is invalid.

Definition at line 245 of file utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filename_chsuffix()

subroutine, public utils::filename_chsuffix ( character(len=*)  fname,
character(len=*)  new_fname,
character(len=*)  new_suffix 
)

Definition at line 192 of file utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filename_name()

subroutine, public utils::filename_name ( character(len=*), intent(in)  fname,
character(len=*), intent(out)  name 
)

Definition at line 139 of file utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filename_path()

subroutine, public utils::filename_path ( character(len=*), intent(in)  fname,
character(len=*), intent(out)  path 
)

Definition at line 124 of file utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filename_split()

subroutine, public utils::filename_split ( character(len=*), intent(in)  fname,
character(len=*), intent(out)  path,
character(len=*), intent(out)  name,
character(len=*), intent(out)  suffix 
)

Definition at line 167 of file utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filename_suffix()

subroutine, public utils::filename_suffix ( character(len=*)  fname,
character(len=*)  suffix 
)

Definition at line 160 of file utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filename_suffix_pos()

pure integer function, public utils::filename_suffix_pos ( character(len=*), intent(in)  fname)

Definition at line 110 of file utils.f90.

Here is the caller graph for this function:

◆ filename_tslash_pos()

pure integer function, public utils::filename_tslash_pos ( character(len=*), intent(in)  fname)

Definition at line 117 of file utils.f90.

Here is the caller graph for this function:

◆ index_is_on_facet()

pure logical function, public utils::index_is_on_facet ( integer, intent(in)  i,
integer, intent(in)  j,
integer, intent(in)  k,
integer, intent(in)  lx,
integer, intent(in)  ly,
integer, intent(in)  lz,
integer, intent(in)  facet 
)

Definition at line 350 of file utils.f90.

◆ linear_index()

pure integer function, public utils::linear_index ( integer, intent(in)  i,
integer, intent(in)  j,
integer, intent(in)  k,
integer, intent(in)  l,
integer, intent(in)  lx,
integer, intent(in)  ly,
integer, intent(in)  lz 
)

Definition at line 325 of file utils.f90.

Here is the caller graph for this function:

◆ mkdir()

recursive subroutine, public utils::mkdir ( character(len=*), intent(in)  path,
integer, intent(in), optional  mode 
)
Parameters
pathThe path of the directory to create.
modeThe octal mode to create the directory with, will adjust by umask.

Definition at line 210 of file utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ neko_error_msg()

subroutine utils::neko_error_msg ( character(len=*)  error_msg)
private
Parameters
error_msgThe error message to report.

Definition at line 394 of file utils.f90.

◆ neko_error_plain()

subroutine utils::neko_error_plain ( integer, optional  error_code)
private
Parameters
[optional]error_code The error code to report.

Definition at line 374 of file utils.f90.

◆ neko_type_error()

subroutine, public utils::neko_type_error ( character(len=*), intent(in)  base_type,
character(len=*), intent(in)  wrong_type,
character(len=*), dimension(:), intent(in)  known_types 
)

Should be used in factories.

Parameters
base_typeThe base type of the object, which the factory tried to construct.
wrong_typeThe type that was attempted to construct.
known_typesA list of the types that are known.

Definition at line 412 of file utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ neko_type_registration_error()

subroutine, public utils::neko_type_registration_error ( character(len=*), intent(in)  base_type,
character(len=*), intent(in)  wrong_type,
logical, intent(in)  known 
)

Definition at line 430 of file utils.f90.

Here is the call graph for this function:

◆ neko_warning()

subroutine, public utils::neko_warning ( character(len=*)  warning_msg)

Definition at line 451 of file utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nonlinear_index()

pure integer function, dimension(4), public utils::nonlinear_index ( integer, intent(in)  linear_index,
integer, intent(in)  lx,
integer, intent(in)  ly,
integer, intent(in)  lz 
)

Definition at line 334 of file utils.f90.

Here is the call graph for this function:

◆ read_duration_components()

subroutine utils::read_duration_components ( character(len=*), intent(in)  runtime_string,
real(kind=rp), dimension(:), intent(inout)  runtime_values,
integer, intent(out), optional  ierr 
)
private
  • size 4: [dd, hh, mm, ss]
  • size 3: [hh, mm, ss]
  • size 2: [mm, ss]
  • size 1: [ss]

Definition at line 514 of file utils.f90.

◆ read_duration_internal()

real(kind=dp) function utils::read_duration_internal ( character(len=*), intent(in)  runtime_string,
integer, intent(out), optional  ierr 
)
private

Definition at line 584 of file utils.f90.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_duration_scalar()

subroutine utils::read_duration_scalar ( character(len=*), intent(in)  runtime_string,
real(kind=rp), intent(inout)  runtime_seconds,
integer, intent(out), optional  ierr 
)
private
  • seconds as an integer or real value (for example "5400" or "5400.0")
  • mm:ss
  • hh:mm:ss
  • dd-hh:mm:ss

Definition at line 489 of file utils.f90.

◆ set_error_or_throw()

subroutine utils::set_error_or_throw ( character(len=*), intent(in)  message,
integer, intent(out), optional  ierr 
)
private

Definition at line 675 of file utils.f90.

Here is the caller graph for this function:

◆ split_string()

character(len=100) function, dimension(:), allocatable, public utils::split_string ( character(len=*)  string,
character(len=*)  delimiter 
)

Definition at line 287 of file utils.f90.

Variable Documentation

◆ neko_fname_len

integer, parameter, public utils::neko_fname_len = 1024

Definition at line 42 of file utils.f90.

◆ neko_varname_len

integer, parameter, public utils::neko_varname_len = 256

Definition at line 43 of file utils.f90.

◆ throw_error

procedure(throw_intf), pointer, public utils::throw_error => null()

Ordinarily only raises an error stop. During testing, pFUnit will hijack this procedure to raise an excpeption that can be caught by the testing framework.

Definition at line 67 of file utils.f90.

◆ throw_warning

procedure(throw_intf), pointer, public utils::throw_warning => null()

Definition at line 69 of file utils.f90.