SUBROUTINE FLDMOD(KAPPA,NU,GAMMA,V1,V2,K1,K2,G1,G2,IKTX,IKTY,KTX, 1
     .     KTY,WN,PXLIM,L,ILAP)
C     
C     INITIALISES MODEL PARAMETERS LIKE WAVENUMBERS, INDICES, SPECTRA, PHASES, ETC.
C     ========================================
C     Diffusion coefficients
C     V1       : Ekman dissipation coefficient
C     V2       : Small-scale dissipation coefficient
C     K1, K2   : same as V1 and V2
C     G1, G2   : same as V1 and V2
C     NU(IKTX,IKTY)w: spectral value of the diffusion for both the Ekman and
C                    small scale diffusion based on V1 and V2
C     KAPPA(IKTX,IKTY): same as NU(IKTX,IKTY) but based on K1 and K2
C     GAMMA(IKTX,IKTY): same as NU(IKTX,IKTY) but based on G1 and G2
C     ========================================
C     Wavenumbers and grid
C     (the number of grid points N is the same in both directions, See the common champ.cdk)
C     IKTX, IKTY: number of spectral components along x and y.
C                 As only half the spectral plane needs to be retained, then
C                 IKTX= KTX+1 while IKTY = 2*KTY +1.
C                 Scanning in Fourier space is then by looping I= 1:PXLIM
C                 and J = 1:IKTY. -IKTX < KX < +IKTX and  -IKTY < KY < +IKTY 
C     KTX, KTY  : N/3, where N is the number of grid points in x and y
C     WN       : total wavenumber squared (KX**2 + KY**2)
C     PXLIM    : maximum number of x-wavenumber (2*KTX +1)
C     L(PXLIM=2*KTX+1,IKTY= 2*KTY+1): =1, if the wavenumber is part of the truncation,
C                                     =0, if the wavenumber is part of the truncation,
C                Used as a mask to filter wavenumbers outside of the truncation
C     ILAP     : order of the Laplaciant hyperviscosity (\nabla^{2*ILAP})
C     =====================================================
C     
      IMPLICIT NONE 
      INTEGER  IKX,IKY,IKTX,IKTY,KTX,KTY,PXLIM 
      INTEGER  ILAP,L(PXLIM,IKTY)

      REAL     KX,KY,WK,V1,V2,K1,K2,G1,G2
      REAL     KAPPA(IKTX,IKTY),NU(IKTX,IKTY),GAMMA(IKTX,IKTY)
      REAL     EK,VK
      REAL     WN(PXLIM,IKTY)
c     
c     Defining the truncation total wavenumbers and the mask L(-KTX:+KTX,-KTY:+KTY)
C     associated with the truncation KTX.
C
      DO  IKX=1,PXLIM
         KX = FLOAT(IKX - KTX - 1)
         DO IKY=1,IKTY
            KY = FLOAT(IKY - KTY - 1)
            L(IKX,IKY)  = 1
            WN(IKX,IKY) = KX*KX + KY*KY
            WK = SQRT(WN(IKX,IKY))
            IF (KX.LT.0)               L(IKX,IKY) =  0
            IF (KX.EQ.0 .AND. KY.LE.0) L(IKX,IKY) =  0
            IF (WK.GT.FLOAT(KTX)-0.5)  L(IKX,IKY) =  0
         enddo
      enddo
C     
C     Definition of the diffusion coefficients in terms of wavenumbers KX and KY
C
      DO  IKX=1,IKTX
         KX = FLOAT(IKX-1)
         DO  IKY=1,IKTY
            KY = FLOAT(IKY-KTY-1)
            WK = SQRT(KX*KX+KY*KY)
            IF(L(IKX+KTX,IKY).ne.1) then
               NU(IKX,IKY)    = 1000.
               KAPPA(IKX,IKY) = 1000.
               GAMMA(IKX,IKY) = 1000.
            else
               NU(IKX,IKY)    = V1 + V2*WK**(2*ILAP)
               KAPPA(IKX,IKY) = K1 + K2*WK**(2*ILAP)
               GAMMA(IKX,IKY) = G1 + G2*WK**(2*ILAP)
            endif
         enddo
      enddo
c     open (16,file='l64.io',status='unknown')
c     write(16,107) ((L(ikx,iky),ikx=1,ikty),iky=1,ikty)
c     107  format(43I3)
c     close(16)

      RETURN
      END