File: write_default_sial_programs.f

package info (click to toggle)
aces3 3.0.6-7
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 82,460 kB
  • sloc: fortran: 225,647; ansic: 20,413; cpp: 4,349; makefile: 953; sh: 137
file content (474 lines) | stat: -rw-r--r-- 13,779 bytes parent folder | download
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
C  Copyright (c) 2003-2010 University of Florida
C
C  This program is free software; you can redistribute it and/or modify
C  it under the terms of the GNU General Public License as published by
C  the Free Software Foundation; either version 2 of the License, or
C  (at your option) any later version.

C  This program is distributed in the hope that it will be useful,
C  but WITHOUT ANY WARRANTY; without even the implied warranty of
C  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
C  GNU General Public License for more details.

C  The GNU General Public License is included in this distribution
C  in the file COPYRIGHT.
      subroutine write_default_sial_programs(calc,dropmo,ref,geom_opt,
     *                                       vib, excite, instab, props,
     *                                       grad_calc)
c-------------------------------------------------------------------------
c   Writes the SIAL_PROGRAM parameters for a default set of SIAL programs
c   determined by the parameters calc, dropmo, ref, geom_opt, and vib.
c   The SIAL_PROGRAM parameters are written to ZMAT.AUTO.
c-------------------------------------------------------------------------
      implicit none
      integer calc,dropmo,ref,geom_opt, vib, excite, instab, props
      integer grad_calc 
      character*80 jobflow
      integer ierr
      integer n, str_trimlen

c---------------------------------------------------------------------------
c   Determine the jobflow required for the combination of parameters.
c---------------------------------------------------------------------------

c      print *,'ref, calc, dropmo, geom_opt, vib ',
c     *   ref, calc, dropmo, geom_opt, vib, excite
      jobflow = 'UNDEFINED'

      if (ref .eq. 0 .and.
     *    calc .eq. 0 .and.
     *    geom_opt .eq. 0 .and. vib .eq. 0) then
         jobflow = 'SCF_RHF_ENERGY'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 0 .and.
     *    geom_opt .eq. 0 .and. vib .eq. 0) then
         jobflow = 'SCF_UHF_ENERGY'
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 0 .and.
     *    geom_opt .gt. 0) then
         jobflow = 'SCF_RHF_GRADIENT'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 0 .and.
     *    geom_opt .gt. 0) then
         jobflow = 'SCF_UHF_GRADIENT'
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 1)) then
         jobflow = 'SCF_RHF_HESSIAN'     ! analytical hessian calc
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 0 .and.
     *    geom_opt .eq. 0 .and. vib .eq. 3) then
         if (grad_calc .eq. 2) then
            jobflow = 'SCF_RHF_ENERGY'    ! numerical gradient calc
         else
            jobflow = 'SCF_RHF_GRADIENT'    ! numerical hessian calc
         endif 
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 1)) then
         jobflow = 'SCF_UHF_HESSIAN'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 3)) then
         if (grad_calc .eq. 2) then
            jobflow = 'SCF_UHF_ENERGY'
         else
            jobflow = 'SCF_UHF_GRADIENT'
         endif
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 1 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 1)) then
         jobflow = 'MP2_RHF_HESSIAN'
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 1 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 3)) then
         if (grad_calc .eq. 2) then
            jobflow = 'MP2_RHF_ENERGY'
         else
            jobflow = 'MP2_RHF_GRADIENT'
         endif
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 1 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 1)) then
         jobflow = 'MP2_UHF_HESSIAN'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 1 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 3)) then
         if (grad_calc .eq. 2) then
            jobflow = 'MP2_UHF_ENERGY'
         else
            jobflow = 'MP2_UHF_GRADIENT'
         endif
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 1 .and.
     *    geom_opt .eq. 0 .and. vib .eq. 0) then
         jobflow = 'MP2_RHF_ENERGY'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 1 .and.
     *    geom_opt .eq. 0 .and. vib .eq. 0) then
         jobflow = 'MP2_UHF_ENERGY'
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 1 .and.
     *    geom_opt .gt. 0) then
         jobflow = 'MP2_RHF_GRADIENT'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 1 .and.
     *    geom_opt .gt. 0) then
         jobflow = 'MP2_UHF_GRADIENT'
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 6 .and.
     *    dropmo .eq. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'LCCSD_RHF_ENERGY'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 6 .and.
     *    dropmo .eq. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'LCCSD_UHF_ENERGY'
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 6 .and.
     *    dropmo .ne. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'LCCSD_RHF_DROPMO_ENERGY'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 6 .and.
     *    dropmo .ne. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'LCCSD_UHF_DROPMO_ENERGY'
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 6 .and.
     *    dropmo .eq. 0 .and.
     *    (geom_opt .gt. 0 .or. vib .eq. 3)) then
         if (grad_calc .eq. 2) then
            jobflow = 'LCCSD_RHF_ENERGY'
         else
            jobflow = 'LCCSD_RHF_GRADIENT'
         endif
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 6 .and.
     *    dropmo .eq. 0 .and.
     *    (geom_opt .gt. 0 .or. vib .eq. 3)) then
         if (grad_calc .eq. 2) then
            jobflow = 'LCCSD_UHF_ENERGY'
         else 
            jobflow = 'LCCSD_UHF_GRADIENT'
         endif  
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 6 .and.
     *    dropmo .ne. 0 .and.
     *    (geom_opt .gt. 0 .or. vib .eq. 3)) then
         jobflow = 'LCCSD_RHF_DROPMO_GRADIENT'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 6 .and.
     *    dropmo .ne. 0 .and.
     *    (geom_opt .gt. 0 .or. vib .eq. 3)) then
         jobflow = 'LCCSD_UHF_DROPMO_GRADIENT'
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 10 .and.
     *    dropmo .eq. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'CCSD_RHF_ENERGY'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 10 .and.
     *    dropmo .eq. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'CCSD_UHF_ENERGY'
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 10 .and.
     *    dropmo .ne. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'CCSD_RHF_DROPMO_ENERGY'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 10 .and.
     *    dropmo .ne. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'CCSD_UHF_DROPMO_ENERGY'
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 10 .and.
     *    dropmo .eq. 0 .and.
     *    (geom_opt .gt. 0 .or. vib .eq. 3)) then
         if (grad_calc .eq. 2) then
            jobflow = 'CCSD_RHF_ENERGY'
         else
            jobflow = 'CCSD_RHF_GRADIENT'
         endif
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 10 .and.
     *    dropmo .eq. 0 .and.
     *    (geom_opt .gt. 0 .or. vib .eq. 3)) then
         if (grad_calc .eq. 2) then
            jobflow = 'CCSD_UHF_ENERGY'
         else
            jobflow = 'CCSD_UHF_GRADIENT'
         endif
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 10 .and.
     *    dropmo .ne. 0 .and.
     *    (geom_opt .gt. 0 .or. vib .eq. 3)) then
         if (grad_calc .eq. 2) then
            jobflow = 'CCSD_RHF_DROPMO_ENERGY'
         else
            jobflow = 'CCSD_RHF_DROPMO_GRADIENT'
         endif 
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 10 .and.
     *    dropmo .ne. 0 .and.
     *    (geom_opt .gt. 0 .or. vib .eq. 3)) then
         if (grad_calc .eq. 2) then
            jobflow = 'CCSD_UHF_DROPMO_GRADIENT'
         else
            jobflow = 'CCSD_UHF_DROPMO_GRADIENT'
         endif
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 22 .and.
     *    dropmo .eq. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'CCSD_RHF_TRIPLES_ENERGY'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 22 .and.
     *    dropmo .eq. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'CCSD_UHF_TRIPLES_ENERGY'
      endif

      if (ref .eq. 0 .and.
     *    calc .eq. 22 .and.
     *    dropmo .ne. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'CCSD_RHF_DROPMO_TRIPLES_ENERGY'
      endif

      if (ref .eq. 1 .and.
     *    calc .eq. 22 .and.
     *    dropmo .ne. 0 .and.
     *    (geom_opt .eq. 0 .and. vib .eq. 0)) then
         jobflow = 'CCSD_UHF_DROPMO_TRIPLES_ENERGY'
      endif

      n = str_trimlen(jobflow)
      if (instab .gt. 0) jobflow((n+1):(n+7)) = '_INSTAB'

      if (excite .eq. 3) then
         if (ref .eq. 0 .and.
     *       calc .eq. 10 .and.
     *       dropmo .eq. 0) then
            jobflow = 'EOM_RHF_CCSD_ENERGY'
         endif

         if (ref .eq. 0 .and.
     *       calc .eq. 10 .and.
     *       dropmo .ne. 0) then
            jobflow = 'EOM_RHF_CCSD_DROPMO_ENERGY'
         endif

         if (ref .eq. 1 .and.
     *       calc .eq. 10 .and.
     *       dropmo .eq. 0) then
            jobflow = 'EOM_UHF_CCSD_ENERGY'
         endif

         if (ref .eq. 1 .and.
     *       calc .eq. 10 .and.
     *       dropmo .ne. 0) then
            jobflow = 'EOM_UHF_CCSD_DROPMO_ENERGY'
         endif
C
C   Watson
C
         if (ref .eq. 0 .and.
     *       calc .eq. 10 .and.
     *       dropmo .eq. 0  .and.
     *       props  .eq. 1)   then
            jobflow = 'EOM_RHF_CCSD_DENS_ENERGY'
         endif

         if (ref .eq. 1 .and.
     *       calc .eq. 10 .and.
     *       dropmo .eq. 0  .and.
     *       props   .eq. 1)  then
            jobflow = 'EOM_UHF_CCSD_DENS_ENERGY'
         endif
C
C   Watson
C
      endif

      n = str_trimlen(jobflow)
      print *,'Using Default jobflow = ',jobflow(1:n)
      call find_default_jobflow(jobflow(1:n), ierr)
      if (ierr .eq. 0) then
         call write_default_jobflow(22, jobflow(1:n))
      else
         print *,'Error: Cannot find jobflow ',jobflow(1:n),
     *           ' in default_jobflows file.'
         call abort_job()
      endif

      return
      end

      subroutine find_default_jobflow(jobflow, ierr)
c---------------------------------------------------------------------------
c   Position default_jobfiles file to desired jobflow.  ierr > 0 indicates
c   the jobflow was not found.
c---------------------------------------------------------------------------
      implicit none
      character*(*) jobflow
      integer ierr

      character*256 fn, envvar
      character*80 line

      integer iunit, ios, lenenv, n, str_trimlen

c--------------------------------------------------------------------------
c   Check for existence of $ACES_EXE_PATH/sial_config
c--------------------------------------------------------------------------

      iunit = 12

      call c_getenv('ACES_EXE_PATH'//char(0), envvar, lenenv, ierr)
      if (ierr .eq. 0) then
         fn = envvar(1:lenenv) // '/sio/default_jobflows'
         open (unit=iunit, file = fn, status = 'OLD',
     *      err=600, iostat = ios)
      else

c--------------------------------------------------------------------------
c   Check for existence of /usr/lib/aces3/sio/sial_config
c--------------------------------------------------------------------------

        fn = '/usr/lib/aces3/sio/default_jobflows'
        open (unit=iunit, file = fn, status = 'OLD',
     *     err=600, iostat = ios)
      endif

  100 continue

c---------------------------------------------------------------------------
c   Read each line, checking for JOBFLOW statements.
c---------------------------------------------------------------------------

      read (iunit, '(A80)', end = 200) line
      if (line(1:7) .eq. 'JOBFLOW') then
         n = str_trimlen(line)
         if (line(9:n) .eq. jobflow) then

c---------------------------------------------------------------------------
c   The jobflow name matches, we have found it.
c---------------------------------------------------------------------------

            ierr = 0
            return
         endif
      endif

      go to 100

  200 continue
      ierr = 1
      return

  600 continue
      ierr = 2
      print *,'Error: Could not open file: ',fn
      return
      end

      subroutine write_default_jobflow(iunit, jobflow)
c---------------------------------------------------------------------------
c   Reads data until an "ENDJOBFLOW" is reached.  Writes the filenames to
c   the ZMAT.AUTO file.
c---------------------------------------------------------------------------

      implicit none
      integer iunit, n, str_trimlen
      character*(*) jobflow
      character*80 line , pline

  100 continue
      read (12, '(A80)', end=200) line
      n = str_trimlen(line)
      if (line(1:10) .eq. 'ENDJOBFLOW') then
         close(12)
         return
      endif

      pline = 'SIAL_PROGRAM=' // line(1:n)
      write(iunit, 9000) pline
      go to 100

  200 continue
      print *,'Error: Missing ENDJOBFLOW statement for jobflow ',
     *   jobflow
      call abort_job()

 9000 format(a80)
      return
      end