362 INTEGER :: ndsi, ndsm, ndstrc, ntrace, ierr, i, j
363 CHARACTER :: comstr*1
370 LOGICAL :: anl_exists, corwsea, flgnml
371 INTEGER :: imod, ndsen, ix, iy, ik, ith, &
373 REAL,
ALLOCATABLE :: updprcnt(:,:),vatmp(:), hsig(:,:), &
374 a(:), hs_anal(:,:), gues(:,:), &
375 hs_dif(:,:),swhanl(:,:), swhbckg(:,:), &
376 swhuprstr(:,:),vatmp_norm(:), &
377 wsbckg(:,:),wdrbckg(:,:)
378 INTEGER,
ALLOCATABLE :: vamapws(:)
379 REAL :: prcntg, prcntg_cap, thrwsea
380 INTEGER :: rows, cols, isea
381 CHARACTER(128) :: flnmcor, flnmanl
382 CHARACTER(16) :: updproc
384 REAL :: swhtmp,swhbckg_1, swhanl_1, &
385 depth, wn, cg, etot, e1i, &
386 swhtmp1,sumvatmp, swhbckg_w, swhbckg_s
388 CHARACTER(8),
PARAMETER :: myname=
'W3UPRSTR'
389 LOGICAL :: smcgrd = .false.
390 LOGICAL :: smcwnd = .false.
391 LOGICAL :: wrston = .false.
396 CALL w3nmod ( 1, 6, 6 )
397 CALL w3setg ( 1, 6, 6 )
399 CALL w3setw ( 1, 6, 6 )
401 CALL w3seta ( 1, 6, 6 )
403 CALL w3seto ( 1, 6, 6 )
421 CALL itrace ( ndstrc, ntrace )
423 IF ( iaproc .EQ. naperr )
THEN
434 WRITE (
ndso,*)
'*** UPRSTR will read wind from restart files'
442 INQUIRE(
file=trim(
fnmpre)//
"ww3_uprstr.nml", exist=flgnml)
447 READ(nml_restart%RESTARTTIME, *)
time
448 updproc = nml_update%UPDPROC
449 prcntg = nml_update%PRCNTG
450 prcntg_cap = nml_update%PRCNTGCAP
451 thrwsea = nml_update%THRWSEA
452 flnmanl = nml_update%FILE
456 IF (.NOT. flgnml)
THEN
458 OPEN (ndsi,
file=
fnmpre(:j)//
'ww3_uprstr.inp',status=
'OLD', &
460 READ (ndsi,
'(A)',
END=801,ERR=802) comstr
461 IF (comstr.EQ.
' ') comstr =
'$'
462 WRITE (ndso,901) comstr
464 CALL nextln ( comstr , ndsi , ndsen )
465 READ (ndsi,*,
END=2001,ERR=2002) time
466 CALL nextln ( comstr , ndsi , ndsen )
467 READ (ndsi,*,
END=2001,ERR=2002) updproc
468 CALL nextln ( comstr , ndsi , ndsen )
469 IF (updproc .EQ.
'UPD0F')
THEN
470 READ (ndsi,*,
END=2001,ERR=2002) prcntg
472 IF ((updproc .EQ.
'UPD2') .OR. (updproc .EQ.
'UPD3'))
THEN
474 READ (ndsi,*,
END=2001,ERR=2002) prcntg_cap
476 CALL nextln ( comstr , ndsi , ndsen )
477 READ (ndsi,*,
END=2001,ERR=2002) flnmcor
480 READ (ndsi,*,
END=2001,ERR=2002) PRCNTG_CAP, thrwsea
482 CALL nextln ( comstr , ndsi , ndsen )
483 READ (ndsi,*,
END=2001,ERR=2002) flnmanl
487 WRITE (ndso,*)
' TIME: ',time
493 CALL w3iogr (
'READ', ndsm )
495 WRITE (ndso,920) gname
499 IF( gtype .EQ. smctype ) smcgrd = .true.
501 IF( fswnd ) smcwnd = .true.
509 WRITE (ndso,*)
'*** UPRSTR set to work with SMC grid model'
518 CALL w3dimi ( 1, 6, 6 )
520 CALL w3iors (
'READ', nds(6), sig(nk), imod )
521 IF ( iaproc .EQ. naplog )
THEN
522 IF (rstype.EQ.0.OR.rstype.EQ.1.OR.rstype.EQ.4)
THEN
523 WRITE (ndso,1004)
'Terminating ww3_uprstr: The restart ' // &
527 WRITE (ndso,1004)
' Updating Restart File'
528 WRITE (ndso,*)
' TIME: ',time
532 WRITE (ndst,*), myname,
' : Exporting VA as imported to VA01.txt'
539 SELECT CASE (updproc)
545 WRITE (ndso,902)
'UPD0F'
546 WRITE (ndso,1005)
' PRCNTG = ',prcntg
548 ALLOCATE( vatmp(
SIZE(va ,1) ))
549 ALLOCATE( swhanl(
SIZE(mapsta,1),
SIZE(mapsta,2)))
550 ALLOCATE( swhbckg(
SIZE(mapsta,1),
SIZE(mapsta,2)))
558 swhbckg(iy,ix)=swhbckg_1
564 swhanl(iy,ix)=swhanl_1
565 WRITE (ndso,*)
' =========== UPD0F Output ==========='
566 WRITE (ndso,*)
'ISEA = ', isea,
' PRCNTG = ',prcntg, &
567 ' SWHBCKG = ',swhbckg(iy,ix), &
568 ' SWHANL= ', swhanl(iy,ix)
572 CALL writematrix(
'SWHBCKG_UPD0F.txt', real(swhbckg))
573 CALL writematrix(
'SWHANL_UPD0F.txt' , real(swhanl ))
574 CALL writematrix(
'SWHRSTR_UPD0F.txt', real(swhanl ))
576 DEALLOCATE ( vatmp, swhbckg, swhanl )
585 WRITE (ndso,902)
'UPD2'
586 WRITE (ndso,1005)
' PRCNTG_CAP = ',prcntg_cap
587 WRITE (ndso,1006)
' Reading updated SWH from: ',trim(flnmanl)
590 ALLOCATE ( vatmp(
SIZE(va,1)))
591 IF (.NOT. smcgrd)
THEN
592 ALLOCATE( swhbckg(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
593 ALLOCATE( swhanl(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
596 ALLOCATE( swhbckg(nsea,1) )
597 ALLOCATE( swhanl(nsea,1) )
601 IF (.NOT. smcgrd)
THEN
602 ALLOCATE( swhuprstr(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
604 ALLOCATE( swhuprstr(nsea,1) )
609 INQUIRE(
file=flnmanl, exist=anl_exists)
612 WRITE (ndso,*)
'shape(SWHANL)', shape(swhanl)
619 WRITE (ndso,*) trim(flnmanl),
' does not exist, stopping...'
620 DEALLOCATE( swhanl,vatmp,swhbckg )
622 DEALLOCATE( swhuprstr )
629 IF (.NOT. smcgrd)
THEN
640 swhbckg(iy,ix)=swhbckg_1
642 IF ( swhbckg(iy,ix) > 0.01 .AND. swhanl(iy,ix) > 0.01 )
THEN
643 prcntg=(swhanl(iy,ix)/swhbckg_1)
645 WRITE (ndso,*)
'ISEA = ', isea,
' IX = ',ix,
' IY = ', iy, &
646 ' PRCNTG = ',prcntg,
' SWHBCKG = ',swhbckg(iy,ix), &
647 ' SWHANL = ', swhanl(iy,ix)
652 CALL swh_rsrt_1p (va(:,isea), isea, swhuprstr(iy,ix))
653 WRITE (ndso,*)
' =========== UPD2 Output ==========='
654 WRITE (ndso,*)
'ISEA = ',isea, &
655 'SWH_BCKG = ', swhbckg(iy,ix), &
656 'SWH_ANL = ', swhanl(iy,ix), &
657 'PRCNTG = ', prcntg, &
658 'SWH_RSTR = ',swhuprstr(iy,ix)
663 CALL writematrix(
'SWHBCKG_UPD2.txt', real(swhbckg ))
664 CALL writematrix(
'SWHANL_UPD2.txt' , real(swhanl ))
665 CALL writematrix(
'SWHRSTR_UPD2.txt', real(swhuprstr))
668 DEALLOCATE( swhanl,vatmp,swhbckg )
670 DEALLOCATE( swhuprstr )
679 WRITE (ndso,902)
'UPD3'
680 WRITE (ndso,1005)
' PRCNTG_CAP = ',prcntg_cap
681 WRITE (ndso,1006)
' Reading updated SWH from: ',trim(flnmanl)
684 ALLOCATE ( vatmp(
SIZE(va,1)))
685 ALLOCATE ( vatmp_norm(
SIZE(va,1)))
686 ALLOCATE ( a(
SIZE(va,1)))
687 IF (.NOT. smcgrd)
THEN
688 ALLOCATE( swhbckg(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
689 ALLOCATE( swhanl(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
692 ALLOCATE( swhbckg(nsea,1) )
693 ALLOCATE( swhanl(nsea,1) )
697 IF (.NOT. smcgrd)
THEN
698 ALLOCATE( swhuprstr(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
700 ALLOCATE( swhuprstr(nsea,1) )
705 INQUIRE(
file=flnmanl, exist=anl_exists)
708 WRITE (ndso,*)
'shape(SWHANL)', shape(swhanl)
715 WRITE (ndso,*) trim(flnmanl),
' does not exist, stopping...'
716 DEALLOCATE( swhanl,vatmp,swhbckg,vatmp_norm,a )
718 DEALLOCATE( swhuprstr )
725 IF (.NOT. smcgrd)
THEN
736 swhbckg(iy,ix)=swhbckg_1
738 IF ( swhbckg(iy,ix) > 0.01 .AND. swhanl(iy,ix) > 0.01 )
THEN
740 prcntg=(swhanl(iy,ix)/swhbckg_1)
742 WRITE (ndso,*)
' =========== Step 1. ==========='
743 WRITE (ndso,*)
' ISEA = ', isea,
' IX = ',ix,
' IY = ', iy, &
744 ' PRCNTG = ',prcntg,
' SWHBCKG = ',swhbckg(iy,ix), &
745 ' SWHANL = ', swhanl(iy,ix)
748 vatmp_norm=vatmp/sum(vatmp)
750 WRITE (ndso,*)
' ISEA =', isea,
' IX = ',ix,
' IY = ', iy, &
751 ' PRCNTG = ',prcntg, &
752 ' SWHBCKG = ',swhbckg(iy,ix),
' SWHANL = ', swhanl(iy,ix)
754 IF (prcntg > 1.)
THEN
755 a=prcntg**2*(1 + vatmp_norm)
757 a=prcntg**2*(1 - vatmp_norm)
761 prcntg=(swhanl(iy,ix)/swhtmp)
763 swhuprstr(iy,ix)=swhtmp
764 WRITE (ndso,*)
' =========== Step 2. ==========='
765 WRITE (ndso,*)
'ISEA = ', isea,
' PRCNTG = ',prcntg, &
766 ' SWHANL= ', swhanl(iy,ix), &
767 ' SWHUPRSTR(IY,IX) = ', swhuprstr(iy,ix)
774 swhuprstr(iy,ix)=swhtmp
775 WRITE (ndso,*)
' =========== UPD3 Output ==========='
776 WRITE (ndso,*)
'ISEA = ',isea,
'SWH_BCKG = ', swhbckg(iy,ix), &
777 'SWH_ANL = ', swhanl(iy,ix), &
778 'SWH_RSTR = ',swhuprstr(iy,ix)
783 CALL writematrix(
'SWHBCKG_UPD3.txt', real(swhbckg))
784 CALL writematrix(
'SWHANL_UPD3.txt' , real(swhanl ))
785 CALL writematrix(
'SWHRSTR_UPD3.txt', real(swhuprstr))
788 DEALLOCATE( swhanl,vatmp,swhbckg,vatmp_norm,a )
790 DEALLOCATE( swhuprstr )
800 WRITE (ndso,902)
'UPD5'
801 WRITE (ndso,1005)
' PRCNTG_CAP = ',prcntg_cap
802 WRITE (ndso,1005)
' THRWSEA = ',thrwsea
803 WRITE (ndso,1006)
' Reading updated SWH from: ',trim(flnmanl)
809 ALLOCATE ( vatmp(
SIZE(va,1)))
810 ALLOCATE ( vamapws(
SIZE(va,1)))
811 IF (.NOT. smcgrd)
THEN
813 ALLOCATE( swhbckg(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
814 ALLOCATE( swhanl(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
816 ALLOCATE( wsbckg(
SIZE(mapsta,2),
SIZE(mapsta,1)) )
817 ALLOCATE( wdrbckg(
SIZE(mapsta,2),
SIZE(mapsta,1)) )
820 ALLOCATE( swhbckg(nsea,1) )
821 ALLOCATE( swhanl(nsea,1) )
824 ALLOCATE( wsbckg(nsea,1) )
825 ALLOCATE( wdrbckg(nsea,1) )
827 ALLOCATE(wsbckg(
SIZE(mapsta,2),
SIZE(mapsta,1)))
828 ALLOCATE(wdrbckg(
SIZE(mapsta,2),
SIZE(mapsta,1)))
833 IF (.NOT. smcgrd)
THEN
834 ALLOCATE( swhuprstr(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
836 ALLOCATE( swhuprstr(nsea,1) )
841 INQUIRE(
file=flnmanl, exist=anl_exists)
844 WRITE (ndso,*)
'shape(SWHANL)', shape(swhanl)
861 WRITE (ndso,*) trim(flnmanl),
' does not exist, stopping...'
862 DEALLOCATE( swhanl,vatmp,swhbckg,vamapws,wsbckg,wdrbckg )
864 DEALLOCATE( swhuprstr )
873 CALL uvtocart(wxnwrst,wynwrst,wsbckg,wdrbckg,smcwnd)
878 IF (.NOT. smcgrd)
THEN
900 CALL swh_rsrt_1pw (vatmp, wsbckg(ixw,iyw), wdrbckg(ixw,iyw), isea, &
901 swhbckg_1, swhbckg_w, swhbckg_s, vamapws)
902 swhbckg(iy,ix)=swhbckg_1
904 IF ( swhbckg(iy,ix) > 0.01 .AND. swhanl(iy,ix) > 0.01 )
THEN
907 IF ( (swhbckg_w / swhbckg_1)**2.0 > thrwsea )
THEN
909 prcntg=sqrt((swhanl(iy,ix)**2.0-swhbckg_s**2.0)/swhbckg_w**2.0)
914 prcntg=(swhanl(iy,ix)/swhbckg_1)
919 WRITE (ndso,*)
'ISEA = ', isea,
' IX = ',ix,
' IY = ', iy, &
920 ' PRCNTG = ',prcntg,
' SWHBCKG = ',swhbckg(iy,ix), &
921 ' SWHANL = ', swhanl(iy,ix)
926 swhuprstr(iy,ix)=swhtmp
927 WRITE (ndso,*)
' =========== UPD5 Output ==========='
928 WRITE (ndso,*)
'ISEA = ',isea,
'SWH_BCKG = ', swhbckg(iy,ix), &
929 'SWH_ANL = ', swhanl(iy,ix), &
930 'SWH_RSTR = ',swhuprstr(iy,ix)
935 CALL writematrix(
'SWHBCKG_UPD5.txt', real(swhbckg ))
936 CALL writematrix(
'SWHANL_UPD5.txt' , real(swhanl ))
937 CALL writematrix(
'SWHRSTR_UPD5.txt', real(swhuprstr))
940 DEALLOCATE( swhanl,vatmp,swhbckg,vamapws,wsbckg,wdrbckg )
942 DEALLOCATE( swhuprstr )
953 WRITE (ndso,902)
'UPD6'
954 WRITE (ndso,1005)
' PRCNTG_CAP = ',prcntg_cap
955 WRITE (ndso,1005)
' THRWSEA = ',thrwsea
956 WRITE (ndso,1006)
' Reading updated SWH from: ',trim(flnmanl)
963 ALLOCATE ( vatmp(
SIZE(va,1)))
964 ALLOCATE ( vamapws(
SIZE(va,1)))
965 IF (.NOT. smcgrd)
THEN
967 ALLOCATE( swhbckg(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
968 ALLOCATE( swhanl(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
970 ALLOCATE( wsbckg(
SIZE(mapsta,2),
SIZE(mapsta,1)) )
971 ALLOCATE( wdrbckg(
SIZE(mapsta,2),
SIZE(mapsta,1)) )
974 ALLOCATE( swhbckg(nsea,1) )
975 ALLOCATE( swhanl(nsea,1) )
978 ALLOCATE( wsbckg(nsea,1) )
979 ALLOCATE( wdrbckg(nsea,1) )
981 ALLOCATE(wsbckg(
SIZE(mapsta,2),
SIZE(mapsta,1)))
982 ALLOCATE(wdrbckg(
SIZE(mapsta,2),
SIZE(mapsta,1)))
987 IF (.NOT. smcgrd)
THEN
988 ALLOCATE( swhuprstr(
SIZE(mapsta,1),
SIZE(mapsta,2)) )
990 ALLOCATE( swhuprstr(nsea,1) )
995 INQUIRE(
file=flnmanl, exist=anl_exists)
998 WRITE (ndso,*)
'shape(SWHANL)', shape(swhanl)
1015 WRITE (ndso,*) trim(flnmanl),
' does not exist, stopping...'
1016 DEALLOCATE( swhanl,vatmp,swhbckg,vamapws,wsbckg,wdrbckg )
1018 DEALLOCATE( swhuprstr )
1027 CALL uvtocart(wxnwrst,wynwrst,wsbckg,wdrbckg,smcwnd)
1032 IF (.NOT. smcgrd)
THEN
1054 CALL swh_rsrt_1pw (vatmp, wsbckg(ixw,iyw), wdrbckg(ixw,iyw), isea, &
1055 swhbckg_1, swhbckg_w, swhbckg_s, vamapws)
1056 swhbckg(iy,ix)=swhbckg_1
1058 IF ( swhbckg(iy,ix) > 0.01 .AND. swhanl(iy,ix) > 0.01 )
THEN
1061 IF ( (swhbckg_w / swhbckg_1)**2.0 > thrwsea )
THEN
1063 prcntg=sqrt((swhanl(iy,ix)**2.0-swhbckg_s**2.0)/swhbckg_w**2.0)
1065 CALL updtwspecf(vatmp, prcntg, vamapws, isea, .false.)
1068 prcntg=(swhanl(iy,ix)/swhbckg_1)
1072 CALL updtwspecf(vatmp, prcntg, vamapws, isea, .true.)
1079 WRITE (ndso,*)
'ISEA = ', isea,
' IX = ',ix,
' IY = ', iy, &
1080 ' PRCNTG = ',prcntg,
' SWHBCKG = ',swhbckg(iy,ix), &
1081 ' SWHANL = ', swhanl(iy,ix)
1086 swhuprstr(iy,ix)=swhtmp
1087 WRITE (ndso,*)
' =========== UPD6 Output ==========='
1088 WRITE (ndso,*)
'ISEA = ',isea,
'SWH_BCKG = ', swhbckg(iy,ix), &
1089 'SWH_ANL = ', swhanl(iy,ix), &
1090 'SWH_RSTR = ',swhuprstr(iy,ix)
1095 CALL writematrix(
'SWHBCKG_UPD6.txt', real(swhbckg ))
1096 CALL writematrix(
'SWHANL_UPD6.txt' , real(swhanl ))
1097 CALL writematrix(
'SWHRSTR_UPD6.txt', real(swhuprstr))
1100 DEALLOCATE( swhanl,vatmp,swhbckg,vamapws,wsbckg,wdrbckg )
1102 DEALLOCATE( swhuprstr )
1120 CALL w3iors (
'HOT', nds(6), sig(nk), 1 )
1122 WRITE (ndst,*), myname,
' : Exporting VA at the end of the re-analysis'
1133 WRITE (ndse,1000) ierr
1141 WRITE (ndse,1002) ierr
1153 IF ( iaproc .EQ. naperr )
WRITE (ndse,1001)
1157 IF ( iaproc .EQ. naperr )
WRITE (ndse,1002) ierr
1165 900
FORMAT (/15x,
' *** WAVEWATCH III ww3_uprstr Initializing *** '/ &
1166 15x,
' ==============================================='/)
1167 901
FORMAT (
' Comment character is ''',a,
''''/)
1169 902
FORMAT (
' The Option ''',a,
''' is used.'/)
1171 903
FORMAT (
' Exporting the Updated Restart file to "restart001.ww3"'/)
1173 920
FORMAT (
' Grid name : ',a/)
1175 930
FORMAT (/
' Time interval : '/ &
1176 ' --------------------------------------------------')
1178 931
FORMAT (
' Starting time : ',a)
1180 932
FORMAT (
' Ending time : ',a/)
1182 999
FORMAT (/
' End of program '/ &
1183 ' ========================================='/ &
1184 ' WAVEWATCH III ww3_uprstr '/)
1186 1000
FORMAT (/
' *** WAVEWATCH III ERROR IN W3UPRSTR : '/ &
1187 ' ERROR IN OPENING INPUT FILE'/ &
1190 1001
FORMAT (/
' *** WAVEWATCH III ERROR IN W3UPRSTR : '/ &
1191 ' PREMATURE END OF INPUT FILE'/)
1193 1002
FORMAT (/
' *** WAVEWATCH III ERROR IN W3UPRSTR : '/ &
1194 ' ERROR IN READING FROM INPUT FILE'/ &
1196 1004
FORMAT (/
' '/,a/)
1197 1005
FORMAT (
' ',a, f6.3/)
1198 1006
FORMAT (
' ',a, a/)
1259 REAL,
INTENT(IN) :: PRCNTG
1260 REAL,
DIMENSION(:),
INTENT(INOUT) :: VATMP
1262 vatmp = (prcntg**2)*vatmp
1323 REAL,
INTENT(INOUT) :: PRCNTG
1324 REAL,
INTENT(IN ) :: PRCNTG_CAP
1326 CHARACTER(12),
PARAMETER :: MYNAME=
'CHECK_PRCNTG'
1329 WRITE (ndso,*) trim(myname),
" The original correction is ",prcntg
1330 WRITE (ndso,*) trim(myname),
" The cap is ",prcntg_cap
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"
1337 WRITE (ndso,*) trim(myname),
" The cap is ",prcntg_cap
1339 IF ( prcntg > 1. )
THEN
1341 WRITE (ndso,*) trim(myname),
" PRCNTG > 1."
1343 prcntg = min(prcntg, 1. * prcntg_cap)
1344 ELSE IF ( prcntg < 1. )
THEN
1346 WRITE (ndso,*) trim(myname),
" PRCNTG < 1."
1348 prcntg = max(prcntg, 1. / prcntg_cap)
1354 WRITE (ndso,*) trim(myname),
" The updated correction is ",prcntg
1415 REAL,
DIMENSION(:,:),
INTENT(OUT) :: UPDPRCNT
1416 CHARACTER(*),
INTENT(IN) :: FLNMCOR
1417 LOGICAL,
INTENT(IN) :: SMCGRD
1419 INTEGER :: I, J, IERR
1420 INTEGER :: K, L, M, N
1422 INTEGER,
PARAMETER :: IP_FID = 123
1423 CHARACTER(25),
PARAMETER::myname=
'read_grbtxt'
1426 WRITE (ndso,*) trim(myname),
' starts'
1428 j = len_trim(fnmpre)
1429 OPEN (ip_fid,
file=fnmpre(:j)//trim(flnmcor),status=
'OLD' &
1430 ,action=
'read',iostat=ierr)
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
1443 IF (
SIZE(updprcnt,1) /= n )
THEN
1444 WRITE (ndso,*) trim(myname),
': These are not the grid ' // &
1453 IF (.NOT. smcgrd)
THEN
1474 WRITE (ndso,*) trim(myname),
' ends'
1537 REAL,
DIMENSION(:,:),
INTENT(OUT) :: UPDPRCNT, WSPD, WDIR
1538 CHARACTER(*),
INTENT(IN) :: FLNMCOR
1539 LOGICAL,
INTENT(IN) :: SMCGRD
1541 INTEGER :: I, J, IERR
1542 INTEGER :: K, L, M, N
1544 INTEGER,
PARAMETER :: IP_FID = 123
1545 CHARACTER(25),
PARAMETER::myname=
'read_grbtxt'
1548 WRITE (ndso,*) trim(myname),
' starts'
1550 j = len_trim(fnmpre)
1551 OPEN (ip_fid,
file=fnmpre(:j)//trim(flnmcor),status=
'OLD' &
1552 ,action=
'read',iostat=ierr)
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
1565 IF (
SIZE(updprcnt,1) /= n )
THEN
1566 WRITE (ndso,*) trim(myname),
': These are not the grid ' // &
1577 IF (.NOT. smcgrd)
THEN
1583 READ(ip_fid,*)a, ws, wd
1595 READ(ip_fid,*)a, ws, wd
1607 WRITE (ndso,*) trim(myname),
' ends'
1665 REAL,
INTENT(OUT) :: HSIG1p
1666 INTEGER,
INTENT(IN) :: ISEA1p
1667 REAL,
DIMENSION(:),
INTENT(IN) :: VA1p
1668 CHARACTER(25),
PARAMETER :: myname=
'SWH_RSRT_1p'
1672 WRITE (ndso,*) trim(myname),
' starts'
1675 depth = max( dmin , -zb(isea1p) )
1679 CALL wavnu1 ( sig(ik), depth, wn, cg )
1682 e1i = e1i + va1p(ith+(ik-1)*nth) * sig(ik) / cg
1684 etot = etot + e1i*dsip(ik)
1687 hsig1p = 4. * sqrt( etot * dth )
1690 WRITE (ndso,*)
' ', trim(myname),
' ends'
1713 SUBROUTINE swh_rsrt_1pw (VA1p, WS, WD, ISEA1p, HSIG1p, HSIGwp, HSIGsp, VAMAPWS )
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
1768 REAL :: RELWS, ETOTw, ETOTs, EwI, EsI
1769 CHARACTER(25),
PARAMETER :: myname=
'SWH_RSRT_1pw'
1772 WRITE (ndso,*) trim(myname),
' starts'
1777 depth = max( dmin , -zb(isea1p) )
1783 CALL wavnu1 ( sig(ik), depth, wn, cg )
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
1796 esi = esi + va1p(ith+(ik-1)*nth) * sig(ik) / cg
1797 vamapws(ith+(ik-1)*nth) = 0
1800 etot = etot + e1i*dsip(ik)
1801 etotw = etotw + ewi*dsip(ik)
1802 etots = etots + esi*dsip(ik)
1805 hsig1p = 4. * sqrt( etot * dth )
1806 hsigwp = 4. * sqrt( etotw * dth )
1807 hsigsp = 4. * sqrt( etots * dth )
1810 WRITE (ndso,*) trim(myname),
' ends'
1827 SUBROUTINE uvtocart (UVEC, VVEC, SPD, DCART, SMCGRD)
1875 REAL,
DIMENSION(:,:),
INTENT(OUT) :: SPD, DCART
1876 REAL,
DIMENSION(:,:),
INTENT(IN) :: UVEC, VVEC
1877 LOGICAL,
INTENT(IN) :: SMCGRD
1880 WRITE (ndso,*) trim(myname),
' starts'
1884 IF (.NOT. smcgrd)
THEN
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 )
1900 spd(iy,ix) = max( spd(iy,ix) , 0.001 )
1904 WRITE (ndso,*) trim(myname),
' ends'
1919 SUBROUTINE updtwspec(VATMP, PRCNTG, VAMAPWS)
1965 REAL,
DIMENSION(:),
INTENT(INOUT) :: VATMP
1966 INTEGER,
DIMENSION(:),
INTENT(IN) :: VAMAPWS
1967 REAL,
INTENT(IN) :: PRCNTG
1968 CHARACTER(25),
PARAMETER :: myname=
'UPDTWSPEC'
1971 WRITE (ndso,*) trim(myname),
' starts'
1975 IF ( vamapws(ith+(ik-1)*nth) .EQ. 1 )
THEN
1976 vatmp(ith+(ik-1)*nth) = vatmp(ith+(ik-1)*nth) * prcntg**2
1982 WRITE (ndso,*) trim(myname),
' ends'
1999 SUBROUTINE updtwspecf(VATMP, PRCNTG, VAMAPWS, ISEA1p, ADJALL)
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(:)
2057 WRITE (ndso,*) trim(myname),
' starts'
2059 depth = max( dmin , -zb(isea1p))
2060 ALLOCATE(vashft(
SIZE(vatmp)))
2064 ffac = (1. / prcntg**2)**(1.0/3.0)
2066 CALL wavnu1(sig(ik), depth, wn, cg)
2067 sigshft = ffac * sig(ik)
2069 IF ( vamapws(ith+(ik-1)*nth) .EQ. 1 )
THEN
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)
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) + &
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)
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)
2115 IF ( vamapws(ith+(ik-1)*nth) .EQ. 1 )
THEN
2116 vashft(ith+(ik-1)*nth) = vashft(ith+(ik-1)*nth) * prcntg**2
2123 IF ( vamapws(ith+(ik-1)*nth) .EQ. 1 )
THEN
2124 vatmp(ith+(ik-1)*nth) = vashft(ith+(ik-1)*nth)
2128 vatmp(ith+(ik-1)*nth) = vatmp(ith+(ik-1)*nth) * &
2130 vashft(ith+(ik-1)*nth)
2133 vatmp(ith+(ik-1)*nth) = vatmp(ith+(ik-1)*nth) + &
2134 vashft(ith+(ik-1)*nth)
2143 WRITE (ndso,*) trim(myname),
' ends'
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
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)
2215 WRITE(unit=ip_fid, fmt=
'(E18.8, $)') rda_a(ib_i,ib_j)
2217 WRITE(unit=ip_fid, fmt=*)
''