Write partitioned spectral data to file.
Unlike other WAVEWATCH III IO routines, this one writes only. First ad-hoc version.
Writing to formatted or unformatted file with ID headers.
463 INTEGER,
INTENT(IN) :: NDSPT, IMOD
468 INTEGER :: I, J, IERR, ISEA, JSEA, JAPROC, &
469 IX, IY, IP, IOFF, DTSIZ=0
471 INTEGER :: ICSIZ, IERR_MPI, IT, &
472 STATUS(MPI_STATUS_SIZE,1), JSLM
475 INTEGER,
SAVE :: IENT = 0
477 INTEGER,
POINTER :: ICP(:,:)
478 REAL :: X, Y, DEPTH, UABS, UDIR, CABS, CDIR
479 REAL,
POINTER :: DTP(:,:)
482 INTEGER,
POINTER :: ICPRT(:,:)
483 REAL,
POINTER :: DTPRT(:,:)
486 TYPE(PROCS),
TARGET,
ALLOCATABLE :: PROC(:)
492 CALL strace (ient,
'W3IOSF')
497 icsiz = 2 * ( nsealm + 1 )
501 WRITE (
ndst,9000) ipass, flform, ndspt, imod, iaproc, napprt
507 IF ( ipass.EQ.1 .AND. iaproc.EQ.napprt )
THEN
515 WRITE (
ndst,9010) fnmpre(:j)//
'partition.'//filext(:i)
519 OPEN (ndspt,
file=fnmpre(:j)//
'partition.'//filext(:i), &
522 OPEN (ndspt,
file=fnmpre(:j)//
'partition.'//filext(:i), &
523 form=
'UNFORMATTED',convert=
file_endian,err=800,iostat=ierr)
531 WRITE (ndspt,910) idstr, verprt
533 WRITE (ndspt,911)
' yyyymmdd hhmmss '// &
534 'lat lon name nprt'// &
535 ' depth ubas udir cabs cdir'
537 WRITE (ndspt,911)
' yyyymmdd hhmmss '// &
539 ' depth ubas udir cabs cdir'
541 WRITE (ndspt,911)
' hs tp lp '// &
544 WRITE ( ndspt ) idstr, verprt
546 WRITE ( ndspt )
' yyyymmdd hhmmss '// &
547 'lat lon name nprt'// &
548 ' depth ubas udir cabs cdir'
550 WRITE ( ndspt )
' yyyymmdd hhmmss '// &
552 ' depth ubas udir cabs cdir'
554 WRITE ( ndspt )
' hs tp lp '// &
564 IF ( iaproc.NE.napprt .AND. iaproc.LE.naproc )
THEN
567 WRITE (
ndst,9020) iaproc, napprt, nsealm+1
571 it = it0prt + iaproc - 1
572 CALL mpi_send ( icprt, icsiz, mpi_real, napprt-1, it, &
574 dtsiz = icprt(nseal+1,2) - 1
578 WRITE (
ndst,9021) iaproc, napprt, dtsiz
582 it = it0prt + naproc + iaproc - 1
583 IF ( dtsiz .GT. 0 )
CALL mpi_send &
584 ( dtprt, 6*dtsiz, mpi_real, napprt-1, &
590 IF ( iaproc .NE. napprt )
RETURN
596 ALLOCATE ( proc(naproc) )
600 IF ( iaproc .LE. naproc )
THEN
601 proc(iaproc)%ICPRT => outpts(imod)%OUT6%ICPRT
602 proc(iaproc)%DTPRT => outpts(imod)%OUT6%DTPRT
608 IF ( iaproc .EQ. japroc ) cycle
611 WRITE (
ndst,9030) japroc, nsealm+1
615 ALLOCATE ( proc(japroc)%ICPRT(nsealm+1,2) )
616 icp => proc(japroc)%ICPRT
617 it = it0prt + japroc - 1
618 CALL mpi_recv ( icp, icsiz, mpi_real, japroc-1, it, &
620 jslm = 1 + (nsea-japroc)/naproc
621 dtsiz = icp(jslm+1,2) - 1
625 WRITE (
ndst,9031) japroc, dtsiz
629 ALLOCATE ( proc(japroc)%DTPRT(dimp,max(1,dtsiz)) )
630 dtp => proc(japroc)%DTPRT
631 it = it0prt + naproc + japroc - 1
632 IF ( dtsiz .GT. 0 )
CALL mpi_recv &
633 ( dtp, dimp*dtsiz, mpi_real, japroc-1, &
649 icp => proc(japroc)%ICPRT
650 dtp => proc(japroc)%DTPRT
652 IF ( icp(jsea,1) .EQ. 0 ) cycle
658 IF ( ix.LT.ix0 .OR. ix.GT.ixn .OR. mod(ix-ix0,ixs).NE.0 ) cycle
659 IF ( iy.LT.iy0 .OR. iy.GT.iyn .OR. mod(iy-iy0,iys).NE.0 ) cycle
663 uabs = u10(isea)*
asf(isea)
664 udir = mod( 270. - u10d(isea)*
rade , 360. )
665 cabs = sqrt( cx(isea)**2 + cy(isea)**2 )
666 IF ( cabs .LT. 1.e-3 )
THEN
669 cdir = atan2( cy(isea), cx(isea) ) *
rade
670 cdir = mod( 270. - cdir , 360. )
675 WRITE (ndspt,940)
time, y, x, &
676 'grid_point', icp(jsea,1) - 1, &
677 depth, uabs, udir, cabs, cdir
679 WRITE (ndspt,941)
time, x*1.e-3, y*1.e-3, &
680 'grid_point', icp(jsea,1) - 1, &
681 depth, uabs, udir, cabs, cdir
685 WRITE ( ndspt )
time, y, x, &
686 'grid_point', icp(jsea,1) - 1, &
687 depth, uabs, udir, cabs, cdir
689 WRITE ( ndspt )
time, x*1.e-3, y*1.e-3, &
690 'grid_point', icp(jsea,1) - 1, &
691 depth, uabs, udir, cabs, cdir
700 DO ip=0, icp(jsea,1) - 1
701 WRITE (ndspt,942) ip, dtp(:,ip+ioff)
704 DO ip=0, icp(jsea,1) - 1
705 WRITE ( ndspt ) ip, dtp(:,ip+ioff)
716 IF ( iaproc .EQ. japroc ) cycle
717 DEALLOCATE ( proc(japroc)%ICPRT, proc(japroc)%DTPRT )
728 IF ( iaproc .EQ. naperr )
WRITE (ndse,1000) ierr
736 940
FORMAT (1x,i8.8,1x,i6.6,2f8.3,2x,
'''',a10,
'''', &
737 1x,i2,f7.1,f5.1,f6.1,f5.2,f6.1)
738 941
FORMAT (1x,i8.8,1x,i6.6,2(f8.1,
'E3'),2x,
'''',a10,
'''', &
739 1x,i2,f7.1,f5.1,f6.1,f5.2,f6.1)
740 942
FORMAT (i3,3f8.2,2f9.2,f7.2)
742 1000
FORMAT (/
' *** WAVEWATCH III ERROR IN W3IOSF : '/ &
743 ' ERROR IN OPENING FILE'/ &
747 9000
FORMAT (
' TEST W3IOSF : IPASS =',i4,
', FLFROM = ',l1, &
748 ', NDSPT =',i3,
', IMOD =',i3,
','/ &
749 ' IAPROC, NAPPRT =',2i4)
750 9010
FORMAT (
' TEST W3IOSF : OPENING NEW FILE [',a,
']')
751 9020
FORMAT (
' TEST W3IOSF : SENDING ICPRT FROM',i3,
' TO',i3, &
755 9021
FORMAT (
' TEST W3IOSF : SENDING DTPRT FROM',i3,
' TO',i3, &
759 9030
FORMAT (
' TEST W3IOSF : RECEIVING ICPRT FROM',i3, &
763 9031
FORMAT (
' TEST W3IOSF : RECEIVING DTPRT FROM',i3, &