surfile Module

Routines to handle Digital Surf binary format (.sur)


Uses

  • module~~surfile~~UsesGraph module~surfile surfile iso_c_binding iso_c_binding module~surfile->iso_c_binding module~data_arch data_arch module~surfile->module~data_arch module~miscellaneous miscellaneous module~surfile->module~miscellaneous module~sort_arrays sort_arrays module~surfile->module~sort_arrays iso_fortran_env iso_fortran_env module~data_arch->iso_fortran_env module~miscellaneous->module~data_arch module~sort_arrays->module~data_arch

Used by

  • module~~surfile~~UsedByGraph module~surfile surfile program~test_surfile test_surfile program~test_surfile->module~surfile

Variables

Type Visibility Attributes Name Initial
integer(kind=4), private, parameter :: SURF_DAT = 1

‘.dat’ format, txt

integer(kind=4), private, parameter :: SURF_SUR = 2

‘.sur’ format, binary


Derived Types

type, public ::  OBJ_SURF

C like surface object: header and heights

Read more…

Components

Type Visibility Attributes Name Initial
real(kind=C_FLOAT), public :: XOffset
real(kind=C_FLOAT), public :: YOffset
real(kind=C_FLOAT), public :: ZOffset
integer(kind=C_SHORT), public :: absolute
integer(kind=C_SHORT), public :: acquisition
character(kind=C_CHAR, len=1), public, dimension(128) :: client_zone
integer(kind=C_SHORT), public :: comment_size
integer(kind=C_SHORT), public :: day
integer(kind=C_SHORT), public :: dayof
real(kind=C_FLOAT), public :: dx
character(kind=C_CHAR, len=1), public, dimension( 16) :: dx_unit
real(kind=C_FLOAT), public :: dy
character(kind=C_CHAR, len=1), public, dimension( 16) :: dy_unit
real(kind=C_FLOAT), public :: dz
character(kind=C_CHAR, len=1), public, dimension( 16) :: dz_unit
integer(kind=C_SHORT), public :: format
integer(kind=C_SHORT), public :: hours
integer(kind=C_SHORT), public :: imprint
integer(kind=C_SHORT), public :: inversion
integer(kind=C_SHORT), public :: leveling
integer(kind=C_SHORT), public :: material_code
real(kind=C_FLOAT), public :: measurement_duration
integer(kind=C_SHORT), public :: minutes
integer(kind=C_SHORT), public :: month
integer(kind=C_SHORT), public :: nobjects
integer(kind=C_INT), public :: nofpoints
character(kind=C_CHAR, len=1), public, dimension( 30) :: object_name
character(kind=C_CHAR, len=1), public, dimension( 12) :: obsolete
character(kind=C_CHAR, len=1), public, dimension( 10) :: obsolete2
character(kind=C_CHAR, len=1), public, dimension( 30) :: operator_name
integer(kind=C_SHORT), public :: pointsize
integer(kind=C_SHORT), public :: private_size
integer(kind=C_SHORT), public :: range
character(kind=C_CHAR, len=1), public, dimension( 8) :: reserved
character(kind=C_CHAR, len=1), public, dimension( 34) :: reservedzone
integer(kind=C_SHORT), public :: seconds
character(kind=C_CHAR, len=1), public, dimension( 12) :: signature
integer(kind=C_SHORT), public :: special_points
integer(kind=C_SHORT), public :: type
integer(kind=C_INT), public, allocatable :: val(:)

heights

integer(kind=C_SHORT), public :: version
character(kind=C_CHAR, len=1), public, dimension( 16) :: xaxis
character(kind=C_CHAR, len=1), public, dimension( 16) :: xlength_unit
integer(kind=C_INT), public :: xres
real(kind=C_FLOAT), public :: xunit_ratio
character(kind=C_CHAR, len=1), public, dimension( 16) :: yaxis
integer(kind=C_SHORT), public :: year
character(kind=C_CHAR, len=1), public, dimension( 16) :: ylength_unit
integer(kind=C_INT), public :: yres
real(kind=C_FLOAT), public :: yunit_ratio
character(kind=C_CHAR, len=1), public, dimension( 16) :: zaxis
character(kind=C_CHAR, len=1), public, dimension( 16) :: zlength_unit
integer(kind=C_INT), public :: zmax
integer(kind=C_INT), public :: zmin
real(kind=C_FLOAT), public :: zunit_ratio

type, public ::  SCALE_SURF

Fortran typed surface object: header, dimensions, mean and std

Read more…

Components

Type Visibility Attributes Name Initial
real(kind=R4), public :: XOffset
real(kind=R4), public :: YOffset
real(kind=R4), public :: ZOffset
integer(kind=2), public :: absolute
integer(kind=2), public :: acquisition
character(len=128), public :: client_zone
integer(kind=2), public :: comment_size
integer(kind=2), public :: day
integer(kind=2), public :: dayof
real(kind=R4), public :: dx
character(len=16), public :: dx_unit
real(kind=R4), public :: dy
character(len=16), public :: dy_unit
real(kind=R4), public :: dz
character(len=16), public :: dz_unit
integer(kind=2), public :: format
integer(kind=2), public :: hours
integer(kind=2), public :: imprint
integer(kind=2), public :: inversion
integer(kind=2), public :: leveling
real(kind=R8), public :: lx

surface length

real(kind=R8), public :: ly

surface width

real(kind=R8), public :: lz

surface height (max -min)

integer(kind=2), public :: material_code
real(kind=R4), public :: measurement_duration
integer(kind=2), public :: minutes
integer(kind=2), public :: month
real(kind=R8), public :: mu

surface mean height

integer(kind=2), public :: nobjects
integer(kind=I4), public :: nofpoints
character(len=30), public :: object_name
character(len=12), public :: obsolete
character(len=10), public :: obsolete2
character(len=30), public :: operator_name
integer(kind=2), public :: pointsize
integer(kind=2), public :: private_size
integer(kind=2), public :: range
character(len=8), public :: reserved
character(len=34), public :: reservedzone
integer(kind=2), public :: seconds
real(kind=R8), public :: si

surface mean height

character(len=12), public :: signature
integer(kind=2), public :: special_points
integer(kind=2), public :: type
integer(kind=2), public :: version
character(len=16), public :: xaxis
character(len=16), public :: xlength_unit
integer(kind=I4), public :: xres
real(kind=R4), public :: xunit_ratio
character(len=16), public :: yaxis
integer(kind=2), public :: year
character(len=16), public :: ylength_unit
integer(kind=I4), public :: yres
real(kind=R4), public :: yunit_ratio
character(len=16), public :: zaxis
character(len=16), public :: zlength_unit
integer(kind=I4), public :: zmax
integer(kind=I4), public :: zmin
real(kind=R4), public :: zunit_ratio

Functions

private function lower(s1) result(s2)

Converts uppercase to lowercase, adapted from here

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: s1

string to transform to lower case

Return Value character(len=len(s1))

result: same string but each character is lower case

public function unit2IUc(string) result(met)

Convert a C type unit string into value (m)

Arguments

Type IntentOptional Attributes Name
character(kind=C_CHAR, len=1), intent(in), dimension(:) :: string

Return Value real(kind=R8)

public function unit2IUf(string) result(met)

Convert a unit string into value (m)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: string

Return Value real(kind=R8)


Subroutines

private subroutine build_surf(surf, tab)

Creates an object OBJ_SURF from an array

Arguments

Type IntentOptional Attributes Name
type(OBJ_SURF), intent(inout) :: surf

resulting object OBJ_SURF

real(kind=R8), intent(in), dimension(1:surf%xres, 1:surf%yres) :: tab

private subroutine c_f_string(cs, fs, lngth_s)

Converts a C string to a Fortran string

Read more…

Arguments

Type IntentOptional Attributes Name
character(kind=C_CHAR, len=1), intent(in), dimension(:) :: cs

C string

character(len=*), intent(out) :: fs

Fortran string

integer(kind=I4), intent(out) :: lngth_s

resulting Fortran string length

public subroutine empty(charinout)

Just empties a string

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(inout) :: charinout

private subroutine f_c_string(fs, cs)

Converts a Fortran string to a C string

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: fs

fortran string

character(kind=C_CHAR, len=1), intent(out), dimension(:) :: cs

resulting C string

public subroutine init_scal(scal, nx, ny, lx, ly, unit_z)

OBJ_SURF initialization, every unit is m

Arguments

Type IntentOptional Attributes Name
type(SCALE_SURF), intent(out) :: scal

object SCALE_SURF

integer(kind=I4), intent(in), optional :: nx
integer(kind=I4), intent(in), optional :: ny
real(kind=R8), intent(in), optional :: lx
real(kind=R8), intent(in), optional :: ly
character(len=*), intent(in), optional :: unit_z

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

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

Read more…

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

public subroutine read_surf(nom_fic, mu, sq, tab_s, scal)

Subroutine that opens a surface file .sur or .dat

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: nom_fic

file name

real(kind=R8), intent(in), optional :: mu

desired mean

real(kind=R8), intent(in), optional :: sq

desired height standard deviation

real(kind=R8), intent(out), dimension(:,:), allocatable :: tab_s

height array

type(SCALE_SURF), intent(out) :: scal

object SCALE_SURF

public subroutine scal2surf(scal, surf)

Transform a SCALE_SURF object into a OBJ_SURF object

Arguments

Type IntentOptional Attributes Name
type(SCALE_SURF), intent(in) :: scal

object SCALE_SURF

type(OBJ_SURF), intent(out) :: surf

object OBJ_SURF

public subroutine surf2scal(surf, scal)

Transform a OBJ_SURF object into a SCALE_SURF object

Arguments

Type IntentOptional Attributes Name
type(OBJ_SURF), intent(in) :: surf

object OBJ_SURF

type(SCALE_SURF), intent(out) :: scal

object SCALE_SURF

private subroutine trans_surf_tab(surf, tab)

Write the heights of an OBJ_SURF object into a 2D array

Arguments

Type IntentOptional Attributes Name
type(OBJ_SURF), intent(inout) :: surf

object OBJ_SURF that contains the heights

real(kind=R8), intent(out), dimension(:, :), allocatable :: tab

height array

public subroutine trans_surf_txt(surf, fichier, xyz)

Writes an OBJ_SURF object in a text file

Read more…

Arguments

Type IntentOptional Attributes Name
type(OBJ_SURF), intent(in) :: surf

object OBJ_SURF

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

text file to write

logical(kind=I4), intent(in) :: xyz

whether to also write the heights (maybe huge)

public subroutine write_surf(nom_fic, tab_s, scal)

Writes a height array into a surface file .sur or .dat

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: nom_fic

file name

real(kind=R8), intent(in), dimension(1:scal%xres, 1:scal%yres) :: tab_s
type(SCALE_SURF), intent(inout) :: scal

object SCALE_SURF

private subroutine write_surffile(fichier, surf)

Write an object OBJ_SURF in a file

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: fichier

file to be written

type(OBJ_SURF), intent(inout) :: surf

object OBJ_SURF to write