* PACKAGE   !"  定数(緯度経度座標値)
*
*"  [HIS] 90/05/19(numaguti)
*
***********************************************************************
      SUBROUTINE SETLAT      !"  モデル緯度座標定数の計算 
     O         ( ALAT  , DLAT  , HALAT  ,
     D           JMAX  , JDIM             )
*
*"    ------ 座標格子定数 -------------------------------------
*
      INTEGER    JMAX, JDIM
      REAL       ALAT  ( JDIM )              !" 緯度
      REAL       DLAT  ( JDIM )              !" 緯度荷重
*
      INTEGER    JDIMD
      PARAMETER  ( JDIMD=200 )
      REAL * 8   QSINLA( JDIMD )             !" sin（緯度）：倍精度
      REAL * 8   QGW   ( JDIMD )             !" ガウス荷重 ：倍精度
*
#ifdef SYS_IBMS
      INCLUDE   (ZHDIM)
#else
#include        "zhdim.F"
#endif
*    [INTERNAL PARAM]
      CHARACTER  HALAT0 *(NCC), HALAT  *(NCC) !" 緯度軸名称
      DATA       HALAT0 / 'GGLA' /
      CHARACTER  HNUM   *(NCC)
      REAL       ALATD0                       !" JMAX=のとき(degree)
      DATA       ALATD0 / 0.0  /
      NAMELIST  /NMLAT0/ ALATD0
*    
*    [INTERNAL WORK]
      INTEGER    IFPAR, JFPAR, J, INUM, IAY
      REAL       PI, SUMGW
*
*    [EXTERNAL FUNC]
      INTEGER    LENC
*
      IF ( JMAX .GT. JDIMD ) THEN
         CALL MSGDMP( 'E', 'SETLAT', 'WORK AREA OVERFULL' )
         RETURN
      ENDIF
*
*"         < 1. 緯度・ガウス荷重の計算 >
*
      IF ( JMAX .GE. 2 ) THEN
         CALL GAUSS
     O         ( QSINLA , QGW    ,
     I           JMAX             )
      ELSE
*
         WRITE ( 6,* ) ' CONTROL PARAMETER NMLAT0: '
*
         CALL   REWNML ( IFPAR , JFPAR )
         READ   ( IFPAR, NMLAT0, END=1090 )
 1090    WRITE  ( JFPAR, NMLAT0 )
         PI = ATAN( 1. )*4.
         QSINLA ( 1 ) = SIN( ALATD0/180.*PI )
         QGW    ( 1 ) = 1.0
      ENDIF
*
      SUMGW=0.0  
      DO 1100 J = 1, JMAX
         ALAT  ( J ) = ASIN ( QSINLA ( J ) )
         DLAT  ( J ) = QGW ( J )
         SUMGW = SUMGW + QGW ( 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)
*
*    [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
