* PACKAGE   !"  定数(緯度経度座標値)
*
*"  [HIS] 90/05/19(numaguti)
*"  [HIS] 97/09/26(horinout) bug fix: SAVE文の書き忘れ
*"        98/01/18(akahori)  SETLAT: SMPACK-0.0 対応
*"        98/03/07(akahori)  SETLAT: SMPACK-1.0 対応
*"
*"  [NOTE] このサブルーチン内で SMPACK を初期化している
*"
***********************************************************************
      SUBROUTINE SETLAT      !"  モデル緯度座標定数の計算 
     O         ( ALAT  , DLAT  , HALAT  ,
     D           JMAX  , JDIM             )
*
*"    ------ 座標格子定数 -------------------------------------
*
      INTEGER    JMAX, JDIM
      REAL       ALAT  ( JDIM )              !" 緯度
      REAL       DLAT  ( JDIM )              !" 緯度荷重
*
#ifdef SYS_IBMS
      INCLUDE   (ZHDIM)                      !" 文字列文字数
#else
#include        "zhdim.F"
#endif
*    [INTERNAL PARAM]
      CHARACTER  HALAT0 *(NCC), HALAT  *(NCC) !" 緯度軸名称
      DATA       HALAT0 / 'GGLA' /
      CHARACTER  HNUM   *(NCC)
      SAVE       HALAT0
*    
*    [INTERNAL WORK]
      INTEGER    J, INUM, IAY
      REAL       SUMGW
*
*    [EXTERNAL FUNC]
      INTEGER    LENC
*
*"         < 1. 緯度・ガウス荷重の計算 >
*
      CALL DSMINI       !" 多層用 SMPACK (dynamics_sm/dsm.F) を初期化
      CALL DS1INI       !" 一層用 SMPACK (dynamics_sm/ds1.F) を初期化
      CALL DSMGAU
     O     ( ALAT , DLAT )
*
      SUMGW=0.0  
      DO 1100 J = 1, JMAX
         SUMGW = SUMGW + DLAT ( J )
 1100 CONTINUE
*
      WRITE ( 6,* ) ' check SUMGW = ', SUMGW
*
      DO 1200 J = JMAX+1, JDIM
         ALAT  ( J ) = ALAT   ( JMAX  )
         DLAT  ( J ) = DLAT   ( JMAX  )
 1200 CONTINUE
*
*"         < 2. 軸の名称 >
*
*--------------------------------------------------------------------
      ENTRY      STNLAT
     O         ( HALAT ,
     I           JMAX    )
*
      CALL GULCHR
     I     ( '(I4)', JMAX  ,
     O       HNUM  , INUM   )
      IAY  = LENC( HALAT0 )
      HALAT  = HALAT0(1:IAY)//HNUM(1:INUM)
*
      RETURN
      END
***********************************************************************
      SUBROUTINE SETLON      !"  モデル経度座標定数の計算 
     O         ( ALON  , DLON  , HALON ,
     D           IMAX  , IDIM            )
*
*"    ------ 座標格子定数 -------------------------------------
*
      INTEGER    IMAX, IDIM
      REAL       ALON  ( IDIM )              !" 経度
      REAL       DLON  ( IDIM )              !" 経度差分
*
#ifdef SYS_IBMS
      INCLUDE   (ZHDIM)                      !" 文字列文字数
#else
#include        "zhdim.F"
#endif
*    [INTERNAL PARAM]
      CHARACTER  HALON0 *(NCC), HALON  *(NCC) !" 経度軸名称
      DATA       HALON0 / 'GLON' /
      CHARACTER  HNUM   *(NCC)
      SAVE       HALON0
*
*    [INTERNAL WORK]
      INTEGER    I, INUM, IAY
      REAL       PI
*
*    [EXTERNAL FUNC]
      INTEGER    LENC
*
*"         < 1. 経度の計算 >
*
      PI = ATAN( 1. ) *4.
      DO 1100 I = 1, IDIM
         ALON  ( I ) = Real( I-1 ) / Real( IMAX ) * 2. * PI
         DLON  ( I ) = 1. / Real( IMAX )
 1100 CONTINUE
*
*"         < 2. 軸の名称 >
*
*--------------------------------------------------------------------
      ENTRY      STNLON
     O         ( HALON ,
     I           IMAX    )
*
      CALL GULCHR
     I     ( '(I4)', IMAX  ,
     O       HNUM  , INUM   )
      IAY  = LENC( HALON0 )
      HALON  = HALON0(1:IAY)//HNUM(1:INUM)
*
      RETURN
      END
