Skip to content
Snippets Groups Projects
shpc_open.F90 1.40 KiB
module shpc_open_m

  implicit none

contains

  subroutine shpc_open(hshp, shpc_dir, rank, pszaccess)

    ! Libraries:
#ifdef HAVE_MPI
    use ezmpi, only: ezmpi_bcast
#endif
    USE jumble, only: new_unit
    use shapelib_03, only: shp_open_03

    use derived_types, only: shpc
    use read_field_indices_m, only: read_field_indices

    TYPE(shpc), intent(out):: hshp
    character(len = *), intent(in):: shpc_dir
    integer, intent(in):: rank ! should be 0 if not in MPI program
    character(len = *), intent(in):: pszaccess ! should be "rb" or "rb+"

    ! Local:
    integer unit
    character(len = 12) orientation

    !--------------------------------------------------------------------

    call shp_open_03(hshp%extremum, shpc_dir // "/extremum", pszaccess)
    call shp_open_03(hshp%outermost, shpc_dir // "/outermost_contour", &
         pszaccess)
    call shp_open_03(hshp%max_speed, shpc_dir // "/max_speed_contour", &
         pszaccess)
    call read_field_indices(hshp, rank)

    if (rank == 0) then
       call new_unit(unit)
       open(unit, file = shpc_dir // "/orientation.txt", status = "old", &
            action = "read", position = "rewind")
       read(unit, fmt = *) orientation
       close(unit)
       hshp%cyclone = trim(adjustl(orientation)) == "cyclones"
    end if

#ifdef HAVE_MPI
    call ezmpi_bcast(hshp%cyclone, root = 0)
#endif

  end subroutine shpc_open

end module shpc_open_m