WAVEWATCH III  beta 0.0.1
ww3_uprstr.F90 File Reference

Contains the program W3UPRSTR. More...

Go to the source code of this file.

Functions/Subroutines

program w3uprstr
 Update restart files based on Hs from DA. More...
 
subroutine update_va (PRCNTG, VATMP)
 Apply correction to the spectrum. More...
 
subroutine check_prcntg (PRCNTG, PRCNTG_CAP)
 Last sanity check before the update of the spectrum. More...
 
subroutine read_grbtxt (UPDPRCNT, FLNMCOR, SMCGRD)
 Read gribtxt files. More...
 
subroutine read_grbtxtws (UPDPRCNT, WSPD, WDIR, FLNMCOR, SMCGRD)
 Read txt files that include wind data. More...
 
subroutine swh_rsrt_1p (VA1p, ISEA1p, HSIG1p)
 Calculate the significant wave height from the restart file for 1 point. More...
 
subroutine swh_rsrt_1pw (VA1p, WS, WD, ISEA1p, HSIG1p, HSIGwp, HSIGsp, VAMAPWS)
 Calculate Hs from restart for 1 point. More...
 
subroutine uvtocart (UVEC, VVEC, SPD, DCART, SMCGRD)
 Calculate speed and cartesian convention directions from u,v input vectors. More...
 
subroutine updtwspec (VATMP, PRCNTG, VAMAPWS)
 Updates the wind-sea part of the wave spectrum only. More...
 
subroutine updtwspecf (VATMP, PRCNTG, VAMAPWS, ISEA1p, ADJALL)
 Updates the wind-sea part of the wave spectrum and shifts in frequency space. More...
 
subroutine writematrix (FILENAME, RDA_A)
 Writes a 2D array to text file, column by column. More...
 

Detailed Description

Contains the program W3UPRSTR.

Author
Stelios Flampouris
Date
16-Feb-2017

Definition in file ww3_uprstr.F90.

Function/Subroutine Documentation

◆ check_prcntg()

subroutine w3uprstr::check_prcntg ( real, intent(inout)  PRCNTG,
real, intent(in)  PRCNTG_CAP 
)

Last sanity check before the update of the spectrum.

The percentage of change is compared against a user defined cap.

Parameters
[in,out]PRCNTG
[in,out]PRCNTG_CAP
Author
Stelios Flampouris
Date
16-Oct-2018

Definition at line 1278 of file ww3_uprstr.F90.

1278  !/
1279  !/ +-----------------------------------+
1280  !/ | WAVEWATCH III NOAA/NCEP |
1281  !/ | Stelios Flampouris |
1282  !/ | FORTRAN 90 |
1283  !/ | Created : 16-Oct-2018 |
1284  !/ +-----------------------------------+
1285  !/
1286  !/ 16-Oct-2018 : Original Code ( version 6.06 )
1287  !/ 24-Oct-2018 : Update by Andy Saulter ( version 7.14 )
1288  !/
1289  !/ Copyright 2010 National Weather Service (NWS),
1290  !/ National Oceanic and Atmospheric Administration. All rights
1291  !/ reserved. WAVEWATCH III is a trademark of the NWS.
1292  !/ No unauthorized use without permission.
1293  !/
1294  ! 1. Purpose :
1295  ! Last sanity check before the update of the spectrum
1296  ! 2. Method :
1297  ! The percentage of change is compared against a user defined cap.
1298  ! 3. Parameters :
1299  !
1300  ! Local parameters.
1301  ! ----------------------------------------------------------------
1302  !
1303  ! 4. Subroutines used :
1304  !
1305  ! ----------------------------------------------------------------
1306  ! Internal Subroutines:
1307  !
1308  ! 5. Called by :
1309  !
1310  ! 6. Error messages :
1311  !
1312  ! 7. Remarks :
1313  !
1314  ! 8. Structure :
1315  !
1316  ! 9. Switches :
1317  !
1318  ! !/T
1319  !
1320  ! 10. Source code :
1321  !
1322  !/
1323  REAL, INTENT(INOUT) :: PRCNTG
1324  REAL, INTENT(IN ) :: PRCNTG_CAP
1325  ! local
1326  CHARACTER(12), PARAMETER :: MYNAME='CHECK_PRCNTG'
1327 #ifdef W3_T
1328 
1329  WRITE (ndso,*) trim(myname)," The original correction is ",prcntg
1330  WRITE (ndso,*) trim(myname)," The cap is ",prcntg_cap
1331 #endif
1332  IF ( prcntg_cap < 1. ) THEN
1333  WRITE (ndso,*) trim(myname)," WARNING: PRCNTG_CAP set < 1."
1334  WRITE (ndso,*) trim(myname)," This may introduce spurious corrections"
1335  END IF
1336 #ifdef W3_T
1337  WRITE (ndso,*) trim(myname)," The cap is ",prcntg_cap
1338 #endif
1339  IF ( prcntg > 1. ) THEN
1340 #ifdef W3_T
1341  WRITE (ndso,*) trim(myname)," PRCNTG > 1."
1342 #endif
1343  prcntg = min(prcntg, 1. * prcntg_cap)
1344  ELSE IF ( prcntg < 1. ) THEN
1345 #ifdef W3_T
1346  WRITE (ndso,*) trim(myname)," PRCNTG < 1."
1347 #endif
1348  prcntg = max(prcntg, 1. / prcntg_cap)
1349 #ifdef W3_T
1350 
1351 #endif
1352  END IF
1353 #ifdef W3_T
1354  WRITE (ndso,*) trim(myname)," The updated correction is ",prcntg
1355 #endif
1356  !

Referenced by w3uprstr().

◆ read_grbtxt()

subroutine w3uprstr::read_grbtxt ( real, dimension(:,:), intent(out)  UPDPRCNT,
character(*), intent(in)  FLNMCOR,
logical, intent(in)  SMCGRD 
)

Read gribtxt files.

Parameters
[in,out]UPDPRCNT
[in,out]FLNMCOR
[in,out]SMCGRD
Author
Stelios Flampouris
Date
16-Oct-2018

Definition at line 1369 of file ww3_uprstr.F90.

1369  !/
1370  !/ +-----------------------------------+
1371  !/ | WAVEWATCH III NOAA/NCEP |
1372  !/ | Stelios Flampouris |
1373  !/ | FORTRAN 90 |
1374  !/ | Created : 15-Mar-2017 |
1375  !/ | Last Update : 16-Oct-2018 |
1376  !/ +-----------------------------------+
1377  !/
1378  !/ 15-Mar-2017 : Original Code ( version 6.04 )
1379  !/ 16-Oct-2018 : Generalization of the reader ( version 6.06 )
1380  !/
1381  !/ Copyright 2010 National Weather Service (NWS),
1382  !/ National Oceanic and Atmospheric Administration. All rights
1383  !/ reserved. WAVEWATCH III is a trademark of the NWS.
1384  !/ No unauthorized use without permission.
1385  !/
1386  ! 1. Purpose :
1387  ! Read gribtxt files
1388  ! 2. Method :
1389  !
1390  ! 3. Parameters :
1391  !
1392  ! Local parameters.
1393  ! ----------------------------------------------------------------
1394  !
1395  ! 4. Subroutines used :
1396  !
1397  ! ----------------------------------------------------------------
1398  ! Internal Subroutines:
1399  !
1400  ! 5. Called by :
1401  !
1402  ! 6. Error messages :
1403  !
1404  ! 7. Remarks :
1405  !
1406  ! 8. Structure :
1407  !
1408  ! 9. Switches :
1409  !
1410  ! !/T
1411  !
1412  ! 10. Source code :
1413  !
1414  !/
1415  REAL, DIMENSION(:,:), INTENT(OUT) :: UPDPRCNT
1416  CHARACTER(*), INTENT(IN) :: FLNMCOR
1417  LOGICAL, INTENT(IN) :: SMCGRD
1418  ! Local Variables
1419  INTEGER :: I, J, IERR
1420  INTEGER :: K, L, M, N
1421  REAL :: A
1422  INTEGER, PARAMETER :: IP_FID = 123
1423  CHARACTER(25), PARAMETER::myname='read_grbtxt'
1424  !
1425 #ifdef W3_T
1426  WRITE (ndso,*) trim(myname), ' starts'
1427 #endif
1428  j = len_trim(fnmpre)
1429  OPEN (ip_fid,file=fnmpre(:j)//trim(flnmcor),status='OLD' &
1430  ,action='read',iostat=ierr)
1431  !
1432  ! Read text header and check dimensions match expected values
1433  IF (.NOT. smcgrd) THEN
1434  READ( ip_fid, *) m,n
1435  IF (( SIZE(updprcnt,1) /= n) .OR. ( SIZE(updprcnt,2) /= m )) THEN
1436  WRITE (ndso,*) trim(myname),': These are not the grid ' // &
1437  'dimensions: M=',m,' N=',n
1438  stop
1439  END IF
1440 #ifdef W3_SMC
1441  ELSE
1442  READ( ip_fid, *) n
1443  IF ( SIZE(updprcnt,1) /= n ) THEN
1444  WRITE (ndso,*) trim(myname),': These are not the grid ' // &
1445  'dimensions: N=',n
1446  stop
1447  END IF
1448 #endif
1449  END IF
1450  updprcnt=0
1451  !
1452  ! Read the data into its allocated array
1453  IF (.NOT. smcgrd) THEN
1454  DO l=1,n
1455  DO k=1,m
1456  a=0.
1457  READ(ip_fid,*)a
1458  updprcnt(n+1-l,k)=a
1459  END DO
1460  END DO
1461 #ifdef W3_SMC
1462  ELSE
1463  DO l=1,n
1464  a=0.
1465  READ(ip_fid,*)a
1466  updprcnt(l,1)=a
1467  END DO
1468 #endif
1469  END IF
1470  !
1471  CLOSE(ip_fid)
1472  !
1473 #ifdef W3_T
1474  WRITE (ndso,*) trim(myname), ' ends'
1475 #endif

References file().

Referenced by w3uprstr().

◆ read_grbtxtws()

subroutine w3uprstr::read_grbtxtws ( real, dimension(:,:), intent(out)  UPDPRCNT,
real, dimension(:,:), intent(out)  WSPD,
real, dimension(:,:), intent(out)  WDIR,
character(*), intent(in)  FLNMCOR,
logical, intent(in)  SMCGRD 
)

Read txt files that include wind data.

Parameters
[out]UPDPRCNT
[out]WSPD
[out]WDIR
[in]FLNMCOR
[in]SMCGRD
Author
Andy Saulter
Date
24-Oct-2018

Definition at line 1492 of file ww3_uprstr.F90.

1492  !/
1493  !/ +-----------------------------------+
1494  !/ | WAVEWATCH III NOAA/NCEP |
1495  !/ | Andy Saulter |
1496  !/ | FORTRAN 90 |
1497  !/ | Original code : 24-Oct-2018 |
1498  !/ | Last update : 05-Oct-2019 |
1499  !/ +-----------------------------------+
1500  !/
1501  !/ 24-Oct-2018 : Original Code ( version 6.07 )
1502  !/
1503  !/ Copyright 2010 National Weather Service (NWS),
1504  !/ National Oceanic and Atmospheric Administration. All rights
1505  !/ reserved. WAVEWATCH III is a trademark of the NWS.
1506  !/ No unauthorized use without permission.
1507  !/
1508  ! 1. Purpose :
1509  ! Read txt files that include wind data
1510  ! 2. Method :
1511  !
1512  ! 3. Parameters :
1513  !
1514  ! Local parameters.
1515  ! ----------------------------------------------------------------
1516  !
1517  ! 4. Subroutines used :
1518  !
1519  ! ----------------------------------------------------------------
1520  ! Internal Subroutines:
1521  !
1522  ! 5. Called by :
1523  !
1524  ! 6. Error messages :
1525  !
1526  ! 7. Remarks :
1527  !
1528  ! 8. Structure :
1529  !
1530  ! 9. Switches :
1531  !
1532  ! !/T
1533  !
1534  ! 10. Source code :
1535  !
1536  !/
1537  REAL, DIMENSION(:,:), INTENT(OUT) :: UPDPRCNT, WSPD, WDIR
1538  CHARACTER(*), INTENT(IN) :: FLNMCOR
1539  LOGICAL, INTENT(IN) :: SMCGRD
1540  ! Local Variables
1541  INTEGER :: I, J, IERR
1542  INTEGER :: K, L, M, N
1543  REAL :: A, WS, WD
1544  INTEGER, PARAMETER :: IP_FID = 123
1545  CHARACTER(25), PARAMETER::myname='read_grbtxt'
1546  !
1547 #ifdef W3_T
1548  WRITE (ndso,*) trim(myname), ' starts'
1549 #endif
1550  j = len_trim(fnmpre)
1551  OPEN (ip_fid,file=fnmpre(:j)//trim(flnmcor),status='OLD' &
1552  ,action='read',iostat=ierr)
1553  !
1554  ! Read text header and check dimensions match expected values
1555  IF (.NOT. smcgrd) THEN
1556  READ( ip_fid, *) m,n
1557  IF (( SIZE(updprcnt,1) /= n) .OR. ( SIZE(updprcnt,2) /= m )) THEN
1558  WRITE (ndso,*) trim(myname),': These are not the grid ' // &
1559  'dimensions: M=',m,' N=',n
1560  stop
1561  END IF
1562 #ifdef W3_SMC
1563  ELSE
1564  READ( ip_fid, *) n
1565  IF ( SIZE(updprcnt,1) /= n ) THEN
1566  WRITE (ndso,*) trim(myname),': These are not the grid ' // &
1567  'dimensions: N=',n
1568  stop
1569  END IF
1570 #endif
1571  END IF
1572  updprcnt=0
1573  wspd=0.
1574  wdir=0.
1575  !
1576  ! Read the data into allocated arrays
1577  IF (.NOT. smcgrd) THEN
1578  DO l=1,n
1579  DO k=1,m
1580  a=0.
1581  ws=0.
1582  wd=0.
1583  READ(ip_fid,*)a, ws, wd
1584  !SWH data read onto Y,X grid
1585  updprcnt(n+1-l,k)=a
1586  !Wind data read onto X,Y grid
1587  wspd(k,n+1-l)=ws
1588  wdir(k,n+1-l)=wd
1589  END DO
1590  END DO
1591 #ifdef W3_SMC
1592  ELSE
1593  DO l=1,n
1594  a=0.
1595  READ(ip_fid,*)a, ws, wd
1596  updprcnt(l,1)=a
1597  wspd(l,1)=ws
1598  wdir(l,1)=wd
1599  END DO
1600 #endif
1601  ENDIF
1602  !
1603  CLOSE(ip_fid)
1604  !
1605  !
1606 #ifdef W3_T
1607  WRITE (ndso,*) trim(myname), ' ends'
1608 #endif

References file().

Referenced by w3uprstr().

◆ swh_rsrt_1p()

subroutine w3uprstr::swh_rsrt_1p ( real, dimension(:), intent(in)  VA1p,
integer, intent(in)  ISEA1p,
real, intent(out)  HSIG1p 
)

Calculate the significant wave height from the restart file for 1 point.

Parameters
[in]VA1p
[in]ISEA1p
[out]HSIG1p
Author
Stelios Flampouris
Date
15-May-2017

Definition at line 1621 of file ww3_uprstr.F90.

1621  !/
1622  !/ +-----------------------------------+
1623  !/ | WAVEWATCH III NOAA/NCEP |
1624  !/ | Stelios Flampouris |
1625  !/ | FORTRAN 90 |
1626  !/ | Last update : 15-Mar-2017 |
1627  !/ +-----------------------------------+
1628  !/
1629  !/ 15-Mar-2017 : Original Code ( version 6.04 )
1630  !/
1631  !/ Copyright 2010 National Weather Service (NWS),
1632  !/ National Oceanic and Atmospheric Administration. All rights
1633  !/ reserved. WAVEWATCH III is a trademark of the NWS.
1634  !/ No unauthorized use without permission.
1635  !/
1636  ! 1. Purpose :
1637  ! Calculate the significant wave height from the restart file for 1 point
1638  ! 2. Method :
1639  !
1640  ! 3. Parameters :
1641  !
1642  ! Local parameters.
1643  ! ----------------------------------------------------------------
1644  !
1645  ! 4. Subroutines used :
1646  !
1647  ! ----------------------------------------------------------------
1648  ! Internal Subroutines:
1649  !
1650  ! 5. Called by :
1651  !
1652  ! 6. Error messages :
1653  !
1654  ! 7. Remarks :
1655  !
1656  ! 8. Structure :
1657  !
1658  ! 9. Switches :
1659  !
1660  ! !/T
1661  !
1662  ! 10. Source code :
1663  !
1664  !/
1665  REAL, INTENT(OUT) :: HSIG1p
1666  INTEGER, INTENT(IN) :: ISEA1p
1667  REAL, DIMENSION(:), INTENT(IN) :: VA1p
1668  CHARACTER(25),PARAMETER :: myname='SWH_RSRT_1p'
1669  !
1670 #ifdef W3_FT
1671  WRITE (ndso,*)' '
1672  WRITE (ndso,*) trim(myname), ' starts'
1673 #endif
1674  hsig1p = 0.
1675  depth = max( dmin , -zb(isea1p) )
1676  etot = 0.
1677  !
1678  DO ik=1, nk
1679  CALL wavnu1 ( sig(ik), depth, wn, cg )
1680  e1i = 0.
1681  DO ith=1, nth
1682  e1i = e1i + va1p(ith+(ik-1)*nth) * sig(ik) / cg
1683  END DO
1684  etot = etot + e1i*dsip(ik)
1685  END DO
1686  !
1687  hsig1p = 4. * sqrt( etot * dth )
1688  !
1689 #ifdef W3_FT
1690  WRITE (ndso,*) ' ', trim(myname), ' ends'
1691  WRITE (ndso,*)' '
1692 #endif

Referenced by w3uprstr().

◆ swh_rsrt_1pw()

subroutine w3uprstr::swh_rsrt_1pw ( real, dimension(:), intent(in)  VA1p,
real, intent(in)  WS,
real, intent(in)  WD,
integer, intent(in)  ISEA1p,
real, intent(out)  HSIG1p,
real, intent(out)  HSIGwp,
real, intent(out)  HSIGsp,
integer, dimension(:), intent(out)  VAMAPWS 
)

Calculate Hs from restart for 1 point.

Calculate the significant wave height for total, wind sea and swell components from the restart file for 1 point

Parameters
[in]VA1p
[in]WS
[in]WD
[in]ISEA1p
[out]HSIG1p
[out]HSIGwp
[out]HSIGsp
[out]VAMAPWS
Author
Andy Saulter
Date
05-0ct-2019

Definition at line 1714 of file ww3_uprstr.F90.

1714  !/
1715  !/ +-----------------------------------+
1716  !/ | WAVEWATCH III NOAA/NCEP |
1717  !/ | Andy Saulter |
1718  !/ | FORTRAN 90 |
1719  !/ | Original code : 24-Oct-2018 |
1720  !/ | Last update : 05-Oct-2019 |
1721  !/ +-----------------------------------+
1722  !/
1723  !/ 24-Oct-2018 : Original Code ( version 6.07 )
1724  !/
1725  !/ Copyright 2010 National Weather Service (NWS),
1726  !/ National Oceanic and Atmospheric Administration. All rights
1727  !/ reserved. WAVEWATCH III is a trademark of the NWS.
1728  !/ No unauthorized use without permission.
1729  !/
1730  ! 1. Purpose :
1731  ! Calculate the significant wave height for total, wind sea and
1732  ! swell components from the restart file for 1 point
1733  ! 2. Method :
1734  !
1735  ! 3. Parameters :
1736  !
1737  ! Local parameters.
1738  ! ----------------------------------------------------------------
1739  !
1740  ! 4. Subroutines used :
1741  !
1742  ! ----------------------------------------------------------------
1743  ! Internal Subroutines:
1744  !
1745  ! 5. Called by :
1746  !
1747  ! 6. Error messages :
1748  !
1749  ! 7. Remarks :
1750  !
1751  ! 8. Structure :
1752  !
1753  ! 9. Switches :
1754  !
1755  ! !/T
1756  !
1757  ! 10. Source code :
1758  !
1759  !/
1760  USE w3gdatmd, ONLY: th
1761  USE w3odatmd, ONLY: wsmult !same wind sea cut-off factor for sea/swell outputs
1762  !
1763  REAL, INTENT(OUT) :: HSIG1p, HSIGwp, HSIGsp
1764  INTEGER, INTENT(IN) :: ISEA1p
1765  REAL, INTENT(IN) :: WS, WD
1766  REAL, DIMENSION(:), INTENT(IN) :: VA1p
1767  INTEGER, DIMENSION(:), INTENT(OUT) :: VAMAPWS ! Wind-sea id for spectral bins
1768  REAL :: RELWS, ETOTw, ETOTs, EwI, EsI
1769  CHARACTER(25),PARAMETER :: myname='SWH_RSRT_1pw'
1770  !
1771 #ifdef W3_T
1772  WRITE (ndso,*) trim(myname), ' starts'
1773 #endif
1774  hsig1p = 0.
1775  hsigwp = 0.
1776  hsigsp = 0.
1777  depth = max( dmin , -zb(isea1p) )
1778  etot = 0.
1779  etotw = 0.
1780  etots = 0.
1781  !
1782  DO ik=1, nk
1783  CALL wavnu1 ( sig(ik), depth, wn, cg )
1784  e1i = 0.
1785  ewi = 0.
1786  esi = 0.
1787  DO ith=1, nth
1788  ! Relative wind-sea calc assumes input with in direction toward
1789  ! i.e. same as for the wave spectrum
1790  relws = wsmult * ws * max(0.0, cos(wd - th(ith)))
1791  e1i = e1i + va1p(ith+(ik-1)*nth) * sig(ik) / cg
1792  IF ( relws > (sig(ik)/wn) ) THEN
1793  ewi = ewi + va1p(ith+(ik-1)*nth) * sig(ik) / cg
1794  vamapws(ith+(ik-1)*nth) = 1
1795  ELSE
1796  esi = esi + va1p(ith+(ik-1)*nth) * sig(ik) / cg
1797  vamapws(ith+(ik-1)*nth) = 0
1798  END IF
1799  END DO
1800  etot = etot + e1i*dsip(ik)
1801  etotw = etotw + ewi*dsip(ik)
1802  etots = etots + esi*dsip(ik)
1803  END DO
1804  !
1805  hsig1p = 4. * sqrt( etot * dth )
1806  hsigwp = 4. * sqrt( etotw * dth )
1807  hsigsp = 4. * sqrt( etots * dth )
1808  !
1809 #ifdef W3_T
1810  WRITE (ndso,*) trim(myname), ' ends'
1811 #endif

References w3gdatmd::th, and w3odatmd::wsmult.

Referenced by w3uprstr().

◆ update_va()

subroutine w3uprstr::update_va ( real, intent(in)  PRCNTG,
real, dimension(:), intent(inout)  VATMP 
)

Apply correction to the spectrum.

The factor is (swh_anal/swh_bkg)**2 as applying to wave energy.

Parameters
[in]PRCNTG
[in,out]VATMP
Author
Stelios Flampouris
Date
16-Oct-2018

Definition at line 1214 of file ww3_uprstr.F90.

1214  !/
1215  !/ +-----------------------------------+
1216  !/ | WAVEWATCH III NOAA/NCEP |
1217  !/ | Stelios Flampouris |
1218  !/ | FORTRAN 90 |
1219  !/ | Created : 16-Oct-2018 |
1220  !/ +-----------------------------------+
1221  !/
1222  !/ 16-Oct-2018 : Original Code ( version 6.06 )
1223  !/
1224  !/ Copyright 2010 National Weather Service (NWS),
1225  !/ National Oceanic and Atmospheric Administration. All rights
1226  !/ reserved. WAVEWATCH III is a trademark of the NWS.
1227  !/ No unauthorized use without permission.
1228  !/
1229  ! 1. Purpose :
1230  ! Apply correction to the spectrum
1231  !
1232  ! 2. Method :
1233  ! The factor is (swh_anal/swh_bkg)**2 as applying to wave energy
1234  ! 3. Parameters :
1235  !
1236  ! Local parameters.
1237  ! ----------------------------------------------------------------
1238  !
1239  ! 4. Subroutines used :
1240  !
1241  ! ----------------------------------------------------------------
1242  ! Internal Subroutines:
1243  !
1244  ! 5. Called by :
1245  !
1246  ! 6. Error messages :
1247  !
1248  ! 7. Remarks :
1249  !
1250  ! 8. Structure :
1251  !
1252  ! 9. Switches :
1253  !
1254  ! !/T
1255  !
1256  ! 10. Source code :
1257  !
1258  !/
1259  REAL, INTENT(IN) :: PRCNTG
1260  REAL, DIMENSION(:), INTENT(INOUT) :: VATMP
1261  !
1262  vatmp = (prcntg**2)*vatmp
1263  !

Referenced by w3uprstr().

◆ updtwspec()

subroutine w3uprstr::updtwspec ( real, dimension(:), intent(inout)  VATMP,
real, intent(in)  PRCNTG,
integer, dimension(:), intent(in)  VAMAPWS 
)

Updates the wind-sea part of the wave spectrum only.

Parameters
[in,out]VATMP
[in]PRCNTG
[in]VAMAPWS
Author
Andy Saulter
Date
05-Oct-2019

Definition at line 1920 of file ww3_uprstr.F90.

1920  !/
1921  !/ +-----------------------------------+
1922  !/ | WAVEWATCH III NOAA/NCEP |
1923  !/ | Andy Saulter |
1924  !/ | FORTRAN 90 |
1925  !/ | Original code : 24-Oct-2018 |
1926  !/ | Last update : 05-Oct-2019 |
1927  !/ +-----------------------------------+
1928  !/
1929  !/ 24-Oct-2018 : Original Code ( version 6.07 )
1930  !/
1931  !/ Copyright 2010 National Weather Service (NWS),
1932  !/ National Oceanic and Atmospheric Administration. All rights
1933  !/ reserved. WAVEWATCH III is a trademark of the NWS.
1934  !/ No unauthorized use without permission.
1935  !/
1936  ! 1. Purpose :
1937  ! Updates the wind-sea part of the wave spectrum only
1938  ! 2. Method :
1939  !
1940  ! 3. Parameters :
1941  !
1942  ! Local parameters.
1943  ! ----------------------------------------------------------------
1944  !
1945  ! 4. Subroutines used :
1946  !
1947  ! ----------------------------------------------------------------
1948  ! Internal Subroutines:
1949  !
1950  ! 5. Called by :
1951  !
1952  ! 6. Error messages :
1953  !
1954  ! 7. Remarks :
1955  !
1956  ! 8. Structure :
1957  !
1958  ! 9. Switches :
1959  !
1960  ! !/T
1961  !
1962  ! 10. Source code :
1963  !
1964  !/
1965  REAL, DIMENSION(:), INTENT(INOUT) :: VATMP
1966  INTEGER, DIMENSION(:), INTENT(IN) :: VAMAPWS
1967  REAL, INTENT(IN) :: PRCNTG
1968  CHARACTER(25),PARAMETER :: myname='UPDTWSPEC'
1969  !
1970 #ifdef W3_T
1971  WRITE (ndso,*) trim(myname), ' starts'
1972 #endif
1973  DO ik=1, nk
1974  DO ith=1, nth
1975  IF ( vamapws(ith+(ik-1)*nth) .EQ. 1 ) THEN
1976  vatmp(ith+(ik-1)*nth) = vatmp(ith+(ik-1)*nth) * prcntg**2
1977  END IF
1978  END DO
1979  END DO
1980  !
1981 #ifdef W3_T
1982  WRITE (ndso,*) trim(myname), ' ends'
1983 #endif

Referenced by w3uprstr().

◆ updtwspecf()

subroutine w3uprstr::updtwspecf ( real, dimension(:), intent(inout)  VATMP,
real, intent(in)  PRCNTG,
integer, dimension(:), intent(in)  VAMAPWS,
integer, intent(in)  ISEA1p,
logical, intent(in)  ADJALL 
)

Updates the wind-sea part of the wave spectrum and shifts in frequency space.

Parameters
[in,out]VATMP
[in]PRCNTG
[in]VAMAPWS
[in]ISEA1p
[in]ADJALL
Author
Andy Saulter
Date
05-Oct-2019

Definition at line 2000 of file ww3_uprstr.F90.

2000  !/
2001  !/ +-----------------------------------+
2002  !/ | WAVEWATCH III NOAA/NCEP |
2003  !/ | Andy Saulter |
2004  !/ | FORTRAN 90 |
2005  !/ | Original code : 24-Oct-2018 |
2006  !/ | Last update : 05-Oct-2019 |
2007  !/ +-----------------------------------+
2008  !/
2009  !/ 24-Oct-2018 : Original Code ( version 6.07 )
2010  !/
2011  !/ Copyright 2010 National Weather Service (NWS),
2012  !/ National Oceanic and Atmospheric Administration. All rights
2013  !/ reserved. WAVEWATCH III is a trademark of the NWS.
2014  !/ No unauthorized use without permission.
2015  !/
2016  ! 1. Purpose :
2017  ! Updates the wind-sea part of the wave spectrum and shifts in frequency
2018  ! space
2019  ! 2. Method :
2020  !
2021  ! 3. Parameters :
2022  !
2023  ! Local parameters.
2024  ! ----------------------------------------------------------------
2025  !
2026  ! 4. Subroutines used :
2027  !
2028  ! ----------------------------------------------------------------
2029  ! Internal Subroutines:
2030  !
2031  ! 5. Called by :
2032  !
2033  ! 6. Error messages :
2034  !
2035  ! 7. Remarks :
2036  !
2037  ! 8. Structure :
2038  !
2039  ! 9. Switches :
2040  !
2041  ! !/T
2042  !
2043  ! 10. Source code :
2044  !
2045  !/
2046  REAL, DIMENSION(:), INTENT(INOUT) :: VATMP
2047  INTEGER, DIMENSION(:), INTENT(IN) :: VAMAPWS
2048  REAL, INTENT(IN) :: PRCNTG
2049  INTEGER, INTENT(IN) :: ISEA1p
2050  LOGICAL, INTENT(IN) :: ADJALL
2051  CHARACTER(25),PARAMETER :: myname='UPDTWSPECF'
2052  REAL :: FFAC, SIGSHFT, FDM1, FDM2, WN1, CG1, WN2, CG2
2053  INTEGER :: LPF, M1, M2
2054  REAL, ALLOCATABLE :: VASHFT(:)
2055  !
2056 #ifdef W3_T
2057  WRITE (ndso,*) trim(myname), ' starts'
2058 #endif
2059  depth = max( dmin , -zb(isea1p))
2060  ALLOCATE(vashft(SIZE(vatmp)))
2061  vashft(:) = 0.0
2062  !
2063  ! 1st iteration shifts wind-sea energy in freq space
2064  ffac = (1. / prcntg**2)**(1.0/3.0) ! uses Toba's relationship
2065  DO ik=1, nk
2066  CALL wavnu1(sig(ik), depth, wn, cg)
2067  sigshft = ffac * sig(ik)
2068  DO ith=1, nth
2069  IF ( vamapws(ith+(ik-1)*nth) .EQ. 1 ) THEN
2070  ! Interpolate frequency bin according to f-shift
2071  lpf = 1
2072  DO WHILE (lpf < nk)
2073  IF (sig(lpf) >= sigshft) THEN
2074  IF (lpf .EQ. 1) THEN
2075  CALL wavnu1(sig(lpf), depth, wn1, cg1)
2076  vashft(ith+(lpf-1)*nth) = vashft(ith+(lpf-1)*nth) + &
2077  vatmp(ith+(ik-1)*nth) * &
2078  (dsip(ik)*sig(ik)/cg) / &
2079  (dsip(lpf)*sig(lpf)/cg1)
2080  ELSE
2081  m2 = lpf
2082  m1 = lpf - 1
2083  fdm1 = sigshft - sig(m1)
2084  fdm2 = sig(m2) - sig(m1)
2085  CALL wavnu1(sig(m1), depth, wn1, cg1)
2086  CALL wavnu1(sig(m2), depth, wn2, cg2)
2087  vashft(ith+(m1-1)*nth) = vashft(ith+(m1-1)*nth) + &
2088  (fdm1 / fdm2) * &
2089  vatmp(ith+(ik-1)*nth) * &
2090  (dsip(ik)*sig(ik)/cg) / &
2091  (dsip(m1)*sig(m1)/cg1)
2092  vashft(ith+(m2-1)*nth) = vashft(ith+(m2-1)*nth) + &
2093  (1.0 - fdm1 / fdm2) * &
2094  vatmp(ith+(ik-1)*nth) * &
2095  (dsip(ik)*sig(ik)/cg) / &
2096  (dsip(m2)*sig(m2)/cg2)
2097  END IF
2098  lpf = nk + 1
2099  ENDIF
2100  lpf = lpf + 1
2101  END DO
2102  IF (lpf .EQ. nk) THEN
2103  CALL wavnu1(sig(lpf), depth, wn1, cg1)
2104  vashft(ith+(lpf-1)*nth) = vashft(ith+(lpf-1)*nth) + &
2105  vatmp(ith+(ik-1)*nth) * &
2106  (dsip(ik)*sig(ik)/cg) / &
2107  (dsip(lpf)*sig(lpf)/cg1)
2108  END IF
2109  END IF
2110  END DO
2111  END DO
2112  ! 2nd iteration scales wind-sea energy
2113  DO ik=1, nk
2114  DO ith=1, nth
2115  IF ( vamapws(ith+(ik-1)*nth) .EQ. 1 ) THEN
2116  vashft(ith+(ik-1)*nth) = vashft(ith+(ik-1)*nth) * prcntg**2
2117  END IF
2118  END DO
2119  END DO
2120  ! 3rd iteration combines wind-sea and swell energy
2121  DO ik=1, nk
2122  DO ith=1, nth
2123  IF ( vamapws(ith+(ik-1)*nth) .EQ. 1 ) THEN
2124  vatmp(ith+(ik-1)*nth) = vashft(ith+(ik-1)*nth)
2125  ELSE
2126  IF ( adjall ) THEN
2127  ! Swell components are also re-scaled
2128  vatmp(ith+(ik-1)*nth) = vatmp(ith+(ik-1)*nth) * &
2129  prcntg**2 + &
2130  vashft(ith+(ik-1)*nth)
2131  ELSE
2132  ! Re-scaling wind-sea only
2133  vatmp(ith+(ik-1)*nth) = vatmp(ith+(ik-1)*nth) + &
2134  vashft(ith+(ik-1)*nth)
2135  END IF
2136  END IF
2137  END DO
2138  END DO
2139  !
2140  DEALLOCATE(vashft)
2141  !
2142 #ifdef W3_T
2143  WRITE (ndso,*) trim(myname), ' ends'
2144 #endif

Referenced by w3uprstr().

◆ uvtocart()

subroutine w3uprstr::uvtocart ( real, dimension(:,:), intent(in)  UVEC,
real, dimension(:,:), intent(in)  VVEC,
real, dimension(:,:), intent(out)  SPD,
real, dimension(:,:), intent(out)  DCART,
logical, intent(in)  SMCGRD 
)

Calculate speed and cartesian convention directions from u,v input vectors.

Parameters
[in]UVEC
[in]VVEC
[out]SPD
[out]DCART
[in]SMCGRD
Author
Andy Saulter
Date
05-Oct-2019

Definition at line 1828 of file ww3_uprstr.F90.

1828  !/
1829  !/ +-----------------------------------+
1830  !/ | WAVEWATCH III NOAA/NCEP |
1831  !/ | Andy Saulter |
1832  !/ | FORTRAN 90 |
1833  !/ | Original code : 05-Oct-2019 |
1834  !/ +-----------------------------------+
1835  !/
1836  !/ 05-Oct-2019 : Original Code ( version 6.07 )
1837  !/
1838  !/ Copyright 2010 National Weather Service (NWS),
1839  !/ National Oceanic and Atmospheric Administration. All rights
1840  !/ reserved. WAVEWATCH III is a trademark of the NWS.
1841  !/ No unauthorized use without permission.
1842  !/
1843  ! 1. Purpose :
1844  ! Calculate speed and cartesian convention directions from u,v
1845  ! input vectors
1846  ! 2. Method :
1847  !
1848  ! 3. Parameters :
1849  !
1850  ! Local parameters.
1851  ! ----------------------------------------------------------------
1852  !
1853  ! 4. Subroutines used :
1854  !
1855  ! ----------------------------------------------------------------
1856  ! Internal Subroutines:
1857  !
1858  ! 5. Called by :
1859  !
1860  ! 6. Error messages :
1861  !
1862  ! 7. Remarks :
1863  !
1864  ! 8. Structure :
1865  !
1866  ! 9. Switches :
1867  !
1868  ! !/T
1869  !
1870  ! 10. Source code :
1871  !
1872  !/
1873  USE constants, ONLY: tpi
1874  !
1875  REAL, DIMENSION(:,:), INTENT(OUT) :: SPD, DCART
1876  REAL, DIMENSION(:,:), INTENT(IN) :: UVEC, VVEC
1877  LOGICAL, INTENT(IN) :: SMCGRD
1878  !
1879 #ifdef W3_T
1880  WRITE (ndso,*) trim(myname), ' starts'
1881 #endif
1882  !
1883  DO isea=1, nsea, 1
1884  IF (.NOT. smcgrd) THEN
1885  ix = mapsf(isea,1)
1886  iy = mapsf(isea,2)
1887 #ifdef W3_SMC
1888  ELSE
1889  ix = 1
1890  iy = isea
1891 #endif
1892  ENDIF
1893  !
1894  spd(iy,ix) = sqrt( uvec(iy,ix)**2 + vvec(iy,ix)**2 )
1895  IF( spd(iy,ix) .GT. 1.e-7) THEN
1896  dcart = mod( tpi+atan2(uvec(iy,ix),vvec(iy,ix)) , tpi )
1897  ELSE
1898  dcart = 0
1899  END IF
1900  spd(iy,ix) = max( spd(iy,ix) , 0.001 )
1901  END DO
1902  !
1903 #ifdef W3_T
1904  WRITE (ndso,*) trim(myname), ' ends'
1905 #endif

References constants::tpi.

Referenced by w3uprstr().

◆ w3uprstr()

program w3uprstr

Update restart files based on Hs from DA.

Update the WAVEWATCH III restart files based on the significant wave height analysis from any data assimilation system.

The W3UPRSTR is the intermediator between the background WW3 and the analysis of the wave field, it modifies the original restart file according to the analysis. For the wave modeling and DA, the ww3_uprstr program applies the operator from the diagnostic to the prognostic variable.

Author
Stelios Flampouris
Date
16-Feb-2017

Definition at line 22 of file ww3_uprstr.F90.

References check_prcntg(), w3gdatmd::dmin, w3gdatmd::dsip, w3gdatmd::dth, w3servmd::extcde(), file(), w3odatmd::fnmpre, w3gdatmd::fswnd, w3gdatmd::gname, w3gdatmd::gtype, w3odatmd::iaproc, w3odatmd::idout, w3servmd::itrace(), w3gdatmd::mapsf, w3gdatmd::mapsta, w3odatmd::naperr, w3odatmd::naplog, w3odatmd::napout, w3odatmd::nds, w3odatmd::ndse, w3odatmd::ndso, w3odatmd::ndst, w3servmd::nextln(), w3gdatmd::nk, w3gdatmd::nsea, w3gdatmd::nseal, w3adatmd::nsealm, w3gdatmd::nth, w3gdatmd::nx, w3gdatmd::ny, read_grbtxt(), read_grbtxtws(), w3gdatmd::rstype, w3gdatmd::sig, w3gdatmd::smctype, swh_rsrt_1p(), swh_rsrt_1pw(), w3wdatmd::time, update_va(), updtwspec(), updtwspecf(), uvtocart(), w3wdatmd::va, w3iogrmd::w3iogr(), w3iorsmd::w3iors(), w3adatmd::w3naux(), w3wdatmd::w3ndat(), w3idatmd::w3ninp(), w3nmluprstrmd::w3nmluprstr(), w3gdatmd::w3nmod(), w3odatmd::w3nout(), w3adatmd::w3seta(), w3gdatmd::w3setg(), w3idatmd::w3seti(), w3odatmd::w3seto(), w3wdatmd::w3setw(), w3dispmd::wavnu1(), writematrix(), and w3gdatmd::zb.

◆ writematrix()

subroutine w3uprstr::writematrix ( character(*), intent(in)  FILENAME,
real, dimension(:, :), intent(in)  RDA_A 
)

Writes a 2D array to text file, column by column.

Parameters
[in,out]FILENAMEPath to the output file.
[in,out]RDA_A2D array to write.
Author
Stelios Flampouris
Date
15-Mar-2017

Definition at line 2157 of file ww3_uprstr.F90.

2157  !/
2158  !/ +-----------------------------------+
2159  !/ | WAVEWATCH III NOAA/NCEP |
2160  !/ | Stelios Flampouris |
2161  !/ | FORTRAN 90 |
2162  !/ | Last update : 15-Mar-2017 |
2163  !/ +-----------------------------------+
2164  !/
2165  !/ 15-Mar-2017 : Original Code ( version 6.04 )
2166  !/
2167  !/ Copyright 2010 National Weather Service (NWS),
2168  !/ National Oceanic and Atmospheric Administration. All rights
2169  !/ reserved. WAVEWATCH III is a trademark of the NWS.
2170  !/ No unauthorized use without permission.
2171  !/
2172  ! 1. Purpose :
2173  ! Writes a 2D array to text file, column by column
2174  ! 2. Method :
2175  !
2176  ! 3. Parameters :
2177  ! fileName path to the output file
2178  ! rda_A 2D array to write
2179  !
2180  ! Local parameters.
2181  ! ----------------------------------------------------------------
2182  !
2183  ! 4. Subroutines used :
2184  !
2185  ! ----------------------------------------------------------------
2186  ! Internal Subroutines:
2187  !
2188  ! 5. Called by :
2189  ! Any routine that has to write 2d arrays !?!
2190  !
2191  ! 6. Error messages :
2192  !
2193  ! 7. Remarks :
2194  !
2195  ! 8. Structure :
2196  !
2197  ! 9. Switches :
2198  !
2199  ! !/T
2200  !
2201  ! 10. Source code :
2202  !
2203  !/
2204  REAL, DIMENSION(:, :), INTENT(IN) :: RDA_A
2205  CHARACTER(*) , INTENT(IN) :: FILENAME
2206  INTEGER IB_I, IB_J, IL_IOS
2207  INTEGER, PARAMETER :: IP_FID = 123
2208  !
2209  OPEN( unit = ip_fid, file = filename, status = 'REPLACE', &
2210  form = 'FORMATTED', iostat = il_ios)
2211  IF (il_ios /= 0) print*,'In writeMatrix : Error creating file'//filename
2212  DO ib_j = 1, SIZE(rda_a,2)
2213  DO ib_i = 1, SIZE(rda_a,1)
2214  ! write(unit=ip_fid, fmt='(I, $)') rda_A(ib_i,ib_j)
2215  WRITE(unit=ip_fid, fmt='(E18.8, $)') rda_a(ib_i,ib_j)
2216  END DO
2217  WRITE(unit=ip_fid, fmt=*)''
2218  END DO
2219  CLOSE(ip_fid)
2220  !

References file().

Referenced by w3uprstr().

w3adatmd::cg
real, dimension(:,:), pointer cg
Definition: w3adatmd.F90:575
w3gdatmd::th
real, dimension(:), pointer th
Definition: w3gdatmd.F90:1234
w3odatmd
Definition: w3odatmd.F90:3
file
file(STRINGS ${CMAKE_BINARY_DIR}/switch switch_strings) separate_arguments(switches UNIX_COMMAND $
Definition: CMakeLists.txt:3
w3odatmd::wsmult
real, pointer wsmult
Definition: w3odatmd.F90:553
w3adatmd::wn
real, dimension(:,:), pointer wn
Definition: w3adatmd.F90:575
constants::tpi
real, parameter tpi
TPI 2*Pi.
Definition: constants.F90:72
constants
Define some much-used constants for global use (all defined as PARAMETER).
Definition: constants.F90:20
w3gdatmd
Definition: w3gdatmd.F90:16