-
Notifications
You must be signed in to change notification settings - Fork 0
/
creatinp.f90
139 lines (119 loc) · 2.71 KB
/
creatinp.f90
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
program creatinp
implicit none
integer :: ntermL,ntermR,itermL,itermR
character(len=2),allocatable :: oprL(:,:,:),oprR(:,:,:)
real(kind=8),allocatable :: coeffL(:),coeffR(:)
open(unit=10,file="inp.inp",status="old")
read(10,*) ntermL,ntermR
read(10,*) itermL,itermR
close(10)
allocate(oprL(4,itermL,ntermL))
allocate(oprR(4,itermR,ntermR))
allocate(coeffL(ntermL))
allocate(coeffR(ntermR))
call readopr('L',oprL,itermL,ntermL,coeffL)
call readopr('R',oprR,itermR,ntermR,coeffR)
call writeopr('g')
call writeopr('h')
deallocate(oprL,oprR,coeffL,coeffR)
contains
!==============================================================
!==============================================================
subroutine writeopr(H)
implicit none
integer :: i,j,k,l
character(len=1) :: H
integer :: ntermH,itermH
character(len=2),allocatable :: oprH(:,:,:)
if(H=='g') then
ntermH=4
itermH=4
else if (H=='h') then
ntermH=2
itermH=2
else
write(*,*) "wrong H=",H
stop
end if
open(unit=11,file=H,status="replace")
write(11,*) H
write(11,*) ntermL*ntermR*ntermH
allocate(oprH(4,itermH,ntermH))
call writeoprH(H,oprH,itermH,ntermH)
do i=1,ntermL,1
do j=1,ntermR,1
do k=1,ntermH,1
write(11,*) coeffL(i)*coeffR(j)
do l=1,itermL,1
write(11,'(4A3)') oprL(:,l,i)
end do
do l=1,itermH,1
write(11,'(4A3)') oprH(:,l,k)
end do
do l=1,itermR,1
write(11,'(4A3)') oprR(:,l,j)
end do
end do
end do
end do
close(11)
deallocate(oprH)
return
end subroutine writeopr
!==============================================================
!==============================================================
end program
subroutine writeoprH(H,oprH,itermH,ntermH)
implicit none
integer :: itermH,ntermH
character(len=2) :: oprH(4,itermH,ntermH)
character(len=1) :: H
oprH='em' ! empty
if(H=='g') then
oprH(1,1,:)='p'
oprH(1,2,:)='q'
oprH(1,3,:)='r'
oprH(1,4,:)='s'
oprH(2:3,:,:)='r'
oprH(4,1:4,1)='u'
oprH(4,1:4,2)='d'
oprH(4,1,3)='u'
oprH(4,4,3)='u'
oprH(4,2,3)='d'
oprH(4,3,3)='d'
oprH(4,1,4)='d'
oprH(4,4,4)='d'
oprH(4,2,4)='u'
oprH(4,3,4)='u'
else if(H=='h') then
oprH(1,1,:)='p'
oprH(1,2,:)='q'
oprH(2:3,:,:)='r'
oprH(4,1:2,1)='u'
oprH(4,1:2,2)='d'
end if
return
end subroutine writeoprH
subroutine readopr(symbol,opr,iterm,nterm,coeff)
implicit none
character(len=1) :: symbol,dummysymbol
integer :: iterm,nterm
character(len=2) :: opr(4,iterm,nterm)
real(kind=8) :: coeff(nterm)
integer :: i,j
open(unit=10,file="inp.inp",status="old")
do while(.true.)
read(10,*) dummysymbol
if(dummysymbol==symbol) then
exit
end if
end do
do i=1,nterm,1
read(10,*) coeff(i)
do j=1,iterm,1
read(10,*) opr(:,j,i)
end do
end do
close(10)
return
end subroutine readopr