WAVEWATCH III  beta 0.0.1
w3pro3md.F90
Go to the documentation of this file.
1 
8 
9 #include "w3macros.h"
10 !/ ------------------------------------------------------------------- /
23 MODULE w3pro3md
24  !/
25  !/ +-----------------------------------+
26  !/ | WAVEWATCH III NOAA/NCEP |
27  !/ | H. L. Tolman |
28  !/ | FORTRAN 90 |
29  !/ | Last update : 27-May-2014 |
30  !/ +-----------------------------------+
31  !/
32  !/ 27-Feb-2000 : Origination. ( version 2.08 )
33  !/ 17-Sep-2000 : Clean-up. ( version 2.13 )
34  !/ 10-Dec-2001 : Sub-grid obstructions. ( version 2.14 )
35  !/ 16-Oct-2002 : Change INTENT for ATRN in W3XYP3. ( version 3.00 )
36  !/ 26-Dec-2002 : Moving grid version. ( version 3.02 )
37  !/ 01-Aug-2003 : Moving grid GSE correction. ( version 3.03 )
38  !/ 17-Dec-2004 : Multiple grid version. ( version 3.06 )
39  !/ 07-Sep-2005 : Upgrade XY boundary conditions. ( version 3.08 )
40  !/ 09-Nov-2005 : Removing soft boundary option. ( version 3.08 )
41  !/ 05-Mar-2008 : Added NEC sxf90 compiler directives.
42  !/ (Chris Bunney, UK Met Office) ( version 3.13 )
43  !/ 01-Apr-2008 : Bug fix W3MAP3 MAPSTA range check. ( version 3.13 )
44  !/ 29-May-2009 : Preparing distribution version. ( version 3.14 )
45  !/ 30-Oct-2009 : Implement curvilinear grid type. ( version 3.14 )
46  !/ (W. E. Rogers & T. J. Campbell, NRL)
47  !/ 17-Aug-2010 : Add test output W3XYP3. ( version 3.14.5 )
48  !/ 06-Dec-2010 : Change from GLOBAL (logical) to ICLOSE (integer) to
49  !/ specify index closure for a grid. ( version 3.14 )
50  !/ (T. J. Campbell, NRL)
51  !/ 26-Dec-2012 : More initializations. ( version 4.11 )
52  !/ 01-Jul-2013 : Adding UQ and UNO switches to chose between third
53  !/ and second order schemes. ( version 4.12 )
54  !/ 12-Sep-2013 : Add documentation for global clos. ( version 4.12 )
55  !/ 27-May-2014 : Adding OMPH switch. ( version 5.02 )
56  !/
57  !/ Copyright 2009-2014 National Weather Service (NWS),
58  !/ National Oceanic and Atmospheric Administration. All rights
59  !/ reserved. WAVEWATCH III is a trademark of the NWS.
60  !/ No unauthorized use without permission.
61  !/
62  ! 1. Purpose :
63  !
64  ! Bundles routines for third order propagation scheme in single
65  ! module.
66  !
67  ! 2. Variables and types :
68  !
69  ! Name Type Scope Description
70  ! ----------------------------------------------------------------
71  ! TRNMIN R.P. Private Minimum transparancy for local
72  ! switching off of averaging.
73  ! ----------------------------------------------------------------
74  !
75  ! Also work arrays for W3KTP3 (private).
76  !
77  ! 3. Subroutines and functions :
78  !
79  ! Name Type Scope Description
80  ! ----------------------------------------------------------------
81  ! W3MAP3 Subr. Public Set up auxiliary maps.
82  ! W3MAPT Subr. Public Set up transparency map for GSE.
83  ! W3XYP3 Subr. Public Third order spatial propagation.
84  ! W3KTP3 Subr. Public Third order spectral propagation.
85  ! ----------------------------------------------------------------
86  !
87  ! 4. Subroutines and functions used :
88  !
89  ! Name Type Module Description
90  ! ----------------------------------------------------------------
91  ! STRACE Subr. W3SERVMD Subroutine tracing.
92  ! W3QCK1 Subr. W3UQCKMD Regular grid UQ scheme.
93  ! W3QCK2 Subr. Id. Irregular grid UQ scheme.
94  ! W3QCK3 Subr. Id. Regular grid UQ scheme + obstructions.
95  ! W3UNO2 Subr. W3UNO2MD UNO2 scheme for irregular grid.
96  ! W3UNO2r Subr. Id. UNO2 scheme reduced to regular grid.
97  ! W3UNO2s Subr. Id. UNO2 regular grid with subgrid
98  ! obstruction.
99  ! ----------------------------------------------------------------
100  !
101  ! 5. Remarks :
102  !
103  ! - The averaging is not performed around semi-transparent grid
104  ! points to avoid that leaking through barriers occurs.
105  !
106  ! 6. Switches :
107  !
108  ! !/UQ 3rd order UQ propagation scheme.
109  ! !/UNO 2nd order UNO propagation scheme.
110  !
111  ! !/MGP Moving grid corrections.
112  ! !/MGG Moving grid corrections.
113  !
114  ! !/OMPH Hybrid OpenMP directives.
115  !
116  ! !/S Enable subroutine tracing.
117  ! !/Tn Enable test output.
118  !
119  ! 7. Source code :
120  !
121  !/ ------------------------------------------------------------------- /
122  !/
123  !/ Public variables
124  !/
125  PUBLIC
126  !/
127  !/ Private data
128  !/
129  REAL, PRIVATE, PARAMETER:: TRNMIN = 0.95
130  !/
131 CONTAINS
132  !/ ------------------------------------------------------------------- /
139  SUBROUTINE w3map3
140  !/
141  !/ +-----------------------------------+
142  !/ | WAVEWATCH III NOAA/NCEP |
143  !/ | H. L. Tolman |
144  !/ | FORTRAN 90 |
145  !/ | Last update : 01-Apr-2008 |
146  !/ +-----------------------------------+
147  !/
148  !/ 27-Feb-2000 : Origination. ( version 2.08 )
149  !/ 10-Dec-2001 : Sub-grid obstructions. ( version 2.14 )
150  !/ (array allocation only.)
151  !/ 17-Dec-2004 : Multiple grid version. ( version 3.06 )
152  !/ 09-Nov-2005 : Removing soft boundary option. ( version 3.08 )
153  !/ 01-Apr-2008 : Bug fix sec. 4 MAPSTA range check. ( version 3.13 )
154  !/
155  ! 1. Purpose :
156  !
157  ! Generate 'map' arrays for the ULTIMATE QUICKEST scheme.
158  !
159  ! 2. Method :
160  !
161  ! MAPX2, MAPY2, MAPTH2 and MAPWN2 contain consecutive 1-D spatial
162  ! grid counters (e.g., IXY = (IX-1)*MY + IY). The arrays are
163  ! devided in three parts. For MAPX2, these ranges are :
164  !
165  ! 1 - NMX0 Counters IXY for which grid point (IX,IY) and
166  ! (IX+1,IY) both are active grid points.
167  ! NMX0+1 - NMX1 Id. only (IX,IY) active.
168  ! NMX1+1 - NMX2 Id. only (IX+1,IY) active.
169  !
170  ! The array MAPY2 has a similar layout varying IY instead of IX.
171  !
172  ! 3. Parameters :
173  !
174  ! Parameter list
175  ! ----------------------------------------------------------------
176  ! ----------------------------------------------------------------
177  !
178  ! 4. Subroutines used :
179  !
180  ! See module documentation.
181  !
182  ! 5. Called by :
183  !
184  ! Name Type Module Description
185  ! ----------------------------------------------------------------
186  ! W3WAVE Subr. W3WAVEMD Wave model routine.
187  ! ----------------------------------------------------------------
188  !
189  ! 6. Error messages :
190  !
191  ! 7. Remarks :
192  !
193  ! 8. Structure :
194  !
195  ! ------------------------------------------------------
196  ! 1. Map MAPX2
197  ! a Range 1 to NMX0
198  ! b Range NMX0+1 to NMX1
199  ! c Range NMX1+1 to NMX2
200  ! 2. Map MAPY2
201  ! a Range 1 to NMY0
202  ! b Range NMY0+1 to NMY1
203  ! c Range NMY1+1 to NMY2
204  ! 3. Map MAPAXY
205  ! 4. Map MAPCXY
206  ! 5. Maps for intra-spectral propagation
207  ! a MAPTH2, MAPATK
208  ! b MAPWN2
209  ! ------------------------------------------------------
210  !
211  ! 9. Switches :
212  !
213  ! !/S Enable subroutine tracing.
214  ! !/T Enable test output.
215  !
216  ! 10. Source code :
217  !/ ------------------------------------------------------------------- /
218  USE w3gdatmd, ONLY: nk, nth, nspec, nx, ny, nsea, mapsta, mapsf,&
219  gtype
220  USE w3adatmd, ONLY: nmx0, nmx1, nmx2, nmy0, nmy1, nmy2, nact, &
221  ncent, mapx2, mapy2, mapaxy, mapcxy, &
222  mapth2, mapwn2
223  USE w3odatmd, ONLY: ndst
224 #ifdef W3_S
225  USE w3servmd, ONLY: strace
226 #endif
227  !/
228  IMPLICIT NONE
229  !/
230  !/ ------------------------------------------------------------------- /
231  !/ Parameter list
232  !/
233  !/ ------------------------------------------------------------------- /
234  !/ Local parameters
235  !/
236  INTEGER :: IX, IY, IXY0, IX2, IY2, IX0, IY0, &
237  ISEA, IK, ITH, ISP, ISP0, ISP2, NCENTC
238 #ifdef W3_S
239  INTEGER, SAVE :: IENT = 0
240 #endif
241 #ifdef W3_T
242  INTEGER :: MAPTXY(NY,NX), I, IXY
243  INTEGER :: MAPTST(NK+2,NTH)
244 #endif
245  !/
246  !/ ------------------------------------------------------------------- /
247  !/
248 #ifdef W3_S
249  CALL strace (ient, 'W3MAP3')
250 #endif
251  !
252  IF (gtype .LT. 3) THEN
253  ! 1. Map MAPX2 ------------------------------------------------------ *
254  ! 1.a Range 1 to NMX0
255  !
256 #ifdef W3_T
257  maptxy = 0.
258 #endif
259  !
260  nmx0 = 0
261  DO ix=1, nx
262  ixy0 = (ix-1)*ny
263  ix2 = 1 + mod(ix,nx)
264  DO iy=2, ny-1
265  IF ( mapsta(iy,ix).EQ.1 .AND. mapsta(iy,ix2).EQ.1 ) THEN
266  nmx0 = nmx0 + 1
267  mapx2(nmx0) = ixy0 + iy
268 #ifdef W3_T
269  maptxy(iy,ix) = maptxy(iy,ix) + 1
270 #endif
271  END IF
272  END DO
273  END DO
274  !
275  ! 1.b Range NMX0+1 to NMX1
276  !
277  nmx1 = nmx0
278  DO ix=1, nx
279  ixy0 = (ix-1)*ny
280  ix2 = 1 + mod(ix,nx)
281  DO iy=2, ny-1
282  IF ( mapsta(iy,ix).EQ.1 .AND. mapsta(iy,ix2).NE.1 ) THEN
283  nmx1 = nmx1 + 1
284  mapx2(nmx1) = ixy0 + iy
285 #ifdef W3_T
286  maptxy(iy,ix) = maptxy(iy,ix) + 2
287 #endif
288  END IF
289  END DO
290  END DO
291  !
292  ! 1.c Range NMX1+1 to NMX2
293  !
294  nmx2 = nmx1
295  DO ix=1, nx
296  ixy0 = (ix-1)*ny
297  ix2 = 1 + mod(ix,nx)
298  DO iy=2, ny-1
299  IF ( mapsta(iy,ix).NE.1 .AND. mapsta(iy,ix2).EQ.1 ) THEN
300  nmx2 = nmx2 + 1
301  mapx2(nmx2) = ixy0 + iy
302 #ifdef W3_T
303  maptxy(iy,ix) = maptxy(iy,ix) + 4
304 #endif
305  END IF
306  END DO
307  END DO
308  !
309 #ifdef W3_T
310  WRITE (ndst,9000) 'MAPX2', nmx0, nmx1-nmx0, &
311  nmx2-nmx1, nmx2
312  DO iy=ny, 1, -1
313  WRITE (ndst,9001) (maptxy(iy,ix),ix=1, nx)
314  END DO
315 #endif
316  !
317  ! 2. Map MAPY2 ------------------------------------------------------ *
318  ! 2.a Range 1 to NMY0
319  !
320 #ifdef W3_T
321  maptxy = 0.
322 #endif
323  !
324  nmy0 = 0
325  DO ix=1, nx
326  ixy0 = (ix-1)*ny
327  DO iy=1, ny-1
328  iy2 = iy + 1
329  IF ( mapsta(iy,ix).EQ.1 .AND. mapsta(iy2,ix).EQ.1 ) THEN
330  nmy0 = nmy0 + 1
331  mapy2(nmy0) = ixy0 + iy
332 #ifdef W3_T
333  maptxy(iy,ix) = maptxy(iy,ix) + 1
334 #endif
335  END IF
336  END DO
337  END DO
338  !
339  ! 2.b Range NMY0+1 to NMY1
340  !
341  nmy1 = nmy0
342  DO ix=1, nx
343  ixy0 = (ix-1)*ny
344  DO iy=1, ny-1
345  iy2 = iy + 1
346  IF ( mapsta(iy,ix).EQ.1 .AND. mapsta(iy2,ix).NE.1 ) THEN
347  nmy1 = nmy1 + 1
348  mapy2(nmy1) = ixy0 + iy
349 #ifdef W3_T
350  maptxy(iy,ix) = maptxy(iy,ix) + 2
351 #endif
352  END IF
353  END DO
354  END DO
355  !
356  ! 2.c Range NMY1+1 to NMY2
357  !
358  nmy2 = nmy1
359  DO ix=1, nx
360  ixy0 = (ix-1)*ny
361  DO iy=1, ny-1
362  iy2 = iy + 1
363  IF ( mapsta(iy,ix).NE.1 .AND. mapsta(iy2,ix).EQ.1 ) THEN
364  nmy2 = nmy2 + 1
365  mapy2(nmy2) = ixy0 + iy
366 #ifdef W3_T
367  maptxy(iy,ix) = maptxy(iy,ix) + 4
368 #endif
369  END IF
370  END DO
371  END DO
372  !
373 #ifdef W3_T
374  WRITE (ndst,9000) 'MAPY2', nmy0, nmy1-nmy0, &
375  nmy2-nmy1, nmy2
376  DO iy=ny, 1, -1
377  WRITE (ndst,9001) (maptxy(iy,ix),ix=1, nx)
378  END DO
379 #endif
380  !
381  ! 3. Map MAPAXY ----------------------------------------------------- *
382  !
383  nact = 0
384  DO ix=1, nx
385  iy0 = (ix-1)*ny
386  DO iy=2, ny-1
387  IF ( mapsta(iy,ix).EQ.1 ) THEN
388  nact = nact + 1
389  mapaxy(nact) = iy0 + iy
390  END IF
391  END DO
392  END DO
393  !
394  ! 4. Map MAPCXY ----------------------------------------------------- *
395  !
396  ncent = 0
397  ncentc = nsea
398  mapcxy = 0
399  !
400  DO isea=1, nsea
401  ix = mapsf(isea,1)
402  ix0 = ix-1
403  ix2 = ix+1
404  iy = mapsf(isea,2)
405  iy0 = iy-1
406  iy2 = iy+1
407  IF ( ix .EQ. nx ) ix2 = 1
408  IF ( ix .EQ. 1 ) ix0 = nx
409  IF ( mapsta(iy,ix).EQ.2 .OR. mapsta(iy,ix).LT.0 ) THEN
410  mapcxy(ncentc) = isea
411  ncentc = ncentc - 1
412  ELSE IF ( mapsta(iy0,ix0).GE.1 .AND. &
413  mapsta(iy0,ix ).GE.1 .AND. &
414  mapsta(iy0,ix2).GE.1 .AND. &
415  mapsta(iy ,ix0).GE.1 .AND. &
416  mapsta(iy ,ix2).GE.1 .AND. &
417  mapsta(iy2,ix0).GE.1 .AND. &
418  mapsta(iy2,ix ).GE.1 .AND. &
419  mapsta(iy2,ix2).GE.1 ) THEN
420  ncent = ncent + 1
421  mapcxy(ncent) = isea
422  ELSE
423  mapcxy(ncentc) = isea
424  ncentc = ncentc - 1
425  END IF
426  END DO
427  END IF
428  !
429  ! 5. Maps for intra-spectral propagation ---------------------------- *
430  !
431  IF ( mapth2(1) .NE. 0 ) RETURN
432  !
433 #ifdef W3_T
434  maptst = 0
435 #endif
436  !
437  ! 5.a MAPTH2 and MAPBTK
438  !
439  DO ik=1, nk
440  DO ith=1, nth
441  isp = ith + (ik-1)*nth
442  isp2 = (ik+1) + (ith-1)*(nk+2)
443  mapth2(isp) = isp2
444 #ifdef W3_T
445  maptst(ik+1,ith) = maptst(ik+1,ith) + 1
446 #endif
447  END DO
448  END DO
449  !
450 #ifdef W3_T
451  WRITE (ndst,9000) 'MAPTH2', isp, 0, 0, isp
452  DO ik=nk+2, 1, -1
453  WRITE (ndst,9001) (maptst(ik,ith),ith=1, nth)
454  END DO
455  maptst = 0
456 #endif
457  !
458  ! 5.b MAPWN2
459  !
460  isp0 = 0
461  DO ik=1, nk-1
462  DO ith=1, nth
463  isp0 = isp0 + 1
464  isp2 = (ik+1) + (ith-1)*(nk+2)
465  mapwn2(isp0) = isp2
466 #ifdef W3_T
467  maptst(ik+1,ith) = maptst(ik+1,ith) + 1
468 #endif
469  END DO
470  END DO
471  !
472  DO ith=1, nth
473  isp0 = isp0 + 1
474  isp2 = nk+1 + (ith-1)*(nk+2)
475  mapwn2(isp0) = isp2
476 #ifdef W3_T
477  maptst(nk+1,ith) = maptst(nk+1,ith) + 2
478 #endif
479  END DO
480  !
481  DO ith=1, nth
482  isp0 = isp0 + 1
483  isp2 = 1 + (ith-1)*(nk+2)
484  mapwn2(isp0) = isp2
485 #ifdef W3_T
486  maptst(1,ith) = maptst(1,ith) + 4
487 #endif
488  END DO
489  !
490 #ifdef W3_T
491  WRITE (ndst,9000) 'MAPWN2', nspec-nth, nth, nth, nspec+nth
492  DO ik=nk+2, 1, -1
493  WRITE (ndst,9001) (maptst(ik,ith),ith=1, nth)
494  END DO
495 #endif
496  !
497  RETURN
498  !
499  ! Formats
500  !
501 #ifdef W3_T
502 9000 FORMAT (/' TEST W3MAP3 : TEST MAP FOR PROPAGATION'/ &
503  ' MAP : ',a/ &
504  ' CENTRAL : ',i6/ &
505  ' ABOVE : ',i6/ &
506  ' BELOW : ',i6/ &
507  ' TOTAL : ',i6/)
508 9001 FORMAT (1x,130i1)
509 9010 FORMAT (' TEST W3MAP3 : COMPOSITE MAPS TH2, WN2 AND BTK')
510 9011 FORMAT (2x,60i2)
511 #endif
512  !/
513  !/ End of W3MAP3 ----------------------------------------------------- /
514  !/
515  END SUBROUTINE w3map3
516  !/ ------------------------------------------------------------------- /
524  SUBROUTINE w3mapt
525  !/
526  !/ +-----------------------------------+
527  !/ | WAVEWATCH III NOAA/NCEP |
528  !/ | H. L. Tolman |
529  !/ | FORTRAN 90 |
530  !/ | Last update : 17-Dec-2004 |
531  !/ +-----------------------------------+
532  !/
533  !/ 10-Dec-2001 : Origination. ( version 2.14 )
534  !/ 17-Dec-2004 : Multiple grid version. ( version 3.06 )
535  !/
536  ! 1. Purpose :
537  !
538  ! Generate 'map' arrays for the ULTIMATE QUICKEST scheme to combine
539  ! GSE alleviation with obstructions.
540  !
541  ! 2. Method :
542  !
543  ! 3. Parameters :
544  !
545  ! Parameter list
546  ! ----------------------------------------------------------------
547  ! ----------------------------------------------------------------
548  !
549  ! 4. Subroutines used :
550  !
551  ! See module documentation.
552  !
553  ! 5. Called by :
554  !
555  ! Name Type Module Description
556  ! ----------------------------------------------------------------
557  ! W3WAVE Subr. W3WAVEMD Wave model routine.
558  ! ----------------------------------------------------------------
559  !
560  ! 6. Error messages :
561  !
562  ! 7. Remarks :
563  !
564  ! 8. Structure :
565  !
566  ! See source code.
567  !
568  ! 9. Switches :
569  !
570  ! !/S Enable subroutine tracing.
571  !
572  ! 10. Source code :
573  !/ ------------------------------------------------------------------- /
574  USE w3gdatmd, ONLY: nx, ny, nsea, mapsf
575  USE w3adatmd, ONLY: atrnx, atrny, maptrn
576 #ifdef W3_S
577  USE w3servmd, ONLY: strace
578 #endif
579  !/
580  IMPLICIT NONE
581  !/
582  !/ ------------------------------------------------------------------- /
583  !/ Parameter list
584  !/
585  !/ ------------------------------------------------------------------- /
586  !/ Local parameters
587  !/
588  INTEGER :: ISEA, IXY
589 #ifdef W3_S
590  INTEGER, SAVE :: IENT = 0
591 #endif
592  !/
593  !/ ------------------------------------------------------------------- /
594  !/
595 #ifdef W3_S
596  CALL strace (ient, 'W3MAPT')
597 #endif
598  !
599  ! 1. Map MAPTRN ----------------------------------------------------- *
600  !
601  DO isea=1, nsea
602  ixy = mapsf(isea,3)
603 
604  !notes: Oct 22 2012: I changed this because it *looks* like a bug.
605  ! I have not confirmed that it is a bug.
606  ! Old code is given (2 lines). Only the first line is
607  ! changed.
608 
609  !old MAPTRN(IXY) = MIN( ATRNX(IXY,1) ,ATRNY(IXY,-1) , &
610  !old ATRNY(IXY,1), ATRNY(IXY,-1) ) .LT. TRNMIN
611 
612  maptrn(ixy) = min( atrnx(ixy,1) ,atrnx(ixy,-1) , &
613  atrny(ixy,1), atrny(ixy,-1) ) .LT. trnmin
614  END DO
615  !
616  RETURN
617  !
618  ! Formats
619  !/
620  !/ End of W3MAPT ----------------------------------------------------- /
621  !/
622  END SUBROUTINE w3mapt
623  !/ ------------------------------------------------------------------- /
638  SUBROUTINE w3xyp3 ( ISP, DTG, MAPSTA, MAPFS, VQ, VGX, VGY )
639  !/
640  !/ +-----------------------------------+
641  !/ | WAVEWATCH III NOAA/NCEP |
642  !/ | H. L. Tolman |
643  !/ | FORTRAN 90 |
644  !/ | Last update : 27-May-2014 |
645  !/ +-----------------------------------+
646  !/
647  !/ 27-Feb-2000 : Origination. ( version 2.08 )
648  !/ 17-Sep-2000 : Clean-up. ( version 2.13 )
649  !/ 10-Dec-2001 : Sub-grid obstructions. ( version 2.14 )
650  !/ 16-Oct-2002 : Change INTENT for ATRNRX/Y. ( version 3.00 )
651  !/ 26-Dec-2002 : Moving grid version. ( version 3.02 )
652  !/ 01-Aug-2003 : Moving grid GSE correction. ( version 3.03 )
653  !/ 17-Dec-2004 : Multiple grid version. ( version 3.06 )
654  !/ 07-Sep-2005 : Upgrade XY boundary conditions. ( version 3.08 )
655  !/ 09-Nov-2005 : Removing soft boundary option. ( version 3.08 )
656  !/ 05-Mar-2008 : Added NEC sxf90 compiler directives.
657  !/ (Chris Bunney, UK Met Office) ( version 3.13 )
658  !/ 30-Oct-2009 : Implement curvilinear grid type. ( version 3.14 )
659  !/ (W. E. Rogers & T. J. Campbell, NRL)
660  !/ 17-Aug-2010 : Add test output. ( version 3.14.5 )
661  !/ 30-Oct-2010 : Implement unstructured grid ( version 3.14 )
662  !/ 06-Dec-2010 : Change from GLOBAL (logical) to ICLOSE (integer) to
663  !/ specify index closure for a grid. ( version 3.14 )
664  !/ (T. J. Campbell, NRL)
665  !/ 01-Jul-2013 : Adding UQ and UNO switches to chose between third
666  !/ and second order schemes. ( version 4.12 )
667  !/ 12-Sep-2013 : Add documentation for global clos. ( version 4.12 )
668  !/ 27-May-2014 : Adding OMPH switch. ( version 5.02 )
669  !/
670  ! 1. Purpose :
671  !
672  ! Propagation in phyiscal space for a given spectral component.
673  !
674  ! 2. Method :
675  !
676  ! Third-order ULTIMATE QUICKEST scheme with averaging.
677  ! Curvilinear grid implementation: Fluxes are computed in index space
678  ! and then transformed back into physical space. The diffusion term
679  ! is handled in physical space. The averaging scheme is adapted for
680  ! curvilinear grids by applying the appropriate local rotations and
681  ! adjustments to interpolation weights which control the strength of
682  ! the averaging in axial directions.
683  !
684  ! 3. Parameters :
685  !
686  ! Parameter list
687  ! ----------------------------------------------------------------
688  ! ISP Int. I Number of spectral bin (IK-1)*NTH+ITH
689  ! DTG Real I Total time step.
690  ! MAPSTA I.A. I Grid point status map.
691  ! MAPFS I.A. I Storage map.
692  ! VQ R.A. I/O Field to propagate.
693  ! VGX/Y Real I Speed of grid.
694  ! ----------------------------------------------------------------
695  !
696  ! Local variables.
697  ! ----------------------------------------------------------------
698  ! NTLOC Int Number of local time steps.
699  ! DTLOC Real Local propagation time step.
700  ! VCFL0X R.A. Local courant numbers for absolute group vel.
701  ! using local X-grid step.
702  ! VCFL0Y R.A. Id. in Y.
703  ! ----------------------------------------------------------------
704  !
705  ! 4. Subroutines used :
706  !
707  ! W3QCK3 Actual propagation algorithm
708  !
709  ! STRACE Service routine.
710  !
711  ! 5. Called by :
712  !
713  ! W3WAVE Wave model routine.
714  !
715  ! 6. Error messages :
716  !
717  ! None.
718  !
719  ! 7. Remarks :
720  !
721  ! - Note that the ULTIMATE limiter does not guarantee non-zero
722  ! energies.
723  ! - The present scheme shows a strong distorsion when propaga-
724  ! ting a field under an angle with the grid in a truly 2-D
725  ! fashion. Propagation is therefore split along the two
726  ! axes.
727  ! - Two boundary treatments are available. The first uses real
728  ! boundaries in each space. In this case waves will not
729  ! penetrate in narrow straights under an angle with the grid.
730  ! This behavior is improved by using a 'soft' option, in
731  ! which the 'X' or 'Y' sweep allows for energy to go onto
732  ! the land. This improves the above behavior, but implies
733  ! that X-Y connenctions are required in barriers for them
734  ! to become inpenetrable.
735  ! - Note that unlike in W3XYP2, isotropic diffusion is never
736  ! used for growth.
737  ! - Curvilinear grid implementation. Variables FACX, FACY, CCOS, CSIN,
738  ! CCURX, CCURY are not needed and have been removed. FACX is accounted
739  ! for as approriate in this subroutine. FACX is also accounted for in
740  ! the case of .NOT.FLCX. Since FACX is removed, there is now a check for
741  ! .NOT.FLCX in this subroutine. In CFL calcs dx and dy are omitted,
742  ! since dx=dy=1 in index space. Curvilinear grid derivatives
743  ! (DPDY, DQDX, etc.) and metric (GSQRT) are brought in via W3GDATMD.
744  ! - The strength of the averaging scheme is dependent on grid resolution.
745  ! Since grid resolution is non-uniform for curvilinear grids, this means
746  ! that the strength of the averaging is also non-uniform. This may not be
747  ! a desirable effect. A potential future upgrade would be to add an
748  ! additional term/factor that balances the effect of the spatial
749  ! variation of grid resolution.
750  !
751  ! 8. Structure :
752  !
753  ! ---------------------------------------------
754  ! 1. Preparations
755  ! a Set constants
756  ! b Initialize arrays
757  ! 2. Prepare arrays
758  ! a Velocities and 'Q'
759  ! 3. Loop over sub-steps
760  ! ----------------------------------------
761  ! a Average
762  ! b Propagate
763  ! c Update boundaries.
764  ! ----------------------------------------
765  ! 4. Store Q field in spectra
766  ! ---------------------------------------------
767  !
768  ! 9. Switches :
769  !
770  ! !/S Enable subroutine tracing.
771  !
772  ! !/OMPH Hybrid OpenMP directives.
773  !
774  ! !/MGP Moving grid corrections.
775  ! !/MGG Moving grid corrections.
776  !
777  ! !/T Enable general test output.
778  ! !/T0 Dump of precalcaulted interpolation data.
779  ! !/T1 Dump of input field and fluxes.
780  ! !/T2 Dump of output field (before boundary update).
781  ! !/T3 Dump of output field (final).
782  !
783  ! 10. Source code :
784  !
785  !/ ------------------------------------------------------------------- /
786  USE constants
787  !
788  USE w3timemd, ONLY: dsec21
789  !
790  USE w3gdatmd, ONLY: nx, ny, nsea, mapsf, dtcfl, clats, &
791  iclose, flcx, flcy, nk, nth, dth, xfr, &
793  ecos, esin, sig, wdcg, wdth, pfmove, &
795  USE w3wdatmd, ONLY: time
796  USE w3adatmd, ONLY: nmx0, nmx1, nmx2, nmy0, nmy1, nmy2, nact, &
797  ncent, mapx2, mapy2, mapaxy, mapcxy, &
798  maptrn, cg, cx, cy, atrnx, atrny, itime
799  USE w3idatmd, ONLY: flcur
800  USE w3odatmd, ONLY: ndse, ndst, flbpi, nbi, tbpi0, tbpin, &
802  USE w3servmd, ONLY: extcde
803 #ifdef W3_S
804  USE w3servmd, ONLY: strace
805 #endif
806 #ifdef W3_UQ
807  USE w3uqckmd
808 #endif
809 #ifdef W3_UNO
810  USE w3uno2md
811 #endif
812  !/
813  IMPLICIT NONE
814  !/
815  !/ ------------------------------------------------------------------- /
816  !/ Parameter list
817  !/
818  INTEGER, INTENT(IN) :: ISP, MAPSTA(NY*NX), MAPFS(NY*NX)
819  REAL, INTENT(IN) :: DTG, VGX, VGY
820  REAL, INTENT(INOUT) :: VQ(1-NY:NY*(NX+2))
821  !/
822  !/ ------------------------------------------------------------------- /
823  !/ Local parameters
824  !/
825  INTEGER :: ITH, IK, NTLOC, ITLOC, ISEA, IXY, IP
826  INTEGER :: IX, IY, IXC, IYC, IBI
827  INTEGER :: IIXY1(NSEA), IIXY2(NSEA), &
828  IIXY3(NSEA), IIXY4(NSEA)
829  INTEGER :: TTEST(2),DTTST
830 #ifdef W3_S
831  INTEGER, SAVE :: IENT = 0
832 #endif
833  REAL :: CG0, CGA, CGN, CGX, CGY, CXC, CYC, &
834  CXMIN, CXMAX, CYMIN, CYMAX
835  REAL :: CGC, FGSE = 1.
836  REAL :: FTH, FTHX, FTHY, FCG, FCGX, FCGY
837  REAL :: DTLOC, DTRAD, &
838  DXCGN, DYCGN, DXCGS, DYCGS, DXCGC, &
839  DYCGC
840  REAL :: RDI1(NSEA), RDI2(NSEA), &
841  RDI3(NSEA), RDI4(NSEA)
842  REAL :: TMPX, TMPY, RD1, RD2, RD3, RD4
843  LOGICAL :: YFIRST
844  LOGICAL :: GLOBAL
845  REAL :: CP, CQ
846  !/
847  !/ Automatic work arrays
848  !/
849  INTEGER :: MAPSTX(1-2*NY:NY*(NX+2))
850  REAL :: VLCFLX((NX+1)*NY), VLCFLY((NX+1)*NY),&
851  AQ(1-NY:NY*(NX+2))
852  REAL :: CXTOT((NX+1)*NY), CYTOT(NX*NY)
853  !/
854  !/ ------------------------------------------------------------------- /
855  !/
856 #ifdef W3_S
857  CALL strace (ient, 'W3XYP3')
858 #endif
859  !
860  ! 1. Preparations --------------------------------------------------- *
861 
862  IF ( iclose .EQ. iclose_trpl ) THEN
863  !/ ------------------------------------------------------------------- /
864  IF (iaproc .EQ. naperr) &
865  WRITE(ndse,*)'SUBROUTINE W3XYP3 IS NOT YET ADAPTED FOR '// &
866  'TRIPOLE GRIDS. STOPPING NOW.'
867  CALL extcde ( 1 )
868  END IF
869 
870  ! 1.a Set constants
871  !
872  global = iclose.NE.iclose_none
873  ith = 1 + mod(isp-1,nth)
874  ik = 1 + (isp-1)/nth
875  !
876  cg0 = 0.575 * grav / sig(1)
877  cga = 0.575 * grav / sig(ik)
878  cgx = cga * ecos(ith)
879  cgy = cga * esin(ith)
880 #ifdef W3_MGP
881  cgx = cgx - vgx
882  cgy = cgy - vgy
883 #endif
884  cgc = sqrt( cgx**2 + cgy**2 )
885 #ifdef W3_MGG
886  fgse = ( cga / max(0.001*cga,cgc) )**pfmove
887 #endif
888  !
889  IF ( flcur ) THEN
890  cxmin = minval( cx(1:nsea) )
891  cxmax = maxval( cx(1:nsea) )
892  cymin = minval( cy(1:nsea) )
893  cymax = maxval( cy(1:nsea) )
894  IF ( abs(cgx+cxmin) .GT. abs(cgx+cxmax) ) THEN
895  cgx = cgx + cxmin
896  ELSE
897  cgx = cgx + cxmax
898  END IF
899  IF ( abs(cgy+cymin) .GT. abs(cgy+cymax) ) THEN
900  cgy = cgy + cymin
901  ELSE
902  cgy = cgy + cymax
903  END IF
904  cxc = max( abs(cxmin) , abs(cxmax) )
905  cyc = max( abs(cymin) , abs(cymax) )
906 #ifdef W3_MGP
907  cxc = max( abs(cxmin-vgx) , abs(cxmax-vgx) )
908  cyc = max( abs(cymin-vgy) , abs(cymax-vgy) )
909 #endif
910  ELSE
911  cxc = 0.
912  cyc = 0.
913  END IF
914  !
915  cgn = max( abs(cgx) , abs(cgy) , cxc, cyc, 0.001*cg0 )
916  !
917  ntloc = 1 + int(dtg/(dtcfl*cg0/cgn))
918  dtloc = dtg / real(ntloc)
919  dtrad = dtloc
920  IF ( flagll ) dtrad=dtrad/(dera*radius)
921  !
922  ttest(1) = time(1)
923  ttest(2) = 0
924  dttst = dsec21(ttest,time)
925  yfirst = mod(nint(dttst/dtg),2) .EQ. 0
926  !
927 #ifdef W3_T
928  WRITE (ndst,9000) yfirst
929  WRITE (ndst,9001) isp, ith, ik, ecos(ith), esin(ith)
930 #endif
931  !
932  ! 1.b Initialize arrays
933  !
934 #ifdef W3_T
935  WRITE (ndst,9010)
936 #endif
937  !
938  vlcflx = 0.
939  vlcfly = 0.
940  cxtot = 0.
941  cytot = 0.
942  !
943  mapstx(1:nx*ny) = mapsta(1:nx*ny)
944  !
945  IF ( global ) THEN
946  mapstx(1-2*ny:0) = mapsta((nx-2)*ny+1:nx*ny)
947  mapstx(nx*ny+1:nx*ny+2*ny) = mapsta(1:2*ny)
948  ELSE
949  mapstx(1-2*ny:0) = 0
950  mapstx(nx*ny+1:nx*ny+2*ny) = 0
951  END IF
952  !
953  ! 1.c Pre-calculate interpolation info
954  !
955  fth = fgse * wdth * dth * dtloc
956  fcg = fgse * wdcg * 0.5 * (xfr-1./xfr) * dtloc
957  IF ( flagll ) THEN
958  fth = fth / radius / dera
959  fcg = fcg / radius / dera
960  END IF
961  fcg = fcg / real(ntloc) !TJC: required to match original (is this correct?)
962  fthx = - fth * esin(ith)
963  fthy = fth * ecos(ith)
964  fcgx = fcg * ecos(ith)
965  fcgy = fcg * esin(ith)
966  !
967 #ifdef W3_T0
968  WRITE (ndst,9011)
969 #endif
970  !
971 #ifdef W3_OMPH
972  !$OMP PARALLEL DO PRIVATE (ISEA, IX, IY, TMPX, TMPY, &
973  !$OMP& DXCGN, DYCGN, DXCGS, DYCGS, DXCGC, DYCGC, &
974  !$OMP& IXC, IYC)
975 #endif
976  !
977  DO isea=1, nsea
978  !
979  ix = mapsf(isea,1)
980  iy = mapsf(isea,2)
981  !
982  ! 1.c.1 Normal and parallel width ...
983  !
984  tmpx = fthx / clats(isea)
985  tmpy = fthy
986  dxcgn = dpdx(iy,ix)*tmpx + dpdy(iy,ix)*tmpy
987  dycgn = dqdx(iy,ix)*tmpx + dqdy(iy,ix)*tmpy
988  tmpx = fcgx / clats(isea)
989  tmpy = fcgy
990  dxcgs = dpdx(iy,ix)*tmpx + dpdy(iy,ix)*tmpy
991  dycgs = dqdx(iy,ix)*tmpx + dqdy(iy,ix)*tmpy
992  !
993  ! 1.c.2 "Sum" corner (and mirror image) ...
994  !
995  dxcgc = dxcgn + dxcgs
996  dycgc = dycgn + dycgs
997  !
998  ixc = ny
999  IF ( dxcgc .LT. 0. ) ixc = - ixc
1000  iyc = 1
1001  IF ( dycgc .LT. 0. ) iyc = - iyc
1002  !
1003  iixy1(isea) = ixc + iyc
1004  IF ( abs(dxcgc) .GT. abs(dycgc) ) THEN
1005  iixy2(isea) = ixc
1006  rdi1(isea) = abs(dycgc/dxcgc)
1007  rdi2(isea) = abs(dxcgc)
1008  ELSE
1009  iixy2(isea) = iyc
1010  IF ( abs(dycgc) .GT. 1.e-5 ) THEN
1011  rdi1(isea) = abs(dxcgc/dycgc)
1012  ELSE
1013  rdi1(isea) = 1.
1014  END IF
1015  rdi2(isea) = abs(dycgc)
1016  END IF
1017  !
1018 #ifdef W3_T0
1019  WRITE (ndst,9012) isea, ith, iixy1(isea), iixy2(isea), &
1020  rdi1(isea), rdi2(isea)*cg(ik,1)
1021 #endif
1022  !
1023  ! 1.c.2 "Difference" corner (and mirror image) ...
1024  !
1025  dxcgc = dxcgn - dxcgs
1026  dycgc = dycgn - dycgs
1027  !
1028  ixc = ny
1029  IF ( dxcgc .LT. 0. ) ixc = - ixc
1030  iyc = 1
1031  IF ( dycgc .LT. 0. ) iyc = - iyc
1032  !
1033  iixy3(isea) = ixc + iyc
1034  IF ( abs(dxcgc) .GT. abs(dycgc) ) THEN
1035  iixy4(isea) = ixc
1036  rdi3(isea) = abs(dycgc/dxcgc)
1037  rdi4(isea) = abs(dxcgc)
1038  ELSE
1039  iixy4(isea) = iyc
1040  IF ( abs(dycgc) .GT. 1.e-5 ) THEN
1041  rdi3(isea) = abs(dxcgc/dycgc)
1042  ELSE
1043  rdi3(isea) = 1.
1044  END IF
1045  rdi4(isea) = abs(dycgc)
1046  END IF
1047  !
1048 #ifdef W3_T0
1049  WRITE (ndst,9013) iixy3(isea), iixy4(isea), rdi3(isea), &
1050  rdi4(isea)*cg(ik,1)
1051 #endif
1052  !
1053  END DO
1054  !
1055 #ifdef W3_OMPH
1056  !$OMP END PARALLEL DO
1057 #endif
1058  !
1059  ! 2. Calculate velocities and diffusion coefficients ---------------- *
1060  ! 2.a Velocities
1061  !
1062  ! Q = ( A / CG * CLATS )
1063  ! LCFLX = ( COS*CG / CLATS ) * DT / DX
1064  ! LCFLY = ( SIN*CG ) * DT / DY
1065  !
1066 #ifdef W3_T
1067  WRITE (ndst,9020) nsea
1068 #endif
1069  !
1070 #ifdef W3_OMPH
1071  !$OMP PARALLEL DO PRIVATE (ISEA, IXY)
1072 #endif
1073  !
1074  DO isea=1, nsea
1075  ixy = mapsf(isea,3)
1076  vq(ixy) = vq(ixy) / cg(ik,isea) * clats(isea)
1077  cxtot(ixy) = ecos(ith) * cg(ik,isea) / clats(isea)
1078  cytot(ixy) = esin(ith) * cg(ik,isea)
1079 #ifdef W3_MGP
1080  cxtot(ixy) = cxtot(ixy) - vgx/clats(isea)
1081  cytot(ixy) = cytot(ixy) - vgy
1082 #endif
1083 #ifdef W3_T1
1084  IF ( .NOT. flcur ) &
1085  WRITE (ndst,9021) isea, mapsf(isea,1), mapsf(isea,2), &
1086  vq(ixy), cxtot(ixy), cytot(ixy)
1087 #endif
1088  END DO
1089  !
1090 #ifdef W3_OMPH
1091  !$OMP END PARALLEL DO
1092 #endif
1093  !
1094  IF ( flcur ) THEN
1095 #ifdef W3_T
1096  WRITE (ndst,9022)
1097 #endif
1098  !
1099 #ifdef W3_OMPH
1100  !$OMP PARALLEL DO PRIVATE (ISEA,IXY)
1101 #endif
1102  !
1103  DO isea=1, nsea
1104  ixy = mapsf(isea,3)
1105  cxtot(ixy) = cxtot(ixy) + cx(isea)/clats(isea)
1106  cytot(ixy) = cytot(ixy) + cy(isea)
1107 #ifdef W3_T1
1108  WRITE (ndst,9021) isea, mapsf(isea,1), mapsf(isea,2), &
1109  vq(ixy), cxtot(ixy), cytot(ixy)
1110 #endif
1111  END DO
1112  !
1113 #ifdef W3_OMPH
1114  !$OMP END PARALLEL DO
1115 #endif
1116  !
1117  END IF
1118  !
1119 #ifdef W3_OMPH
1120  !$OMP PARALLEL DO PRIVATE (ISEA,IX, IY, IXY, CP, CQ)
1121 #endif
1122  !
1123  DO isea=1, nsea
1124  ix = mapsf(isea,1)
1125  iy = mapsf(isea,2)
1126  ixy = mapsf(isea,3)
1127  cp = cxtot(ixy)*dpdx(iy,ix) + cytot(ixy)*dpdy(iy,ix)
1128  cq = cxtot(ixy)*dqdx(iy,ix) + cytot(ixy)*dqdy(iy,ix)
1129  vlcflx(ixy) = cp*dtrad
1130  vlcfly(ixy) = cq*dtrad
1131  END DO
1132  !
1133 #ifdef W3_OMPH
1134  !$OMP END PARALLEL DO
1135 #endif
1136  !
1137  ! 3. Loop over sub-steps -------------------------------------------- *
1138  !
1139  DO itloc=1, ntloc
1140  !
1141  ! 3.a Average
1142  !
1143  aq = vq
1144  vq = 0.
1145  !
1146  ! 3.a.1 Central points
1147  !
1148  DO ip=1, ncent
1149  isea = mapcxy(ip)
1150  ixy = mapsf(isea,3)
1151  IF ( maptrn(ixy) ) THEN
1152  vq(ixy) = aq(ixy)
1153  ELSE
1154  rd1 = rdi1(isea)
1155  rd2 = min( 1. , rdi2(isea) * cg(ik,isea) )
1156  rd3 = rdi3(isea)
1157  rd4 = min( 1. , rdi4(isea) * cg(ik,isea) )
1158  vq(ixy ) = vq(ixy ) &
1159  + aq(ixy) * (3.-rd2-rd4)/3.
1160  vq(ixy+iixy1(isea)) = vq(ixy+iixy1(isea)) &
1161  + aq(ixy) * rd2*rd1/6.
1162  vq(ixy+iixy2(isea)) = vq(ixy+iixy2(isea)) &
1163  + aq(ixy) * (1.-rd1)*rd2/6.
1164  vq(ixy+iixy3(isea)) = vq(ixy+iixy3(isea)) &
1165  + aq(ixy) * rd4*rd3/6.
1166  vq(ixy+iixy4(isea)) = vq(ixy+iixy4(isea)) &
1167  + aq(ixy) * (1.-rd3)*rd4/6.
1168  vq(ixy-iixy1(isea)) = vq(ixy-iixy1(isea)) &
1169  + aq(ixy) * rd2*rd1/6.
1170  vq(ixy-iixy2(isea)) = vq(ixy-iixy2(isea)) &
1171  + aq(ixy) * (1.-rd1)*rd2/6.
1172  vq(ixy-iixy3(isea)) = vq(ixy-iixy3(isea)) &
1173  + aq(ixy) * rd4*rd3/6.
1174  vq(ixy-iixy4(isea)) = vq(ixy-iixy4(isea)) &
1175  + aq(ixy) * (1.-rd3)*rd4/6.
1176  END IF
1177  END DO
1178  !
1179  ! 3.a.2 Near-coast points
1180  !
1181  DO ip=ncent+1, nsea
1182  isea = mapcxy(ip)
1183  ix = mapsf(isea,1)
1184  ixy = mapsf(isea,3)
1185  IF ( mapsta(ixy) .LE. 0 ) cycle
1186  IF ( maptrn(ixy) ) THEN
1187  vq(ixy) = aq(ixy)
1188  ELSE
1189  rd1 = rdi1(isea)
1190  rd3 = rdi3(isea)
1191  rd2 = min( 1. , rdi2(isea) * cg(ik,isea) )
1192  rd4 = min( 1. , rdi4(isea) * cg(ik,isea) )
1193  vq(ixy ) = vq(ixy ) &
1194  + aq(ixy) * (3.-rd2-rd4)/3.
1195  !
1196  ixc = sign(ny,iixy1(isea))
1197  iyc = iixy1(isea) - ixc
1198  IF ( mapstx(ixy+iixy1(isea)) .GE. 1 .AND. &
1199  .NOT. ( mapstx(ixy+ixc).LE.0 .AND. &
1200  mapstx(ixy+iyc).LE.0 ) ) THEN
1201  vq(ixy+iixy1(isea)) = vq(ixy+iixy1(isea)) &
1202  + aq(ixy) * rd2*rd1/6.
1203  ELSE
1204  vq(ixy ) = vq(ixy ) &
1205  + aq(ixy) * rd2*rd1/6.
1206  END IF
1207  IF ( mapstx(ixy-iixy1(isea)) .GE. 1 .AND. &
1208  .NOT. ( mapstx(ixy-ixc).LE.0 .AND. &
1209  mapstx(ixy-iyc).LE.0 ) ) THEN
1210  vq(ixy-iixy1(isea)) = vq(ixy-iixy1(isea)) &
1211  + aq(ixy) * rd2*rd1/6.
1212  ELSE
1213  vq(ixy ) = vq(ixy ) &
1214  + aq(ixy) * rd2*rd1/6.
1215  END IF
1216 
1217  IF ( mapstx(ixy+iixy2(isea)) .GE. 1 ) THEN
1218  vq(ixy+iixy2(isea)) = vq(ixy+iixy2(isea)) &
1219  + aq(ixy) * (1.-rd1)*rd2/6.
1220  ELSE
1221  vq(ixy ) = vq(ixy ) &
1222  + aq(ixy) * (1.-rd1)*rd2/6.
1223  END IF
1224  IF ( mapstx(ixy-iixy2(isea)) .GE. 1 ) THEN
1225  vq(ixy-iixy2(isea)) = vq(ixy-iixy2(isea)) &
1226  + aq(ixy) * (1.-rd1)*rd2/6.
1227  ELSE
1228  vq(ixy ) = vq(ixy ) &
1229  + aq(ixy) * (1.-rd1)*rd2/6.
1230  END IF
1231  !
1232  ixc = sign(ny,iixy3(isea))
1233  iyc = iixy3(isea) - ixc
1234  IF ( mapstx(ixy+iixy3(isea)) .GE. 1 .AND. &
1235  .NOT. ( mapstx(ixy+ixc).LE.0 .AND. &
1236  mapstx(ixy+iyc).LE.0 ) ) THEN
1237  vq(ixy+iixy3(isea)) = vq(ixy+iixy3(isea)) &
1238  + aq(ixy) * rd4*rd3/6.
1239  ELSE
1240  vq(ixy ) = vq(ixy ) &
1241  + aq(ixy) * rd4*rd3/6.
1242  END IF
1243  IF ( mapstx(ixy-iixy3(isea)) .GE. 1 .AND. &
1244  .NOT. ( mapstx(ixy-ixc).LE.0 .AND. &
1245  mapstx(ixy-iyc).LE.0 ) ) THEN
1246  vq(ixy-iixy3(isea)) = vq(ixy-iixy3(isea)) &
1247  + aq(ixy) * rd4*rd3/6.
1248  ELSE
1249  vq(ixy ) = vq(ixy ) &
1250  + aq(ixy) * rd4*rd3/6.
1251  END IF
1252  !
1253  IF ( mapstx(ixy+iixy4(isea)) .GE. 1 ) THEN
1254  vq(ixy+iixy4(isea)) = vq(ixy+iixy4(isea)) &
1255  + aq(ixy) * (1.-rd3)*rd4/6.
1256  ELSE
1257  vq(ixy ) = vq(ixy ) &
1258  + aq(ixy) * (1.-rd3)*rd4/6.
1259  END IF
1260  IF ( mapstx(ixy-iixy4(isea)) .GE. 1 ) THEN
1261  vq(ixy-iixy4(isea)) = vq(ixy-iixy4(isea)) &
1262  + aq(ixy) * (1.-rd3)*rd4/6.
1263  ELSE
1264  vq(ixy ) = vq(ixy ) &
1265  + aq(ixy) * (1.-rd3)*rd4/6.
1266  END IF
1267  !
1268  END IF
1269  !
1270  END DO
1271  !
1272  ! 3.a.3 Restore boundary data
1273  !
1274  DO ixy=1, nx*ny
1275  IF ( mapsta(ixy).EQ.2 ) vq(ixy) = aq(ixy)
1276  END DO
1277  !
1278  ! 3.a.4 Global closure (averaging only, propagation is closed in W3QCK3).
1279  !
1280  IF ( global ) THEN
1281  DO iy=1, ny
1282  vq(iy ) = vq(iy ) + vq(nx*ny+iy)
1283  vq((nx-1)*ny+iy) = vq((nx-1)*ny+iy) + vq(iy-ny)
1284  END DO
1285  END IF
1286  !
1287  ! 3.b Propagate fields
1288  !
1289  ! Transform VQ to straightened space
1290  !
1291 #ifdef W3_OMPH
1292  !$OMP PARALLEL DO PRIVATE (ISEA, IX, IY, IXY)
1293 #endif
1294  !
1295  DO isea=1, nsea
1296  ix = mapsf(isea,1)
1297  iy = mapsf(isea,2)
1298  ixy = mapsf(isea,3)
1299  vq(ixy)= vq(ixy) * gsqrt(iy,ix)
1300  END DO
1301  !
1302 #ifdef W3_OMPH
1303  !$OMP END PARALLEL DO
1304 #endif
1305  !
1306  IF ( yfirst ) THEN
1307  !
1308 #ifdef W3_UQ
1309  IF ( flcy ) CALL w3qck3 &
1310  (nx, ny, nx, ny, vlcfly, atrny, vq, &
1311  .false., 1, mapaxy, nact, mapy2, nmy0, &
1312  nmy1, nmy2, ndse, ndst )
1313  IF ( flcx ) CALL w3qck3 &
1314  (nx, ny, nx, ny, vlcflx, atrnx, vq, &
1315  global, ny, mapaxy, nact, mapx2, nmx0, &
1316  nmx1, nmx2, ndse, ndst )
1317 #endif
1318  !
1319 #ifdef W3_UNO
1320  IF ( flcy ) CALL w3uno2s &
1321  (nx, ny, nx, ny, vlcfly, atrny, vq, &
1322  .false., 1, mapaxy, nact, mapy2, nmy0, &
1323  nmy1, nmy2, ndse, ndst )
1324  IF ( flcx ) CALL w3uno2s &
1325  (nx, ny, nx, ny, vlcflx, atrnx, vq, &
1326  global, ny, mapaxy, nact, mapx2, nmx0, &
1327  nmx1, nmx2, ndse, ndst )
1328 #endif
1329  !
1330  ELSE
1331  !
1332 #ifdef W3_UQ
1333  IF ( flcx ) CALL w3qck3 &
1334  (nx, ny, nx, ny, vlcflx, atrnx, vq, &
1335  global, ny, mapaxy, nact, mapx2, nmx0, &
1336  nmx1, nmx2, ndse, ndst )
1337  IF ( flcy ) CALL w3qck3 &
1338  (nx, ny, nx, ny, vlcfly, atrny, vq, &
1339  .false., 1, mapaxy, nact, mapy2, nmy0, &
1340  nmy1, nmy2, ndse, ndst )
1341 #endif
1342  !
1343 #ifdef W3_UNO
1344  IF ( flcx ) CALL w3uno2s &
1345  (nx, ny, nx, ny, vlcflx, atrnx, vq, &
1346  global, ny, mapaxy, nact, mapx2, nmx0, &
1347  nmx1, nmx2, ndse, ndst )
1348  IF ( flcy ) CALL w3uno2s &
1349  (nx, ny, nx, ny, vlcfly, atrny, vq, &
1350  .false., 1, mapaxy, nact, mapy2, nmy0, &
1351  nmy1, nmy2, ndse, ndst )
1352 #endif
1353  !
1354  END IF
1355  !
1356  ! Transform VQ back to normal space
1357  !
1358 #ifdef W3_OMPH
1359  !$OMP PARALLEL DO PRIVATE (ISEA, IX, IY, IXY)
1360 #endif
1361  !
1362  DO isea=1, nsea
1363  ix = mapsf(isea,1)
1364  iy = mapsf(isea,2)
1365  ixy = mapsf(isea,3)
1366  vq(ixy)= vq(ixy) / gsqrt(iy,ix)
1367  END DO
1368  !
1369 #ifdef W3_OMPH
1370  !$OMP END PARALLEL DO
1371 #endif
1372  !
1373  ! 3.c Update boundaries
1374  !
1375 #ifdef W3_T
1376  WRITE (ndst,9030) nsea
1377 #endif
1378  !
1379 #ifdef W3_T2
1380  DO isea=1, nsea
1381  ixy = mapsf(isea,3)
1382  IF ( mapsta(ixy) .GT. 0 ) THEN
1383  WRITE(ndst,9031)isea,mapsf(isea,1),mapsf(isea,2),vq(ixy)
1384  vq(ixy) = max( 0. , cg(ik,isea)/clats(isea)*vq(ixy) )
1385  END IF
1386  END DO
1387 #endif
1388  !
1389  IF ( flbpi ) THEN
1390  rd1 = dsec21( tbpi0, time ) - dtg * &
1391  REAL(NTLOC-ITLOC)/REAL(NTLOC)
1392  rd2 = dsec21( tbpi0, tbpin )
1393  IF ( rd2 .GT. 0.001 ) THEN
1394  rd2 = min(1.,max(0.,rd1/rd2))
1395  rd1 = 1. - rd2
1396  ELSE
1397  rd1 = 0.
1398  rd2 = 1.
1399  END IF
1400  DO ibi=1, nbi
1401  ixy = mapsf(isbpi(ibi),3)
1402  vq(ixy) = ( rd1*bbpi0(isp,ibi) + rd2*bbpin(isp,ibi) ) &
1403  / cg(ik,isbpi(ibi)) * clats(isbpi(ibi))
1404  END DO
1405  END IF
1406  !
1407  yfirst = .NOT. yfirst
1408  END DO
1409  !
1410  ! 4. Store results in VQ in proper format --------------------------- *
1411  !
1412 #ifdef W3_T
1413  WRITE (ndst,9040) nsea
1414 #endif
1415  !
1416 #ifdef W3_OMPH
1417  !$OMP PARALLEL DO PRIVATE (ISEA, IXY)
1418 #endif
1419  !
1420  DO isea=1, nsea
1421  ixy = mapsf(isea,3)
1422  IF ( mapsta(ixy) .GT. 0 ) THEN
1423 #ifdef W3_T3
1424  WRITE (ndst,9041) isea, mapsf(isea,1), mapsf(isea,2), vq(ixy)
1425 #endif
1426  vq(ixy) = max( 0. , cg(ik,isea)/clats(isea)*vq(ixy) )
1427  END IF
1428  END DO
1429  !
1430 #ifdef W3_OMPH
1431  !$OMP END PARALLEL DO
1432 #endif
1433  !
1434  RETURN
1435  !
1436  ! Formats
1437  !
1438 #ifdef W3_T
1439 9000 FORMAT (' TEST W3XYP3 : YFIRST :',l2)
1440 9001 FORMAT (' TEST W3XYP3 : ISP, ITH, IK, COS-SIN :',i8,2i4,2f7.3)
1441 9010 FORMAT (' TEST W3XYP3 : INITIALIZE ARRAYS')
1442 9020 FORMAT (' TEST W3XYP3 : CALCULATING VCFL0X/Y (NSEA=',i6,')')
1443 9022 FORMAT (' TEST W3XYP3 : CALCULATING VCFLUX/Y')
1444 9030 FORMAT (' TEST W3XYP3 : FIELD BEFORE BPI. (NSEA=',i6,')')
1445 9040 FORMAT (' TEST W3XYP3 : FIELD AFTER PROP. (NSEA=',i6,')')
1446 #endif
1447 #ifdef W3_T0
1448 9011 FORMAT (' TEST W3XYP3 : PREPARE AVERAGING')
1449 9012 FORMAT (' ',4i4,2f7.3)
1450 9013 FORMAT (' ',8x,2i4,2f7.3)
1451 #endif
1452  !
1453 #ifdef W3_T1
1454 9021 FORMAT (1x,i6,2i5,e12.4,2f7.3)
1455 #endif
1456  !
1457 #ifdef W3_T2
1458 9031 FORMAT (1x,i6,2i5,e12.4)
1459 #endif
1460  !
1461 #ifdef W3_T3
1462 9041 FORMAT (1x,i6,2i5,e12.4)
1463 #endif
1464  !/
1465  !/ End of W3XYP3 ----------------------------------------------------- /
1466  !/
1467  END SUBROUTINE w3xyp3
1468  !/ ------------------------------------------------------------------- /
1509  SUBROUTINE w3ktp3 ( ISEA, FACTH, FACK, CTHG0, CG, WN, DW, &
1510  DDDX, DDDY, CX, CY, DCXDX, DCXDY, &
1511  DCYDX, DCYDY, DCDX, DCDY, VA, CFLTHMAX, CFLKMAX )
1512  !/
1513  !/ *** THIS ROUTINE SHOULD BE IDENTICAL TO W3KTP2 ***
1514  !/
1515  !/ +-----------------------------------+
1516  !/ | WAVEWATCH III NOAA/NCEP |
1517  !/ | H. L. Tolman |
1518  !/ | FORTRAN 90 |
1519  !/ | Last update : 01-Jul-2013 |
1520  !/ +-----------------------------------+
1521  !/
1522  !/ 14-Feb-2000 : Origination. ( version 2.08 )
1523  !/ 17-Dec-2004 : Multiple grid version. ( version 3.06 )
1524  !/ 06-Mar-2011 : Output of maximum CFL (F. Ardhuin) ( version 3.14 )
1525  !/ 24-Aug-2011 : Limiter on k advection (F. Ardhuin) ( version 4.04 )
1526  !/ 25-Aug-2011 : DEPTH = MAX ( DMIN, DW(ISEA) ) ( version 4.04 )
1527  !/ 26-Dec-2012 : More initializations. ( version 4.11 )
1528  !/ 01-Jul-2013 : Adding UQ and UNO switches to chose between third
1529  !/ and second order schemes. ( version 4.12 )
1530  !/
1531  ! 1. Purpose :
1532  !
1533  ! Propagation in spectral space.
1534  !
1535  ! 2. Method :
1536  !
1537  ! Third order QUICKEST scheme with ULTIMATE limiter.
1538  !
1539  ! As with the spatial propagation, the two spaces are considered
1540  ! independently, but the propagation is performed in a 2-D space.
1541  ! Compared to the propagation in physical space, the directions
1542  ! rerpesent a closed space and are therefore comparable to the
1543  ! longitudinal or 'X' propagation. The wavenumber space has to be
1544  ! extended to allow for boundary treatment. Using a simple first
1545  ! order boundary treatment at both sided, two points need to
1546  ! be added. This implies that the spectrum needs to be extended,
1547  ! shifted and rotated, as is performed using MAPTH2 as set
1548  ! in W3MAP3.
1549  !
1550  ! 3. Parameters :
1551  !
1552  ! Parameter list
1553  ! ----------------------------------------------------------------
1554  ! ISEA Int. I Number of sea point.
1555  ! FACTH/K Real I Factor in propagation velocity.
1556  ! CTHG0 Real I Factor in great circle refracftion term.
1557  ! MAPxx2 I.A. I Propagation and storage maps.
1558  ! CG R.A. I Local group velocities.
1559  ! WN R.A. I Local wavenumbers.
1560  ! DW R.A. I Depth.
1561  ! DDDx Real I Depth gradients.
1562  ! CX/Y Real I Current components.
1563  ! DCxDx Real I Current gradients.
1564  ! DCDX-Y Real I Phase speed gradients.
1565  ! VA R.A. I/O Spectrum.
1566  ! ----------------------------------------------------------------
1567  !
1568  ! Local variables.
1569  ! ----------------------------------------------------------------
1570  ! DSDD R.A. Partial derivative of sigma for depth.
1571  ! FDD, FDU, FDG, FCD, FCU
1572  ! R.A. Directionally varying part of depth, current and
1573  ! great-circle refraction terms and of consit.
1574  ! of Ck term.
1575  ! CFLT-K R.A. Propagation velocities of local fluxes.
1576  ! DB R.A. Wavenumber band widths at cell centers.
1577  ! DM R.A. Wavenumber band widths between cell centers and
1578  ! next cell center.
1579  ! Q R.A. Extracted spectrum
1580  ! ----------------------------------------------------------------
1581  !
1582  ! 4. Subroutines used :
1583  !
1584  ! W3QCK1 Actual propagation routine.
1585  ! W3QCK2 Actual propagation routine.
1586  ! STRACE Service routine.
1587  !
1588  ! 5. Called by :
1589  !
1590  ! W3WAVE Wave model routine.
1591  !
1592  ! 6. Error messages :
1593  !
1594  ! None.
1595  !
1596  ! 8. Structure :
1597  !
1598  ! -----------------------------------------------------------------
1599  ! 1. Preparations
1600  ! a Initialize arrays
1601  ! b Set constants and counters
1602  ! 2. Point preparations
1603  ! a Calculate DSDD
1604  ! b Extract spectrum
1605  ! 3. Refraction velocities
1606  ! a Filter level depth reffraction.
1607  ! b Depth refratcion velocity.
1608  ! c Current refraction velocity.
1609  ! 4. Wavenumber shift velocities
1610  ! a Prepare directional arrays
1611  ! b Calcuate velocity.
1612  ! 5. Propagate.
1613  ! 6. Store results.
1614  ! -----------------------------------------------------------------
1615  !
1616  ! 9. Switches :
1617  !
1618  ! !/S Enable subroutine tracing.
1619  ! !/T Enable general test output.
1620  !
1621  ! 10. Source code :
1622  !
1623  !/ ------------------------------------------------------------------- /
1624  USE constants
1625  USE w3gdatmd, ONLY: nk, nk2, nth, nspec, sig, dsip, ecos, esin, &
1626  ec2, esc, es2, fachfa, mapwn, flcth, flck, &
1627  ctmax, dmin
1628  USE w3adatmd, ONLY: mapth2, mapwn2, itime
1629  USE w3idatmd, ONLY: flcur
1630  USE w3odatmd, ONLY: ndse, ndst
1631 #ifdef W3_S
1632  USE w3servmd, ONLY: strace
1633 #endif
1634 #ifdef W3_UQ
1635  USE w3uqckmd
1636 #endif
1637 #ifdef W3_UNO
1638  USE w3uno2md
1639 #endif
1640  !/
1641  IMPLICIT NONE
1642  !/
1643  !/ ------------------------------------------------------------------- /
1644  !/ Parameter list
1645  !/
1646  INTEGER, INTENT(IN) :: ISEA
1647  REAL, INTENT(IN) :: FACTH, FACK, CTHG0, CG(0:NK+1), &
1648  WN(0:NK+1), DW, DDDX, DDDY, &
1649  CX, CY, DCXDX, DCXDY, DCYDX, DCYDY
1650  REAL, INTENT(IN) :: DCDX(0:NK+1), DCDY(0:NK+1)
1651  REAL, INTENT(INOUT) :: VA(NSPEC)
1652  REAL, INTENT(OUT) :: CFLTHMAX, CFLKMAX
1653  !/
1654  !/ ------------------------------------------------------------------- /
1655  !/ Local parameters
1656  !/
1657  INTEGER :: ITH, IK, ISP
1658 #ifdef W3_S
1659  INTEGER, SAVE :: IENT = 0
1660 #endif
1661  REAL :: FDDMAX, FDG, FKD, FKD0, DCYX, &
1662  DCXXYY, DCXY, DCXX, DCXYYX, DCYY, &
1663  VELNOFILT, VELFAC, DEPTH
1664  REAL :: DSDD(0:NK+1), FRK(NK), FRG(NK), &
1665  FKC(NTH), VQ(-NK-1:NK2*(NTH+2)), &
1666  DB(NK2,NTH+1), DM(NK2,0:NTH+1), &
1667  VCFLT(NK2*(NTH+1)), CFLK(NK2,NTH)
1668  !/
1669  !/ ------------------------------------------------------------------- /
1670  !/
1671 #ifdef W3_S
1672  CALL strace (ient, 'W3KTP3')
1673 #endif
1674  !
1675  ! 1. Preparations --------------------------------------------------- *
1676  ! 1.a Initialize arrays
1677  !
1678  depth = max( dmin, dw )
1679  vq = 0.
1680  IF ( flcth ) vcflt = 0.
1681  IF ( flck ) cflk = 0.
1682  cflthmax = 0.
1683  cflkmax = 0.
1684  !
1685 #ifdef W3_T
1686  WRITE (ndst,9000) flcth, flck, facth, fack, ctmax
1687  WRITE (ndst,9010) isea, depth, cx, cy, dddx, dddy, &
1688  dcxdx, dcxdy, dcydx, dcydy
1689 #endif
1690  !
1691  ! 2. Preparation for point ------------------------------------------ *
1692  ! 2.a Array with partial derivative of sigma versus depth
1693  !
1694  DO ik=0, nk+1
1695  IF ( depth*wn(ik) .LT. 5. ) THEN
1696  dsdd(ik) = max( 0. , &
1697  cg(ik)*wn(ik)-0.5*sig(ik) ) / depth
1698  ELSE
1699  dsdd(ik) = 0.
1700  END IF
1701  END DO
1702  !
1703 #ifdef W3_T
1704  WRITE (ndst,9020)
1705  DO ik=1, nk+1
1706  WRITE (ndst,9021) ik, tpi/sig(ik), tpi/wn(ik), &
1707  cg(ik), dsdd(ik)
1708  END DO
1709 #endif
1710  !
1711  ! 2.b Extract spectrum
1712  !
1713  DO isp=1, nspec
1714  vq(mapth2(isp)) = va(isp)
1715  END DO
1716  !
1717  ! 3. Refraction velocities ------------------------------------------ *
1718  !
1719  IF ( flcth ) THEN
1720  !
1721  ! 3.a Set slope filter for depth refraction
1722  !
1723  ! N.B.: FACTH = DTG / DTH / REAL(NTLOC) (value set in w3wavemd)
1724  ! namely, FACTH*VC=1 corresponds to CFL=1
1725  !
1726  fddmax = 0.
1727  fdg = facth * cthg0
1728  !
1729  DO ith=1, nth/2
1730  fddmax = max(fddmax,abs(esin(ith)*dddx-ecos(ith)*dddy))
1731  END DO
1732  !
1733  DO ik=1, nk
1734  frk(ik) = facth * dsdd(ik) / wn(ik)
1735  !
1736  ! Removes the filtering that was done at that stage (F. Ardhuin 2011/03/06)
1737  !
1738  ! FRK(IK) = FRK(IK) / MAX ( 1. , FRK(IK)*FDDMAX/CTMAX )
1739  frg(ik) = fdg * cg(ik)
1740  END DO
1741  !
1742  ! 3.b Current refraction
1743  !
1744  IF ( flcur ) THEN
1745  !
1746  dcyx = facth * dcydx
1747  dcxxyy = facth * ( dcxdx - dcydy )
1748  dcxy = facth * dcxdy
1749  !
1750  DO isp=1, nspec
1751  vcflt(mapth2(isp)) = es2(isp)*dcyx + &
1752  esc(isp)*dcxxyy - ec2(isp)*dcxy
1753  END DO
1754  !
1755  ELSE
1756  vcflt(:)=0.
1757  END IF
1758  !
1759  ! 3.c Depth refraction and great-circle propagation
1760  !
1761 #ifdef W3_REFRX
1762  ! 3.d @C/@x refraction and great-circle propagation
1763  frk = 0.
1764  fddmax = 0.
1765  !
1766  DO isp=1, nspec
1767  fddmax = max( fddmax , abs( &
1768  esin(isp)*dcdx(mapwn(isp)) - ecos(isp)*dcdy(mapwn(isp)) ) )
1769  END DO
1770  DO ik=1, nk
1771  frk(ik) = facth * cg(ik) * wn(ik) / sig(ik)
1772  END DO
1773 #endif
1774  !
1775  DO isp=1, nspec
1776  velnofilt = vcflt(mapth2(isp)) &
1777  + frg(mapwn(isp)) * ecos(isp) &
1778  + frk(mapwn(isp)) * ( esin(isp)*dddx - ecos(isp)*dddy )
1779  !
1780 #ifdef W3_REFRX
1781  ! 3.d @C/@x refraction and great-circle propagation
1782  velnofilt = vcflt(mapth2(isp)) &
1783  + frg(mapwn(isp)) * ecos(isp) &
1784  + frk(mapwn(isp)) * ( esin(isp)*dcdx(mapwn(isp)) &
1785  - ecos(isp)*dcdy(mapwn(isp)) )
1786 #endif
1787  cflthmax = max(cflthmax, abs(velnofilt))
1788  !
1789  ! Puts filtering on total velocity (including currents and great circle effects)
1790  ! the filtering limits VCFLT to be less than CTMAX
1791  ! this modification was proposed by F. Ardhuin 2011/03/06
1792  !
1793  vcflt(mapth2(isp))=sign(min(abs(velnofilt),ctmax),velnofilt)
1794  END DO
1795  END IF
1796  !
1797  ! 4. Wavenumber shift velocities ------------------------------------ *
1798  ! N.B.: FACK = DTG / REAL(NTLOC) (value set in w3wavemd)
1799  ! namely, FACK*VC/DK=1 corresponds to CFL=1
1800  !
1801  IF ( flck ) THEN
1802  !
1803  ! 4.a Directionally dependent part
1804  !
1805  dcxx = - dcxdx
1806  dcxyyx = - ( dcxdy + dcydx )
1807  dcyy = - dcydy
1808  fkd = ( cx*dddx + cy*dddy )
1809  !
1810  DO ith=1, nth
1811  fkc(ith) = ec2(ith)*dcxx + &
1812  esc(ith)*dcxyyx + es2(ith)*dcyy
1813  END DO
1814  !
1815  ! 4.b Band widths
1816  !
1817  DO ik=0, nk
1818  db(ik+1,1) = dsip(ik) / cg(ik)
1819  dm(ik+1,1) = wn(ik+1) - wn(ik)
1820  END DO
1821  db(nk+2,1) = dsip(nk+1) / cg(nk+1)
1822  dm(nk+2,1) = 0.
1823  !
1824  DO ith=2, nth
1825  DO ik=1, nk+2
1826  db(ik,ith) = db(ik,1)
1827  dm(ik,ith) = dm(ik,1)
1828  END DO
1829  END DO
1830  !
1831  ! 4.c Velocities
1832  !
1833  DO ik=0, nk+1
1834  fkd0 = fkd / cg(ik) * dsdd(ik)
1835  velfac = fack/db(ik+1,1)
1836  DO ith=1, nth
1837  !
1838  ! Puts filtering on velocity (needs the band widths)
1839  !
1840  velnofilt = ( fkd0 + wn(ik)*fkc(ith) ) * velfac ! this is velocity * DT / DK
1841  cflkmax = max(cflkmax, abs(velnofilt))
1842  cflk(ik+1,ith) = sign(min(abs(velnofilt),ctmax),velnofilt)/velfac
1843  !CFLK(IK+1,ITH) = FKD0 + WN(IK)*FKC(ITH) ! this was without the limiter ...
1844  END DO
1845  END DO
1846  !
1847  END IF
1848  !
1849  ! 5. Propagate ------------------------------------------------------ *
1850  !
1851  IF ( mod(itime,2) .EQ. 0 ) THEN
1852  IF ( flck ) THEN
1853  DO ith=1, nth
1854  vq(nk+2+(ith-1)*nk2) = fachfa * vq(nk+1+(ith-1)*nk2)
1855  END DO
1856  !
1857 #ifdef W3_UQ
1858  CALL w3qck2 ( nth, nk2, nth, nk2, cflk, fack, db, dm, &
1859  vq, .false., 1, mapth2, nspec, &
1860  mapwn2, nspec-nth, nspec, nspec+nth, &
1861  ndse, ndst )
1862 #endif
1863  !
1864 #ifdef W3_UNO
1865  CALL w3uno2 ( nth, nk2, nth, nk2, cflk, fack, db, dm, &
1866  vq, .false., 1, mapth2, nspec, &
1867  mapwn2, nspec-nth, nspec, nspec+nth, &
1868  ndse, ndst )
1869 #endif
1870  !
1871  END IF
1872  IF ( flcth ) THEN
1873  !
1874 #ifdef W3_UQ
1875  CALL w3qck1 ( nth, nk2, nth, nk2, vcflt, vq, .true., &
1876  nk2, mapth2, nspec, mapth2, nspec, nspec, &
1877  nspec, ndse, ndst )
1878 #endif
1879  !
1880 #ifdef W3_UNO
1881  CALL w3uno2r( nth, nk2, nth, nk2, vcflt, vq, .true., &
1882  nk2, mapth2, nspec, mapth2, nspec, nspec,&
1883  nspec, ndse, ndst )
1884 #endif
1885  !
1886  END IF
1887  ELSE
1888  IF ( flcth ) THEN
1889  !
1890 #ifdef W3_UQ
1891  CALL w3qck1 ( nth, nk2, nth, nk2, vcflt, vq, .true., &
1892  nk2, mapth2, nspec, mapth2, nspec, nspec, &
1893  nspec, ndse, ndst )
1894 #endif
1895  !
1896 #ifdef W3_UNO
1897  CALL w3uno2r( nth, nk2, nth, nk2, vcflt, vq, .true., &
1898  nk2, mapth2, nspec, mapth2, nspec, nspec,&
1899  nspec, ndse, ndst )
1900 #endif
1901  !
1902  END IF
1903  IF ( flck ) THEN
1904  DO ith=1, nth
1905  vq(nk+2+(ith-1)*nk2) = fachfa * vq(nk+1+(ith-1)*nk2)
1906  END DO
1907  !
1908 #ifdef W3_UQ
1909  CALL w3qck2 ( nth, nk2, nth, nk2, cflk, fack, db, dm, &
1910  vq, .false., 1, mapth2, nspec, &
1911  mapwn2, nspec-nth, nspec, nspec+nth, &
1912  ndse, ndst )
1913 #endif
1914  !
1915 #ifdef W3_UNO
1916  CALL w3uno2 ( nth, nk2, nth, nk2, cflk, fack, db, dm, &
1917  vq, .false., 1, mapth2, nspec, &
1918  mapwn2, nspec-nth, nspec, nspec+nth, &
1919  ndse, ndst )
1920 #endif
1921  !
1922  END IF
1923  END IF
1924  !
1925  ! 6. Store reults --------------------------------------------------- *
1926  !
1927  DO isp=1, nspec
1928  va(isp) = vq(mapth2(isp))
1929  END DO
1930  !
1931  RETURN
1932  !
1933  ! Formats
1934  !
1935 #ifdef W3_T
1936 9000 FORMAT ( ' TEST W3KTP3 : FLCTH-K, FACTH-K, CTMAX :', &
1937  2l2,2e10.3,f7.3)
1938 9010 FORMAT ( ' TEST W3KTP3 : LOCAL DATA :',i7,f7.1,2f6.2,1x,6e10.2)
1939 9020 FORMAT ( ' TEST W3KTP3 : IK, T, L, CG, DSDD : ')
1940 9021 FORMAT ( ' ',i3,f7.2,f7.1,f7.2,e11.3)
1941 #endif
1942  !
1943 #ifdef W3_T0
1944 9040 FORMAT (/' TEST W3KTP3 : NORMALIZED ',a/)
1945 9041 FORMAT (1x,60(1x,i2))
1946 9042 FORMAT (1x,60i3)
1947 #endif
1948  !/
1949  !/ End of W3KTP3 ----------------------------------------------------- /
1950  !/
1951  END SUBROUTINE w3ktp3
1952  !/ ------------------------------------------------------------------- /
1970  SUBROUTINE w3cflxy ( ISEA, DTG, MAPSTA, MAPFS, CFLXYMAX, VGX, VGY )
1971  !/
1972  !/ +-----------------------------------+
1973  !/ | WAVEWATCH III NOAA/NCEP |
1974  !/ | F. Ardhuin |
1975  !/ | FORTRAN 90 |
1976  !/ | Last update : 31-Oct-2010 |
1977  !/ +-----------------------------------+
1978  !/
1979  !/ 07-Mar-2011 : Origination. ( version 3.14 )
1980  !/
1981  ! 1. Purpose :
1982  !
1983  ! Computes the maximum CFL number for spatial advection. Used for diagnostic
1984  ! purposes. (Could be used to define a local time step ...)
1985  !
1986  ! 2. Method :
1987  !
1988  !
1989  ! 3. Parameters :
1990  !
1991  ! Parameter list
1992  ! ----------------------------------------------------------------
1993  ! ISEA Int. I Index of grid point.
1994  ! DTG Real I Total time step.
1995  ! MAPSTA I.A. I Grid point status map.
1996  ! MAPFS I.A. I Storage map.
1997  ! CFLXYMAX Real O Maximum CFL number for XY propagation.
1998  ! VGX/Y Real I Speed of grid.
1999  ! ----------------------------------------------------------------
2000  !
2001  ! Local variables.
2002  ! ----------------------------------------------------------------
2003  ! NTLOC Int Number of local time steps.
2004  ! DTLOC Real Local propagation time step.
2005  ! VCFL0X R.A. Local courant numbers for absolute group vel.
2006  ! using local X-grid step.
2007  ! VCFL0Y R.A. Id. in Y.
2008  ! ----------------------------------------------------------------
2009  !
2010  ! 4. Subroutines used :
2011  !
2012  ! STRACE Service routine.
2013  !
2014  ! 5. Called by :
2015  !
2016  ! W3WAVE Wave model routine.
2017  !
2018  ! 6. Error messages :
2019  !
2020  ! None.
2021  !
2022  ! 7. Remarks :
2023  !
2024  ! - Curvilinear grid implementation. Variables FACX, FACY, CCOS, CSIN,
2025  ! CCURX, CCURY are not needed and have been removed. FACX is accounted
2026  ! for as approriate in this subroutine. FACX is also accounted for in
2027  ! the case of .NOT.FLCX. Since FACX is removed, there is now a check for
2028  ! .NOT.FLCX in this subroutine. In CFL calcs dx and dy are omitted,
2029  ! since dx=dy=1 in index space. Curvilinear grid derivatives
2030  ! (DPDY, DQDX, etc.) and metric (GSQRT) are brought in via W3GDATMD.
2031  !
2032  ! 8. Structure :
2033  !
2034  ! ---------------------------------------------
2035  ! ---------------------------------------------
2036  !
2037  ! 9. Switches :
2038  !
2039  ! !/S Enable subroutine tracing.
2040  !
2041  ! !/MGP Moving grid corrections.
2042  ! !/MGG Moving grid corrections.
2043  !
2044  ! !/T Enable general test output.
2045  !
2046  ! 10. Source code :
2047  !
2048  !/ ------------------------------------------------------------------- /
2049  USE constants
2050  !
2051  USE w3timemd, ONLY: dsec21
2052  !
2053  USE w3gdatmd, ONLY: nx, ny, nsea, mapsf, dtcfl, clats, &
2054  flcx, flcy, nk, nth, dth, xfr, &
2055  ecos, esin, sig, wdcg, wdth, pfmove, &
2056  flagll, dpdx, dpdy, dqdx, dqdy, gsqrt
2057  USE w3wdatmd, ONLY: time
2058  USE w3adatmd, ONLY: nmx0, nmx1, nmx2, nmy0, nmy1, nmy2, nact, &
2059  ncent, mapx2, mapy2, mapaxy, mapcxy, &
2060  maptrn, cg, cx, cy, atrnx, atrny, itime
2061  USE w3idatmd, ONLY: flcur
2062  USE w3odatmd, ONLY: ndse, ndst, flbpi, nbi, tbpi0, tbpin, &
2063  isbpi, bbpi0, bbpin
2064 #ifdef W3_S
2065  USE w3servmd, ONLY: strace
2066 #endif
2067  !/
2068  IMPLICIT NONE
2069  !/
2070  !/ ------------------------------------------------------------------- /
2071  !/ Parameter list
2072  !/
2073  INTEGER, INTENT(IN) :: ISEA, MAPSTA(NY*NX), MAPFS(NY*NX)
2074  REAL, INTENT(IN) :: DTG, VGX, VGY
2075  REAL, INTENT(INOUT) :: CFLXYMAX
2076  !/
2077  !/ ------------------------------------------------------------------- /
2078  !/ Local parameters
2079  !/
2080  INTEGER :: ITH, IK, IXY, IP
2081  INTEGER :: IX, IY, IXC, IYC, IBI
2082 #ifdef W3_S
2083  INTEGER, SAVE :: IENT = 0
2084 #endif
2085  REAL :: CG0, CGA, CGN, CGX, CGY, CXC, CYC, &
2086  CXMIN, CXMAX, CYMIN, CYMAX
2087  REAL :: CGC, FGSE = 1.
2088  REAL :: FTH, FTHX, FTHY, FCG, FCGX, FCGY
2089  REAL :: CP, CQ
2090  !/
2091  !/ Automatic work arrays
2092  !/
2093  REAL :: VLCFLX, VLCFLY
2094  REAL :: CXTOT, CYTOT
2095  !/
2096  !/ ------------------------------------------------------------------- /
2097  !/
2098 #ifdef W3_S
2099  CALL strace (ient, 'W3XYCFL')
2100 #endif
2101  !
2102  ! 1. Preparations --------------------------------------------------- *
2103  ! 1.a Set constants
2104  !
2105  !
2106  cflxymax=0.
2107  ix = mapsf(isea,1)
2108  iy = mapsf(isea,2)
2109  ixy = mapsf(isea,3)
2110  DO ik=1,nk
2111  DO ith=1,nth
2112  cxtot = ecos(ith) * cg(ik,isea) / clats(isea)
2113  cytot = esin(ith) * cg(ik,isea)
2114 #ifdef W3_MGP
2115  cxtot = cxtot - vgx/clats(isea)
2116  cytot = cytot - vgy
2117 #endif
2118 
2119 
2120  IF ( flcur ) THEN
2121  cxtot = cxtot + cx(isea)/clats(isea)
2122  cytot = cytot + cy(isea)
2123  END IF
2124 
2125  cp = cxtot*dpdx(iy,ix) + cytot*dpdy(iy,ix)
2126  cq = cxtot*dqdx(iy,ix) + cytot*dqdy(iy,ix)
2127  vlcflx = cp*dtg
2128  vlcfly = cq*dtg
2129  cflxymax = max(vlcflx,vlcfly,cflxymax)
2130  END DO
2131  END DO
2132 
2133  RETURN
2134  !/
2135  !/ End of W3XYCFL ----------------------------------------------------- /
2136  !/
2137  END SUBROUTINE w3cflxy
2138 
2139  !/
2140  !/ End of module W3PRO3MD -------------------------------------------- /
2141  !/
2142 END MODULE w3pro3md
w3gdatmd::nk
integer, pointer nk
Definition: w3gdatmd.F90:1230
w3gdatmd::esc
real, dimension(:), pointer esc
Definition: w3gdatmd.F90:1234
w3odatmd::tbpi0
integer, dimension(:), pointer tbpi0
Definition: w3odatmd.F90:464
w3timemd::dsec21
real function dsec21(TIME1, TIME2)
Definition: w3timemd.F90:333
w3gdatmd::dth
real, pointer dth
Definition: w3gdatmd.F90:1232
w3uno2md
Portable UNO2 scheme on irregular grid.
Definition: w3uno2md.F90:14
w3adatmd
Define data structures to set up wave model auxiliary data for several models simultaneously.
Definition: w3adatmd.F90:26
w3gdatmd::nspec
integer, pointer nspec
Definition: w3gdatmd.F90:1230
w3adatmd::mapy2
integer, dimension(:), pointer mapy2
Definition: w3adatmd.F90:642
constants::dera
real, parameter dera
DERA Conversion factor from degrees to radians.
Definition: constants.F90:77
w3pro3md::w3ktp3
subroutine w3ktp3(ISEA, FACTH, FACK, CTHG0, CG, WN, DW, DDDX, DDDY, CX, CY, DCXDX, DCXDY, DCYDX, DCYDY, DCDX, DCDY, VA, CFLTHMAX, CFLKMAX)
Propagation in spectral space.
Definition: w3pro3md.F90:1512
w3gdatmd::dmin
real, pointer dmin
Definition: w3gdatmd.F90:1183
w3wdatmd
Define data structures to set up wave model dynamic data for several models simultaneously.
Definition: w3wdatmd.F90:18
w3adatmd::atrnx
real, dimension(:,:), pointer atrnx
Definition: w3adatmd.F90:578
w3adatmd::cg
real, dimension(:,:), pointer cg
Definition: w3adatmd.F90:575
w3adatmd::nmx0
integer, pointer nmx0
Definition: w3adatmd.F90:640
w3adatmd::atrny
real, dimension(:,:), pointer atrny
Definition: w3adatmd.F90:578
w3gdatmd::sig
real, dimension(:), pointer sig
Definition: w3gdatmd.F90:1234
w3adatmd::mapwn2
integer, dimension(:), pointer mapwn2
Definition: w3adatmd.F90:642
w3gdatmd::flck
logical, pointer flck
Definition: w3gdatmd.F90:1217
w3pro3md::w3xyp3
subroutine w3xyp3(ISP, DTG, MAPSTA, MAPFS, VQ, VGX, VGY)
Propagation in phyiscal space for a given spectral component.
Definition: w3pro3md.F90:639
w3odatmd::iaproc
integer, pointer iaproc
Definition: w3odatmd.F90:457
w3wdatmd::time
integer, dimension(:), pointer time
Definition: w3wdatmd.F90:172
w3uqckmd::w3qck2
subroutine w3qck2(MX, MY, NX, NY, VELO, DT, DX1, DX2, Q, CLOSE, INC, MAPACT, NACT, MAPBOU, NB0, NB1, NB2, NDSE, NDST)
Like W3QCK1 with variable grid spacing.
Definition: w3uqckmd.F90:517
w3gdatmd::ecos
real, dimension(:), pointer ecos
Definition: w3gdatmd.F90:1234
w3odatmd::bbpi0
real, dimension(:,:), pointer bbpi0
Definition: w3odatmd.F90:541
w3gdatmd::ny
integer, pointer ny
Definition: w3gdatmd.F90:1097
w3odatmd::tbpin
integer, dimension(:), pointer tbpin
Definition: w3odatmd.F90:464
w3gdatmd::dsip
real, dimension(:), pointer dsip
Definition: w3gdatmd.F90:1234
w3odatmd::nbi
integer, pointer nbi
Definition: w3odatmd.F90:530
w3odatmd::flbpi
logical, pointer flbpi
Definition: w3odatmd.F90:546
w3idatmd::flcur
logical, pointer flcur
Definition: w3idatmd.F90:261
w3gdatmd::iclose_none
integer, parameter iclose_none
Definition: w3gdatmd.F90:629
w3pro3md
Bundles routines for third order propagation scheme in single module.
Definition: w3pro3md.F90:23
w3odatmd::ndse
integer, pointer ndse
Definition: w3odatmd.F90:456
w3gdatmd::fachfa
real, pointer fachfa
Definition: w3gdatmd.F90:1232
w3gdatmd::es2
real, dimension(:), pointer es2
Definition: w3gdatmd.F90:1234
w3gdatmd::dqdy
real, dimension(:,:), pointer dqdy
Definition: w3gdatmd.F90:1209
w3gdatmd::esin
real, dimension(:), pointer esin
Definition: w3gdatmd.F90:1234
w3odatmd::naperr
integer, pointer naperr
Definition: w3odatmd.F90:457
w3uno2md::w3uno2s
subroutine w3uno2s(MX, MY, NX, NY, CFLL, TRANS, Q, BCLOSE, INC, MAPACT, NACT, MAPBOU, NB0, NB1, NB2, NDSE, NDST)
Like W3UNO2r with cell transparencies added.
Definition: w3uno2md.F90:839
w3gdatmd::nk2
integer, pointer nk2
Definition: w3gdatmd.F90:1230
w3pro3md::w3cflxy
subroutine w3cflxy(ISEA, DTG, MAPSTA, MAPFS, CFLXYMAX, VGX, VGY)
Computes the maximum CFL number for spatial advection.
Definition: w3pro3md.F90:1971
w3gdatmd::nsea
integer, pointer nsea
Definition: w3gdatmd.F90:1097
w3servmd
Definition: w3servmd.F90:3
w3gdatmd::flcth
logical, pointer flcth
Definition: w3gdatmd.F90:1217
w3adatmd::mapcxy
integer, dimension(:), pointer mapcxy
Definition: w3adatmd.F90:649
w3gdatmd::nth
integer, pointer nth
Definition: w3gdatmd.F90:1230
w3uno2md::w3uno2
subroutine w3uno2(MX, MY, NX, NY, VELO, DT, DX1, DX2, Q, BCLOSE, INC, MAPACT, NACT, MAPBOU, NB0, NB1, NB2, NDSE, NDST)
UNO2 scheme for irregular grid.
Definition: w3uno2md.F90:105
w3odatmd
Definition: w3odatmd.F90:3
w3gdatmd::clats
real, dimension(:), pointer clats
Definition: w3gdatmd.F90:1196
w3adatmd::cy
real, dimension(:), pointer cy
Definition: w3adatmd.F90:584
w3uno2md::w3uno2r
subroutine w3uno2r(MX, MY, NX, NY, CFLL, Q, BCLOSE, INC, MAPACT, NACT, MAPBOU, NB0, NB1, NB2, NDSE, NDST)
Preform one-dimensional propagation in a two-dimensional space with irregular boundaries and regular ...
Definition: w3uno2md.F90:475
w3gdatmd::mapsf
integer, dimension(:,:), pointer mapsf
Definition: w3gdatmd.F90:1163
w3gdatmd::dpdx
real, dimension(:,:), pointer dpdx
Definition: w3gdatmd.F90:1208
w3gdatmd::gsqrt
real, dimension(:,:), pointer gsqrt
Definition: w3gdatmd.F90:1210
w3adatmd::mapth2
integer, dimension(:), pointer mapth2
Definition: w3adatmd.F90:642
constants::radius
real, parameter radius
RADIUS Radius of the earth (m).
Definition: constants.F90:79
w3adatmd::nmx2
integer, pointer nmx2
Definition: w3adatmd.F90:640
w3gdatmd::iclose
integer, pointer iclose
Definition: w3gdatmd.F90:1096
constants::tpi
real, parameter tpi
TPI 2*Pi.
Definition: constants.F90:72
w3gdatmd::dpdy
real, dimension(:,:), pointer dpdy
Definition: w3gdatmd.F90:1208
w3servmd::strace
subroutine strace(IENT, SNAME)
Definition: w3servmd.F90:148
w3gdatmd::gtype
integer, pointer gtype
Definition: w3gdatmd.F90:1094
w3idatmd
Define data structures to set up wave model input data for several models simultaneously.
Definition: w3idatmd.F90:16
w3gdatmd::mapwn
integer, dimension(:), pointer mapwn
Definition: w3gdatmd.F90:1231
w3gdatmd::wdcg
real, pointer wdcg
Definition: w3gdatmd.F90:1260
w3gdatmd::xfr
real, pointer xfr
Definition: w3gdatmd.F90:1232
w3gdatmd::flcy
logical, pointer flcy
Definition: w3gdatmd.F90:1217
w3pro3md::w3map3
subroutine w3map3
Generate 'map' arrays for the ULTIMATE QUICKEST scheme.
Definition: w3pro3md.F90:140
w3adatmd::mapx2
integer, dimension(:), pointer mapx2
Definition: w3adatmd.F90:642
w3uqckmd
Portable ULTIMATE QUICKEST schemes.
Definition: w3uqckmd.F90:14
w3odatmd::ndst
integer, pointer ndst
Definition: w3odatmd.F90:456
w3uqckmd::w3qck3
subroutine w3qck3(MX, MY, NX, NY, CFLL, TRANS, Q, CLOSE, INC, MAPACT, NACT, MAPBOU, NB0, NB1, NB2, NDSE, NDST)
Like W3QCK1 with cell transparencies added.
Definition: w3uqckmd.F90:922
w3gdatmd::flcx
logical, pointer flcx
Definition: w3gdatmd.F90:1217
w3adatmd::maptrn
logical, dimension(:), pointer maptrn
Definition: w3adatmd.F90:651
constants
Define some much-used constants for global use (all defined as PARAMETER).
Definition: constants.F90:20
w3uqckmd::w3qck1
subroutine w3qck1(MX, MY, NX, NY, CFLL, Q, CLOSE, INC, MAPACT, NACT, MAPBOU, NB0, NB1, NB2, NDSE, NDST)
Preform one-dimensional propagation in a two-dimensional space with irregular boundaries and regular ...
Definition: w3uqckmd.F90:120
w3gdatmd
Definition: w3gdatmd.F90:16
w3adatmd::nact
integer, pointer nact
Definition: w3adatmd.F90:640
w3gdatmd::iclose_trpl
integer, parameter iclose_trpl
Definition: w3gdatmd.F90:631
w3servmd::extcde
subroutine extcde(IEXIT, UNIT, MSG, FILE, LINE, COMM)
Definition: w3servmd.F90:736
w3gdatmd::pfmove
real, pointer pfmove
Definition: w3gdatmd.F90:1183
w3adatmd::mapaxy
integer, dimension(:), pointer mapaxy
Definition: w3adatmd.F90:642
w3adatmd::itime
integer, pointer itime
Definition: w3adatmd.F90:686
w3adatmd::nmy1
integer, pointer nmy1
Definition: w3adatmd.F90:640
w3odatmd::isbpi
integer, dimension(:), pointer isbpi
Definition: w3odatmd.F90:535
w3adatmd::nmy2
integer, pointer nmy2
Definition: w3adatmd.F90:640
w3adatmd::cx
real, dimension(:), pointer cx
Definition: w3adatmd.F90:584
w3gdatmd::nx
integer, pointer nx
Definition: w3gdatmd.F90:1097
w3gdatmd::ctmax
real, pointer ctmax
Definition: w3gdatmd.F90:1183
w3timemd
Definition: w3timemd.F90:3
w3adatmd::nmx1
integer, pointer nmx1
Definition: w3adatmd.F90:640
w3adatmd::nmy0
integer, pointer nmy0
Definition: w3adatmd.F90:640
w3gdatmd::ec2
real, dimension(:), pointer ec2
Definition: w3gdatmd.F90:1234
w3adatmd::ncent
integer, pointer ncent
Definition: w3adatmd.F90:647
w3gdatmd::dtcfl
real, pointer dtcfl
Definition: w3gdatmd.F90:1183
w3gdatmd::iclose_smpl
integer, parameter iclose_smpl
Definition: w3gdatmd.F90:630
w3pro3md::w3mapt
subroutine w3mapt
Generate 'map' arrays for the ULTIMATE QUICKEST scheme to combine GSE alleviation with obstructions.
Definition: w3pro3md.F90:525
w3gdatmd::dqdx
real, dimension(:,:), pointer dqdx
Definition: w3gdatmd.F90:1209
w3gdatmd::mapsta
integer, dimension(:,:), pointer mapsta
Definition: w3gdatmd.F90:1163
constants::grav
real, parameter grav
GRAV Acc.
Definition: constants.F90:61
w3odatmd::bbpin
real, dimension(:,:), pointer bbpin
Definition: w3odatmd.F90:541
w3gdatmd::flagll
logical, pointer flagll
Definition: w3gdatmd.F90:1219
w3gdatmd::wdth
real, pointer wdth
Definition: w3gdatmd.F90:1260