WAVEWATCH III  beta 0.0.1
yowfunction.F90
Go to the documentation of this file.
1 !PDLIB Software License
2 !
3 !Software, as understood herein, shall be broadly interpreted as being inclusive of algorithms,
4 !source code, object code, data bases and related documentation, all of which shall be furnished
5 !free of charge to the Licensee. Corrections, upgrades or enhancements may be furnished and, if
6 !furnished, shall also be furnished to the Licensee without charge. NOAA, however, is not
7 !required to develop or furnish such corrections, upgrades or enhancements.
8 !Roland & Partner software, whether that initially furnished or corrections or upgrades,
9 !are furnished "as is". Roland & Partner furnishes its software without any warranty
10 !whatsoever and is not responsible for any direct, indirect or consequential damages
11 !that may be incurred by the Licensee. Warranties of merchantability, fitness for any
12 !particular purpose, title, and non-infringement, are specifically negated.
13 !The Licensee is not required to develop any software related to the licensed software.
14 !However, in the event that the Licensee does so, the Licensee is required to offer same
15 !to Roland & Partner for inclusion under the instant licensing terms with Roland & Partner
16 !licensed software along with documentation regarding its principles, use and its advantages.
17 !This includes changes to the wave model proper including numerical and physical approaches
18 !to wave modeling, and boundary layer parameterizations embedded in the wave model
19 !A Licensee may reproduce sufficient software to satisfy its needs.
20 !All copies shall bear the name of the software with any version number
21 !as well as replicas of any applied copyright notice, trademark notice,
22 !other notices and credit lines. Additionally, if the copies have been modified,
23 !e.g. with deletions or additions, this shall be so stated and identified.
24 !All of Licensee's employees who have a need to use the software may have access
25 !to the software but only after reading the instant license and stating, in writing,
26 !that they have read and understood the license and have agreed to its terms.
27 !Licensee is responsible for employing reasonable efforts to assure
28 !that only those of its employees that should have access to the software, in fact, have access.
29 !The Licensee may use the software for any purpose relating to sea state prediction.
30 !No disclosure of any portion of the software, whether by means of a media or verbally,
31 !may be made to any third party by the Licensee or the Licensee's employees
32 !The Licensee is responsible for compliance with any applicable export or
33 !import control laws of the United States, the European Union and Germany.
34 !
35 !© 2009 Roland&Partner, Georgenstr.32, 64297 Germany. All rights reserved.
36 !PDLIB is a trademark of Roland & Partner. No unauthorized use without permission.
37 !
43 CONTAINS
44  !**********************************************************************
45  !* *
46  !**********************************************************************
47  SUBROUTINE pdlib_abort(istat)
48  IMPLICIT NONE
49  integer, intent(in) :: istat
50  print *, 'Error with istat=', istat
51  CALL abort
52  END SUBROUTINE pdlib_abort
53  !**********************************************************************
54  !* *
55  !**********************************************************************
57  USE w3odatmd, only : iaproc, naproc, ntproc
58  USE w3adatmd, ONLY: mpi_comm_wcmp
59  USE yowdatapool, only: rtype, istatus
60  USE yownodepool, only: npa, np, iplg
61  USE yownodepool, only: listnp, listnpa, listiplg
62  IMPLICIT NONE
63  include "mpif.h"
64  integer IPROC, idx, IP, len, istat, sumNP, ierr
65  integer, allocatable :: iVect(:)
66  !
67  ! Computing ListNP and ListNPA
68  !
69 #ifdef W3_DEBUGINIT
70  WRITE(740+iaproc,*) 'ComputeListNP_ListNPA_Kernel, step 1'
71  FLUSH(740+iaproc)
72 #endif
73  allocate(listnp(naproc), listnpa(naproc), ivect(2), stat=istat)
74 #ifdef W3_DEBUGINIT
75  WRITE(740+iaproc,*) 'ComputeListNP_ListNPA_Kernel, step 2'
76  FLUSH(740+iaproc)
77 #endif
78  IF (istat /= 0) CALL pdlib_abort(1)
79 #ifdef W3_DEBUGINIT
80  WRITE(740+iaproc,*) 'ComputeListNP_ListNPA_Kernel, step 3'
81  FLUSH(740+iaproc)
82 #endif
83  IF (iaproc .eq. 1) THEN
84  listnp(1)=np
85  listnpa(1)=npa
86  DO iproc=2,naproc
87  CALL mpi_recv(ivect,2,mpi_integer, iproc-1, 19, mpi_comm_wcmp, istatus, ierr)
88  listnp(iproc)=ivect(1)
89  listnpa(iproc)=ivect(2)
90  END DO
91  DO iproc=2,naproc
92  CALL mpi_send(listnp, naproc,mpi_integer, iproc-1, 20, mpi_comm_wcmp, ierr)
93  CALL mpi_send(listnpa,naproc,mpi_integer, iproc-1, 21, mpi_comm_wcmp, ierr)
94  END DO
95  ELSE
96  ivect(1)=np
97  ivect(2)=npa
98  CALL mpi_send(ivect,2,mpi_integer, 0, 19, mpi_comm_wcmp, ierr)
99  CALL mpi_recv(listnp ,naproc,mpi_integer, 0, 20, mpi_comm_wcmp, istatus, ierr)
100  CALL mpi_recv(listnpa,naproc,mpi_integer, 0, 21, mpi_comm_wcmp, istatus, ierr)
101  END IF
102  deallocate(ivect)
103 #ifdef W3_DEBUGINIT
104  WRITE(740+iaproc,*) 'ComputeListNP_ListNPA_Kernel, step 4'
105  FLUSH(740+iaproc)
106 #endif
107  !
108  ! ListIPLG
109  !
110  sumnp=sum(listnpa)
111 #ifdef W3_DEBUGINIT
112  WRITE(740+iaproc,*) 'ComputeListNP_ListNPA_Kernel, step 5, sumNP=', sumnp
113  FLUSH(740+iaproc)
114 #endif
115  allocate(listiplg(sumnp), stat=istat)
116 #ifdef W3_DEBUGINIT
117  WRITE(740+iaproc,*) 'ComputeListNP_ListNPA_Kernel, step 6'
118  FLUSH(740+iaproc)
119 #endif
120  IF (istat /= 0) CALL pdlib_abort(2)
121 #ifdef W3_DEBUGINIT
122  WRITE(740+iaproc,*) 'ComputeListNP_ListNPA_Kernel, step 7'
123  WRITE(740+iaproc,*) 'ComputeListNP_ListNPA_Kernel, NAPROC=', naproc, ' NTPROC=', ntproc
124  FLUSH(740+iaproc)
125 #endif
126  IF (iaproc .eq. 1) THEN
127 #ifdef W3_DEBUGINIT
128  WRITE(740+iaproc,*) 'Main node 1'
129  FLUSH(740+iaproc)
130 #endif
131  idx=0
132  DO ip=1,npa
133  idx=idx+1
134  listiplg(ip)=iplg(ip)
135  END DO
136 #ifdef W3_DEBUGINIT
137  WRITE(740+iaproc,*) 'Main node 2'
138  FLUSH(740+iaproc)
139 #endif
140  DO iproc=2,naproc
141  len=listnpa(iproc)
142  allocate(ivect(len), stat=istat)
143  IF (istat /= 0) CALL pdlib_abort(3)
144  CALL mpi_recv(ivect,len,mpi_integer, iproc-1, 269, mpi_comm_wcmp, istatus, ierr)
145  DO ip=1,len
146  idx=idx+1
147  listiplg(idx)=ivect(ip)
148  END DO
149  deallocate(ivect)
150  END DO
151 #ifdef W3_DEBUGINIT
152  WRITE(740+iaproc,*) 'Main node 3'
153  FLUSH(740+iaproc)
154 #endif
155  DO iproc=2,naproc
156 #ifdef W3_DEBUGINIT
157  WRITE(740+iaproc,*) 'Before mpi_send IPROC=', iproc
158  FLUSH(740+iaproc)
159 #endif
160  CALL mpi_send(listiplg, sumnp,mpi_integer, iproc-1, 271, mpi_comm_wcmp, ierr)
161 #ifdef W3_DEBUGINIT
162  WRITE(740+iaproc,*) 'After mpi_send IPROC=', iproc
163  FLUSH(740+iaproc)
164 #endif
165  END DO
166 #ifdef W3_DEBUGINIT
167  WRITE(740+iaproc,*) 'Main node 4'
168  FLUSH(740+iaproc)
169 #endif
170  ELSE
171 #ifdef W3_DEBUGINIT
172  WRITE(740+iaproc,*) 'Peripheral node 1'
173  FLUSH(740+iaproc)
174 #endif
175  CALL mpi_send(iplg, npa,mpi_integer, 0, 269, mpi_comm_wcmp, ierr)
176 #ifdef W3_DEBUGINIT
177  WRITE(740+iaproc,*) 'Peripheral node 2'
178  FLUSH(740+iaproc)
179 #endif
180  CALL mpi_recv(listiplg,sumnp,mpi_integer, 0, 271, mpi_comm_wcmp, istatus, ierr)
181 #ifdef W3_DEBUGINIT
182  WRITE(740+iaproc,*) 'Peripheral node 3'
183  FLUSH(740+iaproc)
184 #endif
185  END IF
186 #ifdef W3_DEBUGINIT
187  WRITE(740+iaproc,*) 'ComputeListNP_ListNPA_Kernel, step 8'
188  FLUSH(740+iaproc)
189 #endif
191  !**********************************************************************
192  !* *
193  !**********************************************************************
195  USE w3odatmd, only : iaproc, naproc, ntproc
196  USE w3adatmd, ONLY: mpi_comm_wave
197  USE yowdatapool, only: rtype, istatus
198  USE yownodepool, only: npa, np, iplg
199  USE yownodepool, only: listnp, listnpa, listiplg
200  IMPLICIT NONE
201  include "mpif.h"
202  INTEGER sumNP, iProc, ierr, istat
203 #ifdef W3_DEBUGINIT
204  WRITE(740+iaproc,*) 'Before ComputeListNP_ListNPA_Kernel'
205  FLUSH(740+iaproc)
206 #endif
207  IF (iaproc .le. naproc) THEN
209  END IF
210 #ifdef W3_DEBUGINIT
211  WRITE(740+iaproc,*) ' After ComputeListNP_ListNPA_Kernel'
212  FLUSH(740+iaproc)
213 #endif
214  IF (iaproc .eq. 1) THEN
215 #ifdef W3_DEBUGINIT
216  WRITE(740+iaproc,*) 'Doing the send'
217  FLUSH(740+iaproc)
218 #endif
219  sumnp=sum(listnpa)
220  DO iproc=naproc+1,ntproc
221 #ifdef W3_DEBUGINIT
222  WRITE(740+iaproc,*) 'Loop state 1, iProc=', iproc
223  FLUSH(740+iaproc)
224 #endif
225  CALL mpi_send(listnp, naproc,mpi_integer, iproc-1, 20, mpi_comm_wave, ierr)
226 #ifdef W3_DEBUGINIT
227  WRITE(740+iaproc,*) 'Loop state 2, iProc=', iproc
228  FLUSH(740+iaproc)
229 #endif
230  CALL mpi_send(listnpa,naproc,mpi_integer, iproc-1, 21, mpi_comm_wave, ierr)
231 #ifdef W3_DEBUGINIT
232  WRITE(740+iaproc,*) 'Loop state 3, iProc=', iproc
233  FLUSH(740+iaproc)
234 #endif
235  CALL mpi_send(listiplg, sumnp,mpi_integer, iproc-1, 271, mpi_comm_wave, ierr)
236 #ifdef W3_DEBUGINIT
237  WRITE(740+iaproc,*) 'Loop state 4, iProc=', iproc
238  FLUSH(740+iaproc)
239 #endif
240  END DO
241  END IF
242  IF (iaproc .gt. naproc) THEN
243 #ifdef W3_DEBUGINIT
244  WRITE(740+iaproc,*) 'Before allocation'
245  FLUSH(740+iaproc)
246 #endif
247  allocate(listnp(naproc), listnpa(naproc), stat=istat)
248 #ifdef W3_DEBUGINIT
249  WRITE(740+iaproc,*) 'Before receiving of data 1'
250  FLUSH(740+iaproc)
251 #endif
252  CALL mpi_recv(listnp ,naproc,mpi_integer, 0, 20, mpi_comm_wave, istatus, ierr)
253 #ifdef W3_DEBUGINIT
254  WRITE(740+iaproc,*) 'Before receiving of data 2'
255  FLUSH(740+iaproc)
256 #endif
257  CALL mpi_recv(listnpa,naproc,mpi_integer, 0, 21, mpi_comm_wave, istatus, ierr)
258 #ifdef W3_DEBUGINIT
259  WRITE(740+iaproc,*) 'Before computing sumNP'
260  FLUSH(740+iaproc)
261 #endif
262  sumnp=sum(listnpa)
263 #ifdef W3_DEBUGINIT
264  WRITE(740+iaproc,*) 'Before allocating ListIPLG'
265  FLUSH(740+iaproc)
266 #endif
267  allocate(listiplg(sumnp), stat=istat)
268 #ifdef W3_DEBUGINIT
269  WRITE(740+iaproc,*) 'Before receiving ListIPLG'
270  FLUSH(740+iaproc)
271 #endif
272  CALL mpi_recv(listiplg,sumnp,mpi_integer, 0, 271, mpi_comm_wave, istatus, ierr)
273 #ifdef W3_DEBUGINIT
274  WRITE(740+iaproc,*) 'After receiving ListIPLG'
275  FLUSH(740+iaproc)
276 #endif
277  END IF
278  END SUBROUTINE computelistnp_listnpa_listiplg
279  !**********************************************************************
280  !* *
281  !**********************************************************************
282  SUBROUTINE computeboundaryinformation
284  USE w3gdatmd, ONLY: iobp
285  USE w3odatmd, only : iaproc, naproc
286  IMPLICIT NONE
287  integer ListFirst(NAPROC), NbSend(NAPROC)
288  integer IPROC, eSend, IP, IP_glob, NPAloc
289  listfirst=0
290  DO iproc=2,naproc
291  listfirst(iproc)=listfirst(iproc-1) + listnpa(iproc-1)
292  END DO
293  DO iproc=1,naproc
294  npaloc=listnpa(iproc)
295  esend=0
296  DO ip=1,npaloc
297  ip_glob=listiplg(ip + listfirst(iproc))
298  IF (iobp(ip_glob) .eq. 1) THEN
299  esend=esend + 1
300  END IF
301  END DO
302  nbsend(iproc)=esend
303  END DO
304  END SUBROUTINE computeboundaryinformation
305 end module yowfunction
yowfunction
Definition: yowfunction.F90:42
include
cmake src_list cmake include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_switches.cmake) check_switches("$
Definition: CMakeLists.txt:15
yowfunction::pdlib_abort
subroutine pdlib_abort(istat)
Definition: yowfunction.F90:48
w3adatmd
Define data structures to set up wave model auxiliary data for several models simultaneously.
Definition: w3adatmd.F90:26
w3odatmd::ntproc
integer, pointer ntproc
Definition: w3odatmd.F90:457
w3odatmd::iaproc
integer, pointer iaproc
Definition: w3odatmd.F90:457
yownodepool::iplg
integer, dimension(:), allocatable, public iplg
Node local to global mapping.
Definition: yownodepool.F90:116
yownodepool::npa
integer, public npa
number of ghost + resident nodes this partition holds
Definition: yownodepool.F90:99
yownodepool::listiplg
integer, dimension(:), allocatable, target, public listiplg
Definition: yownodepool.F90:86
yownodepool
Has data that belong to nodes.
Definition: yownodepool.F90:39
yowfunction::computelistnp_listnpa_listiplg
subroutine computelistnp_listnpa_listiplg
Definition: yowfunction.F90:195
yowdatapool::rtype
integer, save rtype
Definition: yowdatapool.F90:76
w3odatmd
Definition: w3odatmd.F90:3
yownodepool::listnpa
integer, dimension(:), allocatable, target, public listnpa
Definition: yownodepool.F90:86
w3odatmd::naproc
integer, pointer naproc
Definition: w3odatmd.F90:457
yownodepool::listnp
integer, dimension(:), allocatable, target, public listnp
Definition: yownodepool.F90:86
yownodepool::np
integer, public np
number of nodes, local
Definition: yownodepool.F90:93
yowdatapool::istatus
integer, dimension(mpi_status_size) istatus
MPI Real Type Shpuld be MPI_REAL8.
Definition: yowdatapool.F90:74
yowdatapool
Has fancy data.
Definition: yowdatapool.F90:39
w3gdatmd::iobp
integer *2, dimension(:), pointer iobp
Definition: w3gdatmd.F90:1129
w3adatmd::mpi_comm_wave
integer, pointer mpi_comm_wave
Definition: w3adatmd.F90:676
yowfunction::computelistnp_listnpa_listiplg_kernel
subroutine computelistnp_listnpa_listiplg_kernel
Definition: yowfunction.F90:57
w3gdatmd
Definition: w3gdatmd.F90:16
yowfunction::computeboundaryinformation
subroutine computeboundaryinformation
Definition: yowfunction.F90:283
w3adatmd::mpi_comm_wcmp
integer, pointer mpi_comm_wcmp
Definition: w3adatmd.F90:676