Skip to content

Commit

Permalink
Option to reverse lat lon increment
Browse files Browse the repository at this point in the history
  • Loading branch information
dhyan1272 committed Sep 18, 2024
1 parent e75fdb4 commit 5f6d963
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
15 changes: 11 additions & 4 deletions test/calculateDisplacement.f90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
subroutine calcSurfDispIncr(mpMesh, latVertex, lonVertex, nEdgesOnCell, verticesOnCell, nVertices, sphereRadius)
subroutine calcSurfDispIncr(mpMesh, latVertex, lonVertex, nEdgesOnCell, verticesOnCell, nVertices, sphereRadius, scale)
use :: polympo
use :: readMPAS
use :: iso_c_binding
Expand All @@ -8,9 +8,16 @@ subroutine calcSurfDispIncr(mpMesh, latVertex, lonVertex, nEdgesOnCell, vertices
real(kind=MPAS_RKIND) :: maxlon, minlon, deltaLon, sphereRadius
integer, dimension(:), pointer :: nEdgesOnCell
integer, dimension(:,:), pointer :: verticesOnCell
integer :: i, j, nVertices, nCompsDisp
integer :: i, j, nVertices, nCompsDisp, scale_use
real(kind=MPAS_RKIND), dimension(:,:), pointer :: dispIncr
type(c_ptr) :: mpMesh
INTEGER, INTENT(IN), OPTIONAL :: scale

IF (PRESENT(scale)) THEN
scale_use=scale
ELSE
scale_use=1
END IF

nCompsDisp = 2
allocate(dispIncr(nCompsDisp,nVertices))
Expand All @@ -31,10 +38,10 @@ subroutine calcSurfDispIncr(mpMesh, latVertex, lonVertex, nEdgesOnCell, vertices
deltaLon = maxlon - minlon

do i = 1,nVertices
dispIncr(1,i) = sphereRadius*cos(latVertex(i))*deltaLon
dispIncr(1,i) = scale_use*sphereRadius*cos(latVertex(i))*deltaLon
dispIncr(2,i) = 0.0_MPAS_RKIND
end do
call polympo_setMeshVtxOnSurfDispIncr(mpMesh,nCompsDisp,nVertices,c_loc(dispIncr))

deallocate(dispIncr)
end subroutine
end subroutine
37 changes: 33 additions & 4 deletions test/testFortranMPAdvection.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,33 @@ subroutine runAdvectionTest(mpMesh, numPush, latVertex, lonVertex, nEdgesOnCell,

end subroutine

subroutine runAdvectionTest2(mpMesh, numPush, latVertex, lonVertex, nEdgesOnCell, verticesOnCell, nVertices, sphereRadius)
use :: polympo
use :: readMPAS
use :: iso_c_binding
implicit none

type(c_ptr) :: mpMesh
integer :: i, numPush, nVertices
real(kind=MPAS_RKIND), dimension(:), pointer :: latVertex, lonVertex
integer, dimension(:), pointer :: nEdgesOnCell
integer, dimension(:,:), pointer :: verticesOnCell
real(kind=MPAS_RKIND) :: sphereRadius

PRINT *, "Foward: "
do i = 1, numPush
call calcSurfDispIncr(mpMesh, latVertex, lonVertex, nEdgesOnCell, verticesOnCell, nVertices, sphereRadius)
call polympo_push(mpMesh)
end do

PRINT *, "Backward: "
call calcSurfDispIncr(mpMesh, latVertex, lonVertex, nEdgesOnCell, verticesOnCell, nVertices, sphereRadius, -1)
call polympo_push(mpMesh)

end subroutine



subroutine runReconstructionTest(mpMesh, numMPs, numPush, nCells, nVertices, mp2Elm, &
latVertex, lonVertex, nEdgesOnCell, verticesOnCell, sphereRadius)
use :: polympo
Expand Down Expand Up @@ -298,12 +325,14 @@ program main
call polympo_setMPRotLatLon(mpMesh,2,numMPs,c_loc(mpLatLon))
call polympo_setMPPositions(mpMesh,3,numMPs,c_loc(mpPosition))

! call runAdvectionTest(mpMesh, numPush, latVertex, lonVertex, nEdgesOnCell, verticesOnCell, nVertices, sphereRadius)
call runAdvectionTest(mpMesh, numPush, latVertex, lonVertex, nEdgesOnCell, verticesOnCell, nVertices, sphereRadius)

call runAdvectionTest2(mpMesh, numPush, latVertex, lonVertex, nEdgesOnCell, verticesOnCell, nVertices, sphereRadius)

! call runReconstructionTest(mpMesh, numMPs, numPush, nCells, nVertices, mp2Elm, &
! latVertex, lonVertex, nEdgesOnCell, verticesOnCell, sphereRadius)
call runReconstructionTest(mpMesh, numMPs, numPush, nCells, nVertices, mp2Elm, &
latVertex, lonVertex, nEdgesOnCell, verticesOnCell, sphereRadius)

call runApiTest(mpMesh, numMPs, nVertices, nCells, numPush, mpLatLon, mpPosition, xVertex, yVertex, zVertex, latVertex)
!call runApiTest(mpMesh, numMPs, nVertices, nCells, numPush, mpLatLon, mpPosition, xVertex, yVertex, zVertex, latVertex)

call polympo_summarizeTime();

Expand Down

0 comments on commit 5f6d963

Please sign in to comment.