WAVEWATCH III  beta 0.0.1
w3uostmd.F90
Go to the documentation of this file.
1 
7 
8 #include "w3macros.h"
9 !/ ------------------------------------------------------------------- /
10 
22 MODULE w3uostmd
23  !/ +-----------------------------------+
24  !/ | WAVEWATCH III NOAA/NCEP |
25  !/ | Lorenzo Mentaschi |
26  !/ | FORTRAN 90 |
27  !/ | Last update : 08-Oct-2018 |
28  !/ +-----------------------------------+
29  !/
30  !/ Aug-2018 : Origination. ( version 6.07 )
31  !/ 18-Sep-2019 : Added UNIT_AB and changed unit ( version 7.06 )
32  !/ number to 110 (C. Bunney, UKMO)
33  !/
34  !/ Copyright 2010 National Weather Service (NWS),
35  !/ National Oceanic and Atmospheric Administration. All rights
36  !/ reserved. WAVEWATCH III is a trademark of the NWS.
37  !/ No unauthorized use without permission.
38  !/
39  ! 1. Purpose : Parmeterization of the unresoled obstacles
40  !
41  ! 2. Subroutines and functions :
42  !
43  ! Name Type Scope Description
44  ! ----------------------------------------------------------------
45  ! UOST_INITGRID Subr. Public allocates UOST variables on each grid,
46  ! and loads the matrices of alpha and beta coefficient
47  ! UOST_SETGRID Subr. Public sets the actual computation grid in the source term
48  ! UOST_SRCTRMCOMPUTE Subr. Public computes the source term for a given input spectrum
49  ! ----------------------------------------------------------------
50  !
51  ! 3. Switches :
52  !
53  ! 4. Source code :
54  !/
55  !/ ------------------------------------------------------------------- /
56  !/
57 
58  USE w3gdatmd, ONLY: grid, sgrd, grids, sgrds
59  USE w3odatmd, ONLY: ndso, ndse
60  USE w3servmd, ONLY: extcde
61 #ifdef W3_S
62  USE w3servmd, ONLY: strace
63 #endif
64 
65  IMPLICIT NONE
66 
67  PUBLIC :: uost_initgrid
68  PUBLIC :: uost_setgrid
69  PUBLIC :: uost_srctrmcompute
70 
71 
72  PRIVATE
73 
74 
75  TYPE uost_sourceterm
76  REAL, ALLOCATABLE :: COSTH(:), SINTH(:)
77  REAL :: GAMMAUP = 10
78  REAL :: GAMMADOWN = 20
79  ! griddata is a pointer to the grid actually computed
80  TYPE(GRID), POINTER :: GRD
81  TYPE(SGRD), POINTER :: SGD
82  CONTAINS
83  !PROCEDURE, PASS, PRIVATE :: COMPUTE_PSI => UOST_SOURCETERM_COMPUTE_PSI
84 
85  !compute_ld: estimates the local dissipation (private method)
86  PROCEDURE, PASS, PRIVATE :: COMPUTE_LD => uost_sourceterm_compute_ld
87  !compute_se: estimates the shadow effect (private method)
88  PROCEDURE, PASS, PRIVATE :: COMPUTE_SE => uost_sourceterm_compute_se
89  !compute: estimates the whole dissipation
90  PROCEDURE, PASS :: COMPUTE => uost_sourceterm_compute
91  !setgrid: sets grd pointer and computes some cached structures
92  PROCEDURE, PASS :: SETGRID => uost_sourceterm_setgrid
93  END TYPE uost_sourceterm
94 
95  ! srctrm: global singleton source term
96  CLASS(UOST_SOURCETERM), ALLOCATABLE :: SRCTRM
97 
98  INTEGER, PARAMETER :: UNIT_AB = 110 ! Unit number for LOAD_ALPHABETA
99 
100 
101 CONTAINS
102 
103 
104  !/ ------------------------------------------------------------------- /
105 
122  SUBROUTINE uost_initgrid(IGRID, FILELOCAL, FILESHADOW, LOCALFACTOR, SHADOWFACTOR)
123  !/
124  !/ +-----------------------------------+
125  !/ | WAVEWATCH III NOAA/NCEP |
126  !/ | Lorenzo Mentaschi |
127  !/ | FORTRAN 90 |
128  !/ | Last update : 01-Oct-2018 |
129  !/ +-----------------------------------+
130  !/
131  !/ Aug-2018 : Origination. ( version 6.07 )
132  !/
133  ! 1. Purpose : allocate the UOST variables for a given grid, and load
134  ! them from file
135  ! 2. Parameters :
136  !
137  ! Parameter list
138  ! ----------------------------------------------------------------
139  ! IGRID, integer: id of the grid being initialized
140  ! FILELOCAL, string: file from where the alpha/beta coefficient
141  ! for the local dissipation are loaded
142  ! FILESHADOW, string: file from where the alpha/beta coefficient
143  ! for the shadow effect are loaded
144  ! LOCALFACTOR, double: adjustment parameter for the local
145  ! dissipation alpha and beta
146  ! SHADOWFACTOR, double: adjustment parameter for the shadow
147  ! dissipation alpha and beta
148  ! ----------------------------------------------------------------
149  !
150  ! 3. Called by :
151  !
152  ! Name Type Module Description
153  ! ----------------------------------------------------------------
154  ! W3IOGR Subr. W3IOGRMD Initialization of grid objects
155  ! ----------------------------------------------------------------
156  !
157  ! 4. Source code :
158  !
159  !/ ------------------------------------------------------------------- /
160  IMPLICIT NONE
161 
162  INTEGER, INTENT(IN) :: igrid
163  CHARACTER(LEN=*), INTENT(IN) :: filelocal, fileshadow
164  REAL, INTENT(IN) :: localfactor, shadowfactor
165  TYPE(grid), POINTER :: grd
166  TYPE(sgrd), POINTER :: sgd
167  REAL :: cgmax, minsize
168 #ifdef W3_S
169  INTEGER, SAVE :: ient = 0
170 #endif
171 
172 #ifdef W3_S
173  CALL strace (ient, 'UOST_INITGRID')
174 #endif
175 
176  IF ( (igrid .LE. 0) .OR. (.NOT. ALLOCATED(grids)) ) THEN
177  RETURN
178  ENDIF
179 
180  grd => grids(igrid)
181  sgd => sgrds(igrid)
182  grd%UOSTFILELOCAL = filelocal
183  grd%UOSTFILESHADOW = fileshadow
184  grd%UOSTLOCALFACTOR = localfactor
185  grd%UOSTSHADOWFACTOR = shadowfactor
186 
187  ALLOCATE( grd%UOST_LCL_OBSTRUCTED(grd%NX, grd%NY) )
188  grd%UOST_LCL_OBSTRUCTED = .false.
189  ALLOCATE( grd%UOST_SHD_OBSTRUCTED(grd%NX, grd%NY) )
190  grd%UOST_SHD_OBSTRUCTED = .false.
191  ALLOCATE( grd%UOSTCELLSIZE(grd%NX, grd%NY, sgd%NTH) )
192  grd%UOSTCELLSIZE = 0
193  ALLOCATE( grd%UOSTLOCALALPHA(grd%NX, grd%NY, sgd%NK, sgd%NTH) )
194  grd%UOSTLOCALALPHA = 100
195  ALLOCATE( grd%UOSTLOCALBETA(grd%NX, grd%NY, sgd%NK, sgd%NTH) )
196  grd%UOSTLOCALBETA = 100
197  ALLOCATE( grd%UOSTSHADOWALPHA(grd%NX, grd%NY, sgd%NK, sgd%NTH) )
198  grd%UOSTSHADOWALPHA = 100
199  ALLOCATE( grd%UOSTSHADOWBETA(grd%NX, grd%NY, sgd%NK, sgd%NTH) )
200  grd%UOSTSHADOWBETA = 100
201 
202 
203  IF ( (igrid .GT. 0) .AND. ( ALLOCATED(srctrm)) ) THEN
204  ! loading local/shadow alpha/beta
205  CALL load_alphabeta(grd, sgd, unit_ab)
206 
207  ! warning the user that for cells too small UOST may be inaccurate
208  cgmax = 20 ! simply taking a high value for the max group velocity to give an indication of this threshold
209  minsize = cgmax*grd%DTMAX/1000
210  WRITE(ndso,*)'*** WAVEWATCH-III WARNING IN W3UOST/UOST_INITGRID'
211  WRITE(ndso,*)'UOST: grid ',trim(grd%GNAME),':'
212  WRITE(ndso,*)' global time step == ', grd%DTMAX, ' s'
213  WRITE(ndso,*)' FOR CELLS SMALLER THAN ABOUT ', minsize, &
214  ' KM UOST MAY UNDERESTIMATE THE DISSIPATION'
215  WRITE(ndso,*)
216  ENDIF
217  END SUBROUTINE uost_initgrid
218 
219 
220 
221  !/ ------------------------------------------------------------------- /
222 
231  SUBROUTINE uost_setgrid(IGRID)
232  !/
233  !/ +-----------------------------------+
234  !/ | WAVEWATCH III NOAA/NCEP |
235  !/ | Lorenzo Mentaschi |
236  !/ | FORTRAN 90 |
237  !/ | Last update : 01-Oct-2018 |
238  !/ +-----------------------------------+
239  !/
240  !/ Aug-2018 : Origination. ( version 6.07 )
241  !/
242  ! 1. Purpose : sets the current grid in the sourceterm object
243  ! 2. Parameters :
244  !
245  ! Parameter list
246  ! ----------------------------------------------------------------
247  ! IGRID, integer: id of the actual grid
248  ! ----------------------------------------------------------------
249  !
250  ! 3. Called by :
251  !
252  ! Name Type Module Description
253  ! ----------------------------------------------------------------
254  ! W3INIT Subr. W3INITMD Initialization of grid objects
255  ! W3WAVE Subr. W3WAVEMD Initialization of grid objects
256  ! before computation
257  ! ----------------------------------------------------------------
258  !
259  ! 4. Source code :
260  !
261  !/ ------------------------------------------------------------------- /
262  IMPLICIT NONE
263 
264  INTEGER, INTENT(IN) :: igrid
265 #ifdef W3_S
266  INTEGER, SAVE :: ient = 0
267 #endif
268 
269 #ifdef W3_S
270  CALL strace (ient, 'UOST_SETGRID')
271 #endif
272 
273  IF ( .NOT. ALLOCATED(srctrm) ) THEN
274  ALLOCATE(srctrm)
275  ENDIF
276 
277  CALL srctrm%SETGRID(grids(igrid), sgrds(igrid))
278  END SUBROUTINE uost_setgrid
279  !/ ------------------------------------------------------------------- /
280 
281  !/ ------------------------------------------------------------------- /
298  SUBROUTINE uost_srctrmcompute(IX, IY, SPEC, CG, DT, U10ABS, U10DIR, S, D)
299  !/
300  !/ +-----------------------------------+
301  !/ | WAVEWATCH III NOAA/NCEP |
302  !/ | Lorenzo Mentaschi |
303  !/ | FORTRAN 90 |
304  !/ | Last update : 01-Oct-2018 |
305  !/ +-----------------------------------+
306  !/
307  !/ Aug-2018 : Origination. ( version 6.07 )
308  !/
309  ! 1. Purpose : estimates the UOST source term for a give spectrum
310  ! 2. Parameters :
311  !
312  ! Parameter list
313  ! ----------------------------------------------------------------
314  ! IGRID, integer: id of the actual grid
315  ! ----------------------------------------------------------------
316  !
317  ! 3. Called by :
318  !
319  ! Name Type Module Description
320  ! ----------------------------------------------------------------
321  ! W3SRCE Subr. W3SRCEMD Computation of the source terms
322  ! ----------------------------------------------------------------
323  !
324  ! 4. Source code :
325  !
326  !/ ------------------------------------------------------------------- /
327  IMPLICIT NONE
328 
329  INTEGER, INTENT(IN) :: ix, iy
330  REAL, INTENT(IN) :: dt
331  REAL, INTENT(IN) :: spec(srctrm%sgd%nspec), cg(srctrm%sgd%nk)
332  REAL, INTENT(IN) :: u10abs, u10dir
333  REAL, INTENT(OUT) :: s(srctrm%sgd%nspec), d(srctrm%sgd%nspec)
334 #ifdef W3_S
335  INTEGER, SAVE :: ient = 0
336 #endif
337 
338 #ifdef W3_S
339  CALL strace (ient, 'UOST_SRCTRMCOMPUTE')
340 #endif
341 
342  CALL srctrm%COMPUTE(ix, iy, spec, cg, dt, u10abs, u10dir, s, d)
343  END SUBROUTINE uost_srctrmcompute
344 
345  !/ ------------------------------------------------------------------- /
346 
357  SUBROUTINE load_alphabeta(GRD, SGD, FILEUNIT)
358  !/
359  !/ +-----------------------------------+
360  !/ | WAVEWATCH III NOAA/NCEP |
361  !/ | Lorenzo Mentaschi |
362  !/ | FORTRAN 90 |
363  !/ | Last update : 01-Oct-2018 |
364  !/ +-----------------------------------+
365  !/
366  !/ Aug-2018 : Origination. ( version 6.07 )
367  !/
368  ! 1. Purpose : loads local and shadow alpha and beta from files
369  ! 2. Parameters :
370  !
371  ! Parameter list
372  ! ----------------------------------------------------------------
373  ! GRD, GRID type: object representing the spatial grid to
374  ! be loaded
375  ! SGD, SGRD type: object representing the current spectral grid
376  ! FILEUNIT, Integer: unit id of the input files
377  ! ----------------------------------------------------------------
378  !
379  ! 3. Called by :
380  !
381  ! Name Type Module Description
382  ! ----------------------------------------------------------------
383  ! UOST_INITGRID Subr. W3UOSTMD Initialization of the UOST grid
384  ! ----------------------------------------------------------------
385  !
386  ! 4. Source code :
387  !
388  !/ ------------------------------------------------------------------- /
389  IMPLICIT NONE
390 
391  TYPE(grid), INTENT(INOUT) :: grd
392  TYPE(sgrd), INTENT(IN) :: sgd
393  INTEGER, INTENT(IN) :: fileunit
394  CHARACTER(256) :: filename
395  LOGICAL :: fileexists
396  INTEGER :: jg, j, l, i, ix, iy
397 #ifdef W3_S
398  INTEGER, SAVE :: ient = 0
399 #endif
400 
401 #ifdef W3_S
402  CALL strace (ient, 'LOAD_ALPHABETA')
403 #endif
404 
405 
406  ! LOADING LOCAL ALPHA/BETA
407  filename = grd%UOSTFILELOCAL
408  INQUIRE(file=filename, exist=fileexists)
409 
410  j = len_trim(filename)
411  IF (.NOT. fileexists) THEN
412  WRITE(ndse,*)'*** WAVEWATCH III ERROR IN W3UOST: '// &
413  'FILE '//filename(:j)//' NOT FOUND. QUITTING'
414  CALL extcde (9999)
415  ENDIF
416  WRITE(ndso,*)'FILE '//filename(:j)//' FOUND.'// &
417  'LOADING UOST SETTINGS FOR GRID '//grd%GNAME
418 
419  CALL load_alphabeta_fromfile(fileunit, filename(:j), grd%NX, grd%NY, sgd%NK, sgd%NTH,&
420  grd%UOSTABMULTFACTOR, grd%UOSTLOCALALPHA, grd%UOSTLOCALBETA,&
421  grd%UOSTCELLSIZE, grd%UOST_LCL_OBSTRUCTED)
422 
423 
424  ! LOADING SHADOW ALPHA/BETA
425  filename = grd%UOSTFILESHADOW
426  INQUIRE(file=filename, exist=fileexists)
427 
428  j = len_trim(filename)
429  IF (.NOT. fileexists) THEN
430  WRITE(ndse,*)'*** WAVEWATCH III ERROR IN W3UOST: '// &
431  'FILE '//filename(:j)//' NOT FOUND. QUITTING'
432  CALL extcde (9999)
433  ENDIF
434  WRITE(ndso,*)'FILE '//filename(:j)//' FOUND.'//&
435  'LOADING UOST SETTINGS FOR GRID '//grd%GNAME
436 
437  CALL load_alphabeta_fromfile(fileunit, filename(:j), grd%NX, grd%NY, sgd%NK, sgd%NTH,&
438  grd%UOSTABMULTFACTOR, grd%UOSTSHADOWALPHA, grd%UOSTSHADOWBETA,&
439  grd%UOSTCELLSIZE, grd%UOST_SHD_OBSTRUCTED)
440 
441 
442  END SUBROUTINE load_alphabeta
443 
444  !/ ------------------------------------------------------------------- /
445 
466  SUBROUTINE load_alphabeta_fromfile(FILEUNIT, FILENAME, NX, NY, NK, NTH,&
467  MULTFACTOR, ALPHAMTX, BETAMTX, CELLSIZE, ISOBSTRUCTED)
468  !/
469  !/ +-----------------------------------+
470  !/ | WAVEWATCH III NOAA/NCEP |
471  !/ | Lorenzo Mentaschi |
472  !/ | FORTRAN 90 |
473  !/ | Last update : 01-Oct-2018 |
474  !/ +-----------------------------------+
475  !/
476  !/ Aug-2018 : Origination. ( version 6.07 )
477  !/
478  ! 1. Purpose : loads alpha and beta from a single obstructions file
479  ! 2. Parameters :
480  !
481  ! Parameter list
482  ! ----------------------------------------------------------------
483  ! FILEUNIT, Integer: unit of the file to be opened
484  ! FILENAME, string: name of the file
485  ! NX, NY, NK, NTH, Integer: size of the spatial/spectral grid
486  ! MULTFACTOR, REAL: multiplication factor for alpha and beta:
487  ! alpha and beta should be real in [0,1]
488  ! but to save memory the are stored in Integer*1
489  ! ALPHAMTX, BETAMTX, Integer*1: loaded alpha and beta spatial/spectral matrices
490  ! CELLSIZE, REAL, REAL: cell size for each spectral direction,
491  ! also loaded from the file
492  ! ISOBSTRUCTED, LOGICAL: matrix of logicals, indicating for each cell
493  ! if it is obstructed or not
494  ! ----------------------------------------------------------------
495  !
496  ! 3. Called by :
497  !
498  ! Name Type Module Description
499  ! ----------------------------------------------------------------
500  ! LOAD_ALPHABETA Subr. W3UOSTMD Initialization of the UOST grid
501  ! ----------------------------------------------------------------
502  !
503  ! 4. Source code :
504  !
505  !/ ------------------------------------------------------------------- /
506  IMPLICIT NONE
507 
508  CHARACTER(*), INTENT(IN) :: filename
509  REAL, INTENT(IN) :: multfactor
510  INTEGER, INTENT(IN) :: fileunit, nx, ny, nk, nth
511  INTEGER*1, INTENT(INOUT) :: alphamtx(:,:,:,:), betamtx(:,:,:,:)
512  real*4, INTENT(INOUT) :: cellsize(:,:,:)
513  LOGICAL, INTENT(INOUT) :: isobstructed(:,:)
514  CHARACTER(LEN=600) :: line
515  INTEGER :: fiostat
516  LOGICAL :: header, filestart, readingcellsize, readingalpha
517  INTEGER :: ix, iy, spgrds_size, ik
518  REAL, ALLOCATABLE :: trans(:)
519 #ifdef W3_S
520  INTEGER, SAVE :: ient = 0
521 #endif
522 
523 #ifdef W3_S
524  CALL strace (ient, 'LOAD_ALPHABETA_FROMFILE')
525 #endif
526 
527  ! INITIALIZING LOGICALS REPRESENTING THE DIFFERENT PHASES OF THE LOAD
528  filestart = .true.
529  header = .true.;
530  readingcellsize = .false.
531  readingalpha = .false.
532  ik = 0
533 
534  ALLOCATE(trans(nth))
535 
536  OPEN(fileunit, file=filename, status='OLD', action='READ')
537  read_loop: DO
538  READ(fileunit, '(A)', iostat=fiostat) line
539 
540  IF (fiostat .NE. 0) EXIT read_loop
541 
542  IF (line(1:1) .EQ. '$') cycle
543 
544  IF (filestart) THEN
545  ! reading the first line
546  READ(line, '(I5)') spgrds_size
547  filestart = .false.
548  ELSEIF (header) THEN
549  ! reading the position of an obstructed cell
550  READ(line, *) ix, iy
551  isobstructed(ix, iy) = .true.
552  IF ((ix .GT. nx) .OR. (iy .GT. ny)) THEN
553  WRITE(ndse,*) '*** WAVEWATCH III ERROR IN W3UOST: '// &
554  'GRID INDICES OUT OF RANGE.'// &
555  'CHECK FILE '//filename
556  CALL extcde (9999)
557  ENDIF
558  ! marking the end of the reading of the header
559  header = .false.
560  ik = 1
561  readingcellsize = .true.
562  ELSEIF (readingcellsize) THEN
563  ! reading the sizes of the cell
564  READ(line, *) cellsize(ix, iy, :)
565  readingcellsize = .false.
566  readingalpha = .true.
567  ELSE
568  READ(line, *) trans
569  IF (readingalpha) THEN
570  ! reading alpha for frequency IK
571  alphamtx(ix, iy, ik, :) = nint(trans*multfactor)
572  ELSE
573  ! reading beta for frequency IK
574  betamtx(ix, iy, ik, :) = nint(trans*multfactor)
575  ENDIF
576  IF (ik .LT. nk) THEN
577  ik = ik + 1
578  ELSE IF (readingalpha) THEN
579  ! preparing to read the next cell
580  readingalpha = .false.
581  ik = 1
582  ELSE
583  header = .true.
584  ik = 1
585  ENDIF
586  ENDIF
587  ENDDO read_loop
588  CLOSE(fileunit)
589 
590  DEALLOCATE(trans)
591 
592  END SUBROUTINE load_alphabeta_fromfile
593 
594  !/ ------------------------------------------------------------------- /
606  SUBROUTINE uost_sourceterm_setgrid(THIS, GRD, SGD)
607  !/
608  !/ +-----------------------------------+
609  !/ | WAVEWATCH III NOAA/NCEP |
610  !/ | Lorenzo Mentaschi |
611  !/ | FORTRAN 90 |
612  !/ | Last update : 01-Oct-2018 |
613  !/ +-----------------------------------+
614  !/
615  !/ Aug-2018 : Origination. ( version 6.07 )
616  !/
617  ! 1. Purpose : method of the class UOST_SOURCETERM,
618  ! to set the actual spatial and spectral grid
619  ! 2. Parameters :
620  !
621  ! Parameter list
622  ! ----------------------------------------------------------------
623  ! GRD, GRID type: object representing the spatial grid to
624  ! be loaded
625  ! SGD, SGRD type: object representing the current spectral grid
626  ! ----------------------------------------------------------------
627  !
628  ! 3. Called by :
629  !
630  ! Name Type Module Description
631  ! ----------------------------------------------------------------
632  ! UOST_SETGRID Subr. W3UOSTMD Setting the actual computation grid
633  ! ----------------------------------------------------------------
634  !
635  ! 4. Source code :
636  !
637  !/ ------------------------------------------------------------------- /
638  IMPLICIT NONE
639 
640  CLASS(uost_sourceterm), INTENT(INOUT) :: this
641  TYPE(grid), TARGET, INTENT(IN) :: grd
642  TYPE(sgrd), TARGET, INTENT(IN) :: sgd
643  INTEGER :: ith, nth
644 #ifdef W3_S
645  INTEGER, SAVE :: ient = 0
646 #endif
647 
648 #ifdef W3_S
649  CALL strace (ient, 'UOST_SOURCETERM_SETGRID')
650 #endif
651 
652  this%GRD => grd
653  this%SGD => sgd
654 
655  IF (ALLOCATED(this%COSTH)) THEN
656  DEALLOCATE(this%COSTH)
657  DEALLOCATE(this%SINTH)
658  ENDIF
659 
660  nth = this%SGD%NTH
661  ALLOCATE(this%COSTH(nth))
662  ALLOCATE(this%SINTH(nth))
663  DO ith=1,nth
664  this%COSTH(ith) = cos(sgd%TH(ith))
665  this%SINTH(ith) = sin(sgd%TH(ith))
666  ENDDO
667  END SUBROUTINE uost_sourceterm_setgrid
668 
669  !/ ------------------------------------------------------------------- /
670 
688  SUBROUTINE compute_reduction_psi(U10ABS, U10DIR, CGABS, CGDIR, DT, PSI)
689  !/
690  !/ +-----------------------------------+
691  !/ | WAVEWATCH III NOAA/NCEP |
692  !/ | Lorenzo Mentaschi |
693  !/ | FORTRAN 90 |
694  !/ | Last update : 01-Oct-2018 |
695  !/ +-----------------------------------+
696  !/
697  !/ Aug-2018 : Origination. ( version 6.07 )
698  !/
699  ! 1. Purpose : In conditions of wind sea, the effect
700  ! of the unresolved obstacles is reduced.
701  ! Here a reduction psi is computed, as a function of the
702  ! wave age.
703  ! 2. Parameters :
704  !
705  ! Parameter list
706  ! ----------------------------------------------------------------
707  ! U10ABS, real: absolute value of U10
708  ! U10DIR, real: direction of U10
709  ! CGABS, real: absolute value of the group velocity
710  ! CGDIR, real: direction of the group velocity
711  ! DT, real: time step
712  ! PSI, real: output psi factor
713  ! ----------------------------------------------------------------
714  !
715  ! 3. Called by :
716  !
717  ! Name Type Module Description
718  ! ----------------------------------------------------------------
719  ! UOST_SOURCETERM_COMPUTE_LD Subr. W3UOSTMD Computing the local dissipation
720  ! UOST_SOURCETERM_COMPUTE_SE Subr. W3UOSTMD Computing the shadow effect
721  ! ----------------------------------------------------------------
722  !
723  ! 4. Source code :
724  !
725  !/ ------------------------------------------------------------------- /
726  USE constants, ONLY: pi
727 
728  IMPLICIT NONE
729 
730  REAL, PARAMETER :: tolerance = 0.000001
731  REAL, PARAMETER :: whthr1 = .5, whthr2 = 1.5
732 
733  REAL, INTENT(IN) :: u10abs, u10dir, cgabs, cgdir, dt
734  REAL, INTENT(OUT) :: psi
735  REAL :: thdelta, cp, wa
736 #ifdef W3_S
737  INTEGER, SAVE :: ient = 0
738 #endif
739 
740 #ifdef W3_S
741  CALL strace (ient, 'COMPUTE_REDUCTION_PSI')
742 #endif
743 
744  ! computing the wave age
745  thdelta = abs(u10dir - cgdir)
746  DO WHILE (thdelta .GT. pi)
747  thdelta = thdelta - 2*pi
748  ENDDO
749  thdelta = abs(thdelta)
750  IF (pi/2 - thdelta .GT. tolerance) THEN
751  cp = cgabs*2 ! this is scrictly valid only in deep water
752  wa = cp/u10abs/cos(thdelta)
753  ELSE
754  wa = 9999999 ! a very high number
755  ENDIF
756 
757  IF (wa .LE. whthr1) THEN
758  ! if the wave age is less that 0.5, psi = 0, i.e.
759  ! no unresolved obstacle is considered
760  psi = 0
761  ELSEIF ((wa .GT. whthr1) .AND. (wa .LT. whthr2)) THEN
762  ! if the wave age is between 0.5 and 1.5
763  ! psi scales linearly with WA
764  psi = (wa - whthr1)/(whthr2 - whthr1)
765  ELSE
766  ! if the wave age is greater than 1.5 psi = 1
767  psi = 1
768  ENDIF
769 
770  END SUBROUTINE compute_reduction_psi
771 
772  !/ ------------------------------------------------------------------- /
773 
793  SUBROUTINE uost_sourceterm_compute_ld(THIS, IX, IY, SPEC, CG, DT, U10ABS, U10DIR, S, D)
794  !/
795  !/ +-----------------------------------+
796  !/ | WAVEWATCH III NOAA/NCEP |
797  !/ | Lorenzo Mentaschi |
798  !/ | FORTRAN 90 |
799  !/ | Last update : 01-Oct-2018 |
800  !/ +-----------------------------------+
801  !/
802  !/ Aug-2018 : Origination. ( version 6.07 )
803  !/
804  ! 1. Purpose : Method of the class UOST_SOURCETERM.
805  ! Computation of the local dissipation of the spectrum
806  ! 2. Parameters :
807  !
808  ! Parameter list
809  ! ----------------------------------------------------------------
810  ! THIS: UOST_SOURCETERM instance of UOST_SOURCETERM passed to the method
811  ! (compulsory in oo programming)
812  ! IX, IY: Integer coordinates of the actual cell
813  ! SPEC: real input spectrum
814  ! CG: real group velocity
815  ! DT: real time step
816  ! U10ABS: real absolute value of U10
817  ! U10DIR: real direction of U10
818  ! S: real source term
819  ! D: real differential of the source term over the spectrum
820  ! ----------------------------------------------------------------
821  !
822  ! 3. Called by :
823  !
824  ! Name Type Module Description
825  ! ----------------------------------------------------------------
826  ! UOST_SOURCETERM_COMPUTE Subr. W3UOSTMD Computing the source term
827  ! ----------------------------------------------------------------
828  !
829  ! 4. Source code :
830  !
831  !/ ------------------------------------------------------------------- /
832  IMPLICIT NONE
833 
834  CLASS(uost_sourceterm), INTENT(INOUT) :: THIS
835  INTEGER, INTENT(IN) :: IX, IY
836  REAL, INTENT(IN) :: SPEC(THIS%SGD%NSPEC), CG(THIS%SGD%NK)
837  REAL, INTENT(OUT) :: S(THIS%SGD%NSPEC), D(THIS%SGD%NSPEC)
838  REAL, INTENT(IN) :: U10ABS, U10DIR
839  REAL, INTENT(IN) :: DT
840 
841  INTEGER :: IK, ITH, ISP, NK, NTH
842  REAL :: ALPHA, BETA, CGI, CELLSIZE, SPECI, SFC
843  LOGICAL :: CELLOBSTRUCTED
844  REAL :: TH, PSI
845 #ifdef W3_S
846  INTEGER, SAVE :: IENT = 0
847 #endif
848 
849 #ifdef W3_S
850  CALL strace (ient, 'UOST_SOURCETERM_COMPUTE_LD')
851 #endif
852 
853  s = 0
854  d = 0
855 
856  cellobstructed = this%GRD%UOST_LCL_OBSTRUCTED(ix, iy)
857  IF (.NOT. cellobstructed) RETURN
858 
859  nk = this%SGD%NK
860  nth = this%SGD%NTH
861 
862  DO ik = 1,nk
863  cgi = cg(ik)
864  DO ith = 1,nth
865 
866  ! Getting alpha and beta for local dissipation
867  alpha = this%GRD%UOSTLOCALALPHA(ix, iy, ik, ith)/this%GRD%UOSTABMULTFACTOR
868  alpha = max(min(alpha*this%GRD%UOSTLOCALFACTOR, 1.), 0.)
869  beta = this%GRD%UOSTLOCALBETA(ix, iy, ik, ith)/this%GRD%UOSTABMULTFACTOR
870  beta = max(min(beta*this%GRD%UOSTLOCALFACTOR, 1.), 0.)
871 
872 
873  IF (alpha .EQ. 1) cycle
874 
875  ! Getting the size of the cell along direction ith
876  cellsize = this%GRD%UOSTCELLSIZE(ix, iy, ith)*this%GRD%UOSTCELLSIZEFACTOR
877 
878  isp = ith + (ik-1)*nth
879  speci = spec(isp)
880 
881  th = this%SGD%TH(ith)
882  CALL compute_reduction_psi(u10abs, u10dir, cg(ik), th, dt, psi)
883 
884  IF (beta > 0.09) THEN
885  ! Computing the local dissipation for a partially obstructed cell
886  sfc = - cgi/cellsize * (1 - beta)/beta
887  ELSE
888  ! The cell is almost completely obstructed.
889  ! Dissipating the energy almost completely.
890  sfc = - cgi/cellsize * this%GAMMAUP
891  ENDIF
892 
893  s(isp) = sfc * speci * psi
894  d(isp) = sfc * psi
895  ENDDO
896  ENDDO
897 
898  END SUBROUTINE uost_sourceterm_compute_ld
899 
900  !/ ------------------------------------------------------------------- /
920  SUBROUTINE uost_sourceterm_compute_se(THIS, IX, IY, SPEC, CG, DT, U10ABS, U10DIR, S, D)
921  !/
922  !/ +-----------------------------------+
923  !/ | WAVEWATCH III NOAA/NCEP |
924  !/ | Lorenzo Mentaschi |
925  !/ | FORTRAN 90 |
926  !/ | Last update : 01-Oct-2018 |
927  !/ +-----------------------------------+
928  !/
929  !/ Aug-2018 : Origination. ( version 6.07 )
930  !/
931  ! 1. Purpose : Method of the class UOST_SOURCETERM.
932  ! Computation of the shadow dissipation of the spectrum
933  ! 2. Parameters :
934  !
935  ! Parameter list
936  ! ----------------------------------------------------------------
937  ! THIS: UOST_SOURCETERM instance of UOST_SOURCETERM passed to the method
938  ! (compulsory in oo programming)
939  ! IX, IY: Integer coordinates of the actual cell
940  ! SPEC: real input spectrum
941  ! CG: real group velocity
942  ! DT: real time step
943  ! U10ABS: real absolute value of U10
944  ! U10DIR: real direction of U10
945  ! S: real source term
946  ! D: real differential of the source term over the spectrum
947  ! ----------------------------------------------------------------
948  !
949  ! 3. Called by :
950  !
951  ! Name Type Module Description
952  ! ----------------------------------------------------------------
953  ! UOST_SOURCETERM_COMPUTE Subr. W3UOSTMD Computing the source term
954  ! ----------------------------------------------------------------
955  !
956  ! 4. Source code :
957  !
958  !/ ------------------------------------------------------------------- /
959  IMPLICIT NONE
960 
961  CLASS(uost_sourceterm), INTENT(INOUT), TARGET :: THIS
962  INTEGER, INTENT(IN) :: IX, IY
963  REAL, INTENT(IN) :: SPEC(THIS%SGD%NSPEC), CG(THIS%SGD%NK)
964  REAL, INTENT(OUT) :: S(THIS%SGD%NSPEC), D(THIS%SGD%NSPEC)
965  REAL, INTENT(IN) :: U10ABS, U10DIR
966  REAL, INTENT(IN) :: DT
967 
968  INTEGER :: IK, ITH, IS
969  REAL :: CGI, SPECI, SFC, CELLSIZE, &
970  SFCLEFT, SFCRIGHT, SFCCENTER, THDIAG, CGDIAG, &
971  ALPHASH, BETASH, GAMMMA, GG
972  INTEGER :: N = 8, ithdiag, isp, nk, nth, nx, ny
973  LOGICAL :: CELLOBSTRUCTED
974  REAL :: TH, PSI
975 #ifdef W3_S
976  INTEGER, SAVE :: IENT = 0
977 #endif
978 
979 #ifdef W3_S
980  CALL strace (ient, 'UOST_SOURCETERM_COMPUTE_SE')
981 #endif
982 
983  s = 0
984  d = 0
985 
986  nk = this%SGD%NK
987  nth = this%SGD%NTH
988  nx = this%GRD%NX
989  ny = this%GRD%NY
990 
991  IF ((ix .EQ. 1) .OR. (ix .EQ. nx) .OR. (iy .EQ. 1) .OR. (iy .EQ. ny)) RETURN
992 
993  cellobstructed = this%GRD%UOST_SHD_OBSTRUCTED(ix, iy)
994  IF (.NOT. cellobstructed) RETURN
995 
996  DO ik=1,nk
997  DO ith=1,nth
998 
999  ! Getting alpha and beta of the shadow
1000  alphash = this%GRD%UOSTSHADOWALPHA(ix, iy, ik, ith)/this%GRD%UOSTABMULTFACTOR
1001  alphash = max(min(alphash*this%GRD%UOSTSHADOWFACTOR, 1.), 0.)
1002  betash = this%GRD%UOSTSHADOWBETA(ix, iy, ik, ith)/this%GRD%UOSTABMULTFACTOR
1003  betash = max(min(betash*this%GRD%UOSTSHADOWFACTOR, 1.), 0.)
1004 
1005  IF (alphash .EQ. 1) cycle
1006 
1007  ! Getting the size of the cell along direction ith
1008  cellsize = this%GRD%UOSTCELLSIZE(ix, iy, ith)*this%GRD%UOSTCELLSIZEFACTOR
1009 
1010  cgi = cg(ik)
1011 
1012  gg = cgi/cellsize
1013 
1014  IF (alphash > 0.2) THEN
1015  ! Computing the shadow gamma coefficient for a partially obstructed cell
1016  gammma = (betash/alphash - 1)
1017  ELSE
1018  ! Alpha is small. The shadow dissipates the energy almost completely
1019  gammma = this%GAMMADOWN
1020  ENDIF
1021 
1022  th = this%SGD%TH(ith)
1023  ! Computing the reduction psi related with the wind component of the spectrum
1024  CALL compute_reduction_psi(u10abs, u10dir, cg(ik), th, dt, psi)
1025 
1026  sfc = - gg*gammma
1027 
1028  isp = ith + (ik-1)*nth
1029  speci = spec(isp)
1030  s(isp) = sfc * speci * psi
1031  d(isp) = sfc * psi
1032  ENDDO
1033  ENDDO
1034  END SUBROUTINE uost_sourceterm_compute_se
1035 
1036  !/ ------------------------------------------------------------------- /
1056  SUBROUTINE uost_sourceterm_compute(THIS, IX, IY, SPEC, CG, DT, U10ABS, U10DIR, S, D)
1057  !/
1058  !/ +-----------------------------------+
1059  !/ | WAVEWATCH III NOAA/NCEP |
1060  !/ | Lorenzo Mentaschi |
1061  !/ | FORTRAN 90 |
1062  !/ | Last update : 01-Oct-2018 |
1063  !/ +-----------------------------------+
1064  !/
1065  !/ Aug-2018 : Origination. ( version 6.07 )
1066  !/
1067  ! 1. Purpose : Method of the class UOST_SOURCETERM.
1068  ! Computation of the source term
1069  ! 2. Parameters :
1070  !
1071  ! Parameter list
1072  ! ----------------------------------------------------------------
1073  ! THIS: UOST_SOURCETERM instance of UOST_SOURCETERM passed to the method
1074  ! (compulsory in oo programming)
1075  ! IX, IY: Integer coordinates of the actual cell
1076  ! SPEC: real input spectrum
1077  ! CG: real group velocity
1078  ! DT: real time step
1079  ! U10ABS: real absolute value of U10
1080  ! U10DIR: real direction of U10
1081  ! S: real source term
1082  ! D: real differential of the source term over the spectrum
1083  ! ----------------------------------------------------------------
1084  !
1085  ! 3. Called by :
1086  !
1087  ! Name Type Module Description
1088  ! ----------------------------------------------------------------
1089  ! UOST_SRCTRMCOMPUTE Subr. W3UOSTMD Computing the source term
1090  ! ----------------------------------------------------------------
1091  !
1092  ! 4. Source code :
1093  !
1094  !/ ------------------------------------------------------------------- /
1095  IMPLICIT NONE
1096 
1097  CLASS(uost_sourceterm), INTENT(INOUT) :: THIS
1098  INTEGER, INTENT(IN) :: IX, IY
1099  REAL, INTENT(IN) :: SPEC(THIS%SGD%NSPEC), CG(THIS%SGD%NK)
1100  REAL, INTENT(IN) :: DT
1101  REAL, INTENT(IN) :: U10ABS, U10DIR
1102  REAL, INTENT(OUT) :: S(THIS%SGD%NSPEC), D(THIS%SGD%NSPEC)
1103 
1104  REAL :: S_LD(THIS%SGD%NSPEC), S_SE(THIS%SGD%NSPEC)
1105  REAL :: D_LD(THIS%SGD%NSPEC), D_SE(THIS%SGD%NSPEC)
1106 #ifdef W3_S
1107  INTEGER, SAVE :: IENT = 0
1108 #endif
1109 
1110 #ifdef W3_S
1111  CALL strace (ient, 'UOST_SOURCETERM_COMPUTE')
1112 #endif
1113 
1114  IF (.NOT. this%GRD%UOSTENABLED) THEN
1115  s = 0
1116  RETURN
1117  ENDIF
1118 
1119  ! Initializing the LD and SE components
1120  s_ld = 0
1121  s_se = 0
1122  ! Local dissipation
1123  CALL this%COMPUTE_LD(ix, iy, spec, cg, dt, u10abs, u10dir, s_ld, d_ld)
1124  ! Shadow effect
1125  CALL this%COMPUTE_SE(ix, iy, spec, cg, dt, u10abs, u10dir, s_se, d_se)
1126  s = s_ld + s_se
1127  d = d_ld + d_se
1128  END SUBROUTINE uost_sourceterm_compute
1129 
1130 
1131  !/ ------------------------------------------------------------------- /
1132 
1133 END MODULE w3uostmd
1134 
1135 !/ ------------------------------------------------------------------- /
constants::pi
real, parameter pi
PI Value of Pi.
Definition: constants.F90:71
w3uostmd
Parmeterization of the unresolved obstacles.
Definition: w3uostmd.F90:22
w3gdatmd::sgrds
type(sgrd), dimension(:), allocatable, target sgrds
Definition: w3gdatmd.F90:1089
w3gdatmd::grid
Definition: w3gdatmd.F90:643
w3uostmd::uost_srctrmcompute
subroutine, public uost_srctrmcompute(IX, IY, SPEC, CG, DT, U10ABS, U10DIR, S, D)
Estimates the UOST source term for a give spectrum.
Definition: w3uostmd.F90:299
w3gdatmd::sgrd
Definition: w3gdatmd.F90:793
w3gdatmd::grids
type(grid), dimension(:), allocatable, target grids
Definition: w3gdatmd.F90:1088
w3odatmd::ndse
integer, pointer ndse
Definition: w3odatmd.F90:456
w3servmd
Definition: w3servmd.F90:3
w3odatmd
Definition: w3odatmd.F90:3
file
file(STRINGS ${CMAKE_BINARY_DIR}/switch switch_strings) separate_arguments(switches UNIX_COMMAND $
Definition: CMakeLists.txt:3
w3uostmd::uost_initgrid
subroutine, public uost_initgrid(IGRID, FILELOCAL, FILESHADOW, LOCALFACTOR, SHADOWFACTOR)
Allocate the UOST variables for a given grid, and load them from file.
Definition: w3uostmd.F90:123
w3servmd::strace
subroutine strace(IENT, SNAME)
Definition: w3servmd.F90:148
w3odatmd::ndso
integer, pointer ndso
Definition: w3odatmd.F90:456
w3uostmd::uost_setgrid
subroutine, public uost_setgrid(IGRID)
Sets the current grid in the sourceterm object.
Definition: w3uostmd.F90:232
constants
Define some much-used constants for global use (all defined as PARAMETER).
Definition: constants.F90:20
w3gdatmd
Definition: w3gdatmd.F90:16
w3servmd::extcde
subroutine extcde(IEXIT, UNIT, MSG, FILE, LINE, COMM)
Definition: w3servmd.F90:736
w3uostmd::uost_sourceterm_compute_ld
subroutine uost_sourceterm_compute_ld(THIS, IX, IY, SPEC, CG, DT, U10ABS, U10DIR, S, D)
Method of the class UOST_SOURCETERM.
Definition: w3uostmd.F90:794