* PACKAGE LADMN  !" $@@~7ANO3X8GM-CM2r@O(J
*"                  ver 1.05    93/07/14 takepiro
*"                              95/06/21(takepiro)  $@=PNO8GM-4X?t7W;;?tF3F~(J
**********************************************************************
      SUBROUTINE LANAL                      !"  $@@~7ANO3X2r@O(J
     O             ( GAU   , GAV   , GAW   , GAT   ,
     O               GATOR , GAPOR , 
     O               GRMAX , FREQ  , 
     I               MFIX  , 
     I               RAYL  , TAU   , PRND  , 
     I               ORSTR , MODE  , 
     C               ALON  , DLON  , ALAT  , DLAT  ,
     C               ARAD  , DRAD                    )
*
*   [PARAM]
#ifdef SYS_IBMS
      INCLUDE   (ZCDIM)                      !" $@3J;RE@?t(J, $@GH?t(J
      INCLUDE   (ZLDIM)                      !" $@%Q%i%a%?!<?t(J, $@78?t9TNs(J
      INCLUDE   (ZHDIM)                      !" $@J8;zNsJ8;z?t(J
      INCLUDE   (ZCCOM)                      !" $@I8=`J*M}Dj?t(J
#else
#include        "zcdim.F"                    !" $@3J;RE@?t(J, $@GH?t(J
#include        "zldim.F"                    !" $@%Q%i%a%?!<?t(J, $@78?t9TNs(J
#include        "zhdim.F"                    !" $@J8;zNsJ8;z?t(J
#include        "zccom.F"                    !" $@I8=`J*M}Dj?t(J
#endif
*
*   [OUTPUT]
      REAL       GAU   ( IDIM, JDIM, 0:KDIM )  !" $@@>Iw(J   $@#u(J
      REAL       GAV   ( IDIM, JDIM, 0:KDIM )  !" $@FnIw(J   $@#v(J
      REAL       GAW   ( IDIM, JDIM, 0:KDIM )  !" $@1tD>Iw(J $@#w(J
      REAL       GAT   ( IDIM, JDIM, 0:KDIM )  !" $@29EY(J   $@#T(J
      REAL       GATOR ( IDIM, JDIM, 0:KDIM )  !" $@%H%m%$%@%k(J $@&7(J
      REAL       GAPOR ( IDIM, JDIM, 0:KDIM )  !" $@%]%m%$%@%k(J $@&5(J
*"       : $@3J;RE@%G!<%?(J(t) <DYNMCS>  $@3J;RE@%G!<%?(J(t+$@&$(Jt)
*
      REAL       GRMAX                       !" $@@.D9N((J
      REAL       FREQ                        !" $@?6F0?t(J
*
*   [INPUT]
      REAL       ALON  ( IDIM )              !" $@7PEY(J
      REAL       DLON  ( IDIM )              !" $@7PEY2Y=E(J
      REAL       ALAT  ( JDIM )              !" $@0^EY(J
      REAL       DLAT  ( JDIM )              !" $@0^EY2Y=E(J
      REAL       ARAD  ( 0:KDIM )            !" $@#r%l%Y%k(J($@@0?t(J)
      REAL       DRAD  ( 0:KDIM )            !" $@&$#r(J($@@0?t(J)
*"        : $@:BI83J;R(J
*
      REAL       RAYL                        !" $@%l%$%j!<?t(J
      REAL       TAU                         !" $@"e%F%$%i!<?t(J
      REAL       PRND                        !" $@%W%i%s%I%k?t(J
*
      INTEGER    MFIX                        !" $@El@>GH?t(J
*
      LOGICAL    ORSTR                       !" $@8GM-4X?t=PNO$9$k$+H]$+(J
      INTEGER    MODE                        !" $@=PNO8GM-4X?t$N%b!<%IHV9f(J
*                                            !" ( 1 $@$G:GBg@.D9N((J )
*
*   [INTERNAL SAVE]
*
*   [INTERNAL ONCE]
      INTEGER    NMO   ( 2, 0:MMAX, 0:LMAX ) !" $@%9%Z%/%H%k$NE:;z=gHV(J
      REAL       FLAPLA( NMDIM  )            !" $@%i%W%i%7%"%s$N78?t(J
      REAL       EDEL  ( NMDIM  )            !" $@&F!$#D"*#U!$#V(J
*
      REAL       UVFACT ( IDIM, JDIM )       !" u$@"*(JU $@$N%U%!%/%?!<(J
*
      SAVE       NMO   , FLAPLA, EDEL  ,
     &           UVFACT
*
      LOGICAL    OSETC , OFIRST
      DATA       OSETC , OFIRST  / .FALSE., .TRUE.  /
      SAVE       OSETC , OFIRST
*
      LOGICAL    OATOR , OAPOR , OAT         !" $@2r@OBP>]J*M}NL(J
      SAVE       OATOR , OAPOR , OAT
*
*   [INTERNAL WORK]
      REAL       COFMTX( MATDMX , MATDMX )   !" $@78?t9TNs(J
      REAL       GROWTH( MATDMX )            !" $@@.D9N((J($@8GM-CM<B?tIt(J)
      REAL       FRQENC( MATDMX )            !" $@?6F0?t(J($@8GM-CM5u?tIt(J)
*
      REAL       EIGVCR( MATDMX, NVDIM )     !" $@8GM-%Y%/%H%k<B?tIt(J
      REAL       EIGVCI( MATDMX, NVDIM )     !" $@8GM-%Y%/%H%k5u?tIt(J
*
      INTEGER    NMKMTX ( NMDIM, 0:KDIM, 3 ) !" $@78?t9TNs$NE:$(;z(J
      INTEGER    NMKMAX                      !" $@78?t9TNs$N:GBgE:$(;z(J
      INTEGER    NMTLST  ( NMDIM )           !" MFIX $@@.J,%j%9%H(J($@%H%m%$%@%k(J)
      INTEGER    NMPLST  ( NMDIM )           !" MFIX $@@.J,%j%9%H(J($@%]%m%$%@%k(J)
      INTEGER    NMQLST  ( NMDIM )           !" MFIX $@@.J,%j%9%H(J($@29EY(J)
      INTEGER    NMTMAX                      !" NMTLST $@$N:GBgE:$(;z(J
      INTEGER    NMPMAX                      !" NMPLST $@$N:GBgE:$(;z(J
      INTEGER    NMQMAX                      !" NMQLST $@$N:GBgE:$(;z(J
      INTEGER    NUMEIG                      !" $@8GM-CM$N?t(J
*
      INTEGER    IERR                        !" $@%5%V%k!<%A%s%(%i!<%3!<%I(J
*"       : $@8GM-CM7W;;MQ9TNs(J
*
      INTEGER    IUNIT                       !" $@I8=`=PNOAuCVHV9f(J
*
c$$$      COMMON     /COMWRK/ EIGVCR , EIGVCI
*
*"  << SETCON : $@Dj?t@_Dj(J >>
*
      IF ( MODE .GT. NVDIM ) THEN
         CALL MSGDMP( 'E', 'LADMN', 'MODE NUMBER IS TOO LARGE' )
      ENDIF
*
*   [ONCE]
      IF ( .NOT. OSETC ) THEN
         OSETC = .TRUE.
         CALL    DSETC                 !" $@%9%Z%/%H%kDj?t@_Dj(J
     O         ( NMO   , FLAPLA, EDEL  , UVFACT, 
     C           ALAT  , DLAT                      )
      ENDIF
*   [ONCE]
      IF ( OFIRST ) THEN
         OFIRST = .FALSE.
         CALL LSTPHS                         !" $@2r@OBP>]J*M}NL$N@_Dj(J
     O         ( OATOR  , OAPOR  , OAT  )
      ENDIF
*
*" << $@78?t9TNs$N7W;;(J >>
*
      CALL CLCSTR( 'LSTMTX' )
*
      CALL MKMLST
     O      ( NMKMTX , NMKMAX ,
     O        NMTLST , NMTMAX , 
     O        NMPLST , NMPMAX , 
     O        NMQLST , NMQMAX , 
     F        OATOR  , OAPOR  , OAT   , 
     I        NMO    , MFIX             )
*
      CALL LSTMTX
     O      ( COFMTX ,
     I        NMKMTX , NMKMAX , 
     I        NMTLST , NMTMAX , 
     I        NMPLST , NMPMAX , 
     I        NMQLST , NMQMAX , 
     I        RAYL   , TAU    , PRND   ,
     F        OATOR  , OAPOR  , OAT    , 
     C        NMO    , FLAPLA , 
     C        ARAD   , DRAD                       )
*
      CALL CLCEND( 'LSTMTX' )
*
*" << $@8GM-CM7W;;(J >>
*
      CALL CLCSTR( 'LEIGEN' )
*
      CALL LEIGEN
     M        ( COFMTX , 
     O          GROWTH , FRQENC ,
     O          EIGVCR , EIGVCI ,
     O          IERR   , 
     I          NMKMAX , .TRUE. , NVDIM     )
*
      IF( IERR .NE. 0 )THEN
         CALL MSGDMP( 'W', 'LADMN', 'ERROR OCCURED AT ' )
         CALL GLPGET( 'MSGUNIT', IUNIT )
         WRITE ( IUNIT, * ) 'Rayleigh Number = ', RAYL
         WRITE ( IUNIT, * ) 'Taylor Number   = ', TAU**2
         WRITE ( IUNIT, * ) 'Prandtl Number  = ', PRND
         WRITE ( IUNIT, * ) 'E-W Wave Numver = ', MFIX
      ENDIF
*
      CALL CLCEND( 'LEIGEN' )
*
      IF ( MFIX .NE. 0 )THEN
         CALL LSLFRQ
     M         (  GROWTH , FRQENC ,
     M            EIGVCR , EIGVCI ,
     O            NUMEIG ,
     I            NMKMAX , NVDIM      )
      ELSE
         NUMEIG = NMKMAX
      ENDIF
*
*" << $@8GM-CM?GCG=PNO(J >>
*
      CALL CLCSTR( 'LDIAG' )
*
      CALL LDIAG
     I      (  GROWTH , FRQENC , 
     I         EIGVCR , EIGVCI ,
     I         NMKMTX , NUMEIG , NVDIM  ,
     I         NMTLST , NMTMAX , 
     I         NMPLST , NMPMAX , 
     I         NMQLST , NMQMAX , 
     F         OATOR  , OAPOR  , OAT    ,
     C         NMO    , FLAPLA , UVFACT , 
     C         ARAD   , DRAD   ,
     W         GAU    , GAV    , GAW    , GAT   ,
     W         GATOR  , GAPOR  )
*
      CALL CLCEND( 'LDIAG' )
*
*" << $@8GM-4X?t7W;;(J >>
*
      CALL CLCSTR( 'LEIVEC' )
*
      GRMAX = GROWTH( MODE )
      FREQ  = FRQENC( MODE )
*
      IF ( ORSTR ) THEN
         CALL LEIVEC
     O       ( GAU    , GAV    , GAW    , GAT    ,
     O         GATOR  , GAPOR  , 
     I         EIGVCR(1,MODE) , EIGVCI(1,MODE) ,
     I         NMKMTX , 
     I         NMTLST , NMTMAX , 
     I         NMPLST , NMPMAX , 
     I         NMQLST , NMQMAX , 
     F         OATOR  , OAPOR  , OAT    ,
     C         NMO    , FLAPLA , UVFACT , 
     C         ARAD   , DRAD                       )
      ENDIF
*
      CALL CLCEND( 'LEIVEC' )
*
      RETURN
      END
**********************************************************************
      SUBROUTINE LSTPHS                         !" $@2r@OBP>]J*M}NL$N@_Dj(J
     O         ( OATOR  , OAPOR  , OAT  )
*
*"  [OUTPUT]
      LOGICAL    OATOR                       !" $@%H%m%$%@%k2r@O%9%$%C%A(J
      LOGICAL    OAPOR                       !" $@%]%m%$%@%k2r@O%9%$%C%A(J
      LOGiCAL    OAT                         !" $@29EY2r@O%9%$%C%A(J
*
*"  [INTERNAL ONCE]
      LOGICAL    OTOR                        !" $@%H%m%$%@%k2r@O%9%$%C%A(J
      LOGICAL    OPOR                        !" $@%]%m%$%@%k2r@O%9%$%C%A(J
      LOGiCAL    OTEMP                       !" $@29EY2r@O%9%$%C%A(J
      DATA       OTOR  ,  OPOR  ,  OTEMP 
     &        / .TRUE. , .TRUE. , .TRUE. /
*
      NAMELIST   /NMLPHS/  OTOR , OPOR , OTEMP
*
*   [INTERNAL WORK]
      INTEGER    IFPAR, JFPAR
*
*"     < 1. $@2r@OBP>]J*M}NL$N@_Dj(J >
*
C      WRITE  ( JFPAR, NMLPHS )
      CALL   REWNML ( IFPAR , JFPAR )
      READ   ( IFPAR, NMLPHS , END=1190 )
 1190 WRITE  ( JFPAR, NMLPHS )
*
      OATOR = OTOR
      OAPOR = OPOR
      OAT   = OTEMP
*
      IF ( (.NOT.OATOR ) .OR. (.NOT. OAPOR ) .OR. (.NOT. OAT ) )THEN
         CALL MSGDMP( 'W', 'LSTPHS', 'ANALIZING RESTRICTED DYNAMICS' )
      ENDIF
*
      RETURN
      END
