read_esri_ascii_file Subroutine

public subroutine read_esri_ascii_file(filename_ascii_sub, ncols_sub, nrows_sub, cellsize_sub, val_array, x_array, y_array, read_nodata_flag)

Arguments

Type IntentOptional Attributes Name
character(len=*) :: filename_ascii_sub
integer :: ncols_sub
integer :: nrows_sub
real :: cellsize_sub
real :: val_array(ncols_sub,nrows_sub)
real :: x_array(ncols_sub,nrows_sub)
real :: y_array(ncols_sub,nrows_sub)
logical :: read_nodata_flag

Called by

proc~~read_esri_ascii_file~~CalledByGraph proc~read_esri_ascii_file read_esri_ascii_file proc~uemep_read_landuse_rivm_data uEMEP_read_landuse_rivm_data proc~uemep_read_landuse_rivm_data->proc~read_esri_ascii_file program~uemep uEMEP program~uemep->proc~uemep_read_landuse_rivm_data

Source Code

    subroutine read_esri_ascii_file(filename_ascii_sub, ncols_sub, nrows_sub, cellsize_sub, val_array, x_array, y_array, read_nodata_flag)
        character(*) :: filename_ascii_sub
        integer :: ncols_sub, nrows_sub
        real :: cellsize_sub
        real :: val_array(ncols_sub,nrows_sub)
        real :: x_array(ncols_sub,nrows_sub)
        real :: y_array(ncols_sub,nrows_sub)
        logical :: read_nodata_flag

        ! Local variables
        character(256) :: temp_str
        integer :: i, j, ii, jj
        integer :: ncols_sub_temp, nrows_sub_temp
        real :: xllcorner
        real :: yllcorner
        real :: NODATA_value
        integer :: unit_in=20

        open(unit_in, file=filename_ascii_sub,access='sequential', form='formatted', status='old', readonly)
        rewind(unit_in)
        read(unit_in,*) temp_str, ncols_sub_temp
        read(unit_in,*) temp_str, nrows_sub_temp
        read(unit_in,*) temp_str, xllcorner
        read(unit_in,*) temp_str, yllcorner
        read(unit_in,*) temp_str, cellsize_sub
        if (read_nodata_flag) read(unit_in,*) temp_str, NODATA_value
        if (ncols_sub .ne. ncols_sub_temp .or. nrows_sub .ne. nrows_sub_temp) then
            write(unit_logfile,*) 'ERROR: Subgrid columns or rows do not match. Columns: ', ncols_sub, ncols_sub_temp, 'Rows: ', nrows_sub, nrows_sub_temp
            stop 1
        end if
        read(unit_in,*) ((val_array(ii,jj), ii = 1, ncols_sub), jj = nrows_sub, 1, -1)
        close(unit_in)

        ! Set position arrays
        do i = 1, ncols_sub
            do j = 1, nrows_sub
                x_array(i,j) = xllcorner+cellsize_sub/2.0 + (i-1)*cellsize_sub
                y_array(i,j) = yllcorner+cellsize_sub/2.0 + (j-1)*cellsize_sub
            end do
        end do
    end subroutine read_esri_ascii_file