Skip to content

Commit

Permalink
bug fix to have save point weight file be different name (#1357)
Browse files Browse the repository at this point in the history
  • Loading branch information
JessicaMeixner-NOAA authored Feb 8, 2025
1 parent e409f81 commit 2681f7b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
32 changes: 24 additions & 8 deletions model/src/w3iopomd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ SUBROUTINE W3IOPP ( NPT, XPT, YPT, PNAMES, IMOD, MPI_COMM_IOPP )
REAL, ALLOCATABLE :: EquLon(:),EquLat(:),StdLon(:),StdLat(:),AnglPT(:)
#endif
! Variables for NetCDF weights file for points
character(len = 124) :: filename
character(len = 124) :: filename, filenameout
logical :: pnt_wght_exists, pnt_wght_write
integer :: ncerr, fh
integer :: d_nopts, d_namelen, d_vsize, d_wghtlen
Expand Down Expand Up @@ -542,7 +542,7 @@ SUBROUTINE W3IOPP ( NPT, XPT, YPT, PNAMES, IMOD, MPI_COMM_IOPP )
END DO ! End loop over output points (IPT).
ELSE
! Saved weight file exists, read weights from file
IF ( IAPROC .EQ. 1 ) THEN
IF ( IAPROC .EQ. 1 ) THEN
! Open the netCDF file.
ncerr = nf90_open(filename, NF90_NOWRITE, fh)
if (nf90_err(ncerr) .ne. 0) return
Expand Down Expand Up @@ -596,14 +596,29 @@ SUBROUTINE W3IOPP ( NPT, XPT, YPT, PNAMES, IMOD, MPI_COMM_IOPP )
ncerr = nf90_get_var(fh, v_ptifac, PTIFAC, start = (/ 1, 1/), &
count = (/ d_wghtlen_len, d_nopts_len /))
if (nf90_err(ncerr) .ne. 0) return

! Close the file.
ncerr = nf90_close(fh)
if (nf90_err(ncerr) .ne. 0) return

END IF

#ifdef W3_MPI
! Broadcast weight info to all MPI tasks:
! Broadcast weight info to all MPI tasks:

!First broadcast NOPTS, used in the next calls:
CALL MPI_BCAST(NOPTS,1,MPI_INTEGER,IAPROC-1,MPI_COMM_IOPP,IERR_MPI)
CALL MPI_BCAST(PTNME,40*NPT,MPI_CHARACTER,IAPROC-1,MPI_COMM_IOPP,IERR_MPI)
CALL MPI_BCAST(PTLOC,2*NPT,MPI_REAL,0,MPI_COMM_IOPP,IERR_MPI)
CALL MPI_BCAST(IPTINT,2*4*NPT,MPI_REAL,0,MPI_COMM_IOPP,IERR_MPI)
CALL MPI_BCAST(PTIFAC,4*NPT,MPI_REAL,0,MPI_COMM_IOPP,IERR_MPI)
CALL MPI_Barrier(MPI_COMM_IOPP,IERR_MPI)

CALL MPI_BCAST(PTLOC,2*NPT,MPI_REAL,IAPROC-1,MPI_COMM_IOPP,IERR_MPI)
CALL MPI_BCAST(PTIFAC,4*NPT,MPI_REAL,IAPROC-1,MPI_COMM_IOPP,IERR_MPI)
CALL MPI_BCAST(IPTINT(:,:,1:NOPTS),2*4*NOPTS,MPI_INTEGER,IAPROC-1,MPI_COMM_IOPP,IERR_MPI)

!Send point names individually
DO IPT=1, NOPTS
CALL MPI_BCAST(PTNME(IPT),40,MPI_CHARACTER,IAPROC-1,MPI_COMM_IOPP,IERR_MPI)
ENDDO

CALL MPI_Barrier(MPI_COMM_IOPP,IERR_MPI)
#endif
ENDIF !end if point weight file exists
Expand All @@ -612,7 +627,8 @@ SUBROUTINE W3IOPP ( NPT, XPT, YPT, PNAMES, IMOD, MPI_COMM_IOPP )
IF ( pnt_wght_write .AND. (NOPTS > 0) ) THEN
IF ( IAPROC .EQ. 1 ) THEN
! Create the netCDF file.
ncerr = nf90_create(filename, NF90_NETCDF4, fh)
filenameout = 'out.pnt_wght.'//FILEXT(:LEN_TRIM(FILEXT))//'.nc'
ncerr = nf90_create(filenameout, NF90_NETCDF4, fh)
if (nf90_err(ncerr) .ne. 0) return

! Define dimensions.
Expand Down
5 changes: 5 additions & 0 deletions model/src/w3odatmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,11 @@ SUBROUTINE W3DMO2 ( IMOD, NDSE, NDST, NPT )
CHECK_ALLOC_STATUS ( ISTAT )
!
OUTPTS(IMOD)%OUT2%O2INIT = .TRUE.
!Initialize:
OUTPTS(IMOD)%OUT2%IPTINT=0
OUTPTS(IMOD)%OUT2%PTNME=''
OUTPTS(IMOD)%OUT2%PTLOC=0.
OUTPTS(IMOD)%OUT2%PTIFAC=0.
!
#ifdef W3_T
WRITE (NDST,9001)
Expand Down

0 comments on commit 2681f7b

Please sign in to comment.