read_unformatted Subroutine

private subroutine read_unformatted(gmsh_msh_format, unit, iostat, iomsg)

Read an $MshMeshFormat from a connected unformatted unit.

Arguments

Type IntentOptional Attributes Name
class(gmsh_msh_format_type), intent(inout) :: gmsh_msh_format
integer, intent(in) :: unit
integer, intent(out) :: iostat
character(len=*), intent(inout) :: iomsg

Calls

proc~~read_unformatted~~CallsGraph proc~read_unformatted read_unformatted proc~check_text_line check_text_line proc~read_unformatted->proc~check_text_line

Called by

proc~~read_unformatted~~CalledByGraph proc~read_unformatted read_unformatted interface~read(unformatted) read(unformatted) interface~read(unformatted)->proc~read_unformatted

Variables

Type Visibility Attributes Name Initial
character(len=1), private :: buffer

A character variable to read a character.

integer, private :: itr
character(len=32), private :: str

A character variable for holding read string.
The length of this string is provisional.


Source Code

    subroutine read_unformatted(gmsh_msh_format, unit, iostat, iomsg)

        class(gmsh_msh_format_type), intent(inout) :: gmsh_msh_format

        integer, intent(in) :: unit

        integer, intent(out) :: iostat

        character(*), intent(inout) :: iomsg



        integer :: itr

        !> Version: experimental
        !> A `character` variable to read a character.
        character(1) :: buffer

        !> Version: experimental
        !> A `character` variable for holding read string.<br>
        !> The length of this string is provisional.
        character(32) :: str



        read_header: &!
        block

            itr   = 1
            iomsg = ''
            str   = ''

            do

                read( &!
                unit   = unit   , &!
                iostat = iostat , &!
                iomsg  = iomsg    &!
                ) &!
                buffer

                if ( iostat .ne. iostat_success ) return

                if ( buffer(1:1) .eq. '$' ) then

                    str(itr:itr) = buffer(1:1)

                    itr = itr + 1

                    exit

                end if

            end do

            do

                read( &!
                unit   = unit   , &!
                iostat = iostat , &!
                iomsg  = iomsg    &!
                ) &!
                buffer

                if ( iostat .ne. iostat_success ) return

                if ( buffer(1:1) .eq. c_new_line ) then

                    call check_text_line( &!
                    text_line = str(1:itr) , &!
                    str       = header     , &!
                    iostat    = iostat     , &!
                    iomsg     = iomsg        &!
                    )

                    exit

                end if

                str(itr:itr) = buffer(1:1)

                itr = itr + 1

            end do

            if ( iostat .ne. iostat_success ) return

        end block &!
        read_header



        read_values: &!
        block

            itr = 1
            str = ''

            do

                read( &!
                unit   = unit   , &!
                iostat = iostat , &!
                iomsg  = iomsg    &!
                ) &!
                buffer

                if ( iostat .ne. iostat_success ) return

                if ( buffer(1:1) .eq. c_new_line ) exit

                str(itr:itr) = buffer(1:1)

                itr = itr + 1

            end do

            read( &!
            unit   = str(1:itr) , &!
            fmt    = *          , &!
            iostat = iostat     , &!
            iomsg  = iomsg        &!
            ) &!
            gmsh_msh_format%version   , &!
            gmsh_msh_format%file_type , &!
            gmsh_msh_format%data_size

            if ( iostat .ne. iostat_success ) return

        end block &!
        read_values



        read_footer: &!
        block

            itr   = 1
            iomsg = ''
            str   = ''

            do

                read( &!
                unit   = unit   , &!
                iostat = iostat , &!
                iomsg  = iomsg    &!
                ) &!
                buffer

                if ( iostat .ne. iostat_success ) return

                if ( buffer(1:1) .eq. '$' ) then

                    str(itr:itr) = buffer(1:1)

                    itr = itr + 1

                    exit

                end if

            end do

            do

                read( &!
                unit   = unit   , &!
                iostat = iostat , &!
                iomsg  = iomsg    &!
                ) &!
                buffer

                if ( iostat .ne. iostat_success ) return

                if ( buffer(1:1) .eq. c_new_line ) then

                    call check_text_line( &!
                    text_line = str(1:itr) , &!
                    str       = footer     , &!
                    iostat    = iostat     , &!
                    iomsg     = iomsg        &!
                    )

                    exit

                end if

                str(itr:itr) = buffer(1:1)

                itr = itr + 1

            end do

            if ( iostat .ne. iostat_success ) return

        end block &!
        read_footer

    end subroutine read_unformatted