Skip to content

Commit

Permalink
Have increased precision of LAT and LON outputs for SMC grids within …
Browse files Browse the repository at this point in the history
…ww3_ounf by increasing the decimal places in the spaceholder used to calculate the structured grid coordinates. Have removed redundant tests using dbllat and dbllon.
  • Loading branch information
ukmo-kitstokes committed Feb 13, 2025
1 parent a7c4891 commit 70efcbc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 32 deletions.
2 changes: 0 additions & 2 deletions model/src/w3metamd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ SUBROUTINE META_LIST_APPEND_D(LIST, ATTNAME, DVAL)

TYPE(META_LIST_T), INTENT(INOUT) :: LIST
CHARACTER(*), INTENT(IN) :: ATTNAME
!INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(15)
!REAL(dp), INTENT(IN) :: DVAL
DOUBLE PRECISION, INTENT(IN) :: DVAL
!/ ------------------------------------------------------------------- /
!/ Local parameters
Expand Down
4 changes: 0 additions & 4 deletions model/src/w3ounfmetamd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1271,8 +1271,6 @@ SUBROUTINE GET_ATTVAL_TYPE(BUF, ILINE, ATTV, ATT_TYPE)
!
REAL :: R
INTEGER :: I, IERR
!INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(15)
!REAL(dp) :: D
DOUBLE PRECISION :: D

! Get attribute and type (default to "c" if no type set)
Expand Down Expand Up @@ -2338,8 +2336,6 @@ SUBROUTINE WRITE_FREEFORM_META_LIST(NCID, VARID, METALIST, ERR)
!/
INTEGER :: I, IVAL
REAL :: RVAL
!INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(15)
!REAL(dp) :: DVAL
DOUBLE PRECISION :: DVAL
TYPE(META_PAIR_T), POINTER :: P

Expand Down
36 changes: 10 additions & 26 deletions model/src/ww3_ounf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,6 @@ SUBROUTINE W3EXNC ( NX, NY, IX1, IXN, IY1, IYN, NSEA, &
#endif
!
REAL,DIMENSION(:), ALLOCATABLE :: LON, LAT, FREQ
DOUBLE PRECISION,DIMENSION(:), ALLOCATABLE :: DBLLON, DBLLAT
REAL,DIMENSION(:,:), ALLOCATABLE :: LON2D, LAT2D, ANGLD2D
#ifdef W3_RTD
REAL,DIMENSION(:,:), ALLOCATABLE :: LON2DEQ, LAT2DEQ
Expand Down Expand Up @@ -2212,8 +2211,6 @@ SUBROUTINE W3EXNC ( NX, NY, IX1, IXN, IY1, IYN, NSEA, &
! Regular gridded file
IF(.NOT.ALLOCATED(lon)) ALLOCATE(lon(NXO))
IF(.NOT.ALLOCATED(lat)) ALLOCATE(lat(NYO))
IF(.NOT.ALLOCATED(dbllon)) ALLOCATE(dbllon(NXO))
IF(.NOT.ALLOCATED(dbllat)) ALLOCATE(dbllat(NYO))
#endif
#ifdef W3_RTD
! Intermediate EQUatorial lat/lon arrays for de-rotation
Expand Down Expand Up @@ -2296,17 +2293,13 @@ SUBROUTINE W3EXNC ( NX, NY, IX1, IXN, IY1, IYN, NSEA, &
#ifdef W3_SMC
ELSE
! CB: Regridded SMC data
SXD=DBLE(0.000001d0*DNINT(1d6*(DBLE(DXO)) ))
SYD=DBLE(0.000001d0*DNINT(1d6*(DBLE(DYO)) ))
X0D=DBLE(0.000001d0*DNINT(1d6*(DBLE(SXO)) ))
Y0D=DBLE(0.000001d0*DNINT(1d6*(DBLE(SYO)) ))
SXD=DBLE(0.00000001d0*DNINT(1d8*(DBLE(DXO)) ))
SYD=DBLE(0.00000001d0*DNINT(1d8*(DBLE(DYO)) ))
X0D=DBLE(0.00000001d0*DNINT(1d8*(DBLE(SXO)) ))
Y0D=DBLE(0.00000001d0*DNINT(1d8*(DBLE(SYO)) ))

!LON(1) = X0D
!LAT(1) = Y0D
DO i=1,NXO
lon(i)=REAL(X0D+SXD*DBLE(i-1))
! KS: Regridded SMC data - use double precision
dbllon(i)=DBLE(X0D+SXD*DBLE(i-1))
#endif
#ifdef W3_RTD
LON2DEQ(i,:) = lon(i)
Expand All @@ -2315,8 +2308,6 @@ SUBROUTINE W3EXNC ( NX, NY, IX1, IXN, IY1, IYN, NSEA, &
END DO
DO i=1,NYO
lat(i)=REAL(Y0D+SYD*DBLE(i-1))
! KS: Regridded SMC data - use double precision
dbllat(i)=DBLE(Y0D+SYD*DBLE(i-1))
#endif
#ifdef W3_RTD
LAT2DEQ(:,i) = lat(i)
Expand Down Expand Up @@ -2347,13 +2338,11 @@ SUBROUTINE W3EXNC ( NX, NY, IX1, IXN, IY1, IYN, NSEA, &
ENDIF ! SMCOTYPE
#endif
ELSE ! SMCGRD
SXD=DBLE(0.000001d0*DNINT(1d6*(DBLE(SX)) ))
SYD=DBLE(0.000001d0*DNINT(1d6*(DBLE(SY)) ))
X0D=DBLE(0.000001d0*DNINT(1d6*(DBLE(X0)) ))
Y0D=DBLE(0.000001d0*DNINT(1d6*(DBLE(Y0)) ))
SXD=DBLE(0.00000001d0*DNINT(1d8*(DBLE(SX)) ))
SYD=DBLE(0.00000001d0*DNINT(1d8*(DBLE(SY)) ))
X0D=DBLE(0.00000001d0*DNINT(1d8*(DBLE(X0)) ))
Y0D=DBLE(0.00000001d0*DNINT(1d8*(DBLE(Y0)) ))

!LON(1) = X0D
!LAT(1) = Y0D
DO I=1,NX
LON(I)=REAL(X0D+SXD*DBLE(I-1))
END DO
Expand Down Expand Up @@ -2490,11 +2479,6 @@ SUBROUTINE W3EXNC ( NX, NY, IX1, IXN, IY1, IYN, NSEA, &
CALL CHECK_ERR(IRET)
IRET=NF90_PUT_VAR(NCID,VARID(6),SMCCY)
CALL CHECK_ERR(IRET)
ELSE ! KS: For regridded SMC data, change from real to double precision
IRET=NF90_PUT_VAR(NCID,VARID(1),dbllon(:))
CALL CHECK_ERR(IRET)
IRET=NF90_PUT_VAR(NCID,VARID(2),dbllat(:))
CALL CHECK_ERR(IRET)
ENDIF
#endif
ELSE ! SMCGRD
Expand Down Expand Up @@ -3406,9 +3390,9 @@ SUBROUTINE W3CRNC (NCFILE, NCID, DIMID, DIMLN, VARID, &
#ifdef W3_SMC
IF(SMCOTYPE .EQ. 1) THEN
! Flat SMC grid - use seapoint dimension:
IRET = NF90_DEF_VAR(NCID, 'longitude', NF90_FLOAT, DIMID(2), VARID(1))
IRET = NF90_DEF_VAR(NCID, 'longitude', NF90_DOUBLE, DIMID(2), VARID(1))
CALL CHECK_ERR(IRET)
IRET = NF90_DEF_VAR(NCID, 'latitude', NF90_FLOAT, DIMID(2), VARID(2))
IRET = NF90_DEF_VAR(NCID, 'latitude', NF90_DOUBLE, DIMID(2), VARID(2))
CALL CHECK_ERR(IRET)

! Latitude and longitude are auxililary variables in type 1 sea point
Expand Down

0 comments on commit 70efcbc

Please sign in to comment.