Subroutine that opens a .sur
file and transfers it contents into an object OBJ_SURF
By default here, the heights are not written with dump=.true.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | fichier | file to be read |
||
type(OBJ_SURF), | intent(out) | :: | surf | object that will contain the file infos and heights |
||
type(SCALE_SURF), | intent(out) | :: | scal | object SCALE_SURF |
||
logical(kind=I4), | intent(in), | optional | :: | dump | whether to transform the data in a text file |
subroutine open_surffile(fichier, surf, scal, dump)
implicit none
character(len=*), intent(in) :: fichier !! *file to be read*
type(OBJ_SURF), intent(out) :: surf !! *object that will contain the file infos and heights*
type(SCALE_SURF), intent(out) :: scal !! *object [[SCALE_SURF]]*
logical(kind=I4), optional, intent(in) :: dump !! *whether to transform the data in a text file*
integer(kind=I4) :: i, k
real(kind=R8) :: scal_x, scal_y, scal_z
character(kind=C_CHAR) :: charact
call get_unit(k)
open(k , file=trim(fichier), & !
form='unformatted', & !
access="stream", & ! beware the "frecord-marker" in other modes
action="read", & !
position="rewind", & !
convert='little_endian',& !
status='old')
read(k) surf%signature, surf%format, surf%nobjects, surf%version, surf%type, surf%object_name, &
surf%operator_name, surf%material_code, surf%acquisition, surf%range, surf%special_points, &
surf%absolute, surf%reserved, surf%pointsize, surf%zmin, surf%zmax, surf%xres, surf%yres, &
surf%nofpoints, surf%dx, surf%dy, surf%dz, surf%xaxis, surf%yaxis, surf%zaxis, surf%dx_unit, &
surf%dy_unit, surf%dz_unit, surf%xlength_unit, surf%ylength_unit, surf%zlength_unit, &
surf%xunit_ratio, surf%yunit_ratio, surf%zunit_ratio, surf%imprint, surf%inversion, surf%leveling, &
surf%obsolete, surf%seconds, surf%minutes, surf%hours, surf%day, surf%month, surf%year, surf%dayof, &
surf%measurement_duration, surf%obsolete2, surf%comment_size, surf%private_size, surf%client_zone, &
surf%XOffset, surf%YOffset, surf%ZOffset, surf%reservedzone
do i = 1, surf%comment_size
read(k) charact
enddo
allocate( surf%val(1:surf%nofpoints) )
do i = 1, surf%nofpoints
read(k) surf%val(i)
enddo
close(k)
call surf2scal(surf, scal)
if (present(dump).and.dump) call trans_surf_txt(surf, trim(fichier)//'.txt', xyz=.false.)
return
endsubroutine open_surffile