WAVEWATCH III  beta 0.0.1
ww3_gint.F90
Go to the documentation of this file.
1 
5 !
6 #include "w3macros.h"
7 !/ ------------------------------------------------------------------- /
22 !
24  !/
25  !/ +-----------------------------------+
26  !/ | WAVEWATCH-III NOAA/NCEP |
27  !/ | A. Chawla |SX
28  !/ | FORTRAN 90 |
29  !/ | Last update : 02-Jun-2021 |
30  !/ +-----------------------------------+
31  !/
32  !/ 15-Mar-2007 : Origination. ( version 3.13 )
33  !/ 24-Sep-2007 : Original code ( version 3.14 )
34  !/ 01-Aug-2011 : Modified to match grid output ( version 4.01 )
35  !/ 20-Feb-2013 : Modified for new output fields ( version 4.11 )
36  !/ 11-Nov-2013 : Update for curvilinear grids ( version 4.13 )
37  !/ 22-Jan-2014 : Update for UNST grids (F. Ardhuin) ( version 4.18 )
38  !/ 30-Apr-2014 : Add group 3 (M. Accensi) ( version 5.00 )
39  !/ 26-Jul-2018 : Write weights file WHTGRIDINT.bin
40  !/ (F.Ardhuin, M.Accensi, J.H.Alves) ( version 6.05 )
41  !/ 31-Aug-2018 : Update groups 2,4,6,8 (S. Zieger) ( version 6.05 )
42  !/ 26-Jan-2021 : Added TP field (derived from FP) ( version 7.12 )
43  !/ 22-Mar-2021 : New coupling fields output ( version 7.13 )
44  !/ 02-Jun-2021 : Bug fix (*SUMGRD; Q. Liu) ( version 7.13 )
45  !/
46  ! 1. Purpose :
47  !
48  ! Re-gridding binary output (out_grd.* files) to another grid
49  !
50  ! 2. Method :
51  !
52  ! Data is interpolated from a combination of base grids to the target
53  ! grid. For each grid, if resolution is coarser or similar to target
54  ! grid then a linear interpolation approach is used. On the other hand
55  ! if resolution is much higher then an averaging technique based on
56  ! cell areas.
57  ! Total number of base grids to be used for interpolation together with
58  ! their (and target grid) file extns are read from 'ww3_gint.inp'.
59  ! Base grids can be arranged in any order but the target grid should
60  ! always be the last grid.
61  !
62  ! 3. Parameters :
63  !
64  ! 4. Subroutines used :
65  !
66  ! Name Type Module Description
67  ! ----------------------------------------------------------------
68  ! W3NMOD Subr. W3GDATMD Set number of model.
69  ! W3SETG Subr. Id. Point to selected model.
70  ! W3IOGR Subr. W3IOGRMD Reading/writing model definition file.
71  ! NEXTLN Subr. W3SERVMD Get next line from input file
72  ! EXTCDE Subr. Id. Abort program as graceful as possible.
73  ! ITRACE Subr. Id. Subroutine tracing initialization.
74  ! STRACE Subr. Id. Subroutine tracing.
75  ! W3NOUT Subr. W3ODATMD Set number of model for output.
76  ! W3SETO Subr. Id. Point to selected model for output.
77  ! W3NDAT Subr. W3WDATMD Set number of model for wave data.
78  ! W3SETW Subr. W3WDATMD Point to selected model for wave data.
79  ! W3NAUX Subr. W3ADATMD Set number of model for aux data.
80  ! W3SETA Subr. Id. Point to selected model for aux data.
81  ! W3DIMA Subr. Id. Assign memory for aux data.
82  ! W3GRMP Func. W3GSRUMD Compute interpolation coeff. from grid.
83  ! W3CKCL Func. Id. Check if point lies within grid cell.
84  ! W3IOGO Subr. W3IOGOMD Reading/writing raw gridded data file.
85  ! ----------------------------------------------------------------
86  !
87  ! 5. Called by :
88  !
89  ! None, stand-alone program.
90  !
91  ! 6. Error messages :
92  !
93  ! Checks on input, checks on determining the interpolation weights
94  !
95  ! 7. Remarks :
96  !
97  ! 8. Structure :
98  !
99  ! See source code.
100  !
101  ! 9. Switches :
102  !
103  ! !/S Enable subroutine tracing.
104  !
105  ! 10. Source code :
106  !
107  !/ ------------------------------------------------------------------- /
108  USE constants
109  !/
110  USE w3iogrmd
111  USE w3timemd
112  USE w3iogomd, ONLY : w3iogo
113  USE w3adatmd, ONLY : w3dima, w3naux, w3seta
114  USE w3gdatmd
115  USE w3odatmd, ONLY : fnmpre, nogrp, ngrpp, outpts, undef, flogrd, &
117  USE w3odatmd, ONLY : w3nout, w3seto
118  USE w3idatmd
119  USE w3wdatmd, ONLY : w3ndat, w3dimw, w3setw
120  USE w3wdatmd, ONLY : wdatas, time, wlv, ice, iceh, icef, &
121  ust, ustdir, asf, rhoair
122  USE w3servmd, ONLY : itrace, nextln, extcde
123 #ifdef W3_S
124  USE w3servmd, ONLY : strace
125 #endif
126  USE w3arrymd, ONLY : prtblk
127  USE w3gsrumd
128  USE w3triamd
129  USE w3wdatmd, ONLY: va
130  USE w3iorsmd, ONLY: w3iors
131  !/
132  IMPLICIT NONE
133  !/
134  !/ ------------------------------------------------------------------- /
135  !/ Local data structure
136  !/
137  TYPE gr_wt
138  INTEGER :: np
139  INTEGER, ALLOCATABLE :: ip(:), jp(:)
140  REAL, ALLOCATABLE :: wt(:)
141  REAL :: ar
142  END TYPE gr_wt
143  !
144  TYPE gr_int
145  INTEGER :: ngrds
146  INTEGER, ALLOCATABLE :: gdid(:)
147  TYPE(gr_wt), ALLOCATABLE :: ind_wts(:)
148  END TYPE gr_int
149  !/
150  !/ Local variables
151  !/
152 
153  TYPE(gr_int), TARGET, ALLOCATABLE :: gr_ints(:)
154  INTEGER :: i, j, ierr, ng, ig, jg, isea, ix, iy, ixt
155  INTEGER :: iyt, ns, countf, countg, noswll_min, itout
156  INTEGER :: ndsm, ndsi, ndse, ndso, ndstrc, ntrace, iotst
157  INTEGER :: intmethod, nsea_file
158  INTEGER, ALLOCATABLE :: fidout(:), map(:,:), tmp_indx(:)
159  REAL :: sxt, syt, xt, yt, xtt
160  DOUBLE PRECISION :: darea, sarea
161  REAL :: xcrnr(5),ycrnr(5),dt(4),dx,dy,xsub,ysub
162  INTEGER :: tout(2), nout, iout
163  REAL :: dtreq, dtest
164  INTEGER :: is(4), js(4)
165  INTEGER :: mapint
166  REAL :: rw(4), sumwt
167 #ifdef W3_S
168  INTEGER, SAVE :: ient = 0
169 #endif
170  REAL, ALLOCATABLE :: int_map(:,:)
171  LOGICAL :: l360=.false., lplc, ingrd, brnchcl, brnchcr, ingrid
172  CHARACTER :: comstr*1, idtime*23, fnamewht*32
173  REAL :: xxx
174  LOGICAL :: outorrest
175  INTEGER :: intype !check if this can be removed
176  INTEGER, ALLOCATABLE :: mapsta_ng(:,:),mapst2_ng(:,:)
177  INTEGER, ALLOCATABLE :: noint(:),noint2(:),mapstatmp(:,:)
178  INTEGER :: inoint,inoint2,jsea,iloops
179  CHARACTER(LEN=8) :: words(5)
180  CHARACTER(LEN=80) :: linein
181  !
182  !---------------------------------------------------------------------------
183  ! 1. Initialization
184  !
185  ndsm = 20
186  ndsi = 10
187  ndse = 6
188  ndso = 6
189  !
190  ndstrc = 6
191  ntrace = 10
192 
193  !
194  !---------------------------------------------------------------------------
195  ! 2. I/O Setup
196  !
197  !
198  j = len_trim(fnmpre)
199  OPEN(ndsi,file=fnmpre(:j)//'ww3_gint.inp',status='OLD', err=2000, &
200  iostat=ierr)
201  WRITE (ndso,900)
202  !
203  CALL itrace ( ndstrc, ntrace )
204 #ifdef W3_S
205  CALL strace (ient, 'W3GRIDINT')
206 #endif
207  !---------------------------------------------------------------------------
208  ! 3. Read and process input file upto number of grids
209  ! 3.a Get comment character
210  !
211  rewind(ndsi)
212  READ (ndsi,'(A)',END=2001,ERR=2002) comstr
213  IF ( comstr .EQ. ' ' ) comstr = '$'
214  WRITE (ndso,901) comstr
215  !
216  ! 3.b.1 Read starting time, time step and number of outputs
217  !
218  CALL nextln ( comstr, ndsi, ndse )
219 
220  words(1:5)=''
221  READ (ndsi,'(A)') linein
222  READ(linein,*,iostat=ierr) words
223 
224  READ(words( 1 ), * ) tout(1)
225  READ(words( 2 ), * ) tout(2)
226  READ(words( 3 ), * ) dtreq
227  READ(words( 4 ), * ) nout
228 
229  ! Set flag OUTorREST for out_grd (True) or restart.* (FALSE)
230  IF (words(5) .EQ. 'F') THEN
231  outorrest = .false.
232  ELSE
233  outorrest = .true.
234  ENDIF
235 
236  dtreq = max( 0. , dtreq )
237  IF ( dtreq.EQ.0 ) nout = 1
238  nout = max( 1 , nout )
239  !
240  CALL stme21 ( tout , idtime )
241  WRITE (ndso,902) idtime, dtreq, nout
242  !
243  ! 3.c Read number of grids and allocate memory
244  !
245  CALL nextln ( comstr, ndsi, ndse )
246  READ (ndsi,*,END=2001,ERR=2002) ng
247  WRITE (ndso,903) ng
248  !
249  CALL w3nmod (ng, 6, 6)
250  CALL w3ndat ( 6, 6)
251  CALL w3naux ( 6, 6)
252  CALL w3ninp ( 6, 6)
253  CALL w3nout( 6, 6)
254  !
255  ! 3.d Read file extensions for each of the grids and
256  ! the grid information from the corresponding mod_def files
257  !
258  noswll_min = 9999999
259  CALL nextln ( comstr, ndsi, ndse )
260  !
261  DO ig = 1,ng
262  READ (ndsi,*,END=2001,ERR=2002) GRIDS(IG)%filext
263  WRITE (ndso,904) ig,grids(ig)%FILEXT
264  !
265  CALL w3seto( ig, 6, 6)
266  CALL w3seta( ig, 6, 6)
267  CALL w3setw( ig, 6, 6)
268  CALL w3setg( ig, 6, 6)
269  CALL w3iogr ('READ', ndsm, ig, grids(ig)%FILEXT)
270  WRITE (ndso,905) nx, ny, gtype, iclose
271 
272  IF ( iclose .EQ. iclose_trpl ) THEN
273  WRITE(ndse,*)'PROGRAM W3GRID_INTERP HAS NOT BEEN '// &
274  'TESTED WITH TRIPOLE GRIDS. STOPPING NOW.'
275  CALL extcde ( 1 )
276  END IF
277  IF ( ig .NE. ng .AND. noswll_min .GE. outpts(ig)%NOSWLL ) THEN
278  noswll_min = outpts(ig)%NOSWLL
279  END IF
280  IF ( ig .EQ. ng) THEN
281  ALLOCATE(mapsta_ng(ny,nx),mapst2_ng(ny,nx))
282  mapsta_ng=mapsta
283  mapst2_ng=mapst2
284  END IF
285  END DO
286  IF ( noswll_min .NE. outpts(ng)%NOSWLL ) THEN
287  WRITE (ndso,907) noswll_min, outpts(ng)%NOSWLL
288  noswll_min = min(noswll_min,outpts(ng)%NOSWLL)
289  END IF
290  CALL nextln ( comstr, ndsi, ndse )
291  READ (ndsi,'(I1)',END=2001,ERR=2002) intmethod
292  WRITE (ndso,917) intmethod
293  CLOSE(ndsi)
294 
295  !
296  ! 3.e Allocate memory for integration map and initialize with grid status map
297  !
298  ALLOCATE(int_map(nx,ny),map(nx,ny))
299  int_map = 0.0
300  ! MAP = TRANSPOSE(MAPSTA)
301  DO ix = 1,nx
302  DO iy = 1,ny
303  IF ( mapsta(iy,ix) .EQ. 0 ) THEN
304  map(ix,iy) = -1
305  END IF
306  END DO
307  END DO
308  !
309  !---------------------------------------------------------------------------
310  ! 4. Determine interpolation weights for output grids
311  !
312  !
313  ! 4.a Point to output grid and allocate space for interpolation weights
314  !
315  CALL w3setg( ng, 6, 6)
316  WRITE (ndso,908) nsea
317  nseal=nsea ! Set for reading restarts
318  !
319  ALLOCATE ( gr_ints(nsea) )
320  !
321  IF ( flagll ) THEN
322  IF ( minval( xgrd ) .LT. 0 .OR. &
323  maxval( xgrd ) .GT. 180.0 ) l360 = .true.
324  END IF
325 
326  ALLOCATE ( noint(nsea) )
327  inoint=0
328  !
329  ! 4.b Check if weight files exist or create it
330  !
331  fnamewht='WHTGRIDINT.bin'
332  OPEN (994,file=fnmpre(:j)//trim(fnamewht),form='UNFORMATTED', convert=file_endian,iostat=ierr,status='OLD')
333  nsea_file = 0
334  IF (ierr.EQ.0) READ(994) nsea_file ! basic consistency check ...
335  IF (nsea_file.EQ.nsea) THEN
336  DO isea = 1, nsea
337  READ(994) countg
338  ALLOCATE ( gr_ints(isea)%IND_WTS(countg),gr_ints(isea)%GDID(countg) )
339  DO ig = 1,countg
340  READ(994) gr_ints(isea)%IND_WTS(ig)%AR
341  READ(994) gr_ints(isea)%GDID(ig)
342  READ(994) countf
343  ALLOCATE ( gr_ints(isea)%IND_WTS(ig)%IP(countf), &
344  gr_ints(isea)%IND_WTS(ig)%JP(countf), &
345  gr_ints(isea)%IND_WTS(ig)%WT(countf) )
346  DO i = 1,countf
347  READ(994) gr_ints(isea)%IND_WTS(ig)%IP(i)
348  READ(994) gr_ints(isea)%IND_WTS(ig)%JP(i)
349  READ(994) gr_ints(isea)%IND_WTS(ig)%WT(i)
350  END DO
351  READ(994) gr_ints(isea)%IND_WTS(ig)%NP
352  END DO ! IG
353  READ(994) gr_ints(isea)%NGRDS
354  END DO ! ISEA
355 
356  ELSE
357  OPEN (994,file=fnmpre(:j)//trim(fnamewht),form='UNFORMATTED', convert=file_endian,iostat=ierr)
358 
359  !
360  ! 4.b Loop through the wet points
361  !
362  DO isea = 1, nsea
363  !
364  ! IF (MOD(ISEA,NINT(REAL(NSEA)/100)).EQ.1) &
365  ! WRITE(6,*) 'Treating point ',ISEA,' out of ', NSEA
366  ix = mapsf(isea,1)
367  iy = mapsf(isea,2)
368  darea = abs(gsqrt(iy,ix))
369  !
370  ALLOCATE ( gr_ints(isea)%IND_WTS(ng-1),gr_ints(isea)%GDID(ng-1) )
371  !
372  ! 4.b.i Loop through the input grids for each wet point
373  !
374  countg = 0
375  DO ig = 1,ng-1
376  !
377  ! 4.b.ii Check if point is enclosed in grid domain
378  !
379  ingrid=.false.
380  IF (grids(ig)%GTYPE .EQ. ungtype) THEN
381  ! Look for a triangle at the coarse cell center
382  CALL is_in_ungrid(ig, xgrd(iy,ix), ygrd(iy,ix), &
383  itout, is, js, rw)
384  IF (itout.GT.0) ingrid=.true.
385  ! ! If extrapolation activated, force to find if a triangles is inside
386  ! ! the coarse grid cell even if there is no triangle in the cell center
387  IF (intmethod.EQ.1) THEN
388  WRITE(991,'(2I6,2F9.4,I8,3I8,3F5.3)') ix,iy,xgrd(iy,ix), ygrd(iy,ix), itout, is(1:3), rw(1:3)
389  IF (itout.EQ.0) WRITE(992,*) ix,iy,isea,xgrd(iy,ix), ygrd(iy,ix)
390  IF (itout.EQ.0) THEN
391  CALL is_in_ungrid2(ig, xgrd(iy,ix), ygrd(iy,ix), intmethod, &
392  itout, is, js, rw)
393  WRITE(993,'(2I6,2F9.4,I8,3I8,3F6.3)') ix,iy,xgrd(iy,ix), ygrd(iy,ix), itout, is(1:3), rw(1:3)
394  ENDIF
395  !IF (ITOUT.EQ.0) CALL IS_IN_UNGRID(IG, XGRD(IY,IX)+DX, YGRD(IY,IX), ITOUT, IS, JS, RW)
396  !IF (ITOUT.GT.0) INGRID=.TRUE.
397  !IF (ITOUT.EQ.0) CALL IS_IN_UNGRID(IG, XGRD(IY,IX)-DX, YGRD(IY,IX), ITOUT, IS, JS, RW)
398  !IF (ITOUT.GT.0) INGRID=.TRUE.
399  !IF (ITOUT.EQ.0) CALL IS_IN_UNGRID(IG, XGRD(IY,IX), YGRD(IY,IX)+DY, ITOUT, IS, JS, RW)
400  !IF (ITOUT.GT.0) INGRID=.TRUE.
401  !IF (ITOUT.EQ.0) CALL IS_IN_UNGRID(IG, XGRD(IY,IX), YGRD(IY,IX)-DY, ITOUT, IS, JS, RW)
402  !IF (ITOUT.GT.0) INGRID=.TRUE.
403  END IF
404  ELSE
405  IF ( w3grmp( grids(ig)%GSU, real(xgrd(iy,ix)), real(ygrd(iy,ix)), is, &
406  js, rw ) ) ingrid=.true.
407  END IF
408  IF (ingrid) THEN
409  !
410  ! 4.b.iii Check source grid resolution vs target grid resolution
411  ! (averaging used for finer resolution source grids)
412  !
413  IF (grids(ig)%GTYPE .EQ. ungtype) THEN
414  sarea = grids(ig)%TRIA(itout)
415  ELSE
416  DO i = 1,4
417  xcrnr(i) = grids(ig)%XGRD(js(i),is(i))
418  ycrnr(i) = grids(ig)%YGRD(js(i),is(i))
419  END DO
420  xcrnr(5) = xcrnr(1)
421  ycrnr(5) = ycrnr(1)
422  DO i = 1,4
423  IF ( abs(xcrnr(i+1)-xcrnr(i)) .GT. 180. .AND. &
424  grids(ig)%ICLOSE .EQ. iclose_smpl ) THEN
425  dt(i) = sqrt( (abs(xcrnr(i+1)-xcrnr(i))-360.)**2 + &
426  (ycrnr(i+1)-ycrnr(i))**2 )
427  ELSE
428  dt(i) = sqrt( (xcrnr(i+1)-xcrnr(i))**2 + &
429  (ycrnr(i+1)-ycrnr(i))**2 )
430  END IF
431  END DO
432  sxt = 0.5*(dt(1)+dt(3))
433  syt = 0.5*(dt(2)+dt(4))
434  sarea = (sxt*syt)
435  END IF
436  ns = nint(darea/sarea)
437  !
438  IF ( ns .LE. 2 .OR. grids(ig)%GTYPE .EQ. ungtype ) THEN
439  ! FA: Quick fix for UNST type grids: always perform interpolation
440  ! To be updated later ...
441  !
442  ! 4.b.iv Counting the contributing nodes to re-normalize the weights RW
443  !
444  ALLOCATE ( tmp_indx(4) )
445  countf = 0
446  sumwt = 0.0
447  DO i = 1,4
448  ! The following two IF tests are separated because for triangles, JS(4)=IS(4)=0
449  IF ( rw(i) .GT. 0.0 ) THEN
450  ! MAPSTA == 0 indicated excluded point (either land
451  ! or truly excluded)
452  IF ( grids(ig)%MAPSTA(js(i),is(i)) .NE. 0) THEN
453  countf = countf+1
454  tmp_indx(countf) = i
455  sumwt = sumwt + rw(i)
456  END IF
457  END IF
458  END DO
459  !
460  ! 4.b.v Interpolating to target grid
461  !
462  IF ( countf .GT. 0 ) THEN
463  ! Should use SAREA info to prevent the increment of COUNTG ...
464  ! what about islands / land in triangle meshes? they are not part of the triangles...
465  countg = countg + 1
466  IF (countg.GT.1) THEN
467  IF (sarea.LT.0.5*gr_ints(isea)%IND_WTS(countg-1)%AR) THEN
468  DO jg=1,countg-1
469  DEALLOCATE (gr_ints(isea)%IND_WTS(jg)%IP)
470  DEALLOCATE (gr_ints(isea)%IND_WTS(jg)%JP)
471  DEALLOCATE (gr_ints(isea)%IND_WTS(jg)%WT)
472  END DO
473  countg=1
474  END IF
475  END IF
476 
477  gr_ints(isea)%IND_WTS(countg)%AR = sarea
478  gr_ints(isea)%GDID(countg) = ig
479  int_map(ix,iy) = real( ig )
480 
481  ALLOCATE ( gr_ints(isea)%IND_WTS(countg)%IP(countf), &
482  gr_ints(isea)%IND_WTS(countg)%JP(countf), &
483  gr_ints(isea)%IND_WTS(countg)%WT(countf) )
484  DO i = 1,countf
485  gr_ints(isea)%IND_WTS(countg)%IP(i) = is(tmp_indx(i))
486  gr_ints(isea)%IND_WTS(countg)%JP(i) = js(tmp_indx(i))
487  gr_ints(isea)%IND_WTS(countg)%WT(i) = rw(tmp_indx(i))/sumwt
488  END DO
489  gr_ints(isea)%IND_WTS(countg)%NP = countf
490  END IF
491  DEALLOCATE ( tmp_indx )
492  !
493  ELSE
494  !
495  ! 4.b.vi Find the averaging points for higher resolution grid
496  ! Step 1 : Compute the corners of the cell
497  !
498  x0 = xgrd(iy,ix)
499  y0 = ygrd(iy,ix)
500  IF ( ix .GT. 1 .AND. ix .LT. nx .AND. iy .GT. 1 &
501  .AND. iy .LT. ny ) THEN
502  xt = xgrd(iy-1,ix+1)
503  yt = ygrd(iy-1,ix+1)
504  IF ( abs(xt-x0) .GT. 270 ) THEN
505  xt = xt - sign(360.,xt-x0)
506  END IF
507  xcrnr(1) = 0.5*(xt+x0)
508  ycrnr(1) = 0.5*(yt+y0)
509  xt = xgrd(iy+1,ix+1)
510  yt = ygrd(iy+1,ix+1)
511  IF ( abs(xt-x0) .GT. 270 ) THEN
512  xt = xt - sign(360.,xt-x0)
513  END IF
514  xcrnr(2) = 0.5*(xt+x0)
515  ycrnr(2) = 0.5*(yt+y0)
516  xt = xgrd(iy+1,ix-1)
517  yt = ygrd(iy+1,ix-1)
518  IF ( abs(xt-x0) .GT. 270 ) THEN
519  xt = xt - sign(360.,xt-x0)
520  END IF
521  xcrnr(3) = 0.5*(xt+x0)
522  ycrnr(3) = 0.5*(yt+y0)
523  xt = xgrd(iy-1,ix-1)
524  yt = ygrd(iy-1,ix-1)
525  IF ( abs(xt-x0) .GT. 270 ) THEN
526  xt = xt - sign(360.,xt-x0)
527  END IF
528  xcrnr(4) = 0.5*(xt+x0)
529  ycrnr(4) = 0.5*(yt+y0)
530  ELSEIF ( ix .EQ. 1 ) THEN
531  IF ( iy .EQ. 1 ) THEN
532  xt = xgrd(iy+1,ix+1)
533  yt = ygrd(iy+1,ix+1)
534  IF ( abs(xt-x0) .GT. 270 ) THEN
535  xt = xt - sign(360.,xt-x0)
536  END IF
537  xcrnr(2) = 0.5*(xt+x0)
538  ycrnr(2) = 0.5*(yt+y0)
539  xcrnr(4) = 2*x0 - xcrnr(2)
540  ycrnr(4) = 2*y0 - ycrnr(2)
541  xcrnr(3) = x0 - (ycrnr(2)-y0)
542  ycrnr(3) = y0 + (xcrnr(2)-x0)
543  xcrnr(1) = 2*x0 - xcrnr(3)
544  ycrnr(1) = 2*y0 - ycrnr(3)
545  ELSEIF ( iy .EQ. ny ) THEN
546  xt = xgrd(iy-1,ix+1)
547  yt = ygrd(iy-1,ix+1)
548  IF ( abs(xt-x0) .GT. 270 ) THEN
549  xt = xt - sign(360.,xt-x0)
550  END IF
551  xcrnr(1) = 0.5*(xt+x0)
552  ycrnr(1) = 0.5*(yt+y0)
553  xcrnr(3) = 2*x0 - xcrnr(1)
554  ycrnr(3) = 2*y0 - ycrnr(1)
555  xcrnr(2) = x0 - (y0-ycrnr(1))
556  ycrnr(2) = y0 + (x0-xcrnr(1))
557  xcrnr(4) = 2*x0 - xcrnr(2)
558  ycrnr(4) = 2*y0 - ycrnr(2)
559  ELSE
560  xt = xgrd(iy-1,ix+1)
561  yt = ygrd(iy-1,ix+1)
562  IF ( abs(xt-x0) .GT. 270 ) THEN
563  xt = xt - sign(360.,xt-x0)
564  END IF
565  xcrnr(1) = 0.5*(xt+x0)
566  ycrnr(1) = 0.5*(yt+y0)
567  xt = xgrd(iy+1,ix+1)
568  yt = ygrd(iy+1,ix+1)
569  IF ( abs(xt-x0) .GT. 270 ) THEN
570  xt = xt - sign(360.,xt-x0)
571  END IF
572  xcrnr(2) = 0.5*(xt+x0)
573  ycrnr(2) = 0.5*(yt+y0)
574  xcrnr(3) = 2*x0 - xcrnr(1)
575  ycrnr(3) = 2*y0 - ycrnr(1)
576  xcrnr(4) = 2*x0 - xcrnr(2)
577  ycrnr(4) = 2*y0 - ycrnr(2)
578  ENDIF
579  ELSEIF ( ix .EQ. nx ) THEN
580  IF ( iy .EQ. 1 ) THEN
581  xt = xgrd(iy+1,ix-1)
582  yt = ygrd(iy+1,ix-1)
583  IF ( abs(xt-x0) .GT. 270 ) THEN
584  xt = xt - sign(360.,xt-x0)
585  END IF
586  xcrnr(3) = 0.5*(xt+x0)
587  ycrnr(3) = 0.5*(yt+y0)
588  xcrnr(2) = x0 - (ycrnr(3)-y0)
589  ycrnr(2) = y0 + (xcrnr(3)-x0)
590  xcrnr(1) = 2*x0 - xcrnr(3)
591  ycrnr(1) = 2*y0 - ycrnr(3)
592  xcrnr(4) = 2*x0 - xcrnr(2)
593  ycrnr(4) = 2*y0 - ycrnr(2)
594  ELSEIF ( iy .EQ. ny ) THEN
595  xt = xgrd(iy-1,ix-1)
596  yt = ygrd(iy-1,ix-1)
597  IF ( abs(xt-x0) .GT. 270 ) THEN
598  xt = xt - sign(360.,xt-x0)
599  END IF
600  xcrnr(4) = 0.5*(xt+x0)
601  ycrnr(4) = 0.5*(yt+y0)
602  xcrnr(3) = x0 - (ycrnr(4)-y0)
603  ycrnr(3) = y0 + (xcrnr(4)-x0)
604  xcrnr(1) = 2*x0 - xcrnr(3)
605  ycrnr(1) = 2*y0 - ycrnr(3)
606  xcrnr(2) = 2*x0 - xcrnr(4)
607  ycrnr(2) = 2*y0 - ycrnr(4)
608  ELSE
609  xt = xgrd(iy+1,ix-1)
610  yt = ygrd(iy+1,ix-1)
611  IF ( abs(xt-x0) .GT. 270 ) THEN
612  xt = xt - sign(360.,xt-x0)
613  END IF
614  xcrnr(3) = 0.5*(xt+x0)
615  ycrnr(3) = 0.5*(yt+y0)
616  xt = xgrd(iy-1,ix-1)
617  yt = ygrd(iy-1,ix-1)
618  IF ( abs(xt-x0) .GT. 270 ) THEN
619  xt = xt - sign(360.,xt-x0)
620  END IF
621  xcrnr(4) = 0.5*(xt+x0)
622  ycrnr(4) = 0.5*(yt+y0)
623  xcrnr(1) = 2*x0 - xcrnr(3)
624  ycrnr(1) = 2*y0 - ycrnr(3)
625  xcrnr(2) = 2*x0 - xcrnr(4)
626  ycrnr(2) = 2*y0 - ycrnr(4)
627  ENDIF
628  ELSE
629  IF ( iy .EQ. 1 ) THEN
630  xt = xgrd(iy+1,ix+1)
631  yt = ygrd(iy+1,ix+1)
632  IF ( abs(xt-x0) .GT. 270 ) THEN
633  xt = xt - sign(360.,xt-x0)
634  END IF
635  xcrnr(2) = 0.5*(xt+x0)
636  ycrnr(2) = 0.5*(yt+y0)
637  xt = xgrd(iy+1,ix-1)
638  yt = ygrd(iy+1,ix-1)
639  IF ( abs(xt-x0) .GT. 270 ) THEN
640  xt = xt - sign(360.,xt-x0)
641  END IF
642  xcrnr(3) = 0.5*(xt+x0)
643  ycrnr(3) = 0.5*(yt+y0)
644  xcrnr(4) = 2*x0 - xcrnr(2)
645  ycrnr(4) = 2*y0 - ycrnr(2)
646  xcrnr(1) = 2*x0 - xcrnr(3)
647  ycrnr(1) = 2*y0 - ycrnr(3)
648  ELSE
649  xt = xgrd(iy-1,ix-1)
650  yt = ygrd(iy-1,ix-1)
651  IF ( abs(xt-x0) .GT. 270 ) THEN
652  xt = xt - sign(360.,xt-x0)
653  END IF
654  xcrnr(4) = 0.5*(xt+x0)
655  ycrnr(4) = 0.5*(yt+y0)
656  xt = xgrd(iy-1,ix+1)
657  yt = ygrd(iy-1,ix+1)
658  IF ( abs(xt-x0) .GT. 270 ) THEN
659  xt = xt - sign(360.,xt-x0)
660  END IF
661  xcrnr(1) = 0.5*(xt+x0)
662  ycrnr(1) = 0.5*(yt+y0)
663  xcrnr(2) = 2*x0 - xcrnr(4)
664  ycrnr(2) = 2*y0 - ycrnr(4)
665  xcrnr(3) = 2*x0 - xcrnr(1)
666  ycrnr(3) = 2*y0 - ycrnr(1)
667  END IF
668  END IF
669  brnchcl = .false.
670  brnchcr = .false.
671  IF ( flagll .AND. iclose .EQ. iclose_smpl ) THEN
672  IF ( l360 ) THEN
673  IF ( minval( xcrnr(1:4) ) .LT. 0.0 ) brnchcl = .true.
674  IF ( maxval( xcrnr(1:4) ) .GT. 360.0 ) brnchcr = .true.
675  ELSE
676  IF ( minval( xcrnr(1:4) ) .LT. -180.0 ) brnchcl = .true.
677  IF ( maxval( xcrnr(1:4) ) .GT. 180.0 ) brnchcr = .true.
678  END IF
679  END IF
680  !
681  ! Step 2 : Loop through source grid to find all active points in cell
682  !
683  !FA : why only *5 ???...
684  !
685  ALLOCATE ( tmp_indx(ns*5) )
686  countf = 0
687  DO i = 1, grids(ig)%NSEA
688  ixt = grids(ig)%MAPSF(i,1)
689  iyt = grids(ig)%MAPSF(i,2)
690  xt = grids(ig)%XGRD(iyt,ixt)
691  yt = grids(ig)%YGRD(iyt,ixt)
692  !
693  IF ( flagll ) THEN
694  IF ( l360 ) THEN
695  IF ( xt .LT. 0 ) xt = xt + 360.
696  ELSE
697  IF ( xt .GT. 180. ) xt = xt - 360.
698  END IF
699  END IF
700  ingrd = w3ckcl(flagll,xt,yt,4,xcrnr,ycrnr,lplc)
701  IF ( ingrd ) THEN
702  countf = countf+1
703  tmp_indx(countf) = i
704  ELSEIF ( brnchcl .AND. grids(ig)%ICLOSE &
705  .EQ. iclose_smpl ) THEN
706  xtt = xt - 360.0
707  ingrd = w3ckcl(flagll,xtt,yt,4,xcrnr,ycrnr,lplc)
708  IF ( ingrd ) THEN
709  countf = countf+1
710  tmp_indx(countf) = i
711  END IF
712  ELSEIF ( brnchcr .AND. grids(ig)%ICLOSE &
713  .EQ. iclose_smpl ) THEN
714  xtt = xt + 360.0
715  ingrd = w3ckcl(flagll,xtt,yt,4,xcrnr,ycrnr,lplc)
716  IF ( ingrd ) THEN
717  countf = countf+1
718  tmp_indx(countf) = i
719  END IF
720  END IF
721  END DO
722  !
723  ! Step 3 : Save interior points for equal wt. interpolation (averaging)
724  !
725  IF ( countf .NE. 0 ) THEN
726  countg = countg + 1
727  gr_ints(isea)%GDID(countg) = ig
728  int_map(ix,iy) = real( ig )
729  ALLOCATE ( gr_ints(isea)%IND_WTS(countg)%IP(countf), &
730  gr_ints(isea)%IND_WTS(countg)%JP(countf), &
731  gr_ints(isea)%IND_WTS(countg)%WT(countf) )
732  DO i = 1,countf
733  ixt = grids(ig)%MAPSF(tmp_indx(i),1)
734  iyt = grids(ig)%MAPSF(tmp_indx(i),2)
735  gr_ints(isea)%IND_WTS(countg)%IP(i) = ixt
736  gr_ints(isea)%IND_WTS(countg)%JP(i) = iyt
737  gr_ints(isea)%IND_WTS(countg)%WT(i) = 1./( real(countf) )
738  END DO
739  gr_ints(isea)%IND_WTS(countg)%NP = countf
740  END IF
741  DEALLOCATE ( tmp_indx )
742  !
743  END IF ! End of check for grid resolution
744  !
745  END IF ! End of check for point inside grid
746  !
747  END DO ! End of loop through all input grids
748  !
749  gr_ints(isea)%NGRDS = countg
750  !
751  ! 4.b.vii Check to see if interpolation weights found.
752  ! Status of output points with / without weights set in MAPST2
753  ! using the next available bit
754  !
755  IF ( gr_ints(isea)%NGRDS .EQ. 0 ) THEN
756 #ifdef W3_T
757  WRITE (ndso,909)ix, iy
758 #endif
759  inoint=inoint+1
760  noint(inoint)=isea
761  mapint = 1
762  mapst2(iy,ix) = mapst2(iy,ix) + mapint*16
763  mapsta(iy,ix) = -abs( mapsta(iy,ix) )
764  END IF
765  !
766  END DO ! End of loop through all wet points
767  !
768  ! Now dumps the coefficients to file ...
769  WRITE(994) nsea
770  DO isea = 1, nsea
771  countg = gr_ints(isea)%NGRDS
772  WRITE(994) countg
773  DO ig = 1,countg
774  WRITE(994) gr_ints(isea)%IND_WTS(ig)%AR
775  WRITE(994) gr_ints(isea)%GDID(ig)
776  countf = gr_ints(isea)%IND_WTS(ig)%NP
777  WRITE(994) countf
778  DO i = 1,countf
779  WRITE(994) gr_ints(isea)%IND_WTS(ig)%IP(i)
780  WRITE(994) gr_ints(isea)%IND_WTS(ig)%JP(i)
781  WRITE(994) gr_ints(isea)%IND_WTS(ig)%WT(i)
782  END DO
783  WRITE(994) gr_ints(isea)%IND_WTS(ig)%NP
784  END DO ! IG
785  WRITE(994) gr_ints(isea)%NGRDS
786  END DO ! ISEA
787  END IF ! NSEA.EQ.NSEA_FILE
788  CLOSE(994)
789  !
790  ! 4.c Print Interpolation grids map
791  !
792  ix = 1+nx/24
793  iy = 1+ny/24
794  CALL prtblk ( ndso, nx, ny, nx, int_map, map, -1, 1., 1, nx, ix, 1, &
795  ny, iy, 'Grid Interpolation Map', ' ' )
796  !
797  !---------------------------------------------------------------------------
798  ! 5 Output interpolations
799  !
800  ! 5.a Set-up dimensions for target grid outputs and allocate file pointers
801  !
802  CALL w3seta(ng, 6, 6)
803  CALL w3dima(ng, 6, 6, .true.)
804  IF (outorrest) THEN
805  CALL w3dimw(ng, 6, 6, .true.)
806  ELSE
807  CALL w3dimw(ng, 6, 6)
808  END IF
809  ALLOCATE(fidout(ng))
810  DO ig = 1,ng
811  fidout(ig) = 30 + (ig-1)*10
812  END DO
813  !---- If out_grd --------------
814  IF (outorrest) THEN !OUTorREST=.TRUE.=out_grd FALSE=restart
815  !
816  ! 5.b Initialize and read the first set of fields for base grids
817  !
818  DO ig = 1,ng-1
819  CALL w3seto( ig, 6, 6)
820  CALL w3iogo('READ',fidout(ig),iotst,ig)
821  IF ( iotst .NE. 0 ) THEN
822  GO TO 2111
823  ENDIF
824  END DO
825  !
826  ! 5.c Setup the output flag options for the target grid
827  !
828  WRITE (ndso,910)
829  DO i = 1, nogrp
830  outpts(ng)%OUT1%FLOGRD(i,:) = outpts(1)%OUT1%FLOGRD(i,:)
831  WRITE (ndso,911) i
832  IF (i.LT.9) THEN
833  WRITE (ndso, 912) (outpts(ng)%OUT1%FLOGRD(i,j),j=1,ngrpp)
834  ELSE
835  WRITE (ndso, 913)
836  END IF
837  END DO
838  WRITE (ndso, 915)
839  !
840  ! Print output flags in human readable from. Mark
841  ! groups that do not make sense to interpolate to
842  ! target grid (e.g. Groups 9, 10).
843  !
844  DO i=1, nogrp
845  DO j=1, ngrpp
846  IF ( outpts(ng)%OUT1%FLOGRD(i,j) ) THEN
847  IF ( i .EQ. 4 .AND. j .EQ. 8 ) THEN
848  WRITE (ndso, 916) i,idout(i,j), '*** NOT IMPLEMENTED ***'
849  outpts(ng)%OUT1%FLOGRD(i,j) = .false.
850  ELSE IF ( i .LE. 8 ) THEN
851  WRITE (ndso, 916) i,idout(i,j), ' '
852  ELSE
853  WRITE (ndso, 916) i,idout(i,j), '*** NOT IMPLEMENTED ***'
854  outpts(ng)%OUT1%FLOGRD(i,j) = .false.
855  END IF
856  END IF
857  END DO
858  END DO
859  WRITE (ndso, 915)
860  !
861  ! 5.d Carry out interpolation in an infinite loop till appropriate
862  ! time steps are interpolated
863  !
864  iout = 0
865  !
866  DO
867  dtest = dsec21( wdatas(1)%TIME, tout )
868  IF ( dtest .GT. 0. ) THEN
869  DO ig = 1,ng-1
870  CALL w3iogo('READ',fidout(ig),iotst,ig)
871  IF ( iotst .NE. 0 ) THEN
872  GO TO 2111
873  ENDIF
874  END DO
875  cycle
876  ENDIF
877  IF ( dtest .LT. 0. ) THEN
878  CALL tick21 ( tout , dtreq )
879  cycle
880  END IF
881  !
882  iout = iout + 1
883  CALL stme21 ( tout, idtime)
884  WRITE (ndso,914) idtime
885  !
886  wdatas(ng)%TIME = wdatas(1)%TIME
887  CALL w3seto(ng, 6, 6)
888  CALL w3setg(ng, 6, 6)
889  CALL w3seta(ng, 6, 6)
890  CALL w3setw(ng, 6, 6)
891  !
892  CALL w3exgi ( ng-1, nsea, noswll_min, intmethod, outorrest,mapsta_ng,mapst2_ng )
893  !
894  CALL tick21 ( tout , dtreq )
895  IF ( iout .GE. nout ) EXIT
896  END DO
897  GOTO 2222
898  ! --- if Restart file --------
899  ELSE !OUTorREST=.FALSE.
900  !
901  ! 5.b Initialize and read the first set of restarts for base grids
902  !
903  DO ig = 1,ng-1
904  wdatas(ig)%TIME = tout
905  CALL w3setg(ig, 6, 6)
906  CALL w3setw(ig, 6, 6)
907  CALL w3seta(ig, 6, 6)
908  CALL w3seto(ig, 6, 6)
909 #ifdef W3_WRST
910  CALL w3dimi(ig, 6, 6)
911 #endif
912  nseal=nsea ! Set for reading restarts
913 
914  !To use an older model version restart file (add a w3iorsold)
915  !CALL W3IORSOLD ( 'READ', 56, XXX, INTYPE, IG )
916  CALL w3iors ( 'READ', 56, xxx, ig )
917  END DO
918 
919  ! 5.d Carry out interpolation
920  wdatas(ng)%TIME = tout
921  CALL w3setg(ng, 6, 6)
922  CALL w3setw(ng, 6, 6)
923  CALL w3seta(ng, 6, 6)
924  CALL w3seto(ng, 6, 6)
925 #ifdef W3_WRST
926  inputs(ng)%INFLAGS1(3)=.true.
927  CALL w3dimi(ng, 6, 6)
928 #endif
929 
930  CALL w3exgi ( ng-1, nsea, noswll_min, intmethod, outorrest,mapsta_ng,mapst2_ng )
931 
932  GOTO 2222
933 
934  END IF !OUTorREST
935  !
936  !---------------------------------------------------------------------------
937  ! Escape locations read errors :
938  !
939 2000 CONTINUE
940  WRITE (ndse,1000) ierr
941  CALL extcde ( 1 )
942 2001 CONTINUE
943  WRITE(ndse,1001)
944  CALL extcde ( 2 )
945 2002 CONTINUE
946  WRITE(ndse,1002) ierr
947  CALL extcde ( 3 )
948 2111 CONTINUE
949  WRITE(ndso,950)
950 2222 CONTINUE
951  WRITE(ndso,999)
952  !
953  !---------------------------------------------------------------------------
954  ! Formats
955  !
956 900 FORMAT (/15x,' *** WAVEWATCH III Grid interpolation *** '/ &
957  15x,'==============================================='/)
958 901 FORMAT ( ' Comment character is ''',a,''''/)
959 902 FORMAT ( ' Time Information : '/ &
960  '---------------------------------------------'/ &
961  ' Starting Time : ',a/ &
962  ' Interval (in sec) : ',f10.2/ &
963  ' Number of requests : ',i4/ &
964  '---------------------------------------------')
965 903 FORMAT ( ' Number of grids (including output grid) =',i3/)
966 904 FORMAT ( /' Extension for grid ',i3,' is --> ',a10/)
967 905 FORMAT ( ' Grid Particulars are : '/ &
968  ' Dimensions = ',2(i9,2x)/ &
969  ' Grid Type = ',i3,' ==> 1 Rect, 2 Curv, 3 Unstr'/ &
970  ' Grid Closure = ',i3,' ==> -1 None, 2 Simple, 8 Tripolar')
971 907 FORMAT ( /' NOTE : The no. of swell partitions from input and', &
972  ' target grids do not match',/ &
973  ' The Min. no. of partitions from input grids =',i5/ &
974  ' The no. of partitions for target grid =',i5/ &
975  ' Interpolation will be limited to the smaller', &
976  ' number of the partitions,',/ &
977  ' rest will be marked undefined.' )
978 908 FORMAT (/' Preparing interpolation weights for output grid ' / &
979  ' Total number of wet points for interpolation ',i7/)
980 909 FORMAT (/' *** WARNING !! No interpolation points at ',2(i5)/)
981 910 FORMAT (/' Interpolating fields .... '/)
982 911 FORMAT (' Output group ', i5)
983 912 FORMAT (' Output variable flags are -> ',7(5l2,1x))
984 913 FORMAT (' Output variables skipped')
985 914 FORMAT ( ' OUTPUT TIME : ',a)
986 915 FORMAT ( ' ------------------------------------------------')
987 916 FORMAT ( i5,a,2x,a)
988 917 FORMAT (/' Interpolation scheme = ',i1,' ==> 0 linear, ', &
989  '1 extrapolate unstructured, 2 nearest'/)
990 950 FORMAT (/' End of file reached'/)
991 999 FORMAT (/15x,' *** End of Grid interpolation Routine *** '/ &
992  15x,'==============================================='/)
993  !
994 1000 FORMAT (/' *** ERROR IN WAVEGRID_INTERP : '/ &
995  ' ERROR IN OPENING INPUT FILE'/ &
996  ' IOSTAT =',i5/)
997 1001 FORMAT (/' *** ERROR IN WAVEGRID_INTERP : '/ &
998  ' PREMATURE END IN INPUT FILE'/)
999 1002 FORMAT (/' *** ERROR IN WAVEGRID_INTERP : '/ &
1000  ' ERROR IN READING FROM INPUT FILE'/ &
1001  ' IOSTAT =',i5/)
1002  !
1003  !/
1004  !/ Internal Subroutine
1005  !/
1006  !/ Internal Subroutine W3EXGI ----------------------------------------------/
1007  !/
1008 CONTAINS
1009  !/ -----------------------------------------------------------------------/
1017  !
1018  SUBROUTINE w3exgi ( NGRD, NSEA, NOSWLL_MIN, INTMETHOD, OUTorRESTflag, &
1019  MAPSTA_NG,MAPST2_NG )
1020  !/ +-----------------------------------+
1021  !/ | WAVEWATCH-III NOAA/NCEP |
1022  !/ | A. Chawla |
1023  !/ | FORTRAN 90 |
1024  !/ | Last update : 22-Mar-2021 |
1025  !/ +-----------------------------------+
1026  !/
1027  !/ 09-Jul-2009 : Original code ( version 3.14 )
1028  !/ 21-Feb-2013 : Modified to new output structure ( version 4.11 )
1029  !/ 30-Apr-2014 : Add group 3 ( version 5.00 )
1030  !/ 27-Aug-2015 : ice thick. and floe added as output ( version 5.10 )
1031  !/ 22-Mar-2021 : New coupling fields output ( version 7.13 )
1032  !/
1033  ! 1. Purpose :
1034  !
1035  ! Perform actual output of interpolated data.
1036  !
1037  ! 3. Parameters :
1038  !
1039  ! 4. Subroutines used :
1040  !
1041  ! Name Type Module Description
1042  ! ----------------------------------------------------------------
1043  ! W3IOGO Subr. W3IOGOMD Reading/writing raw gridded data file.
1044  ! ----------------------------------------------------------------
1045  !
1046  ! 5. Called by :
1047  !
1048  ! Subroutine it resides in
1049  !
1050  ! 6. Error messages :
1051  !
1052  ! None.
1053  !
1054  ! 7. Remarks :
1055  !
1056  ! 8. Structure :
1057  !
1058  ! See source code.
1059  !
1060  ! 9. Switches :
1061  !
1062  ! 10. Source code :
1063  !
1064  !/ -------------------------------------------------------------------------/
1065  USE w3adatmd
1066  USE w3wdatmd
1067  USE w3odatmd, ONLY: noge
1068  USE w3iogomd, ONLY: w3iogo
1069  USE w3gdatmd, ONLY: e3df, nk, nspec
1070  USE w3iorsmd, ONLY: w3iors
1071  !/ -------------------------------------------------------------------------/
1072  !/ Parameter List
1073  !/
1074  INTEGER, INTENT(IN) :: NGRD, NSEA, NOSWLL_MIN, INTMETHOD
1075  !/
1076  !/ Local Parameters
1077  !/
1078  INTEGER :: ISEA, GSEA, IG, IGRID, IPTS, IGX, IGY, IX, &
1079  IY, ISWLL, ICAP, IBED, IFREQ, IK, INRST
1080  INTEGER :: MAPINT, MAPICE, MAPDRY, MAPMSK, MAPLND, &
1081  NMAPICE, NMAPDRY, NMAPMSK, NMAPLND, &
1082  LMAPICE, LMAPDRY, LMAPMSK, LMAPLND, &
1083  MAPICET, MAPDRYT, MAPMSKT, MAPLNDT
1084  INTEGER :: SUMGRD
1085  REAL :: VAR1, VAR2, WT
1086  ! Local group 1 variables
1087  REAL :: DWAUX, CXAUX, CYAUX, UAAUX, UDAUX, ASAUX, &
1088  WLVAUX, ICEAUX, ICEHAUX, ICEFAUX, BERGAUX, &
1089  SED_D50AUX, RHOAIRAUX, TAUAAUX, TAUADIRAUX, &
1090  SUMWT1(NOGE(1))
1091  ! Local group 2 variables
1092  REAL :: HSAUX, WLMAUX, T02AUX, T0M1AUX, T01AUX, &
1093  FP0AUX, THMAUX1, THMAUX2, THSAUX, THP0AUX1, &
1094  THP0AUX2, HSIGAUX, STMAXEAUX,STMAXDAUX, &
1095  HMAXEAUX, HCMAXEAUX, HMAXDAUX, HCMAXDAUX, &
1096  WBTAUX, WNMEANAUX, SUMWT2(NOGE(2))
1097  ! Local group 3 variables
1098  REAL :: EFAUX(E3DF(2,1):E3DF(3,1)), &
1099  TH1MAUX(E3DF(2,2):E3DF(3,2)), &
1100  STH1MAUX(E3DF(2,3):E3DF(3,3)), &
1101  TH2MAUX(E3DF(2,4):E3DF(3,4)), &
1102  STH2MAUX(E3DF(2,5):E3DF(3,5)), WNAUX(1:NK), &
1103  SUMWT3A(E3DF(2,1):E3DF(3,1)), &
1104  SUMWT3B(E3DF(2,2):E3DF(3,2)), &
1105  SUMWT3C(E3DF(2,3):E3DF(3,3)), &
1106  SUMWT3D(E3DF(2,4):E3DF(3,4)), &
1107  SUMWT3E(E3DF(2,5):E3DF(3,5)), &
1108  SUMWT3F(1:NK)
1109  ! Local group 4 variables
1110  REAL :: PHSAUX(0:NOSWLL_MIN), PTPAUX(0:NOSWLL_MIN), &
1111  PLPAUX(0:NOSWLL_MIN), PSIAUX(0:NOSWLL_MIN), &
1112  PWSAUX(0:NOSWLL_MIN), PDIRAUX1(0:NOSWLL_MIN), &
1113  PWSTAUX, PDIRAUX2(0:NOSWLL_MIN), &
1114  PTHP0AUX1(0:NOSWLL_MIN), &
1115  PTHP0AUX2(0:NOSWLL_MIN), &
1116  PQPAUX(0:NOSWLL_MIN), PPEAUX(0:NOSWLL_MIN), &
1117  PGWAUX(0:NOSWLL_MIN), PSWAUX(0:NOSWLL_MIN), &
1118  PTM1AUX(0:NOSWLL_MIN), PT1AUX(0:NOSWLL_MIN), &
1119  PT2AUX(0:NOSWLL_MIN), PEPAUX(0:NOSWLL_MIN), &
1120  SUMWT4(NOGE(4),0:NOSWLL_MIN)
1121  ! Local group 5 variables
1122  REAL :: USTAUX1, USTAUX2, CHARNAUX, CGEAUX, &
1123  PHIAWAUX, TAUWIXAUX, TAUWIYAUX, TAUWNXAUX, &
1124  TAUWNYAUX, WHITECAPAUX(4), SUMWT5(NOGE(5)), &
1125  SUMWTC(4)
1126  ! Local group 6 variables
1127  REAL :: SXXAUX, SYYAUX, SXYAUX, TAUOXAUX, TAUOYAUX, &
1128  BHDAUX, PHIOCAUX, TUSXAUX, TUSYAUX, USSXAUX, &
1129  USSYAUX, PRMSAUX, TPMSAUX, SUMWT6(NOGE(6)), &
1130  TAUICEAUX(2), PHICEAUX, &
1131  TAUOCXAUX, TAUOCYAUX, &
1132  US3DAUX(2*NK), SUMWT68(2*NK), &
1133  P2SMSAUX(P2MSF(2):P2MSF(3)), &
1134  SUMWT69(P2MSF(2):P2MSF(3)), &
1135  USSPAUX(2*NK), SUMWT612(2*NK)
1136  ! Local Group 7 variables
1137  REAL :: ABAAUX, ABDAUX, UBAAUX, UBDAUX, PHIBBLAUX, &
1138  BEDFORMSAUX(3), TAUBBLAUX(2), &
1139  SUMWT7(NOGE(7)), SUMWTB(3)
1140  ! Local group 8 variables
1141  REAL :: MSSXAUX, MSSYAUX, MSCXAUX, MSCYAUX, MSSDAUX1, &
1142  MSSDAUX2, MSCDAUX1, MSCDAUX2, QPAUX, &
1143  SUMWT8(NOGE(8))
1144  !/
1145  LOGICAL :: ACTIVE
1146  LOGICAL :: USEGRID(NGRD)
1147  !
1148  !variables for restart
1149  LOGICAL :: OUTorRESTflag
1150  REAL :: VAAUX(NSPEC), SUMRES(NSPEC)
1151  INTEGER :: INTYPE
1152  REAL :: XXX
1153  INTEGER :: MAPSTA_NG(NY,NX),MAPST2_NG(NY,NX)
1154  !/
1155  !
1156  !-------------------------------------------------------------------
1157  ! 1. Preparations
1158  !
1159  ! Group 1 Variables
1160  !
1161  dw = undef
1162  cx = undef
1163  cy = undef
1164  ua = undef
1165  ud = undef
1166  as = undef
1167  wlv = undef
1168  ice = undef
1169  berg = undef
1170  rhoair = undef
1171  taua = undef
1172  tauadir = undef
1173 #ifdef W3_BT4
1174  sed_d50 = undef
1175 #endif
1176 #ifdef W3_IS2
1177  iceh = undef
1178  icef = undef
1179 #endif
1180  !
1181  ! Group 2 variables
1182  !
1183  hs = undef
1184  wlm = undef
1185  t02 = undef
1186  t0m1 = undef
1187  t01 = undef
1188  fp0 = undef
1189  thm = undef
1190  ths = undef
1191  thp0 = undef
1192  hsig = undef
1193  stmaxe = undef
1194  stmaxd = undef
1195  hmaxe = undef
1196  hcmaxe = undef
1197  hmaxd = undef
1198  hcmaxd = undef
1199  wbt = undef
1200  wnmean = undef
1201  !
1202  ! Group 3 variables
1203  !
1204  IF ( e3df(1,1).GT.0 ) ef = undef
1205  IF ( e3df(1,2).GT.0 ) th1m = undef
1206  IF ( e3df(1,3).GT.0 ) sth1m = undef
1207  IF ( e3df(1,4).GT.0 ) th2m = undef
1208  IF ( e3df(1,5).GT.0 ) sth2m = undef
1209  wn = undef
1210  !
1211  ! Group 4 variables
1212  !
1213  phs = undef
1214  ptp = undef
1215  plp = undef
1216  pdir = undef
1217  psi = undef
1218  pws = undef
1219  pwst = undef
1220  pnr = undef
1221  pthp0 = undef
1222  pqp = undef
1223  ppe = undef
1224  pgw = undef
1225  psw = undef
1226  ptm1 = undef
1227  pt1 = undef
1228  pt2 = undef
1229  pep = undef
1230  !
1231  ! Group 5 variables
1232  !
1233  ust = undef
1234  ustdir = undef
1235  charn = undef
1236  cge = undef
1237  phiaw = undef
1238  tauwix = undef
1239  tauwiy = undef
1240  tauwnx = undef
1241  tauwny = undef
1242  whitecap = undef
1243  !
1244  ! Group 6 variables
1245  !
1246  sxx = undef
1247  sxy = undef
1248  syy = undef
1249  tauox = undef
1250  tauoy = undef
1251  bhd = undef
1252  phioc = undef
1253  tusx = undef
1254  tusy = undef
1255  ussx = undef
1256  ussy = undef
1257  tauocx = undef
1258  tauocy = undef
1259  prms = undef
1260  tpms = undef
1261  IF ( us3df(1).GT.0 ) THEN
1262  us3d = undef
1263  ENDIF
1264  IF ( p2msf(1).GT.0) THEN
1265  p2sms = undef
1266  ENDIF
1267  tauice = undef
1268  phice = undef
1269  IF ( usspf(1).GT.0 ) THEN
1270  ussp = undef
1271  ENDIF
1272  !
1273  ! Group 7 variables
1274  !
1275  aba = undef
1276  abd = undef
1277  uba = undef
1278  ubd = undef
1279  bedforms = undef
1280  phibbl = undef
1281  taubbl = undef
1282  !
1283  ! Group 8 variables
1284  !
1285  mssx = undef
1286  mssy = undef
1287  mscx = undef
1288  mscy = undef
1289  mssd = undef
1290  mscd = undef
1291  qp = undef
1292  !
1293  ! Restart variables
1294  IF (.NOT.(outorrestflag)) THEN
1295  va = undef
1296  ENDIF
1297  !
1298  !-------------------------------------------------------------------
1299  ! 2. Loop through output points
1300  !
1301  DO isea = 1, nsea
1302  !
1303  ix = mapsf(isea,1)
1304  iy = mapsf(isea,2)
1305  mapint = mod(mapst2(iy,ix)/16,2)
1306  !
1307  IF ( mapint .EQ. 0 ) THEN
1308  !
1309  ! Initial loop to determine status map
1310  !
1311  mapice = 0
1312  mapdry = 0
1313  mapmsk = 0
1314  maplnd = 0
1315  active = .true.
1316  mapsta(iy,ix) = abs( mapsta(iy,ix) )
1317  sumgrd = 0
1318  DO ig = 1,gr_ints(isea)%NGRDS
1319  igrid = gr_ints(isea)%GDID(ig)
1320  nmapice = 0
1321  nmapdry = 0
1322  nmaplnd = 0
1323  nmapmsk = 0
1324  mapicet = 0
1325  mapdryt = 0
1326  maplndt = 0
1327  mapmskt = 0
1328  IF ( intmethod == 2 ) THEN
1329  ! Nearest neighbour is the one with the most weight
1330  inrst = maxloc(gr_ints(isea)%IND_WTS(ig)%WT, dim=1)
1331  gr_ints(isea)%IND_WTS(ig)%WT(:) = -1.
1332  gr_ints(isea)%IND_WTS(ig)%WT(inrst) = 1.
1333  END IF
1334  DO ipts = 1,gr_ints(isea)%IND_WTS(ig)%NP
1335  igx = gr_ints(isea)%IND_WTS(ig)%IP(ipts)
1336  igy = gr_ints(isea)%IND_WTS(ig)%JP(ipts)
1337  lmapice = mod( grids(igrid)%MAPST2(igy,igx),2 )
1338  lmapdry = mod( grids(igrid)%MAPST2(igy,igx)/2,2 )
1339  lmaplnd = mod( grids(igrid)%MAPST2(igy,igx)/4,2 )
1340  lmapmsk = mod( grids(igrid)%MAPST2(igy,igx)/8,2 )
1341  IF ( lmapice .EQ. 1 ) nmapice = nmapice + 1
1342  IF ( lmapdry .EQ. 1 ) nmapdry = nmapdry + 1
1343  IF ( lmaplnd .EQ. 1 ) nmaplnd = nmaplnd + 1
1344  IF ( lmapmsk .EQ. 1 ) nmapmsk = nmapmsk + 1
1345  END DO
1346  IF (gr_ints(isea)%IND_WTS(ig)%NP>0) THEN
1347  nmapice = nmapice*100/gr_ints(isea)%IND_WTS(ig)%NP
1348  nmapdry = nmapdry*100/gr_ints(isea)%IND_WTS(ig)%NP
1349  nmaplnd = nmaplnd*100/gr_ints(isea)%IND_WTS(ig)%NP
1350  nmapmsk = nmapmsk*100/gr_ints(isea)%IND_WTS(ig)%NP
1351  ENDIF
1352  IF ( nmapice .GT. 50 ) mapicet = 1
1353  IF ( nmapdry .GT. 50 ) mapdryt = 1
1354  IF ( nmaplnd .GT. 50 ) maplndt = 1
1355  IF ( nmapmsk .GT. 50 ) mapmskt = 1
1356  ! Allow use of grid with ice or dry point. Allow merge of group 1 output
1357  active = (maplndt .NE. 1 .AND. mapmskt .NE. 1)
1358  IF ( active ) THEN
1359  usegrid(ig) = .true.
1360  sumgrd = sumgrd+1
1361  mapice = mapicet
1362  mapdry = mapdryt
1363  maplnd = maplndt
1364  mapmsk = mapmskt
1365  ELSE
1366  usegrid(ig) = .false.
1367  END IF
1368  END DO
1369  IF ( sumgrd .EQ. 0 ) THEN
1370  mapice = mapicet
1371  mapdry = mapdryt
1372  maplnd = maplndt
1373  mapmsk = mapmskt
1374  END IF
1375  !
1376  ! Reset the status map
1377  !
1378  mapst2(iy,ix) = mapst2(iy,ix) + mapice + 2*mapdry + 4*maplnd + &
1379  8*mapmsk
1380  active = (mapice .NE. 1 .AND. mapdry .NE. 1 .AND. maplnd .NE. 1 &
1381  .AND. mapmsk .NE. 1)
1382  IF ( .NOT. active ) mapsta(iy,ix) = -abs( mapsta(iy,ix) )
1383  !
1384  ! Second loop to do the actual interpolation
1385  !
1386  DO ig = 1,gr_ints(isea)%NGRDS
1387  !
1388  IF ( usegrid(ig) ) THEN
1389  !
1390  igrid = gr_ints(isea)%GDID(ig)
1391  !
1392  ! Initialize temporary variables used
1393  !
1394  sumwt = 0.0
1395  !
1396  ! Group 1 variables
1397  !
1398  dwaux = undef
1399  cxaux = undef
1400  cyaux = undef
1401  uaaux = undef
1402  udaux = undef
1403  asaux = undef
1404  wlvaux = undef
1405  iceaux = undef
1406  bergaux = undef
1407  sed_d50aux = undef
1408  icehaux = undef
1409  icefaux = undef
1410  rhoairaux = undef
1411  tauaaux = undef
1412  tauadiraux = undef
1413  sumwt1 = 0
1414  !
1415  ! Group 2 variables
1416  !
1417  hsaux = undef
1418  wlmaux = undef
1419  t02aux = undef
1420  t0m1aux = undef
1421  t01aux = undef
1422  fp0aux = undef
1423  thmaux1 = undef
1424  thmaux2 = undef
1425  thsaux = undef
1426  thp0aux1 = undef
1427  thp0aux2 = undef
1428  hsigaux = undef
1429  stmaxeaux = undef
1430  stmaxdaux = undef
1431  hmaxeaux = undef
1432  hcmaxeaux = undef
1433  hmaxdaux = undef
1434  hcmaxdaux = undef
1435  wbtaux = undef
1436  wnmeanaux = undef
1437  sumwt2 = 0
1438  !
1439  ! Group 3 variables
1440  !
1441  efaux = undef
1442  th1maux = undef
1443  sth1maux = undef
1444  th2maux = undef
1445  sth2maux = undef
1446  wnaux = undef
1447  sumwt3a = 0
1448  sumwt3b = 0
1449  sumwt3c = 0
1450  sumwt3d = 0
1451  sumwt3e = 0
1452  sumwt3f = 0
1453  !
1454  ! Group 4 variables
1455  !
1456  phsaux = undef
1457  ptpaux = undef
1458  plpaux = undef
1459  pdiraux1 = undef
1460  pdiraux2 = undef
1461  psiaux = undef
1462  pwsaux = undef
1463  pwstaux = undef
1464  pthp0aux1 = undef
1465  pthp0aux2 = undef
1466  pqpaux = undef
1467  ppeaux = undef
1468  pgwaux = undef
1469  pswaux = undef
1470  ptm1aux = undef
1471  pt1aux = undef
1472  pt2aux = undef
1473  pepaux = undef
1474  sumwt4 = 0
1475  !
1476  ! Group 5 variables
1477  !
1478  ustaux1 = undef
1479  ustaux2 = undef
1480  charnaux = undef
1481  cgeaux = undef
1482  phiawaux = undef
1483  tauwixaux = undef
1484  tauwiyaux = undef
1485  tauwnxaux = undef
1486  tauwnyaux = undef
1487  whitecapaux = undef
1488  sumwt5 = 0
1489  sumwtc = 0
1490  !
1491  ! Group 6 variables
1492  !
1493  sxxaux = undef
1494  sxyaux = undef
1495  syyaux = undef
1496  tauoxaux = undef
1497  tauoyaux = undef
1498  bhdaux = undef
1499  phiocaux = undef
1500  tusxaux = undef
1501  tusyaux = undef
1502  ussxaux = undef
1503  ussyaux = undef
1504  tauocxaux = undef
1505  tauocyaux = undef
1506  prmsaux = undef
1507  tpmsaux = undef
1508  p2smsaux = undef
1509  us3daux = undef
1510  phiceaux = undef
1511  tauiceaux = undef
1512  usspaux = undef
1513  sumwt69 = 0
1514  sumwt68 = 0
1515  sumwt612 = 0
1516  sumwt6 = 0
1517  !
1518  ! Group 7 variables
1519  !
1520  abaaux = undef
1521  abdaux = undef
1522  ubaaux = undef
1523  ubdaux = undef
1524  bedformsaux = undef
1525  phibblaux = undef
1526  taubblaux = undef
1527  sumwt7 = 0
1528  sumwtb = 0
1529  !
1530  ! Group 8 variables
1531  !
1532  mssxaux = undef
1533  mssyaux = undef
1534  mscxaux = undef
1535  mscyaux = undef
1536  mssdaux1 = undef
1537  mssdaux2 = undef
1538  mscdaux1 = undef
1539  mscdaux2 = undef
1540  qpaux = undef
1541  sumwt8 = 0
1542  !
1543  ! Restart variables
1544  !
1545  IF (.NOT.(outorrestflag)) THEN
1546  !If restarts, set all FLOGRD
1547  !to false to avoid unneeded computations
1548  flogrd=.false.
1549  vaaux = undef
1550  sumres = 0
1551  ENDIF
1552  !
1553  ! Loop through the points per grid to obtain interpolated values
1554  !
1555  DO ipts = 1,gr_ints(isea)%IND_WTS(ig)%NP
1556  igx = gr_ints(isea)%IND_WTS(ig)%IP(ipts)
1557  igy = gr_ints(isea)%IND_WTS(ig)%JP(ipts)
1558  wt = gr_ints(isea)%IND_WTS(ig)%WT(ipts)
1559  IF ( wt < 0. ) THEN
1560  ! Point is not nearest
1561  cycle
1562  END IF
1563  gsea = grids(igrid)%MAPFS(igy,igx)
1564  !
1565  ! Group 1 variables
1566  !
1567  IF ( flogrd(1,1) ) THEN
1568  IF ( wadats(igrid)%DW(gsea) .NE. undef ) THEN
1569  sumwt1(1) = sumwt1(1) + wt
1570  IF ( dwaux .EQ. undef ) THEN
1571  dwaux = wadats(igrid)%DW(gsea)*wt
1572  ELSE
1573  dwaux = dwaux + wadats(igrid)%DW(gsea)*wt
1574  END IF
1575  END IF
1576  END IF
1577  !
1578  IF ( flogrd(1,2) ) THEN
1579  IF ( wadats(igrid)%CX(gsea) .NE. undef ) THEN
1580  sumwt1(2) = sumwt1(2) + wt
1581  IF ( cxaux .EQ. undef ) THEN
1582  cxaux = wadats(igrid)%CX(gsea)*wt
1583  cyaux = wadats(igrid)%CY(gsea)*wt
1584  ELSE
1585  cxaux = cxaux + wadats(igrid)%CX(gsea)*wt
1586  cyaux = cyaux + wadats(igrid)%CY(gsea)*wt
1587  END IF
1588  END IF
1589  END IF
1590  !
1591  IF ( flogrd(1,3) ) THEN
1592  IF ( wadats(igrid)%UA(gsea) .NE. undef ) THEN
1593  sumwt1(3) = sumwt1(3) + wt
1594  IF ( uaaux .EQ. undef ) THEN
1595  uaaux = wadats(igrid)%UA(gsea)*wt
1596  udaux = wadats(igrid)%UD(gsea)*wt
1597  ELSE
1598  uaaux = uaaux + wadats(igrid)%UA(gsea)*wt
1599  udaux = udaux + wadats(igrid)%UD(gsea)*wt
1600  END IF
1601  END IF
1602  END IF
1603  !
1604  IF ( flogrd(1,4) ) THEN
1605  IF ( wadats(igrid)%AS(gsea) .NE. undef ) THEN
1606  sumwt1(4) = sumwt1(4) + wt
1607  IF ( asaux .EQ. undef ) THEN
1608  asaux = wadats(igrid)%AS(gsea)*wt
1609  ELSE
1610  asaux = asaux + wadats(igrid)%AS(gsea)*wt
1611  END IF
1612  END IF
1613  END IF
1614  !
1615  IF ( flogrd(1,5) ) THEN
1616  IF ( wdatas(igrid)%WLV(gsea) .NE. undef ) THEN
1617  sumwt1(5) = sumwt1(5) + wt
1618  IF ( wlvaux .EQ. undef ) THEN
1619  wlvaux = wdatas(igrid)%WLV(gsea)*wt
1620  ELSE
1621  wlvaux = wlvaux + wdatas(igrid)%WLV(gsea)*wt
1622  END IF
1623  END IF
1624  END IF
1625  !
1626  IF ( flogrd(1,6) ) THEN
1627  IF ( wdatas(igrid)%ICE(gsea) .NE. undef ) THEN
1628  sumwt1(6) = sumwt1(6) + wt
1629  IF ( iceaux .EQ. undef ) THEN
1630  iceaux = wdatas(igrid)%ICE(gsea)*wt
1631  ELSE
1632  iceaux = iceaux + wdatas(igrid)%ICE(gsea)*wt
1633  END IF
1634  END IF
1635  END IF
1636  !
1637  IF ( flogrd(1,7) ) THEN
1638  IF ( wdatas(igrid)%BERG(gsea) .NE. undef ) THEN
1639  sumwt1(7) = sumwt1(7) + wt
1640  IF ( bergaux .EQ. undef ) THEN
1641  bergaux = wdatas(igrid)%BERG(gsea)*wt
1642  ELSE
1643  bergaux = bergaux + wdatas(igrid)%BERG(gsea)*wt
1644  END IF
1645  END IF
1646  END IF
1647  !
1648  IF ( flogrd(1,8) ) THEN
1649  IF ( wadats(igrid)%TAUA(gsea) .NE. undef ) THEN
1650  sumwt1(8) = sumwt1(8) + wt
1651  IF ( tauaaux .EQ. undef ) THEN
1652  tauaaux = wadats(igrid)%TAUA(gsea)*wt
1653  tauadiraux = wadats(igrid)%TAUADIR(gsea)*wt
1654  ELSE
1655  tauaaux = tauaaux + wadats(igrid)%TAUA(gsea)*wt
1656  tauadiraux = tauadiraux + wadats(igrid)%TAUADIR(gsea)*wt
1657  END IF
1658  END IF
1659  END IF
1660  !
1661  IF ( flogrd(1,9) ) THEN
1662  IF ( wdatas(igrid)%RHOAIR(gsea) .NE. undef ) THEN
1663  sumwt1(9) = sumwt1(9) + wt
1664  IF ( rhoairaux .EQ. undef ) THEN
1665  rhoairaux = wdatas(igrid)%RHOAIR(gsea)*wt
1666  ELSE
1667  rhoairaux = rhoairaux + wdatas(igrid)%RHOAIR(gsea)*wt
1668  END IF
1669  END IF
1670  END IF
1671  !
1672 #ifdef W3_BT4
1673  IF ( flogrd(1,10) ) THEN
1674  IF ( grids(igrid)%SED_D50(gsea) .NE. undef ) THEN
1675  sumwt1(10) = sumwt1(10) + wt
1676  IF ( sed_d50aux .EQ. undef ) THEN
1677  sed_d50aux = grids(igrid)%SED_D50(gsea)*wt
1678  ELSE
1679  sed_d50aux = sed_d50aux + grids(igrid)%SED_D50(gsea)*wt
1680  END IF
1681  END IF
1682  END IF
1683 #endif
1684  !
1685 #ifdef W3_IS2
1686  IF ( flogrd(1,11) ) THEN
1687  IF ( wdatas(igrid)%ICEH(gsea) .NE. undef ) THEN
1688  sumwt1(11) = sumwt1(11) + wt
1689  IF (icehaux .EQ. undef) THEN
1690  icehaux = wdatas(igrid)%ICEH(gsea)*wt
1691  ELSE
1692  icehaux = icehaux + wdatas(igrid)%ICEH(gsea)*wt
1693  END IF
1694  END IF
1695  END IF
1696 #endif
1697  !
1698 #ifdef W3_IS2
1699  IF ( flogrd(1,12) ) THEN
1700  IF ( wdatas(igrid)%ICEF(gsea) .NE. undef ) THEN
1701  sumwt1(12) = sumwt1(12) + wt
1702  IF (icefaux .EQ. undef) THEN
1703  icefaux = wdatas(igrid)%ICEF(gsea)*wt
1704  ELSE
1705  icefaux = icefaux + wdatas(igrid)%ICEF(gsea)*wt
1706  END IF
1707  END IF
1708  END IF
1709 #endif
1710  !
1711  ! Group 2 variables
1712  !
1713  IF ( flogrd(2,1) .AND. active ) THEN
1714  IF ( wadats(igrid)%HS(gsea) .NE. undef ) THEN
1715  sumwt2(1) = sumwt2(1) + wt
1716  IF ( hsaux .EQ. undef ) THEN
1717  hsaux = wadats(igrid)%HS(gsea)*wt
1718  ELSE
1719  hsaux = hsaux + wadats(igrid)%HS(gsea)*wt
1720  END IF
1721  END IF
1722  END IF
1723  !
1724  IF ( flogrd(2,2) .AND. active ) THEN
1725  IF ( wadats(igrid)%WLM(gsea) .NE. undef ) THEN
1726  sumwt2(2) = sumwt2(2) + wt
1727  IF ( wlmaux .EQ. undef ) THEN
1728  wlmaux = wadats(igrid)%WLM(gsea)*wt
1729  ELSE
1730  wlmaux = wlmaux + wadats(igrid)%WLM(gsea)*wt
1731  END IF
1732  END IF
1733  END IF
1734  !
1735  IF ( flogrd(2,3) .AND. active ) THEN
1736  IF ( wadats(igrid)%T02(gsea) .NE. undef ) THEN
1737  sumwt2(3) = sumwt2(3) + wt
1738  IF ( t02aux .EQ. undef ) THEN
1739  t02aux = wadats(igrid)%T02(gsea)*wt
1740  ELSE
1741  t02aux = t02aux + wadats(igrid)%T02(gsea)*wt
1742  END IF
1743  END IF
1744  END IF
1745  !
1746  IF ( flogrd(2,4) .AND. active ) THEN
1747  IF ( wadats(igrid)%T0M1(gsea) .NE. undef ) THEN
1748  sumwt2(4) = sumwt2(4) + wt
1749  IF ( t0m1aux .EQ. undef ) THEN
1750  t0m1aux = wadats(igrid)%T0M1(gsea)*wt
1751  ELSE
1752  t0m1aux = t0m1aux + wadats(igrid)%T0M1(gsea)*wt
1753  END IF
1754  END IF
1755  END IF
1756  !
1757  IF ( flogrd(2,5) .AND. active ) THEN
1758  IF ( wadats(igrid)%T01(gsea) .NE. undef ) THEN
1759  sumwt2(5) = sumwt2(5) + wt
1760  IF ( t01aux .EQ. undef ) THEN
1761  t01aux = wadats(igrid)%T01(gsea)*wt
1762  ELSE
1763  t01aux = t01aux + wadats(igrid)%T01(gsea)*wt
1764  END IF
1765  END IF
1766  END IF
1767  !
1768  IF ( (flogrd(2,6) .OR. flogrd(2,18)) .AND. active ) THEN
1769  ! Note: Output TP [FLOGRD(2,18)] is derived from FP0
1770  IF ( wadats(igrid)%FP0(gsea) .NE. undef ) THEN
1771  sumwt2(6) = sumwt2(6) + wt
1772  IF ( fp0aux .EQ. undef ) THEN
1773  fp0aux = wadats(igrid)%FP0(gsea)*wt
1774  ELSE
1775  fp0aux = fp0aux + wadats(igrid)%FP0(gsea)*wt
1776  END IF
1777  END IF
1778  END IF
1779  !
1780  IF ( flogrd(2,7) .AND. active ) THEN
1781  IF ( wadats(igrid)%THM(gsea) .NE. undef ) THEN
1782  sumwt2(7) = sumwt2(7) + wt
1783  IF ( thmaux1 .EQ. undef ) THEN
1784  thmaux1 = cos( wadats(igrid)%THM(gsea) )*wt
1785  thmaux2 = sin( wadats(igrid)%THM(gsea) )*wt
1786  ELSE
1787  thmaux1 = thmaux1 + cos( wadats(igrid)%THM(gsea) )*wt
1788  thmaux2 = thmaux2 + sin( wadats(igrid)%THM(gsea) )*wt
1789  END IF
1790  END IF
1791  END IF
1792  !
1793  IF ( flogrd(2,8) .AND. active ) THEN
1794  IF ( wadats(igrid)%THS(gsea) .NE. undef ) THEN
1795  sumwt2(8) = sumwt2(8) + wt
1796  IF ( thsaux .EQ. undef ) THEN
1797  thsaux = wadats(igrid)%THS(gsea)*wt
1798  ELSE
1799  thsaux = thsaux + wadats(igrid)%THS(gsea)*wt
1800  END IF
1801  END IF
1802  END IF
1803  !
1804  IF ( flogrd(2,9) .AND. active ) THEN
1805  IF ( wadats(igrid)%THP0(gsea) .NE. undef ) THEN
1806  sumwt2(9) = sumwt2(9) + wt
1807  IF ( thp0aux1 .EQ. undef ) THEN
1808  thp0aux1 = cos( wadats(igrid)%THP0(gsea) )*wt
1809  thp0aux2 = sin( wadats(igrid)%THP0(gsea) )*wt
1810  ELSE
1811  thp0aux1 = thp0aux1 + &
1812  cos( wadats(igrid)%THP0(gsea) )*wt
1813  thp0aux2 = thp0aux2 + &
1814  sin( wadats(igrid)%THP0(gsea) )*wt
1815  END IF
1816  END IF
1817  END IF
1818  !
1819  IF ( flogrd(2,10) .AND. active ) THEN
1820  IF ( wadats(igrid)%HSIG(gsea) .NE. undef ) THEN
1821  sumwt2(10) = sumwt2(10) + wt
1822  IF ( hsigaux .EQ. undef ) hsigaux = 0.
1823  hsigaux = hsigaux + wadats(igrid)%HSIG(gsea)*wt
1824  END IF
1825  END IF
1826  !
1827  IF ( flogrd(2,11) .AND. active ) THEN
1828  IF ( wadats(igrid)%STMAXE(gsea) .NE. undef ) THEN
1829  sumwt2(11) = sumwt2(11) + wt
1830  IF ( stmaxeaux .EQ. undef ) stmaxeaux = 0.
1831  stmaxeaux = stmaxeaux + wadats(igrid)%STMAXE(gsea)*wt
1832  END IF
1833  END IF
1834  !
1835  IF ( flogrd(2,12) .AND. active ) THEN
1836  IF ( wadats(igrid)%STMAXD(gsea) .NE. undef ) THEN
1837  sumwt2(12) = sumwt2(12) + wt
1838  IF ( stmaxdaux .EQ. undef ) stmaxdaux = 0.
1839  stmaxdaux = stmaxdaux + wadats(igrid)%STMAXD(gsea)*wt
1840  END IF
1841  END IF
1842  !
1843  IF ( flogrd(2,13) .AND. active ) THEN
1844  IF ( wadats(igrid)%HMAXE(gsea) .NE. undef ) THEN
1845  sumwt2(13) = sumwt2(13) + wt
1846  IF ( hmaxeaux .EQ. undef ) hmaxeaux = 0.
1847  hmaxeaux = hmaxeaux + wadats(igrid)%HMAXE(gsea)*wt
1848  END IF
1849  END IF
1850  !
1851  IF ( flogrd(2,14) .AND. active ) THEN
1852  IF ( wadats(igrid)%HCMAXE(gsea) .NE. undef ) THEN
1853  sumwt2(14) = sumwt2(14) + wt
1854  IF ( hcmaxeaux .EQ. undef ) hcmaxeaux = 0.
1855  hcmaxeaux = hcmaxeaux + wadats(igrid)%HCMAXE(gsea)*wt
1856  END IF
1857  END IF
1858  !
1859  IF ( flogrd(2,15) .AND. active ) THEN
1860  IF ( wadats(igrid)%HMAXD(gsea) .NE. undef ) THEN
1861  sumwt2(15) = sumwt2(15) + wt
1862  IF ( hmaxdaux .EQ. undef ) hmaxdaux = 0.
1863  hmaxdaux = hmaxdaux + wadats(igrid)%HMAXD(gsea)*wt
1864  END IF
1865  END IF
1866  !
1867  IF ( flogrd(2,16) .AND. active ) THEN
1868  IF ( wadats(igrid)%HCMAXD(gsea) .NE. undef ) THEN
1869  sumwt2(16) = sumwt2(16) + wt
1870  IF ( hcmaxdaux .EQ. undef ) hcmaxdaux = 0.
1871  hcmaxdaux = hcmaxdaux + wadats(igrid)%HCMAXD(gsea)*wt
1872  END IF
1873  END IF
1874  !
1875  IF ( flogrd(2,17) .AND. active ) THEN
1876  IF ( wadats(igrid)%WBT(gsea) .NE. undef ) THEN
1877  sumwt2(17) = sumwt2(17) + wt
1878  IF ( wbtaux .EQ. undef ) wbtaux = 0.
1879  wbtaux = wbtaux + wadats(igrid)%WBT(gsea)*wt
1880  END IF
1881  END IF
1882  !
1883  IF ( flogrd(2,19) .AND. active ) THEN
1884  IF ( wadats(igrid)%WNMEAN(gsea) .NE. undef ) THEN
1885  sumwt2(19) = sumwt2(19) + wt
1886  IF ( wnmeanaux .EQ. undef ) wnmeanaux = 0.
1887  wnmeanaux = wnmeanaux + wadats(igrid)%WNMEAN(gsea)*wt
1888  END IF
1889  END IF
1890  !
1891  ! Group 3 variables
1892  !
1893  IF ( flogrd(3,1) .AND. active ) THEN
1894  DO ifreq = e3df(2,1),e3df(3,1)
1895  IF ( wadats(igrid)%EF(gsea,ifreq) .NE. undef ) THEN
1896  sumwt3a(ifreq) = sumwt3a(ifreq) + wt
1897  IF ( efaux(ifreq) .EQ. undef ) THEN
1898  efaux(ifreq) = wadats(igrid)%EF(gsea,ifreq)*wt
1899  ELSE
1900  efaux(ifreq) = efaux(ifreq) + wadats(igrid)%EF(gsea,ifreq)*wt
1901  END IF
1902  END IF
1903  END DO
1904  END IF
1905  !
1906  IF ( flogrd(3,2) .AND. active ) THEN
1907  DO ifreq = e3df(2,2),e3df(3,2)
1908  IF ( wadats(igrid)%TH1M(gsea,ifreq) .NE. undef ) THEN
1909  sumwt3b(ifreq) = sumwt3b(ifreq) + wt
1910  IF ( th1maux(ifreq) .EQ. undef ) THEN
1911  th1maux(ifreq) = wadats(igrid)%TH1M(gsea,ifreq)*wt
1912  ELSE
1913  th1maux(ifreq) = th1maux(ifreq) + wadats(igrid)%TH1M(gsea,ifreq)*wt
1914  END IF
1915  END IF
1916  END DO
1917  END IF
1918  !
1919  IF ( flogrd(3,3) .AND. active ) THEN
1920  DO ifreq = e3df(2,3),e3df(3,3)
1921  IF ( wadats(igrid)%STH1M(gsea,ifreq) .NE. undef ) THEN
1922  sumwt3c(ifreq) = sumwt3c(ifreq) + wt
1923  IF ( sth1maux(ifreq) .EQ. undef ) THEN
1924  sth1maux(ifreq) = wadats(igrid)%STH1M(gsea,ifreq)*wt
1925  ELSE
1926  sth1maux(ifreq) = sth1maux(ifreq) + wadats(igrid)%STH1M(gsea,ifreq)*wt
1927  END IF
1928  END IF
1929  END DO
1930  END IF
1931  !
1932  IF ( flogrd(3,4) .AND. active ) THEN
1933  DO ifreq = e3df(2,4),e3df(3,4)
1934  IF ( wadats(igrid)%TH2M(gsea,ifreq) .NE. undef ) THEN
1935  sumwt3d(ifreq) = sumwt3d(ifreq) + wt
1936  IF ( th2maux(ifreq) .EQ. undef ) THEN
1937  th2maux(ifreq) = wadats(igrid)%TH2M(gsea,ifreq)*wt
1938  ELSE
1939  th2maux(ifreq) = th2maux(ifreq) + wadats(igrid)%TH2M(gsea,ifreq)*wt
1940  END IF
1941  END IF
1942  END DO
1943  END IF
1944  !
1945  IF ( flogrd(3,5) .AND. active ) THEN
1946  DO ifreq = e3df(2,5),e3df(3,5)
1947  IF ( wadats(igrid)%STH2M(gsea,ifreq) .NE. undef ) THEN
1948  sumwt3e(ifreq) = sumwt3e(ifreq) + wt
1949  IF ( sth2maux(ifreq) .EQ. undef ) THEN
1950  sth2maux(ifreq) = wadats(igrid)%STH2M(gsea,ifreq)*wt
1951  ELSE
1952  sth2maux(ifreq) = sth2maux(ifreq) + wadats(igrid)%STH2M(gsea,ifreq)*wt
1953  END IF
1954  END IF
1955  END DO
1956  END IF
1957 
1958  !
1959  IF ( flogrd(3,6) .AND. active ) THEN
1960  DO ik = 1,nk
1961  IF ( wadats(igrid)%WN(ik,gsea) .NE. undef ) THEN
1962  sumwt3f(ik) = sumwt3f(ik) + wt
1963  IF ( wnaux(ik) .EQ. undef ) THEN
1964  wnaux(ik) = wadats(igrid)%WN(ik,gsea)*wt
1965  ELSE
1966  wnaux(ik) = wnaux(ik) + wadats(igrid)%WN(ik,gsea)*wt
1967  END IF
1968  END IF
1969  END DO
1970  END IF
1971  !
1972  ! Group 4 variables
1973  !
1974  DO iswll = 0, noswll_min
1975  !
1976  IF ( flogrd(4,1) .AND. active ) THEN
1977  IF ( wadats(igrid)%PHS(gsea,iswll) .NE. undef ) THEN
1978  sumwt4(1,iswll) = sumwt4(1,iswll) + wt
1979  IF ( phsaux(iswll) .EQ. undef ) THEN
1980  phsaux(iswll) = wadats(igrid)%PHS(gsea,iswll)*wt
1981  ELSE
1982  phsaux(iswll) = phsaux(iswll) + &
1983  wadats(igrid)%PHS(gsea,iswll)*wt
1984  END IF
1985  END IF
1986  END IF
1987  !
1988  IF ( flogrd(4,2) .AND. active ) THEN
1989  IF ( wadats(igrid)%PTP(gsea,iswll) .NE. undef ) THEN
1990  sumwt4(2,iswll) = sumwt4(2,iswll) + wt
1991  IF ( ptpaux(iswll) .EQ. undef ) THEN
1992  ptpaux(iswll) = wadats(igrid)%PTP(gsea,iswll)*wt
1993  ELSE
1994  ptpaux(iswll) = ptpaux(iswll) + &
1995  wadats(igrid)%PTP(gsea,iswll)*wt
1996  END IF
1997  END IF
1998  END IF
1999  !
2000  IF ( flogrd(4,3) .AND. active ) THEN
2001  IF ( wadats(igrid)%PLP(gsea,iswll) .NE. undef ) THEN
2002  sumwt4(3,iswll) = sumwt4(3,iswll) + wt
2003  IF ( plpaux(iswll) .EQ. undef ) THEN
2004  plpaux(iswll) = wadats(igrid)%PLP(gsea,iswll)*wt
2005  ELSE
2006  plpaux(iswll) = plpaux(iswll) + &
2007  wadats(igrid)%PLP(gsea,iswll)*wt
2008  END IF
2009  END IF
2010  END IF
2011  !
2012  IF ( flogrd(4,4) .AND. active ) THEN
2013  IF ( wadats(igrid)%PDIR(gsea,iswll) .NE. undef ) THEN
2014  sumwt4(4,iswll) = sumwt4(4,iswll) + wt
2015  IF ( pdiraux1(iswll) .EQ. undef ) THEN
2016  pdiraux1(iswll) = &
2017  cos( wadats(igrid)%PDIR(gsea,iswll) )*wt
2018  pdiraux2(iswll) = &
2019  sin( wadats(igrid)%PDIR(gsea,iswll) )*wt
2020  ELSE
2021  pdiraux1(iswll) = pdiraux1(iswll) + &
2022  cos( wadats(igrid)%PDIR(gsea,iswll) )*wt
2023  pdiraux2(iswll) = pdiraux2(iswll) + &
2024  sin( wadats(igrid)%PDIR(gsea,iswll) )*wt
2025  END IF
2026  END IF
2027  END IF
2028  !
2029  IF ( flogrd(4,5) .AND. active ) THEN
2030  IF ( wadats(igrid)%PSI(gsea,iswll) .NE. undef ) THEN
2031  sumwt4(5,iswll) = sumwt4(5,iswll) + wt
2032  IF ( psiaux(iswll) .EQ. undef ) THEN
2033  psiaux(iswll) = wadats(igrid)%PSI(gsea,iswll)*wt
2034  ELSE
2035  psiaux(iswll) = psiaux(iswll) + &
2036  wadats(igrid)%PSI(gsea,iswll)*wt
2037  END IF
2038  END IF
2039  END IF
2040  !
2041  IF ( flogrd(4,6) .AND. active ) THEN
2042  IF ( wadats(igrid)%PWS(gsea,iswll) .NE. undef ) THEN
2043  sumwt4(6,iswll) = sumwt4(6,iswll) + wt
2044  IF ( pwsaux(iswll) .EQ. undef ) THEN
2045  pwsaux(iswll) = wadats(igrid)%PWS(gsea,iswll)*wt
2046  ELSE
2047  pwsaux(iswll) = pwsaux(iswll) + &
2048  wadats(igrid)%PWS(gsea,iswll)*wt
2049  END IF
2050  END IF
2051  END IF
2052  !
2053  IF ( flogrd(4,7) .AND. active ) THEN
2054  IF ( wadats(igrid)%PTHP0(gsea,iswll) .NE. undef ) THEN
2055  sumwt4(7,iswll) = sumwt4(7,iswll) + wt
2056  IF (pthp0aux1(iswll).EQ.undef) &
2057  pthp0aux1(iswll) = 0.
2058  IF (pthp0aux2(iswll).EQ.undef) &
2059  pthp0aux2(iswll) = 0.
2060  pthp0aux1(iswll) = pthp0aux1(iswll) + &
2061  cos( wadats(igrid)%PTHP0(gsea,iswll) )*wt
2062  pthp0aux2(iswll) = pthp0aux2(iswll) + &
2063  sin( wadats(igrid)%PTHP0(gsea,iswll) )*wt
2064  END IF
2065  END IF
2066  !
2067  IF ( flogrd(4,8) .AND. active ) THEN
2068  IF ( wadats(igrid)%PQP(gsea,iswll) .NE. undef ) THEN
2069  sumwt4(8,iswll) = sumwt4(8,iswll) + wt
2070  IF ( pqpaux(iswll).EQ.undef ) pqpaux(iswll) = 0.
2071  pqpaux(iswll) = pqpaux(iswll) + &
2072  wadats(igrid)%PQP(gsea,iswll)*wt
2073  END IF
2074  END IF
2075  !
2076  IF ( flogrd(4,9) .AND. active ) THEN
2077  IF ( wadats(igrid)%PPE(gsea,iswll) .NE. undef ) THEN
2078  sumwt4(9,iswll) = sumwt4(9,iswll) + wt
2079  IF ( ppeaux(iswll).EQ.undef ) ppeaux(iswll) = 0.
2080  ppeaux(iswll) = ppeaux(iswll) + &
2081  wadats(igrid)%PPE(gsea,iswll)*wt
2082  END IF
2083  END IF
2084  !
2085  IF ( flogrd(4,10) .AND. active ) THEN
2086  IF ( wadats(igrid)%PGW(gsea,iswll) .NE. undef ) THEN
2087  sumwt4(10,iswll) = sumwt4(10,iswll) + wt
2088  IF ( pgwaux(iswll).EQ.undef ) pgwaux(iswll) = 0.
2089  pgwaux(iswll) = pgwaux(iswll) + &
2090  wadats(igrid)%PGW(gsea,iswll)*wt
2091  END IF
2092  END IF
2093  !
2094  IF ( flogrd(4,11) .AND. active ) THEN
2095  IF ( wadats(igrid)%PSW(gsea,iswll) .NE. undef ) THEN
2096  sumwt4(11,iswll) = sumwt4(11,iswll) + wt
2097  IF ( pswaux(iswll).EQ.undef ) pswaux(iswll) = 0.
2098  pswaux(iswll) = pswaux(iswll) + &
2099  wadats(igrid)%PSW(gsea,iswll)*wt
2100  END IF
2101  END IF
2102  !
2103  IF ( flogrd(4,12) .AND. active ) THEN
2104  IF ( wadats(igrid)%PTM1(gsea,iswll) .NE. undef ) THEN
2105  sumwt4(12,iswll) = sumwt4(12,iswll) + wt
2106  IF ( ptm1aux(iswll).EQ.undef ) &
2107  ptm1aux(iswll) = 0.
2108  ptm1aux(iswll) = ptm1aux(iswll) + &
2109  wadats(igrid)%PTM1(gsea,iswll)*wt
2110  END IF
2111  END IF
2112  !
2113  IF ( flogrd(4,13) .AND. active ) THEN
2114  IF ( wadats(igrid)%PT1(gsea,iswll) .NE. undef ) THEN
2115  sumwt4(13,iswll) = sumwt4(13,iswll) + wt
2116  IF ( pt1aux(iswll).EQ.undef ) pt1aux(iswll) = 0.
2117  pt1aux(iswll) = pt1aux(iswll) + &
2118  wadats(igrid)%PT1(gsea,iswll)*wt
2119  END IF
2120  END IF
2121  !
2122  IF ( flogrd(4,14) .AND. active ) THEN
2123  IF ( wadats(igrid)%PT2(gsea,iswll) .NE. undef ) THEN
2124  sumwt4(14,iswll) = sumwt4(14,iswll) + wt
2125  IF ( pt2aux(iswll).EQ.undef ) pt2aux(iswll) = 0.
2126  pt2aux(iswll) = pt2aux(iswll) + &
2127  wadats(igrid)%PT2(gsea,iswll)*wt
2128  END IF
2129  END IF
2130  !
2131  IF ( flogrd(4,15) .AND. active ) THEN
2132  IF ( wadats(igrid)%PEP(gsea,iswll) .NE. undef ) THEN
2133  sumwt4(15,iswll) = sumwt4(15,iswll) + wt
2134  IF ( pepaux(iswll).EQ.undef ) pepaux(iswll) = 0.
2135  pepaux(iswll) = pepaux(iswll) + &
2136  wadats(igrid)%PEP(gsea,iswll)*wt
2137  END IF
2138  END IF
2139  !
2140  END DO !/ ISWLL = 0, NOSWLL_MIN
2141  !
2142  IF ( flogrd(4,16) .AND. active ) THEN
2143  IF ( wadats(igrid)%PWST(gsea) .NE. undef ) THEN
2144  sumwt4(16,0) = sumwt4(16,0) + wt
2145  IF ( pwstaux .EQ. undef ) THEN
2146  pwstaux = wadats(igrid)%PWST(gsea)*wt
2147  ELSE
2148  pwstaux = pwstaux + wadats(igrid)%PWST(gsea)*wt
2149  END IF
2150  END IF
2151  END IF
2152  !
2153  ! Group 5 variables
2154  !
2155  IF ( flogrd(5,1) ) THEN
2156  IF ( wdatas(igrid)%UST(gsea) .NE. undef ) THEN
2157  sumwt5(1) = sumwt5(1) + wt
2158  IF ( ustaux1 .EQ. undef ) THEN
2159  ustaux1 = wdatas(igrid)%UST(gsea)*wt
2160  ustaux2 = wdatas(igrid)%USTDIR(gsea)*wt
2161  ELSE
2162  ustaux1 = ustaux1 + wdatas(igrid)%UST(gsea)*wt
2163  ustaux2 = ustaux2 + wdatas(igrid)%USTDIR(gsea)*wt
2164  END IF
2165  END IF
2166  END IF
2167  !
2168  IF ( flogrd(5,2) .AND. active ) THEN
2169  IF ( wadats(igrid)%CHARN(gsea) .NE. undef ) THEN
2170  sumwt5(2) = sumwt5(2) + wt
2171  IF ( charnaux .EQ. undef ) THEN
2172  charnaux = wadats(igrid)%CHARN(gsea)*wt
2173  ELSE
2174  charnaux = charnaux + wadats(igrid)%CHARN(gsea)*wt
2175  END IF
2176  END IF
2177  END IF
2178  !
2179  IF ( flogrd(5,3) .AND. active ) THEN
2180  IF ( wadats(igrid)%CGE(gsea) .NE. undef ) THEN
2181  sumwt5(3) = sumwt5(3) + wt
2182  IF ( cgeaux .EQ. undef ) THEN
2183  cgeaux = wadats(igrid)%CGE(gsea)*wt
2184  ELSE
2185  cgeaux = cgeaux + wadats(igrid)%CGE(gsea)*wt
2186  END IF
2187  END IF
2188  END IF
2189  !
2190  IF ( flogrd(5,4) .AND. active ) THEN
2191  IF ( wadats(igrid)%PHIAW(gsea) .NE. undef ) THEN
2192  sumwt5(4) = sumwt5(4) + wt
2193  IF ( phiawaux .EQ. undef ) THEN
2194  phiawaux = wadats(igrid)%PHIAW(gsea)*wt
2195  ELSE
2196  phiawaux = phiawaux + wadats(igrid)%PHIAW(gsea)*wt
2197  END IF
2198  END IF
2199  END IF
2200  !
2201  IF ( flogrd(5,5) .AND. active ) THEN
2202  IF ( wadats(igrid)%TAUWIX(gsea) .NE. undef ) THEN
2203  sumwt5(5) = sumwt5(5) + wt
2204  IF ( tauwixaux .EQ. undef ) THEN
2205  tauwixaux = wadats(igrid)%TAUWIX(gsea)*wt
2206  tauwiyaux = wadats(igrid)%TAUWIY(gsea)*wt
2207  ELSE
2208  tauwixaux = tauwixaux + wadats(igrid)%TAUWIX(gsea)*wt
2209  tauwiyaux = tauwiyaux + wadats(igrid)%TAUWIY(gsea)*wt
2210  END IF
2211  END IF
2212  END IF
2213  !
2214  IF ( flogrd(5,6) .AND. active ) THEN
2215  IF ( wadats(igrid)%TAUWNX(gsea) .NE. undef ) THEN
2216  sumwt5(6) = sumwt5(6) + wt
2217  IF ( tauwnxaux .EQ. undef ) THEN
2218  tauwnxaux = wadats(igrid)%TAUWNX(gsea)*wt
2219  tauwnyaux = wadats(igrid)%TAUWNY(gsea)*wt
2220  ELSE
2221  tauwnxaux = tauwnxaux + wadats(igrid)%TAUWNX(gsea)*wt
2222  tauwnyaux = tauwnyaux + wadats(igrid)%TAUWNY(gsea)*wt
2223  END IF
2224  END IF
2225  END IF
2226  !
2227  DO icap = 1,4
2228  !
2229  IF ( flogrd(5,icap+6) .AND. active ) THEN
2230  IF ( wadats(igrid)%WHITECAP(gsea,icap) .NE. undef ) THEN
2231  sumwtc(icap) = sumwtc(icap) + wt
2232  IF ( whitecapaux(icap) .EQ. undef ) THEN
2233  whitecapaux(icap) = wadats(igrid)%WHITECAP(gsea,icap)&
2234  *wt
2235  ELSE
2236  whitecapaux(icap) = whitecapaux(icap) + &
2237  wadats(igrid)%WHITECAP(gsea,icap)*wt
2238  END IF
2239  END IF
2240  END IF
2241  !
2242  END DO
2243  !
2244  ! Group 6 variables
2245  !
2246  IF ( flogrd(6,1) .AND. active ) THEN
2247  IF ( wadats(igrid)%SXX(gsea) .NE. undef ) THEN
2248  sumwt6(1) = sumwt6(1) + wt
2249  IF ( sxxaux .EQ. undef ) THEN
2250  sxxaux = wadats(igrid)%SXX(gsea)*wt
2251  sxyaux = wadats(igrid)%SXY(gsea)*wt
2252  syyaux = wadats(igrid)%SYY(gsea)*wt
2253  ELSE
2254  sxxaux = sxxaux + wadats(igrid)%SXX(gsea)*wt
2255  sxyaux = sxyaux + wadats(igrid)%SXY(gsea)*wt
2256  syyaux = syyaux + wadats(igrid)%SYY(gsea)*wt
2257  END IF
2258  END IF
2259  END IF
2260  !
2261  IF ( flogrd(6,2) .AND. active ) THEN
2262  IF ( wadats(igrid)%TAUOX(gsea) .NE. undef ) THEN
2263  sumwt6(2) = sumwt6(2) + wt
2264  IF ( tauoxaux .EQ. undef ) THEN
2265  tauoxaux = wadats(igrid)%TAUOX(gsea)*wt
2266  tauoyaux = wadats(igrid)%TAUOY(gsea)*wt
2267  ELSE
2268  tauoxaux = tauoxaux + wadats(igrid)%TAUOX(gsea)*wt
2269  tauoyaux = tauoyaux + wadats(igrid)%TAUOY(gsea)*wt
2270  END IF
2271  END IF
2272  END IF
2273  !
2274  IF ( flogrd(6,3) .AND. active ) THEN
2275  IF ( wadats(igrid)%BHD(gsea) .NE. undef ) THEN
2276  sumwt6(3) = sumwt6(3) + wt
2277  IF ( bhdaux .EQ. undef ) THEN
2278  bhdaux = wadats(igrid)%BHD(gsea)*wt
2279  ELSE
2280  bhdaux = bhdaux + wadats(igrid)%BHD(gsea)*wt
2281  END IF
2282  END IF
2283  END IF
2284  !
2285  IF ( flogrd(6,4) .AND. active ) THEN
2286  IF ( wadats(igrid)%PHIOC(gsea) .NE. undef ) THEN
2287  sumwt6(4) = sumwt6(4) + wt
2288  IF ( phiocaux .EQ. undef ) THEN
2289  phiocaux = wadats(igrid)%PHIOC(gsea)*wt
2290  ELSE
2291  phiocaux = phiocaux + wadats(igrid)%PHIOC(gsea)*wt
2292  END IF
2293  END IF
2294  END IF
2295  !
2296  IF ( flogrd(6,5) .AND. active ) THEN
2297  IF ( wadats(igrid)%TUSX(gsea) .NE. undef ) THEN
2298  sumwt6(5) = sumwt6(5) + wt
2299  IF ( tusxaux .EQ. undef ) THEN
2300  tusxaux = wadats(igrid)%TUSX(gsea)*wt
2301  tusyaux = wadats(igrid)%TUSY(gsea)*wt
2302  ELSE
2303  tusxaux = tusxaux + wadats(igrid)%TUSX(gsea)*wt
2304  tusyaux = tusyaux + wadats(igrid)%TUSY(gsea)*wt
2305  END IF
2306  END IF
2307  END IF
2308  !
2309  IF ( flogrd(6,6) .AND. active ) THEN
2310  IF ( wadats(igrid)%USSX(gsea) .NE. undef ) THEN
2311  sumwt6(6) = sumwt6(6) + wt
2312  IF ( ussxaux .EQ. undef ) THEN
2313  ussxaux = wadats(igrid)%USSX(gsea)*wt
2314  ussyaux = wadats(igrid)%USSY(gsea)*wt
2315  ELSE
2316  ussxaux = ussxaux + wadats(igrid)%USSX(gsea)*wt
2317  ussyaux = ussyaux + wadats(igrid)%USSY(gsea)*wt
2318  END IF
2319  END IF
2320  END IF
2321  !
2322  IF ( flogrd(6,7) .AND. active ) THEN
2323  IF ( wadats(igrid)%PRMS(gsea) .NE. undef ) THEN
2324  sumwt6(7) = sumwt6(7) + wt
2325  IF ( prmsaux .EQ. undef ) THEN
2326  prmsaux = wadats(igrid)%PRMS(gsea)*wt
2327  tpmsaux = wadats(igrid)%TPMS(gsea)*wt
2328  ELSE
2329  prmsaux = prmsaux + wadats(igrid)%PRMS(gsea)*wt
2330  tpmsaux = tpmsaux + wadats(igrid)%TPMS(gsea)*wt
2331  END IF
2332  END IF
2333  END IF
2334  !
2335  IF ( flogrd(6,8) .AND. active .AND. us3df(1).GT.0 ) THEN
2336  DO ik = us3df(2),us3df(3)
2337  IF ( wadats(igrid)%US3D(gsea,ik) .NE. undef ) THEN
2338  sumwt68(ik) = sumwt68(ik) + wt
2339  IF ( us3daux(ik) .EQ. undef ) us3daux(ik) = 0.
2340  us3daux(ik) = us3daux(ik) + &
2341  wadats(igrid)%US3D(gsea,ik)*wt
2342  END IF
2343  IF ( wadats(igrid)%US3D(gsea,nk+ik) .NE. undef ) THEN
2344  sumwt68(nk+ik) = sumwt68(nk+ik) + wt
2345  IF ( us3daux(nk+ik) .EQ. undef ) &
2346  us3daux(nk+ik) = 0.
2347  us3daux(nk+ik) = us3daux(nk+ik) + &
2348  wadats(igrid)%US3D(gsea,nk+ik)*wt
2349  END IF
2350  END DO
2351  END IF
2352  !
2353  IF ( flogrd(6,9) .AND. active .AND. p2msf(1).GT.0) THEN
2354  DO ik = p2msf(2),p2msf(3)
2355  IF ( wadats(igrid)%P2SMS(gsea,ik) .NE. undef ) THEN
2356  sumwt69(ik) = sumwt69(ik) + wt
2357  IF ( p2smsaux(ik) .EQ. undef ) p2smsaux(ik) = 0.
2358  p2smsaux(ik) = p2smsaux(ik) + &
2359  wadats(igrid)%P2SMS(gsea,ik)*wt
2360  END IF
2361  END DO
2362  END IF
2363  !
2364  IF ( flogrd(6,10) .AND. active ) THEN
2365  IF ( wadats(igrid)%TAUICE(gsea,1) .NE. undef ) THEN
2366  sumwt6(10) = sumwt6(10) + wt
2367  IF ( tauiceaux(1) .EQ. undef ) tauiceaux(1) = 0.
2368  IF ( tauiceaux(2) .EQ. undef ) tauiceaux(2) = 0.
2369  tauiceaux(1) = tauiceaux(1) + &
2370  wadats(igrid)%TAUICE(gsea,1)*wt
2371  tauiceaux(2) = tauiceaux(2) + &
2372  wadats(igrid)%TAUICE(gsea,2)*wt
2373  END IF
2374  END IF
2375  !
2376  IF ( flogrd(6,11) .AND. active ) THEN
2377  IF ( wadats(igrid)%PHICE(gsea) .NE. undef ) THEN
2378  sumwt6(11) = sumwt6(11) + wt
2379  IF ( phiceaux.EQ.undef ) phiceaux = 0.
2380  phiceaux = phiceaux + wadats(igrid)%PHICE(gsea)*wt
2381  END IF
2382  END IF
2383  !
2384  IF ( flogrd(6,12) .AND. active .AND. usspf(1).GT.0 ) THEN
2385  DO ik = 1,usspf(2)
2386  IF ( wadats(igrid)%USSP(gsea,ik) .NE. undef ) THEN
2387  sumwt612(ik) = sumwt612(ik) + wt
2388  IF ( usspaux(ik) .EQ. undef ) usspaux(ik) = 0.
2389  usspaux(ik) = usspaux(ik) + &
2390  wadats(igrid)%USSP(gsea,ik)*wt
2391  END IF
2392  IF ( wadats(igrid)%USSP(gsea,nk+ik) .NE. undef ) THEN
2393  sumwt612(nk+ik) = sumwt612(nk+ik) + wt
2394  IF ( usspaux(nk+ik) .EQ. undef ) &
2395  usspaux(nk+ik) = 0.
2396  usspaux(nk+ik) = usspaux(nk+ik) + &
2397  wadats(igrid)%USSP(gsea,nk+ik)*wt
2398  END IF
2399  END DO
2400  END IF
2401  !
2402  IF ( flogrd(6,13) .AND. active ) THEN
2403  IF ( wadats(igrid)%TAUOCX(gsea) .NE. undef ) THEN
2404  sumwt6(13) = sumwt6(13) + wt
2405  IF ( tauocxaux .EQ. undef ) THEN
2406  tauocxaux = wadats(igrid)%TAUOCX(gsea)*wt
2407  tauocyaux = wadats(igrid)%TAUOCY(gsea)*wt
2408  ELSE
2409  tauocxaux = tauocxaux + wadats(igrid)%TAUOCX(gsea)*wt
2410  tauocyaux = tauocyaux + wadats(igrid)%TAUOCY(gsea)*wt
2411  END IF
2412  END IF
2413  END IF
2414  !
2415  ! Group 7 variables
2416  !
2417  IF ( flogrd(7,1) .AND. active ) THEN
2418  IF ( wadats(igrid)%ABA(gsea) .NE. undef ) THEN
2419  sumwt7(1) = sumwt7(1) + wt
2420  IF ( abaaux .EQ. undef ) THEN
2421  abaaux = wadats(igrid)%ABA(gsea)*wt
2422  abdaux = wadats(igrid)%ABD(gsea)*wt
2423  ELSE
2424  abaaux = abaaux + wadats(igrid)%ABA(gsea)*wt
2425  abdaux = abdaux + wadats(igrid)%ABD(gsea)*wt
2426  END IF
2427  END IF
2428  END IF
2429  !
2430  IF ( flogrd(7,2) .AND. active ) THEN
2431  IF ( wadats(igrid)%ABA(gsea) .NE. undef ) THEN
2432  sumwt7(2) = sumwt7(2) + wt
2433  IF ( ubaaux .EQ. undef ) THEN
2434  ubaaux = wadats(igrid)%UBA(gsea)*wt
2435  ubdaux = wadats(igrid)%UBD(gsea)*wt
2436  ELSE
2437  ubaaux = ubaaux + wadats(igrid)%UBA(gsea)*wt
2438  ubdaux = ubdaux + wadats(igrid)%UBD(gsea)*wt
2439  END IF
2440  END IF
2441  END IF
2442  !
2443  IF ( flogrd(7,3) .AND. active ) THEN
2444  DO ibed = 1, 3
2445  IF ( wadats(igrid)%BEDFORMS(gsea,ibed) .NE. undef ) THEN
2446  sumwtb(ibed) = sumwtb(ibed) + wt
2447  IF ( bedformsaux(ibed) .EQ. undef ) THEN
2448  bedformsaux(ibed) = wadats(igrid)%BEDFORMS(gsea,ibed)&
2449  *wt
2450  ELSE
2451  bedformsaux(ibed) = bedformsaux(ibed) + &
2452  wadats(igrid)%BEDFORMS(gsea,ibed)*wt
2453  END IF
2454  END IF
2455  END DO
2456  END IF
2457  !
2458  IF ( flogrd(7,4) .AND. active ) THEN
2459  IF ( wadats(igrid)%PHIBBL(gsea) .NE. undef ) THEN
2460  sumwt7(4) = sumwt7(4) + wt
2461  IF ( phibblaux .EQ. undef ) THEN
2462  phibblaux = wadats(igrid)%PHIBBL(gsea)*wt
2463  ELSE
2464  phibblaux = phibblaux + wadats(igrid)%PHIBBL(gsea)*wt
2465  END IF
2466  END IF
2467  END IF
2468  !
2469  IF ( flogrd(7,5) .AND. active ) THEN
2470  IF ( wadats(igrid)%TAUBBL(gsea,1) .NE. undef ) THEN
2471  sumwt7(5) = sumwt7(5) + wt
2472  IF ( taubblaux(1) .EQ. undef ) THEN
2473  taubblaux(1) = wadats(igrid)%TAUBBL(gsea,1)*wt
2474  taubblaux(2) = wadats(igrid)%TAUBBL(gsea,2)*wt
2475  ELSE
2476  taubblaux(1) = taubblaux(1) + &
2477  wadats(igrid)%TAUBBL(gsea,1)*wt
2478  taubblaux(2) = taubblaux(2) + &
2479  wadats(igrid)%TAUBBL(gsea,2)*wt
2480  END IF
2481  END IF
2482  END IF
2483  !
2484  ! Group 8 variables
2485  !
2486  IF ( flogrd(8,1) .AND. active ) THEN
2487  IF ( wadats(igrid)%MSSX(gsea) .NE. undef ) THEN
2488  sumwt8(1) = sumwt8(1) + wt
2489  IF ( mssxaux .EQ. undef ) mssxaux = 0.
2490  IF ( mssyaux .EQ. undef ) mssyaux = 0.
2491  mssxaux = mssxaux + wadats(igrid)%MSSX(gsea)*wt
2492  mssyaux = mssyaux + wadats(igrid)%MSSY(gsea)*wt
2493  END IF
2494  END IF
2495  !
2496  IF ( flogrd(8,2) .AND. active ) THEN
2497  IF ( wadats(igrid)%MSCX(gsea) .NE. undef ) THEN
2498  sumwt8(2) = sumwt8(2) + wt
2499  IF ( mscxaux .EQ. undef ) mscxaux = 0.
2500  IF ( mscyaux .EQ. undef ) mscyaux = 0.
2501  mscxaux = mscxaux + wadats(igrid)%MSCX(gsea)*wt
2502  mscyaux = mscyaux + wadats(igrid)%MSCY(gsea)*wt
2503  END IF
2504  END IF
2505  !
2506  IF ( flogrd(8,3) .AND. active ) THEN
2507  IF ( wadats(igrid)%MSSD(gsea) .NE. undef ) THEN
2508  sumwt8(3) = sumwt8(3) + wt
2509  IF ( mssdaux1 .EQ. undef ) mssdaux1 = 0.
2510  IF ( mssdaux2 .EQ. undef ) mssdaux2 = 0.
2511  mssdaux1 = mssdaux1 + &
2512  cos( wadats(igrid)%MSSD(gsea) )*wt
2513  mssdaux2 = mssdaux2 + &
2514  sin( wadats(igrid)%MSSD(gsea) )*wt
2515  END IF
2516  END IF
2517  !
2518  IF ( flogrd(8,4) .AND. active ) THEN
2519  IF ( wadats(igrid)%MSCD(gsea) .NE. undef ) THEN
2520  sumwt8(4) = sumwt8(4) + wt
2521  IF ( mscdaux1 .EQ. undef ) mscdaux1 = 0.
2522  IF ( mscdaux2 .EQ. undef ) mscdaux2 = 0.
2523  mscdaux1 = mscdaux1 + &
2524  cos( wadats(igrid)%MSCD(gsea) )*wt
2525  mscdaux2 = mscdaux2 + &
2526  sin( wadats(igrid)%MSCD(gsea) )*wt
2527  END IF
2528  END IF
2529  !
2530  IF ( flogrd(8,5) .AND. active ) THEN
2531  IF ( wadats(igrid)%QP(gsea) .NE. undef ) THEN
2532  sumwt8(5) = sumwt8(5) + wt
2533  IF ( qpaux .EQ. undef ) qpaux = 0.
2534  qpaux = qpaux + wadats(igrid)%QP(gsea)*wt
2535  END IF
2536  END IF
2537  !
2538  ! Restart variables
2539  !
2540  IF ( (.NOT.outorrestflag) .AND. active ) THEN
2541  DO ik = 1,nspec
2542  IF ( wdatas(igrid)%VA(ik,gsea) .NE. undef ) THEN
2543  sumres(ik) = sumres(ik) + wt
2544  IF ( vaaux(ik) .EQ. undef ) THEN
2545  vaaux(ik) = wdatas(igrid)%VA(ik,gsea)*wt
2546  ELSE
2547  vaaux(ik) = vaaux(ik) +wdatas(igrid)%VA(ik,gsea)*wt
2548  END IF
2549  END IF
2550  END DO
2551  END IF
2552  !
2553  ! End of loop through the points per grid to obtain interpolated values
2554  END DO !/ IPTS = 1, ...
2555  !
2556  ! Save temp. interpolated variables in proper variables
2557  ! (weighted by the number of grids)
2558  !
2559  !
2560  ! Group 1 variables
2561  !
2562  IF ( dwaux .NE. undef ) THEN
2563  dwaux = dwaux / sumwt1(1)
2564  IF ( dw(isea) .EQ. undef ) THEN
2565  dw(isea) = dwaux / real( sumgrd )
2566  ELSE
2567  dw(isea) = dw(isea) + dwaux / real( sumgrd )
2568  END IF
2569  END IF
2570  !
2571  IF ( cxaux .NE. undef ) THEN
2572  cxaux = cxaux / sumwt1(2)
2573  cyaux = cyaux / sumwt1(2)
2574  IF ( cx(isea) .EQ. undef ) THEN
2575  cx(isea) = cxaux / real( sumgrd )
2576  cy(isea) = cyaux / real( sumgrd )
2577  ELSE
2578  cx(isea) = cx(isea) + cxaux / real( sumgrd )
2579  cy(isea) = cy(isea) + cyaux / real( sumgrd )
2580  END IF
2581  END IF
2582  !
2583  IF ( uaaux .NE. undef ) THEN
2584  uaaux = uaaux / sumwt1(3)
2585  udaux = udaux / sumwt1(3)
2586  IF ( ua(isea) .EQ. undef ) THEN
2587  ua(isea) = uaaux / real( sumgrd )
2588  ud(isea) = udaux / real( sumgrd )
2589  ELSE
2590  ua(isea) = ua(isea) + uaaux / real( sumgrd )
2591  ud(isea) = ud(isea) + udaux / real( sumgrd )
2592  END IF
2593  END IF
2594  !
2595  IF ( asaux .NE. undef ) THEN
2596  asaux = asaux / sumwt1(4)
2597  IF ( as(isea) .EQ. undef ) THEN
2598  as(isea) = asaux / real( sumgrd )
2599  ELSE
2600  as(isea) = as(isea) + asaux / real( sumgrd )
2601  END IF
2602  END IF
2603  !
2604  IF ( wlvaux .NE. undef ) THEN
2605  wlvaux = wlvaux / sumwt1(5)
2606  IF ( wlv(isea) .EQ. undef ) THEN
2607  wlv(isea) = wlvaux / real( sumgrd )
2608  ELSE
2609  wlv(isea) = wlv(isea) + wlvaux / real( sumgrd )
2610  END IF
2611  END IF
2612  !
2613  IF ( iceaux .NE. undef ) THEN
2614  iceaux = iceaux / sumwt1(6)
2615  IF ( ice(isea) .EQ. undef ) THEN
2616  ice(isea) = iceaux / real( sumgrd )
2617  ELSE
2618  ice(isea) = ice(isea) + iceaux / real( sumgrd )
2619  END IF
2620  END IF
2621  !
2622  IF ( bergaux .NE. undef ) THEN
2623  bergaux = bergaux / sumwt1(7)
2624  IF ( berg(isea) .EQ. undef ) THEN
2625  berg(isea) = bergaux / real( sumgrd )
2626  ELSE
2627  berg(isea) = berg(isea) + bergaux / real( sumgrd )
2628  END IF
2629  END IF
2630  !
2631  IF ( tauaaux .NE. undef ) THEN
2632  tauaaux = tauaaux / sumwt1(8)
2633  tauadiraux = tauadiraux / sumwt1(8)
2634  IF ( taua(isea) .EQ. undef ) THEN
2635  taua(isea) = tauaaux / real( sumgrd )
2636  tauadir(isea) = tauadiraux / real( sumgrd )
2637  ELSE
2638  taua(isea) = taua(isea) + tauaaux / real( sumgrd )
2639  tauadir(isea) = tauadir(isea) + tauadiraux / real( sumgrd )
2640  END IF
2641  END IF
2642  !
2643  IF ( rhoairaux .NE. undef ) THEN
2644  rhoairaux = rhoairaux / sumwt1(9)
2645  IF ( rhoair(isea) .EQ. undef ) THEN
2646  rhoair(isea) = rhoairaux / real( sumgrd )
2647  ELSE
2648  rhoair(isea) = rhoair(isea) + rhoairaux / real( sumgrd )
2649  END IF
2650  END IF
2651  !
2652 #ifdef W3_BT4
2653  IF ( sed_d50aux .NE. undef ) THEN
2654  sed_d50aux = sed_d50aux / sumwt1(10)
2655  IF ( sed_d50(isea) .EQ. undef ) THEN
2656  sed_d50(isea) = sed_d50aux / real( sumgrd )
2657  ELSE
2658  sed_d50(isea) = sed_d50(isea) + sed_d50aux / real( sumgrd )
2659  END IF
2660  END IF
2661 #endif
2662  !
2663 #ifdef W3_IS2
2664  IF ( icehaux .NE. undef ) THEN
2665  icehaux = icehaux / sumwt1(11)
2666  IF ( iceh(isea) .EQ. undef ) THEN
2667  iceh(isea) = icehaux / real( sumgrd )
2668  ELSE
2669  iceh(isea) = iceh(isea) + icehaux / real( sumgrd )
2670  END IF
2671  END IF
2672 #endif
2673  !
2674 #ifdef W3_IS2
2675  IF ( icefaux .NE. undef ) THEN
2676  icefaux = icefaux / sumwt1(12)
2677  IF ( icef(isea) .EQ. undef ) THEN
2678  icef(isea) = icefaux / real( sumgrd )
2679  ELSE
2680  icef(isea) = icef(isea) + icefaux / real( sumgrd )
2681  END IF
2682  END IF
2683 #endif
2684  !
2685  ! Group 2 variables
2686  !
2687  IF ( hsaux .NE. undef ) THEN
2688  hsaux = hsaux / sumwt2(1)
2689  IF ( hs(isea) .EQ. undef ) THEN
2690  hs(isea) = hsaux / real( sumgrd )
2691  ELSE
2692  hs(isea) = hs(isea) + hsaux / real( sumgrd )
2693  END IF
2694  END IF
2695  !
2696  IF ( wlmaux .NE. undef ) THEN
2697  wlmaux = wlmaux / sumwt2(2)
2698  IF ( wlm(isea) .EQ. undef ) THEN
2699  wlm(isea) = wlmaux / real( sumgrd )
2700  ELSE
2701  wlm(isea) = wlm(isea) + wlmaux / real( sumgrd )
2702  END IF
2703  END IF
2704  !
2705  IF ( t02aux .NE. undef ) THEN
2706  t02aux = t02aux / sumwt2(3)
2707  IF ( t02(isea) .EQ. undef ) THEN
2708  t02(isea) = t02aux / real( sumgrd )
2709  ELSE
2710  t02(isea) = t02(isea) + t02aux / real( sumgrd )
2711  END IF
2712  END IF
2713  !
2714  IF ( t0m1aux .NE. undef ) THEN
2715  t0m1aux = t0m1aux / sumwt2(4)
2716  IF ( t0m1(isea) .EQ. undef ) THEN
2717  t0m1(isea) = t0m1aux / real( sumgrd )
2718  ELSE
2719  t0m1(isea) = t0m1(isea) + t0m1aux / real( sumgrd )
2720  END IF
2721  END IF
2722  !
2723  IF ( t01aux .NE. undef ) THEN
2724  t01aux = t01aux / sumwt2(5)
2725  IF ( t01(isea) .EQ. undef ) THEN
2726  t01(isea) = t01aux / real( sumgrd )
2727  ELSE
2728  t01(isea) = t01(isea) + t01aux / real( sumgrd )
2729  END IF
2730  END IF
2731  !
2732  IF ( fp0aux .NE. undef ) THEN
2733  fp0aux = fp0aux / sumwt2(6)
2734  IF ( fp0(isea) .EQ. undef ) THEN
2735  fp0(isea) = fp0aux / real( sumgrd )
2736  ELSE
2737  fp0(isea) = fp0(isea) + fp0aux / real( sumgrd )
2738  END IF
2739  END IF
2740  !
2741  IF ( thmaux1 .NE. undef ) THEN
2742  thmaux1 = thmaux1 / sumwt2(7)
2743  thmaux2 = thmaux2 / sumwt2(7)
2744  IF ( thm(isea) .EQ. undef ) THEN
2745  thmaux1 = thmaux1 / real( sumgrd )
2746  thmaux2 = thmaux2 / real( sumgrd )
2747  thm(isea) = atan2( thmaux2, thmaux1 )
2748  ELSE
2749  thmaux1 = thmaux1 / real( sumgrd ) + cos( thm(isea) )
2750  thmaux2 = thmaux2 / real( sumgrd ) + sin( thm(isea) )
2751  thm(isea) = atan2( thmaux2, thmaux1 )
2752  END IF
2753  END IF
2754  !
2755  IF ( thsaux .NE. undef ) THEN
2756  thsaux = thsaux / sumwt2(8)
2757  IF ( ths(isea) .EQ. undef ) THEN
2758  ths(isea) = thsaux / real( sumgrd )
2759  ELSE
2760  ths(isea) = ths(isea) + thsaux / real( sumgrd )
2761  END IF
2762  END IF
2763  !
2764  IF ( thp0aux1 .NE. undef ) THEN
2765  thp0aux1 = thp0aux1 / sumwt2(9)
2766  thp0aux2 = thp0aux2 / sumwt2(9)
2767  IF ( thp0(isea) .EQ. undef ) THEN
2768  thp0aux1 = thp0aux1 / real( sumgrd )
2769  thp0aux2 = thp0aux2 / real( sumgrd )
2770  thp0(isea) = atan2( thp0aux2, thp0aux1 )
2771  ELSE
2772  thp0aux1 = thp0aux1 / real( sumgrd ) + cos( thp0(isea) )
2773  thp0aux2 = thp0aux2 / real( sumgrd ) + sin( thp0(isea) )
2774  thp0(isea) = atan2( thp0aux2, thp0aux1 )
2775  END IF
2776  END IF
2777  !
2778  IF ( hsigaux .NE. undef ) THEN
2779  IF ( hsig(isea) .EQ. undef ) hsig(isea) = 0.
2780  hsig(isea) = hsig(isea) + &
2781  hsigaux / real( sumwt2(10)*sumgrd )
2782  END IF
2783  !
2784  IF ( stmaxeaux .NE. undef ) THEN
2785  IF ( stmaxe(isea) .EQ. undef ) stmaxe(isea) = 0.
2786  stmaxe(isea) = stmaxe(isea) + &
2787  stmaxeaux / real( sumwt2(11) * sumgrd )
2788  END IF
2789  !
2790  IF ( stmaxdaux .NE. undef ) THEN
2791  IF ( stmaxd(isea) .EQ. undef ) stmaxd(isea) = 0.
2792  stmaxd(isea) = stmaxd(isea) + &
2793  stmaxdaux / real( sumwt2(12) * sumgrd )
2794  END IF
2795  !
2796  IF ( hmaxeaux .NE. undef ) THEN
2797  IF ( hmaxe(isea) .EQ. undef ) hmaxe(isea) = 0.
2798  hmaxe(isea) = hmaxe(isea) + &
2799  hmaxeaux / real( sumwt2(13) * sumgrd )
2800  END IF
2801  !
2802  IF ( hcmaxeaux .NE. undef ) THEN
2803  IF ( hcmaxe(isea) .EQ. undef ) hcmaxe(isea) = 0.
2804  hcmaxe(isea) = hcmaxe(isea) + &
2805  hcmaxeaux / real( sumwt2(14) * sumgrd )
2806  END IF
2807  !
2808  IF ( hmaxdaux .NE. undef ) THEN
2809  IF ( hmaxd(isea) .EQ. undef ) hmaxd(isea) = 0.
2810  hmaxd(isea) = hmaxd(isea) + &
2811  hmaxdaux / real( sumwt2(15) * sumgrd )
2812  END IF
2813  !
2814  IF ( hcmaxdaux .NE. undef ) THEN
2815  IF ( hcmaxd(isea) .EQ. undef ) hcmaxd(isea) = 0.
2816  hcmaxd(isea) = hcmaxd(isea) + &
2817  hcmaxdaux / real( sumwt2(16) * sumgrd )
2818  END IF
2819  !
2820  IF ( wbtaux .NE. undef ) THEN
2821  IF ( wbt(isea) .EQ. undef ) wbt(isea) = 0.
2822  wbt(isea) = wbt(isea) + &
2823  wbtaux / real( sumwt2(17)*sumgrd )
2824  END IF
2825  !
2826  IF ( wnmeanaux .NE. undef ) THEN
2827  IF ( wnmean(isea) .EQ. undef ) wnmean(isea) = 0.
2828  wnmean(isea) = wnmean(isea) + &
2829  wnmeanaux / real( sumwt2(19)*sumgrd )
2830  END IF
2831  !
2832  ! Group 3 variables
2833  !
2834  IF ( e3df(1,1).GT.0 ) THEN
2835  DO ifreq = e3df(2,1),e3df(3,1)
2836  IF ( efaux(ifreq) .NE. undef ) THEN
2837  efaux(ifreq) = efaux(ifreq) / sumwt3a(ifreq)
2838  IF ( ef(isea,ifreq) .EQ. undef ) THEN
2839  ef(isea,ifreq) = efaux(ifreq) / real( sumgrd )
2840  ELSE
2841  ef(isea,ifreq) = ef(isea,ifreq) + &
2842  efaux(ifreq) / real( sumgrd )
2843  END IF
2844  END IF
2845  END DO
2846  END IF
2847  !
2848  IF ( e3df(1,2).GT.0 ) THEN
2849  DO ifreq = e3df(2,2),e3df(3,2)
2850  IF ( th1maux(ifreq) .NE. undef ) THEN
2851  th1maux(ifreq) = th1maux(ifreq) / sumwt3b(ifreq)
2852  IF ( th1m(isea,ifreq) .EQ. undef ) THEN
2853  th1m(isea,ifreq) = th1maux(ifreq) / real( sumgrd )
2854  ELSE
2855  th1m(isea,ifreq) = th1m(isea,ifreq) + &
2856  th1maux(ifreq) / real( sumgrd )
2857  END IF
2858  END IF
2859  END DO
2860  END IF
2861  !
2862  IF ( e3df(1,3).GT.0 ) THEN
2863  DO ifreq = e3df(2,3),e3df(3,3)
2864  IF ( sth1maux(ifreq) .NE. undef ) THEN
2865  sth1maux(ifreq) = sth1maux(ifreq) / sumwt3c(ifreq)
2866  IF ( sth1m(isea,ifreq) .EQ. undef ) THEN
2867  sth1m(isea,ifreq) = sth1maux(ifreq) / real( sumgrd )
2868  ELSE
2869  sth1m(isea,ifreq) = sth1m(isea,ifreq) + &
2870  sth1maux(ifreq) / real( sumgrd )
2871  END IF
2872  END IF
2873  END DO
2874  END IF
2875  !
2876  IF ( e3df(1,4).GT.0 ) THEN
2877  DO ifreq = e3df(2,4),e3df(3,4)
2878  IF ( th2maux(ifreq) .NE. undef ) THEN
2879  th2maux(ifreq) = th2maux(ifreq) / sumwt3d(ifreq)
2880  IF ( th2m(isea,ifreq) .EQ. undef ) THEN
2881  th2m(isea,ifreq) = th2maux(ifreq) / real( sumgrd )
2882  ELSE
2883  th2m(isea,ifreq) = th2m(isea,ifreq) + &
2884  th2maux(ifreq) / real( sumgrd )
2885  END IF
2886  END IF
2887  END DO
2888  END IF
2889  !
2890  IF ( e3df(1,5).GT.0 ) THEN
2891  DO ifreq = e3df(2,5),e3df(3,5)
2892  IF ( sth2maux(ifreq) .NE. undef ) THEN
2893  sth2maux(ifreq) = sth2maux(ifreq) / sumwt3e(ifreq)
2894  IF ( sth2m(isea,ifreq) .EQ. undef ) THEN
2895  sth2m(isea,ifreq) = sth2maux(ifreq) / real( sumgrd )
2896  ELSE
2897  sth2m(isea,ifreq) = sth2m(isea,ifreq) + &
2898  sth2maux(ifreq) / real( sumgrd )
2899  END IF
2900  END IF
2901  END DO
2902  END IF
2903  !
2904  DO ik = 1,nk
2905  IF ( wnaux(ik) .NE. undef ) THEN
2906  wnaux(ik) = wnaux(ik) / sumwt3f(ik)
2907  IF ( wn(ik,isea) .EQ. undef ) THEN
2908  wn(ik,isea) = wnaux(ik) / real( sumgrd )
2909  ELSE
2910  wn(ik,isea) = wn(ik,isea) + &
2911  wnaux(ik) / real( sumgrd )
2912  END IF
2913  END IF
2914  END DO
2915  !
2916  ! Group 4 variables
2917  !
2918  DO iswll = 0, noswll_min
2919  !
2920  IF ( phsaux(iswll) .NE. undef ) THEN
2921  phsaux(iswll) = phsaux(iswll) / sumwt4(1,iswll)
2922  IF ( phs(isea,iswll) .EQ. undef ) THEN
2923  phs(isea,iswll) = phsaux(iswll) / real( sumgrd )
2924  ELSE
2925  phs(isea,iswll) = phs(isea,iswll) + &
2926  phsaux(iswll) / real( sumgrd )
2927  END IF
2928  END IF
2929  !
2930  IF ( ptpaux(iswll) .NE. undef ) THEN
2931  ptpaux(iswll) = ptpaux(iswll) / sumwt4(2,iswll)
2932  IF ( ptp(isea,iswll) .EQ. undef ) THEN
2933  ptp(isea,iswll) = ptpaux(iswll) / real( sumgrd )
2934  ELSE
2935  ptp(isea,iswll) = ptp(isea,iswll) + &
2936  ptpaux(iswll) / real( sumgrd )
2937  END IF
2938  END IF
2939  !
2940  IF ( plpaux(iswll) .NE. undef ) THEN
2941  plpaux(iswll) = plpaux(iswll) / sumwt4(3,iswll)
2942  IF ( plp(isea,iswll) .EQ. undef ) THEN
2943  plp(isea,iswll) = plpaux(iswll) / real( sumgrd )
2944  ELSE
2945  plp(isea,iswll) = plp(isea,iswll) + &
2946  plpaux(iswll) / real( sumgrd )
2947  END IF
2948  END IF
2949  !
2950  IF ( pdiraux1(iswll) .NE. undef ) THEN
2951  pdiraux1(iswll) = pdiraux1(iswll) / sumwt4(4,iswll)
2952  pdiraux2(iswll) = pdiraux2(iswll) / sumwt4(4,iswll)
2953  IF ( pdir(isea,iswll) .EQ. undef ) THEN
2954  pdiraux1(iswll) = pdiraux1(iswll) / real( sumgrd )
2955  pdiraux2(iswll) = pdiraux2(iswll) / real( sumgrd )
2956  pdir(isea,iswll) = atan2( pdiraux2(iswll), pdiraux1(iswll) )
2957  ELSE
2958  pdiraux1(iswll) = pdiraux1(iswll) / real( sumgrd ) + &
2959  cos( pdir(isea,iswll) )
2960  pdiraux2(iswll) = pdiraux2(iswll) / real( sumgrd ) + &
2961  sin( pdir(isea,iswll) )
2962  pdir(isea,iswll) = atan2( pdiraux2(iswll), pdiraux1(iswll) )
2963  END IF
2964  END IF
2965  !
2966  IF ( psiaux(iswll) .NE. undef ) THEN
2967  psiaux(iswll) = psiaux(iswll) / sumwt4(5,iswll)
2968  IF ( psi(isea,iswll) .EQ. undef ) THEN
2969  psi(isea,iswll) = psiaux(iswll) / real( sumgrd )
2970  ELSE
2971  psi(isea,iswll) = psi(isea,iswll) + &
2972  psiaux(iswll) / real( sumgrd )
2973  END IF
2974  END IF
2975  !
2976  IF ( pwsaux(iswll) .NE. undef ) THEN
2977  pwsaux(iswll) = pwsaux(iswll) / sumwt4(6,iswll)
2978  IF ( pws(isea,iswll) .EQ. undef ) THEN
2979  pws(isea,iswll) = pwsaux(iswll) / real( sumgrd )
2980  ELSE
2981  pws(isea,iswll) = pws(isea,iswll) + &
2982  pwsaux(iswll) / real( sumgrd )
2983  END IF
2984  END IF
2985  !
2986  IF ( pthp0aux1(iswll) .NE. undef ) THEN
2987  pthp0aux1(iswll) = pthp0aux1(iswll) &
2988  / real( sumwt4(7,iswll)*sumgrd )
2989  pthp0aux2(iswll) = pthp0aux2(iswll) &
2990  / real( sumwt4(7,iswll)*sumgrd )
2991  IF ( pthp0(isea,iswll) .NE. undef ) THEN
2992  pthp0aux1(iswll) = pthp0aux1(iswll) + &
2993  cos( pthp0(isea,iswll) )
2994  pthp0aux2(iswll) = pthp0aux2(iswll) + &
2995  sin( pthp0(isea,iswll) )
2996  END IF
2997  pthp0(isea,iswll) = &
2998  atan2( pthp0aux2(iswll), pthp0aux1(iswll) )
2999  END IF
3000  !
3001  IF ( pqpaux(iswll) .NE. undef ) THEN
3002  IF ( pqp(isea,iswll) .EQ. undef ) &
3003  pqp(isea,iswll) = 0.
3004  pqp(isea,iswll) = pqp(isea,iswll) + &
3005  pqpaux(iswll) / real( sumwt4(8,iswll)*sumgrd )
3006  END IF
3007  !
3008  IF ( ppeaux(iswll) .NE. undef ) THEN
3009  IF ( ppe(isea,iswll) .EQ. undef ) &
3010  ppe(isea,iswll) = 0.
3011  ppe(isea,iswll) = ppe(isea,iswll) + &
3012  ppeaux(iswll) / real( sumwt4(9,iswll)*sumgrd )
3013 
3014  END IF
3015  !
3016  IF ( pgwaux(iswll) .NE. undef ) THEN
3017  IF ( pgw(isea,iswll) .EQ. undef ) &
3018  pgw(isea,iswll) = 0.
3019  pgw(isea,iswll) = pgw(isea,iswll) + &
3020  pgwaux(iswll) / real( sumwt4(10,iswll)*sumgrd )
3021  END IF
3022  !
3023  IF ( pswaux(iswll) .NE. undef ) THEN
3024  IF ( psw(isea,iswll) .EQ. undef ) &
3025  psw(isea,iswll) = 0.
3026  psw(isea,iswll) = psw(isea,iswll) + &
3027  pswaux(iswll) / real( sumwt4(11,iswll)*sumgrd )
3028  END IF
3029  !
3030  IF ( ptm1aux(iswll) .NE. undef ) THEN
3031  IF ( ptm1(isea,iswll) .EQ. undef ) &
3032  ptm1(isea,iswll) = 0.
3033  ptm1(isea,iswll) = ptm1(isea,iswll) + &
3034  ptm1aux(iswll) / real( sumwt4(12,iswll)*sumgrd )
3035  END IF
3036  !
3037  IF ( pt1aux(iswll) .NE. undef ) THEN
3038  IF ( pt1(isea,iswll) .EQ. undef ) &
3039  pt1(isea,iswll) = 0.
3040  pt1(isea,iswll) = pt1(isea,iswll) + &
3041  pt1aux(iswll) / real( sumwt4(13,iswll)*sumgrd )
3042  END IF
3043  !
3044  IF ( pt2aux(iswll) .NE. undef ) THEN
3045  IF ( pt2(isea,iswll) .EQ. undef ) &
3046  pt2(isea,iswll) = 0.
3047  pt2(isea,iswll) = pt2(isea,iswll) + &
3048  pt2aux(iswll) / real( sumwt4(14,iswll)*sumgrd )
3049  END IF
3050  !
3051  IF ( pepaux(iswll) .NE. undef ) THEN
3052  IF ( pep(isea,iswll) .EQ. undef ) &
3053  pep(isea,iswll) = 0.
3054  pep(isea,iswll) = pep(isea,iswll) + &
3055  pepaux(iswll) / real( sumwt4(15,iswll)*sumgrd )
3056  END IF
3057  !
3058  END DO !/ ISWLL = 0, NOSWLL_MIN
3059  !
3060  IF ( pwstaux .NE. undef ) THEN
3061  pwstaux = pwstaux / sumwt4(16,0)
3062  IF ( pwst(isea) .EQ. undef ) THEN
3063  pwst(isea) = pwstaux / real( sumgrd )
3064  ELSE
3065  pwst(isea) = pwst(isea) + pwstaux / real( sumgrd )
3066  END IF
3067  END IF
3068  !
3069  ! Group 5 variables
3070  !
3071  IF ( ustaux1 .NE. undef ) THEN
3072  ustaux1 = ustaux1 / sumwt5(1)
3073  ustaux2 = ustaux2 / sumwt5(1)
3074  IF ( ust(isea) .EQ. undef ) THEN
3075  ust(isea) = ustaux1 / real( sumgrd )
3076  ustdir(isea) = ustaux2 / real( sumgrd )
3077  ELSE
3078  ust(isea) = ust(isea) + ustaux1 / real( sumgrd )
3079  ustdir(isea) = ustdir(isea) + ustaux2 / real( sumgrd )
3080  END IF
3081  END IF
3082  !
3083  IF ( charnaux .NE. undef ) THEN
3084  charnaux = charnaux / sumwt5(2)
3085  IF ( charn(isea) .EQ. undef ) THEN
3086  charn(isea) = charnaux / real( sumgrd )
3087  ELSE
3088  charn(isea) = charn(isea) + charnaux / real( sumgrd )
3089  END IF
3090  END IF
3091  !
3092  IF ( cgeaux .NE. undef ) THEN
3093  cgeaux = cgeaux / sumwt5(3)
3094  IF ( cge(isea) .EQ. undef ) THEN
3095  cge(isea) = cgeaux / real( sumgrd )
3096  ELSE
3097  cge(isea) = cge(isea) + cgeaux / real( sumgrd )
3098  END IF
3099  END IF
3100  !
3101  IF ( phiawaux .NE. undef ) THEN
3102  phiawaux = phiawaux / sumwt5(4)
3103  IF ( phiaw(isea) .EQ. undef ) THEN
3104  phiaw(isea) = phiawaux / real( sumgrd )
3105  ELSE
3106  phiaw(isea) = phiaw(isea) + phiawaux / real( sumgrd )
3107  END IF
3108  END IF
3109  !
3110  IF ( tauwixaux .NE. undef ) THEN
3111  tauwixaux = tauwixaux / sumwt5(5)
3112  tauwiyaux = tauwiyaux / sumwt5(5)
3113  IF ( tauwix(isea) .EQ. undef ) THEN
3114  tauwix(isea) = tauwixaux / real( sumgrd )
3115  tauwiy(isea) = tauwiyaux / real( sumgrd )
3116  ELSE
3117  tauwix(isea) = tauwix(isea) + tauwixaux / real( sumgrd )
3118  tauwiy(isea) = tauwiy(isea) + tauwiyaux / real( sumgrd )
3119  END IF
3120  END IF
3121  !
3122  IF ( tauwnxaux .NE. undef ) THEN
3123  tauwnxaux = tauwnxaux / sumwt5(6)
3124  tauwnyaux = tauwnyaux / sumwt5(6)
3125  IF ( tauwnx(isea) .EQ. undef ) THEN
3126  tauwnx(isea) = tauwnxaux / real( sumgrd )
3127  tauwny(isea) = tauwnyaux / real( sumgrd )
3128  ELSE
3129  tauwnx(isea) = tauwnx(isea) + tauwnxaux / real( sumgrd )
3130  tauwny(isea) = tauwny(isea) + tauwnyaux / real( sumgrd )
3131  END IF
3132  END IF
3133  !
3134  DO icap = 1,4
3135  IF ( whitecapaux(icap) .NE. undef ) THEN
3136  whitecapaux(icap) = whitecapaux(icap) / sumwtc(icap)
3137  IF ( whitecap(isea,icap) .EQ. undef ) THEN
3138  whitecap(isea,icap) = whitecapaux(icap) / real( sumgrd )
3139  ELSE
3140  whitecap(isea,icap) = whitecap(isea,icap) + &
3141  whitecapaux(icap) / real( sumgrd )
3142  END IF
3143  END IF
3144  END DO
3145  !
3146  ! Group 6 variables
3147  !
3148  IF ( sxxaux .NE. undef ) THEN
3149  sxxaux = sxxaux / sumwt6(1)
3150  sxyaux = sxyaux / sumwt6(1)
3151  syyaux = syyaux / sumwt6(1)
3152  IF ( sxx(isea) .EQ. undef ) THEN
3153  sxx(isea) = sxxaux / real( sumgrd )
3154  sxy(isea) = sxyaux / real( sumgrd )
3155  syy(isea) = syyaux / real( sumgrd )
3156  ELSE
3157  sxx(isea) = sxx(isea) + sxxaux / real( sumgrd )
3158  sxy(isea) = sxy(isea) + sxyaux / real( sumgrd )
3159  syy(isea) = syy(isea) + syyaux / real( sumgrd )
3160  END IF
3161  END IF
3162  !
3163  IF ( tauoxaux .NE. undef ) THEN
3164  tauoxaux = tauoxaux / sumwt6(2)
3165  tauoyaux = tauoyaux / sumwt6(2)
3166  IF ( tauox(isea) .EQ. undef ) THEN
3167  tauox(isea) = tauoxaux / real( sumgrd )
3168  tauoy(isea) = tauoyaux / real( sumgrd )
3169  ELSE
3170  tauox(isea) = tauox(isea) + tauoxaux / real( sumgrd )
3171  tauoy(isea) = tauoy(isea) + tauoyaux / real( sumgrd )
3172  END IF
3173  END IF
3174  !
3175  IF ( bhdaux .NE. undef ) THEN
3176  bhdaux = bhdaux / sumwt6(3)
3177  IF ( bhd(isea) .EQ. undef ) THEN
3178  bhd(isea) = bhdaux / real( sumgrd )
3179  ELSE
3180  bhd(isea) = bhd(isea) + bhdaux / real( sumgrd )
3181  END IF
3182  END IF
3183  !
3184  IF ( phiocaux .NE. undef ) THEN
3185  phiocaux = phiocaux / sumwt6(4)
3186  IF ( phioc(isea) .EQ. undef ) THEN
3187  phioc(isea) = phiocaux / real( sumgrd )
3188  ELSE
3189  phioc(isea) = phioc(isea) + phiocaux / real( sumgrd )
3190  END IF
3191  END IF
3192  !
3193  IF ( tusxaux .NE. undef ) THEN
3194  tusxaux = tusxaux / sumwt6(5)
3195  tusyaux = tusyaux / sumwt6(5)
3196  IF ( tusx(isea) .EQ. undef ) THEN
3197  tusx(isea) = tusxaux / real( sumgrd )
3198  tusy(isea) = tusyaux / real( sumgrd )
3199  ELSE
3200  tusx(isea) = tusx(isea) + tusxaux / real( sumgrd )
3201  tusy(isea) = tusy(isea) + tusyaux / real( sumgrd )
3202  END IF
3203  END IF
3204  !
3205  IF ( ussxaux .NE. undef ) THEN
3206  ussxaux = ussxaux / sumwt6(6)
3207  ussyaux = ussyaux / sumwt6(6)
3208  IF ( ussx(isea) .EQ. undef ) THEN
3209  ussx(isea) = ussxaux / real( sumgrd )
3210  ussy(isea) = ussyaux / real( sumgrd )
3211  ELSE
3212  ussx(isea) = ussx(isea) + ussxaux / real( sumgrd )
3213  ussy(isea) = ussy(isea) + ussyaux / real( sumgrd )
3214  END IF
3215  END IF
3216  !
3217  IF ( prmsaux .NE. undef ) THEN
3218  prmsaux = prmsaux / sumwt6(7)
3219  tpmsaux = tpmsaux / sumwt6(7)
3220  IF ( prms(isea) .EQ. undef ) THEN
3221  prms(isea) = prmsaux / real( sumgrd )
3222  tpms(isea) = tpmsaux / real( sumgrd )
3223  ELSE
3224  prms(isea) = prms(isea) + prmsaux / real( sumgrd )
3225  tpms(isea) = tpms(isea) + tpmsaux / real( sumgrd )
3226  END IF
3227  END IF
3228  !
3229  IF ( us3df(1).GT.0 ) THEN
3230  DO ik = us3df(2),us3df(3)
3231  IF ( us3daux(ik) .NE. undef ) THEN
3232  IF ( us3d(isea,ik) .EQ. undef ) us3d(isea,ik) = 0.
3233  us3d(isea,ik) = us3d(isea,ik) + &
3234  us3daux(ik) / real( sumwt68(ik) * sumgrd )
3235  END IF
3236  IF ( us3daux(nk+ik) .NE. undef ) THEN
3237  IF ( us3d(isea,nk+ik) .EQ. undef ) &
3238  us3d(isea,nk+ik) = 0.
3239  us3d(isea,nk+ik) = us3d(isea,nk+ik) + &
3240  us3daux(nk+ik) / real( sumwt68(nk+ik) * sumgrd )
3241  END IF
3242  END DO
3243  END IF
3244  !
3245  IF ( p2msf(1).GT.0 ) THEN
3246  DO ik = p2msf(2),p2msf(3)
3247  IF ( p2smsaux(ik) .NE. undef ) THEN
3248  IF ( p2sms(isea,ik).EQ.undef ) p2sms(isea,ik) = 0.
3249  p2sms(isea,ik) = p2sms(isea,ik) + &
3250  p2smsaux(ik) / real( sumwt69(ik) * sumgrd )
3251  END IF
3252  END DO
3253  END IF
3254  !
3255  IF ( tauiceaux(1) .NE. undef ) THEN
3256  IF ( tauice(isea,1) .EQ. undef ) tauice(isea,1) = 0.
3257  IF ( tauice(isea,2) .EQ. undef ) tauice(isea,2) = 0.
3258  tauice(isea,1) = tauice(isea,1) + &
3259  tauiceaux(1) / real( sumwt6(10) * sumgrd )
3260  tauice(isea,2) = tauice(isea,2) + &
3261  tauiceaux(2) / real( sumwt6(10) * sumgrd )
3262  END IF
3263  !
3264  IF ( phiceaux .NE. undef ) THEN
3265  IF ( phice(isea) .EQ. undef ) phice(isea) = 0.
3266  phice(isea) = phice(isea) + &
3267  phiceaux / real( sumwt6(11) * sumgrd )
3268  END IF
3269  !
3270  IF ( usspf(1).GT.0 ) THEN
3271  DO ik = 1,usspf(2)
3272  IF ( usspaux(ik) .NE. undef ) THEN
3273  IF ( ussp(isea,ik) .EQ. undef ) ussp(isea,ik) = 0.
3274  ussp(isea,ik) = ussp(isea,ik) + &
3275  usspaux(ik) / real( sumwt612(ik) * sumgrd )
3276  END IF
3277  IF ( usspaux(nk+ik) .NE. undef ) THEN
3278  IF ( ussp(isea,nk+ik) .EQ. undef ) &
3279  ussp(isea,nk+ik) = 0.
3280  ussp(isea,nk+ik) = ussp(isea,nk+ik) + &
3281  usspaux(nk+ik) / real( sumwt612(nk+ik) * sumgrd )
3282  END IF
3283  END DO
3284  END IF
3285  !
3286  IF ( tauocxaux .NE. undef ) THEN
3287  tauocxaux = tauocxaux / sumwt6(13)
3288  tauocyaux = tauocyaux / sumwt6(13)
3289  IF ( tauocx(isea) .EQ. undef ) THEN
3290  tauocx(isea) = tauocxaux / real( sumgrd )
3291  tauocy(isea) = tauocyaux / real( sumgrd )
3292  ELSE
3293  tauocx(isea) = tauocx(isea) + tauocxaux / real( sumgrd )
3294  tauocy(isea) = tauocy(isea) + tauocyaux / real( sumgrd )
3295  END IF
3296  END IF
3297  !
3298  ! Group 7 variables
3299  !
3300  IF ( abaaux .NE. undef ) THEN
3301  abaaux = abaaux / sumwt7(1)
3302  abdaux = abdaux / sumwt7(1)
3303  IF ( aba(isea) .EQ. undef ) THEN
3304  aba(isea) = abaaux / real( sumgrd )
3305  abd(isea) = abdaux / real( sumgrd )
3306  ELSE
3307  aba(isea) = aba(isea) + abaaux / real( sumgrd )
3308  abd(isea) = abd(isea) + abdaux / real( sumgrd )
3309  END IF
3310  END IF
3311  !
3312  IF ( ubaaux .NE. undef ) THEN
3313  ubaaux = ubaaux / sumwt7(2)
3314  ubdaux = ubdaux / sumwt7(2)
3315  IF ( uba(isea) .EQ. undef ) THEN
3316  uba(isea) = ubaaux / real( sumgrd )
3317  ubd(isea) = ubdaux / real( sumgrd )
3318  ELSE
3319  uba(isea) = uba(isea) + ubaaux / real( sumgrd )
3320  ubd(isea) = ubd(isea) + ubdaux / real( sumgrd )
3321  END IF
3322  END IF
3323  !
3324  DO ibed = 1,3
3325  IF ( bedformsaux(ibed) .NE. undef ) THEN
3326  bedformsaux(ibed) = bedformsaux(ibed) / sumwtb(ibed)
3327  IF ( bedforms(isea,ibed) .EQ. undef ) THEN
3328  bedforms(isea,ibed) = bedformsaux(ibed) / real( sumgrd )
3329  ELSE
3330  bedforms(isea,ibed) = bedforms(isea,ibed) + &
3331  bedformsaux(ibed) / real( sumgrd )
3332  END IF
3333  END IF
3334  END DO
3335  !
3336  IF ( phibblaux .NE. undef ) THEN
3337  phibblaux = phibblaux / sumwt7(4)
3338  IF ( phibbl(isea) .EQ. undef ) THEN
3339  phibbl(isea) = phibblaux / real( sumgrd )
3340  ELSE
3341  phibbl(isea) = phibbl(isea) + phibblaux / real( sumgrd )
3342  END IF
3343  END IF
3344  !
3345  IF ( taubblaux(1) .NE. undef ) THEN
3346  taubblaux(1) = taubblaux(1) / sumwt7(5)
3347  taubblaux(2) = taubblaux(2) / sumwt7(5)
3348  IF ( taubbl(isea,1) .EQ. undef ) THEN
3349  taubbl(isea,1) = taubblaux(1) / real( sumgrd )
3350  taubbl(isea,2) = taubblaux(2) / real( sumgrd )
3351  ELSE
3352  taubbl(isea,1) = taubbl(isea,1) + &
3353  taubblaux(1) / real( sumgrd )
3354  taubbl(isea,2) = taubbl(isea,2) + &
3355  taubblaux(2) / real( sumgrd )
3356  END IF
3357  END IF
3358  !
3359  ! Group 8 variables
3360  !
3361  IF ( mssxaux .NE. undef ) THEN
3362  IF ( mssx(isea) .EQ. undef ) mssx(isea) = 0.
3363  mssx(isea) = mssx(isea) + &
3364  mssxaux / real( sumwt8(1)*sumgrd )
3365  END IF
3366  !
3367  IF ( mssyaux .NE. undef ) THEN
3368  IF ( mssy(isea) .EQ. undef ) mssy(isea) = 0.
3369  mssy(isea) = mssy(isea) + &
3370  mssyaux / real( sumwt8(1)*sumgrd )
3371  END IF
3372  !
3373  IF ( mscxaux .NE. undef ) THEN
3374  IF ( mscx(isea) .EQ. undef ) mscx(isea) = 0.
3375  mscx(isea) = mscx(isea) + &
3376  mscxaux / real( sumwt8(2)*sumgrd )
3377  END IF
3378  !
3379  IF ( mscyaux .NE. undef ) THEN
3380  IF ( mscy(isea) .EQ. undef ) mscy(isea) = 0.
3381  mscy(isea) = mscy(isea) + &
3382  mscyaux / real( sumwt8(2)*sumgrd )
3383  END IF
3384  !
3385  IF ( mssdaux1 .NE. undef .AND. mssdaux2 .NE. undef ) THEN
3386  mssdaux1 = mssdaux1 / real( sumwt8(3)*sumgrd )
3387  mssdaux2 = mssdaux2 / real( sumwt8(3)*sumgrd )
3388  IF ( mssd(isea) .NE. undef ) THEN
3389  mssdaux1 = mssdaux1 + cos( mssd(isea) )
3390  mssdaux2 = mssdaux2 + sin( mssd(isea) )
3391  END IF
3392  mssd(isea) = atan2( mssdaux2, mssdaux1 )
3393  END IF
3394  !
3395  IF ( mscdaux1 .NE. undef .AND. mscdaux2 .NE. undef ) THEN
3396  mscdaux1 = mscdaux1 / real( sumwt8(4)*sumgrd )
3397  mscdaux2 = mscdaux2 / real( sumwt8(4)*sumgrd )
3398  IF ( mscd(isea) .NE. undef ) THEN
3399  mscdaux1 = mscdaux1 + cos( mscd(isea) )
3400  mscdaux2 = mscdaux2 + sin( mscd(isea) )
3401  END IF
3402  mscd(isea) = atan2( mscdaux2, mscdaux1 )
3403  END IF
3404  !
3405  IF ( qpaux .NE. undef ) THEN
3406  IF ( qp(isea) .EQ. undef ) qp(isea) = 0.
3407  qp(isea) = qp(isea) + qpaux / real( sumwt8(5)*sumgrd )
3408  END IF
3409  !
3410  ! Restart varaibles
3411  !
3412  IF (.NOT.outorrestflag) THEN
3413  DO ik = 1,nspec
3414  IF ( vaaux(ik) .NE. undef ) THEN
3415  vaaux(ik) = vaaux(ik) / sumres(ik)
3416  IF ( va(ik,isea) .EQ. undef ) THEN
3417  va(ik,isea) = vaaux(ik) / real( sumgrd )
3418  ELSE
3419  va(ik,isea) = va(ik,isea) + vaaux(ik) / real( sumgrd )
3420  END IF
3421  END IF
3422  END DO
3423  ENDIF
3424  !
3425  END IF !/ ( USEGRID(IG) )
3426  !
3427  ! End of Second loop
3428  END DO !/ IG = 1, GR_INTS
3429  !
3430  ! Convert select variables back to polar notation. This is done because just
3431  ! prior to writing to file the w3iogo routine converts these variables
3432  ! from polar to cartesian coordinates
3433  !
3434  IF ( ua(isea) .NE. undef ) THEN
3435  var1 = ua(isea)
3436  var2 = ud(isea)
3437  ua(isea) = sqrt( var1**2 + var2**2 )
3438  ud(isea) = atan2( var2, var1 )
3439  END IF
3440  !
3441  IF ( ust(isea) .NE. undef ) THEN
3442  var1 = ust(isea)
3443  var2 = ustdir(isea)
3444  ust(isea) = sqrt( var1**2 + var2**2 )
3445  ustdir(isea) = atan2( var2, var1 )
3446  END IF
3447  !
3448  IF ( aba(isea) .NE. undef ) THEN
3449  var1 = aba(isea)
3450  var2 = abd(isea)
3451  aba(isea) = sqrt( var1**2 + var2**2 )
3452  abd(isea) = atan2( var2, var1 )
3453  END IF
3454  !
3455  IF ( uba(isea) .NE. undef ) THEN
3456  var1 = uba(isea)
3457  var2 = ubd(isea)
3458  uba(isea) = sqrt( var1**2 + var2**2 )
3459  ubd(isea) = atan2( var2, var1 )
3460  END IF
3461  !
3462  END IF
3463  !
3464  !/ End of main loop through output points
3465  END DO !/ ISEA = 1, NSEA
3466 
3467  ! Check to make sure VA is positive for restart file
3468  ! and do nearest neighbor for points w/out interpolation
3469  !
3470  IF (.NOT.(outorrestflag)) THEN
3471  ALLOCATE( mapstatmp(0:(ny+1),0:(nx+1)))
3472  ALLOCATE( noint2(inoint) )
3473  mapstatmp=0
3474  mapstatmp(1:ny,1:nx)=mapsta
3475 
3476  iloops=0
3477  DO WHILE ( iloops < 6 .AND. inoint > 0 )
3478  inoint2=0
3479  DO jsea=1,inoint
3480 
3481  isea=noint(jsea)
3482  !look in the box surrounding the point for a
3483  !neighboring point
3484  ix = mapsf(isea,1)
3485  iy = mapsf(isea,2)
3486 
3487  IF ( mapstatmp(iy+1,ix) .EQ. 1 ) THEN
3488  va(:,isea)=va(:,mapfs(iy+1,ix))
3489  mapstatmp(iy,ix)=1
3490  ELSEIF ( mapstatmp(iy,ix+1) .EQ. 1 ) THEN
3491  va(:,isea)=va(:,mapfs(iy+1,ix))
3492  mapstatmp(iy,ix)=1
3493  ELSEIF ( mapstatmp(iy-1,ix) .EQ. 1 ) THEN
3494  va(:,isea)=va(:,mapfs(iy-1,ix))
3495  mapstatmp(iy,ix)=1
3496  ELSEIF ( mapstatmp(iy,ix-1) .EQ. 1 ) THEN
3497  va(:,isea)=va(:,mapfs(iy,ix-1))
3498  mapstatmp(iy,ix)=1
3499  ELSEIF ( mapstatmp(iy+1,ix+1) .EQ. 1 ) THEN
3500  va(:,isea)=va(:,mapfs(iy+1,ix+1))
3501  mapstatmp(iy,ix)=1
3502  ELSEIF ( mapstatmp(iy-1,ix+1) .EQ. 1 ) THEN
3503  va(:,isea)=va(:,mapfs(iy+1,ix-1))
3504  mapstatmp(iy,ix)=1
3505  ELSEIF ( mapstatmp(iy-1,ix-1) .EQ. 1 ) THEN
3506  va(:,isea)=va(:,mapfs(iy-1,ix-1))
3507  mapstatmp(iy,ix)=1
3508  ELSEIF ( mapstatmp(iy+1,ix-1) .EQ. 1 ) THEN
3509  va(:,isea)=va(:,mapfs(iy+1,ix-1))
3510  mapstatmp(iy,ix)=1
3511  ELSE
3512  !The immediate box surrounding the point
3513  !has no active sea point
3514  inoint2=inoint2+1
3515  noint2(inoint2)=isea
3516  ENDIF
3517  END DO
3518  inoint=inoint2
3519  noint(1:inoint2)=noint2(1:inoint2)
3520  iloops=iloops+1
3521  END DO
3522 
3523  DEALLOCATE (noint,noint2,mapstatmp)
3524 
3525  DO isea = 1, nsea
3526  DO ik = 1,nspec
3527  IF ( va(ik,isea) < 0. ) THEN
3528  va(ik,isea) = 0.
3529  END IF
3530  END DO
3531  END DO
3532 
3533  mapst2=mapst2_ng
3534  mapsta=mapsta_ng
3535 
3536  END IF !IF (.NOT.(OUTorRESTflag))
3537 
3538  !
3539  !------------------------------------------------------------------------------
3540  ! 3. Write out interpolated data to target output file
3541  !
3542  IF (outorrestflag) THEN
3543  CALL w3iogo('WRITE',fidout(ng),iotst,ng)
3544  ELSE
3545  ! A potential future improvement could be to also interpolate other fields
3546  ! in addition to VA for the restart interpolation. For now these are
3547  ! set to zero.
3548  tice(1)=-1
3549  tice(2)=0
3550  tlev(1)=-1
3551  tlev(2)=0
3552  wlv=0.
3553  ice=0.
3554  ust=0.
3555  ustdir=0.
3556  asf=0.
3557  fpis=0.
3558 #ifdef W3_WRST
3559  wxn=0.
3560  wyn=0.
3561 #endif
3562  CALL w3iors ( 'HOT', 55, xxx, ng)
3563  END IF
3564  !
3565  RETURN
3566  !
3567  ! Error escape locations
3568  !
3569  !/
3570  !/ End of W3EXGI ------------------------------------------------------------/
3571  !/
3572  END SUBROUTINE w3exgi
3573  !/
3574  !/ End of W3GRID_INTERP -----------------------------------------------------/
3575  !/
3576 END PROGRAM w3grid_interp
w3adatmd::pt2
real, dimension(:,:), pointer pt2
Definition: w3adatmd.F90:597
w3adatmd::psw
real, dimension(:,:), pointer psw
Definition: w3adatmd.F90:597
w3gdatmd::nk
integer, pointer nk
Definition: w3gdatmd.F90:1230
w3adatmd::hcmaxe
real, dimension(:), pointer hcmaxe
Definition: w3adatmd.F90:587
gr_wt
Definition: ww3_gint.F90:137
w3servmd::nextln
subroutine nextln(CHCKC, NDSI, NDSE)
Definition: w3servmd.F90:222
w3adatmd::phice
real, dimension(:), pointer phice
Definition: w3adatmd.F90:607
w3adatmd::th2m
real, dimension(:,:), pointer th2m
Definition: w3adatmd.F90:594
w3wdatmd::iceh
real, dimension(:), pointer iceh
Definition: w3wdatmd.F90:183
w3adatmd::charn
real, dimension(:), pointer charn
Definition: w3adatmd.F90:603
w3wdatmd::fpis
real, dimension(:), pointer fpis
Definition: w3wdatmd.F90:183
w3triamd
Reads triangle and unstructured grid information.
Definition: w3triamd.F90:21
w3adatmd::as
real, dimension(:), pointer as
Definition: w3adatmd.F90:584
w3adatmd
Define data structures to set up wave model auxiliary data for several models simultaneously.
Definition: w3adatmd.F90:26
w3adatmd::hcmaxd
real, dimension(:), pointer hcmaxd
Definition: w3adatmd.F90:587
w3gdatmd::nspec
integer, pointer nspec
Definition: w3gdatmd.F90:1230
w3adatmd::sth1m
real, dimension(:,:), pointer sth1m
Definition: w3adatmd.F90:594
w3adatmd::ussy
real, dimension(:), pointer ussy
Definition: w3adatmd.F90:607
w3adatmd::pep
real, dimension(:,:), pointer pep
Definition: w3adatmd.F90:597
w3adatmd::mscd
real, dimension(:), pointer mscd
Definition: w3adatmd.F90:617
w3adatmd::abd
real, dimension(:), pointer abd
Definition: w3adatmd.F90:614
w3wdatmd
Define data structures to set up wave model dynamic data for several models simultaneously.
Definition: w3wdatmd.F90:18
w3adatmd::stmaxe
real, dimension(:), pointer stmaxe
Definition: w3adatmd.F90:587
w3adatmd::tauice
real, dimension(:,:), pointer tauice
Definition: w3adatmd.F90:607
w3adatmd::t02
real, dimension(:), pointer t02
Definition: w3adatmd.F90:587
w3adatmd::us3d
real, dimension(:,:), pointer us3d
Definition: w3adatmd.F90:612
w3adatmd::wadats
type(wadat), dimension(:), allocatable, target wadats
Definition: w3adatmd.F90:571
w3adatmd::tusx
real, dimension(:), pointer tusx
Definition: w3adatmd.F90:607
w3adatmd::tusy
real, dimension(:), pointer tusy
Definition: w3adatmd.F90:607
w3adatmd::ptp
real, dimension(:,:), pointer ptp
Definition: w3adatmd.F90:597
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
w3gsrumd
Definition: w3gsrumd.F90:17
w3wdatmd::icef
real, dimension(:), pointer icef
Definition: w3wdatmd.F90:183
w3grid_interp
program w3grid_interp
Re-gridding binary output (out_grd. * files) to another grid.
Definition: ww3_gint.F90:23
w3adatmd::th1m
real, dimension(:,:), pointer th1m
Definition: w3adatmd.F90:594
w3adatmd::t01
real, dimension(:), pointer t01
Definition: w3adatmd.F90:587
w3adatmd::cge
real, dimension(:), pointer cge
Definition: w3adatmd.F90:603
w3wdatmd::wlv
real, dimension(:), pointer wlv
Definition: w3wdatmd.F90:183
w3odatmd::ngrpp
integer, parameter ngrpp
Definition: w3odatmd.F90:324
w3adatmd::pdir
real, dimension(:,:), pointer pdir
Definition: w3adatmd.F90:597
w3wdatmd::wdatas
type(wdata), dimension(:), allocatable, target wdatas
Definition: w3wdatmd.F90:168
w3wdatmd::time
integer, dimension(:), pointer time
Definition: w3wdatmd.F90:172
w3adatmd::thp0
real, dimension(:), pointer thp0
Definition: w3adatmd.F90:587
w3adatmd::tauocy
real, dimension(:), pointer tauocy
Definition: w3adatmd.F90:607
w3adatmd::phs
real, dimension(:,:), pointer phs
Definition: w3adatmd.F90:597
w3adatmd::hs
real, dimension(:), pointer hs
Definition: w3adatmd.F90:587
w3adatmd::uba
real, dimension(:), pointer uba
Definition: w3adatmd.F90:614
w3odatmd::fnmpre
character(len=80) fnmpre
Definition: w3odatmd.F90:330
w3adatmd::pqp
real, dimension(:,:), pointer pqp
Definition: w3adatmd.F90:597
w3wdatmd::va
real, dimension(:,:), pointer va
Definition: w3wdatmd.F90:183
w3adatmd::tauwix
real, dimension(:), pointer tauwix
Definition: w3adatmd.F90:603
w3adatmd::w3dima
subroutine w3dima(IMOD, NDSE, NDST, D_ONLY)
Initialize an individual data grid at the proper dimensions.
Definition: w3adatmd.F90:846
w3adatmd::pthp0
real, dimension(:,:), pointer pthp0
Definition: w3adatmd.F90:597
w3wdatmd::tlev
integer, dimension(:), pointer tlev
Definition: w3wdatmd.F90:172
w3adatmd::tauwiy
real, dimension(:), pointer tauwiy
Definition: w3adatmd.F90:603
w3adatmd::taubbl
real, dimension(:,:), pointer taubbl
Definition: w3adatmd.F90:614
w3adatmd::ef
real, dimension(:,:), pointer ef
Definition: w3adatmd.F90:594
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
w3wdatmd::w3ndat
subroutine w3ndat(NDSE, NDST)
Set up the number of grids to be used.
Definition: w3wdatmd.F90:210
w3adatmd::phiaw
real, dimension(:), pointer phiaw
Definition: w3adatmd.F90:603
w3adatmd::pws
real, dimension(:,:), pointer pws
Definition: w3adatmd.F90:597
w3adatmd::plp
real, dimension(:,:), pointer plp
Definition: w3adatmd.F90:597
w3adatmd::phibbl
real, dimension(:), pointer phibbl
Definition: w3adatmd.F90:614
w3adatmd::psi
real, dimension(:,:), pointer psi
Definition: w3adatmd.F90:597
w3adatmd::sth2m
real, dimension(:,:), pointer sth2m
Definition: w3adatmd.F90:594
w3adatmd::tpms
real, dimension(:), pointer tpms
Definition: w3adatmd.F90:607
w3servmd
Definition: w3servmd.F90:3
w3odatmd::flogrd
logical, dimension(:,:), pointer flogrd
Definition: w3odatmd.F90:478
w3adatmd::ths
real, dimension(:), pointer ths
Definition: w3adatmd.F90:587
w3adatmd::bedforms
real, dimension(:,:), pointer bedforms
Definition: w3adatmd.F90:614
w3adatmd::ud
real, dimension(:), pointer ud
Definition: w3adatmd.F90:584
w3adatmd::hmaxd
real, dimension(:), pointer hmaxd
Definition: w3adatmd.F90:587
w3adatmd::pwst
real, dimension(:), pointer pwst
Definition: w3adatmd.F90:597
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
w3adatmd::sxy
real, dimension(:), pointer sxy
Definition: w3adatmd.F90:607
w3adatmd::tauwnx
real, dimension(:), pointer tauwnx
Definition: w3adatmd.F90:603
w3odatmd
Definition: w3odatmd.F90:3
w3adatmd::wbt
real, dimension(:), pointer wbt
Definition: w3adatmd.F90:587
w3adatmd::bhd
real, dimension(:), pointer bhd
Definition: w3adatmd.F90:607
w3adatmd::w3naux
subroutine w3naux(NDSE, NDST)
Set up the number of grids to be used.
Definition: w3adatmd.F90:704
w3adatmd::cy
real, dimension(:), pointer cy
Definition: w3adatmd.F90:584
w3adatmd::pnr
real, dimension(:), pointer pnr
Definition: w3adatmd.F90:597
w3adatmd::taua
real, dimension(:), pointer taua
Definition: w3adatmd.F90:584
w3adatmd::hmaxe
real, dimension(:), pointer hmaxe
Definition: w3adatmd.F90:587
w3adatmd::pt1
real, dimension(:,:), pointer pt1
Definition: w3adatmd.F90:597
w3adatmd::wlm
real, dimension(:), pointer wlm
Definition: w3adatmd.F90:587
w3odatmd::naproc
integer, pointer naproc
Definition: w3odatmd.F90:457
w3adatmd::wnmean
real, dimension(:), pointer wnmean
Definition: w3adatmd.F90:587
w3iogomd::w3iogo
subroutine w3iogo(INXOUT, NDSOG, IOTST, IMOD ifdef W3_ASCII
Read/write gridded output.
Definition: w3iogomd.F90:2396
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
w3adatmd::wn
real, dimension(:,:), pointer wn
Definition: w3adatmd.F90:575
w3wdatmd::w3dimw
subroutine w3dimw(IMOD, NDSE, NDST, F_ONLY)
Initialize an individual data grid at the proper dimensions.
Definition: w3wdatmd.F90:343
w3adatmd::qp
real, dimension(:), pointer qp
Definition: w3adatmd.F90:587
w3iogomd
Gridded output of mean wave parameters.
Definition: w3iogomd.F90:15
w3adatmd::stmaxd
real, dimension(:), pointer stmaxd
Definition: w3adatmd.F90:587
w3servmd::strace
subroutine strace(IENT, SNAME)
Definition: w3servmd.F90:148
w3idatmd
Define data structures to set up wave model input data for several models simultaneously.
Definition: w3idatmd.F90:16
w3wdatmd::ice
real, dimension(:), pointer ice
Definition: w3wdatmd.F90:183
w3arrymd
Definition: w3arrymd.F90:3
w3adatmd::whitecap
real, dimension(:,:), pointer whitecap
Definition: w3adatmd.F90:603
w3adatmd::tauox
real, dimension(:), pointer tauox
Definition: w3adatmd.F90:607
w3adatmd::p2sms
real, dimension(:,:), pointer p2sms
Definition: w3adatmd.F90:612
w3odatmd::idout
character(len=20), dimension(nogrp, ngrpp) idout
Definition: w3odatmd.F90:329
w3adatmd::prms
real, dimension(:), pointer prms
Definition: w3adatmd.F90:607
w3exgi
subroutine w3exgi(NGRD, NSEA, NOSWLL_MIN, INTMETHOD, OUTorRESTflag, MAPSTA_NG, MAPST2_NG)
Perform actual output of interpolated data.
Definition: ww3_gint.F90:1020
gr_int
Definition: ww3_gint.F90:144
w3adatmd::mssy
real, dimension(:), pointer mssy
Definition: w3adatmd.F90:617
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
w3adatmd::ua
real, dimension(:), pointer ua
Definition: w3adatmd.F90:584
w3adatmd::tauoy
real, dimension(:), pointer tauoy
Definition: w3adatmd.F90:607
w3odatmd::nogrp
integer, parameter nogrp
Definition: w3odatmd.F90:323
w3adatmd::fp0
real, dimension(:), pointer fp0
Definition: w3adatmd.F90:587
w3gdatmd
Definition: w3gdatmd.F90:16
w3adatmd::hsig
real, dimension(:), pointer hsig
Definition: w3adatmd.F90:587
w3adatmd::ussx
real, dimension(:), pointer ussx
Definition: w3adatmd.F90:607
w3adatmd::mssx
real, dimension(:), pointer mssx
Definition: w3adatmd.F90:617
constants::file_endian
character(*), parameter file_endian
FILE_ENDIAN Filled by preprocessor with 'big_endian', 'little_endian', or 'native'.
Definition: constants.F90:86
w3adatmd::tauadir
real, dimension(:), pointer tauadir
Definition: w3adatmd.F90:584
w3servmd::extcde
subroutine extcde(IEXIT, UNIT, MSG, FILE, LINE, COMM)
Definition: w3servmd.F90:736
w3odatmd::w3nout
subroutine w3nout(NDSERR, NDSTST)
Definition: w3odatmd.F90:561
w3odatmd::outpts
type(output), dimension(:), allocatable, target outpts
Definition: w3odatmd.F90:452
w3adatmd::mscy
real, dimension(:), pointer mscy
Definition: w3adatmd.F90:617
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
w3adatmd::ptm1
real, dimension(:,:), pointer ptm1
Definition: w3adatmd.F90:597
w3odatmd::noswll
integer, pointer noswll
Definition: w3odatmd.F90:460
w3adatmd::thm
real, dimension(:), pointer thm
Definition: w3adatmd.F90:587
w3adatmd::mscx
real, dimension(:), pointer mscx
Definition: w3adatmd.F90:617
w3adatmd::ppe
real, dimension(:,:), pointer ppe
Definition: w3adatmd.F90:597
w3adatmd::cx
real, dimension(:), pointer cx
Definition: w3adatmd.F90:584
w3adatmd::pgw
real, dimension(:,:), pointer pgw
Definition: w3adatmd.F90:597
w3timemd
Definition: w3timemd.F90:3
constants::undef
real undef
UNDEF Value for undefined variable in output.
Definition: constants.F90:84
w3adatmd::ussp
real, dimension(:,:), pointer ussp
Definition: w3adatmd.F90:612
w3adatmd::mssd
real, dimension(:), pointer mssd
Definition: w3adatmd.F90:617
w3gdatmd::e3df
integer, dimension(:,:), pointer e3df
Definition: w3gdatmd.F90:1098
w3adatmd::t0m1
real, dimension(:), pointer t0m1
Definition: w3adatmd.F90:587
w3arrymd::prtblk
subroutine prtblk(NDS, NX, NY, MX, F, MAP, MAP0, FSC, IX1, IX2, IX3, IY1, IY2, IY3, PRVAR, PRUNIT)
Definition: w3arrymd.F90:1112
w3iorsmd
Read/write restart files.
Definition: w3iorsmd.F90:14
w3wdatmd::tice
integer, dimension(:), pointer tice
Definition: w3wdatmd.F90:172
w3adatmd::tauocx
real, dimension(:), pointer tauocx
Definition: w3adatmd.F90:607
w3adatmd::aba
real, dimension(:), pointer aba
Definition: w3adatmd.F90:614
w3adatmd::syy
real, dimension(:), pointer syy
Definition: w3adatmd.F90:607
w3adatmd::ubd
real, dimension(:), pointer ubd
Definition: w3adatmd.F90:614
w3adatmd::sxx
real, dimension(:), pointer sxx
Definition: w3adatmd.F90:607
w3wdatmd::asf
real, dimension(:), pointer asf
Definition: w3wdatmd.F90:183