Skip to content

Commit

Permalink
Add grid cell area calculation to wmscrpmd.ftn (port 015fe3f)
Browse files Browse the repository at this point in the history
  • Loading branch information
erinethomas committed Oct 31, 2024
1 parent fd63618 commit 4adda79
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions model/src/wmscrpmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ MODULE WMSCRPMD
!/ Specify default accessibility
!/
PUBLIC
REAL*8 , ALLOCATABLE :: GRID_AREA(:)
!/
!/ Module private variable for checking error returns
!/
Expand Down Expand Up @@ -911,6 +912,37 @@ SUBROUTINE GET_SCRIP_INFO_UNSTRUCTURED (ID_GRD, &
END DO
END IF
END DO

! Calculate area of cell
ALLOCATE(GRID_AREA(MNP))
DO I1=1,MNP
GRID_AREA(I1) = 0.0
NB=NBASSIGNEDCORNER(I1)
DO I2=1,NB
I3 = MOD(I2,NB)+1
PT(1,1)=GRID_CENTER_LON(I1)
PT(2,1)=GRID_CORNER_LON(I2,I1)
PT(3,1)=GRID_CORNER_LON(I3,I1)
PT(1,2)=GRID_CENTER_LAT(I1)
PT(2,2)=GRID_CORNER_LAT(I2,I1)
PT(3,2)=GRID_CORNER_LON(I3,I1)
CALL FIX_PERIODCITY(PT)
ELON1 = PT(1,1)
ELON2 = PT(2,1)
ELON3 = PT(3,1)
ELAT1 = PT(1,2)
ELAT2 = PT(2,2)
ELAT3 = PT(3,2)
DELTALON12=ELON2 - ELON1
DELTALON13=ELON3 - ELON1
DELTALAT12=ELAT2 - ELAT1
DELTALAT13=ELAT3 - ELAT1
THEDET=DELTALON12*DELTALAT13 - DELTALON13*DELTALAT12
GRID_AREA(I1) = GRID_AREA(I1) + ABS(THEDET)
ENDDO
ENDDO


DEALLOCATE(NBASSIGNEDCORNER, STAT=ISTAT)
CHECK_DEALLOC_STATUS ( ISTAT )
DEALLOCATE(LISTNBCORNER, STAT=ISTAT)
Expand Down

0 comments on commit 4adda79

Please sign in to comment.