open_surffile Subroutine

private subroutine open_surffile(fichier, surf, scal, dump)

Note

Subroutine that opens a .sur file and transfers it contents into an object OBJ_SURF

Warning

By default here, the heights are not written with dump=.true.

Arguments

Type IntentOptional 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


Calls

proc~~open_surffile~~CallsGraph proc~open_surffile open_surffile proc~get_unit~2 get_unit proc~open_surffile->proc~get_unit~2 proc~surf2scal surf2scal proc~open_surffile->proc~surf2scal proc~trans_surf_txt trans_surf_txt proc~open_surffile->proc~trans_surf_txt proc~c_f_string c_f_string proc~surf2scal->proc~c_f_string proc~unit2iuf unit2IUf proc~surf2scal->proc~unit2iuf proc~trans_surf_txt->proc~get_unit~2 proc~trans_surf_txt->proc~c_f_string proc~empty empty proc~trans_surf_txt->proc~empty proc~c_f_string->proc~empty

Called by

proc~~open_surffile~~CalledByGraph proc~open_surffile open_surffile proc~read_surf~2 read_surf proc~read_surf~2->proc~open_surffile program~test_surfile test_surfile program~test_surfile->proc~read_surf~2

Source Code

   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