WAVEWATCH III  beta 0.0.1
ww3_prnc.F90 File Reference

Contains program W3PRNC. More...

Go to the source code of this file.

Functions/Subroutines

program w3prnc
 Pre-processing of input fields. More...
 
subroutine interp (MXM, MYM, XC, IX21, IX22, IY21, IY22, RD11, RD12, RD21, RD22, FILLVALUE, FA)
 Interpolate from a field read from file to the wave grid. More...
 
subroutine check_error (IRET, ILINE)
 Desc not available. More...
 

Detailed Description

Contains program W3PRNC.

Author
M. Accensi
F. Ardhuin
Date
22-Mar-2021

Definition in file ww3_prnc.F90.

Function/Subroutine Documentation

◆ check_error()

subroutine check_error ( integer  IRET,
integer  ILINE 
)

Desc not available.

Parameters
IRET
ILINE
Author
NA
Date
NA

Definition at line 2722 of file ww3_prnc.F90.

2722 
2723  USE netcdf
2724  USE w3odatmd, ONLY: ndse
2725  USE w3servmd, ONLY: extcde
2726 
2727  IMPLICIT NONE
2728 
2729  INTEGER IRET, ILINE
2730 
2731  IF (iret .NE. nf90_noerr) THEN
2732  WRITE(ndse,*) ' *** WAVEWATCH III ERROR IN PRNC :'
2733  WRITE(ndse,*) ' LINE NUMBER ', iline
2734  WRITE(ndse,*) ' NETCDF ERROR MESSAGE: '
2735  WRITE(ndse,*) nf90_strerror(iret)
2736  CALL extcde ( 59 )
2737  END IF
2738  RETURN
2739 

References w3servmd::extcde(), and w3odatmd::ndse.

◆ interp()

subroutine interp ( integer, intent(in)  MXM,
integer, intent(in)  MYM,
real, dimension(mxm,mym), intent(in)  XC,
integer, dimension(nx,ny), intent(in)  IX21,
integer, dimension(nx,ny), intent(in)  IX22,
integer, dimension(nx,ny), intent(in)  IY21,
integer, dimension(nx,ny), intent(in)  IY22,
real, dimension(nx,ny), intent(in)  RD11,
real, dimension(nx,ny), intent(in)  RD12,
real, dimension(nx,ny), intent(in)  RD21,
real, dimension(nx,ny), intent(in)  RD22,
real, intent(in)  FILLVALUE,
real, dimension(nx,ny), intent(out)  FA 
)

Interpolate from a field read from file to the wave grid.

Invalid points are identified by the fill value read from the netcdf input, and interpolation does not take into account these points. The valid interpolation coefficients are scaled so that the sum is one, otherwise unphysical values can be generated.

When one point is on the boundary but is not an ocean grid point, the interpolation coefficients are zero, and in this case we provide a sensible value - the value as read, not interpolated

Parameters
[in]MXMDimension X of XC variable
[in]MYMDimension Y of XC variable
[in]XCField to be interpolated, as read from the input netcdf
[in]IX21List of x-index to convert from the original field to the model grid
[in]IX22List of x-index to convert from the original field to the model grid
[in]IY21List of y-index to convert from the original field to the model grid
[in]IY22List of x-index to convert from the original field to the model grid
[in]RD11Interpolation factor
[in]RD12Interpolation factor
[in]RD21Interpolation factor
[in]RD22Interpolation factor
[in]FILLVALUEFill value identifying non valid input
[out]FAResult of the interpolation
Author
J. M. Castillo
Date
23-Feb-2021

Definition at line 2580 of file ww3_prnc.F90.

2580  !/
2581  !/ +-----------------------------------+
2582  !/ | WAVEWATCH III NOAA/NCEP |
2583  !/ | J. M. Castillo |
2584  !/ | FORTRAN 90 |
2585  !/ | Last update : 23-Feb-2021 |
2586  !/ +-----------------------------------+
2587  !/
2588  !/ 23-Feb-2021 : First version ( version 7.12 )
2589  !/
2590  ! 1. Purpose :
2591  !
2592  ! Interpolate from a field read from file to the wave grid
2593  !
2594  ! 2. Method :
2595  !
2596  ! Invalid points are identified by the fill value read from the
2597  ! netcdf input, and interpolation does not take into account
2598  ! these points. The valid interpolation coefficients are scaled
2599  ! so that the sum is one, otherwise unphysical values can be
2600  ! generated.
2601  !
2602  ! When one point is on the boundary but is not an ocean grid point,
2603  ! the interpolation coefficients are zero, and in this case we
2604  ! provide a sensible value - the value as read, not interpolated
2605  !
2606  ! 3. Parameters :
2607  !
2608  ! Parameter list
2609  ! ----------------------------------------------------------------
2610  ! MxM I I Dimensions of the XC variable
2611  ! XC R.A. I Field to be interpolated, as read from the
2612  ! input netcdf
2613  ! IXxx I.A. I List of x-index to convert from the original
2614  ! field to the model grid
2615  ! IYxx I.A. I List of y-index to convert from the original
2616  ! field to the model grid
2617  ! RDxx R.A. I Interpolation factors
2618  ! FILLVALUE R I Fill value identifying non valid input
2619  ! FA F O Result of the interpolation
2620  ! ----------------------------------------------------------------
2621  !
2622  ! 4. Subroutines used :
2623  !
2624  ! None
2625  !
2626  ! 5. Called by :
2627  !
2628  ! Name Type Module Description
2629  ! ----------------------------------------------------------------
2630  ! WW3_PRNC Prog. N/A Input data preprocessor.
2631  ! ----------------------------------------------------------------
2632  !
2633  ! 6. Error messages :
2634  !
2635  ! None
2636  !
2637  ! 7. Remarks :
2638  !
2639  ! 8. Structure :
2640  !
2641  ! See source code.
2642  !
2643  ! 9. Switches :
2644  !
2645  ! 10. Source code :
2646  !
2647  !/ ------------------------------------------------------------------- /
2648  USE w3gdatmd, ONLY: nx, ny
2649 
2650  IMPLICIT NONE
2651  !/
2652  !/ ------------------------------------------------------------------- /
2653  !/ Parameter list
2654  !/
2655  INTEGER, INTENT(IN) :: MXM, MYM
2656  REAL, DIMENSION(MXM,MYM), INTENT(IN) :: XC
2657  INTEGER, DIMENSION(NX,NY), INTENT(IN) :: IX21, IX22, IY21, IY22
2658  REAL, DIMENSION(NX,NY), INTENT(IN) :: RD11, RD12, RD21, RD22
2659  REAL, INTENT(IN) :: FILLVALUE
2660  REAL, DIMENSION(NX,NY), INTENT(OUT) :: FA
2661  !/
2662  !/ ------------------------------------------------------------------- /
2663  !/ Local variables
2664  !/
2665  INTEGER :: IX, IY
2666  REAL :: FACTOR
2667  !/ ------------------------------------------------------------------- /
2668 
2669  DO iy=1,ny
2670  DO ix=1,nx
2671  factor = 0.0
2672  fa(ix,iy) = 0.0
2673 
2674  IF(xc(ix21(ix,iy),iy21(ix,iy)).NE.fillvalue) THEN
2675  factor = factor + rd11(ix,iy)
2676  fa(ix,iy) = rd11(ix,iy) * xc(ix21(ix,iy),iy21(ix,iy))
2677  ENDIF
2678  IF(xc(ix22(ix,iy),iy21(ix,iy)).NE.fillvalue) THEN
2679  factor = factor + rd21(ix,iy)
2680  fa(ix,iy) = fa(ix,iy) + rd21(ix,iy) * xc(ix22(ix,iy),iy21(ix,iy))
2681  ENDIF
2682  IF(xc(ix21(ix,iy),iy22(ix,iy)).NE.fillvalue) THEN
2683  factor = factor + rd12(ix,iy)
2684  fa(ix,iy) = fa(ix,iy) + rd12(ix,iy) * xc(ix21(ix,iy),iy22(ix,iy))
2685  ENDIF
2686  IF(xc(ix22(ix,iy),iy22(ix,iy)).NE.fillvalue) THEN
2687  factor = factor + rd22(ix,iy)
2688  fa(ix,iy) = fa(ix,iy) + rd22(ix,iy) * xc(ix22(ix,iy),iy22(ix,iy))
2689  ENDIF
2690 
2691  IF(factor.GT.0.0) THEN
2692  fa(ix,iy) = fa(ix,iy) / factor
2693  ELSE
2694  ! Interpolation coefficients sum to zero - could be on a boundary
2695  ! (see note in "method" above). If any surrounding points have a
2696  ! valid value then use one of them, otherwise set to zero.
2697  IF( xc(ix21(ix,iy),iy21(ix,iy)) .NE. fillvalue) THEN
2698  fa(ix,iy) = xc(ix21(ix,iy),iy21(ix,iy))
2699  ELSE IF( xc(ix22(ix,iy),iy21(ix,iy)) .NE. fillvalue) THEN
2700  fa(ix,iy) = xc(ix22(ix,iy),iy21(ix,iy))
2701  ELSE IF( xc(ix21(ix,iy),iy22(ix,iy)) .NE. fillvalue) THEN
2702  fa(ix,iy) = xc(ix21(ix,iy),iy22(ix,iy))
2703  ELSE IF( xc(ix22(ix,iy),iy22(ix,iy)) .NE. fillvalue) THEN
2704  fa(ix,iy) = xc(ix22(ix,iy),iy22(ix,iy))
2705  ELSE
2706  ! All surrounding points are FILLVALUE - set to zero.
2707  fa(ix,iy) = 0.0
2708  END IF
2709  END IF
2710  END DO
2711  END DO
2712 

References w3gdatmd::nx, and w3gdatmd::ny.

Referenced by w3bounc(), w3bound(), and w3prnc().

◆ w3prnc()

w3gdatmd::ny
integer, pointer ny
Definition: w3gdatmd.F90:1097
w3odatmd::ndse
integer, pointer ndse
Definition: w3odatmd.F90:456
w3servmd
Definition: w3servmd.F90:3
w3odatmd
Definition: w3odatmd.F90:3
w3gdatmd
Definition: w3gdatmd.F90:16
w3servmd::extcde
subroutine extcde(IEXIT, UNIT, MSG, FILE, LINE, COMM)
Definition: w3servmd.F90:736
w3gdatmd::nx
integer, pointer nx
Definition: w3gdatmd.F90:1097