* PACKAGE XMKAXIS   !" GTOOL3 軸ファイルの作成
*
*"  石渡(2001/12/10) 倍精度用に GZDBAP の引数を変更
      
*******************************************************************
      PROGRAM MKAXIS  !" GTOOL3 軸ファイルの作成
*
*   [PARAM] 
#ifdef SYS_IBMS
      INCLUDE   (ZCDIM)                      !" 格子点数, 波数
      INCLUDE   (GZSIZE)
#else
#include        "zcdim.F"                    !" 格子点数, 波数
#include        "gzsize.F"
#endif
*
*   [VAR]
      CHARACTER  HHLON ( NDC )*(NCC)
      REAL       ALON  ( IMAX+1 )
      CHARACTER  HHDLON( NDC )*(NCC)
      REAL       DLON  ( IMAX+1 )
      CHARACTER  HHLAT ( NDC )*(NCC)
      REAL       ALAT  ( JMAX )
      CHARACTER  HHDLAT( NDC )*(NCC)
      REAL       DLAT  ( JMAX )
      CHARACTER  HHSIG ( NDC )*(NCC)
      REAL       SIG   ( KMAX )
      CHARACTER  HHDSIG( NDC )*(NCC)
      REAL       DSIG  ( KMAX )
      CHARACTER  HHSIGM( NDC )*(NCC)
      REAL       SIGM  ( KMAX+1 )
      CHARACTER  HHDSGM( NDC )*(NCC)
      REAL       DSIGM ( KMAX+1 )
*
      CHARACTER  HALON        *(NCC)
      CHARACTER  HALAT        *(NCC)
      CHARACTER  HASIG        *(NCC)
      CHARACTER  HASIGM       *(NCC)
      CHARACTER  HALOC        *(NFILN)
      CHARACTER  HAWGT        *(NFILN)
*
      CHARACTER  HFLON  *(NFILN)
      CHARACTER  HFDLON *(NFILN)
      CHARACTER  HFLAT  *(NFILN)
      CHARACTER  HFDLAT *(NFILN)
      CHARACTER  HFSIG  *(NFILN)
      CHARACTER  HFDSIG *(NFILN)
      CHARACTER  HFSIGM *(NFILN)
      CHARACTER  HFDSGM *(NFILN)
*
*   [INTERNAL PARM] 
      INTEGER    JFILE
      DATA       JFILE / 50 /
      INTEGER    IT
      INTEGER    IDATE ( 6 )
      INTEGER    ISTEP
      INTEGER    ITDUR
      DATA       IT    / 0 /
      DATA       IDATE / 1990, 1, 1, 0, 0, 0 /
      DATA       ISTEP / 0 /
      DATA       ITDUR / 1 /
      CHARACTER  HDFMT *(NCC)
      DATA       HDFMT / 'UR4' /
*
*   [INTERNAL WORK] 
      INTEGER    NHL, NHW
      INTEGER    I, J
      REAL       PI, VMISS
      REAL       XDMIN, XDMAX, XDIVS, XDIVL 
      DATA       XDMIN / 0.   /
      DATA       XDMAX / 360. /
      DATA       XDIVS / 10.  /
      DATA       XDIVL / 30.  /
      REAL       YDMIN, YDMAX, YDIVS, YDIVL 
      DATA       YDMIN / -90. /
      DATA       YDMAX /  90. /
      DATA       YDIVS /  10. /
      DATA       YDIVL /  30. /
      REAL       SDMIN, SDMAX, SDIVS, SDIVL 
      DATA       SDMIN /  0.  /
      DATA       SDMAX /  1.  /
      DATA       SDIVS /  0.1 /
      DATA       SDIVL /  0.2 /
      REAL       SMDMIN, SMDMAX, SMDIVS, SMDIVL 
      DATA       SMDMIN / 0.  /
      DATA       SMDMAX / 1.  /
      DATA       SMDIVS / 0.1 /
      DATA       SMDIVL / 0.2 /

*
*   [EXTERNAYDL FUNC] 
      INTEGER    LENC
*
      CALL GTOPEN
      CALL GTSIZE ( HHLON , IMAX+1 )
      CALL GTSIZE ( HHDLON, IMAX+1 )
      CALL GTSIZE ( HHLAT , JMAX   )
      CALL GTSIZE ( HHDLAT, JMAX   )
      CALL GTSIZE ( HHSIG , KMAX   )
      CALL GTSIZE ( HHDSIG, KMAX   )
      CALL GTSIZE ( HHSIGM, KMAX+1 )
      CALL GTSIZE ( HHDSGM, KMAX+1 )
*
*"         < 1. 格子点設定 >
*
*
      CALL PCONST
*
      CALL SETLON
     O         ( ALON  , DLON  , HALON ,
     D           IMAX  , IDIM            )
*
      PI = ATAN(1.) * 4.
      DO 1100 I = 1, IMAX
         ALON ( I ) = ALON( I )*180./PI
 1100 CONTINUE
      ALON ( IMAX+1 ) = 360.
      DLON ( IMAX+1 ) = DLON( 1 )
*
      CALL SETLAT
     O         ( ALAT  , DLAT  , HALAT ,
     D           JMAX  , JDIM            )
*
      DO 1200 J = 1, JMAX
         ALAT( J ) = ALAT( J )*180/PI
 1200 CONTINUE
*
      CALL SETSIG
     O         ( SIG   , DSIG  , HASIG ,
     O           SIGM  , DSIGM , HASIGM,
     D           KMAX  , KMAX            )
*
*"         < 2. ファイル名 >
*
      CALL GTCGET( 'FAXLOC1', HALOC )
***      CALL GTCGET( 'FAXLOC', HALOC )
      CALL GTCGET( 'FAXWGT1', HAWGT )
***      CALL GTCGET( 'FAXWGT', HAWGT )
*
      NHL = LENC( HALOC )
      NHW = LENC( HAWGT )
*
      HFLON  = HALOC(1:NHL)//HALON
      HFDLON = HAWGT(1:NHW)//HALON
      HFLAT  = HALOC(1:NHL)//HALAT
      HFDLAT = HAWGT(1:NHW)//HALAT
      HFSIG  = HALOC(1:NHL)//HASIG
      HFDSIG = HAWGT(1:NHW)//HASIG
      HFSIGM = HALOC(1:NHL)//HASIGM
      HFDSGM = HAWGT(1:NHW)//HASIGM
*
*"         < 3. ヘッダー設定 >
*
      CALL GZDBGT( 'MISS' , VMISS )
*
      CALL GZDBAP
     O         ( HHLON ,
     I           'CAXLOC', HALON ,
     I           'longitude'   , 'deg' , IMAX ,
     I           'UR4' ,  VMISS,
     I           XDMIN, XDMAX, XDIVS, XDIVL, 1     )
*
      CALL GHCOPY ( HHLON , HHDLON )
      CALL GHCSET ( HHDLON, 'DSET', 'CAXWGT' )
*
      CALL GZDBAP
     O         ( HHLAT ,
     I           'AXLOC', HALAT ,
     I           'latitude'    , 'deg' , JMAX ,
     I           'UR4' ,  VMISS,
     I           YDMIN, YDMAX, YDIVS, YDIVL, 1     )
*
      CALL GHCOPY ( HHLAT , HHDLAT )
      CALL GHCSET ( HHDLAT, 'DSET', 'AXWGT' )
*
      CALL GZDBAP
     O         ( HHSIG ,
     I           'AXLOC', HASIG ,
     I           'sigma'       , ' '   , KMAX ,
     I           'UR4' ,  VMISS,
     I            SDMIN, SDMAX, SDIVS, SDIVL  , -1    )
*
      CALL GHCOPY ( HHSIG , HHDSIG )
      CALL GHCSET ( HHDSIG, 'DSET', 'AXWGT' )
*
      CALL GZDBAP
     O         ( HHSIGM,
     I           'AXLOC', HASIGM,
     I           'sigma'       , ' '   , KMAX+1,
     I           'UR4' ,  VMISS ,
     I            SMDMIN, SMDMAX, SMDIVS, SMDIVL, -1    )
*
      CALL GHCOPY ( HHSIGM, HHDSGM )
      CALL GHCSET ( HHDSGM, 'DSET', 'AXWGT' )
*
*"         < 4. ファイル書き込み >
*
      CALL GFWOPN( JFILE, HFLON  )
      CALL GZDBWX              !" 精度変換書き込み
     I         ( HHLON , ALON  ,
     I           IT    , IDATE , ISTEP , ITDUR ,
     I           JFILE , 1     , 0     , HDFMT   )
      CALL GFCLSE( JFILE )
*
      CALL GFWOPN( JFILE, HFDLON )
      CALL GZDBWX              !" 精度変換書き込み
     I         ( HHDLON, DLON  ,
     I           IT    , IDATE , ISTEP , ITDUR ,
     I           JFILE , 1     , 0     , HDFMT   )
      CALL GFCLSE( JFILE )
*
      CALL GFWOPN( JFILE, HFLAT  )
      CALL GZDBWX              !" 精度変換書き込み
     I         ( HHLAT , ALAT  ,
     I           IT    , IDATE , ISTEP , ITDUR ,
     I           JFILE , 1     , 0     , HDFMT   )
      CALL GFCLSE( JFILE )
*
      CALL GFWOPN( JFILE, HFDLAT )
      CALL GZDBWX              !" 精度変換書き込み
     I         ( HHDLAT, DLAT  ,
     I           IT    , IDATE , ISTEP , ITDUR ,
     I           JFILE , 1     , 0     , HDFMT   )
      CALL GFCLSE( JFILE )
*
      CALL GFWOPN( JFILE, HFSIG  )
      CALL GZDBWX              !" 精度変換書き込み
     I         ( HHSIG , SIG   ,
     I           IT    , IDATE , ISTEP , ITDUR ,
     I           JFILE , 1     , 0     , HDFMT   )
      CALL GFCLSE( JFILE )
*
      CALL GFWOPN( JFILE, HFDSIG )
      CALL GZDBWX              !" 精度変換書き込み
     I         ( HHDSIG, DSIG  ,
     I           IT    , IDATE , ISTEP , ITDUR ,
     I           JFILE , 1     , 0     , HDFMT   )
      CALL GFCLSE( JFILE )
*
      CALL GFWOPN( JFILE, HFSIGM )
      CALL GZDBWX              !" 精度変換書き込み
     I         ( HHSIGM, SIGM  ,
     I           IT    , IDATE , ISTEP , ITDUR ,
     I           JFILE , 1     , 0     , HDFMT   )
      CALL GFCLSE( JFILE )
*
      CALL GFWOPN( JFILE, HFDSGM )
      CALL GZDBWX              !" 精度変換書き込み
     I         ( HHDSGM, DSIGM ,
     I           IT    , IDATE , ISTEP , ITDUR ,
     I           JFILE , 1     , 0     , HDFMT   )
      CALL GFCLSE( JFILE )
*
      STOP
      END
