allocate.F90 Source File


This file depends on

sourcefile~~allocate.f90~~EfferentGraph sourcefile~allocate.f90 allocate.F90 sourcefile~error.f90 error.F90 sourcefile~allocate.f90->sourcefile~error.f90

Files dependent on this one

sourcefile~~allocate.f90~~AfferentGraph sourcefile~allocate.f90 allocate.F90 sourcefile~array.f90 array.F90 sourcefile~array.f90->sourcefile~allocate.f90 sourcefile~core.f90 core.F90 sourcefile~core.f90->sourcefile~allocate.f90 sourcefile~string_utils.f90 string_utils.F90 sourcefile~core.f90->sourcefile~string_utils.f90 sourcefile~unique.f90 unique.F90 sourcefile~core.f90->sourcefile~unique.f90 sourcefile~vtk.f90 vtk.F90 sourcefile~core.f90->sourcefile~vtk.f90 sourcefile~types.f90 types.F90 sourcefile~core.f90->sourcefile~types.f90 sourcefile~hcf.f90 HCF.F90 sourcefile~hcf.f90->sourcefile~allocate.f90 sourcefile~string_utils.f90->sourcefile~allocate.f90 sourcefile~unique.f90->sourcefile~allocate.f90 sourcefile~variable.f90 variable.F90 sourcefile~variable.f90->sourcefile~allocate.f90 sourcefile~vtk.f90->sourcefile~allocate.f90 sourcefile~vtk.f90->sourcefile~array.f90 sourcefile~vtk.f90->sourcefile~unique.f90 sourcefile~adjacency_element.f90 adjacency_element.F90 sourcefile~adjacency_element.f90->sourcefile~core.f90 sourcefile~element.f90 element.F90 sourcefile~adjacency_element.f90->sourcefile~element.f90 sourcefile~adjacency_node.f90 adjacency_node.F90 sourcefile~adjacency_node.f90->sourcefile~core.f90 sourcefile~boundary_interface.f90 boundary_interface.F90 sourcefile~boundary_interface.f90->sourcefile~core.f90 sourcefile~domain.f90 domain.F90 sourcefile~boundary_interface.f90->sourcefile~domain.f90 sourcefile~input.f90 input.F90 sourcefile~boundary_interface.f90->sourcefile~input.f90 sourcefile~matrix.f90 matrix.F90 sourcefile~boundary_interface.f90->sourcefile~matrix.f90 sourcefile~boundary_manager.f90 boundary_manager.F90 sourcefile~boundary_manager.f90->sourcefile~core.f90 sourcefile~boundary_manager.f90->sourcefile~boundary_interface.f90 sourcefile~boundary_manager.f90->sourcefile~domain.f90 sourcefile~boundary_manager.f90->sourcefile~input.f90 sourcefile~boundary_manager.f90->sourcefile~matrix.f90 sourcefile~density_interface.f90 density_interface.F90 sourcefile~density_interface.f90->sourcefile~core.f90 sourcefile~density_interface.f90->sourcefile~input.f90 sourcefile~domain_manager.f90 domain_manager.F90 sourcefile~domain_manager.f90->sourcefile~core.f90 sourcefile~domain_manager.f90->sourcefile~element.f90 sourcefile~element_factory.f90 element_factory.F90 sourcefile~domain_manager.f90->sourcefile~element_factory.f90 sourcefile~multicoloring.f90 multicoloring.F90 sourcefile~domain_manager.f90->sourcefile~multicoloring.f90 sourcefile~reordering.f90 reordering.F90 sourcefile~domain_manager.f90->sourcefile~reordering.f90 sourcefile~side.f90 side.F90 sourcefile~domain_manager.f90->sourcefile~side.f90 sourcefile~side_factory.f90 side_factory.F90 sourcefile~domain_manager.f90->sourcefile~side_factory.f90 sourcefile~adjacency.f90 adjacency.F90 sourcefile~domain_manager.f90->sourcefile~adjacency.f90 sourcefile~domain_manager.f90->sourcefile~input.f90 sourcefile~element.f90->sourcefile~core.f90 sourcefile~element.f90->sourcefile~input.f90 sourcefile~element_factory.f90->sourcefile~core.f90 sourcefile~element_factory.f90->sourcefile~element.f90 sourcefile~element_factory.f90->sourcefile~input.f90 sourcefile~ftdss.f90 ftdss.F90 sourcefile~ftdss.f90->sourcefile~core.f90 sourcefile~input_interface.f90 input_interface.F90 sourcefile~ftdss.f90->sourcefile~input_interface.f90 sourcefile~thermal_interface.f90 thermal_interface.F90 sourcefile~ftdss.f90->sourcefile~thermal_interface.f90 sourcefile~boundary.f90 boundary.F90 sourcefile~ftdss.f90->sourcefile~boundary.f90 sourcefile~control.f90 control.F90 sourcefile~ftdss.f90->sourcefile~control.f90 sourcefile~ftdss.f90->sourcefile~domain.f90 sourcefile~initial.f90 initial.F90 sourcefile~ftdss.f90->sourcefile~initial.f90 sourcefile~output.f90 output.F90 sourcefile~ftdss.f90->sourcefile~output.f90 sourcefile~properties.f90 properties.F90 sourcefile~ftdss.f90->sourcefile~properties.f90 sourcefile~hcf_bc.f90 HCF_BC.F90 sourcefile~hcf_bc.f90->sourcefile~hcf.f90 sourcefile~hcf_durner.f90 HCF_Durner.F90 sourcefile~hcf_durner.f90->sourcefile~hcf.f90 sourcefile~hcf_dvgch.f90 HCF_DVGCH.F90 sourcefile~hcf_dvgch.f90->sourcefile~hcf.f90 sourcefile~hcf_impedance.f90 HCF_Impedance.F90 sourcefile~hcf_impedance.f90->sourcefile~hcf.f90 sourcefile~hcf_ko.f90 HCF_KO.F90 sourcefile~hcf_ko.f90->sourcefile~hcf.f90 sourcefile~hcf_mvg.f90 HCF_MVG.F90 sourcefile~hcf_mvg.f90->sourcefile~hcf.f90 sourcefile~hcf_vg.f90 HCF_VG.F90 sourcefile~hcf_vg.f90->sourcefile~hcf.f90 sourcefile~hcf_viscosity.f90 HCF_Viscosity.F90 sourcefile~hcf_viscosity.f90->sourcefile~hcf.f90 sourcefile~heat_capacity_interface.f90 heat_capacity_interface.F90 sourcefile~heat_capacity_interface.f90->sourcefile~core.f90 sourcefile~heat_capacity_interface.f90->sourcefile~density_interface.f90 sourcefile~heat_capacity_interface.f90->sourcefile~input_interface.f90 sourcefile~initial_interface.f90 initial_interface.F90 sourcefile~initial_interface.f90->sourcefile~core.f90 sourcefile~initial_interface.f90->sourcefile~boundary.f90 sourcefile~initial_interface.f90->sourcefile~domain.f90 sourcefile~initial_interface.f90->sourcefile~input.f90 sourcefile~initial_manager.f90 initial_manager.F90 sourcefile~initial_manager.f90->sourcefile~core.f90 sourcefile~initial_manager.f90->sourcefile~initial_interface.f90 sourcefile~initial_manager.f90->sourcefile~domain.f90 sourcefile~initial_manager.f90->sourcefile~input.f90 sourcefile~input_interface.f90->sourcefile~core.f90 sourcefile~project_settings.f90 project_settings.F90 sourcefile~input_interface.f90->sourcefile~project_settings.f90 sourcefile~matrix_coo.f90 matrix_coo.F90 sourcefile~matrix_coo.f90->sourcefile~core.f90 sourcefile~matrix_coo.f90->sourcefile~domain.f90 sourcefile~matrix_base.f90 matrix_base.F90 sourcefile~matrix_coo.f90->sourcefile~matrix_base.f90 sourcefile~matrix_crs.f90 matrix_crs.F90 sourcefile~matrix_crs.f90->sourcefile~core.f90 sourcefile~matrix_crs.f90->sourcefile~matrix_coo.f90 sourcefile~matrix_crs.f90->sourcefile~domain.f90 sourcefile~matrix_crs.f90->sourcefile~matrix_base.f90 sourcefile~matrix_dense.f90 matrix_dense.F90 sourcefile~matrix_dense.f90->sourcefile~core.f90 sourcefile~matrix_dense.f90->sourcefile~domain.f90 sourcefile~matrix_dense.f90->sourcefile~matrix_base.f90 sourcefile~multicoloring.f90->sourcefile~core.f90 sourcefile~multicoloring.f90->sourcefile~adjacency_element.f90 sourcefile~output_interface.f90 output_interface.F90 sourcefile~output_interface.f90->sourcefile~core.f90 sourcefile~output_interface.f90->sourcefile~project_settings.f90 sourcefile~output_interface.f90->sourcefile~control.f90 sourcefile~output_interface.f90->sourcefile~domain.f90 sourcefile~output_interface.f90->sourcefile~input.f90 sourcefile~output_interface.f90->sourcefile~matrix.f90 sourcefile~output_interface.f90->sourcefile~properties.f90 sourcefile~project_settings.f90->sourcefile~core.f90 sourcefile~properties_manager.f90 properties_manager.F90 sourcefile~properties_manager.f90->sourcefile~core.f90 sourcefile~calculate.f90 calculate.F90 sourcefile~properties_manager.f90->sourcefile~calculate.f90 sourcefile~properties_manager.f90->sourcefile~input.f90 sourcefile~materials_manager.f90 materials_manager.F90 sourcefile~properties_manager.f90->sourcefile~materials_manager.f90 sourcefile~reordering.f90->sourcefile~core.f90 sourcefile~reordering.f90->sourcefile~adjacency_node.f90 sourcefile~reordering.f90->sourcefile~element.f90 sourcefile~side.f90->sourcefile~core.f90 sourcefile~side.f90->sourcefile~input.f90 sourcefile~side_factory.f90->sourcefile~core.f90 sourcefile~side_factory.f90->sourcefile~side.f90 sourcefile~side_factory.f90->sourcefile~input.f90 sourcefile~specific_heat_interface.f90 specific_heat_interface.F90 sourcefile~specific_heat_interface.f90->sourcefile~core.f90 sourcefile~specific_heat_interface.f90->sourcefile~input.f90 sourcefile~thermal_conductivity_interface.f90 thermal_conductivity_interface.F90 sourcefile~thermal_conductivity_interface.f90->sourcefile~core.f90 sourcefile~thermal_conductivity_interface.f90->sourcefile~input.f90 sourcefile~thermal_interface.f90->sourcefile~core.f90 sourcefile~thermal_interface.f90->sourcefile~boundary.f90 sourcefile~thermal_interface.f90->sourcefile~control.f90 sourcefile~thermal_interface.f90->sourcefile~domain.f90 sourcefile~thermal_interface.f90->sourcefile~input.f90 sourcefile~thermal_interface.f90->sourcefile~matrix.f90 sourcefile~thermal_interface.f90->sourcefile~properties.f90 sourcefile~solver.f90 solver.F90 sourcefile~thermal_interface.f90->sourcefile~solver.f90 sourcefile~time.f90 time.F90 sourcefile~time.f90->sourcefile~core.f90 sourcefile~time.f90->sourcefile~input.f90 sourcefile~types.f90->sourcefile~array.f90 sourcefile~types.f90->sourcefile~variable.f90 sourcefile~adjacency.f90->sourcefile~adjacency_element.f90 sourcefile~adjacency.f90->sourcefile~adjacency_node.f90 sourcefile~boundary.f90->sourcefile~boundary_interface.f90 sourcefile~boundary.f90->sourcefile~boundary_manager.f90 sourcefile~boundary_adiabatic.f90 boundary_adiabatic.F90 sourcefile~boundary_adiabatic.f90->sourcefile~boundary_interface.f90 sourcefile~boundary_base.f90 boundary_base.F90 sourcefile~boundary_base.f90->sourcefile~boundary_interface.f90 sourcefile~boundary_dirichlet.f90 boundary_dirichlet.F90 sourcefile~boundary_dirichlet.f90->sourcefile~boundary_interface.f90 sourcefile~calculate.f90->sourcefile~density_interface.f90 sourcefile~calculate.f90->sourcefile~heat_capacity_interface.f90 sourcefile~calculate.f90->sourcefile~specific_heat_interface.f90 sourcefile~calculate.f90->sourcefile~thermal_conductivity_interface.f90 sourcefile~gcc_interface.f90 gcc_interface.F90 sourcefile~calculate.f90->sourcefile~gcc_interface.f90 sourcefile~control.f90->sourcefile~time.f90 sourcefile~density_3phase.f90 density_3phase.F90 sourcefile~density_3phase.f90->sourcefile~density_interface.f90 sourcefile~density_base.f90 density_base.F90 sourcefile~density_base.f90->sourcefile~density_interface.f90 sourcefile~domain.f90->sourcefile~domain_manager.f90 sourcefile~domain.f90->sourcefile~element.f90 sourcefile~domain.f90->sourcefile~element_factory.f90 sourcefile~domain.f90->sourcefile~multicoloring.f90 sourcefile~domain.f90->sourcefile~reordering.f90 sourcefile~domain.f90->sourcefile~side.f90 sourcefile~domain.f90->sourcefile~side_factory.f90 sourcefile~domain.f90->sourcefile~adjacency.f90 sourcefile~dsatur.f90 dsatur.F90 sourcefile~dsatur.f90->sourcefile~multicoloring.f90 sourcefile~element_square_first.f90 element_square_first.F90 sourcefile~element_square_first.f90->sourcefile~element.f90 sourcefile~element_square_second.f90 element_square_second.F90 sourcefile~element_square_second.f90->sourcefile~element.f90 sourcefile~element_triangle_first.f90 element_triangle_first.F90 sourcefile~element_triangle_first.f90->sourcefile~element.f90 sourcefile~element_triangle_second.f90 element_triangle_second.F90 sourcefile~element_triangle_second.f90->sourcefile~element.f90 sourcefile~heat_capacity_3phase.f90 heat_capacity_3phase.F90 sourcefile~heat_capacity_3phase.f90->sourcefile~heat_capacity_interface.f90 sourcefile~heat_capacity_3phase_apparent.f90 heat_capacity_3phase_apparent.F90 sourcefile~heat_capacity_3phase_apparent.f90->sourcefile~heat_capacity_interface.f90 sourcefile~heat_capacity_base.f90 heat_capacity_base.F90 sourcefile~heat_capacity_base.f90->sourcefile~heat_capacity_interface.f90 sourcefile~initial.f90->sourcefile~initial_interface.f90 sourcefile~initial.f90->sourcefile~initial_manager.f90 sourcefile~initial_laplace.f90 initial_laplace.F90 sourcefile~initial_laplace.f90->sourcefile~initial_interface.f90 sourcefile~initial_uniform.f90 initial_uniform.F90 sourcefile~initial_uniform.f90->sourcefile~initial_interface.f90 sourcefile~input.f90->sourcefile~input_interface.f90 sourcefile~input_basic.f90 input_basic.F90 sourcefile~input_basic.f90->sourcefile~input_interface.f90 sourcefile~input_conditions.f90 input_conditions.F90 sourcefile~input_conditions.f90->sourcefile~input_interface.f90 sourcefile~input_geometry.f90 input_geometry.F90 sourcefile~input_geometry.f90->sourcefile~input_interface.f90 sourcefile~input_output.f90 input_output.F90 sourcefile~input_output.f90->sourcefile~input_interface.f90 sourcefile~lfo.f90 lfo.F90 sourcefile~lfo.f90->sourcefile~multicoloring.f90 sourcefile~matrix.f90->sourcefile~matrix_coo.f90 sourcefile~matrix.f90->sourcefile~matrix_crs.f90 sourcefile~matrix.f90->sourcefile~matrix_dense.f90 sourcefile~matrix.f90->sourcefile~matrix_base.f90 sourcefile~methods.f90 methods.F90 sourcefile~methods.f90->sourcefile~reordering.f90 sourcefile~output.f90->sourcefile~output_interface.f90 sourcefile~output_base.f90 output_base.F90 sourcefile~output_base.f90->sourcefile~output_interface.f90 sourcefile~output_observation.f90 output_observation.F90 sourcefile~output_observation.f90->sourcefile~output_interface.f90 sourcefile~output_overall_base.f90 output_overall_base.F90 sourcefile~output_overall_base.f90->sourcefile~output_interface.f90 sourcefile~output_overall_vtk.f90 output_overall_vtk.F90 sourcefile~output_overall_vtk.f90->sourcefile~output_interface.f90 sourcefile~output_overall_vtu.f90 output_overall_vtu.F90 sourcefile~output_overall_vtu.f90->sourcefile~output_interface.f90 sourcefile~output_system_logger.f90 output_system_logger.F90 sourcefile~output_system_logger.f90->sourcefile~output_interface.f90 sourcefile~properties.f90->sourcefile~properties_manager.f90 sourcefile~properties.f90->sourcefile~materials_manager.f90 sourcefile~side_first.f90 side_first.F90 sourcefile~side_first.f90->sourcefile~side.f90 sourcefile~side_second.f90 side_second.F90 sourcefile~side_second.f90->sourcefile~side.f90 sourcefile~specific_heat_3phase.f90 specific_heat_3phase.F90 sourcefile~specific_heat_3phase.f90->sourcefile~specific_heat_interface.f90 sourcefile~specific_heat_base.f90 specific_heat_base.F90 sourcefile~specific_heat_base.f90->sourcefile~specific_heat_interface.f90 sourcefile~thermal.f90 thermal.F90 sourcefile~thermal.f90->sourcefile~thermal_interface.f90 sourcefile~thermal_3phase.f90 thermal_3phase.F90 sourcefile~thermal_3phase.f90->sourcefile~thermal_interface.f90 sourcefile~thermal_conductivity_3phase.f90 thermal_conductivity_3phase.F90 sourcefile~thermal_conductivity_3phase.f90->sourcefile~thermal_conductivity_interface.f90 sourcefile~thermal_conductivity_base.f90 thermal_conductivity_base.F90 sourcefile~thermal_conductivity_base.f90->sourcefile~thermal_conductivity_interface.f90 sourcefile~to_original.f90 to_original.F90 sourcefile~to_original.f90->sourcefile~reordering.f90 sourcefile~to_reordered.f90 to_reordered.F90 sourcefile~to_reordered.f90->sourcefile~reordering.f90 sourcefile~welch_powell.f90 welch_powell.F90 sourcefile~welch_powell.f90->sourcefile~multicoloring.f90 sourcefile~gcc_interface.f90->sourcefile~input.f90 sourcefile~materials_manager.f90->sourcefile~calculate.f90 sourcefile~materials_manager.f90->sourcefile~input.f90 sourcefile~matrix_base.f90->sourcefile~domain.f90 sourcefile~solver_factory.f90 solver_factory.F90 sourcefile~solver_factory.f90->sourcefile~input.f90 sourcefile~solver_factory.f90->sourcefile~matrix.f90 sourcefile~gcc_base.f90 gcc_base.F90 sourcefile~gcc_base.f90->sourcefile~gcc_interface.f90 sourcefile~gcc_non_segregation_m.f90 gcc_non_segregation_m.F90 sourcefile~gcc_non_segregation_m.f90->sourcefile~gcc_interface.f90 sourcefile~gcc_non_segregation_pa.f90 gcc_non_segregation_pa.F90 sourcefile~gcc_non_segregation_pa.f90->sourcefile~gcc_interface.f90 sourcefile~gcc_segregation_m.f90 gcc_segregation_m.F90 sourcefile~gcc_segregation_m.f90->sourcefile~gcc_interface.f90 sourcefile~gcc_segregation_pa.f90 gcc_segregation_pa.F90 sourcefile~gcc_segregation_pa.f90->sourcefile~gcc_interface.f90 sourcefile~solver.f90->sourcefile~solver_factory.f90

Source Code

module core_allocate
    use, intrinsic :: iso_fortran_env
    use :: core_error, only:error_message
    implicit none
    private

    public :: allocate_array
    public :: allocate_pointer

    interface allocate_array
        ! Rank-1 arrays
        module procedure :: allocate_rank1_int8
        module procedure :: allocate_rank1_int16
        module procedure :: allocate_rank1_int32
        module procedure :: allocate_rank1_int64
        module procedure :: allocate_rank1_real32
        module procedure :: allocate_rank1_real64
        module procedure :: allocate_rank1_real128
        module procedure :: allocate_rank1_logical1
        module procedure :: allocate_rank1_logical4
        module procedure :: allocate_rank1_logical8
        ! Rank-2 arrays
        module procedure :: allocate_rank2_int8
        module procedure :: allocate_rank2_int16
        module procedure :: allocate_rank2_int32
        module procedure :: allocate_rank2_int64
        module procedure :: allocate_rank2_real32
        module procedure :: allocate_rank2_real64
        module procedure :: allocate_rank2_real128
        module procedure :: allocate_rank2_logical1
        module procedure :: allocate_rank2_logical4
        module procedure :: allocate_rank2_logical8
    end interface

    interface allocate_pointer
        ! Scalar pointers
        module procedure :: allocate_pointer_int32
        module procedure :: allocate_pointer_int64
        module procedure :: allocate_pointer_real32
        module procedure :: allocate_pointer_real64
        module procedure :: allocate_pointer_real128

        ! Array pointers
        module procedure :: allocate_rank1_int32_pointer
        module procedure :: allocate_rank1_int64_pointer
        module procedure :: allocate_rank1_real32_pointer
        module procedure :: allocate_rank1_real64_pointer
        module procedure :: allocate_rank1_real128_pointer
        module procedure :: allocate_rank1_logical_pointer
        module procedure :: allocate_rank1_int32_specify_pointer
        module procedure :: allocate_rank1_int64_specify_pointer
        module procedure :: allocate_rank1_real32_specify_pointer
        module procedure :: allocate_rank1_real64_specify_pointer
        module procedure :: allocate_rank1_real128_specify_pointer
        module procedure :: allocate_rank1_logical_specify_pointer
    end interface allocate_pointer
contains

    ! rank-1 配列の割り当て
    subroutine allocate_rank1_int8(array, length, bounds)
        implicit none
        integer(int8), intent(inout), allocatable :: array(:)
        integer(int32), intent(in), optional :: length
        integer(int32), intent(in), optional :: bounds(:)
        integer(int32) :: stat
        logical(logical32) :: length_present, bounds_present
        integer(int64) :: requested_size
        integer(int32) :: first, last

        length_present = present(length)
        bounds_present = present(bounds)

        ! --- Argument validation ---
        if (length_present .and. bounds_present) call error_message(956)
        if (.not. length_present .and. .not. bounds_present) call error_message(957)
        if (bounds_present) then
            if (size(bounds) /= 2) call error_message(958)
        end if

        ! --- Main logic ---
        if (allocated(array)) call error_message(951)

        if (length_present) then
            ! Allocate by length
            if (length <= 0) call error_message(952)
            if (int(length, kind=int64) > huge(0_int32)) call error_message(953)
            allocate (array(length), stat=stat)

        else if (bounds_present) then
            ! Allocate by bounds
            first = bounds(1)
            last = bounds(2)

            if (first > last) call error_message(954)

            requested_size = int(last, kind=int64) - int(first, kind=int64) + 1_int64
            if (requested_size > huge(0_int64) / 4) call error_message(953)
            allocate (array(first:last), stat=stat)
        end if

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank1_int8

    subroutine allocate_rank1_int16(array, length, bounds)
        implicit none
        integer(int16), intent(inout), allocatable :: array(:)
        integer(int32), intent(in), optional :: length
        integer(int32), intent(in), optional :: bounds(:)
        integer(int32) :: stat
        logical(logical32) :: length_present, bounds_present
        integer(int64) :: requested_size
        integer(int32) :: first, last

        length_present = present(length)
        bounds_present = present(bounds)

        ! --- Argument validation ---
        if (length_present .and. bounds_present) call error_message(956)
        if (.not. length_present .and. .not. bounds_present) call error_message(957)
        if (bounds_present) then
            if (size(bounds) /= 2) call error_message(958)
        end if

        ! --- Main logic ---
        if (allocated(array)) call error_message(951)

        if (length_present) then
            ! Allocate by length
            if (length <= 0) call error_message(952)
            if (int(length, kind=int64) > huge(0_int32)) call error_message(953)
            allocate (array(length), stat=stat)

        else if (bounds_present) then
            ! Allocate by bounds
            first = bounds(1)
            last = bounds(2)

            if (first > last) call error_message(954)

            requested_size = int(last, kind=int64) - int(first, kind=int64) + 1_int64
            if (requested_size > huge(0_int64) / 4) call error_message(953)
            allocate (array(first:last), stat=stat)
        end if

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank1_int16

    subroutine allocate_rank1_int32(array, length, bounds)
        implicit none
        integer(int32), intent(inout), allocatable :: array(:)
        integer(int32), intent(in), optional :: length
        integer(int32), intent(in), optional :: bounds(:)
        integer(int32) :: stat
        logical(logical32) :: length_present, bounds_present
        integer(int64) :: requested_size
        integer(int32) :: first, last

        length_present = present(length)
        bounds_present = present(bounds)

        ! --- Argument validation ---
        if (length_present .and. bounds_present) call error_message(956)
        if (.not. length_present .and. .not. bounds_present) call error_message(957)
        if (bounds_present) then
            if (size(bounds) /= 2) call error_message(958)
        end if

        ! --- Main logic ---
        if (allocated(array)) call error_message(951)

        if (length_present) then
            ! Allocate by length
            if (length <= 0) call error_message(952)
            if (int(length, kind=int64) > huge(0_int32)) call error_message(953)
            allocate (array(length), stat=stat)

        else if (bounds_present) then
            ! Allocate by bounds
            first = bounds(1)
            last = bounds(2)

            if (first > last) call error_message(954)

            requested_size = int(last, kind=int64) - int(first, kind=int64) + 1_int64
            if (requested_size > huge(0_int64) / 4) call error_message(953)
            allocate (array(first:last), stat=stat)
        end if

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank1_int32

    subroutine allocate_rank1_int64(array, length, bounds)
        implicit none
        integer(int64), intent(inout), allocatable :: array(:)
        integer(int64), intent(in), optional :: length
        integer(int64), intent(in), optional :: bounds(:)
        integer(int32) :: stat
        logical(logical32) :: length_present, bounds_present
        integer(int64) :: requested_size
        integer(int32) :: first, last

        length_present = present(length)
        bounds_present = present(bounds)

        ! --- Argument validation ---
        if (length_present .and. bounds_present) call error_message(956)
        if (.not. length_present .and. .not. bounds_present) call error_message(957)
        if (bounds_present) then
            if (size(bounds) /= 2) call error_message(958)
        end if

        ! --- Main logic ---
        if (allocated(array)) call error_message(951)

        if (length_present) then
            ! Allocate by length
            if (length <= 0) call error_message(952)
            if (int(length, kind=int64) > huge(0_int64)) call error_message(953)
            allocate (array(length), stat=stat)

        else if (bounds_present) then
            ! Allocate by bounds
            first = bounds(1)
            last = bounds(2)

            if (first > last) call error_message(954)

            requested_size = int(last, kind=int64) - int(first, kind=int64) + 1_int64
            if (requested_size > huge(0_int64) / 4) call error_message(953)
            allocate (array(first:last), stat=stat)
        end if

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank1_int64

    subroutine allocate_rank1_real32(array, length, bounds)
        implicit none
        real(real32), intent(inout), allocatable :: array(:)
        integer(int32), intent(in), optional :: length
        integer(int32), intent(in), optional :: bounds(:)
        integer(int32) :: stat
        logical(logical32) :: length_present, bounds_present
        integer(int64) :: requested_size
        integer(int32) :: first, last

        length_present = present(length)
        bounds_present = present(bounds)

        ! --- Argument validation ---
        if (length_present .and. bounds_present) call error_message(956)
        if (.not. length_present .and. .not. bounds_present) call error_message(957)
        if (bounds_present) then
            if (size(bounds) /= 2) call error_message(958)
        end if

        ! --- Main logic ---
        if (allocated(array)) call error_message(951)

        if (length_present) then
            ! Allocate by length
            if (length <= 0) call error_message(952)
            if (int(length, kind=int64) > huge(0_int32)) call error_message(953)
            allocate (array(length), stat=stat)

        else if (bounds_present) then
            ! Allocate by bounds
            first = bounds(1)
            last = bounds(2)

            if (first > last) call error_message(954)

            requested_size = int(last, kind=int64) - int(first, kind=int64) + 1_int64
            if (requested_size > huge(0_int64) / 4) call error_message(953)
            allocate (array(first:last), stat=stat)
        end if

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank1_real32

    subroutine allocate_rank1_real64(array, length, bounds)
        implicit none
        real(real64), intent(inout), allocatable :: array(:)
        integer(int32), intent(in), optional :: length
        integer(int32), intent(in), optional :: bounds(:)
        integer(int32) :: stat
        logical(logical32) :: length_present, bounds_present
        integer(int64) :: requested_size
        integer(int32) :: first, last

        length_present = present(length)
        bounds_present = present(bounds)

        ! --- Argument validation ---
        if (length_present .and. bounds_present) call error_message(956)
        if (.not. length_present .and. .not. bounds_present) call error_message(957)
        if (bounds_present) then
            if (size(bounds) /= 2) call error_message(958)
        end if

        ! --- Main logic ---
        if (allocated(array)) call error_message(951)

        if (length_present) then
            ! Allocate by length
            if (length <= 0) call error_message(952)
            if (int(length, kind=int64) > huge(0_int32)) call error_message(953)
            allocate (array(length), stat=stat)

        else if (bounds_present) then
            ! Allocate by bounds
            first = bounds(1)
            last = bounds(2)

            if (first > last) call error_message(954)

            requested_size = int(last, kind=int64) - int(first, kind=int64) + 1_int64
            if (requested_size > huge(0_int64) / 4) call error_message(953)
            allocate (array(first:last), stat=stat)
        end if

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank1_real64

    subroutine allocate_rank1_real128(array, length, bounds)
        implicit none
        real(real128), intent(inout), allocatable :: array(:)
        integer(int32), intent(in), optional :: length
        integer(int32), intent(in), optional :: bounds(:)
        integer(int32) :: stat
        logical(logical32) :: length_present, bounds_present
        integer(int64) :: requested_size
        integer(int32) :: first, last

        length_present = present(length)
        bounds_present = present(bounds)

        ! --- Argument validation ---
        if (length_present .and. bounds_present) call error_message(956)
        if (.not. length_present .and. .not. bounds_present) call error_message(957)
        if (bounds_present) then
            if (size(bounds) /= 2) call error_message(958)
        end if

        ! --- Main logic ---
        if (allocated(array)) call error_message(951)

        if (length_present) then
            ! Allocate by length
            if (length <= 0) call error_message(952)
            if (int(length, kind=int64) > huge(0_int32)) call error_message(953)
            allocate (array(length), stat=stat)

        else if (bounds_present) then
            ! Allocate by bounds
            first = bounds(1)
            last = bounds(2)

            if (first > last) call error_message(954)

            requested_size = int(last, kind=int64) - int(first, kind=int64) + 1_int64
            if (requested_size > huge(0_int64) / 4) call error_message(953)
            allocate (array(first:last), stat=stat)
        end if

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank1_real128

    subroutine allocate_rank1_logical1(array, length, bounds)
        implicit none
        logical(logical8), intent(inout), allocatable :: array(:)
        integer(int32), intent(in), optional :: length
        integer(int32), intent(in), optional :: bounds(:)
        integer(int32) :: stat
        logical(logical32) :: length_present, bounds_present
        integer(int64) :: requested_size
        integer(int32) :: first, last

        length_present = present(length)
        bounds_present = present(bounds)

        ! --- Argument validation ---
        if (length_present .and. bounds_present) call error_message(956)
        if (.not. length_present .and. .not. bounds_present) call error_message(957)
        if (bounds_present) then
            if (size(bounds) /= 2) call error_message(958)
        end if

        ! --- Main logic ---
        if (allocated(array)) call error_message(951)

        if (length_present) then
            ! Allocate by length
            if (length <= 0) call error_message(952)
            if (int(length, kind=int64) > huge(0_int32)) call error_message(953)
            allocate (array(length), stat=stat)

        else if (bounds_present) then
            ! Allocate by bounds
            first = bounds(1)
            last = bounds(2)

            if (first > last) call error_message(954)

            requested_size = int(last, kind=int64) - int(first, kind=int64) + 1_int64
            if (requested_size > huge(0_int64) / 4) call error_message(953)
            allocate (array(first:last), stat=stat)
        end if

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank1_logical1

    subroutine allocate_rank1_logical4(array, length, bounds)
        implicit none
        logical(logical32), intent(inout), allocatable :: array(:)
        integer(int32), intent(in), optional :: length
        integer(int32), intent(in), optional :: bounds(:)
        integer(int32) :: stat
        logical(logical32) :: length_present, bounds_present
        integer(int64) :: requested_size
        integer(int32) :: first, last

        length_present = present(length)
        bounds_present = present(bounds)

        ! --- Argument validation ---
        if (length_present .and. bounds_present) call error_message(956)
        if (.not. length_present .and. .not. bounds_present) call error_message(957)
        if (bounds_present) then
            if (size(bounds) /= 2) call error_message(958)
        end if

        ! --- Main logic ---
        if (allocated(array)) call error_message(951)

        if (length_present) then
            ! Allocate by length
            if (length <= 0) call error_message(952)
            if (int(length, kind=int64) > huge(0_int32)) call error_message(953)
            allocate (array(length), stat=stat)

        else if (bounds_present) then
            ! Allocate by bounds
            first = bounds(1)
            last = bounds(2)

            if (first > last) call error_message(954)

            requested_size = int(last, kind=int64) - int(first, kind=int64) + 1_int64
            if (requested_size > huge(0_int64) / 4) call error_message(953)
            allocate (array(first:last), stat=stat)
        end if

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank1_logical4

    subroutine allocate_rank1_logical8(array, length, bounds)
        implicit none
        logical(logical64), intent(inout), allocatable :: array(:)
        integer(int32), intent(in), optional :: length
        integer(int32), intent(in), optional :: bounds(:)
        integer(int32) :: stat
        logical(logical32) :: length_present, bounds_present
        integer(int64) :: requested_size
        integer(int32) :: first, last

        length_present = present(length)
        bounds_present = present(bounds)

        ! --- Argument validation ---
        if (length_present .and. bounds_present) call error_message(956)
        if (.not. length_present .and. .not. bounds_present) call error_message(957)
        if (bounds_present) then
            if (size(bounds) /= 2) call error_message(958)
        end if

        ! --- Main logic ---
        if (allocated(array)) call error_message(951)

        if (length_present) then
            ! Allocate by length
            if (length <= 0) call error_message(952)
            if (int(length, kind=int64) > huge(0_int32)) call error_message(953)
            allocate (array(length), stat=stat)

        else if (bounds_present) then
            ! Allocate by bounds
            first = bounds(1)
            last = bounds(2)

            if (first > last) call error_message(954)

            requested_size = int(last, kind=int64) - int(first, kind=int64) + 1_int64
            if (requested_size > huge(0_int64) / 4) call error_message(953)
            allocate (array(first:last), stat=stat)
        end if

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank1_logical8

    subroutine allocate_rank2_int8(array, nrow, ncol)
        implicit none
        integer(int8), intent(inout), allocatable :: array(:, :)
        integer(int32), intent(in) :: nrow, ncol
        integer(int32) :: stat

        if (allocated(array)) call error_message(951)
        if (nrow <= 0 .or. ncol <= 0) call error_message(952)
        ! if (nrow * ncol > huge(ncol)) call error_message(953)

        allocate (array(nrow, ncol), stat=stat)

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank2_int8
    subroutine allocate_rank2_int16(array, num_row, num_col)
        implicit none
        integer(int16), intent(inout), allocatable :: array(:, :)
        integer(int32), intent(in) :: num_row, num_col
        integer(int32) :: stat
        integer(int64) :: total_size

        if (allocated(array)) call error_message(951)
        if (num_row <= 0 .or. num_col <= 0) call error_message(952)

        total_size = int(num_row, kind=int64) * int(num_col, kind=int64)
        if (total_size > huge(0_int64) / 4) call error_message(953)

        allocate (array(num_row, num_col), stat=stat)

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank2_int16

    subroutine allocate_rank2_int32(array, num_row, num_col)
        implicit none
        integer(int32), intent(inout), allocatable :: array(:, :)
        integer(int32), intent(in) :: num_row, num_col
        integer(int32) :: stat
        integer(int64) :: total_size

        if (allocated(array)) call error_message(951)
        if (num_row <= 0 .or. num_col <= 0) call error_message(952)

        total_size = int(num_row, kind=int64) * int(num_col, kind=int64)
        if (total_size > huge(0_int64) / 4) call error_message(953)

        allocate (array(num_row, num_col), stat=stat)

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank2_int32

    subroutine allocate_rank2_int64(array, num_row, num_col)
        implicit none
        integer(int64), intent(inout), allocatable :: array(:, :)
        integer(int32), intent(in) :: num_row, num_col
        integer(int32) :: stat
        integer(int64) :: total_size

        if (allocated(array)) call error_message(951)
        if (num_row <= 0 .or. num_col <= 0) call error_message(952)

        total_size = int(num_row, kind=int64) * int(num_col, kind=int64)
        if (total_size > huge(0_int64) / 8) call error_message(953)

        allocate (array(num_row, num_col), stat=stat)

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank2_int64

    subroutine allocate_rank2_real32(array, num_row, num_col)
        implicit none
        real(real32), intent(inout), allocatable :: array(:, :)
        integer(int32), intent(in) :: num_row, num_col
        integer(int32) :: stat
        integer(int64) :: total_size

        if (allocated(array)) call error_message(951)
        if (num_row <= 0 .or. num_col <= 0) call error_message(952)

        total_size = int(num_row, kind=int64) * int(num_col, kind=int64)
        if (total_size > huge(0_int64) / 4) call error_message(953)

        allocate (array(num_row, num_col), stat=stat)

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank2_real32

    subroutine allocate_rank2_real64(array, num_row, num_col)
        implicit none
        real(real64), intent(inout), allocatable :: array(:, :)
        integer(int32), intent(in) :: num_row, num_col
        integer(int32) :: stat
        integer(int64) :: total_size

        if (allocated(array)) call error_message(951)
        if (num_row <= 0 .or. num_col <= 0) call error_message(952)

        total_size = int(num_row, kind=int64) * int(num_col, kind=int64)
        if (total_size > huge(0_int64) / 8) call error_message(953)

        allocate (array(num_row, num_col), stat=stat)

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank2_real64

    subroutine allocate_rank2_real128(array, num_row, num_col)
        implicit none
        real(real128), intent(inout), allocatable :: array(:, :)
        integer(int32), intent(in) :: num_row, num_col
        integer(int32) :: stat
        integer(int64) :: total_size

        if (allocated(array)) call error_message(951)
        if (num_row <= 0 .or. num_col <= 0) call error_message(952)

        total_size = int(num_row, kind=int64) * int(num_col, kind=int64)
        if (total_size > huge(0_int64) / 16) call error_message(953)

        allocate (array(num_row, num_col), stat=stat)

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank2_real128

    subroutine allocate_rank2_logical1(array, num_row, num_col)
        implicit none
        logical(logical8), intent(inout), allocatable :: array(:, :)
        integer(int32), intent(in) :: num_row, num_col
        integer(int32) :: stat

        if (allocated(array)) call error_message(951)
        if (num_row <= 0 .or. num_col <= 0) call error_message(952)

        allocate (array(num_row, num_col), stat=stat)

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank2_logical1

    subroutine allocate_rank2_logical4(array, num_row, num_col)
        implicit none
        logical(logical32), intent(inout), allocatable :: array(:, :)
        integer(int32), intent(in) :: num_row, num_col
        integer(int32) :: stat

        if (allocated(array)) call error_message(951)
        if (num_row <= 0 .or. num_col <= 0) call error_message(952)

        allocate (array(num_row, num_col), stat=stat)

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank2_logical4

    subroutine allocate_rank2_logical8(array, num_row, num_col)
        implicit none
        logical(logical64), intent(inout), allocatable :: array(:, :)
        integer(int32), intent(in) :: num_row, num_col
        integer(int32) :: stat

        if (allocated(array)) call error_message(951)
        if (num_row <= 0 .or. num_col <= 0) call error_message(952)

        allocate (array(num_row, num_col), stat=stat)

        if (stat /= 0) call error_message(955)

    end subroutine allocate_rank2_logical8

    subroutine allocate_rank1_int32_pointer(array, size)
        implicit none
        integer(int32), intent(inout), dimension(:), pointer :: array
        integer(int32), intent(in) :: size

        if (size <= 0) call error_message(951)
        if (.not. associated(array)) then
            allocate (array(size))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_int32_pointer

    subroutine allocate_rank1_int64_pointer(array, size)
        implicit none
        integer(int64), intent(inout), dimension(:), pointer :: array
        integer(int64), intent(in) :: size

        if (size <= 0) call error_message(951)
        if (.not. associated(array)) then
            allocate (array(size))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_int64_pointer

    subroutine allocate_rank1_real32_pointer(array, size)
        implicit none
        real(real32), intent(inout), dimension(:), pointer :: array
        integer(int32), intent(in) :: size

        if (size <= 0) call error_message(951)
        if (.not. associated(array)) then
            allocate (array(size))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_real32_pointer

    subroutine allocate_rank1_real64_pointer(array, size)
        implicit none
        real(real64), intent(inout), dimension(:), pointer :: array
        integer(int32), intent(in) :: size

        if (size <= 0) call error_message(951)
        if (.not. associated(array)) then
            allocate (array(size))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_real64_pointer

    subroutine allocate_rank1_real128_pointer(array, size)
        implicit none
        real(real128), intent(inout), dimension(:), pointer :: array
        integer(int32), intent(in) :: size

        if (size <= 0) call error_message(951)
        if (.not. associated(array)) then
            allocate (array(size))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_real128_pointer

    subroutine allocate_rank1_logical_pointer(array, size)
        implicit none
        logical, intent(inout), dimension(:), pointer :: array
        integer(int32), intent(in) :: size

        if (size <= 0) call error_message(951)
        if (.not. associated(array)) then
            allocate (array(size))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_logical_pointer

    subroutine allocate_rank1_int32_specify_pointer(array, first, last)
        implicit none
        integer(int32), intent(inout), dimension(:), pointer :: array
        integer(int32), intent(in) :: first, last

        if (first > last) call error_message(952)
        if (.not. associated(array)) then
            allocate (array(first:last))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_int32_specify_pointer

    subroutine allocate_rank1_int64_specify_pointer(array, first, last)
        implicit none
        integer(int64), intent(inout), dimension(:), pointer :: array
        integer(int64), intent(in) :: first, last

        if (first > last) call error_message(952)
        if (.not. associated(array)) then
            allocate (array(first:last))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_int64_specify_pointer

    subroutine allocate_rank1_real32_specify_pointer(array, first, last)
        implicit none
        real(real32), intent(inout), dimension(:), pointer :: array
        integer(int32), intent(in) :: first, last

        if (first > last) call error_message(952)
        if (.not. associated(array)) then
            allocate (array(first:last))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_real32_specify_pointer

    subroutine allocate_rank1_real64_specify_pointer(array, first, last)
        implicit none
        real(real64), intent(inout), dimension(:), pointer :: array
        integer(int32), intent(in) :: first, last

        if (first > last) call error_message(952)
        if (.not. associated(array)) then
            allocate (array(first:last))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_real64_specify_pointer

    subroutine allocate_rank1_real128_specify_pointer(array, first, last)
        implicit none
        real(real128), intent(inout), dimension(:), pointer :: array
        integer(int32), intent(in) :: first, last

        if (first > last) call error_message(952)
        if (.not. associated(array)) then
            allocate (array(first:last))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_real128_specify_pointer

    subroutine allocate_rank1_logical_specify_pointer(array, first, last)
        implicit none
        logical(4), intent(inout), dimension(:), pointer :: array
        integer(int32), intent(in) :: first, last

        if (first > last) call error_message(952)
        if (.not. associated(array)) then
            allocate (array(first:last))
        else
            ! call error_message(953)
        end if
    end subroutine allocate_rank1_logical_specify_pointer

    ! ポインタ用の割り当て
    subroutine allocate_pointer_int32(iptr)
        implicit none
        integer(int32), pointer :: iptr

        if (.not. associated(iptr)) then
            allocate (iptr)
        else
            call error_message(955)
        end if
    end subroutine allocate_pointer_int32

    subroutine allocate_pointer_int64(iptr)
        implicit none
        integer(int64), pointer :: iptr

        if (.not. associated(iptr)) then
            allocate (iptr)
        else
            call error_message(955)
        end if
    end subroutine allocate_pointer_int64

    subroutine allocate_pointer_real32(dptr)
        implicit none
        real(real32), pointer :: dptr

        if (.not. associated(dptr)) then
            allocate (dptr)
        else
            call error_message(955)
        end if
    end subroutine allocate_pointer_real32

    subroutine allocate_pointer_real64(dptr)
        implicit none
        real(real64), pointer :: dptr

        if (.not. associated(dptr)) then
            allocate (dptr)
        else
            call error_message(955)
        end if
    end subroutine allocate_pointer_real64

    subroutine allocate_pointer_real128(dptr)
        implicit none
        real(real128), pointer :: dptr

        if (.not. associated(dptr)) then
            allocate (dptr)
        else
            call error_message(955)
        end if
    end subroutine allocate_pointer_real128
end module core_allocate