-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParseAname.f90
53 lines (43 loc) · 1.03 KB
/
ParseAname.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
!*****************************************************
Subroutine ParseAname(Aname,NA,n)
Use Elements, Only: ElName
Implicit Real(8) (A-H,O-Z)
Character(*) Aname
Character symb*1,symb1*1,EN*2,buf*10
ll=Len(Aname)
n=0
kbuf=0
buf=repeat(' ',10)
Do i=1,ll
symb=Aname(i:i)
ic=ICHAR(symb) ! ïåðåâîäèì ñèìâîë â ASCII-êîä
If (ic>=48.and.ic<=57) Then
Aname(i:i)=' ' ! Åñëè ñèìâîë-öèôðà (ASCII-êîäû îò 48 äî 57, òî çàìåíÿåì åå íà ïðîáåë)
kbuf=kbuf+1
buf(kbuf:kbuf)=symb
Endif
If (ic>=97.and.ic<=122) Aname(i:i)=CHAR(ic-32) ! Çàìåíÿåì ñòðî÷íûå áóêâû íà çàãëàâíûå
Enddo
If (kbuf>0) Then
buf=AdjustR(buf)
Read(buf,'(i10)')n
Endif
Do i=1,120
EN=ElName(i)
Call UCase(EN)
If (INDEX(EN,Trim(Aname))>0) Then
NA=i
Return
Endif
Enddo
End
!************************************************************
Subroutine UCase(Str)
Character(*) Str
Character(1) sym
ls=Len_Trim(Str)
Do i=1,ls
ic=ICHAR(Str(i:i))
If (ic>=97.and.ic<=122) Str(i:i)=CHAR(ic-32)
Enddo
End