Extract the grid size from the grid file header
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | file_handler | (input)file handling unit |
||
type(extent), | intent(out) | :: | dims | Extent of the domain:imx,jmx,kmx |
subroutine extract_grid_size(file_handler, dims)
!< Extract the grid size from the grid file header
!
! We assume that the grid could be in 1 or 2 dimensions. If
! the grid is in 1 dimension, jmx will be set to 1.
! We assume that at least one number is specified in the
! header, i.e., the grid has atleast one dimension.
!-----------------------------------------------------------
implicit none
integer, intent(in) :: file_handler
!< (input)file handling unit
character(len=STRING_BUFFER_LENGTH) :: header
!< store header
type(extent), intent(out) :: dims
!< Extent of the domain:imx,jmx,kmx
integer :: ios ! io operation status
DebugCall('extract_grid_size')
read(file_handler, '(A)', iostat=ios) header
if (ios /= 0) then
print *, 'Error while reading grid file header.'
print *, 'Current buffer length is set to: ', &
STRING_BUFFER_LENGTH
!stop
end if
! Try to read constants corresponding to two dimensions.
read(header, *, iostat=ios) dims%imx, dims%jmx, dims%kmx
if (ios /= 0) then
print*, "Not able to read dimension from the grid file"
print*, "Make sure you provdie 3D grid"
Fatal_error
end if
end subroutine extract_grid_size