* PACKAGE DGENG  !" 力学 スペクトル→格子点値
*
************************************************************************
      SUBROUTINE GENGD          !" 新格子点値の生成
     O         ( GDU   , GDV   , GDT   , GDPS  , GDQ   ,
     O           GDVOR , GDDIV ,
     I           WDVOR , WDDIV , WDT   , WDPI  , WDQ   ,
     C           EDEL  , UVFACT                         )
*
*   [PARAM]
#ifdef SYS_IBMS
      INCLUDE   (ZCDIM)
#else
#include        "zcdim.F"
#endif
*
*   [OUTPUT]
      REAL       GDU   ( IDIM*JDIM, KMAX )   !" 西風  Ｕ
      REAL       GDV   ( IDIM*JDIM, KMAX )   !" 南風  Ｖ
      REAL       GDT   ( IDIM*JDIM, KMAX )   !" 温度  Ｔ
      REAL       GDPS  ( IDIM*JDIM       )   !" 地表気圧 Ｐｓ
      REAL       GDQ   ( IDIM*JDIM, KMAX )   !" 比湿  ｑ
      REAL       GDVOR ( IDIM*JDIM, KMAX )   !" 渦度  ζ
      REAL       GDDIV ( IDIM*JDIM, KMAX )   !" 発散  Ｄ
*
*   [INPUT]
      REAL       WDVOR ( NMDIM , KMAX     )  !" 渦度  ζ
      REAL       WDDIV ( NMDIM , KMAX     )  !" 発散  Ｄ
      REAL       WDT   ( NMDIM , KMAX     )  !" 温度  Ｔ
      REAL       WDPI  ( NMDIM            )  !" log Ps ＝π
      REAL       WDQ   ( NMDIM , KMAX     )  !" 比湿  ｑ
*
      REAL       EDEL  ( NMDIM  )            !" ζ,Ｄ→Ｕ,Ｖ
      REAL       UVFACT( IDIM*JDIM )         !" u→U のファクター
*
*   [INTERNAL WORK]
      COMMON    /COMWRK/
     &           WDPSI , WDCHI
      REAL       WDPSI ( NMDIM, KMAX      )  !" ψ/a スペクトル
      REAL       WDCHI ( NMDIM, KMAX      )  !" χ/a スペクトル
*
      INTEGER    IJ, K, NM
*
*
*"         < 1. ψ/a, χ/a のスペクトル >
*
      DO 1100 K = 1, KMAX
         DO 1100 NM = 1, NMDIM
            WDPSI( NM,K ) = WDVOR( NM,K ) * EDEL( NM )
            WDCHI( NM,K ) = WDDIV( NM,K ) * EDEL( NM )
 1100 CONTINUE
*
*"         < 2. ζ，Ｄ，Ｔ，π，ｑ格子点値 >
*
      CALL W2G
     O         ( GDVOR ,
     I           WDVOR ,
     I           '    ', 'POS ', KMAX )
*
      CALL W2G
     O         ( GDDIV ,
     I           WDDIV ,
     I           '    ', 'POS ', KMAX )
*
      CALL W2G
     O         ( GDT   ,
     I           WDT   ,
     I           '    ', 'POSO', KMAX )
*
      CALL W2G
     O         ( GDPS  ,
     I           WDPI  ,
     I           '    ', 'POSO', 1    )
*
      DO 2100 IJ = 1, IDIM*JDIM
         GDPS ( IJ ) = EXP( GDPS( IJ ) )
 2100 CONTINUE
*
      CALL W2G
     O         ( GDQ   ,
     I           WDQ   ,
     I           '    ', 'POSO', KMAX )
*
*"         < 3.  Ｕ，Ｖ の格子点値 >
*
      CALL W2G
     O         ( GDU   ,
     I           WDPSI ,
     I           'YGRA', 'NEG ', KMAX )
*
      IF ( MMAX .GE. 1 ) THEN
         CALL W2G
     O         ( GDU   ,
     I           WDCHI ,
     I           'XGRA', 'ADD ', KMAX )
      ENDIF
*
      CALL W2G
     O         ( GDV   ,
     I           WDCHI ,
     I           'YGRA', 'POS ', KMAX )
*
      IF ( MMAX .GE. 1 ) THEN
         CALL W2G
     O         ( GDV   ,
     I           WDPSI ,
     I           'XGRA', 'ADD ', KMAX )
      ENDIF
*
      DO 3100 K = 1, KMAX
         DO 3100 IJ = 1, IDIM*JDIM
            GDU ( IJ,K ) = GDU ( IJ,K ) / UVFACT( IJ )
            GDV ( IJ,K ) = GDV ( IJ,K ) / UVFACT( IJ )
 3100 CONTINUE
*
      RETURN
      END
