~siesta-pseudos-bases/siesta/trunk-psml

« back to all changes in this revision

Viewing changes to Util/TS/TBtrans/tbt_reinit.F90

  • Committer: Alberto Garcia
  • Date: 2019-09-02 14:09:43 UTC
  • mfrom: (427.6.323 trunk)
  • Revision ID: albertog@icmab.es-20190902140943-mzmbe1jacgefpgxw
Sync to trunk-776 (notably nc/soc wavefunction support)


Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
  integer ::  count, in, length, lun, lun_tmp, iostat
37
37
  character(len=256) :: line
38
38
 
39
 
  logical :: debug_input, file_exists
 
39
  logical :: debug_input, file_exists, is_pipe
40
40
 
41
41
  external :: bye
42
42
  
67
67
     write(6,'(a)') &
68
68
          '                           ************************ '
69
69
 
70
 
! ..................
71
70
!
72
71
!       Set name of file to read from. Done only
73
72
!       in the master node.
74
73
!
 
74
     is_pipe = .true.
75
75
#ifndef NO_F2003
76
76
     count = command_argument_count()
77
77
     if ( count > 0 ) then
78
78
        filein = ' '
79
 
        call get_command_argument(count,filein,length)
 
79
        call get_command_argument(count, filein, length)
80
80
        inquire(file=filein,exist=debug_input)
81
 
        if ( .not. debug_input ) count = 0
 
81
        if ( debug_input ) then
 
82
          is_pipe = .false.
 
83
        else
 
84
          count = 0
 
85
        end if
82
86
     end if
83
87
#endif
84
88
 
88
92
!      processed and dumped to a temporary file)
89
93
!
90
94
     inquire(file='INPUT_DEBUG',exist=debug_input)
91
 
     if (debug_input) then
 
95
     if ( debug_input ) then
92
96
        write(*,'(a)') 'WARNING: ' // &
93
97
             'TBTrans is reading its input from file INPUT_DEBUG'
94
98
        filein = 'INPUT_DEBUG'
95
99
 
96
100
#ifndef NO_F2003
97
 
     else if ( count > 0 ) then
 
101
     else if ( .not. is_pipe ) then
98
102
 
99
103
        ! Get file-name from input line (last input argument)
100
 
        count = command_argument_count()
101
104
        filein = ' '
102
 
        call get_command_argument(count,filein,length)
 
105
        call get_command_argument(count, filein, length)
103
106
        if ( length > len(filein) ) then
104
107
           call die('The argument is too long to be retrieved, please &
105
108
                &limit to 50 characters for the input file')
106
109
        end if
107
 
        inquire(file=filein,exist=debug_input)
 
110
        inquire(file=filein, exist=debug_input)
108
111
        if ( .not. debug_input ) then
109
112
           call die('Input file '//trim(filein)//' does not exist? Have &
110
113
                &you specified the wrong file-name?')
127
130
           inquire( file=filein, exist=file_exists )
128
131
           if (.not.file_exists) exit
129
132
        end do
130
 
!
 
133
 
131
134
        open(lun_tmp,file=filein, &
132
135
             form='formatted',status='replace')
133
136
        rewind(lun_tmp)
134
137
        write(*,"(a,23('*'),a,28('*'))") &
135
138
             '***', ' Dump of input data file '
136
 
!
 
139
 
137
140
        do
138
141
           read(lun,iostat=iostat,fmt='(a)') line
139
142
           if (iostat /= 0 ) exit
155
158
!
156
159
     endif
157
160
  endif
158
 
! ...
159
161
 
160
162
! Set up fdf ...
161
163
!
168
170
  call fdf_init(filein,trim(fileout))
169
171
 
170
172
#ifndef NO_F2003
171
 
  ! Read special variables from the command line
 
173
  ! Read command line flags from the command line
172
174
  count = command_argument_count()
 
175
  
 
176
  ! When we are not using pipes we have to skip the last argument
 
177
  if ( .not. is_pipe ) count = count - 1
 
178
  
173
179
  if ( count > 0 ) then
174
 
     in = 0
175
 
     do while ( in <= count - 1 )
176
 
        in = in + 1
177
 
        call get_command_argument(in,line,length)
178
 
 
179
 
        ! If it is not an option, skip it
180
 
        if ( line(1:1) /= '-' ) cycle
181
 
 
182
 
        do while ( line(1:1) == '-' )
183
 
           line = line(2:)
184
 
        end do
185
 
 
186
 
        ! We allow these line
187
 
        if ( line(1:3) == 'fdf' ) then
188
 
           if ( in >= count - 1 ) &
189
 
                call die('Missing argument on command line, -fdf')
190
 
           in = in + 1
191
 
           call get_command_argument(in,line,length)
192
 
 
193
 
           ! We allow these variations:
194
 
           !  TBT.Voltage=0.1:eV
195
 
           !  TBT.Voltage:0.1:eV
196
 
           !  TBT.Voltage=0.1=eV
197
 
           line = cmd_tokenize(line)
198
 
           call fdf_overwrite(line)
199
 
 
200
 
        else if ( line(1:1) == 'V' ) then
201
 
           if ( in >= count - 1 ) &
202
 
                call die('Missing argument on command line, -V')
203
 
           in = in + 1
204
 
           call get_command_argument(in,line,length)
205
 
           line = cmd_tokenize(line)
206
 
           line = 'TBT.Voltage '//trim(line)
207
 
           call fdf_overwrite(line)
208
 
 
209
 
        else if ( line(1:1) == 'D' ) then
210
 
           if ( in >= count - 1 ) &
211
 
                call die('Missing argument on command line, -D')
212
 
           in = in + 1
213
 
           call get_command_argument(in,line,length)
214
 
           line = 'TBT.Directory '//trim(line)
215
 
           call fdf_overwrite(line)
216
 
 
217
 
        else if ( line(1:2) == 'HS' ) then
218
 
           if ( in >= count - 1 ) &
219
 
                call die('Missing argument on command line, -HS')
220
 
           in = in + 1
221
 
           call get_command_argument(in,line,length)
222
 
           line = 'TBT.HS '//trim(line)
223
 
           call fdf_overwrite(line)
224
 
 
225
 
        else if ( line(1:1) == 'L' ) then
226
 
           if ( in >= count - 1 ) &
227
 
                call die('Missing argument on command line, -L')
228
 
           in = in + 1
229
 
           call get_command_argument(in,line,length)
230
 
           line = cmd_tokenize(line)
231
 
           line = 'SystemLabel '//trim(line)
232
 
           call fdf_overwrite(line)
233
 
 
234
 
        else if ( line(1:4) == 'help' .or. line(1:1) == 'h' ) then
235
 
           write(*,'(a)') 'Help for calling the tight-binding transport code'
236
 
           write(*,'(a)') '  -out <file>'
237
 
           write(*,'(a)') '      Write all output to <file> instead of STDOUT'
238
 
           write(*,'(a)') '  -fdf <label>=<value>[:<unit>]'
239
 
           write(*,'(a)') '      Set the label to the corresponding value.'
240
 
           write(*,'(a)') '  -V <value>:<unit>'
241
 
           write(*,'(a)') '      Short-hand for setting TBT.Voltage'
242
 
           write(*,'(a)') '  -D <directory>'
243
 
           write(*,'(a)') '      Short-hand for setting TBT.Directory'
244
 
           write(*,'(a)') '  -HS <Hamiltonian>'
245
 
           write(*,'(a)') '      Short-hand for setting TBT.HS'
246
 
           write(*,'(a)') '  -L <name>'
247
 
           write(*,'(a)') '      Short-hand for setting SystemLabel'
248
 
           write(*,'(a)') '  <fdf-file>'
249
 
           write(*,'(a)') '      Use file as fdf-input, you need not to pipe it in.'
250
 
           call bye('Help-menu requested, stopping')
251
 
        end if
252
 
        
253
 
     end do
 
180
    in = 0
 
181
    do while ( in <= count )
 
182
      in = in + 1
 
183
      call get_command_argument(in,line,length)
 
184
      
 
185
      ! If it is not an option, skip it
 
186
      if ( line(1:1) /= '-' ) cycle
 
187
      
 
188
      do while ( line(1:1) == '-' )
 
189
        line = line(2:)
 
190
      end do
 
191
      
 
192
      ! We allow these line
 
193
      if ( line(1:3) == 'fdf' ) then
 
194
        if ( in >= count ) &
 
195
            call die('Missing argument on command line, -fdf')
 
196
        in = in + 1
 
197
        call get_command_argument(in,line,length)
 
198
        
 
199
        ! We allow these variations:
 
200
        !  TBT.Voltage=0.1:eV
 
201
        !  TBT.Voltage:0.1:eV
 
202
        !  TBT.Voltage=0.1=eV
 
203
        line = cmd_tokenize(line)
 
204
        call fdf_overwrite(line)
 
205
        
 
206
      else if ( line(1:1) == 'V' ) then
 
207
        if ( in >= count ) &
 
208
            call die('Missing argument on command line, -V')
 
209
        in = in + 1
 
210
        call get_command_argument(in,line,length)
 
211
        line = cmd_tokenize(line)
 
212
        line = 'TBT.Voltage '//trim(line)
 
213
        call fdf_overwrite(line)
 
214
        
 
215
      else if ( line(1:1) == 'D' ) then
 
216
        if ( in >= count ) &
 
217
            call die('Missing argument on command line, -D')
 
218
        in = in + 1
 
219
        call get_command_argument(in,line,length)
 
220
        line = 'TBT.Directory '//trim(line)
 
221
        call fdf_overwrite(line)
 
222
        
 
223
      else if ( line(1:2) == 'HS' ) then
 
224
        if ( in >= count ) &
 
225
            call die('Missing argument on command line, -HS')
 
226
        in = in + 1
 
227
        call get_command_argument(in,line,length)
 
228
        line = 'TBT.HS '//trim(line)
 
229
        call fdf_overwrite(line)
 
230
        
 
231
      else if ( line(1:1) == 'L' ) then
 
232
        if ( in >= count ) &
 
233
            call die('Missing argument on command line, -L')
 
234
        in = in + 1
 
235
        call get_command_argument(in,line,length)
 
236
        line = cmd_tokenize(line)
 
237
        line = 'SystemLabel '//trim(line)
 
238
        call fdf_overwrite(line)
 
239
        
 
240
      else if ( line(1:4) == 'help' .or. line(1:1) == 'h' ) then
 
241
        write(*,'(a)') 'Help for calling the tight-binding transport code'
 
242
        write(*,'(a)') '  -out <file>'
 
243
        write(*,'(a)') '      Write all output to <file> instead of STDOUT'
 
244
        write(*,'(a)') '  -fdf <label>=<value>[:<unit>]'
 
245
        write(*,'(a)') '      Set the label to the corresponding value.'
 
246
        write(*,'(a)') '  -V <value>:<unit>'
 
247
        write(*,'(a)') '      Short-hand for setting TBT.Voltage'
 
248
        write(*,'(a)') '  -D <directory>'
 
249
        write(*,'(a)') '      Short-hand for setting TBT.Directory'
 
250
        write(*,'(a)') '  -HS <Hamiltonian>'
 
251
        write(*,'(a)') '      Short-hand for setting TBT.HS'
 
252
        write(*,'(a)') '  -L <name>'
 
253
        write(*,'(a)') '      Short-hand for setting SystemLabel'
 
254
        write(*,'(a)') '  <fdf-file>'
 
255
        write(*,'(a)') '      Use file as fdf-input, you need not to pipe it in.'
 
256
        call bye('Help-menu requested, stopping')
 
257
      end if
 
258
      
 
259
    end do
254
260
  end if
255
261
#endif
256
262
 
257
263
  ! Initialize the verbosity setting
258
 
  call init_verbosity('TBT.Verbosity',5)
 
264
  call init_verbosity('TBT.Verbosity', 5)
259
265
 
260
266
! Define Name of the system ...
261
267
  sname = fdf_get('SystemName',' ')
264
270
     write(*,'(a,a)') 'reinit: System Name: ',trim(sname)
265
271
     write(*,'(a,71("-"))') 'reinit: '
266
272
  endif
267
 
! ...
268
273
 
269
274
! Define System Label (short name to label files) ...
270
275
  slabel = fdf_get('SystemLabel','siesta')
272
277
     write(*,'(a,a)') 'reinit: System Label: ',trim(slabel)
273
278
     write(*,'(a,71("-"))') 'reinit: '
274
279
  endif
275
 
! ...
276
280
 
277
281
contains
278
282