253 INTEGER :: ndsi, ndsm, ndsr, ndstrc, ntrace, &
254 ndsen, ierr, itype, ncos, ikm, ik, &
255 ithm, ith, jsea, isea, ix, iy, j
260 INTEGER,
SAVE :: ient = 0
264 INTEGER,
ALLOCATABLE :: mapo(:,:)
266 REAL :: fp, sip, thm, xm, six, ym, siy, hmax,&
267 chsip, frrel, etot, e1i, factor, x, &
268 y, rdsqr, alfa, gamma, siga, sigb, &
269 yln, fr, beta, frr, s, sumd, ang, &
270 arg, facs, depth, wn, cg, hpqmax
271 REAL,
ALLOCATABLE :: e1(:), dd(:), e2(:,:), e21(:), finp(:,:)
273 REAL,
ALLOCATABLE :: e2out(:,:)
276 REAL,
ALLOCATABLE :: hsig(:,:)
278 CHARACTER :: comstr*1, inxout*4
282 LOGICAL :: flone,nosix
297 CALL w3seto ( 1, 6, 6 )
308 flogrr(:,:) = .false.
312 CALL itrace ( ndstrc, ntrace )
315 CALL strace (ient,
'W3STRT')
326 CALL mpi_init ( ierr_mpi )
327 CALL mpi_comm_size ( mpi_comm_world,
naproc, ierr_mpi )
328 CALL mpi_comm_rank ( mpi_comm_world,
iaproc, ierr_mpi )
341 OPEN (ndsi,
file=
fnmpre(:j)//
'ww3_strt.inp',status=
'OLD', &
344 READ (ndsi,
'(A)',
END=801,ERR=802) comstr
345 IF (comstr.EQ.
' ') comstr =
'$'
346 IF ( iaproc .EQ. napout )
WRITE (ndso,901) comstr
352 CALL w3iogr (
'READ', ndsm )
354 IF ( iaproc .EQ. napout )
WRITE (ndso,902) gname
363 nseal = 1 + (nsea-iaproc)/naproc
364 IF ( nsea .LT. naproc )
GOTO 803
367 CALL w3dimw ( 1, ndse, ndst )
368 ALLOCATE ( e1(nk), dd(nth), e2(nth,nk), e21(nspec), &
374 CALL nextln ( comstr , ndsi , ndsen )
375 READ (ndsi,*,
END=801,ERR=802) itype
376 IF ( itype.LT.1 .OR. itype.GT.5 )
THEN
377 IF ( iaproc .EQ. naperr )
WRITE (ndse,1010) itype
380 IF ( iaproc .EQ. napout )
WRITE (ndso,930) itype
385 IF ( itype .EQ. 1 )
THEN
390 CALL nextln ( comstr , ndsi , ndsen )
391 READ (ndsi,*,
END=801,ERR=802) &
392 fp, sip, thm, ncos, xm, six, ym, siy, hmax
393 fp = max( 0.5 *
tpiinv * sig(1) , fp )
394 sip = max( 0. , sip )
396 IF ( thm .LT. 0. )
THEN
402 thm = mod( thm , 360. )
403 ncos = max( 0 , 2*(ncos/2) )
407 IF ( iaproc .EQ. napout )
WRITE (ndso,903)
414 isea = iaproc + (jsea-1)*naproc
421 IF(hpfac(iy,ix).GT.hpqmax)
THEN
425 six = max(0.01*hpqmax,six)
430 isea = iaproc + (jsea-1)*naproc
437 IF(hqfac(iy,ix).GT.hpqmax)
THEN
441 siy = max(0.01*hpqmax,siy)
443 hmax = max( 0. , hmax )
445 IF ( iaproc .EQ. napout )
THEN
448 WRITE (ndso,940) fp, sip, thm, ncos, &
449 factor*xm, min(9999.99,factor*six), factor*ym, &
450 min(9999.99,factor*siy), hmax
453 WRITE (ndso,941) fp, sip, thm, ncos, &
454 factor*xm, min(9999.99,factor*six), factor*ym, &
455 min(9999.99,factor*siy), hmax
461 thm = mod( 630. - thm , 360. ) *
dera
465 chsip = 0.1 * dsip(1)
466 flone = sip .LT. chsip
467 ikm = nint( 1. + (log(fp)-log(fr1*
tpi))/log(xfr) )
468 ikm = max( 1 , min( nk , ikm ) )
478 frrel = (sig(ik)-fp)/sip
479 IF (abs(frrel).LT.10)
THEN
480 e1(ik) = exp( -0.125 * frrel**2 )
488 IF ( iaproc .EQ. napout )
CALL prt1ds &
489 (ndso, nk, e1, sig(1:),
' ', 10, 0., &
490 'Unscaled 1-D',
' ',
'TEST E(f)')
496 ithm = 1 + nint( thm / dth )
499 IF ( ith .EQ. ithm )
THEN
505 dd(ith) = max( cos(th(ith)-thm) , 0. )**ncos
515 e2(ith,ik) = e1(ik) * dd(ith)
516 e1i = e1i + e2(ith,ik)
518 etot = etot + e1i * dsip(ik)
521 factor = hmax**2 / ( 16. * etot )
526 ALLOCATE ( e2out(nk,nth) )
529 e2out(ik,ith) =
tpi * e2(ith,ik)
535 IF ( iaproc .EQ. napout )
CALL prt2ds &
536 ( ndso, nk, nk, nth, e2out, sig(1:),
' ',
dera*
tpi, &
537 0., 0.0001,
'Energy',
'm2s',
'TEST 2-D')
545 e21(1+(ik-1)*nth:ik*nth) = e2(:,ik)
551 isea = iaproc + (jsea-1)*naproc
556 IF (gtype .EQ. ungtype)
THEN
567 rdsqr =(w3dist(flagll,x,y,xm,ym)/siy)**2
569 rdsqr =((x-xm)/six)**2 + ((y-ym)/siy)**2
571 IF ( rdsqr .GT. 40. )
THEN
574 factor = exp( -0.5 * rdsqr )
580 va(:,jsea) = factor * e21
589 ELSE IF ( itype .EQ. 2 )
THEN
594 CALL nextln ( comstr , ndsi , ndsen )
595 READ (ndsi,*,
END=801,ERR=802) &
596 alfa, fp, thm, gamma, siga, sigb, xm, six, ym, siy
598 IF (alfa.LE.0.) alfa = 0.0081
599 IF (fp .LE.0.) fp = 0.10
600 IF (siga.LE.0.) siga = 0.07
601 IF (sigb.LE.0.) sigb = 0.09
602 fp = max( 0.5 *
tpiinv * sig(1) , fp )
603 fp = min(
tpiinv * sig(nk) , fp )
607 IF ( iaproc .EQ. napout )
WRITE (ndso,903)
614 isea = iaproc + (jsea-1)*naproc
621 IF(hpfac(iy,ix).GT.hpqmax)
THEN
625 six = max(0.01*hpqmax,six)
630 isea = iaproc + (jsea-1)*naproc
637 IF(hqfac(iy,ix).GT.hpqmax)
THEN
641 siy = max(0.01*hpqmax,siy)
644 IF ( thm .LT. 0. )
THEN
650 thm = mod( thm , 360. )
651 gamma = max(gamma,1.)
654 IF ( iaproc .EQ. napout )
THEN
657 WRITE (ndso,950) alfa, fp, thm, gamma, siga, sigb, &
658 factor*xm, factor*six, factor*ym, factor*siy
661 WRITE (ndso,951) alfa, fp, thm, gamma, siga, sigb, &
662 factor*xm, factor*six, factor*ym, factor*siy
665 thm = mod( 630. - thm , 360. ) *
dera
671 e1(ik) = ej5p(fr, alfa, fp, yln, siga, sigb )
675 IF ( iaproc .EQ. napout )
CALL prt1ds &
676 (ndso, nk, e1, sig(1:),
' ', 18, 0., &
677 'E(f)',
' ',
'TEST 1-D')
690 frr = min( 2.5 , fr/fp )
694 ang = cos( 0.5 * ( thm - th(ith) ) )**2
696 IF(ang.GT.1.e-20)
THEN
698 IF(arg.GT.-170) dd(ith) = exp(arg)
700 sumd = sumd + dd(ith)
702 factor = 1. / (
tpi*sumd*dth)
704 e2(ith,ik) = factor * e1(ik) * dd(ith)
709 ALLOCATE ( e2out(nk,nth) )
712 e2out(ik,ith) =
tpi * e2(ith,ik)
718 IF ( iaproc .EQ. napout )
CALL prt2ds &
719 (ndso, nk, nk, nth, e2out, sig(1:),
' ', 1., &
720 0., 0.0001,
'E(f,theta)',
'm2s',
'TEST 2-D')
728 e21(1+(ik-1)*nth:ik*nth) = e2(:,ik)
735 isea = iaproc + (jsea-1)*naproc
740 IF (gtype .EQ. ungtype)
THEN
751 rdsqr =(w3dist(flagll,x,y,xm,ym)/siy)**2
753 rdsqr =((x-xm)/six)**2 + ((y-ym)/siy)**2
755 IF ( rdsqr .GT. 40. )
THEN
758 factor = exp( -0.5 * rdsqr )
761 va(:,jsea) = factor * e21
768 ELSE IF ( itype .EQ. 3 )
THEN
770 IF ( iaproc .EQ. napout )
WRITE (ndso,960)
775 ELSE IF ( itype .EQ. 4 )
THEN
780 CALL nextln ( comstr , ndsi , ndsen )
781 READ (ndsi,*,
END=801,ERR=802) facs
782 IF ( facs .LE. 0. ) facs = 1.
783 IF ( iaproc .EQ. napout )
WRITE (ndso,970) facs
787 CALL nextln ( comstr , ndsi , ndsen )
788 READ (ndsi,*,
END=801,ERR=802) &
789 ((finp(ik,ith),ik=1,nk),ith=1,nth)
791 finp = finp * facs /
tpi
794 IF ( iaproc .EQ. napout )
CALL prt2ds &
795 (ndso, nk, nk, nth, finp, sig(1:),
' ',
tpi, &
796 0., 0.0001,
'Energy',
'm2s',
'TEST 2-D')
804 isea = iaproc + (jsea-1)*naproc
811 va(ith+(ik-1)*nth,jsea) = finp(ik,ith)
821 IF ( iaproc .EQ. napout )
WRITE (ndso,980)
828 IF ( itype.NE.3 .AND. itype.NE.5 )
THEN
829 IF ( iaproc .EQ. napout )
WRITE (ndso,990)
832 ALLOCATE ( hsig(nx,ny) )
838 isea = iaproc + (jsea-1)*naproc
843 depth = max( dmin , -zb(isea) )
848 CALL wavnu1 ( sig(ik), depth, wn, cg )
854 e1i = e1i + va(ith+(ik-1)*nth,jsea)
856 va(ith+(ik-1)*nth,jsea) = va(ith+(ik-1)*nth,jsea) * &
860 etot = etot + e1i*dsip(ik)
866 hsig(ix,iy) = 4. * sqrt( etot * dth )
869 IF (jsea .eq. 1)
THEN
872 ispec = ith + nth * (ik-1)
873 WRITE(10003) ith, ik, va(ispec,jsea)
876 WRITE(740+iaproc,*)
'FINAL : sum(VA)=', sum(va(:,jsea))
882 ALLOCATE ( mapo(nx,ny) )
885 mapo(ix,iy) = mapsta(iy,ix)
891 IF ( naproc .EQ. 1 )
THEN
896 IF ( iaproc .EQ. napout )
CALL prtblk &
897 (ndso, nx, ny, nx, hsig, mapo, 0, 0., &
898 1, nx, nsx, 1, ny, nsy,
'Hs',
'm')
909 IF ( iaproc .EQ. napout )
WRITE (ndso,995)
910 CALL w3iors ( inxout, ndsr, sig(nk) )
917 IF ( iaproc .EQ. naperr )
WRITE (ndse,1000) ierr
921 IF ( iaproc .EQ. naperr )
WRITE (ndse,1001)
925 IF ( iaproc .EQ. naperr )
WRITE (ndse,1002) ierr
930 IF ( iaproc .EQ. naperr )
WRITE (ndse,1003) nsea, naproc
935 IF ( iaproc .EQ. napout )
WRITE (ndso,999)
937 CALL mpi_finalize ( ierr_mpi )
942 900
FORMAT (/15x,
' *** WAVEWATCH III Initial conditions *** '/ &
943 15x,
'==============================================='/)
944 901
FORMAT (
' Comment character is ''',a,
''''/)
945 902
FORMAT (
' Grid name : ',a/)
946 903
FORMAT (
' Negative SIX was provided by user. '/ &
947 ' WW3 will create a gaussian distribution '/ &
948 ' that is circular in real space. ')
950 930
FORMAT (/
' Initial field ITYPE =',i2/ &
951 ' --------------------------------------------------')
953 940
FORMAT (
' Gaussian / cosine power spectrum '// &
954 ' Peak frequency and spread (Hz) :',2x,2f8.4/ &
955 ' Mean direction (Naut., degr.) :',f7.1/ &
956 ' Cosine power of dir. distribution :',i5/ &
957 ' Mean longitude and spread (degr.) :',2f8.2/ &
958 ' Mean latitude and spread (degr.) :',2f8.2/ &
959 ' Maximum wave height :',f8.2/)
961 950
FORMAT (
' JONSWAP spectrum'// &
962 ' alfa (-) : ',f12.5/ &
963 ' Peak frequecy (Hz) : ',f11.4/ &
964 ' Mean direction (Naut.,deg.) : ',f 8.1/ &
965 ' gamma (-) : ',f 9.2/ &
966 ' sigma-A (-) : ',f11.4/ &
967 ' sigma-B (-) : ',f11.4/ &
968 ' Mean longitude and spread (degr.) : ',2f9.2/ &
969 ' Mean latitude and spread (degr.) : ',2f9.2)
970 941
FORMAT (
' Gaussian / cosine power spectrum '// &
971 ' Peak frequency and spread (Hz) :',2x,2f8.4/ &
972 ' Mean direction (Naut., degr.) :',f7.1/ &
973 ' Cosine power of dir. distribution :',i5/ &
974 ' Mean X and spread (km) :',2f8.2/ &
975 ' Mean Y and spread (km) :',2f8.2/ &
976 ' Maximum wave height :',f8.2/)
978 951
FORMAT (
' JONSWAP spectrum'// &
979 ' alfa (-) : ',f12.5/ &
980 ' Peak frequecy (Hz) : ',f11.4/ &
981 ' Mean direction (Naut.,deg.) : ',f 8.1/ &
982 ' gamma (-) : ',f 9.2/ &
983 ' sigma-A (-) : ',f11.4/ &
984 ' sigma-B (-) : ',f11.4/ &
985 ' Mean X and spread (km) : ',2f9.2/ &
986 ' Mean Y and spread (km) : ',2f9.2)
988 960
FORMAT (
' Fetch-limited JONSWAP spectra based on local '/ &
989 ' wind speed (fetch related to grid increment).')
991 970
FORMAT (
' User-defined energy spectrum F(f,theta).'// &
992 ' Scale factor (-) : ',e12.4/)
994 980
FORMAT (
' Starting from calm conditions (Hs = 0)')
996 990
FORMAT (/
' Converting energy to action ... ')
997 995
FORMAT (/
' Writing restart file ... '/)
999 999
FORMAT (/
' End of program '/ &
1000 ' ========================================='/ &
1001 ' WAVEWATCH III Initial conditions '/)
1003 1000
FORMAT (/
' *** WAVEWATCH III ERROR IN W3STRT : '/ &
1004 ' ERROR IN OPENING INPUT FILE'/ &
1007 1001
FORMAT (/
' *** WAVEWATCH III ERROR IN W3STRT : '/ &
1008 ' PREMATURE END OF INPUT FILE'/)
1010 1002
FORMAT (/
' *** WAVEWATCH III ERROR IN W3STRT : '/ &
1011 ' ERROR IN READING FROM INPUT FILE'/ &
1014 1010
FORMAT (/
' *** WAVEWATCH III ERROR IN W3STRT : '/ &
1015 ' ILLEGAL TYPE, ITYPE =',i4/)
1018 1003
FORMAT (/
' *** WAVEWATCH III ERROR IN W3STRT : '/ &
1019 ' NUMBER OF SEA POINTS LESS THAN NUMBER OF PROC.'/ &
1020 ' NSEA, NAPROC =',2i8/)