read_sites Subroutine

private subroutine read_sites(this)

Type Bound

ext_input

Arguments

Type IntentOptional Attributes Name
class(ext_input) :: this

Contents

Source Code


Source Code

    subroutine read_sites(this)

        class(ext_input):: this

        integer:: i, n_site, n_neighbors
        integer, allocatable :: neighs(:)

        CHARACTER(LEN=100) w
        type(ManagingFileReader_t) :: file_reader
        type(TokenIterator_t) :: tokens

        file_reader = ManagingFileReader_t("lattice.file")

        readsites: do while (file_reader%nextline(tokens, skip_empty=.true.))
            w = to_upper(tokens%next())
            select case (w)
            case ('SITE')
                n_site = to_int(tokens%next())

                n_neighbors = to_int(tokens%next())
                if (allocated(neighs)) deallocate(neighs)
                allocate(neighs(n_neighbors), source=0)
                do i = 1, size(neighs)
                    neighs(i) = to_int(tokens%next())
                end do
                this%sites(n_site) = site(n_site, n_neighbors, neighs)
            end select
        end do readsites

        call file_reader%close()
    end subroutine read_sites