write_surf Subroutine

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


Calls

proc~~write_surf~~CallsGraph proc~write_surf write_surf proc~build_surf build_surf proc~write_surf->proc~build_surf proc~get_unit~2 get_unit proc~write_surf->proc~get_unit~2 proc~lower lower proc~write_surf->proc~lower proc~scal2surf scal2surf proc~write_surf->proc~scal2surf 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~f_c_string f_c_string proc~scal2surf->proc~f_c_string proc~c_f_string c_f_string proc~surf2scal->proc~c_f_string proc~unit2iuf unit2IUf proc~surf2scal->proc~unit2iuf proc~write_surffile->proc~get_unit~2 proc~empty empty proc~c_f_string->proc~empty proc~unit2iuc->proc~unit2iuf

Called by

proc~~write_surf~~CalledByGraph proc~write_surf write_surf program~test_surfile test_surfile program~test_surfile->proc~write_surf

Source Code

   subroutine write_surf(nom_fic, tab_s, scal)
   !! Writes a height array into a surface file ```.sur``` or ```.dat```
   implicit none
   character(len=*), intent(in)    :: nom_fic   !! *file name*
   type(SCALE_SURF), intent(inout) :: scal      !! *object [[SCALE_SURF]]*
   real(kind=R8), dimension(1:scal%xres, 1:scal%yres), intent(in) :: tab_s

      character(len=3) :: ext
      integer(kind=I4) :: style, i, j, k
      type(OBJ_SURF)   :: surf_s
      real(kind=R8)    :: dx, dy

      i   = len_trim(nom_fic)
      ext = lower( nom_fic(i-2:i) )

      if (ext == 'dat') style = SURF_DAT
      if (ext == 'sur') style = SURF_SUR

      select case (style)
         case (SURF_SUR)
            call scal2surf(scal, surf_s)
            call build_surf(surf=surf_s, tab=tab_s(1:scal%xres, 1:scal%yres))
            surf_s%comment_size  = 0 ! to increase compatibility with mountains
            surf_s%material_code = 1 ! to increase compatibility with mountains
            surf_s%type          = 2 ! to increase compatibility with mountains
            surf_s%range         = 0 ! to increase compatibility with mountains
            surf_s%imprint       = 0 ! to increase compatibility with mountains
            call write_surffile(fichier=trim(nom_fic), surf=surf_s)
            call surf2scal(surf_s, scal)

         case (SURF_DAT)
            dx = scal%dx
            dy = scal%dy
            call get_unit(k)
            open(k, file=trim(nom_fic))
               do i = 1, scal%xres
                  do j = 1, scal%yres
                     write(k,*) (i-1)*dx, (j-1)*dy, tab_s(i, j)
                  enddo
               enddo
            close(k)
      endselect

   return
   endsubroutine write_surf