read_gmsh_msh1_file_kernel Subroutine

private subroutine read_gmsh_msh1_file_kernel(mesh_data, file_unit)

Arguments

Type IntentOptional Attributes Name
type(gmsh_msh1_data_type), intent(inout) :: mesh_data

The read data will be stored in this argument

integer, intent(in) :: file_unit

Calls

proc~~read_gmsh_msh1_file_kernel~~CallsGraph proc~read_gmsh_msh1_file_kernel read_gmsh_msh1_file_kernel proc~initialize_gmsh_msh1_node initialize_gmsh_msh1_node proc~read_gmsh_msh1_file_kernel->proc~initialize_gmsh_msh1_node proc~is_iostat_failure is_iostat_failure proc~read_gmsh_msh1_file_kernel->proc~is_iostat_failure proc~is_iostat_success is_iostat_success proc~read_gmsh_msh1_file_kernel->proc~is_iostat_success proc~is_stat_failure is_stat_failure proc~read_gmsh_msh1_file_kernel->proc~is_stat_failure proc~read_gmsh_msh1_element read_gmsh_msh1_element proc~read_gmsh_msh1_file_kernel->proc~read_gmsh_msh1_element proc~read_gmsh_msh1_header_footer read_gmsh_msh1_header_footer proc~read_gmsh_msh1_file_kernel->proc~read_gmsh_msh1_header_footer proc~read_gmsh_msh1_node read_gmsh_msh1_node proc~read_gmsh_msh1_file_kernel->proc~read_gmsh_msh1_node proc~read_gmsh_msh1_number_of_items read_gmsh_msh1_number_of_items proc~read_gmsh_msh1_file_kernel->proc~read_gmsh_msh1_number_of_items proc~initialize_gmsh_msh1_node_number initialize_gmsh_msh1_node_number proc~initialize_gmsh_msh1_node->proc~initialize_gmsh_msh1_node_number proc~read_gmsh_msh1_element->proc~is_iostat_failure proc~read_gmsh_msh1_element->proc~is_stat_failure proc~clear_msg clear_msg proc~read_gmsh_msh1_element->proc~clear_msg proc~initialize_gmsh_msh1_element initialize_gmsh_msh1_element proc~read_gmsh_msh1_element->proc~initialize_gmsh_msh1_element proc~read_gmsh_msh1_node->proc~is_iostat_failure proc~read_gmsh_msh1_node->proc~clear_msg proc~read_gmsh_msh1_number_of_items->proc~is_iostat_failure proc~read_gmsh_msh1_number_of_items->proc~is_iostat_success

Called by

proc~~read_gmsh_msh1_file_kernel~~CalledByGraph proc~read_gmsh_msh1_file_kernel read_gmsh_msh1_file_kernel proc~read_gmsh_msh1_file read_gmsh_msh1_file proc~read_gmsh_msh1_file->proc~read_gmsh_msh1_file_kernel

Variables

Type Visibility Attributes Name Initial
integer, private :: number_of_elements

the number of elements in the mesh

integer, private :: number_of_nodes

the number of nodes in the mesh

character(len=2048), private :: text_line

A string for reading a line of text.
The length of this string is 2048,
which is a provisional value.


Source Code

    subroutine read_gmsh_msh1_file_kernel(mesh_data, file_unit)

        !> The read data will be stored in this argument
        type(gmsh_msh1_data_type), intent(inout) :: mesh_data

        integer, intent(in) :: file_unit



        !> the number of elements in the mesh
        integer :: number_of_elements

        !> the number of nodes in the mesh
        integer :: number_of_nodes

        !> version: experimental
        !> A string for reading a line of text.<br>
        !> The length of this string is 2048,<br>
        !> which is a provisional value.
        character(len=2048) :: text_line



        read_nod_section_header: &!
        do

            call read_gmsh_msh1_header_footer( &!
            file_unit     = file_unit                            , &!
            header_footer =                nod_section_header(:) , &!
            text_line     = text_line(:)                         , &!
            status        = mesh_data%status                     , &!
            flag          = mesh_data%flag_nod_section_header      &!
            )

            if ( mesh_data%flag_nod_section_header   ) exit
            if ( is_iostat_success(mesh_data%status) ) cycle

            return

        end do &!
        read_nod_section_header



        read_number_of_nodes: &!
        block

            call read_gmsh_msh1_number_of_items( &!
            file_unit       = file_unit                      , &!
            item_name       = 'number_of_nodes'              , &!
            text_line       = text_line(:)                   , &!
            number_of_items = number_of_nodes                , &!
            status          = mesh_data%status               , &!
            flag            = mesh_data%flag_number_of_nodes   &!
            )

            if ( .not. mesh_data%flag_number_of_nodes ) return

        end block &!
        read_number_of_nodes



        read_nodes: &!
        block

            integer :: itr_node



            if ( allocated(mesh_data%node) ) then

                deallocate(&!
                mesh_data%node                       , &!
                stat   = mesh_data%status%err%code   , &!
                errmsg = mesh_data%status%err%msg(:)   &!
                )

                if ( is_stat_failure(mesh_data%status) ) return

            end if

            mesh_data%flag_deallocation_nodes = .true.



            allocate( &!
            mesh_data%node(number_of_nodes)      , &!
            stat   = mesh_data%status%err%code   , &!
            errmsg = mesh_data%status%err%msg(:)   &!
            )

            if ( is_stat_failure(mesh_data%status) ) return

            mesh_data%flag_allocation_nodes = .true.

            call initialize_gmsh_msh1_node( mesh_data%node(:) )


            do itr_node = 1, number_of_nodes

                call read_gmsh_msh1_node( &!
                file_unit = file_unit                , &!
                itr_node  =                itr_node  , &!
                node      = mesh_data%node(itr_node) , &!
                status    = mesh_data%status           &!
                )

                if ( is_iostat_failure(mesh_data%status) ) return

            end do

            mesh_data%flag_reading_nodes = .true.

        end block &!
        read_nodes



        read_nod_section_footer: &!
        block

            call read_gmsh_msh1_header_footer( &!
            file_unit     = file_unit                            , &!
            header_footer =                nod_section_footer(:) , &!
            text_line     = text_line(:)                         , &!
            status        = mesh_data%status                     , &!
            flag          = mesh_data%flag_nod_section_footer      &!
            )

            if ( .not. mesh_data%flag_nod_section_footer ) return

        end block &!
        read_nod_section_footer



        read_elm_section_header: &!
        do

            call read_gmsh_msh1_header_footer( &!
            file_unit     = file_unit                            , &!
            header_footer =                elm_section_header(:) , &!
            text_line     = text_line(:)                         , &!
            status        = mesh_data%status                     , &!
            flag          = mesh_data%flag_elm_section_header      &!
            )

            if ( mesh_data%flag_elm_section_header   ) exit
            if ( is_iostat_success(mesh_data%status) ) cycle

            return

        end do &!
        read_elm_section_header



        read_number_of_elements: &!
        block

            call read_gmsh_msh1_number_of_items( &!
            file_unit       = file_unit                         , &!
            item_name       = 'number_of_elements'              , &!
            text_line       = text_line(:)                      , &!
            status          = mesh_data%status                  , &!
            number_of_items = number_of_elements                , &!
            flag            = mesh_data%flag_number_of_elements   &!
            )

            if ( .not. mesh_data%flag_number_of_elements ) return

        end block &!
        read_number_of_elements



        read_elements: &!
        block

            integer :: itr_element



            if ( allocated(mesh_data%element) ) then

                deallocate(&!
                mesh_data%element                    , &!
                stat   = mesh_data%status%err%code   , &!
                errmsg = mesh_data%status%err%msg(:)   &!
                )

                if ( is_stat_failure(mesh_data%status) ) return

            end if

            mesh_data%flag_deallocation_elements = .true.



            allocate( &!
            mesh_data%element(number_of_elements) , &!
            stat   = mesh_data%status%err%code    , &!
            errmsg = mesh_data%status%err%msg(:)    &!
            )

            if ( is_stat_failure(mesh_data%status) ) return

            mesh_data%flag_allocation_elements = .true.



            if ( number_of_elements .gt. 0 ) then

                do itr_element = 1, number_of_elements

                    call read_gmsh_msh1_element( &!
                    file_unit   = file_unit                       , &!
                    itr_element =                   itr_element   , &!
                    text_line   = text_line(:)                    , &!
                    element     = mesh_data%element(itr_element)  , &!
                    status      = mesh_data%status                , &!
                    flag        = mesh_data%flag_reading_elements   &!
                    )

                    if ( is_iostat_failure (mesh_data%status)  ) return
                    if ( is_stat_failure   (mesh_data%status)  ) return
                    if ( .not. mesh_data%flag_reading_elements ) return

                end do

            else

                mesh_data%flag_reading_elements = .true.

            end if

        end block &!
        read_elements



        read_elm_section_footer: &!
        block

            call read_gmsh_msh1_header_footer( &!
            file_unit     = file_unit                            , &!
            header_footer =                elm_section_footer(:) , &!
            text_line     = text_line(:)                         , &!
            status        = mesh_data%status                     , &!
            flag          = mesh_data%flag_elm_section_footer      &!
            )

        end block &!
        read_elm_section_footer

    end subroutine read_gmsh_msh1_file_kernel