SPEED
GET_NEAREST_NODE_PGM.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine get_nearest_node_pgm (nloc, xs, ys, zs, xt, yt, zt, nt, dist_min
 Computes the nearest node with respet to (xt,yt,zt) starting from a given elevation.
 

Function/Subroutine Documentation

◆ get_nearest_node_pgm()

subroutine get_nearest_node_pgm ( integer*4  nloc,
real*8, dimension(nloc)  xs,
real*8, dimension(nloc)  ys,
real*8, dimension(nloc)  zs,
real*8  xt,
real*8  yt,
real*8  zt,
integer*4  nt,
real*8  dist_min 
)

Computes the nearest node with respet to (xt,yt,zt) starting from a given elevation.


Author
Ilario Mazzieri
Date
September, 2013
Version
1.0
Parameters
[in]nlocnumber of local nodes
[in]xsvertex x-coordinate of local nodes
[in]ysvertex y-coordinate of local nodes
[in]zsvertex z-coordinate of local nodes
[in]xtx-coor current vertex
[in]yty-coor current vertex
[in]ztz-coor current vertex
[in]elevationz-value from wich we start the search
[out]ntindex of the nearest node from (xt,yt,zt)
[out]dist_minminimal distance from (xt,yt,zt)

Definition at line 35 of file GET_NEAREST_NODE_PGM.f90.

36
37 implicit none
38
39 integer*4 :: i, nloc, nt
40
41 real*8 :: xt,yt,zt
42 real*8 :: elevation
43 real*8 :: dist,dist_min
44
45 real*8, dimension(nloc) :: xs, ys, zs
46
47 dist_min = 1.0d30
48 nt = 1
49
50 do i = 1,nloc
51
52 if (zs(i) .gt. elevation) then
53
54 dist = dsqrt((xs(i) - xt)*(xs(i) - xt) + (ys(i) - yt)*(ys(i) - yt) + (zs(i) - zt)*(zs(i) - zt))
55
56 if (dist .lt. dist_min) then
57 dist_min = dist; nt = i
58 endif
59
60 endif
61
62 enddo
63
64 return

Referenced by find_monitor_position(), and read_system_position().

Here is the caller graph for this function: