WAVEWATCH III  beta 0.0.1
ww3_grib.F90
Go to the documentation of this file.
1 
8 !
9 #include "w3macros.h"
10 !/ ------------------------------------------------------------------- /
26 !
27 PROGRAM w3grib
28  !/
29  !/ +-----------------------------------+
30  !/ | WAVEWATCH III NOAA/NCEP |
31  !/ | H. L. Tolman |
32  !/ | A. Chawla |
33  !/ | J.-H. Alves |
34  !/ | FORTRAN 90 |
35  !/ | Last update : 22-Mar-2021 |
36  !/ +-----------------------------------+
37  !/
38  !/ 01-Nov-1999 : Final FORTRAN 77 ( version 1.18 + error fix )
39  !/ 24-Jan-2000 : Upgrade to FORTRAN 90 ( version 2.00 )
40  !/ 25-Jan-2001 : Flat grid error exit added ( version 2.06 )
41  !/ 29-Apr-2002 : Adding output fields 17-18. ( version 2.20 )
42  !/ 08-May-2002 : Replace XLF switch with NCEP1. ( version 2.21 )
43  !/ 13-Nov-2002 : Add stress vector. ( version 3.00 )
44  !/ 24-Dec-2004 : Multiple grid version. ( version 3.06 )
45  !/ 20-Jul-2005 : Additional output parameters. ( version 3.07 )
46  !/ 11-Apr-2007 : Additional output parameters. ( version 3.11 )
47  !/ 18-May-2007 : Update GRIB1 for partitioning. ( version 3.11 )
48  !/ 16-Jul-2007 : Adding GRIB2 capability. ( version 3.11 )
49  !/ (A. Chawla)
50  !/ 01-Aug-2007 : Update FLGRIB for GRIB2. ( version 3.11 )
51  !/ 29-May-2009 : Preparing distribution version. ( version 3.14 )
52  !/ 30-Oct-2009 : Implement run-time grid selection. ( version 3.14 )
53  !/ (W. E. Rogers & T. J. Campbell, NRL)
54  !/ 05-Oct-2011 : Updating to the 53 output parameter ( version 4.05 )
55  !/ (Arun Chawla)
56  !/ 01-Mar-2013 : Adding double-index output fields ( version 4.11 )
57  !/ (J-Henrique Alves)
58  !/ 01-Dec-2016 : Adding lambert conformal grid ( version 6.01 )
59  !/ (J.H. Alves)
60  !/ 26-Jul-2018 : Adding polar stereographic grid ( version 6.05 )
61  !/ (J.H. Alves)
62  !/ 22-Mar-2021 : New coupling fields output ( version 7.13 )
63  !/ 09-Jun-2021 : remove grib1 support (NCEP1) ( version 7.14 )
64  !/
65  !/ Copyright 2009 National Weather Service (NWS),
66  !/ National Oceanic and Atmospheric Administration. All rights
67  !/ reserved. WAVEWATCH III is a trademark of the NWS.
68  !/ No unauthorized use without permission.
69  !/
70  ! 1. Purpose :
71  !
72  ! Post-processing of grid output.
73  !
74  ! 2. Method :
75  !
76  ! Data is read from the grid output file out_grd.ww3 (raw data)
77  ! and from the file ww3_grib.inp ( NDSI, output requests ).
78  ! Model definition and raw data files are read using WAVEWATCH III
79  ! subroutines.
80  ! GRIB packing is performed using NCEP's W3 library (not supplied).
81  !
82  ! When adding new parameters to GRIB packing, keep in mind that
83  ! packing is done differently for scalar and vector quantities
84  !
85  ! 3. Parameters :
86  !
87  ! 4. Subroutines used :
88  !
89  ! Name Type Module Description
90  ! ----------------------------------------------------------------
91  ! W3NMOD Subr. W3GDATMD Set number of model.
92  ! W3SETG Subr. Id. Point to selected model.
93  ! W3NDAT Subr. W3WDATMD Set number of model for wave data.
94  ! W3SETW Subr. Id. Point to selected model for wave data.
95  ! W3NAUX Subr. W3ADATMD Set number of model for aux data.
96  ! W3SETA Subr. Id. Point to selected model for aux data.
97  ! ITRACE Subr. W3SERVMD Subroutine tracing initialization.
98  ! STRACE Subr. Id. Subroutine tracing.
99  ! NEXTLN Subr. Id. Get next line from input filw
100  ! EXTCDE Subr. Id. Abort program as graceful as possible.
101  ! STME21 Subr. W3TIMEMD Convert time to string.
102  ! TICK21 Subr. Id. Advance time.
103  ! DSEC21 Func. Id. Difference between times.
104  ! W3IOGR Subr. W3IOGRMD Reading/writing model definition file.
105  ! W3IOGO Subr. W3IOGOMD Reading/writing raw gridded data file.
106  ! W3READFLGRD Subr. W3IOGOMD Reading output fields flags.
107  ! W3EXGB Subr. Internal Execute grib output.
108  ! BAOPEN Subr. NCEP library routine.
109  ! BAOPENW Subr. NCEP library routine.
110  ! ----------------------------------------------------------------
111  !
112  ! 5. Called by :
113  !
114  ! None, stand-alone program.
115  !
116  ! 6. Error messages :
117  !
118  ! Checks on input, checks in W3IOxx.
119  !
120  ! 7. Remarks :
121  !
122  ! 8. Structure :
123  !
124  ! See source code.
125  !
126  ! 9. Switches :
127  !
128  ! !/S Enable subroutine tracing.
129  !
130  ! !/NCO NCEP NCO modifications for operational implementation.
131  !
132  ! !/NOGRB No GRIB package included.
133  ! !/NCEP2 NCEP IBM links to GRIB2 packing routines.
134  !
135  ! 10. Source code :
136  !
137  !/ ------------------------------------------------------------------- /
138  USE constants
139  !
140  ! USE W3GDATMD, ONLY: W3NMOD, W3SETG
141  USE w3wdatmd, ONLY: w3ndat, w3setw
142  ! USE W3ADATMD, ONLY: W3NAUX, W3SETA
143  USE w3odatmd, ONLY: w3nout, w3seto
144  USE w3iogrmd, ONLY: w3iogr
145  USE w3iogomd, ONLY: w3readflgrd, w3iogo
146  USE w3servmd, ONLY : itrace, nextln, extcde
147 #ifdef W3_S
148  USE w3servmd, ONLY : strace
149 #endif
150  USE w3timemd, ONLY: stme21, tick21, dsec21
151  !
152  USE w3gdatmd
153  USE w3wdatmd, ONLY: time, wlv, ice, ust, ustdir, rhoair
154  USE w3adatmd
155  USE w3odatmd, ONLY: ndse, ndst, ndso, nogrp, ngrpp, idout, undef,&
157  !
158  IMPLICIT NONE
159  !/
160  !/ ------------------------------------------------------------------- /
161  !/ Local variables
162  !/
163  INTEGER :: ndsi, ndsm, ndsog, ndsdat, ndstrc, &
164  ntrace, ierr, iotest, i,j,k, ifi,ifj,&
165  isea, ix, iy, tout(2), nout, tdum(2),&
166  ftime(2), cid, pid, gid, gds, iout, &
167  gdtn
168  INTEGER, ALLOCATABLE :: ifia(:),ifja(:)
169 #ifdef W3_NOGRB
170  INTEGER :: kpds(1), kgds(1)
171 #endif
172  ! GRIB2 specific variables
173 #ifdef W3_NCEP2
174  INTEGER :: kpds(200), kgds(200), idrs(200)
175  INTEGER :: listsec0(3), listsec1(13),igds(5)
176  INTEGER :: ideflist, idefnum, kpdsnum, numcoord
177  INTEGER :: ibmp, lcgrib, lengrib, idrsnum
178  REAL :: coordlist, xn
179  CHARACTER(LEN=1), ALLOCATABLE :: cgrib(:)
180  INTEGER :: latan1, lonv, scnmod, latin1, &
181  latin2, latsp, lonsp
182  REAL :: dsx, dsy
183  REAL :: yn, x0n, y0n
184 #endif
185 #ifdef W3_S
186  INTEGER, SAVE :: ient = 0
187 #endif
188  REAL :: dtreq, dtest, rftime
189  LOGICAL :: flreq(nogrp,ngrpp), flgrib(nogrp,ngrpp)
190  CHARACTER :: comstr*1, idtime*23, iddday*11
191  CHARACTER(LEN=80) :: linein
192  CHARACTER(LEN=8) :: words(5)
193  INTEGER :: gen_pro
194 
195  !/
196  !/ ------------------------------------------------------------------- /
197  !/
198 #ifdef W3_NCO
199  ! CALL W3TAGB('WAVEGRIB',1998,0007,0050,'NP21 ')
200 #endif
201  !
202  !--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
203  ! 1. IO set-up.
204  !
205  CALL w3nmod ( 1, 6, 6 )
206  CALL w3setg ( 1, 6, 6 )
207  CALL w3ndat ( 6, 6 )
208  CALL w3setw ( 1, 6, 6 )
209  CALL w3naux ( 6, 6 )
210  CALL w3seta ( 1, 6, 6 )
211  CALL w3nout ( 6, 6 )
212  CALL w3seto ( 1, 6, 6 )
213  !
214  ndsi = 10
215  ndsm = 20
216  ndsog = 20
217  ndsdat = 50
218  !
219  ndstrc = 6
220  ntrace = 10
221  !
222 #ifdef W3_NCO
223  !
224  ! Redo according to NCO
225  !
226  ndsi = 11
227  ndso = 6
228  ndse = ndso
229  ndst = ndso
230  ndsm = 12
231  ndsog = 13
232  ndsdat = 51
233  ndstrc = ndso
234 #endif
235  !
236  WRITE (ndso,900)
237  !
238  CALL itrace ( ndstrc, ntrace )
239 #ifdef W3_S
240  CALL strace (ient, 'W3GRIB')
241 #endif
242  !
243  OPEN (ndsi,file='ww3_grib.inp',status='OLD',err=800,iostat=ierr)
244  READ (ndsi,'(A)',END=801,ERR=802) comstr
245  IF (comstr.EQ.' ') comstr = '$'
246  WRITE (ndso,901) comstr
247  !
248 #ifdef W3_NOGRB
249  WRITE (ndse,902)
250 #endif
251 #ifdef W3_NCEP2
252  CALL baopenw (ndsdat,'gribfile',ierr)
253 #endif
254  !
255  !--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
256  ! 2. Read model definition file.
257  !
258  CALL w3iogr ( 'READ', ndsm )
259  WRITE (ndso,920) gname
260  !
261  IF ( .NOT. flagll ) GOTO 810
262  !
263  !--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
264  ! 3. Read requests from input file.
265  ! Output times
266  !
267  CALL nextln ( comstr , ndsi , ndse )
268  READ (ndsi,'(A)') linein
269  WRITE(ndso,*)' LINEIN: ',linein
270  READ(linein,*,iostat=ierr) words
271  WRITE (ndso,*) words
272  READ(words( 1 ), * ) tout(1)
273  READ(words( 2 ), * ) tout(2)
274  READ(words( 3 ), * ) dtreq
275  READ(words( 4 ), * ) nout
276  IF (words(5) .NE. '0' .AND. words(5) .NE. '1') THEN
277  gen_pro=-99999
278  ELSE
279  READ(words( 5 ), * ) gen_pro
280  ENDIF
281  WRITE(ndso,*) 'GEN_PRO ',gen_pro
282  dtreq = max( 0. , dtreq )
283  IF ( dtreq.EQ.0 ) nout = 1
284  nout = max( 1 , nout )
285  !
286  CALL stme21 ( tout , idtime )
287  WRITE (ndso,940) idtime
288  !
289  tdum(1) = 0
290  tdum(2) = 0
291  CALL tick21 ( tdum , dtreq )
292  CALL stme21 ( tdum , idtime )
293  IF ( dtreq .GE. 86400. ) THEN
294  WRITE (iddday,'(I10,1X)') int(dtreq/86400.)
295  ELSE
296  iddday = ' '
297  END IF
298  idtime(1:11) = iddday
299  idtime(21:23) = ' '
300  WRITE (ndso,941) idtime, nout
301  !
302  ! ... Initialize FLGRD array
303  !
304  flreq(:,:)=.false.
305  !
306  ! ... Call to interface for reading flags or namelists
307  !
308  CALL w3readflgrd ( ndsi, ndso, 9, ndse, comstr, flogd, flreq, &
309  1, 1, ierr )
310  !
311  ! Inform user of parameters that were requested but failed to make the
312  ! grade, as they are not available for grib encoding, or are not
313  ! included presently
314  !
315  WRITE (ndso,944)
316  ! Reset flags for variables not yet implemented in grib output
317  ! interface
318  !
319  !
320  ifi = 3 ! Entire group Frequency-dependent parameters
321  DO ifj = 1,noge(ifi)
322  IF ( flreq(ifi,ifj) ) THEN
323  WRITE (ndso,946) idout(ifi,ifj), &
324  '*** NOT YET CODED INTO WW3_GRIB ***'
325  flreq(ifi,ifj) = .false.
326  END IF
327  END DO
328  !
329  ifi = 5 ! Atm-waves layer, all except for friction velocity
330  DO ifj = 2,10
331  IF ( flreq(ifi,ifj) ) THEN
332  WRITE (ndso,946) idout(ifi,ifj), &
333  '*** NOT YET CODED INTO WW3_GRIB ***'
334  flreq(ifi,ifj) = .false.
335  END IF
336  END DO
337  DO ifi = 6,8 ! Entire groups wave-ocean interaction, wave-bottom
338  ! layer and spectrum parameters
339  DO ifj = 1,noge(ifi)
340  IF ( flreq(ifi,ifj) ) THEN
341  WRITE (ndso,946) idout(ifi,ifj), &
342  '*** NOT YET CODED INTO WW3_GRIB ***'
343  flreq(ifi,ifj) = .false.
344  END IF
345  END DO
346  END DO
347  IF ( flreq(9,5) ) THEN ! CFL number for K advection
348  WRITE (ndso,946) idout(9,5),'*** NOT YET CODED INTO WW3_GRIB ***'
349  flreq(9,5) = .false.
350  END IF
351  ifi = 10 ! User defined parameters
352  DO ifj = 1,noge(ifi)
353  IF ( flreq(ifi,ifj) ) THEN
354  WRITE (ndso,946) idout(ifi,ifj), &
355  '*** NOT YET CODED INTO WW3_GRIB ***'
356  flreq(ifi,ifj) = .false.
357  END IF
358  END DO
359  !
360  ! Compatibility with NCEP operational codes, same effect as old FLGRIB
361  ! lists variables that have no code for variable names (not 100%
362  ! correct in old codes... )
363  !
364  ! Chage this as parameters become available in grib2 tables
365  !
366  ALLOCATE ( ifia(13), ifja(13) )
367 
368  ifia = (/ 1, 2, 2, 4, 4, 4, 4, 4, 5, 9, 9, 9, 9 /)
369  ifja = (/ 4, 2, 8, 3, 5, 6, 7, 8, 1, 1, 2, 3, 4 /)
370  DO i = 1, 13
371  IF ( flreq(ifia(i),ifja(i)) ) THEN
372  flreq(ifia(i),ifja(i)) = .false.
373  WRITE(ndso,946) idout(ifia(i),ifja(i)), &
374  '*** EXCLUDED FROM GRIB OUTPUT ***'
375  END IF
376  END DO
377  !
378  ! Write to stdout parameters that have successfully been requested
379  !
380  WRITE (ndso,945)
381  DO i=1, nogrp
382  DO j=1, ngrpp
383  IF ( flreq(i,j) ) WRITE (ndso,931) idout(i,j)
384  END DO
385  END DO
386  !
387  !
388  !
389  ! ... GRIB specific parameters
390  !
391  CALL nextln ( comstr , ndsi , ndse )
392  READ (ndsi,*,END=801,ERR=802) FTIME, CID, PID, GID, GDS, gdtn
393  !
394  ! Check if grid type is curvilinear, and only go on if Lambert conformal
395  ! or PolarStereo
396  !
397  IF ( gtype .EQ. clgtype ) THEN
398 #ifdef W3_NCEP2
399  ! Allowing code to work with Lambert conformal grids
400  IF ( gdtn .NE. 30 .AND. gdtn .NE. 20 ) THEN
401 #endif
402  WRITE(ndse,*)'PROGRAM W3GRIB: CURVILINEAR GRID SUPPORT '// &
403  'FOR GRIB OUTPUT IS NOT YET IMPLEMENTED. NOW STOPPING'
404  CALL extcde ( 1 )
405 #ifdef W3_NCEP2
406  ENDIF
407 #endif
408  END IF
409  !
410  !
411  ! Coded up to now only for Lamber conformal grids (GDTN=30) or
412  ! PolarStereo (GDTN=20). For regular grids use GDTN=0
413  !
414 #ifdef W3_NCEP2
415  IF ( gdtn .EQ. 30 ) THEN
416  ! This is a Lambert conformal grid, read projection parameters
417  CALL nextln ( comstr , ndsi , ndse )
418  READ (ndsi,*,END=801,ERR=802) LATAN1, LONV, DSX, DSY, &
419  scnmod, latin1, latin2, latsp, lonsp
420  ELSEIF ( gdtn .EQ. 20 ) THEN
421  CALL nextln ( comstr , ndsi , ndse )
422  READ (ndsi,*,END=801,ERR=802) LATAN1, LONV, DSX, DSY, &
423  scnmod
424 #endif
425 
426 #ifdef W3_NCEP2
427  ENDIF
428 #endif
429  !
430  CALL stme21 ( ftime , idtime )
431  WRITE (ndso,948) idtime, cid, pid, gid, gds
432  !
433  !
434  !--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
435  ! 4. Read general data and first fields from file
436  ! 4.a Read file.
437  !
438  CALL w3iogo ( 'READ', ndsog, iotest )
439  !
440  ! 4.b Output fields in file
441  !
442  !
443  WRITE (ndso,930)
444  DO i=1, nogrp
445  DO j=1, ngrpp
446  IF ( flogrd(i,j) ) WRITE (ndso,931) idout(i,j)
447  END DO
448  END DO
449  !
450 #ifdef W3_NCEP2
451  !
452  IF ( gdtn .EQ. 0 ) THEN
453  !
454 #endif
455  ! 4.c Flip MAPSF for REGULAR/RECTILINEAR grids
456  !
457  DO isea=1, nsea
458  ix = mapsf(isea,1)
459  iy = mapsf(isea,2)
460  mapsf(isea,2) = ny + 1 - iy
461  mapsf(isea,3) = iy +( ix-1)*ny
462  END DO
463 #ifdef W3_NCEP2
464  !
465  ENDIF
466 #endif
467  !
468  !--- - - - - - - - - - - - - - - - - - - - - - - - - -
469  ! 5. Set grib encoding parameter Sections
470  !
471  ! ... Initialize KPDS and KGDS (for NCEP2)
472  !
473  kpds = 0
474  kgds = 0
475  !
476  ! ... Set GRIB2 packing arrays
477  !
478 #ifdef W3_NCEP2
479  lcgrib = 4*nx*ny
480  ALLOCATE(cgrib(lcgrib))
481 #endif
482  !
483  ! ... Set GRIB2 Indicator Section
484  ! ( 1) Discipline-GRIB Master Table Number (see Code Table 0.0)
485  ! 0 = Metereological; 10 = Oceanographic
486  ! ( 2) GRIB Edition Number
487  ! ( 3)
488 #ifdef W3_NCEP2
489  listsec0 = 0
490  listsec0(1) = 10
491  listsec0(2) = 2
492 #endif
493  !
494  ! ... Set GRIB2 Identification Section
495  ! ( 1) ID OF CENTER
496  ! ( 2) ID OF SUB-CENTER
497  ! ( 3) GRIB Master Tables Version Number (Code Table 1.0)
498  ! ( 4) GRIB Local Tables Version Number (Code Table 1.0)
499  ! ( 5) Significance of Reference Time (Code Table 1.2)
500  ! * ( 6) YEAR (4 digits)
501  ! * ( 7) MONTH OF YEAR
502  ! * ( 8) DAY OF MONTH
503  ! * ( 9) HOUR OF DAY
504  ! (10) MINUTE OF HOUR
505  ! (11) SECOND OF MINUTE
506  ! (12) Production status of data (Code Table 1.3)
507  ! (13) Type of processed data (Code Table 1.4)
508  !
509 #ifdef W3_NCEP2
510  listsec1 = 0
511  listsec1(1) = cid
512  listsec1(3) = 2
513  listsec1(4) = 1
514  listsec1(5) = 1
515  listsec1(13) = 1
516 #endif
517  !
518  ! ... Set GRIB2 IGDS elements
519  ! ( 1) Source of grid definition (Code Table 3.0)
520  ! ( 2) Number of grid points
521  ! ( 3) Number of octets needed for each additional grid points definition
522  ! ( 4) Interpretation of list for optional points definition (Code Table 3.11)
523  ! ( 5) Grid definition template number (Code Table 3.1)
524  !
525 #ifdef W3_NCEP2
526  igds = 0 ! Defined in code
527  igds(2) = nx*ny
528  idefnum = 0
529  ideflist = 0
530  igds(5)=gdtn
531  IF ( gdtn .EQ. 30 .AND. gtype .EQ. clgtype ) THEN
532  idefnum = 1
533  WRITE (ndso,1011) 'LAMBERTCONF'
534  ELSEIF ( gdtn .EQ. 20 .AND. gtype .EQ. clgtype ) THEN
535  WRITE (ndso,1011) 'POLARSTEREO'
536  ELSEIF ( gdtn .EQ. 0 ) THEN
537  WRITE (ndso,1011) 'LLRECTILINEAR'
538  ELSE
539  WRITE(ndse,*)'PROGRAM WAVEGRIB2: SUPPORT FOR CHOSEN '// &
540  'GRIB2 GRID DEFINITION TEMPLATE NOT YET IMPLEMENTED'
541  CALL extcde ( 2 )
542  ENDIF
543 #endif
544  !
545  ! ... Set GRIB2 KGDS elements
546  !
547  ! General parameters for all grids
548  ! ( 1) Coordinate system (6 = spherical coordinate system with radius of 6,371,229 m)
549  ! ( 2)
550  ! ( 3)
551  ! ( 4)
552  ! ( 5)
553  ! ( 6)
554  ! ( 7)
555  ! ( 8) Number of points along parallel
556  ! ( 9) Number of points along meridian
557 #ifdef W3_NCEP2
558  kgds( 1) = 6
559  kgds( 8) = nx
560  kgds( 9) = ny
561 #endif
562  !
563 #ifdef W3_NCEP2
564  IF ( gdtn .EQ. 30 ) THEN
565 #endif
566  !
567  ! Lambert Conformal grid
568  ! (10) Latitude of first grid point
569  ! (11) Longitude of first grid point
570  ! (12) Resolution and component flags
571  ! (13) Latitude where DX and DY are specified
572  ! (14) Longitude of orientation
573  ! (15) Increment of longitude
574  ! (16) Increment of latitude
575  ! (17) Projection center flag
576  ! (18) Scanning mode
577  ! (19) First latitude of secant cone
578  ! (20) Second latitude of secant cone
579  ! (21) Latitude of southern pole
580  ! (22) Longitude of southern pole
581  !
582 #ifdef W3_NCEP2
583  x0 = mod(xgrd(1,1) + 360.,360.)
584  xn = mod(xgrd(ny,nx) + 360., 360.)
585  x0n = mod(xgrd(ny,1) + 360., 360.)
586  kgds(11)=nint(1000000.*x0)
587  y0 = ygrd(1,1)
588  yn = ygrd(ny,nx)
589  y0n = ygrd(ny,1)
590  kgds(10)=nint(1000000.*y0)
591  kgds(12)=0
592  kgds(13)=dble(1000000.*latan1)
593  kgds(14)=dble(1000000.*lonv)
594  kgds(15)=nint(1000000*dsx)
595  kgds(16)=nint(1000000*dsy)
596  kgds(17)=0
597  kgds(18)=scnmod
598  kgds(19)=dble(1000000.*latin1)
599  kgds(20)=dble(1000000.*latin2)
600  kgds(21)=dble(1000000.*latsp)
601  kgds(22)=dble(1000000.*lonsp)
602 #endif
603  !
604 #ifdef W3_NCEP2
605  ELSEIF (gdtn .EQ. 20 ) THEN
606 #endif
607  !
608  ! PolarStereo grid
609  ! (10) Latitude of first grid point
610  ! (11) Longitude of first grid point
611  ! (12) Res and component flags
612  ! (13) Latitude where DX and DY are specified
613  ! (14) Longitude of orientation
614  ! (15) Increment of longitude
615  ! (16) Increment of latitude
616  ! (17) Projection center flag
617  ! (18) Scanning mode
618  !
619  ! Projection for PolarStereo grid was changed from
620  ! KGDS( 1) = 6 to KGDS( 1) = 5 (Earth assumed represented by WGS84 -
621  ! Octet No 15 Table 3.2)
622 #ifdef W3_NCEP2
623  kgds( 1) = 5
624  x0 = mod(xgrd(1,1) + 360.,360.)
625  xn = mod(xgrd(ny,nx) + 360., 360.)
626  x0n = mod(xgrd(ny,1) + 360., 360.)
627  kgds(11)=nint(1000000.*x0)
628  y0 = ygrd(1,1)
629  yn = ygrd(ny,nx)
630  y0n = ygrd(ny,1)
631  kgds(10)=nint(1000000.*y0)
632  kgds(12)=0
633  kgds(13)=dble(1000000.*latan1)
634  kgds(14)=dble(1000000.*lonv)
635  kgds(15)=nint(1000000*dsx)
636  kgds(16)=nint(1000000*dsy)
637  kgds(17)=0
638  kgds(18)=scnmod
639 #endif
640  !
641 #ifdef W3_NCEP2
642  ELSEIF (gdtn .EQ. 0 ) THEN
643 #endif
644  !
645  ! Lat Lon rectilinear grid
646  ! (10)
647  ! (11)
648  ! (12) Latitude of first grid point
649  ! (13) Longitude of first grid point
650  ! (14) Res and component flags
651  ! (15) Latitude of last grid point
652  ! (16) Longitude of last grid point
653  ! (17) Increment of longitude
654  ! (18) Increment of latitude
655  ! (19) Scanning mode
656  !
657 #ifdef W3_NCEP2
658  kgds(12) = nint(1000000.*(y0+(real(ny-1)*sy)))
659  x0 = mod(x0 + 360.,360.)
660  kgds(13) = nint(1000000.*x0)
661  kgds(14) = 48
662  kgds(15) = nint(1000000.*y0)
663  xn = mod(x0+real(nx-1)*sx + 360., 360.)
664  kgds(16) = nint(1000000.*xn)
665  kgds(17) = nint(1000000.*sx)
666  kgds(18) = nint(1000000.*sy)
667  ENDIF
668 #endif
669  !
670  ! ... Set GRIB2 PDS elements
671  ! KPDSNUM (0 indicates forecast at a horizontal level)
672  ! ( 1) Parameter category (Code Table 4.1)
673  ! For oceanographic products -- 0 = waves; 1 = currents; 2 = ice
674  ! For atmospheric products -- 2 = momentum
675  ! ( 2) Parameter number (Code Table 4.2)
676  ! ( 3) Generating process (Code Table 4.3)
677  ! ( 4) Background generating process identifier (center specific)
678  ! ( 5) Process or model number
679  ! ( 6) Hours of observational data cutoff after reference time
680  ! ( 7) Minutes of observational data cutoff after reference time
681  ! ( 8) Indicator of forecast time unit (Code Table 4.4)
682  ! ( 9) Time range
683  ! (10) Type of level (Code Table 4.5) 1st level
684  ! (11) Scaled factor of (10)
685  ! (12) Scaled value of (10)
686  ! (13) Type of level (Code Table 4.5) 2nd level
687  ! (14) Scaled factor of (13)
688  ! (15) Scaled value of (13)
689  !
690  !
691  ! KPDS(3)=4 ensemble forecast:ww3_grib.inp has gen_pro set to 1
692  ! =2 deterministic forecast: ww3_grib.inp gen_pro set to 0
693  ! =2 legacy :with no gen_pro set in ww3_grib.inp
694  ! (in the case of legacy the params revert back to old names)
695 #ifdef W3_NCEP2
696  kpdsnum = 0
697  if ( gen_pro.eq.1 ) then
698  kpds( 3) = 4
699  else
700  kpds(3)=2
701  endif
702  kpds( 4) = 0
703  kpds( 5) = pid
704  kpds( 8) = 1
705  kpds(10) = 1
706  kpds(12) = 1
707  kpds(13) = 255
708 #endif
709  !
710  ! ... Set GRIB2 vertical layer information
711  !
712 #ifdef W3_NCEP2
713  numcoord = 0
714  coordlist = 0.0
715 #endif
716  !
717  ! ... Set GRIB2 bitmap information
718  ! 0 Bitmap is provided
719  !
720 #ifdef W3_NCEP2
721  ibmp = gds
722 #endif
723  !
724  ! ... Set GRIB2 Data Representation Template Number (Code Table 5.0)
725  !
726 #ifdef W3_NCEP2
727  idrsnum = 40 !jpeg2000 *** SEGFAULTS in some linux
728 #endif
729  ! clusters with Intel compiler ***
730 #ifdef W3_NCEP2
731  !IDRSNUM = 0 !simple packing
732  !IDRSNUM = 41 !png packing
733  !IDRSNUM = 2 !Complex Packing (Grid Point Data)
734 #endif
735  !
736  ! ... Set GRIB2 IDRS elements
737  ! ( 1) Reference value (R) (IEEE 32-bit floating-point value)
738  ! ( 2) Binary Scale Factor (E)
739  ! ( 3) Decimal Scale Factor (D)
740  ! ( 4) Number of bits used for each packed value
741  ! ( 5) Type of original field values (Code Table 5.1)
742  !
743 #ifdef W3_NCEP2
744  idrs = 0
745  idrs(3) = 2
746 #endif
747  !
748 #ifdef W3_T
749  WRITE (ndst,9050) kpds
750  WRITE (ndst,9051) kgds
751 #endif
752  !
753  !--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
754  ! 6. Time management.
755  !
756  iout = 0
757  WRITE (ndso,970)
758  !
759  DO
760  dtest = dsec21( time , tout )
761  IF ( dtest .GT. 0. ) THEN
762  CALL w3iogo ( 'READ', ndsog, iotest )
763  IF ( iotest .EQ. -1 ) THEN
764  WRITE (ndso,942)
765  GOTO 888
766  END IF
767  cycle
768  END IF
769  IF ( dtest .LT. 0. ) THEN
770  CALL tick21 ( tout , dtreq )
771  cycle
772  END IF
773  !
774  iout = iout + 1
775  CALL stme21 ( tout , idtime )
776  !
777  rftime = dsec21( ftime , time ) / 3600.
778  IF ( rftime .LT. 0. ) THEN
779 #ifdef W3_NCEP2
780  listsec1( 6) = time(1)/10000
781  listsec1( 7) = mod(time(1),10000) / 100
782  listsec1( 8) = mod(time(1),100)
783  listsec1( 9) = time(2) / 10000
784  kpds( 9) = 0
785 #endif
786  WRITE (ndso,972) idtime
787  ELSE
788 #ifdef W3_NCEP2
789  listsec1( 6) = ftime(1)/10000
790  listsec1( 7) = mod(ftime(1),10000) / 100
791  listsec1( 8) = mod(ftime(1),100)
792  listsec1( 9) = ftime(2) / 10000
793  kpds( 9) = nint(rftime)
794 #endif
795  WRITE (ndso,971) idtime, nint(rftime)
796  END IF
797  !
798  CALL w3exgb ( nx, ny, nsea )
799  CALL tick21 ( tout , dtreq )
800  IF ( iout .GE. nout ) EXIT
801  END DO
802  !
803  GOTO 888
804  !
805  ! Escape locations read errors :
806  !
807 800 CONTINUE
808  WRITE (ndse,1000) ierr
809  CALL extcde ( 3 )
810  !
811 801 CONTINUE
812  WRITE (ndse,1001)
813  CALL extcde ( 4 )
814  !
815 802 CONTINUE
816  WRITE (ndse,1002) ierr
817  CALL extcde ( 5 )
818  !
819 810 CONTINUE
820  IF ( .NOT. flagll ) THEN
821  WRITE (ndse,1010)
822  CALL extcde ( 10 )
823  END IF
824  !
825 888 CONTINUE
826  WRITE (ndso,999)
827  !
828 #ifdef W3_NCO
829  ! CALL W3TAGE('WAVEGRIB')
830 #endif
831  !
832  ! Formats
833  !
834 900 FORMAT (/15x,' *** WAVEWATCH III GRIB output postp. *** '/ &
835  15x,'=============================================='/)
836 901 FORMAT ( ' Comment character is ''',a,''''/)
837 902 FORMAT (/' *** WARNING : NO GRIB PACKAGE LINKED ***'/)
838  !
839 920 FORMAT ( ' Grid name : ',a/)
840  !
841 930 FORMAT ( ' Fields in file : '/ &
842  ' --------------------------')
843 931 FORMAT ( ' ',a)
844  !
845 940 FORMAT (/' Output time data : '/ &
846  ' -----------------------------------------------------'/ &
847  ' First time : ',a)
848 941 FORMAT ( ' Interval : ',a/ &
849  ' Number of requests : ',i4)
850 942 FORMAT (/' End of file reached '/)
851  !
852 944 FORMAT (/' Requested output fields not yet available: '/ &
853  ' -----------------------------------------------------')
854  !
855 945 FORMAT (/' Successfully requested output fields : '/ &
856  ' -----------------------------------------------------')
857 946 FORMAT ( ' ',a,1x,a)
858  !
859 948 FORMAT (/' Additional GRIB parameters : '/ &
860  ' -----------------------------------------------------'/ &
861  ' Run time : ',a/ &
862  ' GRIB center ID : ',i4/ &
863  ' GRIB gen. proc. ID : ',i4/ &
864  ' GRIB grid ID : ',i4/ &
865  ' GRIB GDS parameter : ',i4)
866  !
867 970 FORMAT (//' Generating file '/ &
868  ' -----------------------------------------------------')
869 971 FORMAT ( ' Data for ',a,' ',i3,'H forecast.')
870 972 FORMAT ( ' Data for ',a,' hindcast.')
871  !
872 999 FORMAT (/' End of program '/ &
873  ' ========================================='/ &
874  ' WAVEWATCH III GRIB output '/)
875  !
876 #ifdef W3_T
877 9050 FORMAT ( ' TEST W3GRIB : KPDS : ',13i4/ &
878  ' ',12i4)
879 9051 FORMAT ( ' TEST W3GRIB : KGDS : ',8i6/ &
880  ' ',8i6/ &
881  ' ',6i6)
882 #endif
883  !
884 1000 FORMAT (/' *** WAVEWATCH III ERROR IN W3GRIB : '/ &
885  ' ERROR IN OPENING INPUT FILE'/ &
886  ' IOSTAT =',i5/)
887  !
888 1001 FORMAT (/' *** WAVEWATCH III ERROR IN W3GRIB : '/ &
889  ' PREMATURE END OF INPUT FILE'/)
890  !
891 1002 FORMAT (/' *** WAVEWATCH III ERROR IN W3GRIB : '/ &
892  ' ERROR IN READING FROM INPUT FILE'/ &
893  ' IOSTAT =',i5/)
894  !
895 1010 FORMAT (/' *** WAVEWATCH-III ERROR IN W3GRIB : '/ &
896  ' GRIB REQUIRES SPHERICAL GRID'/)
897 #ifdef W3_NCEP2
898 1011 FORMAT (/' CHOSEN GRID TYPE: : ',a/)
899 #endif
900  !/
901  !/ Internal subroutine W3EXGB ---------------------------------------- /
902  !/
903 CONTAINS
904  !/ ------------------------------------------------------------------- /
914  SUBROUTINE w3exgb ( NX, NY, NSEA )
915  !/
916  !/ +-----------------------------------+
917  !/ | WAVEWATCH III NOAA/NCEP |
918  !/ | H. L. Tolman |
919  !/ | A. Chawla |
920  !/ | FORTRAN 90 |
921  !/ | Last update : 22-Mar-2021 |
922  !/ +-----------------------------------+
923  !/
924  !/ 10-Jun-1999 : Final FORTRAN 77 ( version 1.18 )
925  !/ 24-Jan-2000 : Upgrade to FORTRAN 90 ( version 2.00 )
926  !/ Massive changes to logistics.
927  !/ 29-Apr-2002 : Adding output fields 17-18. ( version 2.20 )
928  !/ 24-Dec-2004 : Multiple grid version. ( version 3.06 )
929  !/ 18-May-2007 : Update GRIB1 for partitioning. ( version 3.11 )
930  !/ 16-Jul-2007 : Adding GRIB2 capability ( version 3.11 )
931  !/ (A. Chawla)
932  !/ 22-Mar-2021 : New coupling fields output ( version 7.13 )
933  !/
934  ! 1. Purpose :
935  !
936  ! Perform actual GRIB output.
937  !
938  ! 3. Parameters :
939  !
940  ! Parameter list
941  ! ----------------------------------------------------------------
942  ! NX, NY, NSEA
943  ! Int. I Array dimensions.
944  ! ----------------------------------------------------------------
945  !
946  ! Internal parameters
947  ! ----------------------------------------------------------------
948  ! X1, X2, XX, XY
949  ! R.A. Output fields
950  ! BITMAP L.A. Data / no data bitmap
951  ! ----------------------------------------------------------------
952  !
953  ! 4. Subroutines used :
954  !
955  ! Name Type Module Description
956  ! ----------------------------------------------------------------
957  ! STRACE Subr. W3SERVMD Subroutine tracing.
958  ! EXTCDE Subr. Id. Abort program as graceful as possible.
959  ! W3S2XY Subr. Id. Convert from storage to spatial grid.
960  ! PUTGB Subr. NCEP GRIB1 library routine.
961  ! GRIBCREATE Subr. NCEP GRIB2 library routine.
962  ! ADDGRID Subr. NCEP GRIB2 library routine.
963  ! ADDFIELD Subr. NCEP GRIB2 library routine.
964  ! GRIBEND Subr. NCEP GRIB2 library routine.
965  ! WRYTE Subr. NCEP GRIB2 library routine.
966  ! ----------------------------------------------------------------
967  !
968  ! 5. Called by :
969  !
970  ! Program in which it is contained.
971  !
972  ! 6. Error messages :
973  !
974  ! None.
975  !
976  ! 7. Remarks :
977  !
978  ! - Note that arrays CX and CY of the main program now contain
979  ! the absolute current speed and direction respectively.
980  !
981  ! 8. Structure :
982  !
983  ! See source code.
984  !
985  ! 9. Switches :
986  !
987  ! !/S Enable subroutine tracing.
988  ! !/T Enable test output.
989  ! !/NCEP2 NCEP IBM calls to GRIB2 packer (follows updated grib2
990  ! tables under verification as of 02/10/2012).
991  !
992  ! 10. Source code :
993  !
994  !/ ------------------------------------------------------------------- /
995  USE w3servmd, ONLY : w3s2xy
996 #ifdef W3_RTD
997  USE w3servmd, ONLY : w3thrtn, w3xyrtn
998 #endif
999  !/
1000  !/ ------------------------------------------------------------------- /
1001  !/ Parameter list
1002  !/
1003  INTEGER, INTENT(IN) :: NX, NY, NSEA
1004  !/
1005  !/ ------------------------------------------------------------------- /
1006  !/ Local parameters
1007  !/
1008  INTEGER :: J, IXY, NDATA
1009  INTEGER :: IO
1010 #ifdef W3_S
1011  INTEGER, SAVE :: IENT = 0
1012 #endif
1013  REAL :: X1(NX*NY), X2(NX*NY), XX(NX*NY), &
1014  XY(NX*NY), CABS, UABS, &
1015  YY(NX*NY,0:NOSWLL), KPDS5A, KPDS5B, &
1016  KPDS5A1(3)
1017  LOGICAL*1 :: BITMAP(NX*NY)
1018  LOGICAL :: FLONE, FLTWO, FLDIR, FLTRI, FLPRT
1019  !/
1020  !/ ------------------------------------------------------------------- /
1021  !/
1022 #ifdef W3_S
1023  CALL strace (ient, 'W3EXGB')
1024 #endif
1025  !
1026 #ifdef W3_T
1027  WRITE (ndst,9000) ((flreq(ifi,ifj),ifj=1,ngrpp), ifi=1,nogrp)
1028  WRITE (ndst,9001) ndsdat, kpds, kgds
1029 #endif
1030  !
1031  !--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1032  ! 1. Preparations
1033  !
1034  x1 = undef
1035  x2 = undef
1036  xx = undef
1037  xy = undef
1038  yy = undef
1039  !
1040  !
1041  !--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1042  ! 2. Loop over output fields.
1043  !
1044  DO ifi=1, nogrp
1045  DO ifj=1, ngrpp
1046  IF ( flreq(ifi,ifj) ) THEN
1047 
1048 
1049  !
1050  ! Initialize array dimension flags
1051  !
1052  flone = .false.
1053  fltwo = .false.
1054  fldir = .false.
1055  fltri = .false.
1056  flprt = .false.
1057  !
1058 #ifdef W3_T
1059  WRITE (ndst,9020) idout(ifi,ifj)
1060 #endif
1061  !
1062  ! 2.a Set output arrays and parameters
1063  !
1064  ! Water depth
1065  !
1066  IF ( ifi .EQ. 1 .AND. ifj .EQ. 1 ) THEN
1067  flone = .true.
1068 #ifdef W3_NCEP2
1069  kpds(2) = 14
1070  kpds(1) = 4
1071 #endif
1072  CALL w3s2xy ( nsea, nsea, nx, ny, dw(1:nsea) &
1073  , mapsf, x1 )
1074  !
1075  ! Current
1076  !
1077  ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 2 ) THEN
1078  fltwo = .true.
1079 #ifdef W3_NCEP2
1080  kpds(2) = 1
1081  kpds(1) = 1
1082 #endif
1083 #ifdef W3_RTD
1084  ! Rotate x,y vector back to standard pole
1085  IF ( flagunr ) CALL w3xyrtn(nsea, cx, cy, angld)
1086 #endif
1087  CALL w3s2xy ( nsea, nsea, nx, ny, cx(1:nsea) &
1088  , mapsf, xx )
1089  CALL w3s2xy ( nsea, nsea, nx, ny, cy(1:nsea) &
1090  , mapsf, xy )
1091  DO isea=1, nsea
1092  IF (cx(isea) .NE. undef) THEN
1093  cabs = sqrt(cx(isea)**2+cy(isea)**2)
1094  IF ( cabs .GT. 0.001 ) THEN
1095  cy(isea) = mod( 630. - &
1096  rade*atan2(cy(isea),cx(isea)) , 360. )
1097  ELSE
1098  cy(isea) = 0.
1099  END IF
1100  ELSE
1101  cabs = undef
1102  cy(isea) = undef
1103  END IF
1104  cx(isea) = cabs
1105  END DO
1106  CALL w3s2xy ( nsea, nsea, nx, ny, cx(1:nsea) &
1107  , mapsf, x1 )
1108  CALL w3s2xy ( nsea, nsea, nx, ny, cy(1:nsea) &
1109  , mapsf, x2 )
1110  !
1111  ! Wind speed
1112  !
1113  ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 3 ) THEN
1114  fltwo = .true.
1115 #ifdef W3_NCEP2
1116  kpds(2) = 1
1117  kpds(1) = 2
1118  listsec0(1) = 0
1119 #endif
1120 #ifdef W3_RTD
1121  ! Rotate x,y vector back to standard pole
1122  IF ( flagunr ) CALL w3xyrtn(nsea, ua, ud, angld)
1123 #endif
1124  CALL w3s2xy ( nsea, nsea, nx, ny, ua(1:nsea) &
1125  , mapsf, xx )
1126  CALL w3s2xy ( nsea, nsea, nx, ny, ud(1:nsea) &
1127  , mapsf, xy )
1128  DO isea=1, nsea
1129  IF (ua(isea) .NE. undef) THEN
1130  uabs = sqrt(ua(isea)**2+ud(isea)**2)
1131  IF ( uabs .GT. 0.001 ) THEN
1132  ud(isea) = mod( 630. - &
1133  rade*atan2(ud(isea),ua(isea)) , 360. )
1134  ELSE
1135  ud(isea) = 0.
1136  END IF
1137  ELSE
1138  uabs = undef
1139  ud(isea) = undef
1140  END IF
1141  ua(isea) = uabs
1142  END DO
1143  CALL w3s2xy ( nsea, nsea, nx, ny, ua(1:nsea) &
1144  , mapsf, x1 )
1145  CALL w3s2xy ( nsea, nsea, nx, ny, ud(1:nsea) &
1146  , mapsf, x2 )
1147  !
1148  ! Air-sea temp. dif.
1149  !
1150  ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 4 ) THEN
1151  flone = .true.
1152 #ifdef W3_NCEP2
1153  kpds(2) = 255
1154  kpds(1) = 3
1155 #endif
1156  CALL w3s2xy ( nsea, nsea, nx, ny, as(1:nsea) &
1157  , mapsf, x1 )
1158  !
1159  ! Water level
1160  !
1161  ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 5 ) THEN
1162  flone = .true.
1163 #ifdef W3_NCEP2
1164  kpds(2) = 1
1165  kpds(1) = 3
1166 #endif
1167  CALL w3s2xy ( nsea, nsea, nx, ny, wlv , mapsf, x1 )
1168  !
1169  ! Ice concentration
1170  !
1171  ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 6 ) THEN
1172  flone = .true.
1173 #ifdef W3_NCEP2
1174  kpds(2) = 0
1175  kpds(1) = 2
1176 #endif
1177  CALL w3s2xy ( nsea, nsea, nx, ny, ice , mapsf, x1 )
1178  !
1179  ! Atmospheric momentum
1180  !
1181  ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 8 ) THEN
1182  fltwo = .true.
1183 #ifdef W3_NCEP2
1184  kpds(2) = 1
1185  kpds(1) = 2
1186  listsec0(1) = 0
1187 #endif
1188 #ifdef W3_RTD
1189  ! Rotate x,y vector back to standard pole
1190  IF ( flagunr ) CALL w3xyrtn(nsea, taua, tauadir, angld)
1191 #endif
1192  CALL w3s2xy ( nsea, nsea, nx, ny, taua(1:nsea) &
1193  , mapsf, xx )
1194  CALL w3s2xy ( nsea, nsea, nx, ny, tauadir(1:nsea) &
1195  , mapsf, xy )
1196  DO isea=1, nsea
1197  IF (taua(isea) .NE. undef) THEN
1198  uabs = sqrt(taua(isea)**2+tauadir(isea)**2)
1199  IF ( uabs .GT. 0.001 ) THEN
1200  tauadir(isea) = mod( 630. - &
1201  rade*atan2(tauadir(isea),taua(isea)) , 360. )
1202  ELSE
1203  tauadir(isea) = 0.
1204  END IF
1205  ELSE
1206  uabs = undef
1207  tauadir(isea) = undef
1208  END IF
1209  taua(isea) = uabs
1210  END DO
1211  CALL w3s2xy ( nsea, nsea, nx, ny, taua(1:nsea) &
1212  , mapsf, x1 )
1213  CALL w3s2xy ( nsea, nsea, nx, ny, tauadir(1:nsea) &
1214  , mapsf, x2 )
1215  !
1216  ! Air density
1217  !
1218  ELSE IF ( ifi .EQ. 1 .AND. ifj .EQ. 9 ) THEN
1219  flone = .true.
1220 #ifdef W3_NCEP2
1221  kpds(2) = 0
1222  kpds(1) = 2
1223 #endif
1224  CALL w3s2xy ( nsea, nsea, nx, ny, rhoair, mapsf, x1 )
1225  !
1226  ! Significant wave height
1227  !
1228  ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 1 ) THEN
1229  flone = .true.
1230 #ifdef W3_NCEP2
1231  kpds(2) = 3
1232 #endif
1233  CALL w3s2xy ( nsea, nsea, nx, ny, hs , mapsf, x1 )
1234  !
1235  ! Mean wave length
1236  !
1237  ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 2 ) THEN
1238  flone = .true.
1239 #ifdef W3_NCEP2
1240  kpds(2) = 193
1241 #endif
1242  CALL w3s2xy ( nsea, nsea, nx, ny, wlm , mapsf, x1 )
1243  !
1244  ! Mean wave period (based on second moment)
1245  !
1246  ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 3 ) THEN
1247  flone = .true.
1248 #ifdef W3_NCEP2
1249  if ((gen_pro.eq.1) .or. (gen_pro.eq.0)) then
1250  kpds(2) = 28
1251  else
1252  kpds(2) = 25
1253  endif
1254 #endif
1255 
1256  CALL w3s2xy ( nsea, nsea, nx, ny, t02 , mapsf, x1 )
1257  !
1258  ! Mean wave period (based on first moment)
1259  !
1260  ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 4 ) THEN
1261  flone = .true.
1262 #ifdef W3_NCEP2
1263  kpds(2) = 15
1264 #endif
1265  CALL w3s2xy ( nsea, nsea, nx, ny, t0m1 , mapsf, x1 )
1266  !
1267  ! Mean wave period (based on first inverse moment)
1268  !
1269  ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 5 ) THEN
1270  flone = .true.
1271 #ifdef W3_NCEP2
1272  if ((gen_pro.eq.1) .or. (gen_pro.eq.0)) then
1273  kpds(2) = 34
1274  else
1275  kpds(2) = 15
1276  endif
1277 #endif
1278  CALL w3s2xy ( nsea, nsea, nx, ny, t01 , mapsf, x1 )
1279  !
1280  ! Peak frequency
1281  !
1282  ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 6 ) THEN
1283  flone = .true.
1284 #ifdef W3_NCEP2
1285  kpds(2) = 11
1286 #endif
1287  DO isea=1, nsea
1288  IF ( fp0(isea) .NE. undef .AND. fp0(isea) .NE. 0 ) THEN
1289  fp0(isea) = 1. / max(fr1,fp0(isea)) ! Limit FP to lowest discrete frequency
1290  END IF
1291  END DO
1292  CALL w3s2xy ( nsea, nsea, nx, ny, fp0 , mapsf, x1 )
1293  !
1294  !
1295  ! Mean wave direction
1296  !
1297  ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 7 ) THEN
1298  flone = .true.
1299 #ifdef W3_NCEP2
1300  kpds(2) = 14
1301 #endif
1302 #ifdef W3_RTD
1303  ! Rotate direction back to standard pole
1304  IF ( flagunr ) CALL w3thrtn(nsea, thm, angld, .false.)
1305 #endif
1306  DO isea=1, nsea
1307  IF ( thm(isea) .NE. undef ) &
1308  thm(isea) = mod( 630. - rade*thm(isea) , 360. )
1309  END DO
1310  CALL w3s2xy ( nsea, nsea, nx, ny, thm , mapsf, x1 )
1311  !
1312  ! Directional spread
1313  !
1314  ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 8 ) THEN
1315  flone = .true.
1316 #ifdef W3_NCEP2
1317  kpds(2) = 31
1318 #endif
1319  CALL w3s2xy ( nsea, nsea, nx, ny, ths , mapsf, x1 )
1320  !
1321  ! Peak direction
1322  !
1323  ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 9 ) THEN
1324  flone = .true.
1325 #ifdef W3_NCEP2
1326  if ((gen_pro.eq.1) .or. (gen_pro.eq.0)) then
1327  kpds(2) = 46
1328  else
1329  kpds(2) = 10
1330  endif
1331 #endif
1332 #ifdef W3_RTD
1333  ! Rotate direction back to standard pole
1334  IF ( flagunr ) CALL w3thrtn(nsea, thp0, angld, .false.)
1335 #endif
1336  DO isea=1, nsea
1337  IF ( thp0(isea) .NE. undef ) THEN
1338  thp0(isea) = mod( 630-rade*thp0(isea) , 360. )
1339  END IF
1340  END DO
1341  CALL w3s2xy ( nsea, nsea, nx, ny, thp0 , mapsf, x1 )
1342  !
1343  ! Mean wave number
1344  !
1345  ELSE IF ( ifi .EQ. 2 .AND. ifj .EQ. 19 ) THEN
1346  flone = .true.
1347 #ifdef W3_NCEP2
1348  kpds(2) = 255
1349 #endif
1350  CALL w3s2xy ( nsea, nsea, nx, ny, wnmean, mapsf, x1 )
1351  !
1352  ! Partitioned wave height
1353  !
1354  ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 1 ) THEN
1355  flprt = .true.
1356 #ifdef W3_NCEP2
1357  kpds5a = 5
1358  kpds5b = 8
1359  if ((gen_pro.eq.1) .or. (gen_pro.eq.0)) then
1360  kpds5a1(1) =47
1361  kpds5a1(2) =48
1362  kpds5a1(3) =49
1363  else
1364  kpds5b = 8
1365  endif
1366 #endif
1367  CALL w3s2xy &
1368  ( nsea, nsea, nx, ny, phs(:,0), mapsf, yy(:,0) )
1369  DO i=1, noswll
1370  CALL w3s2xy &
1371  ( nsea, nsea, nx, ny, phs(:,i), mapsf, yy(:,i) )
1372  END DO
1373  !
1374  ! Partitioned peak period
1375  !
1376  ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 2 ) THEN
1377  flprt = .true.
1378 #ifdef W3_NCEP2
1379  kpds5a = 6
1380  kpds5b = 9
1381  if ((gen_pro.eq.1) .or. (gen_pro.eq.0)) then
1382  kpds5a1(1) = 50
1383  kpds5a1(2) = 51
1384  kpds5a1(3) = 52
1385  else
1386  kpds5b = 9
1387  endif
1388 #endif
1389  CALL w3s2xy &
1390  ( nsea, nsea, nx, ny, ptp(:,0), mapsf, yy(:,0) )
1391  DO i=1, noswll
1392  CALL w3s2xy &
1393  ( nsea, nsea, nx, ny, ptp(:,i), mapsf, yy(:,i) )
1394  END DO
1395  !
1396  ! Partitioned peak wave length
1397  !
1398  ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 3 ) THEN
1399  flprt = .true.
1400 #ifdef W3_NCEP2
1401  kpds5a = 193
1402  kpds5b = 193
1403 #endif
1404  CALL w3s2xy &
1405  ( nsea, nsea, nx, ny, plp(:,0), mapsf, yy(:,0) )
1406  DO i=1, noswll
1407  CALL w3s2xy &
1408  ( nsea, nsea, nx, ny, plp(:,i), mapsf, yy(:,i) )
1409  END DO
1410  !
1411  ! Partitioned mean direction
1412  !
1413  ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 4 ) THEN
1414  flprt = .true.
1415 #ifdef W3_NCEP2
1416  kpds5a = 4
1417  kpds5b = 7
1418  if ((gen_pro.eq.1) .or. (gen_pro.eq.0)) then
1419  kpds5a1(1) = 53
1420  kpds5a1(2) = 54
1421  kpds5a1(3) = 55
1422  else
1423  kpds5b = 7
1424  endif
1425 #endif
1426 #ifdef W3_RTD
1427  DO i = 0,noswll
1428  ! Rotate direction back to standard pole
1429  IF ( flagunr ) CALL w3thrtn(nsea, pdir(:,i), angld, .false.)
1430  END DO
1431 #endif
1432  DO isea = 1,nsea
1433  DO i = 0,noswll
1434  IF ( pdir(isea,i) .NE. undef ) THEN
1435  pdir(isea,i) = mod( 630 - rade*pdir(isea,i) , 360. )
1436  END IF
1437  END DO
1438  END DO
1439  CALL w3s2xy &
1440  ( nsea, nsea, nx, ny, pdir(:,0), mapsf, yy(:,0) )
1441  DO i=1, noswll
1442  CALL w3s2xy &
1443  ( nsea, nsea, nx, ny, pdir(:,i), mapsf, yy(:,i) )
1444  END DO
1445  !
1446  ! Partitioned Directional spread
1447  !
1448  ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 5 ) THEN
1449  flprt = .true.
1450 #ifdef W3_NCEP2
1451  kpds5a = 32
1452  kpds5b = 33
1453 #endif
1454  CALL w3s2xy &
1455  ( nsea, nsea, nx, ny, psi(:,0), mapsf, yy(:,0) )
1456  DO i=1, noswll
1457  CALL w3s2xy &
1458  ( nsea, nsea, nx, ny, psi(:,i), mapsf, yy(:,i) )
1459  END DO
1460  !
1461  ! Partitioned wind sea fraction
1462  !
1463  ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 6 ) THEN
1464  flprt = .true.
1465 #ifdef W3_NCEP2
1466  kpds5a = 255
1467  kpds5b = 255
1468 #endif
1469  CALL w3s2xy &
1470  ( nsea, nsea, nx, ny, pws(:,0), mapsf, yy(:,0) )
1471  DO i=1, noswll
1472  CALL w3s2xy &
1473  ( nsea, nsea, nx, ny, pws(:,i), mapsf, yy(:,i) )
1474  END DO
1475  !
1476  ! Total wind sea fraction
1477  !
1478  ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 16 ) THEN
1479  flone = .true.
1480 #ifdef W3_NCEP2
1481  kpds(2) = 255
1482 #endif
1483  CALL w3s2xy ( nsea, nsea, nx, ny, pwst , mapsf, x1 )
1484  !
1485  ! Number of fields in partition
1486  !
1487  ELSE IF ( ifi .EQ. 4 .AND. ifj .EQ. 17 ) THEN
1488  flone = .true.
1489 #ifdef W3_NCEP2
1490  kpds(2) = 255
1491 #endif
1492  CALL w3s2xy ( nsea, nsea, nx, ny, pnr , mapsf, x1 )
1493  !
1494  ! Friction velocity
1495  !
1496  ELSE IF ( ifi .EQ. 5 .AND. ifj .EQ. 1 ) THEN
1497  fltwo = .true.
1498 #ifdef W3_NCEP2
1499  kpds(2) = 17
1500  kpds(1) = 1
1501 #endif
1502 #ifdef W3_RTD
1503  ! Rotate x,y vector back to standard pole
1504  IF ( flagunr ) CALL w3xyrtn(nsea, ust, ustdir, angld)
1505 #endif
1506  CALL w3s2xy ( nsea, nsea, nx, ny, ust(1:nsea) &
1507  , mapsf, x1 )
1508  CALL w3s2xy ( nsea, nsea, nx, ny, ustdir(1:nsea) &
1509  , mapsf, x2 )
1510  !
1511  ! Average source term time step
1512  !
1513  ELSE IF ( ifi .EQ. 9 .AND. ifj .EQ. 1 ) THEN
1514  flone = .true.
1515 #ifdef W3_NCEP2
1516  kpds(2) = 255
1517 #endif
1518  DO isea=1, nsea
1519  IF ( dtdyn(isea) .NE. undef ) &
1520  dtdyn(isea) = dtdyn(isea) / 60.
1521  END DO
1522  CALL w3s2xy ( nsea, nsea, nx, ny, dtdyn , mapsf, x1 )
1523  !
1524  ! Cut-off frequency
1525  !
1526  ELSE IF ( ifi .EQ. 9 .AND. ifj .EQ. 2 ) THEN
1527  flone = .true.
1528 #ifdef W3_NCEP2
1529  kpds(2) = 255
1530 #endif
1531  CALL w3s2xy ( nsea, nsea, nx, ny, fcut , mapsf, x1 )
1532  !
1533  ! CFL Maximum (in spatial space)
1534  !
1535  ELSE IF ( ifi .EQ. 9 .AND. ifj .EQ. 3 ) THEN
1536  flone = .true.
1537 #ifdef W3_NCEP2
1538  kpds(2) = 255
1539 #endif
1540  CALL w3s2xy ( nsea, nsea, nx, ny, cflxymax , mapsf, x1 )
1541  !
1542  ! CFL Maximum (in spectral space)
1543  !
1544  ELSE IF ( ifi .EQ. 9 .AND. ifj .EQ. 4 ) THEN
1545  flone = .true.
1546 #ifdef W3_NCEP2
1547  kpds(2) = 255
1548 #endif
1549  CALL w3s2xy ( nsea, nsea, nx, ny, cflthmax , mapsf, x1 )
1550  !
1551  ELSE
1552  WRITE (ndse,999)
1553  CALL extcde ( 1 )
1554  !
1555  END IF
1556  !
1557  ! 3 Perform output
1558  !
1559  ndata = nx*ny
1560  !
1561  ! 3.a Partitioned data
1562  !
1563  IF ( flprt ) THEN
1564  !
1565 #ifdef W3_NCEP2
1566  kpds(2) = kpds5a
1567 #endif
1568  DO ixy=1, nx*ny
1569  bitmap(ixy) = yy(ixy,0) .NE. undef
1570  END DO
1571 #ifdef W3_NCEP2
1572  CALL gribcreate (cgrib,lcgrib,listsec0,listsec1,io)
1573  IF (io .NE. 0) GOTO 810
1574  CALL addgrid (cgrib,lcgrib,igds,kgds,200,ideflist, &
1575  idefnum, io)
1576  IF (io .NE. 0) GOTO 820
1577  CALL addfield (cgrib,lcgrib,kpdsnum,kpds,200, &
1578  coordlist, numcoord, idrsnum, idrs, &
1579  200,yy(:,0), ndata, ibmp, bitmap, io)
1580  IF (io .NE. 0) GOTO 820
1581  CALL gribend (cgrib, lcgrib, lengrib, io)
1582  IF (io .NE. 0) GOTO 830
1583  CALL wryte (ndsdat, lengrib, cgrib)
1584 #endif
1585  !
1586 #ifdef W3_NCEP2
1587  if ((gen_pro.eq.0) .or. (gen_pro.eq.1)) then
1588  kpds(10) = 241
1589 #endif
1590  DO i=1, noswll
1591 #ifdef W3_NCEP2
1592  kpds(2) = kpds5a1(i)
1593  kpds(12) = i
1594 #endif
1595  DO ixy=1, nx*ny
1596  bitmap(ixy) = yy(ixy,i) .NE. undef
1597  END DO
1598 #ifdef W3_NCEP2
1599  CALL gribcreate (cgrib,lcgrib,listsec0,listsec1,io)
1600  IF (io .NE. 0) GOTO 810
1601  CALL addgrid (cgrib,lcgrib,igds,kgds,200,ideflist, &
1602  idefnum, io)
1603  IF (io .NE. 0) GOTO 820
1604  CALL addfield (cgrib,lcgrib,kpdsnum,kpds,200, &
1605  coordlist, numcoord, idrsnum, idrs, &
1606  200,yy(:,i), ndata, ibmp, bitmap, io)
1607  IF (io .NE. 0) GOTO 820
1608  CALL gribend (cgrib, lcgrib, lengrib, io)
1609  IF (io .NE. 0) GOTO 830
1610  CALL wryte (ndsdat, lengrib, cgrib)
1611 #endif
1612  END DO
1613 #ifdef W3_NCEP2
1614  ELSE
1615  kpds(2) = kpds5b
1616  kpds(10) = 241
1617 #endif
1618  DO i=1, noswll
1619 #ifdef W3_NCEP2
1620  kpds(12) = i
1621 #endif
1622  DO ixy=1, nx*ny
1623  bitmap(ixy) = yy(ixy,i) .NE. undef
1624  END DO
1625 #ifdef W3_NCEP2
1626  CALL gribcreate (cgrib,lcgrib,listsec0,listsec1,io)
1627  IF (io .NE. 0) GOTO 810
1628  CALL addgrid (cgrib,lcgrib,igds,kgds,200,ideflist, &
1629  idefnum, io)
1630  IF (io .NE. 0) GOTO 820
1631  CALL addfield (cgrib,lcgrib,kpdsnum,kpds,200, &
1632  coordlist, numcoord, idrsnum, idrs, &
1633  200,yy(:,i), ndata, ibmp, bitmap, io)
1634  IF (io .NE. 0) GOTO 820
1635  CALL gribend (cgrib, lcgrib, lengrib, io)
1636  IF (io .NE. 0) GOTO 830
1637  CALL wryte (ndsdat, lengrib, cgrib)
1638 #endif
1639  END DO
1640 #ifdef W3_NCEP2
1641  ENDIF
1642  kpds(10) = 1
1643  kpds(12) = 1
1644 #endif
1645  !
1646  ! 3.b Other data
1647  !
1648  ELSE IF (flone) THEN
1649  !
1650  DO ixy=1, nx*ny
1651  bitmap(ixy) = x1(ixy) .NE. undef
1652  END DO
1653  !
1654 #ifdef W3_NCEP2
1655  CALL gribcreate (cgrib,lcgrib,listsec0,listsec1,io)
1656  IF (io .NE. 0) GOTO 810
1657  CALL addgrid (cgrib,lcgrib,igds,kgds,200,ideflist, &
1658  idefnum, io)
1659  IF (io .NE. 0) GOTO 820
1660  CALL addfield (cgrib,lcgrib,kpdsnum,kpds,200, &
1661  coordlist, numcoord, idrsnum, idrs, &
1662  200,x1, ndata, ibmp, bitmap, io)
1663  IF (io .NE. 0) GOTO 820
1664  CALL gribend (cgrib, lcgrib, lengrib, io)
1665  IF (io .NE. 0) GOTO 830
1666  CALL wryte (ndsdat, lengrib, cgrib)
1667 #endif
1668  !
1669  ELSE IF ( fltwo ) THEN
1670  !
1671  DO ixy=1, nx*ny
1672  bitmap(ixy) = x1(ixy) .NE. undef
1673  END DO
1674 #ifdef W3_NCEP2
1675  CALL gribcreate (cgrib,lcgrib,listsec0,listsec1,io)
1676  IF (io .NE. 0) GOTO 810
1677  CALL addgrid (cgrib,lcgrib,igds,kgds,200,ideflist, &
1678  idefnum, io)
1679  IF (io .NE. 0) GOTO 820
1680  CALL addfield (cgrib,lcgrib,kpdsnum,kpds,200, &
1681  coordlist, numcoord, idrsnum, idrs, &
1682  200,x1, ndata, ibmp, bitmap, io)
1683  IF (io .NE. 0) GOTO 820
1684  CALL gribend (cgrib, lcgrib, lengrib, io)
1685  IF (io .NE. 0) GOTO 830
1686  CALL wryte (ndsdat, lengrib, cgrib)
1687 #endif
1688 
1689 #ifdef W3_NCEP2
1690  kpds(2) = 0
1691  CALL gribcreate (cgrib,lcgrib,listsec0,listsec1,io)
1692  IF (io .NE. 0) GOTO 810
1693  CALL addgrid (cgrib,lcgrib,igds,kgds,200,ideflist, &
1694  idefnum, io)
1695  IF (io .NE. 0) GOTO 820
1696  CALL addfield (cgrib,lcgrib,kpdsnum,kpds,200, &
1697  coordlist, numcoord, idrsnum, idrs, &
1698  200,x2, ndata, ibmp, bitmap, io)
1699  IF (io .NE. 0) GOTO 820
1700  CALL gribend (cgrib, lcgrib, lengrib, io)
1701  IF (io .NE. 0) GOTO 830
1702  CALL wryte (ndsdat, lengrib, cgrib)
1703  kpds(2) = 2
1704  CALL gribcreate (cgrib,lcgrib,listsec0,listsec1,io)
1705  IF (io .NE. 0) GOTO 810
1706  CALL addgrid (cgrib,lcgrib,igds,kgds,200,ideflist, &
1707  idefnum, io)
1708  IF (io .NE. 0) GOTO 820
1709  CALL addfield (cgrib,lcgrib,kpdsnum,kpds,200, &
1710  coordlist, numcoord, idrsnum, idrs, &
1711  200,xx, ndata, ibmp, bitmap, io)
1712  IF (io .NE. 0) GOTO 820
1713  CALL gribend (cgrib, lcgrib, lengrib, io)
1714  IF (io .NE. 0) GOTO 830
1715  CALL wryte (ndsdat, lengrib, cgrib)
1716  kpds(2) = 3
1717  CALL gribcreate (cgrib,lcgrib,listsec0,listsec1,io)
1718  IF (io .NE. 0) GOTO 810
1719  CALL addgrid (cgrib,lcgrib,igds,kgds,200,ideflist, &
1720  idefnum, io)
1721  IF (io .NE. 0) GOTO 820
1722  CALL addfield (cgrib,lcgrib,kpdsnum,kpds,200, &
1723  coordlist, numcoord, idrsnum, idrs, &
1724  200,xy, ndata, ibmp, bitmap, io)
1725  IF (io .NE. 0) GOTO 820
1726  CALL gribend (cgrib, lcgrib, lengrib, io)
1727  IF (io .NE. 0) GOTO 830
1728  CALL wryte (ndsdat, lengrib, cgrib)
1729 #endif
1730  !
1731  END IF
1732 #ifdef W3_NCEP2
1733  listsec0(1) = 10
1734  kpds(1) = 0
1735 #endif
1736  !
1737  ! ... End of fields loop
1738  !
1739  END IF
1740  END DO
1741  END DO
1742  !
1743  RETURN
1744  !
1745  ! Error escape locations
1746  !
1747 #ifdef W3_NCEP2
1748 810 CONTINUE
1749  WRITE (ndse,1010) io
1750  CALL extcde ( 20 )
1751 820 CONTINUE
1752  WRITE (ndse,1020) io
1753  CALL extcde ( 30 )
1754 830 CONTINUE
1755  WRITE (ndse,1030) io
1756  CALL extcde ( 40 )
1757 #endif
1758  !
1759  ! Formats
1760  !
1761 999 FORMAT (/' *** WAVEWATCH III ERROR IN W3EXGB :'/ &
1762  ' PLEASE UPDATE FIELDS !!! '/)
1763  !
1764 #ifdef W3_NCEP2
1765 1000 FORMAT (/' *** WAVEWATCH III ERROR IN W3EXGB : '/ &
1766  ' ERROR IN OPENING OUTPUT FILE'/ &
1767  ' IOSTAT =',i5/)
1768 #endif
1769  !
1770 #ifdef W3_NCEP2
1771 1010 FORMAT (/' *** WAVEWATCH III ERROR IN W3EXGB : '/ &
1772  ' ERROR CREATING NEW GRIB2 FIELD'/ &
1773  ' IOSTAT =',i5/)
1774 #endif
1775  !
1776 #ifdef W3_NCEP2
1777 1020 FORMAT (/' *** WAVEWATCH III ERROR IN W3EXGB : '/ &
1778  ' ERROR ADDING GRIB2 FIELD'/ &
1779  ' IOSTAT =',i5/)
1780 #endif
1781  !
1782 #ifdef W3_NCEP2
1783 1030 FORMAT (/' *** WAVEWATCH III ERROR IN W3EXGB : '/ &
1784  ' ERROR ENDING GRIB2 MESSAGE'/ &
1785  ' IOSTAT =',i5/)
1786 #endif
1787  !
1788 #ifdef W3_T
1789 9000 FORMAT (' TEST W3EXGB : FLAGS :',40l2)
1790 9001 FORMAT (' TEST W3EXGB : NDSDAT :',i4/ &
1791  ' KPDS :',13i4/ &
1792  ' ',12i4/ &
1793  ' KGDS :',8i6/ &
1794  ' ',8i6/ &
1795  ' ',6i6)
1796 #endif
1797  !
1798 #ifdef W3_T
1799 9012 FORMAT (' TEST W3EXGB : BLOK PARS : ',3i4)
1800 9014 FORMAT (' BASE NAME : ',a)
1801 #endif
1802  !
1803 #ifdef W3_T
1804 9020 FORMAT (' TEST W3EXGB : OUTPUT FIELD : ',a)
1805 #endif
1806  !/
1807  !/ End of W3EXGB ----------------------------------------------------- /
1808  !/
1809  END SUBROUTINE w3exgb
1810  !/
1811  !/ End of W3GRIB ----------------------------------------------------- /
1812  !/
1813 END PROGRAM w3grib
w3timemd::dsec21
real function dsec21(TIME1, TIME2)
Definition: w3timemd.F90:333
w3servmd::nextln
subroutine nextln(CHCKC, NDSI, NDSE)
Definition: w3servmd.F90:222
w3adatmd
Define data structures to set up wave model auxiliary data for several models simultaneously.
Definition: w3adatmd.F90:26
w3wdatmd
Define data structures to set up wave model dynamic data for several models simultaneously.
Definition: w3wdatmd.F90:18
w3odatmd::flogd
logical, dimension(:), pointer flogd
Definition: w3odatmd.F90:478
w3wdatmd::wlv
real, dimension(:), pointer wlv
Definition: w3wdatmd.F90:183
w3odatmd::ngrpp
integer, parameter ngrpp
Definition: w3odatmd.F90:324
w3wdatmd::time
integer, dimension(:), pointer time
Definition: w3wdatmd.F90:172
constants::rade
real, parameter rade
RADE Conversion factor from radians to degrees.
Definition: constants.F90:76
w3odatmd::fnmpre
character(len=80) fnmpre
Definition: w3odatmd.F90:330
w3exgb
subroutine w3exgb(NX, NY, NSEA)
Perform actual GRIB output.
Definition: ww3_grib.F90:915
w3grib
program w3grib
Post-processing of grid output.
Definition: ww3_grib.F90:27
w3gdatmd::w3setg
subroutine w3setg(IMOD, NDSE, NDST)
Definition: w3gdatmd.F90:2152
w3odatmd::ndse
integer, pointer ndse
Definition: w3odatmd.F90:456
w3adatmd::w3seta
subroutine w3seta(IMOD, NDSE, NDST)
Select one of the WAVEWATCH III grids / models.
Definition: w3adatmd.F90:2645
w3servmd::w3thrtn
subroutine w3thrtn(NSEA, THETA, AnglD, Degrees)
Definition: w3servmd.F90:1333
w3wdatmd::w3ndat
subroutine w3ndat(NDSE, NDST)
Set up the number of grids to be used.
Definition: w3wdatmd.F90:210
w3servmd
Definition: w3servmd.F90:3
w3odatmd::flogrd
logical, dimension(:,:), pointer flogrd
Definition: w3odatmd.F90:478
w3timemd::tick21
subroutine tick21(TIME, DTIME)
Definition: w3timemd.F90:84
w3wdatmd::w3setw
subroutine w3setw(IMOD, NDSE, NDST)
Select one of the WAVEWATCH III grids / models.
Definition: w3wdatmd.F90:660
w3odatmd::noge
integer, dimension(nogrp) noge
Definition: w3odatmd.F90:326
w3odatmd::w3seto
subroutine w3seto(IMOD, NDSERR, NDSTST)
Definition: w3odatmd.F90:1523
w3timemd::stme21
subroutine stme21(TIME, DTME21)
Definition: w3timemd.F90:682
w3odatmd
Definition: w3odatmd.F90:3
w3adatmd::w3naux
subroutine w3naux(NDSE, NDST)
Set up the number of grids to be used.
Definition: w3adatmd.F90:704
w3iogrmd::w3iogr
subroutine w3iogr(INXOUT, NDSM, IMOD, FEXT ifdef W3_ASCII
Reading and writing of the model definition file.
Definition: w3iogrmd.F90:117
w3iogomd::w3iogo
subroutine w3iogo(INXOUT, NDSOG, IOTST, IMOD ifdef W3_ASCII
Read/write gridded output.
Definition: w3iogomd.F90:2396
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
w3iogomd
Gridded output of mean wave parameters.
Definition: w3iogomd.F90:15
w3servmd::strace
subroutine strace(IENT, SNAME)
Definition: w3servmd.F90:148
w3odatmd::ndso
integer, pointer ndso
Definition: w3odatmd.F90:456
w3wdatmd::ice
real, dimension(:), pointer ice
Definition: w3wdatmd.F90:183
w3gdatmd::w3nmod
subroutine w3nmod(NUMBER, NDSE, NDST, NAUX)
Definition: w3gdatmd.F90:1433
w3odatmd::idout
character(len=20), dimension(nogrp, ngrpp) idout
Definition: w3odatmd.F90:329
w3iogomd::w3readflgrd
subroutine w3readflgrd(NDSI, NDSO, NDSS, NDSEN, COMSTR, FLG1D, FLG2D, IAPROC, NAPOUT, IERR)
Fills in FLG1D and FLG2D arrays from ASCII input file.
Definition: w3iogomd.F90:336
w3odatmd::ndst
integer, pointer ndst
Definition: w3odatmd.F90:456
w3wdatmd::ust
real, dimension(:), pointer ust
Definition: w3wdatmd.F90:183
constants
Define some much-used constants for global use (all defined as PARAMETER).
Definition: constants.F90:20
w3odatmd::nogrp
integer, parameter nogrp
Definition: w3odatmd.F90:323
w3gdatmd
Definition: w3gdatmd.F90:16
w3servmd::w3xyrtn
subroutine w3xyrtn(NSEA, XVEC, YVEC, AnglD)
Definition: w3servmd.F90:1387
w3servmd::extcde
subroutine extcde(IEXIT, UNIT, MSG, FILE, LINE, COMM)
Definition: w3servmd.F90:736
w3odatmd::w3nout
subroutine w3nout(NDSERR, NDSTST)
Definition: w3odatmd.F90:561
w3wdatmd::rhoair
real, dimension(:), pointer rhoair
Definition: w3wdatmd.F90:183
w3servmd::itrace
subroutine itrace(NDS, NMAX)
Definition: w3servmd.F90:91
w3wdatmd::ustdir
real, dimension(:), pointer ustdir
Definition: w3wdatmd.F90:183
w3odatmd::noswll
integer, pointer noswll
Definition: w3odatmd.F90:460
w3timemd
Definition: w3timemd.F90:3
constants::undef
real undef
UNDEF Value for undefined variable in output.
Definition: constants.F90:84
w3servmd::w3s2xy
subroutine w3s2xy(NSEA, MSEA, MX, MY, S, MAPSF, XY)
Definition: w3servmd.F90:337