CFPRIME AUDMD                                                           AUDMD       1
C***********************************************************************RIGHTE      1
C*                                                                     *RIGHTE      2
C*        Extended Transient-Midterm Stability Program (ETMSP)         *RIGHTE      3
C*        ====================================================         *RIGHTE      4
C*                                                                     *RIGHTE      5
C*       Copyright (C) (1993) Electric Power Research Institute        *RIGHTE      6
C*                                                                     *RIGHTE      7
C* EPRI reserves all rights in the software and associated             *RIGHTE      8
C* documentation as delivered. The software and its associated         *RIGHTE      9
C* documention or any portion thereof may not be reproduced in any form*RIGHTE     10
C* whatsoever without the consent of EPRI, except as explicity provided*RIGHTE     11
C* for by license. Licensee shall submit a detailed description to EPRI*RIGHTE     12
C* of any changes or modifications to the software within two (2)      *RIGHTE     13
C* months after such changes or modifications are made. At EPRI's sole *RIGHTE     14
C* discretion, the software, as changed or modified, shall be given a  *RIGHTE     15
C* new designation sufficiently different from its then current        *RIGHTE     16
C* designation as to prevent mistake,confusion, or deception as between*RIGHTE     17
C* the current software as changed or modified.                        *RIGHTE     18
C*                                                                     *RIGHTE     19
C* A license under EPRI's rights in the software can be obtained       *RIGHTE     20
C* directly from EPRI.                                                 *RIGHTE     21
C*                                                                     *RIGHTE     22
C* This program and supporting materials may be independently available*RIGHTE     23
C* from Electric Power Software centre (EPSC) for an appropriate       *RIGHTE     24
C* distribution fee. The EPSC is a service of                          *RIGHTE     25
C*                                                                     *RIGHTE     26
C*                    Power Computing Company                          *RIGHTE     27
C*                    1930 Hi Line                                     *RIGHTE     28
C*                    Dallas, Tx 75207                                 *RIGHTE     29
C*                                                                     *RIGHTE     30
C* NEITHER EPRI, ANY MEMBER OF EPRI, NOR ANY PERSON OR  ORGANIZATION   *RIGHTE     31
C* ACTING ON BEHAVE OF THEM:                                           *RIGHTE     32
C*                                                                     *RIGHTE     33
C* 1. MAKE ANY WARRANTY OR REPRESENTATION WHATSOEVER, EXPRESS OR       *RIGHTE     34
C*    IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS OR *RIGHTE     35
C*    ANY PURPOSE WITH RESPECT TO THE SOFTWARE OR ITS ASSOCIATED       *RIGHTE     36
C*    DOCUMENTATION; OR                                                *RIGHTE     37
C*                                                                     *RIGHTE     38
C* 2. ASSUMES ANY LIABILITY WHATSOEVER WITH RESPECT TO ANY USE OF THE  *RIGHTE     39
C*    SOFTWARE OR ITS ASSOCIATED DOCUMENTATION OR ANY PORTION THEREOF  *RIGHTE     40
C*    OR WITH RESPECT TO ANY DAMAGES WHICH MAY RESULT FROM SUCH USE.   *RIGHTE     41
C*                                                                     *RIGHTE     42
C* THIS NOTICE MAY NOT BE REMOVED FROM THE SOFTWARE BY ANY USER        *RIGHTE     43
C* THEREOF.                                                            *RIGHTE     44
C*                                                                     *RIGHTE     45
C***********************************************************************RIGHTE     46
      SUBROUTINE AUDMD(LSTA,LOUT,LREM,LREF)                             AUDMD       3
CD                                                                      AUDMD       4
CD    TO FORMULATE THE A B C D MATRICES OF EACH DEVICE IN A USER DEFINEDAUDMD       5
CD    MODEL FOR THE CONSTRUCTION OF THE JACOBIAN MATRICES.              AUDMD       6
CD                                                                      AUDMD       7
      INCLUDE 'PARX.INS'                                                AUDMD       8
      INCLUDE 'CNPT.INS'                                                AUDMD       9
      INCLUDE 'CNUDMB.INS'                                              AUDMD      10
      INCLUDE 'CNFLAG.INS'                                              AUDMD      11
      INCLUDE 'CNUNIT.INS'                                              AUDMD      12
C                                                                       AUDMD      13
      DIMENSION CAUX(LOUTP,LOUTP*NXUDB),IRU(LOUTP),ICU(LOUTP)           AUDMD      14
C                                                                       AUDMD      15
      LDEB=(JDEB(263).NE.0)                                             AUDMD      16
C                                                                       AUDMD      17
C     FORM: XDOT=AX*X+BXV*DEL V(S&R)+BREF*DEL VREF                      AUDMD      18
C     DEL I(INTO NETWORK)=CX*X-YDEV*DEL V-YDEVR*DEL VR+CREF*DEL VREF    AUDMD      19
C                                                                       AUDMD      20
      IF(LDEB)WRITE(IUD6,1010) LSTA,LOUT,LREM,LREF                      AUDMD      21
C                                                                       AUDMD      22
      DO 100 I=1,LOUT                                                   AUDMD      23
      DO 100 J=1,LOUT                                                   AUDMD      24
      ADEV(I,J)=-ADEV(I,J)                                              AUDMD      25
      IF(I.EQ.J) ADEV(I,J)=ADEV(I,J)+1.0                                AUDMD      26
  100 CONTINUE                                                          AUDMD      27
      CALL MINVRS (ADEV,LOUTP,LOUT,DETA,IER,IRU,ICU)                    AUDMD      28
      IF(LDEB)WRITE(IUD6,1000) ((ADEV(I,J),J=1,LOUT),I=1,LOUT)          AUDMD      29
C                                                                       AUDMD      30
      DO 120 I=1,LOUT                                                   AUDMD      31
      DO 120 J=1,LSTA                                                   AUDMD      32
      SUM=0.                                                            AUDMD      33
      DO 110 L=1,LOUT                                                   AUDMD      34
      SUM=SUM+ADEV(I,L)*CX(L,J)                                         AUDMD      35
  110 CONTINUE                                                          AUDMD      36
      CAUX(I,J)=SUM                                                     AUDMD      37
  120 CONTINUE                                                          AUDMD      38
      DO 130 I=1,LOUT                                                   AUDMD      39
      DO 130 J=1,LSTA                                                   AUDMD      40
      CX(I,J)=-CAUX(I,J)                                                AUDMD      41
  130 CONTINUE                                                          AUDMD      42
C                                                                       AUDMD      43
      DO 150 I=1,LOUT                                                   AUDMD      44
      DO 150 J=1,LOUT                                                   AUDMD      45
      SUM=0.                                                            AUDMD      46
      DO 140 L=1,LOUT                                                   AUDMD      47
      SUM=SUM+ADEV(I,L)*YDEVS(L,J)                                      AUDMD      48
  140 CONTINUE                                                          AUDMD      49
      CAUX(I,J)=SUM                                                     AUDMD      50
  150 CONTINUE                                                          AUDMD      51
      DO 160 I=1,LOUT                                                   AUDMD      52
      DO 160 J=1,LOUT                                                   AUDMD      53
      YDEVS(I,J)=CAUX(I,J)                                              AUDMD      54
  160 CONTINUE                                                          AUDMD      55
C                                                                       AUDMD      56
      DO 180 I=1,LOUT                                                   AUDMD      57
      DO 180 J=1,LREM                                                   AUDMD      58
      SUM=0.                                                            AUDMD      59
      DO 170 L=1,LOUT                                                   AUDMD      60
      SUM=SUM+ADEV(I,L)*YDEVR(L,J)                                      AUDMD      61
  170 CONTINUE                                                          AUDMD      62
      CAUX(I,J)=SUM                                                     AUDMD      63
  180 CONTINUE                                                          AUDMD      64
      DO 190 I=1,LOUT                                                   AUDMD      65
      DO 190 J=1,LREM                                                   AUDMD      66
      YDEVR(I,J)=CAUX(I,J)                                              AUDMD      67
  190 CONTINUE                                                          AUDMD      68
C                                                                       AUDMD      69
      DO 210 I=1,LOUT                                                   AUDMD      70
      DO 210 J=1,LREF                                                   AUDMD      71
      SUM=0.                                                            AUDMD      72
      DO 200 L=1,LOUT                                                   AUDMD      73
      SUM=SUM+ADEV(I,L)*CREF(L,J)                                       AUDMD      74
  200 CONTINUE                                                          AUDMD      75
      CAUX(I,J)=SUM                                                     AUDMD      76
  210 CONTINUE                                                          AUDMD      77
      DO 220 I=1,LOUT                                                   AUDMD      78
      DO 220 J=1,LREF                                                   AUDMD      79
      CREF(I,J)=-CAUX(I,J)                                              AUDMD      80
  220 CONTINUE                                                          AUDMD      81
C                                                                       AUDMD      82
      DO 240 I=1,LSTA                                                   AUDMD      83
      DO 240 J=1,LSTA                                                   AUDMD      84
      SUM=0.                                                            AUDMD      85
      DO 230 L=1,LOUT                                                   AUDMD      86
      SUM=SUM+BXI(I,L)*CX(L,J)                                          AUDMD      87
  230 CONTINUE                                                          AUDMD      88
      AX(I,J)=AX(I,J)-SUM                                               AUDMD      89
  240 CONTINUE                                                          AUDMD      90
C                                                                       AUDMD      91
      DO 260 I=1,LSTA                                                   AUDMD      92
      DO 260 J=1,LOUT                                                   AUDMD      93
      SUM=0.                                                            AUDMD      94
      DO 250 L=1,LOUT                                                   AUDMD      95
      SUM=SUM+BXI(I,L)*YDEVS(L,J)                                       AUDMD      96
  250 CONTINUE                                                          AUDMD      97
      BXV(I,J)=BXV(I,J)+SUM                                             AUDMD      98
  260 CONTINUE                                                          AUDMD      99
C                                                                       AUDMD     100
      DO 280 I=1,LSTA                                                   AUDMD     101
      DO 280 J=1,LREM                                                   AUDMD     102
      SUM=0.                                                            AUDMD     103
      DO 270 L=1,LOUT                                                   AUDMD     104
      SUM=SUM+BXI(I,L)*YDEVR(L,J)                                       AUDMD     105
  270 CONTINUE                                                          AUDMD     106
      BXV(I,J+LOUT)=BXV(I,J+LOUT)+SUM                                   AUDMD     107
  280 CONTINUE                                                          AUDMD     108
C                                                                       AUDMD     109
      DO 300 I=1,LSTA                                                   AUDMD     110
      DO 300 J=1,LREF                                                   AUDMD     111
      SUM=0.                                                            AUDMD     112
      DO 290 L=1,LOUT                                                   AUDMD     113
      SUM=SUM+BXI(I,L)*CREF(L,J)                                        AUDMD     114
  290 CONTINUE                                                          AUDMD     115
      BREF(I,J)=BREF(I,J)-SUM                                           AUDMD     116
  300 CONTINUE                                                          AUDMD     117
C                                                                       AUDMD     118
      IF(LDEB)THEN                                                      AUDMD     119
         WRITE(IUD6,1020) ((AX(I,J),J=1,LSTA),I=1,LSTA)                 AUDMD     120
         WRITE(IUD6,1030) ((BXV(I,J),J=1,LOUT+LREM),I=1,LSTA)           AUDMD     121
         WRITE(IUD6,1090) ((BREF(I,J),J=1,LREF),I=1,LSTA)               AUDMD     122
         WRITE(IUD6,1050) ((CX(I,J),I=1,LOUT),J=1,LSTA)                 AUDMD     123
         WRITE(IUD6,1100) ((CREF(I,J),I=1,LOUT),J=1,LREF)               AUDMD     124
         WRITE(IUD6,1060) ((YDEVS(I,J),I=1,LOUT),J=1,LOUT)              AUDMD     125
         WRITE(IUD6,1070) ((YDEVR(I,J),I=1,LOUT),J=1,LREM)              AUDMD     126
         WRITE(IUD6,1080)                                               AUDMD     127
      ENDIF                                                             AUDMD     128
C                                                                       AUDMD     129
      RETURN                                                            AUDMD     130
 1000 FORMAT(1X,'((ADEV(I,J),J=1,LOUT),I=1,LOUT):    ',(/,1X,10E12.4))  AUDMD     131
 1010 FORMAT(/,1X,'AUDMD STARTS',/,' LSTA,LOUT,LREM,LREF:       ',4I5)  AUDMD     132
 1020 FORMAT(1X,'((AX(I,J),J=1,LSTA),I=1,LSTA):      ',(/,1X,10E12.4))  AUDMD     133
 1030 FORMAT(1X,'((BXV(I,J),J=1,LOUT+LREM),I=1,LSTA):',(/,1X,10E12.4))  AUDMD     134
 1050 FORMAT(1X,'((CX(I,J),I=1,LOUT),J=1,LSTA):      ',(/,1X,10E12.4))  AUDMD     135
 1060 FORMAT(1X,'((YDEVS(I,J),I=1,LOUT),J=1,LOUT):   ',(/,1X,10E12.4))  AUDMD     136
 1070 FORMAT(1X,'((YDEVR(I,J),I=1,LOUT),J=1,LREM):   ',(/,1X,10E12.4))  AUDMD     137
 1080 FORMAT(1X,'AUDMD ENDS',/)                                         AUDMD     138
 1090 FORMAT(1X,'((BREF(I,J),J=1,LREF),I=1,LSTA) :   ',(/,1X,10E12.4))  AUDMD     139
 1100 FORMAT(1X,'((CREF(I,J),I=1,LOUT),J=1,LREF):    ',(/,1X,10E12.4))  AUDMD     140
      END                                                               AUDMD     141
