read_map Subroutine

public subroutine read_map(filename, map)

Arguments

Type IntentOptional AttributesName
character(len=512), intent(in) :: filename
real(kind=xp), intent(inout), dimension(:,:), allocatable:: map

Called by

proc~~read_map~~CalledByGraph proc~read_map read_map program~rohsa ROHSA program~rohsa->proc~read_map

Contents

Source Code


Source Code

  subroutine read_map(filename, map)
    implicit none

    integer           :: ios=0, i
    integer           :: y,x 
    real(xp)          :: val
    integer           :: ny,nx
    integer           :: nl
    character(len=512), intent(in) :: filename
    real(xp), intent(inout), dimension(:,:), allocatable :: map

    open(unit=11, file=filename, action="read", status="old", iostat=ios)
    if (ios /= 0) stop "opening file error"
    
    read(11,fmt=*) ny, nx
    nl = ny*nx

    allocate(map(ny,nx))

    do i=1,nl
       read(11,fmt=*) y, x, val
       map(y+1,x+1) = val
    enddo
    
    close(11)
  end subroutine read_map