<commit_before>!< Concrete class of integrator, Euler explicit scheme.
module openpde_integrator_euler_explicit
    !< Concrete class of integrator, Euler explicit scheme.
    use, intrinsic :: iso_fortran_env, only : stderr=>error_unit
    use json_module
    use openpde_equation_abstract
    use openpde_field_abstract
    use openpde_integrator_abstract
    use openpde_kinds

    implicit none
    private
    public :: integrator_euler_explicit

    type, extends(integrator) :: integrator_euler_explicit
        !< Concrete class of integrator, Euler explicit scheme.
        contains
            ! deferred public methods
            procedure, pass(this) :: init      !< Initilize integrator.
            procedure, pass(this) :: integrate !< Integrate the field accordingly to the equation.
            ! public methods
            generic :: load => load_from_json !< Load integrator definition from file.
            ! private methods
            procedure, pass(this), private :: load_from_json !< Load integrator definition from jSON file.
    endtype integrator_euler_explicit
contains
    ! deferred public methods
    subroutine init(this, description, filename, error)
        !< Initialize integrator.
        class(integrator_euler_explicit), intent(inout)         :: this        !< The integrator.
        character(*),                     intent(in),  optional :: description !< Integrator description.
        character(*),                     intent(in),  optional :: filename    !< Initialization file name.
        integer(I_P),                     intent(out), optional :: error       !< Error status.

        call this%free
        if (present(description)) this%description = description
        if (present(filename)) then
            call this%load(filename=filename, error=error)
        else
            this%dt = 0.001_R_P
            if (present(error)) error = 0
        endif
    end subroutine init

    function integrate(this, equ, t, inp) result(error)
        !< Integrate the field accordingly the to equation by means of the Euler explicit scheme.
        class(integrator_euler_explicit), intent(in)            :: this  !< The integrator.
        class(equation),                  intent(in),    target :: equ   !< The equation.
        real(R_P),                        intent(in)            :: t     !< Time.
        class(field),                     intent(inout), target :: inp   !< Input field.
        integer(I_P)                                            :: error !< Error status.
        class(field), allocatable                               :: for   !< Temporary
        call equ%bc(inp=inp, t=t)
        allocate(for, source=inp)
        ! the temporary variable for seems to be needed by intel compiler
        ! otherwise there is an internal compiler error or seg fault<commit_msg>change all 'allocate(source...)' with allocate(mold...)'<commit_after>!< Concrete class of integrator, Euler explicit scheme.
module openpde_integrator_euler_explicit
    !< Concrete class of integrator, Euler explicit scheme.
    use, intrinsic :: iso_fortran_env, only : stderr=>error_unit
    use json_module
    use openpde_equation_abstract
    use openpde_field_abstract
    use openpde_integrator_abstract
    use openpde_kinds

    implicit none
    private
    public :: integrator_euler_explicit

    type, extends(integrator) :: integrator_euler_explicit
        !< Concrete class of integrator, Euler explicit scheme.
        contains
            ! deferred public methods
            procedure, pass(this) :: init      !< Initilize integrator.
            procedure, pass(this) :: integrate !< Integrate the field accordingly to the equation.
            ! public methods
            generic :: load => load_from_json !< Load integrator definition from file.
            ! private methods
            procedure, pass(this), private :: load_from_json !< Load integrator definition from jSON file.
    endtype integrator_euler_explicit
contains
    ! deferred public methods
    subroutine init(this, description, filename, error)
        !< Initialize integrator.
        class(integrator_euler_explicit), intent(inout)         :: this        !< The integrator.
        character(*),                     intent(in),  optional :: description !< Integrator description.
        character(*),                     intent(in),  optional :: filename    !< Initialization file name.
        integer(I_P),                     intent(out), optional :: error       !< Error status.

        call this%free
        if (present(description)) this%description = description
        if (present(filename)) then
            call this%load(filename=filename, error=error)
        else
            this%dt = 0.001_R_P
            if (present(error)) error = 0
        endif
    end subroutine init

    function integrate(this, equ, t, inp) result(error)
        !< Integrate the field accordingly the to equation by means of the Euler explicit scheme.
        class(integrator_euler_explicit), intent(in)            :: this  !< The integrator.
        class(equation),                  intent(in),    target :: equ   !< The equation.
        real(R_P),                        intent(in)            :: t     !< Time.
        class(field),                     intent(inout), target :: inp   !< Input field.
        integer(I_P)                                            :: error !< Error status.
        class(field), allocatable                               :: for   !< Temporary
        call equ%bc(inp=inp, t=t)
        allocate(for, mold=inp)
        ! the temporary variable for seems to be needed by intel compiler
        ! otherwise there is an internal compiler error or seg fault
{'fraction_non_alphanumeric': 0.0794204922325013, 'fraction_numerical': 0.0017455053237912376, 'mean_word_length': 2.0989724175229854, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1087774', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1426, 'n_words': 449}