WAVEWATCH III  beta 0.0.1
w3wavemd.F90
Go to the documentation of this file.
1 
6 #include "w3macros.h"
7 !/ ------------------------------------------------------------------- /
13 MODULE w3wavemd
14  !/
15  !/ +-----------------------------------+
16  !/ | WAVEWATCH III NOAA/NCEP |
17  !/ | H. L. Tolman |
18  !/ | FORTRAN 90 |
19  !/ | Last update : 13-Sep-2022 |
20  !/ +-----------------------------------+
21  !/
22  !/ 04-Feb-2000 : Origination. ( version 2.00 )
23  !/ For upgrades see subroutines.
24  !/ 14-Feb-2000 : Exact-NL added. ( version 2.01 )
25  !/ 05-Jan-2001 : Bug fix to allow model to run ( version 2.05 )
26  !/ without output.
27  !/ 24-Jan-2001 : Flat grid version. ( version 2.06 )
28  !/ 09-Feb-2001 : Third propagation scheme added. ( version 2.08 )
29  !/ 23-Feb-2001 : Check for barrier after source
30  !/ terms added ( W3NMIN ). ( delayed version 2.07 )
31  !/ 16-Mar-2001 : Fourth propagation scheme added. ( version 2.09 )
32  !/ 30-Mar-2001 : Sub-grid obstacles added. ( version 2.10 )
33  !/ 23-May-2001 : Clean up and bug fixes. ( version 2.11 )
34  !/ 10-Dec-2001 : Sub-grid obstacles for UQ schemes. ( version 2.14 )
35  !/ 11-Jan-2002 : Sub-grid ice. ( version 2.15 )
36  !/ 24-Jan-2002 : Zero time step dor data ass. ( version 2.17 )
37  !/ 18-Feb-2002 : Point output diagnostics added. ( version 2.18 )
38  !/ 30-Apr-2002 : Add field output types 17-18. ( version 2.20 )
39  !/ 09-May-2002 : Switch clean up. ( version 2.21 )
40  !/ 13-Nov-2002 : Add stress vector. ( version 3.00 )
41  !/ 26-Dec-2002 : Moving grid version. ( version 3.02 )
42  !/ 01-Aug-2003 : Moving grid GSE correction. ( version 3.03 )
43  !/ 20-Aug-2003 : Output server options added. ( version 3.04 )
44  !/ 07-Oct-2003 : Output options for NN training. ( version 3.05 )
45  !/ 29-Dec-2004 : Multiple grid version. ( version 3.06 )
46  !/ W3INIT, W3MPII-O and WWVER moved to w3initmd.ftn
47  !/ 04-Feb-2005 : Add STAMP to par list of W3WAVE. ( version 3.07 )
48  !/ 04-May-2005 : Change to MPI_COMM_WAVE. ( version 3.07 )
49  !/ 28-Jun-2005 : Adding map recalc for W3ULEV call. ( version 3.07 )
50  !/ 07-Sep-2005 : Updated boundary conditions. ( version 3.08 )
51  !/ Fix NRQSG1/2 = 0 array bound issue.
52  !/ 13-Jun-2006 : Split STORE in G/SSTORE ( version 3.09 )
53  !/ 26-Jun-2006 : Add output type 6. ( version 3.09 )
54  !/ 04-Jul-2006 : Consolidate stress arrays. ( version 3.09 )
55  !/ 18-Oct-2006 : Partitioned spectral data output. ( version 3.10 )
56  !/ 02-Feb-2007 : Add FLAGST test. ( version 3.10 )
57  !/ 02-Apr-2007 : Add partitioned field data. ( version 3.11 )
58  !/ 07-May-2007 : Bug fix SKIP_O treatment. ( version 3.11 )
59  !/ 17-May-2007 : Adding NTPROC/NAPROC separation. ( version 3.11 )
60  !/ 08-Oct-2007 : Adding AS CX-Y to W3SRCE par. list. ( version 3.13 )
61  !/ 22-Feb-2008 : Initialize VGX-Y properly. ( version 3.13 )
62  !/ 10-Apr-2008 : Bug fix writing log file (MPI). ( version 3.13 )
63  !/ 29-May-2009 : Preparing distribution version. ( version 3.14 )
64  !/ 30-Oct-2009 : Implement run-time grid selection. ( version 3.14 )
65  !/ (W. E. Rogers & T. J. Campbell, NRL)
66  !/ 30-Oct-2009 : Implement curvilinear grid type. ( version 3.14 )
67  !/ (W. E. Rogers & T. J. Campbell, NRL)
68  !/ 29-Mar-2010 : Adding coupling, ice in W3SRCE. ( version 3.14_SHOM )
69  !/ 16-May-2010 : Adding transparencies in W3SCRE ( version 3.14_SHOM )
70  !/ 23-Jun-2011 : Movable bed bottom friction BT4 ( version 4.04 )
71  !/ 03-Nov-2011 : Shoreline reflection on unst. grids ( version 4.04 )
72  !/ 02-Jul-2011 : Update for PALM coupling ( version 4.07 )
73  !/ 06-Mar-2012 : Initializing ITEST as needed. ( version 4.07 )
74  !/ 02-Jul-2012 : Update for PALM coupling ( version 4.07 )
75  !/ 02-Sep-2012 : Clean up of open BC for UG grids ( version 4.08 )
76  !/ 03-Sep-2012 : Fix format 902. ( version 4.10 )
77  !/ 07-Dec-2012 : Wrap W3SRCE with TMPn to limit WARN ( version 4.OF )
78  !/ 10-Dec-2012 : Modify field output MPI for new ( version 4.OF )
79  !/ structure and smaller memory footprint.
80  !/ 12-Dec-2012 : Adding SMC grid. JG_Li ( version 4.08 )
81  !/ 26-Dec-2012 : Move FIELD init. to W3GATH. ( version 4.OF )
82  !/ 16-Sep-2013 : Add Arctic part for SMC grid. ( version 4.11 )
83  !/ 11-Nov-2013 : SMC and rotated grid incorporated in the main
84  !/ trunk ( version 4.13 )
85  !/ 14-Nov-2013 : Remove orphaned work arrays. ( version 4.13 )
86  !/ 27-Nov-2013 : Fixes for OpenMP versions. ( version 4.15 )
87  !/ 23-May-2014 : Adding ice fluxes to W3SRCE ( version 5.01 )
88  !/ 27-May-2014 : Move to OMPG/X switch. ( version 5.02 )
89  !/ 24-Apr-2015 : Adding OASIS coupling calls ( version 5.07 )
90  !/ (M. Accensi & F. Ardhuin, IFREMER)
91  !/ 27-Aug-2015 : Update for ICEH, ICEF ( version 5.08 )
92  !/ 14-Sep-2018 : Remove PALM implementation ( version 6.06 )
93  !/ 15-Sep-2020 : Bugfix FIELD allocation. Remove ( version 7.11 )
94  !/ defunct OMPX switches.
95  !/ 22-Mar-2021 : Update TAUA, RHOA ( version 7.13 )
96  !/ 06-May-2021 : Use ARCTC and SMCTYPE options. JGLi ( version 7.13 )
97  !/ 19-Jul-2021 : Momentum and air density support ( version 7.14 )
98  !/ 11-Nov-2021 : Remove XYB since it is obsolete ( version 7.xx )
99  !/ 13-Sep-2022 : Add OMP for W3NMIN loops. Hide
100  !/ W3NMIN in W3_DEBUGRUN for scaling. ( version 7.xx )
101  !/
102  !/ Copyright 2009-2014 National Weather Service (NWS),
103  !/ National Oceanic and Atmospheric Administration. All rights
104  !/ reserved. WAVEWATCH III is a trademark of the NWS.
105  !/ No unauthorized use without permission.
106  !/
107  ! 1. Purpose :
108  !
109  ! 2. Variables and types :
110  !
111  ! 3. Subroutines and functions :
112  !
113  ! Name Type Scope Description
114  ! ----------------------------------------------------------------
115  ! W3WAVE Subr. Public Actual wave model.
116  ! W3GATH Subr. Public Data transpose before propagation.
117  ! W3SCAT Subr. Public Data transpose after propagation.
118  ! W3NMIN Subr. Public Calculate minimum number of sea
119  ! points per processor.
120  ! ----------------------------------------------------------------
121  !
122  ! 4. Subroutines and functions used :
123  !
124  ! Name Type Module Description
125  ! ----------------------------------------------------------------
126  ! W3SETx Subr. W3xDATMD Point to data structure.
127  !
128  ! W3UCUR Subr. W3UPDTMD Interpolate current fields in time.
129  ! W3UWND Subr. W3UPDTMD Interpolate wind fields in time.
130  ! W3UINI Subr. W3UPDTMD Update initial conditions if init.
131  ! with initial wind conditions.
132  ! W3UBPT Subr. W3UPDTMD Update boundary points.
133  ! W3UICE Subr. W3UPDTMD Update ice coverage.
134  ! W3ULEV Subr. W3UPDTMD Transform the wavenumber grid.
135  ! W3DDXY Subr. W3UPDTMD Calculate dirivatives of the depth.
136  ! W3DCXY Subr. W3UPDTMD Calculate dirivatives of the current.
137  !
138  ! W3MAPn Subr. W3PROnMD Preparation for ropagation schemes.
139  ! W3XYPn Subr. W3PROnMD Longitude-latitude ("XY") propagation.
140  ! W3KTPn Subr. W3PROnMD Intra-spectral ("k-theta") propagation.
141  !
142  ! W3SRCE Subr. W3SRCEMD Source term integration and calculation.
143  !
144  ! W3IOGR Subr. W3IOGRMD Reading/writing model definition file.
145  ! W3OUTG Subr. W3IOGOMD Generate gridded output fields.
146  ! W3IOGO Subr. W3IOGOMD Read/write gridded output.
147  ! W3IOPE Subr. W3IOPOMD Extract point output.
148  ! W3IOPO Subr. W3IOPOMD Read/write point output.
149  ! W3IOTR Subr. W3IOTRMD Process spectral output along tracks.
150  ! W3IORS Subr. W3IORSMD Read/write restart files.
151  ! W3IOBC Subr. W3IOBCMD Read/write boundary conditions.
152  ! W3CPRT Subr. W3IOSFMD Partition spectra.
153  ! W3IOSF Subr. Id. Write partitioned spectral data.
154  !
155  ! STRACE Subr. W3SERVMD Subroutine tracing.
156  ! WWTIME Subr. Id. System time in readable format.
157  ! EXTCDE Subr. Id. Program abort.
158  !
159  ! TICK21 Subr. W3TIMEMD Advance the clock.
160  ! DSEC21 Func. Id. Difference between times.
161  ! STME21 Subr. Id. Time in readable format.
162  !
163  ! MPI_BARRIER, MPI_STARTALL, MPI_WAITALL
164  ! Subr. Basic MPI routines.
165  ! ----------------------------------------------------------------
166  !
167  ! 5. Remarks : Call to W3NMIN hidden behind W3_DEBUGRUN. This call
168  ! currently only serves to warn when one or more procs
169  ! have no active seapoints. It has been hid as this
170  ! dramatically increases runtime performance.
171  !
172  ! 6. Switches :
173  !
174  ! !/SHRD Switch for shared / distributed memory architecture.
175  ! !/DIST Id.
176  ! !/MPI Id.
177  ! !/OMPG Id.
178  !
179  ! !/PR1 First order propagation schemes.
180  ! !/PR2 ULTIMATE QUICKEST scheme.
181  ! !/PR3 Averaged ULTIMATE QUICKEST scheme.
182  ! !/SMC UNO2 scheme on SMC grid.
183  !
184  ! !/S Enable subroutine tracing.
185  ! !/T Test output.
186  ! !/MPIT Test output for MPI specific code.
187  !
188  ! 7. Source code :
189  !
190  !/ ------------------------------------------------------------------- /
191  use w3servmd, only : print_memcheck
192 #ifdef W3_MPI
193  USE w3adatmd, ONLY: mpibuf
194 #endif
195  !module default
196  implicit none
197  !
198  PUBLIC
199  !/
200 CONTAINS
201  !/ ------------------------------------------------------------------- /
227 
228  SUBROUTINE w3wave ( IMOD, ODAT, TEND, STAMP, NO_OUT &
229 #ifdef W3_OASIS
230  ,ID_LCOMM, TIMEN &
231 #endif
232  )
233  !/
234  !/ +-----------------------------------+
235  !/ | WAVEWATCH III NOAA/NCEP |
236  !/ | H. L. Tolman |
237  !/ | FORTRAN 90 |
238  !/ | Last update : 22-Mar-2021 |
239  !/ +-----------------------------------+
240  !/
241  !/ 17-Mar-1999 : Distributed FORTRAN 77 version. ( version 1.18 )
242  !/ 04-Feb-2000 : Upgrade to FORTRAN 90 ( version 2.00 )
243  !/ Major changes to logistics.
244  !/ 05-Jan-2001 : Bug fix to allow model to run ( version 2.05 )
245  !/ without output.
246  !/ 24-Jan-2001 : Flat grid version. ( version 2.06 )
247  !/ 09-Feb-2001 : Third propagation scheme added. ( version 2.08 )
248  !/ 23-Feb-2001 : Check for barrier after source
249  !/ terms added ( W3NMIN ). ( delayed version 2.07 )
250  !/ 16-Mar-2001 : Fourth propagation scheme added. ( version 2.09 )
251  !/ 30-Mar-2001 : Sub-grid obstacles added. ( version 2.10 )
252  !/ 23-May-2001 : Barrier added for dry run, changed ( version 2.10 )
253  !/ declaration of FLIWND.
254  !/ 10-Dec-2001 : Sub-grid obstacles for UQ schemes. ( version 2.14 )
255  !/ 11-Jan-2002 : Sub-grid ice. ( version 2.15 )
256  !/ 24-Jan-2002 : Zero time step dor data ass. ( version 2.17 )
257  !/ 09-May-2002 : Switch clean up. ( version 2.21 )
258  !/ 13-Nov-2002 : Add stress vector. ( version 3.00 )
259  !/ 26-Dec-2002 : Moving grid version. ( version 3.02 )
260  !/ 01-Aug-2003 : Moving grid GSE correction. ( version 3.03 )
261  !/ 07-Oct-2003 : Output options for NN training. ( version 3.05 )
262  !/ 29-Dec-2004 : Multiple grid version. ( version 3.06 )
263  !/ 04-Feb-2005 : Add STAMP to par list. ( version 3.07 )
264  !/ 04-May-2005 : Change to MPI_COMM_WAVE. ( version 3.07 )
265  !/ 28-Jun-2005 : Adding map recalc for W3ULEV call. ( version 3.07 )
266  !/ 07-Sep-2005 : Updated boundary conditions. ( version 3.08 )
267  !/ 26-Jun-2006 : Add output type 6. ( version 3.09 )
268  !/ 04-Jul-2006 : Consolidate stress arrays. ( version 3.09 )
269  !/ 18-Oct-2006 : Partitioned spectral data output. ( version 3.10 )
270  !/ 02-Feb-2007 : Add FLAGST test. ( version 3.10 )
271  !/ 02-Apr-2007 : Add partitioned field data. ( version 3.11 )
272  !/ Improve MPI_WAITALL call tests/allocations.
273  !/ 07-May-2007 : Bug fix SKIP_O treatment. ( version 3.11 )
274  !/ 17-May-2007 : Adding NTPROC/NAPROC separation. ( version 3.11 )
275  !/ 08-Oct-2007 : Adding AS CX-Y to W3SRCE par. list. ( version 3.13 )
276  !/ 22-Feb-2008 : Initialize VGX-Y properly. ( version 3.13 )
277  !/ 10-Apr-2008 : Bug fix writing log file (MPI). ( version 3.13 )
278  !/ 30-Oct-2009 : Implement run-time grid selection. ( version 3.14 )
279  !/ (W. E. Rogers & T. J. Campbell, NRL)
280  !/ 30-Oct-2009 : Implement curvilinear grid type. ( version 3.14 )
281  !/ (W. E. Rogers & T. J. Campbell, NRL)
282  !/ 31-Mar-2010 : Add reflections ( version 3.14.4 )
283  !/ 29-Oct-2010 : Implement unstructured grids ( version 3.14.4 )
284  !/ (A. Roland and F. Ardhuin)
285  !/ 06-Mar-2011 : Output of max. CFL (F.Ardhuin) ( version 3.14.4 )
286  !/ 05-Apr-2011 : Implement iteration for DTMAX <1s ( version 3.14.4 )
287  !/ 02-Jul-2012 : Update for PALM coupling ( version 4.07 )
288  !/ 02-Sep-2012 : Clean up of open BC for UG grids ( version 4.08 )
289  !/ 03-Sep-2012 : Fix format 902. ( version 4.10 )
290  !/ 10-Dec-2012 : Modify field output MPI for new ( version 4.OF )
291  !/ structure and smaller memory footprint.
292  !/ 16-Nov-2013 : Allows reflection on curvi. grids ( version 4.13 )
293  !/ 27-Nov-2013 : Fixes for OpenMP versions. ( version 4.15 )
294  !/ 23-May-2014 : Adding ice fluxes to W3SRCE ( version 5.01 )
295  !/ 27-May-2014 : Move to OMPG/X switch. ( version 5.02 )
296  !/ 24-Apr-2015 : Adding OASIS coupling calls ( version 5.07 )
297  !/ (M. Accensi & F. Ardhuin, IFREMER)
298  !/ 27-Aug-2015 : Update for ICEH, ICEF ( version 5.10 )
299  !/ 31-Mar-2016 : Current option for smc grid. ( version 5.18 )
300  !/ 06-Jun-2018 : Add PDLIB/MEMCHECK/SETUP/NETCDF_QAD/TIMING
301  !/ OASIS/DEBUGINIT/DEBUGSRC/DEBUGRUN/DEBUGCOH
302  !/ DEBUGIOBP/DEBUGIOBC ( version 6.04 )
303  !/ 14-Sep-2018 : Remove PALM implementation ( version 6.06 )
304  !/ 25-Sep-2020 : Oasis coupling at T+0 ( version 7.10 )
305  !/ 22-Mar-2021 : Update TAUA, RHOA ( version 7.13 )
306  !/ 06-May-2021 : Use ARCTC and SMCTYPE options. JGLi ( version 7.13 )
307  !/
308  ! 1. Purpose :
309  !
310  ! Run WAVEWATCH III for a given time interval.
311  !
312  ! 3. Parameters :
313  !
314  ! Parameter list
315  ! ----------------------------------------------------------------
316  ! IMOD Int. I Model number.
317  ! TEND I.A. I Ending time of integration.
318  ! STAMP Log. I WRITE(*,*)time stamp (optional, defaults to T).
319  ! NO_OUT Log. I Skip output (optional, defaults to F).
320  ! Skip at ending time only!
321  ! ----------------------------------------------------------------
322  !
323  ! Local parameters : Flags
324  ! ----------------------------------------------------------------
325  ! FLOUTG Log. Flag for running W3OUTG.
326  ! FLPART Log. Flag for running W3CPRT.
327  ! FLZERO Log. Flag for zero time interval.
328  ! FLAG0 Log. Flag for processors without tasks.
329  ! ----------------------------------------------------------------
330  !
331  ! 4. Subroutines used :
332  !
333  ! See module documentation.
334  !
335  ! 5. Called by :
336  !
337  ! Any program shell or integrated model which uses WAVEWATCH III.
338  !
339  ! 6. Error messages :
340  !
341  ! 7. Remarks :
342  !
343  ! - Currents are updated before winds as currents are used in wind
344  ! and USTAR processing.
345  ! - Ice and water levels can be updated only once per call.
346  ! - If ice or water level time are undefined, the update
347  ! takes place asap, otherwise around the "half-way point"
348  ! betweem the old and new times.
349  ! - To increase accuracy, the calculation of the intra-spectral
350  ! propagation is performed in two parts around the spatial propagation.
351  !
352  ! 8. Structure :
353  !
354  ! -----------------------------------------------------------
355  ! 0. Initializations
356  ! a Point to data structures
357  ! b Subroutine tracing
358  ! c Local parameter initialization
359  ! d Test output
360  ! 1. Check the consistency of the input.
361  ! a Ending time versus initial time.
362  ! b Water level time.
363  ! c Current time interval.
364  ! d Wind time interval.
365  ! e Ice time.
366  ! 2. Determine next time from ending and output
367  ! time and get corresponding time step.
368  ! 3. Loop over time steps (see below).
369  ! 4. Perform output to file if requested.
370  ! a Check if time is output time.
371  ! b Processing and MPP preparations. ( W3CPRT, W3OUTG )
372  ! c Reset next output time.
373  ! -------------- loop over output types ------------------
374  ! d Perform output. ( W3IOxx )
375  ! e Update next output time.
376  ! -------------------- end loop --------------------------
377  ! 5. Update log file.
378  ! 6. If time is not ending time, branch back to 2.
379  ! -----------------------------------------------------------
380  !
381  ! Section 3.
382  ! ----------------------------------------------------------
383  ! 3.1 Interpolate winds and currents. ( W3UCUR, W3DCXY )
384  ! ( W3UWND )
385  ! ( W3UINI )
386  ! 3.2 Update boundary conditions. ( W3IOBC, W3UBPT )
387  ! 3.3 Update ice coverage (if new ice map). ( W3UICE )
388  ! 3.4 Transform grid (if new water level). ( W3ULEV )
389  ! 3.5 Update maps and dirivatives. ( W3MAPn, W3DDXY )
390  ! ( W3NMIN, W3UTRN )
391  ! Update grid advection vector.
392  ! 3.6 Perform propagation
393  ! a Preparations.
394  ! b Intra spectral part 1. ( W3KTPn )
395  ! c Longitude-latitude ( W3GATH, W3XYPn W3SCAT )
396  ! b Intra spectral part 2. ( W3KTPn )
397  ! 3.7 Calculate and integrate source terms. ( W3SRCE )
398  ! 3.8 Update global time step.
399  ! ----------------------------------------------------------
400  !
401  ! 9. Switches :
402  !
403  ! See module documentation.
404  !
405  ! 10. Source code :
406  !
407  !/ ------------------------------------------------------------------- /
408  USE constants
409  !/
410  USE w3gdatmd
411  USE w3wdatmd
412  USE w3adatmd
413  USE w3idatmd
414  USE w3odatmd
415  !/
416  USE w3updtmd
417  USE w3srcemd
418 #ifdef W3_PR1
419  USE w3pro1md
420 #endif
421 #ifdef W3_PR2
422  USE w3pro2md
423 #endif
424 #ifdef W3_PR3
425  USE w3pro3md
426 #endif
427 #ifdef W3_SMC
428  USE w3psmcmd
429 #endif
430  !
431 #ifdef W3_PR1
432  USE w3profsmd
433 #endif
434 #ifdef W3_PR2
435  USE w3profsmd
436 #endif
437 #ifdef W3_PR3
438  USE w3profsmd
439 #endif
440  !/
441  USE w3triamd
442  USE w3iogrmd
443  USE w3iogomd
444  USE w3iopomd
445  USE w3iotrmd
446  USE w3iorsmd
447  USE w3iobcmd
448  USE w3iosfmd
449 #ifdef W3_PDLIB
453  USE w3parall, only : pdlib_nseal, pdlib_nsealm
454  USE yownodepool, only: npa, iplg, np
455 #endif
456  !/
457  USE w3servmd
458  USE w3timemd
459 #ifdef W3_IC3
460  USE w3sic3md
461 #endif
462 #ifdef W3_IS2
463  USE w3sis2md
464 #endif
465 #ifdef W3_UOST
466  USE w3uostmd, ONLY: uost_setgrid
467 #endif
468  USE w3parall, ONLY : init_get_isea
469 #ifdef W3_SETUP
470  USE w3wavset, only : wave_setup_computation
471 #endif
472 
473 #ifdef W3_OASIS
474  USE w3oacpmd, ONLY: id_oasis_time, cplt0
475 #endif
476 #ifdef W3_OASOCM
477  USE w3ogcmmd, ONLY: snd_fields_to_ocean
478 #endif
479 #ifdef W3_OASACM
480  USE w3agcmmd, ONLY: snd_fields_to_atmos
481 #endif
482 #ifdef W3_OASICM
483  USE w3igcmmd, ONLY: snd_fields_to_ice
484 #endif
485 
486 #ifdef W3_PDLIB
489  USE w3parall, only : lsloc
490 #endif
491 #ifdef W3_TIMINGS
492  USE w3parall, only : print_my_time
493 #endif
494  !
495 #ifdef W3_MPI
496  include "mpif.h"
497 #endif
498  !/
499  !/ ------------------------------------------------------------------- /
500  !/ Parameter list
501  !/
502  INTEGER, INTENT(IN) :: IMOD, TEND(2),ODAT(35)
503  LOGICAL, INTENT(IN), OPTIONAL :: STAMP, NO_OUT
504 #ifdef W3_OASIS
505  INTEGER, INTENT(IN), OPTIONAL :: ID_LCOMM
506  INTEGER, INTENT(IN), OPTIONAL :: TIMEN(2)
507 #endif
508  !/
509  !/ ------------------------------------------------------------------- /
510  !/ Local parameters :
511  !/
512 #ifdef W3_T
513  INTEGER :: ILEN
514 #endif
515 #ifdef W3_S
516  INTEGER, SAVE :: IENT = 0
517 #endif
518  INTEGER :: IP
519  INTEGER :: TCALC(2), IT, IT0, NT, ITEST, &
520  ITLOC, ITLOCH, NTLOC, ISEA, JSEA, &
521  IX, IY, ISPEC, J, TOUT(2), TLST(2), &
522  REFLED(6), IK, ITH, IS, NKCFL
523  INTEGER :: ISP, IP_glob
524  INTEGER :: TTEST(2),DTTEST
525  REAL :: ICEDAVE
526  !
527 #ifdef W3_MPI
528  LOGICAL :: SBSED
529 #endif
530 #ifdef W3_SEC1
531  INTEGER :: ISEC1
532 #endif
533 #ifdef W3_SBS
534  INTEGER :: JJ, NDSOFLG
535 #endif
536 #ifdef W3_MPI
537  INTEGER :: IERR_MPI, NRQMAX
538  INTEGER, ALLOCATABLE :: STATCO(:,:), STATIO(:,:)
539 #endif
540  INTEGER :: IXrel
541  REAL :: DTTST, DTTST1, DTTST2, DTTST3, &
542  DTL0, DTI0, DTR0, DTI10, DTI50, &
543  DTGA, DTG, DTGpre, DTRES, &
544  FAC, VGX, VGY, FACK, FACTH, &
545  FACX, XXX, REFLEC(4), &
546  DELX, DELY, DELA, DEPTH, D50, PSIC
547  REAL :: VSioDummy(NSPEC), VDioDummy(NSPEC), VAoldDummy(NSPEC)
548  LOGICAL :: SHAVETOTioDummy
549 #ifdef W3_SEC1
550  REAL :: DTGTEMP
551 #endif
552  !
553  REAL, ALLOCATABLE :: FIELD(:)
554  REAL :: TMP1(4), TMP2(3), TMP3(2), TMP4(2)
555 #ifdef W3_IC3
556  REAL, ALLOCATABLE :: WN_I(:)
557 #endif
558 #ifdef W3_REFRX
559  REAL, ALLOCATABLE :: CIK(:)
560 #endif
561  !
562  ! Orphaned arrays from old data structure
563  !
564  REAL, ALLOCATABLE :: TAUWX(:), TAUWY(:)
565  !
566  LOGICAL :: FLACT, FLZERO, FLFRST, FLMAP, TSTAMP,&
567  SKIP_O, FLAG_O, FLDDIR, READBC, &
568  FLAG0 = .false., floutg, flpfld, &
569  flpart, local, floutg2
570  !
571 #ifdef W3_MPI
572  LOGICAL :: FLGMPI(0:8)
573 #endif
574 #ifdef W3_IC3
575  REAL :: FIXEDVISC,FIXEDDENS,FIXEDELAS
576  REAL :: USE_CHENG, USE_CGICE, HICE
577 #endif
578  LOGICAL :: UGDTUPDATE ! true if time step should be updated for UG schemes
579  CHARACTER(LEN=8) :: STTIME
580  CHARACTER(LEN=21) :: IDACT
581  CHARACTER(LEN=16) :: OUTID
582  CHARACTER(LEN=23) :: IDTIME
583  INTEGER eIOBP
584  INTEGER ITH_F
585 #ifdef W3_PDLIB
586  REAL :: VS_SPEC(NSPEC)
587  REAL :: VD_SPEC(NSPEC)
588 #endif
589  !
590 #ifdef W3_SBS
591  CHARACTER(LEN=30) :: FOUTNAME
592 #endif
593  !
594 #ifdef W3_T
595  REAL :: INDSORT(NSEA), DTCFL1(NSEA)
596 #endif
597  !/
598 #ifdef W3_SMC
599  !Li Temperature spectra for Arctic boundary update.
600  REAL, ALLOCATABLE :: BACSPEC(:)
601  REAL :: BACANGL
602 #endif
603  integer :: memunit
604  !/ ------------------------------------------------------------------- /
605  ! 0. Initializations
606  !
607  xxx = undef
608  memunit = 40000+iaproc
609  ! 0.a Set pointers to data structure
610  !
611 #ifdef W3_COU
612  screen = 333
613 #endif
614  !
615  IF ( ioutp .NE. imod ) CALL w3seto ( imod, ndse, ndst )
616  IF ( igrid .NE. imod ) CALL w3setg ( imod, ndse, ndst )
617  IF ( iwdata .NE. imod ) CALL w3setw ( imod, ndse, ndst )
618  IF ( iadata .NE. imod ) CALL w3seta ( imod, ndse, ndst )
619  IF ( iidata .NE. imod ) CALL w3seti ( imod, ndse, ndst )
620 #ifdef W3_UOST
621  CALL uost_setgrid(imod)
622 #endif
623 
624 #ifdef W3_DEBUGCOH
625  CALL all_va_integral_print(imod, "W3WAVEMD, step 1", 1)
626 #endif
627 
628  !
629  ALLOCATE(tauwx(nseal), tauwy(nseal))
630 #ifdef W3_REFRX
631  ALLOCATE(cik(nseal))
632 #endif
633  !
634  IF ( PRESENT(stamp) ) THEN
635  tstamp = stamp
636  ELSE
637  tstamp = .true.
638  END IF
639  !
640  IF ( PRESENT(no_out) ) THEN
641  skip_o = no_out
642  ELSE
643  skip_o = .false.
644  END IF
645 #ifdef W3_DEBUGCOH
646  CALL all_va_integral_print(imod, "W3WAVEMD, step 2", 1)
647 #endif
648  !
649  ! 0.b Subroutine tracing
650  !
651 #ifdef W3_S
652  CALL strace (ient, 'W3WAVE')
653 #endif
654  !
655  !
656  ! 0.c Local parameter initialization
657  !
658  ipass = ipass + 1
659  idact = ' '
660  outid = ' '
661  flact = itime .EQ. 0
662  flmap = itime .EQ. 0
663  flddir = itime .EQ. 0 .AND. ( flcth .OR. fsrefraction .OR. flck .OR. fsfreqshift )
664  !
665  flpfld = .false.
666  DO j=1,noge(4)
667  flpfld = flpfld .OR. flogrd(4,j) .OR. flogr2(4,j)
668  END DO
669  !
670  IF ( iaproc .EQ. naplog ) backspace( ndso )
671  !
672  IF ( flcold ) THEN
673  dtdyn = 0.
674  fcut = sig(nk) * tpiinv
675  END IF
676  !
677  IF( gtype .EQ. smctype ) THEN
678  j = 1
679 #ifdef W3_SMC
680  !!Li Use sea point only field for SMC grid.
681  ALLOCATE ( field(ncel) )
682 #endif
683  ELSE
684  ALLOCATE ( field(1-ny:ny*(nx+2)) )
685  ENDIF
686  !
687  local = iaproc .LE. naproc
688  ugdtupdate = .false.
689  IF (flagll) THEN
690  facx = 1./(dera * radius)
691  ELSE
692  facx = 1.
693  END IF
694  !
695 #ifdef W3_SBS
696  ndsoflg = 99
697 #endif
698 #ifdef W3_MPI
699  sbsed = .false.
700 #endif
701 #ifdef W3_SBS
702  sbsed = .true.
703 #endif
704  !
705  tauwx = 0.
706  tauwy = 0.
707  !
708  ! 0.d Test output
709  !
710 #ifdef W3_T
711  ilen = len_trim(filext)
712  WRITE (ndst,9000) imod, filext(:ilen), tend
713 #endif
714  !
715  ! 1. Check the consistency of the input ----------------------------- /
716  ! 1.a Ending time versus initial time
717  !
718  dttst = dsec21( time , tend )
719  flzero = dttst .EQ. 0.
720 #ifdef W3_T
721  WRITE (ndst,9010) dttst, flzero
722 #endif
723  IF ( dttst .LT. 0. ) THEN
724  IF ( iaproc .EQ. naperr ) WRITE (ndse,1000)
725  CALL extcde ( 1 )
726  END IF
727  !
728  ! 1.b Water level time
729  !
730  IF ( fllev ) THEN
731  IF ( tlev(1) .GE. 0. ) THEN
732  dtl0 = dsec21( tlev , tln )
733  ELSE
734  dtl0 = 1.
735  END IF
736 #ifdef W3_T
737  WRITE (ndst,9011) dtl0
738 #endif
739  IF ( dtl0 .LT. 0. ) THEN
740  IF ( iaproc .EQ. naperr ) WRITE (ndse,1001)
741  CALL extcde ( 2 )
742  END IF
743  ELSE
744  dtl0 = 0.
745  END IF
746 #ifdef W3_DEBUGCOH
747  CALL all_va_integral_print(imod, "W3WAVEMD, step 4", 1)
748 #endif
749  !
750  ! 1.c Current interval
751  !
752  IF ( flcur ) THEN
753  dttst1 = dsec21( tc0 , tcn )
754  dttst2 = dsec21( tc0 , time )
755  dttst3 = dsec21( tend , tcn )
756 #ifdef W3_T
757  WRITE (ndst,9012) dttst1, dttst2, dttst3
758 #endif
759  IF ( dttst1.LT.0. .OR. dttst2.LT.0. .OR. dttst3.LT.0. ) THEN
760  IF ( iaproc .EQ. naperr ) WRITE (ndse,1002)
761  CALL extcde ( 3 )
762  END IF
763  IF ( dttst2.EQ.0..AND. itime.EQ.0 ) THEN
764  idact(7:7) = 'F'
765  tofrst = time
766  END IF
767  END IF
768  !
769  ! 1.d Wind interval
770  !
771  IF ( flwind ) THEN
772  dttst1 = dsec21( tw0 , twn )
773  dttst2 = dsec21( tw0 , time )
774  dttst3 = dsec21( tend , twn )
775 #ifdef W3_T
776  WRITE (ndst,9013) dttst1, dttst2, dttst3
777 #endif
778  IF ( dttst1.LT.0. .OR. dttst2.LT.0. .OR. dttst3.LT.0. ) THEN
779  IF ( iaproc .EQ. naperr ) WRITE (ndse,1003)
780  CALL extcde ( 4 )
781  END IF
782  IF ( dttst2.EQ.0..AND. itime.EQ.0 ) THEN
783  idact(3:3) = 'F'
784  tofrst = time
785  END IF
786  END IF
787 #ifdef W3_DEBUGCOH
788  CALL all_va_integral_print(imod, "W3WAVEMD, step 5", 1)
789 #endif
790  !
791  ! 1.e Ice concentration interval
792  !
793  IF ( flice ) THEN
794  IF ( tice(1) .GE. 0 ) THEN
795  dti0 = dsec21( tice , tin )
796  ELSE
797  dti0 = 1.
798  END IF
799 #ifdef W3_T
800  WRITE (ndst,9014) dti0
801 #endif
802  IF ( dti0 .LT. 0. ) THEN
803  IF ( iaproc .EQ. naperr ) WRITE (ndse,1004)
804  CALL extcde ( 5 )
805  END IF
806  ELSE
807  dti0 = 0.
808  END IF
809 #ifdef W3_DEBUGCOH
810  CALL all_va_integral_print(imod, "W3WAVEMD, step 6", 1)
811 #endif
812  !
813  ! 1.f Momentum interval
814  !
815  IF ( fltaua ) THEN
816  dttst1 = dsec21( tu0 , tun )
817  dttst2 = dsec21( tu0 , time )
818  dttst3 = dsec21( tend , tun )
819 #ifdef W3_T
820  WRITE (ndst,9017) dttst1, dttst2, dttst3
821 #endif
822  IF ( dttst1.LT.0. .OR. dttst2.LT.0. .OR. dttst3.LT.0. ) THEN
823  IF ( iaproc .EQ. naperr ) WRITE (ndse,1007)
824  CALL extcde ( 3 )
825  END IF
826  IF ( dttst2.EQ.0..AND. itime.EQ.0 ) THEN
827  idact(9:9) = 'F'
828  tofrst = time
829  END IF
830  END IF
831  !
832  ! 1.g Air density time
833  !
834  IF ( flrhoa ) THEN
835  dttst1 = dsec21( tr0 , trn )
836  dttst2 = dsec21( tr0 , time )
837  dttst3 = dsec21( tend , trn )
838 #ifdef W3_T
839  WRITE (ndst,9018) dttst1, dttst2, dttst3
840 #endif
841  IF ( dttst1.LT.0. .OR. dttst2.LT.0. .OR. dttst3.LT.0. ) THEN
842  IF ( iaproc .EQ. naperr ) WRITE (ndse,1008)
843  CALL extcde ( 2 )
844  END IF
845  IF ( dttst2.EQ.0..AND. itime.EQ.0 ) THEN
846  idact(11:11) = 'F'
847  tofrst = time
848  END IF
849  END IF
850  !
851  ! 1.e Ice thickness interval
852  !
853  IF ( flic1 ) THEN
854  IF ( tic1(1) .GE. 0 ) THEN
855  dti10 = dsec21( tic1 , ti1 )
856  ELSE
857  dti10 = 1.
858  END IF
859 #ifdef W3_T
860  WRITE (ndst,9015) dti10
861 #endif
862  IF ( dti10 .LT. 0. ) THEN
863  IF ( iaproc .EQ. naperr ) WRITE (ndse,1005)
864  CALL extcde ( 5 )
865  END IF
866  ELSE
867  dti10 = 0.
868  END IF
869  !
870  ! 1.e Ice floe interval
871  !
872 #ifdef W3_IS2
873  IF ( flic5 ) THEN
874  IF ( tic5(1) .GE. 0 ) THEN
875  dti50 = dsec21( tic5 , ti5 )
876  ELSE
877  dti50 = 1.
878  END IF
879 #ifdef W3_T
880  WRITE (ndst,9016) dti50
881 #endif
882  IF ( dti50 .LT. 0. ) THEN
883  IF ( iaproc .EQ. naperr ) WRITE (ndse,1006)
884  CALL extcde ( 5 )
885  END IF
886  ELSE
887  dti50 = 0.
888  END IF
889 #endif
890  !
891  ! 2. Determine next time from ending and output --------------------- /
892  ! time and get corresponding time step.
893  !
894  flfrst = .true.
895  DO
896 #ifdef W3_TIMINGS
897  CALL print_my_time("First entry in the TIME LOOP")
898 #endif
899 
900 #ifdef W3_DEBUGCOH
901  CALL all_va_integral_print(imod, "W3WAVEMD, step 6.1", 1)
902 #endif
903  !
904  !
905  ! 2.a Pre-calculate table for IC3 ------------------------------------ /
906 #ifdef W3_IC3
907  use_cheng=ic3pars(9)
908  IF( use_cheng==1.0 )THEN
909  fixedvisc=ic3pars(14)
910  fixeddens=ic3pars(15)
911  fixedelas=ic3pars(16)
912  IF ( (fixedvisc.LT.0.0).OR.(fixeddens.LT.0.0) .OR. (fixedelas.LT.0.0) ) THEN
913  IF ( iaproc .EQ. naperr ) &
914  WRITE(ndse,*)'Cheng method requires stationary', &
915  ' and uniform rheology from namelist.'
916  CALL extcde(2)
917  END IF
918  IF (calledic3table==0) THEN
919  CALL ic3table_cheng(fixedvisc,fixeddens,fixedelas)
920  calledic3table = 1
921  ENDIF
922  ENDIF
923 #endif
924 
925  ! 2.b Update group velocity and wavenumber from ice parameters ------- /
926  ! from W3SIC3MD module. ------------------------------------------ /
927  ! Note: "IF FLFRST" can be added for efficiency, but testing req'd
928 
929  jsea=1 ! no switch (intentional)
930 
931 #ifdef W3_IC3
932  use_cgice=ic3pars(12)
933  IF ( use_cgice==1.0 ) THEN
934  IF ( iaproc .EQ. naperr ) WRITE(screen,920)
935 #endif
936 
937 #ifdef W3_IC3
938  DO jsea=1,nseal
939 #endif
940 #ifdef W3_DIST
941  isea = iaproc + (jsea-1)*naproc
942 #endif
943 #ifdef W3_SHRD
944  isea = jsea
945 #endif
946 #ifdef W3_IC3
947  ALLOCATE(wn_i(SIZE(wn(:,isea))))
948  wn_i(:) = 0.
949  depth = max( dmin , dw(isea) )
950  ix = mapsf(isea,1)
951  iy = mapsf(isea,2)
952 #endif
953 
954  ! 2.b.1 Using Cheng method: requires stationary/uniform rheology.
955  ! However, ice thickness may be input by either method
956 
957 #ifdef W3_IC3
958  IF ( use_cheng==1.0 ) THEN
959  IF (flic1) THEN
960  hice=icep1(ix,iy)
961  ELSEIF (ic3pars(13).GE.0.0)THEN
962  hice=ic3pars(13)
963  ELSE
964  IF ( iaproc .EQ. naperr ) then
965  WRITE(ndse,*)'ICE THICKNESS NOT AVAILABLE FOR CG CALC'
966  end if
967  CALL extcde(2)
968  ENDIF
969  IF (hice > 0.0) THEN ! non-zero ice
970  CALL w3ic3wncg_cheng(wn(:,isea),wn_i(:), cg(:,isea),hice,fixedvisc, &
971  fixeddens, fixedelas, depth)
972  END IF ! non-zero ice
973 #endif
974 
975 #ifdef W3_IC3
976  ELSE ! not using Cheng method
977 #endif
978  ! 2.b.2 If not using Cheng method: require FLIC1 to FLIC4 (not strictly
979  ! necesssary, but makes code simpler)
980 
981 #ifdef W3_IC3
982  IF (flic1.AND.flic2.AND.flic3.AND.flic4) THEN
983  IF (icep1(ix,iy)>0.0) THEN ! non-zero ice
984  CALL w3ic3wncg_v1(wn(:,isea),wn_i(:), cg(:,isea),icep1(ix,iy), &
985  icep2(ix,iy), icep3(ix,iy),icep4(ix,iy),depth)
986  END IF ! non-zero ice
987  ELSE
988  IF ( iaproc .EQ. naperr ) then
989  WRITE(ndse,*)'ICE PARAMETERS NOT AVAILABLE FOR CG CALC'
990  end if
991  CALL extcde(2)
992  END IF
993  ENDIF ! IF USE_CHENG...
994 #endif
995 
996 #ifdef W3_IC3
997  DEALLOCATE(wn_i)
998  END DO ! DO JSEA=1,NSEAL
999  END IF ! IF USE_CGICE ...
1000 #endif
1001  !
1002  IF ( tofrst(1) .GT. 0 ) THEN
1003  dttst = dsec21( tend , tofrst )
1004  ELSE
1005  dttst = 0.
1006  ENDIF
1007  !
1008  IF ( dttst.GE.0. ) THEN
1009  tcalc = tend
1010  ELSE
1011  tcalc = tofrst
1012  END IF
1013  !
1014  dttst = dsec21( time , tcalc )
1015  nt = 1 + int( dttst / dtmax - 0.001 )
1016  dtga = dttst / real(nt)
1017  IF ( dttst .EQ. 0. ) THEN
1018  it0 = 0
1019  IF ( .NOT.flzero ) itime = itime - 1
1020  nt = 0
1021  ELSE
1022  it0 = 1
1023  END IF
1024  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE')
1025  !
1026 #ifdef W3_T
1027  WRITE (ndst,9020) it0, nt, dtga
1028 #endif
1029  !
1030  ! ==================================================================== /
1031  !
1032  ! 3. Loop over time steps
1033  !
1034  dtres = 0.
1035 
1036  !
1037  DO it = it0, nt
1038 #ifdef W3_TIMINGS
1039  CALL print_my_time("Begin of IT loop")
1040 #endif
1041 #ifdef W3_SETUP
1043 #endif
1044  ! copy old values
1045 #ifdef W3_PDLIB
1046  DO ip=1,nseal
1047  DO ispec=1,nspec
1048  vaold(ispec,ip)=va(ispec,ip)
1049  END DO
1050  END DO
1051 #endif
1052  !
1053 #ifdef W3_DEBUGCOH
1054  CALL all_va_integral_print(imod, "Beginning time loop", 1)
1055 #endif
1056 #ifdef W3_TIMINGS
1057  CALL print_my_time("After assigning VAOLD")
1058 #endif
1059  !
1060  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 0')
1061  !
1062  itime = itime + 1
1063  !
1064  dtg = real(nint(dtga+dtres+0.0001))
1065  dtres = dtres + dtga - dtg
1066  IF ( abs(dtres) .LT. 0.001 ) dtres = 0.
1067  CALL tick21 ( time , dtg )
1068  !
1069  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 1')
1070 
1071  IF ( tstamp .AND. screen.NE.ndso .AND. iaproc.EQ.napout ) THEN
1072  CALL wwtime ( sttime )
1073  CALL stme21 ( time , idtime )
1074  WRITE (screen,950) idtime, sttime
1075  END IF
1076  !
1077  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 2')
1078 
1079  vgx = 0.
1080  vgy = 0.
1081  IF(inflags1(10)) THEN
1082  dttst1 = dsec21( time, tgn )
1083  dttst2 = dsec21( tg0, tgn )
1084  fac = dttst1 / max( 1. , dttst2 )
1085  vgx = (fac*ga0+(1.-fac)*gan) * cos(fac*gd0+(1.-fac)*gdn)
1086  vgy = (fac*ga0+(1.-fac)*gan) * sin(fac*gd0+(1.-fac)*gdn)
1087  END IF
1088 #ifdef W3_TIMINGS
1089  CALL print_my_time("After VGX/VGY assignation")
1090 #endif
1091  !
1092 #ifdef W3_T
1093  WRITE (ndst,9021) itime, it, time, flmap, flddir, vgx, vgy, dtg, dtres
1094 #endif
1095  !
1096  ! 3.1 Interpolate winds, currents, and momentum.
1097  ! (Initialize wave fields with winds)
1098  !
1099 #ifdef W3_DEBUGDCXDX
1100  WRITE(740+iaproc,*) 'Debug DCXDX FLCUR=', flcur
1101 #endif
1102  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 3a')
1103 
1104  IF ( flcur ) THEN
1105 #ifdef W3_DEBUGCOH
1106  CALL all_va_integral_print(imod, "Before UCUR", 1)
1107 #endif
1108 #ifdef W3_TIMINGS
1109  CALL print_my_time("W3WAVE, step 6.4.1")
1110 #endif
1111  CALL w3ucur ( flfrst )
1112 
1113  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 3b')
1114 
1115  IF (gtype .EQ. smctype) THEN
1116  ix = 1
1117 #ifdef W3_SMC
1118  !!Li Use new sub for DCXDX/Y and DCYDX/Y assignment.
1119  CALL smcdcxy
1120 #endif
1121  ELSE IF (gtype .EQ. ungtype) THEN
1122 #ifdef W3_DEBUGDCXDX
1123  WRITE(740+iaproc,*) 'Before call to UG_GRADIENT for assigning DCXDX/DCXDY array'
1124 #endif
1125  CALL ug_gradients(cx, dcxdx, dcxdy)
1126  CALL ug_gradients(cy, dcydx, dcydy)
1127  ugdtupdate=.true.
1128  cflxymax = 0.
1129  ELSE
1130  CALL w3dzxy(cx(1:ubound(cx,1)),'m/s',dcxdx, dcxdy) !CX GRADIENT
1131  CALL w3dzxy(cy(1:ubound(cy,1)),'m/s',dcydx, dcydy) !CY GRADIENT
1132  ENDIF !! End GTYPE
1133  !
1134  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 4')
1135  !
1136  ELSE IF ( flfrst ) THEN
1137  ugdtupdate=.true.
1138  cflxymax = 0.
1139  cx = 0.
1140  cy = 0.
1141  END IF ! FLCUR
1142 #ifdef W3_TIMINGS
1143  CALL print_my_time("After CX/CY assignation")
1144 #endif
1145  !
1146  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 5')
1147 
1148  IF ( flwind ) THEN
1149  IF ( flfrst ) asf = 1.
1150  CALL w3uwnd ( flfrst, vgx, vgy )
1151  ELSE IF ( flfrst ) THEN
1152  u10 = 0.01
1153  u10d = 0.
1154  ust = 0.05
1155  ustdir = 0.05
1156  END IF
1157 
1158 #ifdef W3_DEBUGRUN
1159  DO jsea = 1, nseal
1160  DO is = 1, nspec
1161  IF (va(is, jsea) .LT. 0.) THEN
1162  WRITE(740+iaproc,*) 'TEST W3WAVE 5', va(is,jsea)
1163  CALL flush(740+iaproc)
1164  ENDIF
1165  ENDDO
1166  ENDDO
1167  IF (sum(va) .NE. sum(va)) THEN
1168  WRITE(740+iaproc,*) 'NAN in ACTION 5', ix, iy, sum(va)
1169  CALL flush(740+iaproc)
1170  stop
1171  ENDIF
1172 #endif
1173  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 6')
1174 
1175 #ifdef W3_TIMINGS
1176  CALL print_my_time("After U10, etc. assignation")
1177 #endif
1178  !
1179 #ifdef W3_DEBUGCOH
1180  CALL all_va_integral_print(imod, "Before call to W3UINI", 1)
1181 #endif
1182 #ifdef W3_TIMINGS
1183  CALL print_my_time("Before call W3UINI")
1184 #endif
1185  IF ( fliwnd .AND. local ) CALL w3uini ( va )
1186  !
1187  IF ( fltaua ) THEN
1188  CALL w3utau ( flfrst )
1189  ELSE IF ( flfrst ) THEN
1190  taua = 0.01
1191  tauadir = 0.
1192  END IF
1193  !
1194  IF ( flrhoa ) THEN
1195  CALL w3urho ( flfrst )
1196  ELSE IF ( flfrst ) THEN
1197  rhoair = dair
1198  END IF
1199  !
1200  ! 3.2 Update boundary conditions if boundary flag is true (FLBPI)
1201  !
1202 #ifdef W3_DEBUGCOH
1203  CALL all_va_integral_print(imod, "Before boundary update", 1)
1204 #endif
1205 #ifdef W3_TIMINGS
1206  CALL print_my_time("Before boundary update")
1207 #endif
1208  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 7')
1209 
1210  IF ( flbpi .AND. local ) THEN
1211  !
1212  DO
1213  IF ( tbpin(1) .EQ. -1 ) THEN
1214  readbc = .true.
1215  idact(1:1) = 'F'
1216  ELSE
1217  readbc = dsec21(time,tbpin).LT.0.
1218  IF (readbc.AND.idact(1:1).EQ.' ') idact(1:1) = 'X'
1219  END IF
1220  flact = readbc .OR. flact
1221 
1222  IF ( readbc ) THEN
1223  CALL w3iobc ( 'READ', nds(9), tbpi0, tbpin, itest, imod )
1224  IF ( itest .NE. 1 ) CALL w3ubpt
1225  ELSE
1226  itest = 0
1227  END IF
1228  IF ( itest .LT. 0 ) idact(1:1) = 'L'
1229  IF ( itest .GT. 0 ) idact(1:1) = ' '
1230  IF ( .NOT. (readbc.AND.flbpi) ) EXIT
1231  END DO
1232 
1233  END IF
1234  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 7')
1235 
1236 #ifdef W3_PDLIB
1237  CALL apply_boundary_condition_va
1238 #ifdef W3_DEBUGCOH
1239  CALL all_va_integral_print(imod, "After FLBPI and LOCAL", 1)
1240 #endif
1241 #endif
1242 #ifdef W3_TIMINGS
1243  CALL print_my_time("After FLBPI and LOCAL")
1244 #endif
1245  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 8')
1246  !
1247  ! 3.3.1 Update ice coverage (if new ice map).
1248  ! Need to be run on output nodes too, to update MAPSTx
1249  !
1250  IF ( flice .AND. dti0.NE.0. ) THEN
1251  !
1252  IF ( tice(1).GE.0 ) THEN
1253  IF ( dti0 .LT. 0. ) THEN
1254  idact(13:13) = 'B'
1255  ELSE
1256  dttst = dsec21( time, tin )
1257  IF ( dttst .LE. 0.5*dti0 ) idact(13:13) = 'U'
1258  END IF
1259  ELSE
1260  idact(13:13) = 'I'
1261  END IF
1262  !
1263  IF ( idact(13:13).NE.' ' ) THEN
1264  CALL w3uice ( va )
1265  dti0 = 0.
1266  flact = .true.
1267  flmap = .true.
1268  END IF
1269  END IF
1270 #ifdef W3_DEBUGCOH
1271  CALL all_va_integral_print(imod, "After FLICE and DTI0", 1)
1272 #endif
1273 #ifdef W3_TIMINGS
1274  CALL print_my_time("After FLICE and DTI0")
1275 #endif
1276  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 9')
1277  !
1278  ! 3.3.2 Update ice thickness
1279  !
1280  IF ( flic1 .AND. dti10.NE.0. ) THEN
1281  !
1282  IF ( tic1(1).GE.0 ) THEN
1283  IF ( dti10 .LT. 0. ) THEN
1284  idact(15:15) = 'B'
1285  ELSE
1286  dttst = dsec21( time, ti1 )
1287  IF ( dttst .LE. 0.5*dti10 ) idact(15:15) = 'U'
1288  END IF
1289  ELSE
1290  idact(15:15) = 'I'
1291  END IF
1292 
1293  !
1294  IF ( idact(15:15).NE.' ' ) THEN
1295  CALL w3uic1 ( flfrst )
1296  dti10 = 0.
1297  flact = .true.
1298  flmap = .true.
1299  END IF
1300  !
1301  END IF
1302  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 10')
1303  !
1304  ! 3.3.3 Update ice floe diameter
1305  !
1306 #ifdef W3_IS2
1307  IF ( flic5 .AND. dti50.NE.0. ) THEN
1308  !
1309  IF ( tic5(1).GE.0 ) THEN
1310  IF ( dti50 .LT. 0. ) THEN
1311  idact(18:18) = 'B'
1312  ELSE
1313  dttst = dsec21( time, ti5 )
1314  IF ( dttst .LE. 0.5*dti50 ) idact(18:18) = 'U'
1315  END IF
1316  ELSE
1317  idact(18:18) = 'I'
1318  END IF
1319  !
1320  IF ( idact(18:18).NE.' ' ) THEN
1321  CALL w3uic5( flfrst )
1322  dti50 = 0.
1323  flact = .true.
1324  flmap = .true.
1325  END IF
1326  !
1327  END IF
1328 #endif
1329  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 11a')
1330  !
1331  ! 3.4 Transform grid (if new water level).
1332  !
1333  IF ( fllev .AND. dtl0 .NE.0. ) THEN
1334  !
1335  IF ( tlev(1) .GE. 0 ) THEN
1336  IF ( dtl0 .LT. 0. ) THEN
1337  idact(5:5) = 'B'
1338  ELSE
1339  dttst = dsec21( time, tln )
1340  IF ( dttst .LE. 0.5*dtl0 ) idact(5:5) = 'U'
1341  END IF
1342  ELSE
1343  idact(5:5) = 'I'
1344  END IF
1345  !
1346  IF ( idact(5:5).NE.' ' ) THEN
1347 
1348  CALL w3ulev ( va, va )
1349 
1350  ugdtupdate=.true.
1351  cflxymax = 0.
1352  dtl0 = 0.
1353  flact = .true.
1354  flmap = .true.
1355  flddir = flddir .OR. flcth .OR. fsrefraction .OR. flck .OR. fsfreqshift
1356  END IF
1357  END IF
1358 #ifdef W3_DEBUGCOH
1359  CALL all_va_integral_print(imod, "After FFLEV and DTL0", 1)
1360 #endif
1361 #ifdef W3_TIMINGS
1362  CALL print_my_time("After FFLEV and DTL0")
1363 #endif
1364  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 11b')
1365  !
1366  ! 3.5 Update maps and derivatives.
1367  !
1368  IF ( flmap ) THEN
1369  IF ( gtype .NE. smctype ) THEN
1370 #ifdef W3_PR1
1371  CALL w3map1 ( mapsta )
1372 #endif
1373 #ifdef W3_PR2
1374  CALL w3map2
1375 #endif
1376 #ifdef W3_PR3
1377  CALL w3map3
1378 #endif
1379  CALL w3utrn ( trnx, trny )
1380 #ifdef W3_PR3
1381  CALL w3mapt
1382 #endif
1383  END IF !! GTYPE
1384 
1385  !! Hides call to W3NMIN, which currently only serves to warn when
1386  !! one or more procs have zero active seapoints.
1387 #ifdef W3_DEBUGRUN
1388  CALL w3nmin ( mapsta, flag0 )
1389  IF ( flag0 .AND. iaproc.EQ.naperr ) WRITE (ndse,1030) imod
1390 #endif
1391  flmap = .false.
1392  END IF
1393  !
1394  !
1395  IF ( flddir ) THEN
1396  IF (gtype .EQ. smctype) THEN
1397  ix = 1
1398 #ifdef W3_SMC
1399  !!Li Use new sub for DDDX and DDDY assignment.
1400  CALL smcdhxy
1401 #endif
1402  ELSE IF (gtype .EQ. ungtype) THEN
1403  CALL ug_gradients(dw, dddx, dddy)
1404  ELSE
1405  CALL w3dzxy(dw(1:ubound(dw,1)),'m',dddx,dddy)
1406  END IF
1407  flddir = .false.
1408  END IF
1409 
1410  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 12')
1411  !
1412  ! Calculate PHASE SPEED GRADIENT.
1413  dcdx = 0.
1414  dcdy = 0.
1415 #ifdef W3_REFRX
1416  cik = 0.
1417  !
1418  IF (gtype .NE. ungtype) THEN
1419  DO ik=0,nk+1
1420  cik = sig(ik) / wn(ik,1:nsea)
1421  CALL w3dzxy(cik,'m/s',dcdx(ik,:,:),dcdy(ik,:,:))
1422  END DO
1423  ELSE
1424  WRITE (ndse,1040)
1425  CALL extcde(2)
1426  ! CALL UG_GRADIENTS(CMN, DCDX, DCDY) !/ Stefan, to be confirmed!
1427  END IF
1428 #endif
1429  !
1430  !
1431  fliwnd = .false.
1432  flfrst = .false.
1433  !
1434 #ifdef W3_PDLIB
1435 #ifdef W3_DEBUGSRC
1436  WRITE(740+iaproc,*) 'ITIME=', itime, ' IT=', it
1437  CALL all_va_integral_print(imod, "VA before W3SRCE_IMP_PRE", 1)
1438  CALL all_field_integral_print(vstot, "VSTOT before W3SRCE_IMP_PRE")
1439  CALL all_field_integral_print(vdtot, "VDTOT before W3SRCE_IMP_PRE")
1440  IF (debug_node .le. nseal) THEN
1441  WRITE(740+iaproc,*) ' Values for DEBUG_NODE=', debug_node
1442  WRITE(740+iaproc,*) ' sum(VA)=', sum(va(:,debug_node))
1443  WRITE(740+iaproc,*) ' sum(VSTOT)=', sum(vstot(:,debug_node))
1444  WRITE(740+iaproc,*) ' sum(VDTOT)=', sum(vdtot(:,debug_node))
1445  END IF
1446 #endif
1447  IF (it .eq. 0) THEN
1448  dtgpre = 1.
1449  ELSE
1450  dtgpre = dtg
1451  END IF
1452 #endif
1453  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 13')
1454  !
1455 #ifdef W3_PDLIB
1456  IF (lpdlib .and. flsou .and. fssource) THEN
1457 #endif
1458 
1459 #ifdef W3_OMP0
1460  !$OMP PARALLEL DO PRIVATE (JSEA,ISEA,IX,IY) SCHEDULE (DYNAMIC,1)
1461 #endif
1462 
1463 #ifdef W3_PDLIB
1464  d50=0.0002
1465  reflec(:)=0.
1466  refled(:)=0
1467  psic=0.
1468 #endif
1469 
1470 #ifdef W3_PDLIB
1471  IF (lsloc) THEN
1472  b_jac = 0.
1473  aspar_jac = 0.
1474  ELSE
1475  vstot = 0.
1476  vdtot = 0.
1477  ENDIF
1478 #endif
1479 
1480 
1481 #ifdef W3_PDLIB
1482 
1483  DO jsea = 1, np
1484 
1485  CALL init_get_isea(isea, jsea)
1486 
1487  ix = mapsf(isea,1)
1488  iy = mapsf(isea,2)
1489  dela=1.
1490  delx=1.
1491  dely=1.
1492 
1493 #ifdef W3_REF1
1494  IF (gtype.EQ.rlgtype) THEN
1495  delx=sx*clats(isea)/facx
1496  dely=sy/facx
1497  dela=delx*dely
1498  END IF
1499  IF (gtype.EQ.clgtype) THEN
1500  ! Maybe what follows works also for RLGTYPE ... to be verified
1501  delx=hpfac(iy,ix)/ facx
1502  dely=hqfac(iy,ix)/ facx
1503  dela=delx*dely
1504  END IF
1505  reflec=reflc(:,isea)
1506  reflec(4)=berg(isea)*reflec(4)
1507  refled=refld(:,isea)
1508 #endif
1509 
1510 #ifdef W3_BT4
1511  d50=sed_d50(isea)
1512  psic=sed_psic(isea)
1513 #endif
1514  !
1515 #ifdef W3_DEBUGSRC
1516  IF (ix .eq. debug_node) THEN
1517  WRITE(740+iaproc,*) 'NODE_SRCE_IMP_PRE : IX=', ix, ' JSEA=', jsea
1518  END IF
1519  WRITE(740+iaproc,*) 'IT/IX/IY/IMOD=', it, ix, iy, imod
1520  WRITE(740+iaproc,*) 'ISEA/JSEA=', isea, jsea
1521  WRITE(740+iaproc,*) 'Before sum(VA)=', sum(va(:,jsea))
1522  FLUSH(740+iaproc)
1523 #endif
1524  CALL w3srce(srce_imp_pre, it, isea, jsea, ix, iy, imod, &
1525  vaold(:,jsea), va(:,jsea), &
1526  vsiodummy, vdiodummy, shavetot(jsea), &
1527  alpha(1:nk,jsea), wn(1:nk,isea), &
1528  cg(1:nk,isea), clats(isea), dw(isea), u10(isea), &
1529  u10d(isea), &
1530 #ifdef W3_FLX5
1531  taua(isea), tauadir(isea), &
1532 #endif
1533  as(isea), ust(isea), &
1534  ustdir(isea), cx(isea), cy(isea), &
1535  ice(isea), iceh(isea), icef(isea), &
1536  icedmax(isea), &
1537  reflec, refled, delx, dely, dela, &
1538  trnx(iy,ix), trny(iy,ix), berg(isea), &
1539  fpis(isea), dtdyn(jsea), &
1540  fcut(jsea), dtgpre, tauwx(jsea), tauwy(jsea), &
1541  tauox(jsea), tauoy(jsea), tauwix(jsea), &
1542  tauwiy(jsea), tauwnx(jsea), &
1543  tauwny(jsea), phiaw(jsea), charn(jsea), &
1544  tws(jsea), phioc(jsea), tmp1, d50, psic, tmp2, &
1545  phibbl(jsea), tmp3, tmp4, phice(jsea), &
1546  tauocx(jsea), tauocy(jsea), wnmean(jsea), &
1547  rhoair(isea), asf(isea))
1548  IF (.not. lsloc) THEN
1549  vstot(:,jsea) = vsiodummy
1550  vdtot(:,jsea) = vdiodummy
1551  ENDIF
1552 #ifdef W3_DEBUGSRC
1553  WRITE(740+iaproc,*) 'After sum(VA)=', sum(va(:,jsea))
1554  WRITE(740+iaproc,*) ' sum(VSTOT)=', sum(vstot(:,jsea))
1555  WRITE(740+iaproc,*) ' sum(VDTOT)=', sum(vdtot(:,jsea))
1556  WRITE(740+iaproc,*) ' SHAVETOT=', shavetot(jsea)
1557  FLUSH(740+iaproc)
1558 #endif
1559  END DO ! JSEA
1560  END IF ! PDLIB
1561 #endif
1562 
1563 
1564 #ifdef W3_PDLIB
1565 #ifdef W3_DEBUGSRC
1566  WRITE(740+iaproc,*) 'ITIME=', itime, ' IT=', it
1567  CALL all_va_integral_print(imod, "VA after W3SRCE_IMP_PRE", 1)
1568  CALL all_field_integral_print(vstot, "VSTOT after W3SRCE_IMP_PRE")
1569  CALL all_field_integral_print(vdtot, "VDTOT after W3SRCE_IMP_PRE")
1570  IF (debug_node .le. nseal) THEN
1571  WRITE(740+iaproc,*) ' Values for DEBUG_NODE=', debug_node
1572  WRITE(740+iaproc,*) ' sum(VA)=', sum(va(:,debug_node))
1573  WRITE(740+iaproc,*) ' sum(VSTOT)=', sum(vstot(:,debug_node))
1574  WRITE(740+iaproc,*) ' sum(VDTOT)=', sum(vdtot(:,debug_node))
1575  END IF
1576 #endif
1577 #endif
1578  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 14')
1579 
1580  IF ( flzero ) THEN
1581 #ifdef W3_T
1582  WRITE (ndst,9022)
1583 #endif
1584  GOTO 400
1585  END IF
1586  IF ( it.EQ.0 ) THEN
1587  dtg = 1.
1588  ! DTG = 60.
1589  GOTO 370
1590  END IF
1591  IF ( fldry .OR. iaproc.GT.naproc ) THEN
1592 #ifdef W3_T
1593  WRITE (ndst,9023)
1594 #endif
1595  GOTO 380
1596  END IF
1597  !
1598  ! Estimation of the local maximum CFL for XY propagation
1599  !
1600 #ifdef W3_T
1601  WRITE(ndse,*) 'Computing CFLs .... ',nseal
1602 #endif
1603  IF ( flogrd(9,3).AND. ugdtupdate ) THEN
1604  IF (fstotalimp .eqv. .false.) THEN
1605  nkcfl=nk
1606 #ifdef W3_T
1607  nkcfl=1
1608 #endif
1609  !
1610 #ifdef W3_OMPG
1611  !$OMP PARALLEL DO PRIVATE (JSEA,ISEA) SCHEDULE (DYNAMIC,1)
1612 #endif
1613  !
1614  DO jsea=1, nseal
1615  CALL init_get_isea(isea, jsea)
1616 #ifdef W3_PR3
1617  IF (gtype .EQ. ungtype) THEN
1618  IF ( flogrd(9,3) ) THEN
1619 #endif
1620 #ifdef W3_T
1621  IF (mod(isea,100).EQ.0) WRITE(ndse,*) 'COMPUTING CFL FOR NODE:',isea
1622 #endif
1623 #ifdef W3_PDLIB
1624  IF (.NOT. lpdlib) THEN
1625 #endif
1626 #ifdef W3_PR3
1627  CALL w3cflug ( isea, nkcfl, facx, facx, dtg, mapfs, cflxymax(jsea), &
1628  vgx, vgy )
1629 #endif
1630 #ifdef W3_PDLIB
1631  ENDIF
1632 #endif
1633 #ifdef W3_PR3
1634  END IF
1635  ELSE
1636  CALL w3cflxy ( isea, dtg, mapsta, mapfs, cflxymax(jsea), vgx, vgy )
1637  END IF
1638 #endif
1639  END DO
1640  !
1641 #ifdef W3_OMPG
1642  !$OMP END PARALLEL DO
1643 #endif
1644  !
1645  END IF
1646  END IF
1647  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 15')
1648  !
1649 
1650  !
1651 #ifdef W3_T
1652  IF (gtype .EQ. ungtype) THEN
1653  IF ( flogrd(9,3) ) THEN
1654  dtcfl1(:)=1.
1655  DO jsea=1,nseal
1656  indsort(jsea)=float(jsea)
1657  dtcfl1(jsea)=dtg/cflxymax(jsea)
1658  END DO
1659  CALL ssort1 (dtcfl1, indsort, nseal, 2)
1660  IF ( iaproc .EQ. naperr ) WRITE(ndse,*) 'Nodes requesting smallest timesteps:'
1661  IF ( iaproc .EQ. naperr ) WRITE(ndse,'(A,10I10)') 'Nodes ',nint(indsort(1:10))
1662  IF ( iaproc .EQ. naperr ) WRITE(ndse,'(A,10F10.2)') 'time steps ',dtcfl1(1:10)
1663  DO jsea = 1, min(nseal,200)
1664  isea = nint(indsort(jsea)) ! will not work with MPI
1665  ix = mapsf(isea,1)
1666  IF (jsea.EQ.1) then
1667  WRITE(995,*) ' IP dtmax_exp(ip) x-coord y-coord z-coord'
1668  end if
1669  WRITE(995,'(I10,F10.2,3F10.4)') ix, dtcfl1(jsea), xgrd(1,ix), ygrd(2,ix), zb(ix)
1670  END DO ! JSEA
1671  CLOSE(995)
1672  END IF
1673  END IF
1674 #endif
1675 
1676  !
1677  ! 3.6 Perform Propagation = = = = = = = = = = = = = = = = = = = = = = =
1678  ! 3.6.1 Preparations
1679  !
1680 #ifdef W3_SEC1
1681  dtgtemp=dtg
1682  dtg=dtg/nitersec1
1683  DO isec1=1,nitersec1
1684 #endif
1685  ntloc = 1 + int( dtg/dtcfli - 0.001 )
1686 #ifdef W3_SEC1
1687  IF ( iaproc .EQ. napout ) then
1688  WRITE(ndse,'(A,I4,A,I4)') ' SUBSECOND STEP:',isec1,' out of ',nitersec1
1689  end if
1690 #endif
1691  !
1692  facth = dtg / (dth*real(ntloc))
1693  fack = dtg / real(ntloc)
1694 
1695  ttest(1) = time(1)
1696  ttest(2) = 0
1697  dttest = dsec21(ttest,time)
1698  itloch = ( ntloc + 1 - mod(nint(dttest/dtg),2) ) / 2
1699  !
1700  ! 3.6.2 Intra-spectral part 1
1701  !
1702 #ifdef W3_DEBUGCOH
1703  CALL all_va_integral_print(imod, "Before intraspectral part 1", 1)
1704 #endif
1705 #ifdef W3_TIMINGS
1706  CALL print_my_time("Before intraspectral")
1707 #endif
1708  IF ( flcth .OR. flck ) THEN
1709  DO itloc=1, itloch
1710  !
1711 #ifdef W3_OMPG
1712  !$OMP PARALLEL PRIVATE (JSEA,ISEA,IX,IY,DEPTH,IXrel)
1713  !$OMP DO SCHEDULE (DYNAMIC,1)
1714 #endif
1715  !
1716  DO jsea=1, nseal
1717  CALL init_get_isea(isea, jsea)
1718  ix = mapsf(isea,1)
1719  iy = mapsf(isea,2)
1720 
1721 
1722  IF ( gtype .EQ. ungtype ) THEN
1723  IF (lpdlib) THEN
1724 #ifdef W3_PDLIB
1725  IF (iobp_loc(jsea) .NE. 1) cycle
1726 #endif
1727  ELSE
1728  IF (iobp(isea) .NE. 1) cycle
1729  ENDIF
1730  ENDIF
1731 
1732  IF ( mapsta(iy,ix) .EQ. 1 ) THEN
1733  depth = max( dmin , dw(isea) )
1734  IF (lpdlib) THEN
1735  ixrel = jsea
1736  ELSE
1737  ixrel = ix
1738  END IF
1739  !
1740  IF( gtype .EQ. smctype ) THEN
1741  j = 1
1742 #ifdef W3_SMC
1743  !!Li Refraction and GCT in theta direction is done by rotation.
1744  CALL w3krtn ( isea, facth, fack, cthg0s(isea), &
1745  cg(:,isea), wn(:,isea), depth, &
1746  dhdx(isea), dhdy(isea), dhlmt(:,isea), &
1747  cx(isea), cy(isea), dcxdx(iy,ix), &
1748  dcxdy(iy,ix), dcydx(iy,ix), dcydy(iy,ix), &
1749  dcdx(:,iy,ix), dcdy(:,iy,ix), va(:,jsea) )
1750 #endif
1751  !
1752  ELSE
1753  j = 1
1754  !
1755 #ifdef W3_PR1
1756  CALL w3ktp1 ( isea, facth, fack, cthg0s(isea), &
1757  cg(:,isea), wn(:,isea), depth, &
1758  dddx(iy,ixrel), dddy(iy,ixrel), cx(isea), &
1759  cy(isea), dcxdx(iy,ixrel), dcxdy(iy,ixrel), &
1760  dcydx(iy,ixrel), dcydy(iy,ixrel), &
1761  dcdx(:,iy,ixrel), dcdy(:,iy,ixrel), va(:,jsea))
1762 #endif
1763 #ifdef W3_PR2
1764  CALL w3ktp2 ( isea, facth, fack, cthg0s(isea), &
1765  cg(:,isea), wn(:,isea), depth, &
1766  dddx(iy,ixrel), dddy(iy,ixrel), cx(isea), &
1767  cy(isea), dcxdx(iy,ixrel), dcxdy(iy,ixrel), &
1768  dcydx(iy,ixrel), dcydy(iy,ixrel), &
1769  dcdx(:,iy,ixrel), dcdy(:,iy,ixrel), va(:,jsea))
1770 #endif
1771 #ifdef W3_PR3
1772  CALL w3ktp3 ( isea, facth, fack, cthg0s(isea), &
1773  cg(:,isea), wn(:,isea), depth, &
1774  dddx(iy,ixrel), dddy(iy,ixrel), cx(isea), &
1775  cy(isea), dcxdx(iy,ixrel), dcxdy(iy,ixrel), &
1776  dcydx(iy,ixrel), dcydy(iy,ixrel), &
1777  dcdx(:,iy,ixrel), dcdy(:,iy,ixrel), va(:,jsea), &
1778  cflthmax(jsea), cflkmax(jsea) )
1779 #endif
1780  !
1781  END IF !! GTYPE
1782  !
1783  END IF
1784  END DO
1785  !
1786 #ifdef W3_OMPG
1787  !$OMP END DO
1788  !$OMP END PARALLEL
1789 #endif
1790  !
1791  END DO
1792  END IF
1793 
1794  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 16')
1795 
1796 #ifdef W3_DEBUGCOH
1797  CALL all_va_integral_print(imod, "Before spatial advection", 1)
1798 #endif
1799 #ifdef W3_TIMINGS
1800  CALL print_my_time("Before spatial advection")
1801 #endif
1802  !
1803  ! 3.6.3 Longitude-latitude
1804  ! (time step correction in routine)
1805  !
1806  IF (gtype .EQ. ungtype) THEN
1807  IF (flagll) THEN
1808  facx = 1./(dera * radius)
1809  ELSE
1810  facx = 1.
1811  END IF
1812  END IF
1813 
1814  IF (lpdlib) THEN
1815  !
1816 #ifdef W3_PDLIB
1817  IF (flcx .or. flcy) THEN
1818  IF (.NOT. fstotalimp .AND. .NOT. fstotalexp) THEN
1819  DO ispec=1,nspec
1820  CALL pdlib_w3xypug ( ispec, facx, facx, dtg, vgx, vgy, ugdtupdate )
1821  END DO
1822  END IF
1823  END IF
1824 #endif
1825  !
1826 #ifdef W3_PDLIB
1827  IF (fstotalimp .and. (it .ne. 0)) THEN
1828 #endif
1829 #ifdef W3_DEBUGCOH
1830  CALL all_va_integral_print(imod, "Before Block implicit", 1)
1831 #endif
1832 #ifdef W3_PDLIB
1833  CALL pdlib_w3xypug_block_implicit(imod, facx, facx, dtg, vgx, vgy, ugdtupdate )
1834 #endif
1835 #ifdef W3_PDLIB
1836  ELSE IF(fstotalexp .and. (it .ne. 0)) THEN
1837 #endif
1838 #ifdef W3_PDLIB
1839  CALL pdlib_w3xypug_block_explicit(imod, facx, facx, dtg, vgx, vgy, ugdtupdate )
1840 #endif
1841 #ifdef W3_PDLIB
1842  ENDIF
1843 #endif
1844  ELSE
1845  IF (flcx .or. flcy) THEN
1846  !
1847 #ifdef W3_MPI
1848  IF ( nrqsg1 .GT. 0 ) THEN
1849  CALL mpi_startall (nrqsg1, irqsg1(1,1), ierr_mpi)
1850  CALL mpi_startall (nrqsg1, irqsg1(1,2), ierr_mpi)
1851  END IF
1852 #endif
1853  !
1854  !
1855  ! Initialize FIELD variable
1856  field = 0.
1857  !
1858  DO ispec=1, nspec
1859  IF ( iappro(ispec) .EQ. iaproc ) THEN
1860  !
1861  IF( gtype .EQ. smctype ) THEN
1862  ix = 1
1863 #ifdef W3_SMC
1864  !!Li Use SMC sub to gether field
1865  CALL w3gathsmc ( ispec, field )
1866 #endif
1867  ELSE IF (.NOT.lpdlib ) THEN
1868  CALL w3gath ( ispec, field )
1869  END IF !! GTYPE
1870  !
1871  IF (gtype .EQ. smctype) THEN
1872  ix = 1
1873 #ifdef W3_SMC
1874  !!Li Propagation on SMC grid uses UNO2 scheme.
1875  CALL w3psmc ( ispec, dtg, field )
1876 #endif
1877  !
1878  ELSE IF (gtype .EQ. ungtype) THEN
1879  ix = 1
1880 #ifdef W3_MPI
1881  IF (.NOT. lpdlib) THEN
1882 #endif
1883 #ifdef W3_PR1
1884  CALL w3xypug ( ispec, facx, facx, dtg, field, vgx, vgy, ugdtupdate )
1885 #endif
1886 #ifdef W3_PR2
1887  CALL w3xypug ( ispec, facx, facx, dtg, field, vgx, vgy, ugdtupdate )
1888 #endif
1889 #ifdef W3_PR3
1890  CALL w3xypug ( ispec, facx, facx, dtg, field, vgx, vgy, ugdtupdate )
1891 #endif
1892 #ifdef W3_MPI
1893  END IF
1894 #endif
1895  !
1896  ELSE
1897  ix = 1
1898 #ifdef W3_PR1
1899  CALL w3xyp1 ( ispec, dtg, mapsta, field, vgx, vgy )
1900 #endif
1901 #ifdef W3_PR2
1902  CALL w3xyp2 ( ispec, dtg, mapsta, mapfs, field, vgx, vgy )
1903 #endif
1904 #ifdef W3_PR3
1905  CALL w3xyp3 ( ispec, dtg, mapsta, mapfs, field, vgx, vgy )
1906 #endif
1907  !
1908  END IF !! GTYPE
1909  !
1910  IF( gtype .EQ. smctype ) THEN
1911  ix = 1
1912 #ifdef W3_SMC
1913  !!Li Use SMC sub to scatter field
1914  CALL w3scatsmc ( ispec, mapsta, field )
1915 #endif
1916  ELSE IF (.NOT.lpdlib ) THEN
1917  CALL w3scat ( ispec, mapsta, field )
1918  END IF !! GTYPE
1919 
1920  END IF
1921  END DO
1922  !
1923 #ifdef W3_MPI
1924  IF ( nrqsg1 .GT. 0 ) THEN
1925  ALLOCATE ( statco(mpi_status_size,nrqsg1) )
1926  CALL mpi_waitall (nrqsg1, irqsg1(1,1), statco, ierr_mpi)
1927  CALL mpi_waitall (nrqsg1, irqsg1(1,2), statco, ierr_mpi)
1928  DEALLOCATE ( statco )
1929  END IF
1930 #endif
1931  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE TIME LOOP 17')
1932  !
1933  !Li Initialise IK IX IY in case ARC option is not used to avoid warnings.
1934  ik=1
1935  ix=1
1936  iy=1
1937 #ifdef W3_SMC
1938  !Li Find source boundary spectra and assign to SPCBAC
1939  IF( arctc ) THEN
1940 
1941  DO ik = 1, nbac
1942  IF( ik .LE. (nbac-nbgl) ) THEN
1943  iy = iclbac(ik)
1944  ELSE
1945  iy = nglo + ik
1946  ENDIF
1947 
1948  !Li Work out root PE (ISPEC) and JSEA numbers for IY
1949 #ifdef W3_DIST
1950  ispec = mod( iy-1, naproc )
1951  jsea = 1 + (iy - ispec - 1)/naproc
1952 #endif
1953 #ifdef W3_SHRD
1954  ispec = 0
1955  jsea = iy
1956 #endif
1957 #endif
1958  ! W3_SMC ...
1959  !
1960 #ifdef W3_SMC
1961  !!Li Assign boundary cell spectra.
1962  IF( iaproc .EQ. ispec+1 ) THEN
1963  spcbac(:,ik)=va(:,jsea)
1964  ENDIF
1965 #endif
1966  !
1967 #ifdef W3_SMC
1968  !!Li Broadcast local SPCBAC(:,IK) to all other PEs.
1969 #ifdef W3_MPI
1970  CALL mpi_bcast(spcbac(1,ik),nspec,mpi_real,ispec,mpi_comm_wave,ierr_mpi)
1971  CALL mpi_barrier (mpi_comm_wave,ierr_mpi)
1972 #endif
1973 #endif
1974  !
1975 #ifdef W3_SMC
1976  END DO !! Loop IK ends.
1977 #endif
1978  !
1979 #ifdef W3_SMC
1980  !!Li Update Arctic boundary cell spectra if within local range
1981  ALLOCATE ( bacspec(nspec) )
1982  DO ik = 1, nbac
1983  IF( ik .LE. (nbac-nbgl) ) THEN
1984  ix = nglo + ik
1985  bacangl = angarc(ik)
1986  ELSE
1987  ix = iclbac(ik)
1988  bacangl = - angarc(ik)
1989  ENDIF
1990 
1991  !!Li Work out boundary PE (ISPEC) and JSEA numbers for IX
1992 #ifdef W3_DIST
1993  ispec = mod( ix-1, naproc )
1994  jsea = 1 + (ix - ispec - 1)/naproc
1995 #endif
1996 #ifdef W3_SHRD
1997  ispec = 0
1998  jsea = ix
1999 #endif
2000 #endif
2001  !
2002 #ifdef W3_SMC
2003  IF( iaproc .EQ. ispec+1 ) THEN
2004  bacspec = spcbac(:,ik)
2005 
2006  CALL w3acturn( nth, nk, bacangl, bacspec )
2007 
2008  va(:,jsea) = bacspec
2009  !!Li WRITE(NDSE,*) "IAPROC, IX, JSEAx, IK=", IAPROC, IX, JSEA, IK
2010  ENDIF
2011 
2012  END DO !! Loop IK ends.
2013  DEALLOCATE ( bacspec )
2014 
2015  ENDIF !! ARCTC
2016 #endif
2017  !
2018  ! End of test FLCX.OR.FLCY
2019  END IF
2020  !
2021  END IF
2022 
2023 #ifdef W3_DEBUGCOH
2024  CALL all_va_integral_print(imod, "After spatial advection", 1)
2025 #endif
2026 #ifdef W3_TIMINGS
2027  CALL print_my_time("After spatial advection")
2028 #endif
2029  !
2030  ! 3.6.4 Intra-spectral part 2
2031  !
2032  IF ( flcth .OR. flck ) THEN
2033  DO itloc=itloch+1, ntloc
2034  !
2035 #ifdef W3_OMPG
2036  !$OMP PARALLEL PRIVATE (JSEA,ISEA,IX,IY,DEPTH,IXrel)
2037  !$OMP DO SCHEDULE (DYNAMIC,1)
2038 #endif
2039  !
2040  DO jsea = 1, nseal
2041 
2042  CALL init_get_isea(isea, jsea)
2043  ix = mapsf(isea,1)
2044  iy = mapsf(isea,2)
2045  depth = max( dmin , dw(isea) )
2046 
2047  IF ( gtype .EQ. ungtype ) THEN
2048  IF (lpdlib) THEN
2049 #ifdef W3_PDLIB
2050  IF (iobp_loc(jsea) .NE. 1) cycle
2051 #endif
2052  ELSE
2053  IF (iobp(isea) .NE. 1) cycle
2054  ENDIF
2055  ENDIF
2056 
2057  IF ( mapsta(iy,ix) .EQ. 1 ) THEN
2058  IF (lpdlib) THEN
2059  ixrel = jsea
2060  ELSE
2061  ixrel = ix
2062  END IF
2063  !
2064  IF( gtype .EQ. smctype ) THEN
2065  j = 1
2066 #ifdef W3_SMC
2067  !!Li Refraction and GCT in theta direction is done by rotation.
2068  CALL w3krtn ( isea, facth, fack, cthg0s(isea), &
2069  cg(:,isea), wn(:,isea), depth, &
2070  dhdx(isea), dhdy(isea), dhlmt(:,isea), &
2071  cx(isea), cy(isea), dcxdx(iy,ix), &
2072  dcxdy(iy,ix), dcydx(iy,ix), dcydy(iy,ix), &
2073  dcdx(:,iy,ix), dcdy(:,iy,ix), va(:,jsea) )
2074 #endif
2075  !
2076  ELSE
2077  j = 1
2078 #ifdef W3_PR1
2079  CALL w3ktp1 ( isea, facth, fack, cthg0s(isea), &
2080  cg(:,isea), wn(:,isea), depth, &
2081  dddx(iy,ixrel), dddy(iy,ixrel), cx(isea), &
2082  cy(isea), dcxdx(iy,ixrel), dcxdy(iy,ixrel), &
2083  dcydx(iy,ixrel), dcydy(iy,ixrel), &
2084  dcdx(:,iy,ixrel), dcdy(:,iy,ixrel), va(:,jsea))
2085 #endif
2086 #ifdef W3_PR2
2087  CALL w3ktp2 ( isea, facth, fack, cthg0s(isea), &
2088  cg(:,isea), wn(:,isea), depth, &
2089  dddx(iy,ixrel), dddy(iy,ixrel), cx(isea), &
2090  cy(isea), dcxdx(iy,ixrel), dcxdy(iy,ixrel), &
2091  dcydx(iy,ixrel), dcydy(iy,ixrel), &
2092  dcdx(:,iy,ixrel), dcdy(:,iy,ixrel), va(:,jsea))
2093 #endif
2094 #ifdef W3_PR3
2095  CALL w3ktp3 ( isea, facth, fack, cthg0s(isea), &
2096  cg(:,isea), wn(:,isea), depth, &
2097  dddx(iy,ixrel), dddy(iy,ixrel), cx(isea), &
2098  cy(isea), dcxdx(iy,ixrel), dcxdy(iy,ixrel), &
2099  dcydx(iy,ixrel), dcydy(iy,ixrel), &
2100  dcdx(:,iy,ixrel), dcdy(:,iy,ixrel), va(:,jsea), &
2101  cflthmax(jsea), cflkmax(jsea) )
2102 #endif
2103  !
2104  END IF !! GTYPE
2105  !
2106  END IF
2107  END DO
2108  !
2109 #ifdef W3_OMPG
2110  !$OMP END DO
2111  !$OMP END PARALLEL
2112 #endif
2113  !
2114  END DO
2115  END IF
2116 #ifdef W3_DEBUGCOH
2117  CALL all_va_integral_print(imod, "After intraspectral adv.", 1)
2118 #endif
2119 #ifdef W3_TIMINGS
2120  CALL print_my_time("fter intraspectral adv.")
2121 #endif
2122 
2123  !
2124  ugdtupdate = .false.
2125  !
2126  ! 3.6 End propapgation = = = = = = = = = = = = = = = = = = = = = = = =
2127 
2128  ! 3.7 Calculate and integrate source terms.
2129  !
2130 370 CONTINUE
2131  IF ( flsou ) THEN
2132  !
2133  d50=0.0002
2134  reflec(:)=0.
2135  refled(:)=0
2136  psic=0.
2137 #ifdef W3_PDLIB
2138 #ifdef W3_DEBUGSRC
2139  WRITE(740+iaproc,*) 'ITIME=', itime, ' IT=', it
2140  CALL all_vaold_integral_print("VAOLD before W3SRCE_IMP_POST", 1)
2141  CALL all_va_integral_print(imod, "VA before W3SRCE_IMP_POST", 1)
2142  IF (debug_node .le. nseal) THEN
2143  WRITE(740+iaproc,*) ' Values for DEBUG_NODE=', debug_node
2144  WRITE(740+iaproc,*) ' sum(VA)=', sum(va(:,debug_node))
2145  WRITE(740+iaproc,*) ' sum(VAOLD)=', sum(vaold(:,debug_node))
2146  WRITE(740+iaproc,*) ' sum(VSTOT)=', sum(vstot(:,debug_node))
2147  WRITE(740+iaproc,*) ' sum(VDTOT)=', sum(vdtot(:,debug_node))
2148  END IF
2149 #endif
2150 #endif
2151  !
2152 #ifdef W3_OMPG
2153  !$OMP PARALLEL PRIVATE (JSEA,ISEA,IX,IY,DELA,DELX,DELY, &
2154  !$OMP& REFLEC,REFLED,D50,PSIC,TMP1,TMP2,TMP3,TMP4)
2155  !$OMP DO SCHEDULE (DYNAMIC,1)
2156 #endif
2157 
2158  !
2159  DO jsea=1, nseal
2160  CALL init_get_isea(isea, jsea)
2161  ix = mapsf(isea,1)
2162  iy = mapsf(isea,2)
2163  dela=1.
2164  delx=1.
2165  dely=1.
2166 #ifdef W3_REF1
2167  IF (gtype.EQ.rlgtype) THEN
2168  delx=sx*clats(isea)/facx
2169  dely=sy/facx
2170  dela=delx*dely
2171  END IF
2172  IF (gtype.EQ.clgtype) THEN
2173  ! Maybe what follows works also for RLGTYPE ... to be verified
2174  delx=hpfac(iy,ix)/ facx
2175  dely=hqfac(iy,ix)/ facx
2176  dela=delx*dely
2177  END IF
2178 #endif
2179  !
2180 #ifdef W3_REF1
2181  reflec=reflc(:,isea)
2182  reflec(4)=berg(isea)*reflec(4)
2183  refled=refld(:,isea)
2184 #endif
2185 #ifdef W3_BT4
2186  d50=sed_d50(isea)
2187  psic=sed_psic(isea)
2188 #endif
2189 
2190 
2191  IF ( mapsta(iy,ix) .EQ. 1 .AND. flagst(isea)) THEN
2192  tmp1 = whitecap(jsea,1:4)
2193  tmp2 = bedforms(jsea,1:3)
2194  tmp3 = taubbl(jsea,1:2)
2195  tmp4 = tauice(jsea,1:2)
2196 #ifdef W3_PDLIB
2197  IF (fssource) THEN
2198  CALL w3srce(srce_imp_post,it,isea,jsea,ix,iy,imod, &
2199  vaold(:,jsea), va(:,jsea), &
2200  vsiodummy,vdiodummy,shavetot(jsea), &
2201  alpha(1:nk,jsea), wn(1:nk,isea), &
2202  cg(1:nk,isea), clats(isea), dw(isea), u10(isea), &
2203  u10d(isea), &
2204 #ifdef W3_FLX5
2205  taua(isea), tauadir(isea), &
2206 #endif
2207  as(isea), ust(isea), &
2208  ustdir(isea), cx(isea), cy(isea), &
2209  ice(isea), iceh(isea), icef(isea), &
2210  icedmax(isea), &
2211  reflec, refled, delx, dely, dela, &
2212  trnx(iy,ix), trny(iy,ix), berg(isea), &
2213  fpis(isea), dtdyn(jsea), &
2214  fcut(jsea), dtg, tauwx(jsea), tauwy(jsea), &
2215  tauox(jsea), tauoy(jsea), tauwix(jsea), &
2216  tauwiy(jsea), tauwnx(jsea), &
2217  tauwny(jsea), phiaw(jsea), charn(jsea), &
2218  tws(jsea),phioc(jsea), tmp1, d50, psic, tmp2, &
2219  phibbl(jsea), tmp3, tmp4, phice(jsea), &
2220  tauocx(jsea), tauocy(jsea), wnmean(jsea), &
2221  rhoair(isea), asf(isea))
2222  ELSE
2223 #endif
2224  CALL w3srce(srce_direct, it, isea, jsea, ix, iy, imod, &
2225  vaolddummy, va(:,jsea), &
2226  vsiodummy, vdiodummy, shavetotiodummy, &
2227  alpha(1:nk,jsea), wn(1:nk,isea), &
2228  cg(1:nk,isea), clats(isea), dw(isea), u10(isea), &
2229  u10d(isea), &
2230 #ifdef W3_FLX5
2231  taua(isea), tauadir(isea), &
2232 #endif
2233  as(isea), ust(isea), &
2234  ustdir(isea), cx(isea), cy(isea), &
2235  ice(isea), iceh(isea), icef(isea), &
2236  icedmax(isea), &
2237  reflec, refled, delx, dely, dela, &
2238  trnx(iy,ix), trny(iy,ix), berg(isea), &
2239  fpis(isea), dtdyn(jsea), &
2240  fcut(jsea), dtg, tauwx(jsea), tauwy(jsea), &
2241  tauox(jsea), tauoy(jsea), tauwix(jsea), &
2242  tauwiy(jsea), tauwnx(jsea), &
2243  tauwny(jsea), phiaw(jsea), charn(jsea), &
2244  tws(jsea), phioc(jsea), tmp1, d50, psic,tmp2, &
2245  phibbl(jsea), tmp3, tmp4 , phice(jsea), &
2246  tauocx(jsea), tauocy(jsea), wnmean(jsea), &
2247  rhoair(isea), asf(isea))
2248 #ifdef W3_PDLIB
2249  END IF
2250 #endif
2251  whitecap(jsea,1:4) = tmp1
2252  bedforms(jsea,1:3) = tmp2
2253  taubbl(jsea,1:2) = tmp3
2254  tauice(jsea,1:2) = tmp4
2255  ELSE
2256  ust(isea) = undef
2257  ustdir(isea) = undef
2258  dtdyn(jsea) = undef
2259  fcut(jsea) = undef
2260  ! VA(:,JSEA) = 0.
2261  END IF
2262  END DO
2263 
2264  !
2265 #ifdef W3_OMPG
2266  !$OMP END DO
2267  !$OMP END PARALLEL
2268 #endif
2269  !
2270 #ifdef W3_PDLIB
2271 #ifdef W3_DEBUGSRC
2272  WRITE(740+iaproc,*) 'ITIME=', itime, ' IT=', it
2273  CALL all_vaold_integral_print("VAOLD after W3SRCE_IMP_PRE_POST", 1)
2274  CALL all_va_integral_print(imod, "VA after W3SRCE_IMP_PRE_POST", 1)
2275  IF (debug_node .le. nseal) THEN
2276  WRITE(740+iaproc,*) ' Values for DEBUG_NODE=', debug_node
2277  WRITE(740+iaproc,*) ' sum(VA)=', sum(va(:,debug_node))
2278  WRITE(740+iaproc,*) ' min/max(VA)=', minval(va(:,debug_node)), maxval(va(:,debug_node))
2279  END IF
2280 #endif
2281 #endif
2282  END IF
2283 #ifdef W3_DEBUGCOH
2284  CALL all_va_integral_print(imod, "After source terms", 1)
2285 #endif
2286 #ifdef W3_TIMINGS
2287  CALL print_my_time("After source terms")
2288 #endif
2289  !
2290  ! End of interations for DTMAX < 1s
2291  !
2292 #ifdef W3_SEC1
2293  IF (it.EQ.0) EXIT
2294  END DO
2295  IF (it.GT.0) dtg=dtgtemp
2296 #endif
2297 
2298 
2299 
2300 
2301  !
2302  !
2303  ! 3.8 Update global time step.
2304  ! (Branch point FLDRY, IT=0)
2305  !
2306 380 CONTINUE
2307  !
2308  IF (it.NE.nt) THEN
2309  dttst = dsec21( time , tcalc )
2310  dtg = dttst / real(nt-it)
2311  END IF
2312  !
2313  IF ( flact .AND. it.NE.nt .AND. iaproc.EQ.naplog ) THEN
2314  CALL stme21 ( time , idtime )
2315  IF ( idlast .NE. time(1) ) THEN
2316  WRITE (ndso,900) itime, ipass, idtime(01:19), idact, outid
2317  idlast = time(1)
2318  ELSE
2319  WRITE (ndso,901) itime, ipass, idtime(12:19), idact, outid
2320  END IF
2321  flact = .false.
2322  idact = ' '
2323  END IF
2324  !
2325 #ifdef W3_DEBUGCOH
2326  CALL all_va_integral_print(imod, "end of time loop", 1)
2327 #endif
2328 #ifdef W3_TIMINGS
2329  CALL print_my_time("end of time loop")
2330 #endif
2331  !
2332  !
2333  END DO
2334 
2335 #ifdef W3_TIMINGS
2336  CALL print_my_time("W3WAVE, step 6.21.1")
2337 #endif
2338  !
2339 #ifdef W3_T
2340  WRITE (ndst,9030)
2341 #endif
2342  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE END TIME LOOP')
2343  !
2344  ! End of loop over time steps
2345  ! ==================================================================== /
2346  !
2347 400 CONTINUE
2348  !
2349  ! 4. Perform output to file if requested ---------------------------- /
2350  ! 4.a Check if time is output time
2351  ! Delay if data assimilation time.
2352  !
2353  !
2354  IF ( tofrst(1) .EQ. -1 ) THEN
2355  dttst = 1.
2356  ELSE
2357  dttst = dsec21( time, tofrst )
2358  END IF
2359  !
2360  IF ( tdn(1) .EQ. -1 ) THEN
2361  dttst1 = 1.
2362  ELSE
2363  dttst1 = dsec21( time, tdn )
2364  END IF
2365  !
2366  dttst2 = dsec21( time, tend )
2367  flag_o = .NOT.skip_o .OR. ( skip_o .AND. dttst2.NE.0. )
2368  !
2369 #ifdef W3_T
2370  WRITE (ndst,9040) tofrst, tdn, dttst, dttst1, flag_o
2371 #endif
2372  !
2373  IF ( dttst.LE.0. .AND. dttst1.NE.0. .AND. flag_o ) THEN
2374  !
2375 #ifdef W3_T
2376  WRITE (ndst,9041)
2377 #endif
2378  !
2379  ! 4.b Processing and MPP preparations
2380  !
2381  IF ( flout(1) ) THEN
2382  floutg = dsec21(time,tonext(:,1)).EQ.0.
2383  ELSE
2384  floutg = .false.
2385  END IF
2386  !
2387  IF ( flout(7) ) THEN
2388  floutg2 = dsec21(time,tonext(:,7)).EQ.0.
2389  ELSE
2390  floutg2 = .false.
2391  END IF
2392  !
2393  flpart = .false.
2394  IF ( flout(1) .AND. flpfld ) flpart = flpart .OR. dsec21(time,tonext(:,1)).EQ.0.
2395  IF ( flout(6) ) flpart = flpart .OR. dsec21(time,tonext(:,6)).EQ.0.
2396  !
2397 #ifdef W3_T
2398  WRITE (ndst,9042) local, flpart, floutg
2399 #endif
2400  !
2401  IF ( local .AND. flpart ) CALL w3cprt ( imod )
2402  IF ( local .AND. (floutg .OR. floutg2) ) then
2403  CALL w3outg ( va, flpfld, floutg, floutg2 )
2404  end if
2405  !
2406 #ifdef W3_MPI
2407  flgmpi = .false.
2408  nrqmax = 0
2409 #endif
2410  !
2411 #ifdef W3_MPI
2412  IF ( (floutg) .OR. (floutg2 .AND. sbsed) ) THEN
2413  IF (.NOT. lpdlib) THEN
2414  IF (nrqgo.NE.0 ) THEN
2415 #endif
2416 #ifdef W3_MPI
2417  CALL mpi_startall ( nrqgo, irqgo , ierr_mpi )
2418 #endif
2419 
2420 #ifdef W3_MPI
2421  flgmpi(0) = .true.
2422  nrqmax = max( nrqmax , nrqgo )
2423 #endif
2424 #ifdef W3_MPIT
2425  WRITE (ndst,9043) '1a', nrqgo, nrqmax, napfld
2426 #endif
2427 #ifdef W3_MPI
2428  END IF
2429 #endif
2430  !
2431 #ifdef W3_MPI
2432  IF (nrqgo2.NE.0 ) THEN
2433 #endif
2434 #ifdef W3_MPI
2435  CALL mpi_startall ( nrqgo2, irqgo2, ierr_mpi )
2436 #endif
2437 #ifdef W3_MPI
2438  flgmpi(1) = .true.
2439  nrqmax = max( nrqmax , nrqgo2 )
2440 #endif
2441 #ifdef W3_MPIT
2442  WRITE (ndst,9043) '1b', nrqgo2, nrqmax, napfld
2443 #endif
2444 #ifdef W3_MPI
2445  END IF
2446  ELSE
2447 #endif
2448 #ifdef W3_PDLIB
2449  CALL do_output_exchanges(imod)
2450 #endif
2451 #ifdef W3_MPI
2452  END IF ! IF (.NOT. LPDLIB) THEN
2453  END IF
2454 #endif
2455  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE AFTER TIME LOOP 1')
2456  !
2457 #ifdef W3_MPI
2458  IF ( flout(2) .AND. nrqpo.NE.0 ) THEN
2459  IF ( dsec21(time,tonext(:,2)).EQ.0. ) THEN
2460  CALL mpi_startall ( nrqpo, irqpo1, ierr_mpi )
2461  flgmpi(2) = .true.
2462  nrqmax = max( nrqmax , nrqpo )
2463 #endif
2464 #ifdef W3_MPIT
2465  WRITE (ndst,9043) '2 ', nrqpo, nrqmax, nappnt
2466 #endif
2467 #ifdef W3_MPI
2468  END IF
2469  END IF
2470 #endif
2471  !
2472 #ifdef W3_MPI
2473  IF ( flout(4) .AND. nrqrs.NE.0 ) THEN
2474  IF ( dsec21(time,tonext(:,4)).EQ.0. ) THEN
2475  CALL mpi_startall ( nrqrs, irqrs , ierr_mpi )
2476  flgmpi(4) = .true.
2477  nrqmax = max( nrqmax , nrqrs )
2478 #endif
2479 #ifdef W3_MPIT
2480  WRITE (ndst,9043) '4 ', nrqrs, nrqmax, naprst
2481 #endif
2482 #ifdef W3_MPI
2483  END IF
2484  END IF
2485 #endif
2486  !
2487 #ifdef W3_MPI
2488  IF ( flout(8) .AND. nrqrs.NE.0 ) THEN
2489  IF ( dsec21(time,tonext(:,8)).EQ.0. ) THEN
2490  CALL mpi_startall ( nrqrs, irqrs , ierr_mpi )
2491  flgmpi(8) = .true.
2492  nrqmax = max( nrqmax , nrqrs )
2493 #endif
2494 #ifdef W3_MPIT
2495  WRITE (ndst,9043) '8 ', nrqrs, nrqmax, naprst
2496 #endif
2497 #ifdef W3_MPI
2498  END IF
2499  END IF
2500 #endif
2501  !
2502 #ifdef W3_MPI
2503  IF ( flout(5) .AND. nrqbp.NE.0 ) THEN
2504  IF ( dsec21(time,tonext(:,5)).EQ.0. ) THEN
2505  CALL mpi_startall ( nrqbp , irqbp1, ierr_mpi )
2506  flgmpi(5) = .true.
2507  nrqmax = max( nrqmax , nrqbp )
2508 #endif
2509 #ifdef W3_MPIT
2510  WRITE (ndst,9043) '5a', nrqbp, nrqmax, napbpt
2511 #endif
2512 #ifdef W3_MPI
2513  END IF
2514  END IF
2515 #endif
2516  !
2517 #ifdef W3_MPI
2518  IF ( flout(5) .AND. nrqbp2.NE.0 .AND. iaproc.EQ.napbpt) THEN
2519  IF ( dsec21(time,tonext(:,5)).EQ.0. ) THEN
2520  CALL mpi_startall (nrqbp2,irqbp2,ierr_mpi)
2521  nrqmax = max( nrqmax , nrqbp2 )
2522 #endif
2523 #ifdef W3_MPIT
2524  WRITE (ndst,9043) '5b', nrqbp2, nrqmax, napbpt
2525 #endif
2526 #ifdef W3_MPI
2527  END IF
2528  END IF
2529 #endif
2530  !
2531 #ifdef W3_MPI
2532  IF ( nrqmax .NE. 0 ) ALLOCATE ( statio(mpi_status_size,nrqmax) )
2533 #endif
2534  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE AFTER TIME LOOP 2')
2535  !
2536  ! 4.c Reset next output time
2537 
2538  !
2539  tofrst(1) = -1
2540  tofrst(2) = 0
2541  !
2542  DO j=1, notype
2543 
2544  IF ( flout(j) ) THEN
2545  !
2546  ! 4.d Perform output
2547  !
2548 #ifdef W3_NL5
2549  IF (j .EQ. 2) tosnl5 = tonext(:, 2)
2550 #endif
2551  tout(:) = tonext(:,j)
2552  dttst = dsec21( time, tout )
2553  !
2554  IF ( dttst .EQ. 0. ) THEN
2555  IF ( ( j .EQ. 1 ) &
2556 #ifdef W3_SBS
2557  .OR. ( j .EQ. 7 ) &
2558 #endif
2559  ) THEN
2560  IF ( iaproc .EQ. napfld ) THEN
2561 #ifdef W3_MPI
2562  IF ( flgmpi(1) ) CALL mpi_waitall ( nrqgo2, irqgo2, statio, ierr_mpi )
2563  flgmpi(1) = .false.
2564 #endif
2565  !
2566 #ifdef W3_SBS
2567  IF ( j .EQ. 1 ) THEN
2568 #endif
2569  CALL w3iogo( 'WRITE', nds(7), itest, imod &
2570 #ifdef W3_ASCII
2571  ,nds(14) &
2572 #endif
2573  )
2574 #ifdef W3_SBS
2575  ENDIF
2576 #endif
2577  !
2578 #ifdef W3_SBS
2579  !
2580  ! Generate output flag file for fields and SBS coupling.
2581  !
2582  jj = len_trim( filext )
2583  CALL stme21 ( time, idtime )
2584  foutname = 'Field_done.' // idtime(1:4) &
2585  // idtime(6:7) // idtime(9:10) &
2586  // idtime(12:13) // '.' // filext(1:jj)
2587 #endif
2588  !
2589 #ifdef W3_SBS
2590  OPEN( unit=ndsoflg, file=foutname)
2591  CLOSE( ndsoflg )
2592 #endif
2593  END IF
2594  !
2595  ELSE IF ( j .EQ. 2 ) THEN
2596  !
2597  ! Point output
2598  !
2599  IF ( iaproc .EQ. nappnt ) THEN
2600  !
2601  ! Gets the necessary spectral data
2602  !
2603  CALL w3iope ( va )
2604 #ifdef W3_BIN2NC
2605  CALL w3iopon ( 'WRITE', nds(8), itest, imod )
2606 #else
2607  CALL w3iopo ( 'WRITE', nds(8), itest, imod &
2608 #ifdef W3_ASCII
2609  ,nds(15) &
2610 #endif
2611  )
2612 #endif
2613  END IF
2614  !
2615  ELSE IF ( j .EQ. 3 ) THEN
2616  !
2617  ! Track output
2618  !
2619  CALL w3iotr ( nds(11), nds(12), va, imod )
2620  ELSE IF ( j .EQ. 4 ) THEN
2621  CALL w3iors ('HOT', nds(6), xxx, imod, flout(8) )
2622  itest = rstype
2623  ELSE IF ( j .EQ. 5 ) THEN
2624  IF ( iaproc .EQ. napbpt ) THEN
2625 #ifdef W3_MPI
2626  IF (nrqbp2.NE.0) CALL mpi_waitall ( nrqbp2, irqbp2,statio, ierr_mpi )
2627 #endif
2628  CALL w3iobc ( 'WRITE', nds(10), &
2629  time, time, itest, imod )
2630  END IF
2631  ELSE IF ( j .EQ. 6 ) THEN
2632  CALL w3iosf ( nds(13), imod )
2633 #ifdef W3_OASIS
2634  ELSE IF ( j .EQ. 7 ) THEN
2635  !
2636  ! Send variables to atmospheric or ocean circulation or ice model
2637  !
2638  IF (dtout(7).NE.0) THEN
2639  IF ( (mod(id_oasis_time,nint(dtout(7))) .EQ. 0 ) .AND. &
2640  (dsec21(time00, time) .GT. 0.0) ) THEN
2641  IF ( (cplt0 .AND. (dsec21(time, timen) .GT. 0.0)) .OR. &
2642  .NOT. cplt0 ) THEN
2643  IF (cplt0) id_oasis_time = nint(dsec21( time00 , time ))
2644 
2645 #endif
2646 #ifdef W3_OASACM
2647  CALL snd_fields_to_atmos()
2648 #endif
2649 #ifdef W3_OASOCM
2650  CALL snd_fields_to_ocean()
2651 #endif
2652 #ifdef W3_OASICM
2653  CALL snd_fields_to_ice()
2654 #endif
2655 #ifdef W3_OASIS
2656  IF (.NOT. cplt0) id_oasis_time = nint(dsec21( time00 , time ))
2657  ENDIF
2658  ENDIF
2659  ENDIF
2660 #endif
2661  END IF
2662  !
2663  CALL tick21 ( tout, dtout(j) )
2664  tonext(:,j) = tout
2665  tlst = tolast(:,j)
2666  dttst = dsec21( tout , tlst )
2667  flout(j) = dttst.GE.0.
2668  IF ( flout(j) ) THEN
2669  outid(2*j-1:2*j-1) = 'X'
2670 #ifdef W3_OASIS
2671  IF ( (dtout(7).NE.0) .AND. &
2672  (dsec21(time,time00).EQ.0 .OR. &
2673  dsec21(time,timeend).EQ.0) ) outid(13:13) = ' '
2674 #endif
2675  ELSE
2676  outid(2*j-1:2*j-1) = 'L'
2677  END IF
2678  END IF
2679  !
2680  ! 4.e Update next output time
2681  !
2682  IF ( flout(j) ) THEN
2683  IF ( tofrst(1).EQ.-1 ) THEN
2684  tofrst = tout
2685  ELSE
2686  dttst = dsec21( tout , tofrst )
2687  IF ( dttst.GT.0.) THEN
2688  tofrst = tout
2689  END IF
2690  END IF
2691  END IF
2692  !
2693  END IF
2694  !
2695  END DO
2696  !
2697  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE AFTER TIME LOOP 3')
2698 
2699  ! If there is a second stream of restart files then J=8 and FLOUT(8)=.TRUE.
2700  j=8
2701  IF ( flout(j) ) THEN
2702  !
2703  ! 4.d Perform output
2704  !
2705  tout(:) = tonext(:,j)
2706  dttst = dsec21( time, tout )
2707  IF ( dttst .EQ. 0. ) THEN
2708  CALL w3iors ('HOT', nds(6), xxx, imod, flout(8) )
2709  itest = rstype
2710  CALL tick21 ( tout, dtout(j) )
2711  tonext(:,j) = tout
2712  tlst = tolast(:,j)
2713  dttst = dsec21( tout , tlst )
2714  flout(j) = dttst.GE.0.
2715  IF ( flout(j) ) THEN
2716  outid(2*j-1:2*j-1) = 'X'
2717 #ifdef W3_OASIS
2718  IF ( (dtout(7).NE.0) .AND. &
2719  (dsec21(time,time00).EQ.0 .OR. &
2720  dsec21(time,timeend).EQ.0) ) outid(13:13) = ' '
2721 #endif
2722  ELSE
2723  outid(2*j-1:2*j-1) = 'L'
2724  END IF
2725  END IF
2726  !
2727  ! 4.e Update next output time
2728  !
2729  IF ( flout(j) ) THEN
2730  IF ( tofrst(1).EQ.-1 ) THEN
2731  tofrst = tout
2732  ELSE
2733  dttst = dsec21( tout , tofrst )
2734  IF ( dttst.GT.0.) THEN
2735  tofrst = tout
2736  END IF
2737  END IF
2738  END IF
2739  END IF
2740  ! END OF CHECKPOINT
2741  !
2742  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE AFTER TIME LOOP 3')
2743  !
2744 #ifdef W3_MPI
2745  IF ( flgmpi(0) ) CALL mpi_waitall ( nrqgo, irqgo , statio, ierr_mpi )
2746  IF ( flgmpi(2) ) CALL mpi_waitall ( nrqpo, irqpo1, statio, ierr_mpi )
2747  IF ( flgmpi(4) ) CALL mpi_waitall ( nrqrs, irqrs , statio, ierr_mpi )
2748  IF ( flgmpi(8) ) CALL mpi_waitall ( nrqrs, irqrs , statio, ierr_mpi )
2749  IF ( flgmpi(5) ) CALL mpi_waitall ( nrqbp, irqbp1, statio, ierr_mpi )
2750  IF ( nrqmax .NE. 0 ) DEALLOCATE ( statio )
2751 #endif
2752  !
2753 #ifdef W3_T
2754  WRITE (ndst,9044)
2755 #endif
2756  END IF
2757 #ifdef W3_TIMINGS
2758  CALL print_my_time("Before update log file")
2759 #endif
2760  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE AFTER TIME LOOP 4')
2761  !
2762  ! 5. Update log file ------------------------------------------------ /
2763  !
2764  IF ( iaproc.EQ.naplog ) THEN
2765  !
2766  CALL stme21 ( time , idtime )
2767  IF ( flcur ) THEN
2768  dttst = dsec21( time , tcn )
2769  IF ( dttst .EQ. 0. ) idact(7:7) = 'X'
2770  END IF
2771  IF ( flwind ) THEN
2772  dttst = dsec21( time , twn )
2773  IF ( dttst .EQ. 0. ) idact(3:3) = 'X'
2774  END IF
2775  IF ( fltaua ) THEN
2776  dttst = dsec21( time , tun )
2777  IF ( dttst .EQ. 0. ) idact(9:9) = 'X'
2778  END IF
2779  IF ( flrhoa ) THEN
2780  dttst = dsec21( time , trn )
2781  IF ( dttst .EQ. 0. ) idact(11:11) = 'X'
2782  END IF
2783  IF ( tdn(1) .GT. 0 ) THEN
2784  dttst = dsec21( time , tdn )
2785  IF ( dttst .EQ. 0. ) idact(21:21) = 'X'
2786  END IF
2787  !
2788  IF ( idlast.NE.time(1) ) THEN
2789  WRITE (ndso,900) itime, ipass, idtime(1:19), idact, outid
2790  idlast = time(1)
2791  ELSE
2792  WRITE (ndso,901) itime, ipass, idtime(12:19), idact, outid
2793  END IF
2794  !
2795  END IF
2796  !
2797  idact = ' '
2798  outid = ' '
2799  flact = .false.
2800  !
2801  ! 6. If time is not ending time, branch back to 2 ------------------- /
2802  !
2803  dttst = dsec21( time, tend )
2804  IF ( dttst .EQ. 0. ) EXIT
2805 #ifdef W3_TIMINGS
2806  CALL print_my_time("Continuing the loop")
2807 #endif
2808  END DO
2809  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE AFTER TIME LOOP 5')
2810  !
2811 
2812  IF ( tstamp .AND. screen.NE.ndso .AND. iaproc.EQ.napout ) THEN
2813  CALL wwtime ( sttime )
2814  WRITE (screen,951) sttime
2815  END IF
2816 
2817  IF ( iaproc .EQ. naplog ) WRITE (ndso,902)
2818  !
2819  DEALLOCATE(field)
2820  DEALLOCATE(tauwx, tauwy)
2821  !
2822  call print_memcheck(memunit, 'memcheck_____:'//' WW3_WAVE END W3WAVE')
2823  !
2824  RETURN
2825  !
2826  ! Formats
2827  !
2828 900 FORMAT (4x,i6,'|',i6,'| ', a19 ,' | ',a,' | ',a,' |')
2829 901 FORMAT (4x,i6,'|',i6,'| ',11x,a8,' | ',a,' | ',a,' |')
2830 902 FORMAT (2x,'--------+------+---------------------+' &
2831  ,'-----------------------+------------------+')
2832  !
2833 #ifdef W3_IC3
2834 920 FORMAT (' Updating k and Cg from ice param. 1,2,3,4.'/)
2835 #endif
2836 950 FORMAT (' WAVEWATCH III calculating for ',a,' at ',a)
2837 951 FORMAT (' WAVEWATCH III reached the end of a computation', &
2838  ' loop at ',a)
2839 1000 FORMAT (/' *** WAVEWATCH III ERROR IN W3WAVE :'/ &
2840  ' ENDING TIME BEFORE STARTING TIME '/)
2841 1001 FORMAT (/' *** WAVEWATCH III ERROR IN W3WAVE :'/ &
2842  ' NEW WATER LEVEL BEFORE OLD WATER LEVEL '/)
2843 1002 FORMAT (/' *** WAVEWATCH III ERROR IN W3WAVE :'/ &
2844  ' ILLEGAL CURRENT INTERVAL '/)
2845 1003 FORMAT (/' *** WAVEWATCH III ERROR IN W3WAVE :'/ &
2846  ' ILLEGAL WIND INTERVAL '/)
2847 1004 FORMAT (/' *** WAVEWATCH III ERROR IN W3WAVE :'/ &
2848  ' NEW ICE FIELD BEFORE OLD ICE FIELD '/)
2849 1005 FORMAT (/' *** WAVEWATCH III ERROR IN W3WAVE :'/ &
2850  ' NEW IC1 FIELD BEFORE OLD IC1 FIELD '/)
2851 1007 FORMAT (/' *** WAVEWATCH III ERROR IN W3WAVE :'/ &
2852  ' NEW ATM MOMENTUM BEFORE OLD ATM MOMENTUM '/)
2853 1008 FORMAT (/' *** WAVEWATCH III ERROR IN W3WAVE :'/ &
2854  ' NEW AIR DENSITY BEFORE OLD AIR DENSITY '/)
2855 #ifdef W3_IS2
2856 1006 FORMAT (/' *** WAVEWATCH III ERROR IN W3WAVE :'/ &
2857  ' NEW IC5 FIELD BEFORE OLD IC5 FIELD '/)
2858 #endif
2859 1030 FORMAT (/' *** WAVEWATCH III WARING IN W3WAVE :'/ &
2860  ' AT LEAST ONE PROCESSOR HAS 0 ACTIVE POINTS', &
2861  ' IN GRID',i3)
2862 #ifdef W3_REFRX
2863 1040 FORMAT (/' *** WAVEWATCH III ERROR IN W3WAVE :'/ &
2864  ' EXPERIMENTAL FEATURE !/REFRX NOT FULLY IMPLEMENTED.'/)
2865 #endif
2866  !
2867 #ifdef W3_T
2868 9000 FORMAT ( &
2869  '============================================================', &
2870  '===================='/ &
2871  ' TEST W3WAVE : RUN MODEL',i3,' FILEXT [',a, &
2872  '] UP TO ',i8.8,i7.6 / &
2873  '====================', &
2874  '============================================================')
2875 9010 FORMAT (' TEST W3WAVE : DT INT. =',f12.1,' FLZERO = ',l1)
2876 9011 FORMAT (' TEST W3WAVE : DT LEV. =',f12.1)
2877 9012 FORMAT (' TEST W3WAVE : DT CUR. =',f12.1/ &
2878  ' ',f12.1/ &
2879  ' ',f12.1)
2880 9013 FORMAT (' TEST W3WAVE : DT WIND =',f12.1/ &
2881  ' ',f12.1/ &
2882  ' ',f12.1)
2883 9014 FORMAT (' TEST W3WAVE : DT ICE =',f12.1)
2884 9015 FORMAT (' TEST W3WAVE : DT IC1 =',f12.1)
2885 9016 FORMAT (' TEST W3WAVE : DT IC5 =',f12.1)
2886 9017 FORMAT (' TEST W3WAVE : DT TAU =',f12.1)
2887 9018 FORMAT (' TEST W3WAVE : DT RHO =',f12.1)
2888 9020 FORMAT (' TEST W3WAVE : IT0, NT, DTG :',2i4,f8.1)
2889 9021 FORMAT (' TEST W3WAVE : ITIME etc',i6,i4,i10.8,i7.6,1x,2l1, &
2890  2f6.2,f7.1,f6.2)
2891 9022 FORMAT (' TEST W3WAVE : SKIP TO 400 IN 3.5')
2892 9023 FORMAT (' TEST W3WAVE : SKIP TO 380 IN 3.5')
2893 9030 FORMAT (' TEST W3WAVE : END OF COMPUTATION LOOP')
2894 9040 FORMAT (' TEST W3WAVE : CHECKING FOR OUTPUT'/ &
2895  ' TOFRST :',i9.8,i7.6/ &
2896  ' TND :',i9.8,i7.6/ &
2897  ' DTTST[1], FLAG_O :',2f8.1,l4)
2898 9041 FORMAT (' TEST W3WAVE : PERFORMING OUTPUT')
2899 9042 FORMAT (' TEST W3WAVE : OUTPUT COMPUTATION FLAGS: ',3l2)
2900 #endif
2901 #ifdef W3_MPIT
2902 9043 FORMAT (' TEST W3WAVE : TYPE, NRQ, NRQMAX, NA : ',a2,3i6)
2903 #endif
2904 #ifdef W3_T
2905 9044 FORMAT (' TEST W3WAVE : END OF OUTPUT')
2906 #endif
2907  !/
2908  !/ End of W3WAVE ----------------------------------------------------- /
2909  !/
2910  END SUBROUTINE w3wave
2911  !/ ------------------------------------------------------------------- /
2937  SUBROUTINE w3gath ( ISPEC, FIELD )
2938  !/
2939  !/ +-----------------------------------+
2940  !/ | WAVEWATCH III NOAA/NCEP |
2941  !/ | H. L. Tolman |
2942  !/ | FORTRAN 90 |
2943  !/ | Last update : 26-Dec-2012 |
2944  !/ +-----------------------------------+
2945  !/
2946  !/ 04-Jan-1999 : Distributed FORTRAN 77 version. ( version 1.18 )
2947  !/ 13-Jan-2000 : Upgrade to FORTRAN 90 ( version 2.00 )
2948  !/ Major changes to logistics.
2949  !/ 29-Dec-2004 : Multiple grid version. ( version 3.06 )
2950  !/ 13-Jun-2006 : Split STORE in G/SSTORE ( version 3.09 )
2951  !/ 26-Dec-2012 : Move FIELD init. to W3GATH. ( version 4.OF )
2952  !/
2953  ! 1. Purpose :
2954  !
2955  ! Gather spectral bin information into a propagation field array.
2956  !
2957  ! 2. Method :
2958  !
2959  ! Direct copy or communication calls (MPP version).
2960  !
2961  ! 3. Parameters :
2962  !
2963  ! Parameter list
2964  ! ----------------------------------------------------------------
2965  ! ISPEC Int. I Spectral bin considered.
2966  ! FIELD R.A. O Full field to be propagated.
2967  ! ----------------------------------------------------------------
2968  !
2969  ! 4. Subroutines used :
2970  !
2971  ! Name Type Module Description
2972  ! ----------------------------------------------------------------
2973  ! STRACE Subr. W3SERVMD Subroutine tracing.
2974  !
2975  ! MPI_STARTALL, MPI_WAITALL
2976  ! Subr. mpif.h MPI persistent comm. routines (!/MPI).
2977  ! ----------------------------------------------------------------
2978  !
2979  ! 5. Called by :
2980  !
2981  ! Name Type Module Description
2982  ! ----------------------------------------------------------------
2983  ! W3WAVE Subr. W3WAVEMD Actual wave model routine.
2984  ! ----------------------------------------------------------------
2985  !
2986  ! 6. Error messages :
2987  !
2988  ! None.
2989  !
2990  ! 7. Remarks :
2991  !
2992  ! - The field is extracted but not converted.
2993  ! - MPI version requires posing of send and receive calls in
2994  ! W3WAVE to match local calls.
2995  ! - MPI version does not require an MPI_TESTALL call for the
2996  ! posted gather operation as MPI_WAITALL is mandatory to
2997  ! reset persistent communication for next time step.
2998  ! - MPI version allows only two new pre-fetch postings per
2999  ! call to minimize chances to be slowed down by gathers that
3000  ! are not yet needed, while maximizing the pre-loading
3001  ! during the early (low-frequency) calls to the routine
3002  ! where the amount of calculation needed for proagation is
3003  ! the largest.
3004  !
3005  ! 8. Structure :
3006  !
3007  ! See source code.
3008  !
3009  ! 9. Switches :
3010  !
3011  ! !/SHRD Switch for message passing method.
3012  ! !/MPI Id.
3013  !
3014  ! !/S Enable subroutine tracing.
3015  ! !/MPIT MPI test output.
3016  !
3017  ! 10. Source code :
3018  !
3019  !/ ------------------------------------------------------------------- /
3020 #ifdef W3_S
3021  USE w3servmd, ONLY: strace
3022 #endif
3023  !/
3024  USE w3gdatmd, ONLY: nspec, nx, ny, nsea, nseal, mapsf, dmin
3025  USE w3parall, ONLY: init_get_isea
3026  USE w3wdatmd, ONLY: a => va
3027 #ifdef W3_MPI
3028  USE w3adatmd, ONLY: mpibuf, bstat, ibfloc, isploc, bispl, &
3030  USE w3odatmd, ONLY: ndst, iaproc, naproc, notype
3031 #endif
3032  !/
3033  !
3034 #ifdef W3_MPI
3035  include "mpif.h"
3036 #endif
3037  !/
3038  !/ ------------------------------------------------------------------- /
3039  !/ Parameter list
3040  !/
3041  INTEGER, INTENT(IN) :: ISPEC
3042  REAL, INTENT(OUT) :: FIELD(1-NY:NY*(NX+2))
3043  !/
3044  !/ ------------------------------------------------------------------- /
3045  !/ Local parameters
3046  !/
3047 #ifdef W3_SHRD
3048  INTEGER :: ISEA, IXY
3049 #endif
3050 #ifdef W3_MPI
3051  INTEGER :: STATUS(MPI_STATUS_SIZE,NSPEC), &
3052  IOFF, IERR_MPI, JSEA, ISEA, &
3053  IXY, IS0, IB0, NPST, J
3054 #endif
3055 #ifdef W3_S
3056  INTEGER, SAVE :: IENT
3057 #endif
3058 #ifdef W3_MPIT
3059  CHARACTER(LEN=15) :: STR(MPIBUF), STRT
3060 #endif
3061  !/
3062  !/ ------------------------------------------------------------------- /
3063  !/
3064 #ifdef W3_S
3065  CALL strace (ient, 'W3GATH')
3066 #endif
3067  !
3068  field = 0.
3069  !
3070  ! 1. Shared memory version ------------------------------------------ /
3071  !
3072 #ifdef W3_SHRD
3073  DO isea=1, nsea
3074  ixy = mapsf(isea,3)
3075  field(ixy) = a(ispec,isea)
3076  END DO
3077 #endif
3078  !
3079 #ifdef W3_SHRD
3080  RETURN
3081 #endif
3082  !
3083  ! 2. Distributed memory version ( MPI ) ----------------------------- /
3084  ! 2.a Update counters
3085  !
3086 #ifdef W3_MPI
3087  isploc = isploc + 1
3088  ibfloc = ibfloc + 1
3089  IF ( ibfloc .GT. mpibuf ) ibfloc = 1
3090 #endif
3091  !
3092 #ifdef W3_MPIT
3093  IF ( isploc .EQ. 1 ) THEN
3094  str = '--------------+'
3095  WRITE (ndst,9000) str
3096  END IF
3097  str = ' |'
3098  strt = str(ibfloc)
3099  strt(9:9) = 'A'
3100 #endif
3101  !
3102  ! 2.b Check status of present buffer
3103  ! 2.b.1 Scatter (send) still in progress, wait to end
3104  !
3105 #ifdef W3_MPI
3106  IF ( bstat(ibfloc) .EQ. 2 ) THEN
3107  ioff = 1 + (bispl(ibfloc)-1)*nrqsg2
3108  IF ( nrqsg2 .GT. 0 ) CALL mpi_waitall ( nrqsg2, irqsg2(ioff,2), status, ierr_mpi )
3109  bstat(ibfloc) = 0
3110 #endif
3111 #ifdef W3_MPIT
3112  strt(13:13) = 'S'
3113 #endif
3114 #ifdef W3_MPI
3115  END IF
3116 #endif
3117  !
3118  ! 2.b.2 Gather (recv) not yet posted, post now
3119  !
3120 #ifdef W3_MPI
3121  IF ( bstat(ibfloc) .EQ. 0 ) THEN
3122  bstat(ibfloc) = 1
3123  bispl(ibfloc) = isploc
3124  ioff = 1 + (isploc-1)*nrqsg2
3125  IF ( nrqsg2 .GT. 0 ) CALL mpi_startall ( nrqsg2, irqsg2(ioff,1), ierr_mpi )
3126 #endif
3127 #ifdef W3_MPIT
3128  strt(10:10) = 'g'
3129 #endif
3130 #ifdef W3_MPI
3131  END IF
3132 #endif
3133  !
3134  ! 2.c Put local spectral densities in store
3135  !
3136 #ifdef W3_MPI
3137  DO jsea=1, nseal
3138  CALL init_get_isea(isea, jsea)
3139  gstore(isea,ibfloc) = a(ispec,jsea)
3140  END DO
3141 #endif
3142  !
3143  ! 2.d Wait for remote spectral densities
3144  !
3145 #ifdef W3_MPI
3146  ioff = 1 + (bispl(ibfloc)-1)*nrqsg2
3147  IF ( nrqsg2 .GT. 0 ) CALL mpi_waitall ( nrqsg2, irqsg2(ioff,1), status, ierr_mpi )
3148 #endif
3149  !
3150 #ifdef W3_MPIT
3151  strt(11:11) = 'G'
3152  WRITE (strt(1:7),'(I2,I5)') bstat(ibfloc), isploc
3153  str(ibfloc) = strt
3154 #endif
3155  !
3156  ! 2.e Convert storage array to field.
3157  !
3158 #ifdef W3_MPI
3159  DO isea=1, nsea
3160  ixy = mapsf(isea,3)
3161  field(ixy) = gstore(isea,ibfloc)
3162  END DO
3163 #endif
3164  !
3165  ! 2.f Pre-fetch data in available buffers
3166  !
3167 #ifdef W3_MPI
3168  is0 = isploc
3169  ib0 = ibfloc
3170  npst = 0
3171 #endif
3172  !
3173 #ifdef W3_MPI
3174  DO j=1, mpibuf-1
3175  is0 = is0 + 1
3176  IF ( is0 .GT. nsploc ) EXIT
3177  ib0 = 1 + mod(ib0,mpibuf)
3178  IF ( bstat(ib0) .EQ. 0 ) THEN
3179  bstat(ib0) = 1
3180  bispl(ib0) = is0
3181  ioff = 1 + (is0-1)*nrqsg2
3182  IF ( nrqsg2 .GT. 0 ) CALL mpi_startall ( nrqsg2, irqsg2(ioff,1), ierr_mpi )
3183  npst = npst + 1
3184 #endif
3185 #ifdef W3_MPIT
3186  strt = str(ib0)
3187  strt(10:10) = 'g'
3188  WRITE (strt(1:7),'(I2,I5)') bstat(ib0), bispl(ib0)
3189  str(ib0) = strt
3190 #endif
3191 #ifdef W3_MPI
3192  END IF
3193  IF ( npst .GE. 2 ) EXIT
3194  END DO
3195 #endif
3196  !
3197  ! 2.g Test output
3198  !
3199 #ifdef W3_MPIT
3200  DO ib0=1, mpibuf
3201  strt = str(ib0)
3202  IF ( strt(2:2) .EQ. ' ' ) THEN
3203  IF ( bstat(ib0) .EQ. 0 ) THEN
3204  WRITE (strt(1:2),'(I2)') bstat(ib0)
3205  ELSE
3206  WRITE (strt(1:7),'(I2,I5)') bstat(ib0), bispl(ib0)
3207  END IF
3208  str(ib0) = strt
3209  END IF
3210  END DO
3211  WRITE (ndst,9010) isploc, str
3212 #endif
3213  !
3214 #ifdef W3_MPI
3215  RETURN
3216 #endif
3217  !
3218  ! Formats
3219  !
3220 #ifdef W3_MPIT
3221 9000 FORMAT ( ' TEST OF BUFFER MANAGEMENT MPI :'/ &
3222  ' -------------------------------'/ &
3223  ' RECORDS ALTERNATELY WRITTEN BY W3GATH AND W3SCAT'/ &
3224  ' FRIST COLLUMN : LOCAL ISPEC'/ &
3225  ' OTHER COLLUMNS : BUFFER STATUS INDICATOR '/ &
3226  ' 0 : INACTIVE'/ &
3227  ' 1 : RECEIVING'/ &
3228  ' 2 : SENDING'/ &
3229  ' LOCAL ISPEC FOR BUFFER'/ &
3230  ' A : ACTIVE BUFFER'/ &
3231  ' g/G: START/FINISH RECIEVE'/ &
3232  ' s/S: START/FINISH SEND'/ &
3233  ' +-----+',8a15)
3234 9010 FORMAT ( ' |',i4,' |',8a15)
3235 #endif
3236  !/
3237  !/ End of W3GATH ----------------------------------------------------- /
3238  !/
3239  END SUBROUTINE w3gath
3240  !/ ------------------------------------------------------------------- /
3255  SUBROUTINE w3scat ( ISPEC, MAPSTA, FIELD )
3256  !/
3257  !/ +-----------------------------------+
3258  !/ | WAVEWATCH III NOAA/NCEP |
3259  !/ | H. L. Tolman |
3260  !/ | FORTRAN 90 |
3261  !/ | Last update : 13-Jun-2006 |
3262  !/ +-----------------------------------+
3263  !/
3264  !/ 04-Jan-1999 : Distributed FORTRAN 77 version. ( version 1.18 )
3265  !/ 13-Jan-2000 : Upgrade to FORTRAN 90 ( version 2.00 )
3266  !/ Major changes to logistics.
3267  !/ 28-Dec-2004 : Multiple grid version. ( version 3.06 )
3268  !/ 07-Sep-2005 : Updated boundary conditions. ( version 3.08 )
3269  !/ 13-Jun-2006 : Split STORE in G/SSTORE ( version 3.09 )
3270  !/
3271  ! 1. Purpose :
3272  !
3273  ! 'Scatter' data back to spectral storage after propagation.
3274  !
3275  ! 2. Method :
3276  !
3277  ! Direct copy or communication calls (MPP version).
3278  ! See also W3GATH.
3279  !
3280  ! 3. Parameters :
3281  !
3282  ! Parameter list
3283  ! ----------------------------------------------------------------
3284  ! ISPEC Int. I Spectral bin considered.
3285  ! MAPSTA I.A. I Status map for spatial grid.
3286  ! FIELD R.A. I Full field to be propagated.
3287  ! ----------------------------------------------------------------
3288  !
3289  ! 4. Subroutines used :
3290  !
3291  ! Name Type Module Description
3292  ! ----------------------------------------------------------------
3293  ! STRACE Subr. W3SERVMD Subroutine tracing.
3294  !
3295  ! MPI_STARTALL, MPI_WAITALL, MPI_TESTALL
3296  ! Subr. mpif.h MPI persistent comm. routines (!/MPI).
3297  ! ----------------------------------------------------------------
3298  !
3299  ! 5. Called by :
3300  !
3301  ! Name Type Module Description
3302  ! ----------------------------------------------------------------
3303  ! W3WAVE Subr. W3WAVEMD Actual wave model routine.
3304  ! ----------------------------------------------------------------
3305  !
3306  ! 6. Error messages :
3307  !
3308  ! None.
3309  !
3310  ! 7. Remarks :
3311  !
3312  ! - The field is put back but not converted !
3313  ! - MPI persistent communication calls initialize in W3MPII.
3314  ! - See W3GATH and W3MPII for additional comments on data
3315  ! buffering.
3316  !
3317  ! 8. Structure :
3318  !
3319  ! See source code.
3320  !
3321  ! 9. Switches :
3322  !
3323  ! !/SHRD Switch for message passing method.
3324  ! !/MPI Id.
3325  !
3326  ! !/S Enable subroutine tracing.
3327  ! !/MPIT MPI test output.
3328  !
3329  ! 10. Source code :
3330  !
3331  !/ ------------------------------------------------------------------- /
3332  USE w3gdatmd, ONLY: nsea, nseal, mapsf, nspec, nx, ny
3333 #ifdef W3_S
3334  USE w3servmd, ONLY: strace
3335 #endif
3336  !/
3337  USE w3wdatmd, ONLY: a => va
3338 #ifdef W3_MPI
3339  USE w3adatmd, ONLY: mpibuf, bstat, ibfloc, isploc, bispl, &
3341 #endif
3342  USE w3odatmd, ONLY: ndst
3343 #ifdef W3_MPI
3344  USE w3odatmd, ONLY: iaproc, naproc
3345 #endif
3346  USE constants, ONLY : lpdlib
3347  USE w3parall, only: init_get_isea
3348  !/
3349  !
3350 #ifdef W3_MPI
3351  include "mpif.h"
3352 #endif
3353  !/
3354  !/ ------------------------------------------------------------------- /
3355  !/ Parameter list
3356  !/
3357  INTEGER, INTENT(IN) :: ISPEC, MAPSTA(NY*NX)
3358  REAL, INTENT(IN) :: FIELD(1-NY:NY*(NX+2))
3359  !/
3360  !/ ------------------------------------------------------------------- /
3361  !/ Local parameters
3362  !/
3363 #ifdef W3_SHRD
3364  INTEGER :: ISEA, IXY
3365 #endif
3366 #ifdef W3_MPI
3367  INTEGER :: ISEA, IXY, IOFF, IERR_MPI, J, &
3368  STATUS(MPI_STATUS_SIZE,NSPEC), &
3369  JSEA, IB0
3370 #endif
3371 #ifdef W3_S
3372  INTEGER, SAVE :: IENT
3373 #endif
3374 #ifdef W3_MPIT
3375  CHARACTER(LEN=15) :: STR(MPIBUF), STRT
3376 #endif
3377 #ifdef W3_MPI
3378  LOGICAL :: DONE
3379 #endif
3380  !/
3381  !/ ------------------------------------------------------------------- /
3382  !/
3383 #ifdef W3_S
3384  CALL strace (ient, 'W3SCAT')
3385 #endif
3386  !
3387  ! 1. Shared memory version ------------------------------------------ *
3388  !
3389 #ifdef W3_SHRD
3390  DO isea=1, nsea
3391  ixy = mapsf(isea,3)
3392  IF ( mapsta(ixy) .NE. 0 ) a(ispec,isea) = field(ixy)
3393  END DO
3394 #endif
3395  !
3396 #ifdef W3_SHRD
3397  RETURN
3398 #endif
3399  !
3400  ! 2. Distributed memory version ( MPI ) ----------------------------- *
3401  ! 2.a Initializations
3402  !
3403 #ifdef W3_MPIT
3404  DO ib0=1, mpibuf
3405  str(ib0) = ' |'
3406  END DO
3407 #endif
3408  !
3409 #ifdef W3_MPIT
3410  strt = str(ibfloc)
3411  strt(9:9) = 'A'
3412 #endif
3413  !
3414  ! 2.b Convert full grid to sea grid, active points only
3415  !
3416 #ifdef W3_MPI
3417  DO isea=1, nsea
3418  ixy = mapsf(isea,3)
3419  IF ( mapsta(ixy) .NE. 0 ) sstore(isea,ibfloc) = field(ixy)
3420  END DO
3421 #endif
3422  !
3423  ! 2.c Send spectral densities to appropriate remote
3424  !
3425 #ifdef W3_MPI
3426  ioff = 1 + (isploc-1)*nrqsg2
3427  IF ( nrqsg2 .GT. 0 ) CALL mpi_startall ( nrqsg2, irqsg2(ioff,2), ierr_mpi )
3428  bstat(ibfloc) = 2
3429 #endif
3430 #ifdef W3_MPIT
3431  strt(12:12) = 's'
3432  WRITE (strt(1:7),'(I2,I5)') bstat(ibfloc), isploc
3433  str(ibfloc) = strt
3434 #endif
3435  !
3436  ! 2.d Save locally stored results
3437  !
3438 #ifdef W3_MPI
3439  DO jsea=1, nseal
3440  CALL init_get_isea(isea, jsea)
3441  ixy = mapsf(isea,3)
3442  IF (mapsta(ixy) .NE. 0) a(ispec,jsea) = sstore(isea,ibfloc)
3443  END DO
3444 #endif
3445  !
3446  ! 2.e Check if any sends have finished
3447  !
3448 #ifdef W3_MPI
3449  ib0 = ibfloc
3450 #endif
3451  !
3452 #ifdef W3_MPI
3453  DO j=1, mpibuf
3454  ib0 = 1 + mod(ib0,mpibuf)
3455  IF ( bstat(ib0) .EQ. 2 ) THEN
3456  ioff = 1 + (bispl(ib0)-1)*nrqsg2
3457  IF ( nrqsg2 .GT. 0 ) THEN
3458  CALL mpi_testall ( nrqsg2, irqsg2(ioff,2), done, status, ierr_mpi )
3459  ELSE
3460  done = .true.
3461  END IF
3462  IF ( done .AND. nrqsg2.GT.0 ) THEN
3463  CALL mpi_waitall ( nrqsg2, irqsg2(ioff,2), status, ierr_mpi )
3464  END IF
3465  IF ( done ) THEN
3466  bstat(ib0) = 0
3467 #endif
3468 #ifdef W3_MPIT
3469  strt = str(ib0)
3470  WRITE (strt(1:7),'(I2,I5)') bstat(ib0), bispl(ib0)
3471  strt(13:13) = 'S'
3472  str(ib0) = strt
3473 #endif
3474 #ifdef W3_MPI
3475  END IF
3476  END IF
3477  END DO
3478 #endif
3479  !
3480  ! 2.f Last component, finish message passing, reset buffer control
3481  !
3482 #ifdef W3_MPI
3483  IF ( isploc .EQ. nsploc ) THEN
3484 #endif
3485  !
3486 #ifdef W3_MPI
3487  DO ib0=1, mpibuf
3488  IF ( bstat(ib0) .EQ. 2 ) THEN
3489  ioff = 1 + (bispl(ib0)-1)*nrqsg2
3490  IF ( nrqsg2 .GT. 0 ) CALL mpi_waitall ( nrqsg2, irqsg2(ioff,2), status, ierr_mpi )
3491  bstat(ib0) = 0
3492 #endif
3493 #ifdef W3_MPIT
3494  strt = str(ib0)
3495  WRITE (strt(1:7),'(I2,I5)') bstat(ib0), bispl(ib0)
3496  strt(13:13) = 'S'
3497  str(ib0) = strt
3498 #endif
3499 #ifdef W3_MPI
3500  END IF
3501  END DO
3502 #endif
3503  !
3504 #ifdef W3_MPI
3505  isploc = 0
3506  ibfloc = 0
3507 #endif
3508  !
3509 #ifdef W3_MPI
3510  END IF
3511 #endif
3512  !
3513  ! 2.g Test output
3514  !
3515 #ifdef W3_MPIT
3516  DO ib0=1, mpibuf
3517  strt = str(ib0)
3518  IF ( strt(2:2) .EQ. ' ' ) THEN
3519  IF ( bstat(ib0) .EQ. 0 ) THEN
3520  WRITE (strt(1:2),'(I2)') bstat(ib0)
3521  ELSE
3522  WRITE (strt(1:7),'(I2,I5)') bstat(ib0), bispl(ib0)
3523  END IF
3524  str(ib0) = strt
3525  END IF
3526  END DO
3527 #endif
3528  !
3529 #ifdef W3_MPIT
3530  WRITE (ndst,9000) str
3531 #endif
3532  !
3533 #ifdef W3_MPIT
3534  IF ( isploc .EQ. 0 ) THEN
3535  DO ib0=1, mpibuf
3536  str(ib0) = '--------------+'
3537  END DO
3538  WRITE (ndst,9010) str
3539  WRITE (ndst,*)
3540  END IF
3541 #endif
3542  !
3543 #ifdef W3_MPI
3544  RETURN
3545 #endif
3546  !
3547  ! Formats
3548  !
3549 #ifdef W3_MPIT
3550 9000 FORMAT ( ' | |',8a15)
3551 9010 FORMAT ( ' +-----+',8a15)
3552 #endif
3553  !/
3554  !/ End of W3SCAT ----------------------------------------------------- /
3555  !/
3556  END SUBROUTINE w3scat
3557  !/ ------------------------------------------------------------------- /
3567  SUBROUTINE w3nmin ( MAPSTA, FLAG0 )
3568  !/
3569  !/ +-----------------------------------+
3570  !/ | WAVEWATCH III NOAA/NCEP |
3571  !/ | H. L. Tolman |
3572  !/ | FORTRAN 90 |
3573  !/ | Last update : 28-Dec-2004 |
3574  !/ +-----------------------------------+
3575  !/
3576  !/ 23-Feb-2001 : Origination. ( version 2.07 )
3577  !/ 28-Dec-2004 : Multiple grid version. ( version 3.06 )
3578  !/
3579  ! 1. Purpose :
3580  !
3581  ! Check minimum number of active sea points at given processor to
3582  ! evaluate the need for a MPI_BARRIER call.
3583  !
3584  ! 2. Method :
3585  !
3586  ! Evaluate mapsta.
3587  !
3588  ! 3. Parameters :
3589  !
3590  ! Parameter list
3591  ! ----------------------------------------------------------------
3592  ! MAPSTA I.A. I Status map for spatial grid.
3593  ! FLAG0 log. O Flag to identify 0 as minimum.
3594  ! ----------------------------------------------------------------
3595  !
3596  ! 4. Subroutines used :
3597  !
3598  ! Name Type Module Description
3599  ! ----------------------------------------------------------------
3600  ! STRACE Subr. W3SERVMD Subroutine tracing.
3601  ! ----------------------------------------------------------------
3602  !
3603  ! 5. Called by :
3604  !
3605  ! Name Type Module Description
3606  ! ----------------------------------------------------------------
3607  ! W3WAVE Subr. W3WAVEMD Actual wave model routine.
3608  ! ----------------------------------------------------------------
3609  !
3610  ! 6. Error messages :
3611  !
3612  ! None.
3613  !
3614  ! 7. Remarks :
3615  !
3616  ! 8. Structure :
3617  !
3618  ! See source code.
3619  !
3620  ! 9. Switches :
3621  !
3622  ! !/S Enable subroutine tracing.
3623  ! !/T Test output.
3624  !
3625  ! 10. Source code :
3626  !
3627  !/ ------------------------------------------------------------------- /
3628 #ifdef W3_S
3629  USE w3servmd, ONLY: strace
3630 #endif
3631  !/
3632  USE w3gdatmd, ONLY: nsea, mapsf, nx, ny
3633  USE w3odatmd, ONLY: ndst, naproc
3634  USE w3parall, ONLY: init_get_jsea_isproc
3635  !/
3636  !/
3637  !/ ------------------------------------------------------------------- /
3638  !/ Parameter list
3639  !/
3640  INTEGER, INTENT(IN) :: MAPSTA(NY*NX)
3641  LOGICAL, INTENT(OUT) :: FLAG0
3642  !/
3643  !/ ------------------------------------------------------------------- /
3644  !/ Local parameters
3645  !/
3646  INTEGER :: NMIN, IPROC, NLOC, ISEA, IXY
3647  INTEGER :: JSEA, ISPROC
3648 #ifdef W3_S
3649  INTEGER, SAVE :: IENT
3650 #endif
3651  !/
3652  !/ ------------------------------------------------------------------- /
3653  !/
3654 #ifdef W3_S
3655  CALL strace (ient, 'W3NMIN')
3656 #endif
3657  !
3658  nmin = nsea
3659  !
3660 #ifdef W3_OMPG
3661  !$OMP PARALLEL PRIVATE (IPROC,NLOC,ISEA,JSEA,ISPROC,IXY,NMIN)
3662  !$OMP DO SCHEDULE (DYNAMIC,1)
3663 #endif
3664  DO iproc=1, naproc
3665  nloc = 0
3666  DO isea=1, nsea
3667  CALL init_get_jsea_isproc(isea, jsea, isproc)
3668  IF (isproc .eq. iproc) THEN
3669  ixy = mapsf(isea,3)
3670  IF ( mapsta(ixy) .EQ. 1 ) nloc = nloc + 1
3671  END IF
3672  END DO
3673 #ifdef W3_SMC
3674  !!Li For SMC grid, local sea points are equally NSEA/NAPROC
3675  !!Li so the NLOC is overwirte by a constant.
3676  nloc = nsea/naproc
3677 #endif
3678  !
3679 #ifdef W3_T
3680  WRITE (ndst,9000) iproc, nloc
3681 #endif
3682  nmin = min( nmin , nloc )
3683  END DO
3684 #ifdef W3_OMPG
3685  !$OMP END DO
3686  !$OMP END PARALLEL
3687 #endif
3688  !
3689  flag0 = nmin .EQ. 0
3690 #ifdef W3_T
3691  WRITE (ndst,9001) nmin, flag0
3692 #endif
3693  !
3694  RETURN
3695  !
3696  ! Formats
3697  !
3698 #ifdef W3_T
3699 9000 FORMAT ( ' TEST W3NMIN : IPROC =',i3,' NLOC =',i5)
3700 9001 FORMAT ( ' TEST W3NMIN : NMIN =',i5,' FLAG0 =',l2)
3701 #endif
3702  !/
3703  !/ End of W3NMIN ----------------------------------------------------- /
3704  !/
3705  END SUBROUTINE w3nmin
3706  !/
3707  !/ End of module W3WAVEMD -------------------------------------------- /
3708  !/
3709 END MODULE w3wavemd
pdlib_w3profsmd::aspar_diag_all
real, dimension(:,:), allocatable aspar_diag_all
Definition: w3profsmd_pdlib.F90:114
w3idatmd::gdn
real, pointer gdn
Definition: w3idatmd.F90:242
w3gdatmd::nk
integer, pointer nk
Definition: w3gdatmd.F90:1230
w3odatmd::nrqbp2
integer, pointer nrqbp2
Definition: w3odatmd.F90:533
w3wdatmd::iwdata
integer iwdata
Definition: w3wdatmd.F90:134
w3gdatmd::nseal
integer, pointer nseal
Definition: w3gdatmd.F90:1097
w3odatmd::tbpi0
integer, dimension(:), pointer tbpi0
Definition: w3odatmd.F90:464
constants::srce_imp_pre
integer, parameter srce_imp_pre
srce_imp_pre
Definition: constants.F90:98
w3timemd::dsec21
real function dsec21(TIME1, TIME2)
Definition: w3timemd.F90:333
w3triamd::ug_gradients
subroutine ug_gradients(PARAM, DIFFX, DIFFY)
Calculate gradients at a point via its connection.
Definition: w3triamd.F90:2039
w3adatmd::phice
real, dimension(:), pointer phice
Definition: w3adatmd.F90:607
include
cmake src_list cmake include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_switches.cmake) check_switches("$
Definition: CMakeLists.txt:15
w3odatmd::nrqpo
integer, pointer nrqpo
Definition: w3odatmd.F90:486
w3gdatmd::nitersec1
integer, pointer nitersec1
Definition: w3gdatmd.F90:1181
pdlib_w3profsmd::all_field_integral_print
subroutine all_field_integral_print(FIELD, string)
Definition: w3profsmd_pdlib.F90:2387
w3wdatmd::iceh
real, dimension(:), pointer iceh
Definition: w3wdatmd.F90:183
w3idatmd::twn
integer, dimension(:), pointer twn
Definition: w3idatmd.F90:236
w3agcmmd
Module used for coupling applications between atmospheric model and WW3 with OASIS3-MCT.
Definition: w3agcmmd.F90:23
w3idatmd::inflags1
logical, dimension(:), pointer inflags1
Definition: w3idatmd.F90:260
w3adatmd::charn
real, dimension(:), pointer charn
Definition: w3adatmd.F90:603
w3adatmd::dtdyn
real, dimension(:), pointer dtdyn
Definition: w3adatmd.F90:620
w3psmcmd::w3scatsmc
subroutine w3scatsmc(ISPEC, MAPSTA, FIELD)
SMC version of W3GATH.
Definition: w3psmcmd.F90:3420
w3wdatmd::fpis
real, dimension(:), pointer fpis
Definition: w3wdatmd.F90:183
w3gdatmd::dth
real, pointer dth
Definition: w3gdatmd.F90:1232
w3triamd
Reads triangle and unstructured grid information.
Definition: w3triamd.F90:21
w3odatmd::nrqgo2
integer, pointer nrqgo2
Definition: w3odatmd.F90:475
w3adatmd::as
real, dimension(:), pointer as
Definition: w3adatmd.F90:584
w3wdatmd::shavetot
logical, dimension(:), pointer shavetot
Definition: w3wdatmd.F90:193
w3odatmd::tosnl5
integer, dimension(:), pointer tosnl5
Definition: w3odatmd.F90:462
w3gdatmd::ygrd
double precision, dimension(:,:), pointer ygrd
Definition: w3gdatmd.F90:1205
w3odatmd::notype
integer notype
Definition: w3odatmd.F90:327
w3uostmd
Parmeterization of the unresolved obstacles.
Definition: w3uostmd.F90:22
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
w3iosfmd::w3cprt
subroutine w3cprt(IMOD)
Partitioning of spectra into fields for all grid points that are locally stored.
Definition: w3iosfmd.F90:109
w3wavemd::w3scat
subroutine w3scat(ISPEC, MAPSTA, FIELD)
Scatter data back to spectral storage after propagation.
Definition: w3wavemd.F90:3256
w3gdatmd::trnx
real, dimension(:,:), pointer trnx
Definition: w3gdatmd.F90:1200
w3adatmd::dcdx
real, dimension(:,:,:), pointer dcdx
Definition: w3adatmd.F90:629
constants::dair
real, parameter dair
DAIR Density of air (kg/m3).
Definition: constants.F90:63
w3adatmd::nrqsg2
integer, pointer nrqsg2
Definition: w3adatmd.F90:676
w3gdatmd::zb
real, dimension(:), pointer zb
Definition: w3gdatmd.F90:1195
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::flagst
logical, dimension(:), pointer flagst
Definition: w3gdatmd.F90:1221
w3gdatmd::ungtype
integer, parameter ungtype
Definition: w3gdatmd.F90:626
w3updtmd::w3ucur
subroutine w3ucur(FLFRST)
Interpolate the current field to the present time.
Definition: w3updtmd.F90:172
w3gdatmd::dmin
real, pointer dmin
Definition: w3gdatmd.F90:1183
constants::srce_direct
integer, parameter srce_direct
srce_direct
Definition: constants.F90:96
w3wavset
Implicit solution of wave setup problem following Dingemans for structured and unstructured grids.
Definition: w3wavset.F90:18
w3wdatmd
Define data structures to set up wave model dynamic data for several models simultaneously.
Definition: w3wdatmd.F90:18
w3updtmd::w3urho
subroutine w3urho(FLFRST)
Interpolate air density field to the given time.
Definition: w3updtmd.F90:2552
w3adatmd::dhdy
real, dimension(:), pointer dhdy
Definition: w3adatmd.F90:631
w3adatmd::dhlmt
real, dimension(:,:), pointer dhlmt
Definition: w3adatmd.F90:631
w3adatmd::tauice
real, dimension(:,:), pointer tauice
Definition: w3adatmd.F90:607
w3updtmd::w3uini
subroutine w3uini(A)
Initialize the wave field with fetch-limited spectra before the actual calculation start.
Definition: w3updtmd.F90:1050
w3wavemd::w3gath
subroutine w3gath(ISPEC, FIELD)
Gather spectral bin information into a propagation field array.
Definition: w3wavemd.F90:2938
w3gdatmd::sed_d50
real, dimension(:), pointer sed_d50
Definition: w3gdatmd.F90:1214
w3adatmd::cflxymax
real, dimension(:), pointer cflxymax
Definition: w3adatmd.F90:620
w3adatmd::cg
real, dimension(:,:), pointer cg
Definition: w3adatmd.F90:575
w3adatmd::tws
real, dimension(:), pointer tws
Definition: w3adatmd.F90:603
w3psmcmd::smcdhxy
subroutine smcdhxy
Calculates water-depth gradient for refraction.
Definition: w3psmcmd.F90:2897
w3adatmd::fcut
real, dimension(:), pointer fcut
Definition: w3adatmd.F90:620
w3gdatmd::rlgtype
integer, parameter rlgtype
Definition: w3gdatmd.F90:624
w3adatmd::nsploc
integer, pointer nsploc
Definition: w3adatmd.F90:676
w3odatmd::flogr2
logical, dimension(:,:), pointer flogr2
Definition: w3odatmd.F90:478
pdlib_w3profsmd::aspar_jac
real, dimension(:,:), allocatable aspar_jac
Definition: w3profsmd_pdlib.F90:114
w3pro2md::w3ktp2
subroutine w3ktp2(ISEA, FACTH, FACK, CTHG0, CG, WN, DEPTH, DDDX, DDDY, CX, CY, DCXDX, DCXDY, DCYDX, DCYDY, DCDX, DCDY, VA)
Propagation in spectral space.
Definition: w3pro2md.F90:1305
w3adatmd::bispl
integer, dimension(:), pointer bispl
Definition: w3adatmd.F90:680
w3parall::lsloc
logical, parameter lsloc
Definition: w3parall.F90:89
w3adatmd::dw
real, dimension(:), pointer dw
Definition: w3adatmd.F90:584
w3iorsmd::w3iors
subroutine w3iors(INXOUT, NDSR, DUMFPI, IMOD, FLRSTRT)
Reads/writes restart files.
Definition: w3iorsmd.F90:113
w3adatmd::u10d
real, dimension(:), pointer u10d
Definition: w3adatmd.F90:584
w3gdatmd::reflc
real, dimension(:,:), pointer reflc
Definition: w3gdatmd.F90:1101
w3odatmd::dtout
real, dimension(:), pointer dtout
Definition: w3odatmd.F90:467
w3gdatmd::sig
real, dimension(:), pointer sig
Definition: w3gdatmd.F90:1234
w3profsmd
Definition: w3profsmd.F90:3
w3wdatmd::icef
real, dimension(:), pointer icef
Definition: w3wdatmd.F90:183
w3gdatmd::xgrd
double precision, dimension(:,:), pointer xgrd
Definition: w3gdatmd.F90:1205
w3gdatmd::sy
real, pointer sy
Definition: w3gdatmd.F90:1183
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
w3idatmd::ti5
integer, dimension(:), pointer ti5
Definition: w3idatmd.F90:236
w3gdatmd::fsrefraction
logical, pointer fsrefraction
Definition: w3gdatmd.F90:1406
w3adatmd::ipass
integer, pointer ipass
Definition: w3adatmd.F90:686
w3odatmd::iaproc
integer, pointer iaproc
Definition: w3odatmd.F90:457
w3adatmd::iadata
integer iadata
Definition: w3adatmd.F90:374
w3idatmd::gan
real, pointer gan
Definition: w3idatmd.F90:242
w3updtmd
Bundles all input updating routines for WAVEWATCH III.
Definition: w3updtmd.F90:22
w3wdatmd::time
integer, dimension(:), pointer time
Definition: w3wdatmd.F90:172
w3adatmd::tauocy
real, dimension(:), pointer tauocy
Definition: w3adatmd.F90:607
w3odatmd::irqpo1
integer, dimension(:), pointer irqpo1
Definition: w3odatmd.F90:490
w3idatmd::flic4
logical, pointer flic4
Definition: w3idatmd.F90:264
constants::srce_imp_post
integer, parameter srce_imp_post
srce_imp_post
Definition: constants.F90:97
w3updtmd::w3ubpt
subroutine w3ubpt
Update spectra at the active boundary points.
Definition: w3updtmd.F90:1314
w3gdatmd::ny
integer, pointer ny
Definition: w3gdatmd.F90:1097
w3wavemd::w3nmin
subroutine w3nmin(MAPSTA, FLAG0)
Check minimum number of active sea points at given processor to evaluate the need for a MPI_BARRIER c...
Definition: w3wavemd.F90:3568
yownodepool::iplg
integer, dimension(:), allocatable, public iplg
Node local to global mapping.
Definition: yownodepool.F90:116
w3srcemd::w3srce
subroutine w3srce(srce_call, IT, ISEA, JSEA, IX, IY, IMOD, SPECOLD, SPEC, VSIO, VDIO, SHAVEIO, ALPHA, WN1, CG1, CLATSL, D_INP, U10ABS, U10DIR, ifdef W3_FLX5
Calculate and integrate source terms for a single grid point.
Definition: w3srcemd.F90:195
w3odatmd::tbpin
integer, dimension(:), pointer tbpin
Definition: w3odatmd.F90:464
w3idatmd::tg0
integer, dimension(:), pointer tg0
Definition: w3idatmd.F90:236
w3gdatmd::iclbac
integer, dimension(:), pointer iclbac
Definition: w3gdatmd.F90:1171
w3adatmd::iappro
integer, dimension(:), pointer iappro
Definition: w3adatmd.F90:674
w3gdatmd::fssource
logical, pointer fssource
Definition: w3gdatmd.F90:1406
w3odatmd::ioutp
integer ioutp
Definition: w3odatmd.F90:321
w3gdatmd::iobp_loc
integer *2, dimension(:), pointer iobp_loc
Definition: w3gdatmd.F90:1117
yownodepool::npa
integer, public npa
number of ghost + resident nodes this partition holds
Definition: yownodepool.F90:99
w3sic3md::calledic3table
integer, save calledic3table
Definition: w3sic3md.F90:88
w3odatmd::flbpi
logical, pointer flbpi
Definition: w3odatmd.F90:546
w3wdatmd::va
real, dimension(:,:), pointer va
Definition: w3wdatmd.F90:183
w3idatmd::flcur
logical, pointer flcur
Definition: w3idatmd.F90:261
w3iobcmd::w3iobc
subroutine w3iobc(INXOUT, NDSB, TIME1, TIME2, IOTST, IMOD)
Write/read boundary conditions file(s).
Definition: w3iobcmd.F90:99
w3odatmd::napbpt
integer, pointer napbpt
Definition: w3odatmd.F90:457
w3adatmd::tauwix
real, dimension(:), pointer tauwix
Definition: w3adatmd.F90:603
w3idatmd::tu0
integer, dimension(:), pointer tu0
Definition: w3idatmd.F90:236
w3gdatmd::spcbac
real, dimension(:,:), pointer spcbac
Definition: w3gdatmd.F90:1204
w3updtmd::w3ulev
subroutine w3ulev(A, VA)
Update the water level.
Definition: w3updtmd.F90:2013
w3adatmd::dcydx
real, dimension(:,:), pointer dcydx
Definition: w3adatmd.F90:627
w3pro3md
Bundles routines for third order propagation scheme in single module.
Definition: w3pro3md.F90:23
w3gdatmd::hqfac
real, dimension(:,:), pointer hqfac
Definition: w3gdatmd.F90:1212
w3wdatmd::tlev
integer, dimension(:), pointer tlev
Definition: w3wdatmd.F90:172
w3idatmd::flic5
logical, pointer flic5
Definition: w3idatmd.F90:264
w3igcmmd::snd_fields_to_ice
subroutine, public snd_fields_to_ice()
Send coupling fields to ice model.
Definition: w3igcmmd.F90:77
w3gdatmd::nglo
integer, pointer nglo
Definition: w3gdatmd.F90:1168
w3gdatmd::w3setg
subroutine w3setg(IMOD, NDSE, NDST)
Definition: w3gdatmd.F90:2152
w3pro1md
Bundles routines for first order propagation scheme in single module.
Definition: w3pro1md.F90:23
w3pro2md
Bundles routines for third order porpagation scheme in single module.
Definition: w3pro2md.F90:24
w3servmd::w3acturn
subroutine w3acturn(NDirc, NFreq, Alpha, Spectr)
Definition: w3servmd.F90:977
w3adatmd::tauwiy
real, dimension(:), pointer tauwiy
Definition: w3adatmd.F90:603
w3adatmd::taubbl
real, dimension(:,:), pointer taubbl
Definition: w3adatmd.F90:614
w3servmd::wwtime
subroutine wwtime(STRNG)
Definition: w3servmd.F90:664
w3odatmd::ndse
integer, pointer ndse
Definition: w3odatmd.F90:456
w3wdatmd::berg
real, dimension(:), pointer berg
Definition: w3wdatmd.F90:183
w3adatmd::w3seta
subroutine w3seta(IMOD, NDSE, NDST)
Select one of the WAVEWATCH III grids / models.
Definition: w3adatmd.F90:2645
w3adatmd::tauwny
real, dimension(:), pointer tauwny
Definition: w3adatmd.F90:603
w3gdatmd::rstype
integer, pointer rstype
Definition: w3gdatmd.F90:1095
w3gdatmd::mapfs
integer, dimension(:,:), pointer mapfs
Definition: w3gdatmd.F90:1163
w3odatmd::tonext
integer, dimension(:,:), pointer tonext
Definition: w3odatmd.F90:464
w3idatmd::fllev
logical, pointer fllev
Definition: w3idatmd.F90:261
w3adatmd::dcdy
real, dimension(:,:,:), pointer dcdy
Definition: w3adatmd.F90:629
w3odatmd::naperr
integer, pointer naperr
Definition: w3odatmd.F90:457
w3odatmd::stop
logical, pointer stop
Definition: w3odatmd.F90:515
w3sic3md::ic3table_cheng
subroutine, public ic3table_cheng(ICE2, ICE3, ICE4)
Definition: w3sic3md.F90:1963
w3adatmd::phiaw
real, dimension(:), pointer phiaw
Definition: w3adatmd.F90:603
w3iotrmd::w3iotr
subroutine w3iotr(NDSINP, NDSOUT, A, IMOD)
Perform output of spectral information along provided tracks.
Definition: w3iotrmd.F90:105
w3wavemd
Contains wave model subroutine, w3wave.
Definition: w3wavemd.F90:13
w3wdatmd::vdtot
real, dimension(:,:), pointer vdtot
Definition: w3wdatmd.F90:191
w3adatmd::phibbl
real, dimension(:), pointer phibbl
Definition: w3adatmd.F90:614
w3adatmd::mpibuf
integer, parameter mpibuf
Definition: w3adatmd.F90:376
w3gdatmd::refld
integer, dimension(:,:), pointer refld
Definition: w3gdatmd.F90:1102
w3gdatmd::sed_psic
real, dimension(:), pointer sed_psic
Definition: w3gdatmd.F90:1214
w3parall::pdlib_nsealm
integer pdlib_nsealm
Definition: w3parall.F90:82
w3agcmmd::snd_fields_to_atmos
subroutine, public snd_fields_to_atmos()
Send coupling fields to atmospheric model.
Definition: w3agcmmd.F90:89
yownodepool
Has data that belong to nodes.
Definition: yownodepool.F90:39
constants::lpdlib
logical lpdlib
LPDLIB Logical for using the PDLIB library.
Definition: constants.F90:101
pdlib_field_vec::do_output_exchanges
subroutine do_output_exchanges(IMOD)
Definition: pdlib_field_vec.F90:787
w3adatmd::cflthmax
real, dimension(:), pointer cflthmax
Definition: w3adatmd.F90:620
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
w3gdatmd::clgtype
integer, parameter clgtype
Definition: w3gdatmd.F90:625
w3servmd
Definition: w3servmd.F90:3
w3wdatmd::vstot
real, dimension(:,:), pointer vstot
Definition: w3wdatmd.F90:191
w3adatmd::dcxdx
real, dimension(:,:), pointer dcxdx
Definition: w3adatmd.F90:627
w3odatmd::flogrd
logical, dimension(:,:), pointer flogrd
Definition: w3odatmd.F90:478
w3odatmd::naplog
integer, pointer naplog
Definition: w3odatmd.F90:457
pdlib_w3profsmd::all_vaold_integral_print
subroutine all_vaold_integral_print(string, choice)
Definition: w3profsmd_pdlib.F90:2220
w3adatmd::bedforms
real, dimension(:,:), pointer bedforms
Definition: w3adatmd.F90:614
w3gdatmd::nbac
integer, pointer nbac
Definition: w3gdatmd.F90:1168
w3timemd::tick21
subroutine tick21(TIME, DTIME)
Definition: w3timemd.F90:84
w3wdatmd::tic1
integer, dimension(:), pointer tic1
Definition: w3wdatmd.F90:172
pdlib_w3profsmd::pdlib_w3xypug
subroutine pdlib_w3xypug(ISP, FACX, FACY, DTG, VGX, VGY, LCALC)
Definition: w3profsmd_pdlib.F90:632
w3wdatmd::w3setw
subroutine w3setw(IMOD, NDSE, NDST)
Select one of the WAVEWATCH III grids / models.
Definition: w3wdatmd.F90:660
w3ogcmmd
Definition: w3ogcmmd.F90:3
w3odatmd::noge
integer, dimension(nogrp) noge
Definition: w3odatmd.F90:326
w3adatmd::irqsg1
integer, dimension(:,:), pointer irqsg1
Definition: w3adatmd.F90:681
constants::tpiinv
real, parameter tpiinv
TPIINV Inverse of 2*Pi.
Definition: constants.F90:74
w3odatmd::irqbp1
integer, dimension(:), pointer irqbp1
Definition: w3odatmd.F90:538
w3odatmd::w3seto
subroutine w3seto(IMOD, NDSERR, NDSTST)
Definition: w3odatmd.F90:1523
w3timemd::stme21
subroutine stme21(TIME, DTME21)
Definition: w3timemd.F90:682
w3servmd::print_memcheck
subroutine print_memcheck(iun, msg)
Write memory statistics if requested.
Definition: w3servmd.F90:2033
w3adatmd::gstore
real, dimension(:,:), pointer gstore
Definition: w3adatmd.F90:682
w3adatmd::tauwnx
real, dimension(:), pointer tauwnx
Definition: w3adatmd.F90:603
w3idatmd::flic2
logical, pointer flic2
Definition: w3idatmd.F90:264
w3adatmd::alpha
real, dimension(:,:), pointer alpha
Definition: w3adatmd.F90:687
w3servmd::ssort1
subroutine ssort1(X, Y, N, KFLAG)
Definition: w3servmd.F90:1518
w3gdatmd::flcth
logical, pointer flcth
Definition: w3gdatmd.F90:1217
w3profsmd::w3xypug
subroutine w3xypug(ISP, FACX, FACY, DTG, VQ, VGX, VGY, LCALC)
Definition: w3profsmd.F90:63
w3gdatmd::nth
integer, pointer nth
Definition: w3gdatmd.F90:1230
w3idatmd::flic3
logical, pointer flic3
Definition: w3idatmd.F90:264
w3odatmd
Definition: w3odatmd.F90:3
w3oacpmd
Definition: w3oacpmd.F90:3
w3adatmd::dddy
real, dimension(:,:), pointer dddy
Definition: w3adatmd.F90:627
w3gdatmd::clats
real, dimension(:), pointer clats
Definition: w3gdatmd.F90:1196
w3idatmd::iidata
integer iidata
Definition: w3idatmd.F90:160
w3odatmd::irqgo2
integer, dimension(:), pointer irqgo2
Definition: w3odatmd.F90:476
w3odatmd::nds
integer, dimension(:), pointer nds
Definition: w3odatmd.F90:464
w3updtmd::w3uice
subroutine w3uice(VA)
Update ice map in the wave model.
Definition: w3updtmd.F90:1756
pdlib_w3profsmd::pdlib_w3xypug_block_explicit
subroutine pdlib_w3xypug_block_explicit(IMOD, FACX, FACY, DTG, VGX, VGY, LCALC)
Definition: w3profsmd_pdlib.F90:2807
w3adatmd::cy
real, dimension(:), pointer cy
Definition: w3adatmd.F90:584
w3srcemd
Source term integration routine.
Definition: w3srcemd.F90:24
w3adatmd::idlast
integer, pointer idlast
Definition: w3adatmd.F90:686
w3pro1md::w3map1
subroutine w3map1(MAPSTA)
Generate 'map' arrays for the first order upstream scheme.
Definition: w3pro1md.F90:108
w3gdatmd::flsou
logical, pointer flsou
Definition: w3gdatmd.F90:1217
w3iobcmd
Processing of boundary data output.
Definition: w3iobcmd.F90:14
w3odatmd::screen
integer, pointer screen
Definition: w3odatmd.F90:456
w3adatmd::taua
real, dimension(:), pointer taua
Definition: w3adatmd.F90:584
w3gdatmd::angarc
real, dimension(:), pointer angarc
Definition: w3gdatmd.F90:1204
w3odatmd::tolast
integer, dimension(:,:), pointer tolast
Definition: w3odatmd.F90:464
w3idatmd::gd0
real, pointer gd0
Definition: w3idatmd.F90:242
w3sic3md::w3ic3wncg_cheng
subroutine, public w3ic3wncg_cheng(WN_R, WN_I, CG, ICE1, ICE2, ICE3, ICE4, DPT)
Definition: w3sic3md.F90:1801
pdlib_w3profsmd::pdlib_w3xypug_block_implicit
subroutine pdlib_w3xypug_block_implicit(IMOD, FACX, FACY, DTG, VGX, VGY, LCALC)
Definition: w3profsmd_pdlib.F90:2736
w3gdatmd::mapsf
integer, dimension(:,:), pointer mapsf
Definition: w3gdatmd.F90:1163
w3idatmd::ti1
integer, dimension(:), pointer ti1
Definition: w3idatmd.F90:236
w3odatmd::naproc
integer, pointer naproc
Definition: w3odatmd.F90:457
w3parall::print_my_time
subroutine print_my_time(string)
Print timings.
Definition: w3parall.F90:200
w3gdatmd::nbgl
integer, pointer nbgl
Definition: w3gdatmd.F90:1168
w3gdatmd::igrid
integer igrid
Definition: w3gdatmd.F90:618
yownodepool::np
integer, public np
number of nodes, local
Definition: yownodepool.F90:93
w3adatmd::wnmean
real, dimension(:), pointer wnmean
Definition: w3adatmd.F90:587
w3adatmd::cflkmax
real, dimension(:), pointer cflkmax
Definition: w3adatmd.F90:620
w3odatmd::irqbp2
integer, dimension(:), pointer irqbp2
Definition: w3odatmd.F90:538
w3adatmd::sstore
real, dimension(:,:), pointer sstore
Definition: w3adatmd.F90:682
w3iogomd::w3iogo
subroutine w3iogo(INXOUT, NDSOG, IOTST, IMOD ifdef W3_ASCII
Read/write gridded output.
Definition: w3iogomd.F90:2396
w3idatmd::w3seti
subroutine w3seti(IMOD, NDSE, NDST)
Select one of the WAVEWATCH III grids / models.
Definition: w3idatmd.F90:819
w3parall::pdlib_nseal
integer pdlib_nseal
Definition: w3parall.F90:82
w3updtmd::w3uic5
subroutine w3uic5(FLFRST)
Update ice floe mean and max diameters in the wave model.
Definition: w3updtmd.F90:1624
w3gdatmd::smctype
integer, parameter smctype
Definition: w3gdatmd.F90:627
w3gdatmd::cthg0s
real, dimension(:), pointer cthg0s
Definition: w3gdatmd.F90:1198
w3adatmd::phioc
real, dimension(:), pointer phioc
Definition: w3adatmd.F90:607
file
file(STRINGS ${CMAKE_BINARY_DIR}/switch switch_strings) separate_arguments(switches UNIX_COMMAND $
Definition: CMakeLists.txt:3
w3iogrmd
Reading/writing of model definition file.
Definition: w3iogrmd.F90:20
constants::radius
real, parameter radius
RADIUS Radius of the earth (m).
Definition: constants.F90:79
w3iopomd::w3iopon
subroutine w3iopon(INXOUT, NDSOP, IOTST, IMOD)
Read or write the netCDF point output file, depending on the value of the first parameter.
Definition: w3iopomd.F90:1747
w3odatmd::nrqrs
integer, pointer nrqrs
Definition: w3odatmd.F90:523
w3wavset::wave_setup_computation
subroutine wave_setup_computation
General driver.
Definition: w3wavset.F90:3075
w3adatmd::wn
real, dimension(:,:), pointer wn
Definition: w3adatmd.F90:575
w3updtmd::w3dzxy
subroutine w3dzxy(ZZ, ZUNIT, DZZDX, DZZDY)
Calculate derivatives of a field.
Definition: w3updtmd.F90:3139
w3adatmd::u10
real, dimension(:), pointer u10
Definition: w3adatmd.F90:584
w3gdatmd::fstotalexp
logical, pointer fstotalexp
Definition: w3gdatmd.F90:1405
w3igcmmd
Module used for coupling applications between ice model and WW3 with OASIS3-MCT.
Definition: w3igcmmd.F90:15
w3odatmd::irqrs
integer, dimension(:), pointer irqrs
Definition: w3odatmd.F90:524
w3adatmd::fliwnd
logical, pointer fliwnd
Definition: w3adatmd.F90:688
w3wdatmd::timeend
integer, dimension(:), pointer timeend
Definition: w3wdatmd.F90:176
w3adatmd::dcydy
real, dimension(:,:), pointer dcydy
Definition: w3adatmd.F90:627
w3idatmd::tdn
integer, dimension(:), pointer tdn
Definition: w3idatmd.F90:236
w3odatmd::flout
logical, dimension(:), pointer flout
Definition: w3odatmd.F90:468
w3iogomd
Gridded output of mean wave parameters.
Definition: w3iogomd.F90:15
w3idatmd::flwind
logical, pointer flwind
Definition: w3idatmd.F90:261
w3idatmd::ga0
real, pointer ga0
Definition: w3idatmd.F90:242
w3servmd::strace
subroutine strace(IENT, SNAME)
Definition: w3servmd.F90:148
w3wdatmd::icedmax
real, dimension(:), pointer icedmax
Definition: w3wdatmd.F90:183
w3oacpmd::id_oasis_time
integer, public id_oasis_time
Definition: w3oacpmd.F90:78
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
w3odatmd::ndso
integer, pointer ndso
Definition: w3odatmd.F90:456
w3wdatmd::ice
real, dimension(:), pointer ice
Definition: w3wdatmd.F90:183
w3updtmd::w3utau
subroutine w3utau(FLFRST)
Interpolate atmosphere momentum fields to the given time.
Definition: w3updtmd.F90:829
w3sis2md
Floe-size dependant scattering of waves in the marginal ice zone.
Definition: w3sis2md.F90:33
w3gdatmd::flcy
logical, pointer flcy
Definition: w3gdatmd.F90:1217
w3adatmd::whitecap
real, dimension(:,:), pointer whitecap
Definition: w3adatmd.F90:603
w3wavemd::w3wave
subroutine w3wave(IMOD, ODAT, TEND, STAMP, NO_OUT ifdef W3_OASIS
Run WAVEWATCH III for a given time interval.
Definition: w3wavemd.F90:230
w3odatmd::nappnt
integer, pointer nappnt
Definition: w3odatmd.F90:457
w3odatmd::napout
integer, pointer napout
Definition: w3odatmd.F90:457
pdlib_field_vec
Definition: pdlib_field_vec.F90:1
w3gdatmd::fldry
logical, pointer fldry
Definition: w3gdatmd.F90:1217
w3uostmd::uost_setgrid
subroutine, public uost_setgrid(IGRID)
Sets the current grid in the sourceterm object.
Definition: w3uostmd.F90:232
w3pro1md::w3xyp1
subroutine w3xyp1(ISP, DTG, MAPSTA, FIELD, VGX, VGY)
Propagation in physical space for a given spectral component.
Definition: w3pro1md.F90:303
w3pro3md::w3map3
subroutine w3map3
Generate 'map' arrays for the ULTIMATE QUICKEST scheme.
Definition: w3pro3md.F90:140
w3idatmd::tc0
integer, dimension(:), pointer tc0
Definition: w3idatmd.F90:236
w3ogcmmd::snd_fields_to_ocean
subroutine, public snd_fields_to_ocean()
Definition: w3ogcmmd.F90:63
w3adatmd::tauox
real, dimension(:), pointer tauox
Definition: w3adatmd.F90:607
w3idatmd::tw0
integer, dimension(:), pointer tw0
Definition: w3idatmd.F90:236
w3idatmd::tin
integer, dimension(:), pointer tin
Definition: w3idatmd.F90:236
w3psmcmd
Spherical Multiple-Cell (SMC) grid routines.
Definition: w3psmcmd.F90:18
w3odatmd::napfld
integer, pointer napfld
Definition: w3odatmd.F90:457
w3gdatmd::hpfac
real, dimension(:,:), pointer hpfac
Definition: w3gdatmd.F90:1211
w3parall::init_get_jsea_isproc
subroutine init_get_jsea_isproc(ISEA, JSEA, ISPROC)
Set JSEA for all schemes.
Definition: w3parall.F90:1163
w3oacpmd::cplt0
logical, public cplt0
Definition: w3oacpmd.F90:80
w3pro2md::w3xyp2
subroutine w3xyp2(ISP, DTG, MAPSTA, MAPFS, VQ, VGX, VGY)
Propagation in physical space for a given spectral component.
Definition: w3pro2md.F90:509
w3wdatmd::time00
integer, dimension(:), pointer time00
Definition: w3wdatmd.F90:175
w3gdatmd::iobp
integer *2, dimension(:), pointer iobp
Definition: w3gdatmd.F90:1129
w3odatmd::tofrst
integer, dimension(:), pointer tofrst
Definition: w3odatmd.F90:464
w3idatmd::fltaua
logical, pointer fltaua
Definition: w3idatmd.F90:261
w3gdatmd::sx
real, pointer sx
Definition: w3gdatmd.F90:1183
w3odatmd::ndst
integer, pointer ndst
Definition: w3odatmd.F90:456
w3wdatmd::ust
real, dimension(:), pointer ust
Definition: w3wdatmd.F90:183
w3gdatmd::flcx
logical, pointer flcx
Definition: w3gdatmd.F90:1217
w3adatmd::mpi_comm_wave
integer, pointer mpi_comm_wave
Definition: w3adatmd.F90:676
constants::debug_node
integer, parameter debug_node
DEBUG_NODE Node number used for debugging.
Definition: constants.F90:99
constants
Define some much-used constants for global use (all defined as PARAMETER).
Definition: constants.F90:20
w3adatmd::tauoy
real, dimension(:), pointer tauoy
Definition: w3adatmd.F90:607
w3profsmd::w3cflug
subroutine w3cflug(ISEA, NKCFL, FACX, FACY, DT, MAPFS, CFLXYMAX, VGX, VGY)
Definition: w3profsmd.F90:272
w3gdatmd::ic3pars
real, dimension(:), pointer ic3pars
Definition: w3gdatmd.F90:1148
w3gdatmd
Definition: w3gdatmd.F90:16
w3adatmd::flcold
logical, pointer flcold
Definition: w3adatmd.F90:688
w3idatmd::flrhoa
logical, pointer flrhoa
Definition: w3idatmd.F90:261
w3psmcmd::w3gathsmc
subroutine w3gathsmc(ISPEC, FIELD)
SMC version of W3GATH.
Definition: w3psmcmd.F90:3185
w3adatmd::dcxdy
real, dimension(:,:), pointer dcxdy
Definition: w3adatmd.F90:627
w3updtmd::w3uic1
subroutine w3uic1(FLFRST)
Update ice thickness in the wave model.
Definition: w3updtmd.F90:1513
w3gdatmd::arctc
logical, pointer arctc
Definition: w3gdatmd.F90:1264
w3adatmd::tauadir
real, dimension(:), pointer tauadir
Definition: w3adatmd.F90:584
w3servmd::extcde
subroutine extcde(IEXIT, UNIT, MSG, FILE, LINE, COMM)
Definition: w3servmd.F90:736
w3gdatmd::dtcfli
real, pointer dtcfli
Definition: w3gdatmd.F90:1183
w3adatmd::ibfloc
integer, pointer ibfloc
Definition: w3adatmd.F90:676
w3wdatmd::rhoair
real, dimension(:), pointer rhoair
Definition: w3wdatmd.F90:183
w3adatmd::bstat
integer, dimension(:), pointer bstat
Definition: w3adatmd.F90:680
w3idatmd::flice
logical, pointer flice
Definition: w3idatmd.F90:261
w3adatmd::nrqsg1
integer, pointer nrqsg1
Definition: w3adatmd.F90:676
w3gdatmd::ncel
integer, pointer ncel
Definition: w3gdatmd.F90:1167
w3wdatmd::ustdir
real, dimension(:), pointer ustdir
Definition: w3wdatmd.F90:183
w3iogomd::w3outg
subroutine w3outg(A, FLPART, FLOUTG, FLOUTG2)
Fill necessary arrays with gridded data for output.
Definition: w3iogomd.F90:1198
w3adatmd::itime
integer, pointer itime
Definition: w3adatmd.F90:686
pdlib_w3profsmd::all_va_integral_print
subroutine all_va_integral_print(IMOD, string, choice)
Definition: w3profsmd_pdlib.F90:2292
w3iosfmd::w3iosf
subroutine w3iosf(NDSPT, IMOD)
Write partitioned spectral data to file.
Definition: w3iosfmd.F90:361
w3adatmd::dddx
real, dimension(:,:), pointer dddx
Definition: w3adatmd.F90:627
w3sic3md::w3ic3wncg_v1
subroutine, public w3ic3wncg_v1(WN_R, WN_I, CG, ICE1, ICE2, ICE3, ICE4, DPT)
Definition: w3sic3md.F90:658
w3adatmd::irqsg2
integer, dimension(:,:), pointer irqsg2
Definition: w3adatmd.F90:681
w3idatmd::tln
integer, dimension(:), pointer tln
Definition: w3idatmd.F90:236
w3adatmd::isploc
integer, pointer isploc
Definition: w3adatmd.F90:676
w3adatmd::cx
real, dimension(:), pointer cx
Definition: w3adatmd.F90:584
w3gdatmd::nx
integer, pointer nx
Definition: w3gdatmd.F90:1097
w3wdatmd::tic5
integer, dimension(:), pointer tic5
Definition: w3wdatmd.F90:172
w3idatmd::trn
integer, dimension(:), pointer trn
Definition: w3idatmd.F90:236
w3psmcmd::w3psmc
subroutine w3psmc(ISP, DTG, VQ)
Propagation in phyiscal space for a given spectral component.
Definition: w3psmcmd.F90:137
w3gdatmd::fsfreqshift
logical, pointer fsfreqshift
Definition: w3gdatmd.F90:1406
w3timemd
Definition: w3timemd.F90:3
constants::undef
real undef
UNDEF Value for undefined variable in output.
Definition: constants.F90:84
w3odatmd::nrqbp
integer, pointer nrqbp
Definition: w3odatmd.F90:533
w3parall
Parallel routines for implicit solver.
Definition: w3parall.F90:22
w3iopomd::w3iopo
subroutine w3iopo(INXOUT, NDSOP, IOTST, IMOD ifdef W3_ASCII
Read or write point output.
Definition: w3iopomd.F90:1907
w3iotrmd
Generate track output.
Definition: w3iotrmd.F90:14
pdlib_w3profsmd::b_jac
real, dimension(:,:), allocatable b_jac
Definition: w3profsmd_pdlib.F90:114
w3odatmd::irqgo
integer, dimension(:), pointer irqgo
Definition: w3odatmd.F90:476
w3odatmd::nrqgo
integer, pointer nrqgo
Definition: w3odatmd.F90:475
w3gdatmd::fstotalimp
logical, pointer fstotalimp
Definition: w3gdatmd.F90:1405
w3idatmd::tun
integer, dimension(:), pointer tun
Definition: w3idatmd.F90:236
w3odatmd::naprst
integer, pointer naprst
Definition: w3odatmd.F90:457
w3idatmd::tr0
integer, dimension(:), pointer tr0
Definition: w3idatmd.F90:236
w3pro3md::w3mapt
subroutine w3mapt
Generate 'map' arrays for the ULTIMATE QUICKEST scheme to combine GSE alleviation with obstructions.
Definition: w3pro3md.F90:525
w3iopomd::w3iope
subroutine w3iope(A)
Extract point output data and store in output COMMONs.
Definition: w3iopomd.F90:697
w3updtmd::w3utrn
subroutine w3utrn(TRNX, TRNY)
Update cell boundary transparencies for general use in propagation routines.
Definition: w3updtmd.F90:2736
w3gdatmd::mapsta
integer, dimension(:,:), pointer mapsta
Definition: w3gdatmd.F90:1163
w3updtmd::w3uwnd
subroutine w3uwnd(FLFRST, VGX, VGY)
Interpolate wind fields to the given time.
Definition: w3updtmd.F90:489
w3pro2md::w3map2
subroutine w3map2
Generate 'map' arrays for the ULTIMATE QUICKEST scheme.
Definition: w3pro2md.F90:136
w3wdatmd::vaold
real, dimension(:,:), pointer vaold
Definition: w3wdatmd.F90:192
w3iorsmd
Read/write restart files.
Definition: w3iorsmd.F90:14
w3wdatmd::tice
integer, dimension(:), pointer tice
Definition: w3wdatmd.F90:172
w3gdatmd::trny
real, dimension(:,:), pointer trny
Definition: w3gdatmd.F90:1200
w3iosfmd
I/O and computational routines for the wave-field separation output.
Definition: w3iosfmd.F90:16
w3iopomd
Process point output.
Definition: w3iopomd.F90:19
w3adatmd::tauocx
real, dimension(:), pointer tauocx
Definition: w3adatmd.F90:607
w3idatmd::tgn
integer, dimension(:), pointer tgn
Definition: w3idatmd.F90:236
pdlib_w3profsmd
Definition: w3profsmd_pdlib.F90:4
pdlib_w3profsmd::apply_boundary_condition_va
subroutine apply_boundary_condition_va
Definition: w3profsmd_pdlib.F90:5026
w3parall::init_get_isea
subroutine init_get_isea(ISEA, JSEA)
Set ISEA for all schemes.
Definition: w3parall.F90:1398
w3idatmd::tcn
integer, dimension(:), pointer tcn
Definition: w3idatmd.F90:236
w3adatmd::dhdx
real, dimension(:), pointer dhdx
Definition: w3adatmd.F90:631
w3idatmd::flic1
logical, pointer flic1
Definition: w3idatmd.F90:264
w3sic3md
Definition: w3sic3md.F90:3
w3psmcmd::w3krtn
subroutine w3krtn(ISEA, FACTH, FACK, CTHG0, CG, WN, DEPTH, DDDX, DDDY, ALFLMT, CX, CY, DCXDX, DCXDY, DCYDX, DCYDY, DCDX, DCDY, VA)
Refraction and great-circle turning by spectral rotation.
Definition: w3psmcmd.F90:969
w3gdatmd::dtmax
real, pointer dtmax
Definition: w3gdatmd.F90:1183
w3gdatmd::flagll
logical, pointer flagll
Definition: w3gdatmd.F90:1219
w3pro1md::w3ktp1
subroutine w3ktp1(ISEA, FACTH, FACK, CTHG0, CG, WN, DEPTH, DDDX, DDDY, CX, CY, DCXDX, DCXDY, DCYDX, DCYDY, DCDX, DCDY, VA)
Propagation in spectral space.
Definition: w3pro1md.F90:900
w3wdatmd::asf
real, dimension(:), pointer asf
Definition: w3wdatmd.F90:183
w3gdatmd::filext
character(len=13), pointer filext
Definition: w3gdatmd.F90:1224
w3psmcmd::smcdcxy
subroutine smcdcxy
Calculates current velocity gradient for refraction.
Definition: w3psmcmd.F90:3042