read_cube Subroutine

public subroutine read_cube(filename, cube)

Arguments

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

Called by

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

Contents

Source Code


Source Code

  subroutine read_cube(filename, cube)
    implicit none
    integer           :: ios=0, i
    integer           :: v, y, x 
    real(xp)          :: val
    integer           :: nv, ny, nx !cube dimension
    integer           :: nl
    character(len=512), intent(in) :: filename
    real(xp), intent(inout), dimension(:,:,:), allocatable :: cube

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

    allocate(cube(nv,ny,nx))

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