~useakat/cfmc/gg_4g_cfmc

« back to all changes in this revision

Viewing changes to library/gmline.f

  • Committer: useakat at gmail
  • Date: 2012-10-01 07:45:50 UTC
  • mfrom: (4.1.13 gg_3g_cfmc_dev)
  • Revision ID: useakat@gmail.com-20121001074550-zs09eu30khm4yvyx
independent ver.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
*   15/05/85 508092014 MEMBER NAME  GMLINE   (S)           FORTRAN
 
2
************************************************************************
 
3
*     ---------------------------------------
 
4
      SUBROUTINE GMLINE(X1,Y1,X2,Y2,A,B,IERR)
 
5
*     ---------------------------------------
 
6
*
 
7
*     (Purpose)
 
8
*        Calculate a gradient and a intercept of line
 
9
*        when two points are given.
 
10
*
 
11
*     (Input)
 
12
*        X1,Y1  : coordinate of one point.
 
13
*        X2,Y2  : coordinate of another point.
 
14
*
 
15
*     (Output)
 
16
*        A        : a gradient of the line
 
17
*        B        : a intercept of the line
 
18
*        IERR = 0 : Normal end
 
19
*             = 1 : No solution is found.
 
20
*
 
21
************************************************************************
 
22
 
 
23
      REAL*8 DX1,DY1,DX2,DY2
 
24
      REAL*8 DA,DB
 
25
 
 
26
      IF(X1.EQ.X2) THEN
 
27
         IERR=1
 
28
         A=0.
 
29
         B=0.
 
30
      ELSE
 
31
         IERR=0
 
32
         DX1=X1
 
33
         DY1=Y1
 
34
         DX2=X2
 
35
         DY2=Y2
 
36
         DA=(DY1-DY2)/(DX1-DX2)
 
37
         DB=DY1-DA*DX1
 
38
         A=DA
 
39
         B=DB
 
40
      END IF
 
41
 
 
42
      RETURN
 
43
      END