File: modsubs.f

package info (click to toggle)
raster3d 3.0-3-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,916 kB
  • ctags: 1,557
  • sloc: fortran: 9,536; ansic: 1,060; makefile: 318; sh: 250; csh: 15
file content (150 lines) | stat: -rw-r--r-- 2,408 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
      SUBROUTINE CROSS(B,C,A)
C     =======================
C
C
      DIMENSION A(3),B(3),C(3)
      A(1)=B(2)*C(3)-C(2)*B(3)
      A(2)=B(3)*C(1)-C(3)*B(1)
      A(3)=B(1)*C(2)-C(1)*B(2)
      RETURN
      END
C
      FUNCTION DOT(A,B)
C     ================
C
C     DOT PRODUCT OF TWO VECTORS
C
      DIMENSION A(3),B(3)
      DOT=A(1)*B(1)+A(2)*B(2)+A(3)*B(3)
      RETURN
      END
	SUBROUTINE MATMUL(A,B,C)
C	========================
C
C	MULTIPLY 2 3X3 MATRICES
C
C	A=BC
C
	REAL A(3,3),B(3,3),C(3,3)
	DO 1 I=1,3
	DO 2 J=1,3
	S=0
	DO 3 K=1,3
3	S=S+B(I,K)*C(K,J)
2	A(I,J)=S
1	CONTINUE
	RETURN
	END
	SUBROUTINE MATVEC(V,A,B)
C	========================
C
C	POST-MULTIPLY A 3X3 MATRIX BY A VECTOR
C
C	V=AB
C
	REAL A(3,3),B(3),V(3)
	DO 1 I=1,3
	S=0
	DO 2 J=1,3
2	S=S+A(I,J)*B(J)
1	V(I)=S
	RETURN
	END
	SUBROUTINE MINV(A,B,D)
C	======================
C
C	INVERT A GENERAL 3X3 MATRIX AND RETURN DETERMINANT IN D
C
C	A=(B)-1
C
	REAL A(3,3),B(3,3),C(3,3)
	CALL CROSS(B(1,2),B(1,3),C(1,1))
	CALL CROSS(B(1,3),B(1,1),C(1,2))
	CALL CROSS(B(1,1),B(1,2),C(1,3))
	D=DOT(B(1,1),C(1,1))
C
C	TEST DETERMINANT
C
	IF(ABS(D).GT.1.E-30)GO TO 10
	D=0.0
	RETURN
C
C	DETERMINANT IS NON-ZERO
C
10	DO 20 I=1,3
	DO 20 J=1,3
20	A(I,J)=C(J,I)/D
	RETURN
	END
C
      SUBROUTINE SCALEV(A,X,B)
C     ========================
C
C     SCALE A VECTOR B WITH SCALAR X AND PUT RESULT IN A
C
      DIMENSION A(3),B(3)
      DO 10 I=1,3
      A(I)=B(I)*X
   10 CONTINUE
      RETURN
      END
	SUBROUTINE TRANSP(A,B)
C	======================
C
C	TRANSPOSE A 3X3 MATRIX
C
C	A=BT
C
	REAL A(3,3),B(3,3)
	DO 1 I=1,3
	DO 1 J=1,3
1	A(I,J)=B(J,I)
	RETURN
	END
      SUBROUTINE UNIT(V)
C     =================
C
C
      REAL V(3)
C****VECTOR V REDUCED TO UNIT VECTOR
      VMOD=V(1)**2+V(2)**2+V(3)**2
      VMOD=SQRT(VMOD)
      DO 1 I=1,3
    1 V(I)=V(I)/VMOD
      RETURN
      END
      SUBROUTINE VDIF(A,B,C)
C     =====================
C
C
C     SUBTRACT TWO VECTORS
C
      DIMENSION A(3),B(3),C(3)
      DO 10 I=1,3
      A(I)=B(I)-C(I)
   10 CONTINUE
      RETURN
      END
      SUBROUTINE VSET(A,B)
C     ====================
C
C
C     MOVE A VECTOR FROM B TO A
C
      DIMENSION A(3),B(3)
      DO 10 I=1,3
   10 A(I)=B(I)
      RETURN
      END
      SUBROUTINE VSUM(A,B,C)
C     ======================
C
C
C     ADD TWO VECTORS
C
      DIMENSION A(3),B(3),C(3)
      DO 10 I=1,3
      A(I)=B(I)+C(I)
   10 CONTINUE
      RETURN
      END