SPEED
READ_FILEXYZ.f90
Go to the documentation of this file.
1! Copyright (C) 2012 The SPEED FOUNDATION
2! Author: Ilario Mazzieri
3!
4! This file is part of SPEED.
5!
6! SPEED is free software; you can redistribute it and/or modify it
7! under the terms of the GNU Affero General Public License as
8! published by the Free Software Foundation, either version 3 of the
9! License, or (at your option) any later version.
10!
11! SPEED is distributed in the hope that it will be useful, but
12! WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14! Affero General Public License for more details.
15!
16! You should have received a copy of the GNU Affero General Public License
17! along with SPEED. If not, see <http://www.gnu.org/licenses/>.
18
33
34 subroutine read_filexyz(filec,num_nodes,num_tria, &
35 x,y,z,&
36 node1,node2,node3,&
37 max_length)
38
39 implicit none
40
41 integer*4 :: num_nodes,num_tria
42 integer*4 :: i
43 integer*4 :: trash
44 real*8, dimension(num_nodes) :: x,y,z
45 integer*4, dimension(num_tria) :: node1,node2,node3
46 character*70 :: filec
47 integer*4 :: ileft,iright
48 integer*4 :: status
49 character*100000 :: input_line
50 real*8 :: length_edge1,length_edge2,length_edge3
51 real*8 :: max_edge_length,max_length
52
53 max_length = 0.0d0
54
55 open(20,file=filec)
56 read(20,'(A)',iostat = status) input_line
57 ileft = 1
58 iright = len(input_line)
59 read(input_line(ileft:iright),*) num_nodes,num_tria
60
61 do i = 1,num_nodes
62 read(20,'(A)',iostat = status) input_line
63 if (status.ne.0) exit
64 ileft = 1
65 iright = len(input_line)
66 read(input_line(ileft:iright),*)trash,x(i),y(i),z(i)
67 enddo
68
69 do i = 1,num_tria
70 read(20,'(A)',iostat = status) input_line
71 if (status.ne.0) exit
72 ileft = 1
73 iright = len(input_line)
74 read(input_line(ileft:iright),*)trash,node1(i),node2(i),node3(i)
75 enddo
76
77 close(20)
78
79 ! compute max tria edge length
80
81 do i = 1,num_tria
82
83 length_edge1 = ( x(node1(i)) - x(node2(i)) )**2 + ( y(node1(i)) - y(node2(i)) )**2
84 length_edge2 = ( x(node2(i)) - x(node3(i)) )**2 + ( y(node2(i)) - y(node3(i)) )**2
85 length_edge3 = ( x(node3(i)) - x(node1(i)) )**2 + ( y(node3(i)) - y(node1(i)) )**2
86
87 max_edge_length = max(length_edge1,length_edge2,length_edge3)
88
89 if (max_length.lt.max_edge_length) then
90 max_length = max_edge_length
91 endif
92
93 enddo
94
95 max_length = sqrt(max_length)
96
97 return
98
99 end subroutine read_filexyz
100
subroutine read_filexyz(filec, num_nodes, num_tria, x, y, z, node1, node2, node3, max_length)
Reads mesh of triangular elements (topography or alluvial basin)