read Subroutine

private subroutine read(self)

读取 pif.nml 文件

Type Bound

pif_namelist

Arguments

Type IntentOptional Attributes Name
class(pif_namelist), intent(inout) :: self

Contents

Source Code


Source Code

    subroutine read (self)
        class(pif_namelist), intent(inout) :: self
        integer :: numbers(5)
        integer :: iunit, dim, real_kind
        character(64) :: creator, date_time, version
        real(rk) :: hsml  !! 光滑长度
        integer, allocatable :: float_objects(:, :)
        namelist /pif_attr/ creator, date_time, version, real_kind, numbers, dim, hsml
        namelist /pif_float/ float_objects

        open (newunit=iunit, file=cli_obj%working_directory.join.pif_nml_file, status='old', action='read')
        read (iunit, nml=pif_attr)
        self%numbers = numbers
        self%hsml = hsml

        if (dim /= dimension_) call terminal_obj%error('pif.nml: dimension must be the same as SPX dimension')
        if (real_kind /= rk) call terminal_obj%error('pif.nml: real_kind must be the same as SPX real kind')

        allocate (float_objects(2, numbers(5)))
        read (iunit, nml=pif_float)
        call move_alloc(float_objects, self%float_objects)

        close (iunit)

    end subroutine read