solver_c_api Module



Variables

Type Visibility Attributes Name Initial
integer, private, parameter :: handle_token = 1
type(solver_session_t), private, pointer, save :: active_session => null()
type(cfd_solver_handle_t), private, pointer, save :: active_handle => null()
character(len=512), private, save :: api_last_error = ''

Derived Types

type, public, bind(c) ::  cfd_solver_progress_c_t

C-interoperable progress record returned by cfd_solver_get_progress.

Components

Type Visibility Attributes Name Initial
integer(kind=c_int), public :: iteration = 0
integer(kind=c_int), public :: n_point = 0
integer(kind=c_int), public :: is_initialized = 0
integer(kind=c_int), public :: is_finished = 0
real(kind=c_double), public :: sim_time = 0.0_c_double
real(kind=c_double), public :: time_stop = 0.0_c_double
real(kind=c_double), public :: dt = 0.0_c_double
real(kind=c_double), public :: residual = 0.0_c_double

type, private, bind(c) ::  cfd_solver_handle_t

Opaque token wrapper used to validate ABI handles from foreign code.

Components

Type Visibility Attributes Name Initial
integer(kind=c_int), public :: token = 0

Functions

public function cfd_solver_create(handle) result(status) bind(c, name='cfd_solver_create'))

Allocate the sole supported v1 session and return its opaque handle.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(out) :: handle

Return Value integer(kind=c_int)

public function cfd_solver_destroy(handle) result(status) bind(c, name='cfd_solver_destroy'))

Destroy the active session referenced by handle.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle

Return Value integer(kind=c_int)

public function cfd_solver_load_namelist(handle, filename) result(status) bind(c, name='cfd_solver_load_namelist'))

Load a namelist file into the session configuration.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: filename(*)

Return Value integer(kind=c_int)

public function cfd_solver_initialize(handle) result(status) bind(c, name='cfd_solver_initialize'))

Validate config and allocate the runtime owned by handle.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle

Return Value integer(kind=c_int)

public function cfd_solver_advance(handle, max_steps, steps_taken, finished) result(status) bind(c, name='cfd_solver_advance'))

Advance the solver by at most max_steps iterations.

Read more…

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
integer(kind=c_int), value :: max_steps
integer(kind=c_int), intent(out) :: steps_taken
integer(kind=c_int), intent(out) :: finished

Return Value integer(kind=c_int)

public function cfd_solver_run_to_end(handle) result(status) bind(c, name='cfd_solver_run_to_end'))

Run the session to completion without intermediate polling.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle

Return Value integer(kind=c_int)

public function cfd_solver_get_progress(handle, progress) result(status) bind(c, name='cfd_solver_get_progress'))

Copy out the current progress snapshot for a session.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
type(cfd_solver_progress_c_t), intent(out) :: progress

Return Value integer(kind=c_int)

public function cfd_solver_get_point_count(handle, n_point) result(status) bind(c, name='cfd_solver_get_point_count'))

Return the grid-point count required by solution-copy buffers.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
integer(kind=c_int), intent(out) :: n_point

Return Value integer(kind=c_int)

public function cfd_solver_copy_solution(handle, x, rho, u, p, n_point) result(status) bind(c, name='cfd_solver_copy_solution'))

Copy the primitive solution into caller-owned C buffers.

Read more…

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
real(kind=c_double), intent(out) :: x(*)
real(kind=c_double), intent(out) :: rho(*)
real(kind=c_double), intent(out) :: u(*)
real(kind=c_double), intent(out) :: p(*)
integer(kind=c_int), value :: n_point

Return Value integer(kind=c_int)

public function cfd_solver_write_result(handle, filename) result(status) bind(c, name='cfd_solver_write_result'))

Write the current solution in the standard text result format.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: filename(*)

Return Value integer(kind=c_int)

public function cfd_solver_write_checkpoint(handle, base) result(status) bind(c, name='cfd_solver_write_checkpoint'))

Force an immediate checkpoint write for the active runtime.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: base(*)

Return Value integer(kind=c_int)

public function cfd_solver_get_last_error(handle, buffer, buffer_len) result(status) bind(c, name='cfd_solver_get_last_error'))

Copy the last surfaced error string into a C buffer.

Read more…

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(out) :: buffer(*)
integer(kind=c_int), value :: buffer_len

Return Value integer(kind=c_int)

public function cfd_solver_get_int(handle, key, value) result(status) bind(c, name='cfd_solver_get_int'))

Read an integer configuration field by canonical schema key.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: key(*)
integer(kind=c_int), intent(out) :: value

Return Value integer(kind=c_int)

public function cfd_solver_get_real(handle, key, value) result(status) bind(c, name='cfd_solver_get_real'))

Read a scalar real configuration field by canonical schema key.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: key(*)
real(kind=c_double), intent(out) :: value

Return Value integer(kind=c_int)

public function cfd_solver_get_bool(handle, key, value) result(status) bind(c, name='cfd_solver_get_bool'))

Read a logical configuration field by canonical schema key.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: key(*)
integer(kind=c_int), intent(out) :: value

Return Value integer(kind=c_int)

public function cfd_solver_get_string(handle, key, buffer, buffer_len) result(status) bind(c, name='cfd_solver_get_string'))

Read a string or choice-token configuration field by canonical schema key.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: key(*)
character(kind=c_char, len=1), intent(out) :: buffer(*)
integer(kind=c_int), value :: buffer_len

Return Value integer(kind=c_int)

public function cfd_solver_get_real3(handle, key, values, n_values) result(status) bind(c, name='cfd_solver_get_real3'))

Read a length-3 real configuration field by canonical schema key.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: key(*)
real(kind=c_double), intent(out) :: values(*)
integer(kind=c_int), value :: n_values

Return Value integer(kind=c_int)

public function cfd_solver_set_int(handle, key, value) result(status) bind(c, name='cfd_solver_set_int'))

Set an integer configuration field by canonical schema key.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: key(*)
integer(kind=c_int), value :: value

Return Value integer(kind=c_int)

public function cfd_solver_set_real(handle, key, value) result(status) bind(c, name='cfd_solver_set_real'))

Set a scalar real configuration field by canonical schema key.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: key(*)
real(kind=c_double), value :: value

Return Value integer(kind=c_int)

public function cfd_solver_set_bool(handle, key, value) result(status) bind(c, name='cfd_solver_set_bool'))

Set a logical configuration field by canonical schema key.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: key(*)
integer(kind=c_int), value :: value

Return Value integer(kind=c_int)

public function cfd_solver_set_string(handle, key, value) result(status) bind(c, name='cfd_solver_set_string'))

Set a string or choice-token configuration field by canonical schema key.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: key(*)
character(kind=c_char, len=1), intent(in) :: value(*)

Return Value integer(kind=c_int)

public function cfd_solver_set_real3(handle, key, values, n_values) result(status) bind(c, name='cfd_solver_set_real3'))

Set a length-3 real configuration field by canonical schema key.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
character(kind=c_char, len=1), intent(in) :: key(*)
real(kind=c_double), intent(in) :: values(*)
integer(kind=c_int), value :: n_values

Return Value integer(kind=c_int)

public function cfd_solver_schema_count() result(count) bind(c, name='cfd_solver_schema_count'))

Return the number of schema entries exported through the ABI.

Read more…

Arguments

None

Return Value integer(kind=c_int)

public function cfd_solver_schema_key(index, buffer, buffer_len) result(status) bind(c, name='cfd_solver_schema_key'))

Copy the canonical key for schema entry index.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
character(kind=c_char, len=1), intent(out) :: buffer(*)
integer(kind=c_int), value :: buffer_len

Return Value integer(kind=c_int)

public function cfd_solver_schema_group(index, buffer, buffer_len) result(status) bind(c, name='cfd_solver_schema_group'))

Copy the namelist group name for schema entry index.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
character(kind=c_char, len=1), intent(out) :: buffer(*)
integer(kind=c_int), value :: buffer_len

Return Value integer(kind=c_int)

public function cfd_solver_schema_help(index, buffer, buffer_len) result(status) bind(c, name='cfd_solver_schema_help'))

Copy the short help text for schema entry index.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
character(kind=c_char, len=1), intent(out) :: buffer(*)
integer(kind=c_int), value :: buffer_len

Return Value integer(kind=c_int)

public function cfd_solver_schema_kind(index, value_kind) result(status) bind(c, name='cfd_solver_schema_kind'))

Return the cfg_kind_* tag for schema entry index.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
integer(kind=c_int), intent(out) :: value_kind

Return Value integer(kind=c_int)

public function cfd_solver_schema_bounds(index, has_min, min_value, has_max, max_value) result(status) bind(c, name='cfd_solver_schema_bounds'))

Return optional numeric bounds for schema entry index.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
integer(kind=c_int), intent(out) :: has_min
real(kind=c_double), intent(out) :: min_value
integer(kind=c_int), intent(out) :: has_max
real(kind=c_double), intent(out) :: max_value

Return Value integer(kind=c_int)

public function cfd_solver_schema_choice_count(index, count) result(status) bind(c, name='cfd_solver_schema_choice_count'))

Return the number of allowed string choices for schema entry index.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
integer(kind=c_int), intent(out) :: count

Return Value integer(kind=c_int)

public function cfd_solver_schema_choice(index, choice_index, buffer, buffer_len) result(status) bind(c, name='cfd_solver_schema_choice'))

Copy one allowed string token for a choice-valued schema entry.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
integer(kind=c_int), value :: choice_index
character(kind=c_char, len=1), intent(out) :: buffer(*)
integer(kind=c_int), value :: buffer_len

Return Value integer(kind=c_int)

public function cfd_solver_schema_default_int(index, value) result(status) bind(c, name='cfd_solver_schema_default_int'))

Copy the compiled-in default integer value for schema entry index.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
integer(kind=c_int), intent(out) :: value

Return Value integer(kind=c_int)

public function cfd_solver_schema_default_real(index, value) result(status) bind(c, name='cfd_solver_schema_default_real'))

Copy the compiled-in default scalar real value for schema entry index.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
real(kind=c_double), intent(out) :: value

Return Value integer(kind=c_int)

public function cfd_solver_schema_default_bool(index, value) result(status) bind(c, name='cfd_solver_schema_default_bool'))

Copy the compiled-in default logical value for schema entry index.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
integer(kind=c_int), intent(out) :: value

Return Value integer(kind=c_int)

public function cfd_solver_schema_default_string(index, buffer, buffer_len) result(status) bind(c, name='cfd_solver_schema_default_string'))

Copy the compiled-in default string or choice token for schema entry index.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
character(kind=c_char, len=1), intent(out) :: buffer(*)
integer(kind=c_int), value :: buffer_len

Return Value integer(kind=c_int)

public function cfd_solver_schema_default_real3(index, values, n_values) result(status) bind(c, name='cfd_solver_schema_default_real3'))

Copy the compiled-in default length-3 real vector for schema entry index.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
real(kind=c_double), intent(out) :: values(*)
integer(kind=c_int), value :: n_values

Return Value integer(kind=c_int)

private function resolve_session(handle, session) result(status)

Resolve an opaque C handle to the active Fortran session pointer.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: handle
type(solver_session_t), pointer :: session

Return Value integer(kind=c_int)

private function schema_entry_text(index, buffer, buffer_len, found, entry, field_name) result(status)

Shared helper for copying one text field from a schema entry into a C buffer.

Arguments

Type IntentOptional Attributes Name
integer(kind=c_int), value :: index
character(kind=c_char, len=1), intent(out) :: buffer(*)
integer(kind=c_int), value :: buffer_len
logical, intent(out) :: found
type(config_schema_entry_t), intent(out) :: entry
character(len=*), intent(in) :: field_name

Return Value integer(kind=c_int)

private function c_string_to_fortran(cstr) result(text)

Convert a NUL-terminated C string into a fixed-length Fortran buffer.

Arguments

Type IntentOptional Attributes Name
character(kind=c_char, len=1), intent(in) :: cstr(*)

Return Value character(len=512)


Subroutines

private subroutine fortran_to_c_buffer(text, buffer, buffer_len)

Copy trimmed Fortran text into a NUL-terminated C buffer.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: text
character(kind=c_char, len=1), intent(out) :: buffer(*)
integer, intent(in) :: buffer_len