test_surfile Program

Uses

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

Routines to handle Digital Surf binary format (.sur). Example of use


Calls

program~~test_surfile~~CallsGraph program~test_surfile test_surfile proc~init_scal init_scal program~test_surfile->proc~init_scal proc~read_surf~2 read_surf program~test_surfile->proc~read_surf~2 proc~scal2surf scal2surf program~test_surfile->proc~scal2surf proc~trans_surf_txt trans_surf_txt program~test_surfile->proc~trans_surf_txt proc~write_surf write_surf program~test_surfile->proc~write_surf proc~empty empty proc~init_scal->proc~empty proc~get_unit~2 get_unit proc~read_surf~2->proc~get_unit~2 proc~lower lower proc~read_surf~2->proc~lower proc~open_surffile open_surffile proc~read_surf~2->proc~open_surffile proc~sort_array2 sort_array2 proc~read_surf~2->proc~sort_array2 proc~trans_surf_tab trans_surf_tab proc~read_surf~2->proc~trans_surf_tab proc~f_c_string f_c_string proc~scal2surf->proc~f_c_string proc~c_f_string c_f_string proc~trans_surf_txt->proc~c_f_string proc~trans_surf_txt->proc~empty proc~trans_surf_txt->proc~get_unit~2 proc~write_surf->proc~scal2surf proc~build_surf build_surf proc~write_surf->proc~build_surf proc~write_surf->proc~get_unit~2 proc~write_surf->proc~lower proc~surf2scal surf2scal proc~write_surf->proc~surf2scal proc~write_surffile write_surffile proc~write_surf->proc~write_surffile proc~unit2iuc unit2IUc proc~build_surf->proc~unit2iuc proc~c_f_string->proc~empty proc~open_surffile->proc~trans_surf_txt proc~open_surffile->proc~get_unit~2 proc~open_surffile->proc~surf2scal proc~change_array_order change_array_order proc~sort_array2->proc~change_array_order proc~init_order init_order proc~sort_array2->proc~init_order proc~sort_array_integer_with_order sort_array_integer_with_order proc~sort_array2->proc~sort_array_integer_with_order proc~sort_array_real_with_order sort_array_real_with_order proc~sort_array2->proc~sort_array_real_with_order proc~surf2scal->proc~c_f_string proc~unit2iuf unit2IUf proc~surf2scal->proc~unit2iuf proc~trans_surf_tab->proc~unit2iuc proc~write_surffile->proc~get_unit~2 proc~sort_array_integer_with_order->proc~sort_array_integer_with_order proc~sort_array_real_with_order->proc~sort_array_real_with_order proc~unit2iuc->proc~unit2iuf

Variables

Type Attributes Name Initial
integer(kind=I4) :: i
integer(kind=I4) :: j
type(SCALE_SURF) :: scal

object SCALE_SURF, fortran type version

type(OBJ_SURF) :: surf

object OBJ_SURF, c type version

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

height array


Source Code

program test_surfile
use data_arch
use surfile
implicit none

real(kind=R8), dimension(:,:), allocatable :: tab  !! *height array*
type(SCALE_SURF) :: scal                           !! *object [[SCALE_SURF]], fortran type version*
type(OBJ_SURF)   :: surf                           !! *object [[OBJ_SURF]],         c type version*

integer(kind=I4) :: i, j

   ! --- reads a xyz ascii file, writes the corresponding "sur" file and dumps the header
   call init_scal(scal)                          ! creates an empty surface type (fortran form)

   call read_surf(nom_fic = "sur/600x300.dat", & !  in; three columns in ascii format : x y f(x,y); no header; tab separation
                    tab_s = tab,               & ! out; array containing the surface
                     scal = scal)                ! out; surface type containing some informations like length, width, etc.

   call write_surf(nom_fic = "out/600x300_dat_to_not-scaled.sur",  & !    in; filename of the ".sur" to be created
                     tab_s = tab,                                  & !    in; surface array
                      scal = scal)                                   ! inout; surface type

   call scal2surf(scal, surf)                                        !        surface type transformation: fortran form to c form
   call trans_surf_txt(surf = surf,                                & !    in; dumps the surface header ...
                    fichier = "out/600x300_dat_to_not-scaled.txt", & !    in; ... in a specified file ...
                        xyz = .false.)                               !    in; ... and no f(x,y) dump.

   deallocate(tab)

   ! --- reads a "sur" file, writes its scaled form in a "sur" file and a xyz file
   call read_surf(nom_fic = "sur/600x300.sur",  & !  in; Digital Surf format
                       mu = 1._R8,              & !  in; data will be centered
                       sq = 1._R8,              & !  in; data will be normalized (with the standard deviation)
                    tab_s = tab,                & ! out; array containing the surface
                     scal = scal)                 ! out; surface type containing some informations like length, width, etc.

   call write_surf(nom_fic = "out/600x300_resu_scaled.sur",       & !    in; filename of the ".sur" to be created
                     tab_s = tab,                                 & !    in; surface array
                      scal = scal)                                  ! inout; surface type

   call write_surf(nom_fic = "out/600x300_resu_scaled.dat",       & !    in; filename of the ascii ".dat" to be created
                     tab_s = tab,                                 & !    in; surface array
                      scal = scal)                                  ! inout; surface type

   deallocate(tab)

   ! --- creates a surface and writes a ".sur" file
   allocate(tab(600,300))
   do j = 1, 300
      do i = 1, 600
         tab(i, j) = 1.e+9*cos(6 *2*PI_R8*i/600)*cos(3 *2*PI_R8*j/300) +1.e+8
      enddo
   enddo

   call init_scal(scal = scal,      &           ! out; creates a surface type, containing ...
                    nx = 600,       &           !  in; ... the number of points along x ...
                    ny = 300,       &           !  in; ... the number of points along y ...
                    lx = 1.0e-3_R8, &           !  in; ... the length (default unit : m) ...
                    ly = 0.5e-3_R8, &           !  in; ... the width ...
                unit_z = 'Pa'       )           !  in; ... and the unit along z.

   call write_surf(nom_fic = "out/cos.sur",  &  !    in; filename of the ".sur" to be created
                     tab_s = tab,            &  !    in; surface array
                      scal = scal)              ! inout; surface type

   call read_surf(nom_fic = "out/cos.sur", &    !  in; Digital Surf format
                    tab_s = tab,           &    ! out; array containing the surface
                     scal = scal)               ! out; surface type containing some informations like length, width, etc.
   call scal2surf(scal, surf)                   !      surface type transformation: fortran form to c form
   call trans_surf_txt(surf = surf,          &  ! in; dumps the surface header ...
                    fichier = "out/cos.txt", &  ! in; ... in a specified file ...
                        xyz = .false.)          ! in; ... and no f(x,y) dump.

   deallocate( tab )

stop
endprogram test_surfile