My Project
Functions/Subroutines
longshore_flow.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine longshore_flow
 

Function/Subroutine Documentation

◆ longshore_flow()

subroutine longshore_flow ( )

Definition at line 41 of file longshore_flow.f90.

41 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42 ! SETUP THE METRICS FOR LONGSHORE WIND DRIVEN FLOW
43 ! CALCULATE BOUNDARY ANGLE
44 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
45  USE mod_utils
46  USE all_vars
47  USE mod_par
48  IMPLICIT NONE
49  INTEGER :: I,J,K,nxt, prv, idx, ndx
50  real(sp) :: dx, dy
51 
52  IF(dbg_set(dbg_sbr)) WRITE(ipt,*) "START longshore_flow"
53 
54  ! MAKE SURE THERE ARE ATLEAST TWO NODES IN THE LIST
55  IF (nobclsf == 0 .and. par) THEN
56  ! DO NOTHING AND RETURN
57  RETURN
58  ELSE IF (nobclsf < 2 .and. serial) THEN
59  CALL fatal_error&
60  &('There are less than two long shore flow nodes',&
61  &'You must change the _lsf.dat file to contain atleast two nodes!.')
62  END IF
63 
64  !MAKE SURE THE FIRST NODE IN THIS LIST IS NEXT TO A SOLID BOUNDARY
65  ! OR A HALO NODE (IF PAR)
66  idx = ibclsf(1)
67  i = 0
68  DO
69  i = i + 1
70  if(i > ntsn(idx)) CALL fatal_error&
71  &("THE FIRST NODE IN THE LSF LIST MUST BE NEXT TO THE SOLID BOUNDARY",&
72  &"OR (IN THE PARALLEL CASE) NEXT TO THE HALO?")
73 
74  ndx = nbsn(idx,i)
75 
76  if(isonb(ndx) == 1 .or. (ndx > m .and. ndx <= mt)) THEN
77  exit
78  end if
79  END DO
80 
81 
82  ! MAKE SURE ALL THE NODES IN THE LIST ARE ON THE OPEN BOUNDARY
83  DO i = 1, nobclsf
84  j = ibclsf(i)
85  if (isonb(j) /= 2) THEN
86 
87  write(ipt,*) "LONG SHORE FLOW ERROR ON GLOBAL NODE NUMBER: ", ngid_x(j)
88  CALL fatal_error&
89  &("A LONG SHORE FLOW BOUNDARY NODE IS NOT ON THE OPEN BOUNDARY:", &
90  &"CHECK YOUR BOUNDARY FILES!")
91  END if
92 
93  END DO
94 
95  ! MAKE A LIST OF 'NEXT NODES' - used to determine angles and
96  ! gradients allong the lsf boundary
97 
98  ALLOCATE(nbclsf(nobclsf))
99  DO idx = 1, nobclsf-1
100  prv= idx
101  nxt= idx+1
102 
103  if(ibclsf(nxt) == ibclsf(prv)) CALL fatal_error&
104  &("Two long shore flow nodes in the file list are the same!")
105 
106 
107  i = 0
108  DO
109  i = i+ 1
110  if(i > ntsn(ibclsf(prv))) CALL fatal_error&
111  &("Two long shore flow nodes are not next to eachother!")
112 
113  if( ibclsf(nxt) == nbsn(ibclsf(prv),i) ) exit
114  END DO
115 
116  nbclsf(idx)=ibclsf(nxt)
117 
118  END DO
119 
120 
121  ! NOW FIND THE NEXT NODE AFTER THE LAST IN THE LIST - THERE ARE ALWAYS TWO!
122 
123  idx = ibclsf(nobclsf)
124  IF (nobclsf >1) THEN
125  prv = ibclsf(nobclsf - 1)
126  ELSE
127  ! THIS CAN ONLY HAPPEN IN A PARALLEL CASE WHRE THERE IS ONLY ONE
128  ! LOCAL NODE IN THE LSF BOUNDARY DUE TO A NASTY DECOMPOSITION
129 
130  ! SET PRV TO THE NEIGHBORING HALO NODE!
131  i = 0
132  DO
133  i = i + 1
134  if(i > ntsn(idx)) CALL fatal_error&
135  &("CAN'T FIND ANOTHER OPEN BOUNDARY NODE FOR LONG SHORE FLOW?",&
136  &"IF THERE IS ONLY ONE NODE IN THE DOMAIN IT MUST BE NEXT TO THE HALO!")
137 
138  ndx = nbsn(idx,i)
139 
140  if(isonb(ndx) == 2 .and. ndx > m ) THEN
141  prv = ndx
142  exit
143  end if
144  END DO
145  END IF
146 
147  i = 0
148  DO
149  i = i + 1
150  if(i > ntsn(idx)) CALL fatal_error&
151  &("CAN'T FIND ANOTHER OPEN BOUNDARY NODE FOR LONG SHORE FLOW?",&
152  &"The list can't contain the entire open boundary!")
153 
154  ndx = nbsn(idx,i)
155 
156  if(isonb(ndx) == 2 .and. ndx /= prv .and. ndx /= idx ) THEN
157  nbclsf(nobclsf)= ndx
158  exit
159  end if
160  END DO
161 
162  Allocate(wdf_ang(nobclsf)); wdf_ang = 0.0_sp
163  Allocate(wdf_dist(nobclsf)); wdf_dist = 0.0_sp
164 
165  DO i = 1,nobclsf
166  dx = vx(nbclsf(i)) - vx(ibclsf(i))
167  dy = vy(nbclsf(i)) - vy(ibclsf(i))
168 
169  wdf_dist(i)= sqrt(dx**2 + dy**2)
170  wdf_ang(i) = atan2(dy,dx)
171  END DO
172 
173 
174  write(ipt,*) "! LONG SHORE FLOW BOUNDARY CONDITION METRICS"
175  WRITE(ipt,*) "! NodeList, NextNode, Angle, Distance"
176  DO i = 1, nobclsf
177 
178  write(ipt,*)"! ",ngid_x(ibclsf(i)), ngid_x(nbclsf(i)), wdf_ang(i),wdf_dist(i)
179  if (nbclsf(i) > m .and. dbg_set(dbg_log)) write(ipt,*)&
180  & "! The next node value shown above is in the halo and does not appear co&
181  &rrectly in ngid: Don't worry about it ;-)"
182 
183  END DO
184 
185  IF(dbg_set(dbg_sbr)) WRITE(ipt,*) "END longshore_flow"
186 
integer, dimension(:), allocatable, target ntsn
Definition: mod_main.f90:1023
logical serial
Definition: mod_main.f90:100
integer mt
Definition: mod_main.f90:78
integer, dimension(:), allocatable, target ibclsf
Definition: mod_main.f90:1080
logical function dbg_set(vrb)
Definition: mod_utils.f90:182
integer, dimension(:), allocatable, target nbclsf
Definition: mod_main.f90:1082
integer, dimension(:), pointer ngid_x
Definition: mod_par.f90:63
logical par
Definition: mod_main.f90:102
integer m
Definition: mod_main.f90:56
real(sp), dimension(:), allocatable, target vx
Definition: mod_main.f90:1001
real(sp), dimension(:), allocatable, target vy
Definition: mod_main.f90:1002
real(sp), dimension(:), allocatable, target wdf_ang
Definition: mod_main.f90:1078
integer nobclsf
Definition: mod_main.f90:58
subroutine fatal_error(ER1, ER2, ER3, ER4)
Definition: mod_utils.f90:230
real(sp), dimension(:), allocatable, target wdf_dist
Definition: mod_main.f90:1079
integer, dimension(:,:), allocatable, target nbsn
Definition: mod_main.f90:1030
integer ipt
Definition: mod_main.f90:922
integer, parameter dbg_sbr
Definition: mod_utils.f90:69
integer, dimension(:), allocatable, target isonb
Definition: mod_main.f90:1024
integer, parameter dbg_log
Definition: mod_utils.f90:65
Here is the call graph for this function:
Here is the caller graph for this function: