auxiliar.f90 Source File


This file depends on

sourcefile~~auxiliar.f90~2~~EfferentGraph sourcefile~auxiliar.f90~2 auxiliar.f90 sourcefile~constants.f90 constants.f90 sourcefile~auxiliar.f90~2->sourcefile~constants.f90

Files dependent on this one

sourcefile~~auxiliar.f90~2~~AfferentGraph sourcefile~auxiliar.f90~2 auxiliar.f90 sourcefile~continuation.f90 continuation.f90 sourcefile~continuation.f90->sourcefile~auxiliar.f90~2 sourcefile~linalg.f90 linalg.f90 sourcefile~continuation.f90->sourcefile~linalg.f90 sourcefile~flash.f90 flash.f90 sourcefile~flash.f90->sourcefile~auxiliar.f90~2 sourcefile~ar_models.f90 ar_models.f90 sourcefile~flash.f90->sourcefile~ar_models.f90 sourcefile~auxiliar.f90~3 auxiliar.f90 sourcefile~flash.f90->sourcefile~auxiliar.f90~3 sourcefile~pressure_equality.f90 pressure_equality.f90 sourcefile~flash.f90->sourcefile~pressure_equality.f90 sourcefile~linalg.f90->sourcefile~auxiliar.f90~2 sourcefile~math.f90 math.f90 sourcefile~math.f90->sourcefile~auxiliar.f90~2 sourcefile~math.f90->sourcefile~continuation.f90 sourcefile~math.f90->sourcefile~linalg.f90 sourcefile~phase_envelopes_pt.f90 phase_envelopes_pt.f90 sourcefile~phase_envelopes_pt.f90->sourcefile~auxiliar.f90~2 sourcefile~phase_envelopes_pt.f90->sourcefile~continuation.f90 sourcefile~phase_envelopes_pt_mp.f90 phase_envelopes_pt_mp.f90 sourcefile~phase_envelopes_pt.f90->sourcefile~phase_envelopes_pt_mp.f90 sourcefile~phase_envelopes_pt.f90->sourcefile~ar_models.f90 sourcefile~critical.f90 critical.f90 sourcefile~phase_envelopes_pt.f90->sourcefile~critical.f90 sourcefile~phase_envelopes_pt.f90->sourcefile~auxiliar.f90~3 sourcefile~phase_envelopes_pt_mp.f90->sourcefile~auxiliar.f90~2 sourcefile~phase_envelopes_pt_mp.f90->sourcefile~math.f90 sourcefile~phase_envelopes_pt_mp.f90->sourcefile~ar_models.f90 sourcefile~auxiliar.f90 auxiliar.f90 sourcefile~phase_envelopes_pt_mp.f90->sourcefile~auxiliar.f90 sourcefile~phase_envelopes_px.f90 phase_envelopes_px.f90 sourcefile~phase_envelopes_px.f90->sourcefile~auxiliar.f90~2 sourcefile~phase_envelopes_px.f90->sourcefile~continuation.f90 sourcefile~phase_envelopes_px.f90->sourcefile~ar_models.f90 sourcefile~phase_envelopes_px.f90->sourcefile~auxiliar.f90 sourcefile~phase_envelopes_px_mp.f90 phase_envelopes_px_mp.f90 sourcefile~phase_envelopes_px_mp.f90->sourcefile~auxiliar.f90~2 sourcefile~phase_envelopes_px_mp.f90->sourcefile~math.f90 sourcefile~phase_envelopes_px_mp.f90->sourcefile~ar_models.f90 sourcefile~phase_envelopes_px_mp.f90->sourcefile~auxiliar.f90 sourcefile~phase_envelopes_tx.f90 phase_envelopes_tx.f90 sourcefile~phase_envelopes_tx.f90->sourcefile~auxiliar.f90~2 sourcefile~phase_envelopes_tx.f90->sourcefile~continuation.f90 sourcefile~phase_envelopes_tx.f90->sourcefile~ar_models.f90 sourcefile~phase_envelopes_tx.f90->sourcefile~auxiliar.f90 sourcefile~phase_envelopes_tx_mp.f90 phase_envelopes_tx_mp.f90 sourcefile~phase_envelopes_tx_mp.f90->sourcefile~auxiliar.f90~2 sourcefile~phase_envelopes_tx_mp.f90->sourcefile~math.f90 sourcefile~phase_envelopes_tx_mp.f90->sourcefile~ar_models.f90 sourcefile~phase_envelopes_tx_mp.f90->sourcefile~auxiliar.f90 sourcefile~pure_saturation.f90 pure_saturation.f90 sourcefile~pure_saturation.f90->sourcefile~auxiliar.f90~2 sourcefile~pure_saturation.f90->sourcefile~continuation.f90 sourcefile~pure_saturation.f90->sourcefile~linalg.f90 sourcefile~pure_saturation.f90->sourcefile~ar_models.f90 sourcefile~saturations_points.f90 saturations_points.f90 sourcefile~saturations_points.f90->sourcefile~auxiliar.f90~2 sourcefile~saturations_points.f90->sourcefile~ar_models.f90 sourcefile~saturation_point.f90 saturation_point.f90 sourcefile~saturations_points.f90->sourcefile~saturation_point.f90 sourcefile~saturations_points.f90->sourcefile~auxiliar.f90~3 sourcefile~volume.f90 volume.f90 sourcefile~volume.f90->sourcefile~auxiliar.f90~2 sourcefile~volume.f90->sourcefile~ar_models.f90 sourcefile~ar_models.f90->sourcefile~math.f90 sourcefile~auxiliar.f90->sourcefile~math.f90 sourcefile~binaries.f90 binaries.f90 sourcefile~binaries.f90->sourcefile~math.f90 sourcefile~binaries.f90->sourcefile~ar_models.f90 sourcefile~critical.f90->sourcefile~continuation.f90 sourcefile~critical.f90->sourcefile~linalg.f90 sourcefile~critical.f90->sourcefile~math.f90 sourcefile~critical.f90->sourcefile~ar_models.f90 sourcefile~stability.f90 stability.f90 sourcefile~critical.f90->sourcefile~stability.f90 sourcefile~equilibria.f90 equilibria.f90 sourcefile~equilibria.f90->sourcefile~flash.f90 sourcefile~equilibria.f90->sourcefile~phase_envelopes_pt.f90 sourcefile~equilibria.f90->sourcefile~phase_envelopes_pt_mp.f90 sourcefile~equilibria.f90->sourcefile~phase_envelopes_px.f90 sourcefile~equilibria.f90->sourcefile~phase_envelopes_px_mp.f90 sourcefile~equilibria.f90->sourcefile~phase_envelopes_tx.f90 sourcefile~equilibria.f90->sourcefile~phase_envelopes_tx_mp.f90 sourcefile~equilibria.f90->sourcefile~pure_saturation.f90 sourcefile~equilibria.f90->sourcefile~saturations_points.f90 sourcefile~equilibria.f90->sourcefile~binaries.f90 sourcefile~equilibria.f90->sourcefile~critical.f90 sourcefile~flash_mp.f90 flash_mp.f90 sourcefile~equilibria.f90->sourcefile~flash_mp.f90 sourcefile~generalized_isoline.f90 generalized_isoline.f90 sourcefile~equilibria.f90->sourcefile~generalized_isoline.f90 sourcefile~phase_envelopes_pt_3ph.f90 phase_envelopes_pt_3ph.f90 sourcefile~equilibria.f90->sourcefile~phase_envelopes_pt_3ph.f90 sourcefile~phase_envelopes_px_3ph.f90 phase_envelopes_px_3ph.f90 sourcefile~equilibria.f90->sourcefile~phase_envelopes_px_3ph.f90 sourcefile~equilibria.f90->sourcefile~auxiliar.f90~3 sourcefile~flash_second_order.f90 flash_second_order.f90 sourcefile~equilibria.f90->sourcefile~flash_second_order.f90 sourcefile~equilibria.f90->sourcefile~stability.f90 sourcefile~flash_mp.f90->sourcefile~math.f90 sourcefile~flash_mp.f90->sourcefile~ar_models.f90 sourcefile~flash_mp.f90->sourcefile~stability.f90 sourcefile~generalized_isoline.f90->sourcefile~math.f90 sourcefile~generalized_isoline.f90->sourcefile~ar_models.f90 sourcefile~generalized_isoline.f90->sourcefile~stability.f90 sourcefile~generic_cubic.f90 generic_cubic.f90 sourcefile~generic_cubic.f90->sourcefile~linalg.f90 sourcefile~generic_cubic.f90->sourcefile~volume.f90 sourcefile~generic_cubic.f90->sourcefile~ar_models.f90 sourcefile~gerg2008.f90 gerg2008.f90 sourcefile~gerg2008.f90->sourcefile~math.f90 sourcefile~gerg2008.f90->sourcefile~generic_cubic.f90 sourcefile~implementations.f90~2 implementations.f90 sourcefile~gerg2008.f90->sourcefile~implementations.f90~2 sourcefile~armodel_adiff_api.f90 armodel_adiff_api.f90 sourcefile~gerg2008.f90->sourcefile~armodel_adiff_api.f90 sourcefile~implementations.f90~2->sourcefile~pure_saturation.f90 sourcefile~implementations.f90~2->sourcefile~generic_cubic.f90 sourcefile~alphas.f90 alphas.f90 sourcefile~implementations.f90~2->sourcefile~alphas.f90 sourcefile~huron_vidal.f90 huron_vidal.f90 sourcefile~implementations.f90~2->sourcefile~huron_vidal.f90 sourcefile~implementations.f90 implementations.f90 sourcefile~implementations.f90~2->sourcefile~implementations.f90 sourcefile~quadratic_mixing.f90 quadratic_mixing.f90 sourcefile~implementations.f90~2->sourcefile~quadratic_mixing.f90 sourcefile~nonlineal.f90 nonlineal.f90 sourcefile~nonlineal.f90->sourcefile~linalg.f90 sourcefile~nonlineal.f90->sourcefile~math.f90 sourcefile~pc_saft.f90 pc_saft.f90 sourcefile~pc_saft.f90->sourcefile~linalg.f90 sourcefile~pc_saft.f90->sourcefile~volume.f90 sourcefile~pc_saft.f90->sourcefile~critical.f90 sourcefile~pure_critical_solver.f90 pure_critical_solver.f90 sourcefile~pc_saft.f90->sourcefile~pure_critical_solver.f90 sourcefile~tapenade_ar_api.f90 tapenade_ar_api.f90 sourcefile~pc_saft.f90->sourcefile~tapenade_ar_api.f90 sourcefile~phase_envelopes_pt_3ph.f90->sourcefile~math.f90 sourcefile~phase_envelopes_pt_3ph.f90->sourcefile~ar_models.f90 sourcefile~phase_envelopes_px_3ph.f90->sourcefile~math.f90 sourcefile~phase_envelopes_px_3ph.f90->sourcefile~ar_models.f90 sourcefile~phase_envelopes_px_3ph.f90->sourcefile~auxiliar.f90 sourcefile~pure_critical_solver.f90->sourcefile~pure_saturation.f90 sourcefile~pure_critical_solver.f90->sourcefile~ar_models.f90 sourcefile~saturation_point.f90->sourcefile~linalg.f90 sourcefile~saturation_point.f90->sourcefile~math.f90 sourcefile~saturation_point.f90->sourcefile~ar_models.f90 sourcefile~saturation_point.f90->sourcefile~nonlineal.f90 sourcefile~uniquac.f90 uniquac.f90 sourcefile~uniquac.f90->sourcefile~math.f90 sourcefile~alphas.f90->sourcefile~generic_cubic.f90 sourcefile~armodel_adiff_api.f90->sourcefile~ar_models.f90 sourcefile~auxiliar.f90~3->sourcefile~ar_models.f90 sourcefile~consistency_armodel.f90 consistency_armodel.f90 sourcefile~consistency_armodel.f90->sourcefile~ar_models.f90 sourcefile~cubic_mixing.f90 cubic_mixing.f90 sourcefile~cubic_mixing.f90->sourcefile~generic_cubic.f90 sourcefile~flash_second_order.f90->sourcefile~ar_models.f90 sourcefile~flash_second_order.f90->sourcefile~auxiliar.f90~3 sourcefile~flash_second_order.f90->sourcefile~stability.f90 sourcefile~huron_vidal.f90->sourcefile~generic_cubic.f90 sourcefile~huron_vidal.f90->sourcefile~quadratic_mixing.f90 sourcefile~nrtl_hv.f90 nrtl_hv.f90 sourcefile~huron_vidal.f90->sourcefile~nrtl_hv.f90 sourcefile~implementations.f90->sourcefile~uniquac.f90 sourcefile~implementations.f90->sourcefile~nrtl_hv.f90 sourcefile~models.f90 models.f90 sourcefile~models.f90->sourcefile~ar_models.f90 sourcefile~models.f90->sourcefile~generic_cubic.f90 sourcefile~models.f90->sourcefile~gerg2008.f90 sourcefile~models.f90->sourcefile~implementations.f90~2 sourcefile~models.f90->sourcefile~pc_saft.f90 sourcefile~models.f90->sourcefile~alphas.f90 sourcefile~models.f90->sourcefile~cubic_mixing.f90 sourcefile~models.f90->sourcefile~huron_vidal.f90 sourcefile~models.f90->sourcefile~implementations.f90 sourcefile~models.f90->sourcefile~quadratic_mixing.f90 sourcefile~sddlc.f90 sddlc.f90 sourcefile~models.f90->sourcefile~sddlc.f90 sourcefile~pressure_equality.f90->sourcefile~ar_models.f90 sourcefile~quadratic_mixing.f90->sourcefile~generic_cubic.f90 sourcefile~stability.f90->sourcefile~ar_models.f90 sourcefile~tapenade_ar_api.f90->sourcefile~ar_models.f90 sourcefile~yaeos.f90 yaeos.f90 sourcefile~yaeos.f90->sourcefile~equilibria.f90 sourcefile~yaeos.f90->sourcefile~models.f90 sourcefile~consistency.f90 consistency.f90 sourcefile~yaeos.f90->sourcefile~consistency.f90 sourcefile~autodiff.f90 autodiff.f90 sourcefile~autodiff.f90->sourcefile~armodel_adiff_api.f90 sourcefile~consistency.f90->sourcefile~consistency_armodel.f90 sourcefile~fluids.f90 fluids.f90 sourcefile~fluids.f90->sourcefile~models.f90 sourcefile~sddlc.f90->sourcefile~quadratic_mixing.f90 sourcefile~nrtl_hv.f90->sourcefile~autodiff.f90

Source Code

module yaeos__auxiliar
   !! # General auxiliary utilities
   !! Small convenience procedures shared by model, solver, and phase-equilibrium code.
   !!
   !! # Description
   !! The generic `optval` returns either a present optional scalar or a supplied
   !! default. `sort` sorts a real array in place using `stdlib_sorting`.
   !!
   !! # Examples
   !! ```fortran
   !! niter = optval(max_iters, 100)
   !! call sort(values)
   !! ```
   use yaeos__constants, only: pr
   implicit none

   interface optval
      module procedure optval_integer, optval_real, optval_character, optval_logical
   end interface optval

contains

   integer function optval_integer(val, default)
      !! # optval_integer
      !! Return the optional integer value or its fallback.
      !!
      !! # Description
      !! Selects `val` when present and otherwise returns `default`.
      !!
      !! # Examples
      !! ```fortran
      !! iterations = optval(max_iters, 100)
      !! ```
      integer, optional, intent(in) :: val !! Optional integer value.
      integer, intent(in) :: default !! Value returned when `val` is absent.

      if (present(val)) then
         optval_integer = val
      else
         optval_integer = default
      end if
   end function optval_integer
   
   logical function optval_logical(val, default)
      !! # optval_logical
      !! Return the optional logical value or its fallback.
      !!
      !! # Description
      !! Selects `val` when present and otherwise returns `default`.
      logical, optional, intent(in) :: val !! Optional logical value.
      logical, intent(in) :: default !! Value returned when `val` is absent.

      if (present(val)) then
         optval_logical = val
      else
         optval_logical = default
      end if
   end function optval_logical

   real(pr) function optval_real(val, default)
      !! # optval_real
      !! Return the optional real value or its fallback.
      !!
      !! # Description
      !! Selects `val` when present and otherwise returns `default`.
      real(pr), optional, intent(in) :: val !! Optional real value.
      real(pr), intent(in) :: default !! Value returned when `val` is absent.

      if (present(val)) then
         optval_real = val
      else
         optval_real = default
      end if
   end function optval_real

   function optval_character(val, default)
      !! # optval_character
      !! Return the optional character value or its fallback.
      !!
      !! # Description
      !! Selects `val` when present and otherwise returns `default`; the result
      !! is allocated to the selected string length.
      character(len=*), optional, intent(in) :: val !! Optional character value.
      character(len=*), intent(in) :: default !! Value returned when `val` is absent.
      character(len=:), allocatable :: optval_character

      if (present(val)) then
         optval_character = val
      else
         optval_character = default
      end if
   end function optval_character

   subroutine sort(array, idx)
      !! # sort
      !! Sort a real array in ascending order in place.
      !!
      !! # Description
      !! Delegates the sorting operation to `stdlib_sorting`. The optional `idx`
      !! argument is present in the interface but is not currently populated.
      !!
      !! # Examples
      !! ```fortran
      !! call sort(values)
      !! ```
      use stdlib_sorting, only: std => sort
      real(pr), intent(in out) :: array(:) !! Values to sort; overwritten in ascending order.
      integer, optional, intent(out) :: idx(:) !! Reserved optional index output; currently unchanged.

      call std(array)

   end subroutine sort
end module yaeos__auxiliar