Writes a height array into a surface file .sur
or .dat
Type | Intent | Optional | 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 |
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