Go to the documentation of this file.
77 DOUBLE PRECISION ::
sxo
78 DOUBLE PRECISION ::
syo
79 DOUBLE PRECISION ::
exo
80 DOUBLE PRECISION ::
eyo
81 DOUBLE PRECISION ::
dxo
82 DOUBLE PRECISION ::
dyo
93 INTEGER,
ALLOCATABLE ::
xidx(:)
94 INTEGER,
ALLOCATABLE ::
yidx(:)
95 INTEGER,
ALLOCATABLE ::
xspan(:)
96 INTEGER,
ALLOCATABLE ::
yspan(:)
97 REAL,
ALLOCATABLE ::
wts(:)
98 REAL,
ALLOCATABLE ::
cov(:,:)
148 REAL :: S0CHK, XSNAP, YSNAP
150 INTEGER :: ISEA, mx, my, ixx, iyy, J
175 IF(abs(
sxo + 999.9) .LT. 1e-4)
THEN
178 s0chk = cx0 + floor((
sxo - cx0) / xsnap) * xsnap
180 IF (s0chk .LT.
sxo)
THEN
186 IF(abs(
syo + 999.9) .LT. 1e-4)
THEN
189 s0chk = cy0 + floor((
syo - cy0) / ysnap) * ysnap
191 IF (s0chk .LT.
syo)
THEN
200 IF(abs(
exo + 999.9) .LT. 1e-4)
THEN
203 IF(abs(
eyo + 999.9) .LT. 1e-4)
THEN
246 lon = lon + 0.5 * mx *
dlon
247 lat = lat + 0.5 * my *
dlat
248 IF(lon .LT.
sxo) lon = lon + 360.0
249 IF(lon .GT.
exo) lon = lon - 360.0
252 IF(lon .GE.
sxo .AND. lon .LE.
exo .AND. &
253 lat .GE.
syo .AND. lat .LE.
eyo )
THEN
265 IF(lon .LT.
sxo)
THEN
268 IF(lon .GT.
exo)
THEN
285 IF(ixx .LE. 0 .AND. ixx + mx /
celfac .GT. 0)
THEN
286 DO WHILE(mx .GT.
cfac)
293 IF(iyy .LE. 0 .AND. iyy + my /
celfac .GT. 0)
THEN
294 DO WHILE(my .GT.
cfac)
303 IF(ixx .LE. 0 .OR. ixx .GT.
nxo .OR. &
304 iyy .LE. 0 .OR. iyy .GT.
nyo)
THEN
320 IF(
xspan(isea) .GT. 1)
THEN
321 IF(abs((
sxo+(ixx-1)*
dxo) - lon) .GT.
dxo/100.0)
THEN
322 print*,
'Potential problem with SMC grid cell span:'
326 print*,
"diff:", (
sxo+(ixx-1)*
dxo) - lon
364 REAL,
INTENT(IN) :: S(:)
365 REAL,
INTENT(OUT) :: XY(NXO,NYO)
368 INTEGER :: I, J, IX, IY, ISEA, ISMC
377 IF(s(isea) .EQ.
undef) cycle
380 DO i=0,
xspan(isea) - 1
381 DO j=0,
yspan(isea) - 1
386 IF(ix .GT. nxo .OR. iy .GT. nyo) cycle
389 xy(ix, iy) = xy(ix, iy) + s(isea) *
wts(isea)
401 IF(
mapsmc(ix,iy) .EQ. 0)
THEN
404 ELSE IF(
cov(ix,iy) .LT. 0.5)
THEN
407 ELSE IF(
cov(ix,iy) .LT. 1.0)
THEN
411 xy(ix,iy) = xy(ix,iy) * ( 1.0 /
cov(ix,iy) )
443 REAL,
INTENT(IN) :: S(:)
444 REAL,
INTENT(OUT) :: XY(NXO,NYO)
447 INTEGER :: I, J, IX, IY, ISEA, ISMC
448 REAL,
ALLOCATABLE :: AUX1(:,:), AUX2(:,:)
452 ALLOCATE(aux1(nxo,nyo),aux2(nxo,nyo))
461 IF(s(isea) .EQ.
undef) cycle
466 DO i=0,
xspan(isea) - 1
467 DO j=0,
yspan(isea) - 1
472 IF(ix .GT. nxo .OR. iy .GT. nyo) cycle
476 aux1(ix, iy) = aux1(ix, iy) + coss *
wts(isea)
477 aux2(ix, iy) = aux2(ix, iy) + sins *
wts(isea)
489 IF(
mapsmc(ix,iy) .EQ. 0)
THEN
492 ELSE IF(
cov(ix,iy) .LT. 0.5)
THEN
495 ELSE IF(
cov(ix,iy) .LT. 1.0)
THEN
499 xy(ix,iy) = atan2(aux2(ix,iy), aux1(ix,iy))
500 xy(ix,iy) = mod(630. -
rade * xy(ix,iy), 360. )
502 xy(ix,iy) = atan2(aux2(ix,iy), aux1(ix,iy))
503 xy(ix,iy) = mod(630. -
rade * xy(ix,iy), 360. )
523 INTEGER :: I, J, IX, IY, IMX, IMY, ISEA
533 IF(
xidx(isea) .EQ. -1) cycle
536 DO i=0,
xspan(isea) - 1
537 DO j=0,
yspan(isea) - 1
542 IF(ix .GT.
nxo .OR. iy .GT.
nyo) cycle
546 IF(
mapsta(imy, imx) .NE. 0)
THEN
558 IF(
cov(ix,iy) .LT. 0.5)
THEN
585 INTEGER :: IERR, I, J
590 OPEN(
ndsmc,
file=
'smcint.ww3', status=
'old', form=
'unformatted', convert=
file_endian, iostat=ierr)
592 WRITE(*,*)
"ERROR! Failed to open smcint.ww3 for reading"
632 INTEGER :: IERR, I, J, ISEA, N, CFAC
633 REAL :: mlon(NSEA), mlat(NSEA), olon(nxo,nyo), olat(nxo,nyo), &
634 ang(nxo,nyo), lon, lat
636 REAL :: tmplon(nxo,nyo), tmplat(nxo,nyo)
650 mlon(isea) = (x0-0.5*sx) + (ijkcel(1,isea) + 0.5 * ijkcel(3,isea)) *
dlon
651 mlat(isea) = (y0-0.5*sy) + (ijkcel(2,isea) + 0.5 * ijkcel(4,isea)) *
dlat
657 olon(i,j) =
sxo + (i-1) *
dxo
658 olat(i,j) =
syo + (j-1) *
dyo
665 print*,
'Rotating coordinates'
666 CALL w3lltoeq ( tmplat, tmplon, olat, olon, &
668 print*,
'Rotating coordinates complete'
679 IF(lon .LT. x0 - sx / 2) lon = lon + 360.0
680 IF(lon .GT. (x0 + (nx-1) * sx) + 0.5 * sx) lon = lon - 360.0
682 IF(mlon(isea) - 0.5 * ijkcel(3,isea) *
dlon .LE. lon .AND. &
683 mlon(isea) + 0.5 * ijkcel(3,isea) *
dlon .GE. lon .AND. &
684 mlat(isea) - 0.5 * ijkcel(4,isea) *
dlat .LE. lat .AND. &
685 mlat(isea) + 0.5 * ijkcel(4,isea) *
dlat .GE. lat )
THEN
716 REAL,
INTENT(IN) :: S(:)
717 REAL,
INTENT(OUT) :: XY(NXO,NYO)
718 LOGICAL,
INTENT(IN) :: DIRN
721 INTEGER :: I, J, IX, IY, ISEA, ISMC
725 IF(isea .EQ. -1)
THEN
729 IF(s(isea) .EQ.
undef)
THEN
736 xy(ix,iy) = mod(630. -
rade * xy(ix,iy), 360.0)
768 REAL,
INTENT(IN) :: S(:)
769 REAL,
INTENT(OUT) :: XY(NXO,NYO)
770 LOGICAL,
INTENT(IN) :: DIRN
773 INTEGER :: I, J, IX, IY, ISEA, ISMC
775 REAL :: GrdX(NSEA), GrdY(NSEA)
785 IF(isea .EQ. -1)
THEN
789 xy(ix,iy) = s(isea) + grdx(isea) *
xdist(ix,iy) + grdy(isea) *
ydist(ix,iy)
792 xy(ix,iy) = mod(630. -
rade * xy(ix,iy), 360.0)
820 REAL,
INTENT(IN) :: S(:)
821 REAL,
INTENT(OUT) :: XY(NXO,NYO)
822 LOGICAL,
OPTIONAL :: DIR
827 IF(
PRESENT(dir))
THEN
839 IF(xy(isea,1) .NE.
undef)
THEN
840 xy(isea,1) = mod(630. -
rade * xy(isea,1), 360.)
858 WRITE(*,*)
"Uknonwn SMC type!",
smcotype
integer nxo
Output grid number of longitude cells.
integer, dimension(:), allocatable smccy
Latitude cell size factors.
integer nsmc
Number of SMC cells used in regridding.
real, parameter dera
DERA Conversion factor from degrees to radians.
integer celfac
Output grid cell scaling factor; should be an integer power of 2.
integer, dimension(:,:), allocatable mapsmc
Regridded MAPSTA.
integer nyo
Output grid number of latitude cells.
subroutine w3s2xy_smcnn(S, XY, DIRN)
Fill regular grid using nearest SMC point data.
real, dimension(:,:), allocatable xdist
Lng.
real dlat
Base longitude cell size.
subroutine calc_interp()
Calculates weights for SMC to arbitrary grid intepolation.
subroutine w3s2xy_smc(S, XY, DIR)
Entry point for SMC version of W3S2XY.
real dlon
Base latitude cell size.
real, parameter rade
RADE Conversion factor from radians to degrees.
subroutine w3s2xy_smcrg_dir(S, XY)
Regrid directional SMC data onto a regular grid.
logical, dimension(:), allocatable smcmask
Mask for type 1 output (flat array)
integer, dimension(:), allocatable smcidx
Indices of SMC cells within output grid domain.
double precision exo
Output grid final longitude.
subroutine mapsta_smc()
Calculates a new MAPSTA using SMC grid cell averaging.
subroutine w3s2xy_smcrg(S, XY)
Regrid SMC data onto a regular grid.
integer, dimension(:), allocatable xidx
X-indices of SMC cells in regular grid.
subroutine w3lltoeq(PHI, LAMBDA, PHI_EQ, LAMBDA_EQ, ANGLED, PHI_POLE, LAMBDA_POLE, POINTS)
double precision eyo
Output grid final latitude.
integer ndsmc
ww3_smcint file unit number
integer, dimension(:,:), allocatable nnidx
Nearest neighbour SMC point to regular grid.
real, dimension(:), pointer clats
subroutine smcgradn(CVQ, GrdX, GrdY, L0r1)
Evaluate local gradient for sea points.
double precision sxo
Output grid longitude origin.
integer, dimension(:), allocatable smccx
SMC grid definition.
integer, dimension(:,:), pointer mapsf
double precision dxo
Output grid cell longitude size.
file(STRINGS ${CMAKE_BINARY_DIR}/switch switch_strings) separate_arguments(switches UNIX_COMMAND $
real, parameter radius
RADIUS Radius of the earth (m).
integer smcnout
Number of SMC output cells.
Service module for support of SMC regridding and interpolation.
integer, dimension(:,:), pointer ijkcel
integer, dimension(:), allocatable xspan
Number of longitude cells SMC cell spans.
Spherical Multiple-Cell (SMC) grid routines.
subroutine w3s2xy_smcnn_int(S, XY, DIRN)
Nearest neighbour interpolation.
Define some much-used constants for global use (all defined as PARAMETER).
character(*), parameter file_endian
FILE_ENDIAN Filled by preprocessor with 'big_endian', 'little_endian', or 'native'.
subroutine extcde(IEXIT, UNIT, MSG, FILE, LINE, COMM)
subroutine read_smcint()
Read interpolation information from smcint.ww3.
subroutine smc_interp()
Generate SMC interpolation/output information.
integer, dimension(:), allocatable yspan
Number of longitude cells SMC cell spans.
real noval
Fill value for seapoints with no value.
integer, dimension(:), allocatable yidx
Y-Indices of SMC cells in regular grid.
double precision syo
Output grid latitude origin.
real undef
UNDEF Value for undefined variable in output.
integer smcotype
Type of SMC output: 1=seapoint grid of SMC cells; 2=regridding to regular grid; 3=interpolation to ar...
double precision dyo
Output grid cell latitude size.
real, dimension(:), allocatable wts
Regridding weights.
real, dimension(:,:), allocatable ydist
Lat.
real, dimension(:,:), allocatable cov
Wet fraction (coverage) of cell.
integer, dimension(:,:), pointer mapsta
integer cfac
SMC scaling factor (number of levels)