Statistics
| Revision:

root / src / ReadInput_mopac.f90 @ 5

History | View | Annotate | Download (3.2 kB)

1
 SUBROUTINE ReadInput_Mopac
2

    
3
! This routine reads an input template for MOPAC
4

    
5
  use VarTypes
6
  use Path_module
7
  use Io_module
8

    
9
  IMPLICIT NONE
10

    
11
  INTERFACE
12
     function valid(string) result (isValid)
13
       CHARACTER(*), intent(in) :: string
14
       logical                  :: isValid
15
     END function VALID
16
  END INTERFACE
17

    
18

    
19
  CHARACTER(132) ::  Line,Line2
20
  INTEGER(KINT) :: LineL, Idx, NTmp
21
  
22
  LOGICAL :: Debug
23

    
24

    
25
  Debug=Valid("readinput").OR.Valid("readinput_mopac")
26

    
27
  if (debug) Call Header("Entering ReadInput_mopac")
28

    
29
! The structure is:
30
! A MOPAC data set normally consists of one line of keywords, two lines of user-defined text, then the coordinates
31
! Then  a blank line or a line of 0.
32
! then the symmetry description.
33
! comment lines start with * and can be anywhere !!!
34

    
35
  ! First, the root
36
  IF (DEBUG) WRITE(*,*) "Reading Mopac input"
37
  ALLOCATE(Mopac_Root)
38
  NULLIFY(Mopac_Root%next)
39
  ALLOCATE(Mopac_Comment)
40
  NULLIFY(Mopac_Comment%next)
41
  ALLOCATE(Mopac_End)
42
  NuLLIFY(Mopac_End%Next)
43
  Current => Mopac_root
44
  CurCom => Mopac_Comment
45
  LineL=1
46
  NTmp=0
47
  DO WHILE (NTmp.LT.3)
48
     READ(IOIN,'(A)') Line
49
     Line=AdjustL(Line)
50
     LineL=len(Trim(Line))
51
     IF (Line(1:1)/="*") THEN
52
        IF (NTmp==0) THEN
53
           Line2=Line
54
           Call UpCase(Line2)
55
           Idx=Index(Line2,'GRADIENTS')
56
           If (Idx==0) Line=TRIM(Line) // " GRADIENTS"
57
           Idx=Index(Line2,'1SCF')
58
           If (Idx==0) Line=TRIM(Line) // " 1SCF"
59
        END IF
60
        current%Line=TRIM(Line)
61
        ALLOCATE(current%next)
62
        Current => Current%next
63
        Nullify(Current%next)
64
        NTmp=NTmp+1
65
     ELSE
66
        CurCom%Line=TRIM(LINE)
67
        ALLOCATE(CurCom%Next)
68
        CurCom => CurCom%Next
69
        NULLIFY(CurCom%Next)
70
     END IF
71
  END DO
72

    
73
!     Current => Mopac_root
74
!     DO WHILE (ASSOCIATED(Current%next))
75
!        WRITE(*,'(1X,A)') Trim(current%line)
76
!        Current => current%next
77
!     END DO
78

    
79
! Now the geometry... that we just skip :)
80
  IF (DEBUG) WRITE(*,*) "Reading Mopac Geometry"
81
  Mopac_EndGeom=""
82
  LineL=1
83
  DO WHILE (LineL.NE.0)
84
     READ(IOIN,'(A)',END=989) Line
85
     Line=AdjustL(Line)
86
     LineL=len(Trim(Line))
87
     ! The last line might be either blank or filled with 0
88
     IF (Line(1:1)=="0") THEN
89
        LineL=0
90
        Mopac_EndGeom=Trim(Line)
91
     END IF
92
     IF (Line(1:1)=="*") THEN
93
        CurCom%Line=TRIM(LINE)
94
        ALLOCATE(CurCom%Next)
95
        CurCom => CurCom%Next
96
        NULLIFY(CurCom%Next)
97
     END IF
98
  END DO
99

    
100
! If we are here, there might be something else to read: Mopac_end
101

    
102
  ! We now read the last part
103
  IF (DEBUG) WRITE(*,*) "Reading Mopac End"
104
  !     READ(IOIN,'(A)') Line
105
  Current => Mopac_End
106
  LineL=1
107
  DO WHILE (1.EQ.1)
108
     READ(IOIN,'(A)',END=989) Line
109
     Line=AdjustL(Line)
110
     LineL=len(Trim(Line))
111
     IF (Line(1:1)/="*") THEN
112
        current%Line=TRIM(Line)
113
        ALLOCATE(current%next)
114
        Current => Current%next
115
        Nullify(Current%next)
116
        NTmp=NTmp+1
117
     ELSE
118
        CurCom%Line=TRIM(LINE)
119
        ALLOCATE(CurCom%Next)
120
        CurCom => CurCom%Next
121
        NULLIFY(CurCom%Next)
122
        END IF
123
     END DO
124
989  CONTINUE
125

    
126
  if (debug) Call Header("Exiting ReadInput_mopac")
127

    
128
END SUBROUTINE READINPUT_Mopac