write_3d_r4_raw Subroutine

private subroutine write_3d_r4_raw(array, filename, overwrite)

Uses

write 3D array of float32's to disk as raw binary data

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(in) :: array(:,:,:)

array to write to disk

character(len=*), intent(in) :: filename

filename to save array as

logical, intent(in) :: overwrite

overwrite flag


Source Code

        subroutine write_3d_r4_raw(array, filename, overwrite)
        !! write 3D array of float32's to disk as raw binary data
            use constants, only : sp

            !> array to write to disk
            real(kind=sp), intent(IN) :: array(:, :, :)
            !> filename to save array as
            character(*),  intent(IN) :: filename
            !> overwrite flag
            logical,       intent(IN) :: overwrite

            integer :: u
            character(len=:), allocatable :: file

            if(check_file(filename) .and. .not. overwrite)then
                file = get_new_file_name(filename)
            else
                file = filename
            end if
            open(newunit=u,file=file,access='stream',status='REPLACE',form='unformatted')
            write(u) array
            close(u)

        end subroutine write_3d_r4_raw