Skip to content

Commit

Permalink
modified WW3_RECEIVE_FROM_ERF to output magnitude and theta as 1d arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
japham0 committed Aug 6, 2024
1 parent d934892 commit 7fce3b0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 41 deletions.
85 changes: 50 additions & 35 deletions model/src/w3iogomd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ MODULE W3IOGOMD
PUBLIC
CHARACTER(LEN=1024) :: FLDOUT
! MY EDITS
PUBLIC :: mag_values, th_values
REAL(8), allocatable :: mag_values(:)
REAL(8), allocatable :: th_values(:)
!PUBLIC :: mag_values, th_values
REAL(8), allocatable :: magnitude_values(:)
REAL(8), allocatable :: theta_values(:)
!/
!/ Private parameter statements (ID strings)
!/
Expand Down Expand Up @@ -199,11 +199,6 @@ SUBROUTINE WW3_SEND_TO_ERF
CHARACTER(LEN=80) :: exename
REAL, ALLOCATABLE :: X1(:,:)

! MY EDITS
INTEGER :: n_elements
REAL(8), allocatable :: magnitude_values(:)
REAL(8), allocatable :: theta_values(:)

#ifdef W3_PDLIB
REAL(rkind) :: XY_SEND(NX*NY)
REAL(rkind) :: XY_SYNCH_SEND(NSEA)
Expand Down Expand Up @@ -357,8 +352,11 @@ SUBROUTINE WW3_RECEIVE_FROM_ERF

! MY EDITS
INTEGER :: n_elements
REAL(8), allocatable :: magnitude_values(:)
REAL(8), allocatable :: theta_values(:)
! REAL(8), allocatable :: magnitude_values(:)
! REAL(8), allocatable :: theta_values(:)

! REAL(8), allocatable, intent(inout) :: mag_values(:)
! REAL(8), allocatable, intent(inout) :: th_values(:)

#ifdef W3_PDLIB
REAL(rkind) :: XY_SEND(NX*NY)
Expand Down Expand Up @@ -402,6 +400,13 @@ SUBROUTINE WW3_RECEIVE_FROM_ERF

CALL MPI_RECV( n_elements, 1, MPI_INT, other_root, 10, MPI_COMM_WORLD, MPI_STATUS_IGNORE, IERR_MPI );

if(allocated(magnitude_values)) then
deallocate(magnitude_values)
endif

if(allocated(theta_values)) then
deallocate(theta_values)
endif

allocate(magnitude_values(n_elements))
allocate(theta_values(n_elements))
Expand All @@ -411,7 +416,13 @@ SUBROUTINE WW3_RECEIVE_FROM_ERF
else ! the second program

CALL MPI_RECV( n_elements, 1, MPI_INT, other_root, 11, MPI_COMM_WORLD, MPI_STATUS_IGNORE,IERR_MPI );
if(allocated(magnitude_values)) then
deallocate(magnitude_values)
endif

if(allocated(theta_values)) then
deallocate(theta_values)
endif
allocate(magnitude_values(n_elements))
allocate(theta_values(n_elements))

Expand All @@ -425,6 +436,12 @@ SUBROUTINE WW3_RECEIVE_FROM_ERF
#endif
#endif

!allocate(mag_values(n_elements))
!allocate(th_values(n_elements))




! END RECEIVE ------------------------------------------------------------------ *
END SUBROUTINE WW3_RECEIVE_FROM_ERF
!> @brief Expand the seapoint array to full grid with handling of
Expand Down Expand Up @@ -1706,8 +1723,8 @@ SUBROUTINE W3OUTG ( A, FLPART, FLOUTG, FLOUTG2 )

! MY EDITS
INTEGER :: n_elements
REAL(8), allocatable :: magnitude_values(:)
REAL(8), allocatable :: theta_values(:)
!REAL(8), allocatable :: magnitude_values(:)
!REAL(8), allocatable :: theta_values(:)

#ifdef W3_PDLIB
REAL(rkind) :: XY_SEND(NX*NY)
Expand Down Expand Up @@ -2496,6 +2513,22 @@ SUBROUTINE W3OUTG ( A, FLPART, FLOUTG, FLOUTG2 )

CALL WW3_SEND_TO_ERF()
CALL WW3_RECEIVE_FROM_ERF()
open(unit=6123, file='ww3_mpi_recv.txt', status='unknown', access='append', action="write")
DO JSEA=1, NSEAL
CALL INIT_GET_ISEA(ISEA, JSEA)
IX = MAPSF(ISEA,1)
IY = MAPSF(ISEA,2)
! Need correct mapping of magnitude_values and theta_values
COUNTER = IX + (IY-1) * NX

! mag_values(ISEA) = magnitude_values(ISEA)
! th_values(ISEA) = theta_values(ISEA)

WRITE(6123, *) "(", IX, IY, ")", n_elements, ISEA, JSEA, COUNTER, size(magnitude_values), magnitude_values(ISEA), size(theta_values), theta_values(ISEA), IERR_MPI
END DO
! write(6123,*) 'Magnitude Values:', magnitude_values, 'Theta Values:', theta_values
close(6123)


! Uncomment if statement if we only want to receive from ERF
COMMENT = 2
Expand Down Expand Up @@ -2598,15 +2631,6 @@ SUBROUTINE W3OUTG ( A, FLPART, FLOUTG, FLOUTG2 )

CALL MPI_RECV( n_elements, 1, MPI_INT, other_root, 10, MPI_COMM_WORLD, MPI_STATUS_IGNORE, IERR_MPI );

if (allocated(mag_values)) then
deallocate(mag_values)
!allocate(mag_values(n_elements))
end if

if (allocated(th_values)) then
deallocate(th_values)
!allocate(th_values(n_elements))
end if

allocate(magnitude_values(n_elements))
allocate(theta_values(n_elements))
Expand All @@ -2616,15 +2640,6 @@ SUBROUTINE W3OUTG ( A, FLPART, FLOUTG, FLOUTG2 )
else ! the second program

CALL MPI_RECV( n_elements, 1, MPI_INT, other_root, 11, MPI_COMM_WORLD, MPI_STATUS_IGNORE,IERR_MPI );
if (allocated(mag_values)) then
deallocate(mag_values)
!allocate(mag_values(n_elements))
end if

if (allocated(th_values)) then
deallocate(th_values)
!allocate(th_values(n_elements))
end if

allocate(magnitude_values(n_elements))
allocate(theta_values(n_elements))
Expand All @@ -2634,8 +2649,8 @@ SUBROUTINE W3OUTG ( A, FLPART, FLOUTG, FLOUTG2 )
end if
end if

allocate(mag_values(n_elements))
allocate(th_values(n_elements))
! allocate(mag_values(n_elements))
! allocate(th_values(n_elements))

print*, "JUST RECEIVED AND ALLOCATED MAG_VALUES(n-elements)"! MPI RECEIVE TEST
! Allocate arrays
Expand All @@ -2655,10 +2670,10 @@ SUBROUTINE W3OUTG ( A, FLPART, FLOUTG, FLOUTG2 )
! Need correct mapping of magnitude_values and theta_values
COUNTER = IX + (IY-1) * NX

mag_values(ISEA) = magnitude_values(ISEA)
th_values(ISEA) = theta_values(ISEA)
!mag_values(ISEA) = magnitude_values(ISEA)
!th_values(ISEA) = theta_values(ISEA)

WRITE(6123, *) "(", IX, IY, ")", n_elements, size(mag_values), ISEA, JSEA, COUNTER, size(magnitude_values), magnitude_values(ISEA), mag_values(ISEA), size(theta_values), theta_values(ISEA), IERR_MPI
WRITE(6123, *) "(", IX, IY, ")", n_elements, ISEA, JSEA, COUNTER, size(magnitude_values), magnitude_values(ISEA), size(theta_values), theta_values(ISEA), IERR_MPI
END DO
! write(6123,*) 'Magnitude Values:', magnitude_values, 'Theta Values:', theta_values
close(6123)
Expand Down
12 changes: 6 additions & 6 deletions model/src/w3srcemd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ MODULE W3SRCEMD
!/ ------------------------------------------------------------------- /
!/
! MY EDITS HERE
USE W3IOGOMD, ONLY: mag_values, th_values, S2GRID
!USE W3IOGOMD, ONLY: mag_values, th_values, S2GRID
! USE W3IOGOMD, ONLY: S2GRID
! END MY EDITS

Expand Down Expand Up @@ -2126,11 +2126,11 @@ SUBROUTINE W3SRCE ( srce_call, IT, ISEA, JSEA, IX, IY, IMOD, &

! MY EDITS HERE
! Check if we can access received values from ERF
print *, "Now activating ST6"
OPEN(4121, file='output_SRC.txt', status='unknown', access='append', action="write")
!WRITE(4121, *) U10DIR, "(x_vel, y_vel) = ", "(", COS(U10DIR), SIN(U10DIR), ") ", "Wind Vel = ", U10ABS
WRITE(4121, *) size(mag_values), size(th_values)
CLOSE(4121)
!print *, "Now activating ST6"
! OPEN(4121, file='output_SRC.txt', status='unknown', access='append', action="write")
! !WRITE(4121, *) U10DIR, "(x_vel, y_vel) = ", "(", COS(U10DIR), SIN(U10DIR), ") ", "Wind Vel = ", U10ABS
! WRITE(4121, *) size(mag_values), size(th_values)
! CLOSE(4121)

! END MY EDITS

Expand Down

0 comments on commit 7fce3b0

Please sign in to comment.