forked from AdvancedPhotonSource/GSAS-II
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDERIV.f
102 lines (102 loc) · 3.1 KB
/
DERIV.f
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
SUBROUTINE DERIV
COMMON /DELTA1/ IRSS
COMMON /DELTA3/ IDET,ILATNO
COMMON /DELTA4/ IDERIV,IFINIS,IQMATF
COMMON /INVER1/ UI1,VI1,WI1,UI2,VI2,WI2,UI3,VI3,WI3
COMMON /MATR1/ U1,V1,W1,U2,V2,W2,U3,V3,W3
COMMON /QMAT/ ISQ11(519),ISQ12(519),ISQ13(519),
$ ISQ22(519),ISQ23(519),ISQ33(519)
C
C
C SUBROUTINE 'DERIV' ...
C FIND MATRIX TO CALCULATE DERIVATIVE LATTICE
C
C
C
C --- INITIALIZE VARIABLES FOR EACH NEW PROBLEM
IF(IDERIV.NE.1) GO TO 100
IDET = 0
IFINIS = 0
ILATNO = 0
100 CONTINUE
C
C --- INCREMENT DERIVATIVE LATTICE NUMBER, AND COUNT THE NUMBER
C OF UPPER TRIANGULAR MATRICES SELECTED (IDERIV = IQMATF WHEN
C LAST MATRIX IS SELECTED)
ILATNO = ILATNO + 1
IDERIV = IDERIV + 1
C
C --- SELECT AN UPPER TRIANGULAR MATRIX
U1 = ISQ11(IDERIV-1)
V1 = ISQ12(IDERIV-1)
W1 = ISQ13(IDERIV-1)
U2 = 0.0
V2 = ISQ22(IDERIV-1)
W2 = ISQ23(IDERIV-1)
U3 = 0.0
V3 = 0.0
W3 = ISQ33(IDERIV-1)
C
C --- CALCULATE DETERMINANT FOR UPPER TRIANGULAR MATRIX
C (SAVE PREVIOUS VALUE FOR LATER COMPARISON)
IDPRE = IDET
DET = U1*V2*W3 + V1*W2*U3 + W1*U2*V3 - U3*V2*W1 - V3*W2*U1 -
$ W3*U2*V1
IDET = NINT(DET)
C
C --- DO NOT CALCULATE THE TRANSPOSE OF THE INVERSE FOR THE UPPER
C TRIANGULAR MATRIX WHEN SUPERCELLS ARE BEING CALCULATED
C (WHEN BOTH SUPERCELL AND SUBCELL CALCULATIONS ARE TO BE
C DONE, SUPERCELLS ARE CALCULATED FIRST)
IF(IRSS.EQ.1.OR.IRSS.EQ.3) GO TO 300
C
C --- CALCULATE THE TRANSPOSE OF THE INVERSE FOR AN UPPER
C TRIANGULAR MATRIX (USED FOR CALCULATING SUBCELLS)
CALL INVERS(0)
U1 = UI1
V1 = UI2
W1 = UI3
U2 = VI1
V2 = VI2
W2 = VI3
U3 = WI1
V3 = WI2
W3 = WI3
300 CONTINUE
C
C --- CHECK FOR A CHANGE IN THE VALUE OF THE DETERMINANT OF
C THE UPPER TRIANGULAR MATRIX ... ENABLES APPROPRIATE
C SUB-HEADING TO BE WRITTEN
IF(IDET.EQ.IDPRE) GO TO 400
C
C --- CHANGE IN DELTA ENCOUNTERED ... WRITE SUB-HEADING FOR
C DERIVATIVE LATTICES
ILATNO = 1
IF(IRSS.NE.2) CALL OUTPT1(7)
IF(IRSS.EQ.2) CALL OUTPT1(8)
400 CONTINUE
C
C --- WRITE DERIVATIVE LATTICE NUMBER AND TRANSFORMATION MATRIX
C TO DERIVATIVE CELL
CALL OUTPT1(9)
CALL OUTPT1(10)
C
C --- ONLY WHEN THE LAST UPPER TRIANGULAR MATRIX HAS BEEN SELECTED,
C INITIALIZE VARIABLES FOR THE NEXT PROBLEM, OR FOR THE SUBCELL
C CALCULATIONS WHEN BOTH SUPERCELL AND SUBCELL CALCULATIONS ARE
C ARE TO BE DONE
IF(IDERIV-1.LT.IQMATF) GO TO 700
C
C --- LAST UPPER TRIANGULAR MATRIX, CHECK IF FINISHED PROBLEM
IF(IRSS.NE.3) IFINIS = 1
IF(IRSS.NE.3) GO TO 700
C
C --- FINISHED SUPERCELLS, INITIALIZE VARIABLES FOR SUBCELL
C CALCULATION ON NEXT CALL TO SUBROUTINE 'DERIV'
IRSS = 2
IDET = 0
IDERIV = 1
ILATNO = 0
700 CONTINUE
RETURN
END