-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathg09.freqinput.sh
executable file
·701 lines (631 loc) · 23.7 KB
/
g09.freqinput.sh
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
#!/bin/bash
#####################################################################
# #
# Warning: This repository is no longer maintained as Gaussian 09 #
# is also becoming obsolete, or deprecated. #
# Info: The sucessor repository for Gaussian 16 can be found at #
# https://github.com/polyluxus/tools-for-g16.bash #
# #
# Martin, 2019-05-01 #
# #
#####################################################################
how_called="$0 $*"
scriptname=${0##*\/} # Remove trailing path
scriptname=${scriptname%.sh} # remove scripting ending (if present)
version="0.1.9"
versiondate="2018-02-15"
# A script to take an input file and write a new inputfile to
# perform a frequency calculation.
# To Do: import (formatted) checkpoint files
#hlp This script takes a Gaussian inputfile and writes a new inputfile for a frequency run.
#hlp The newly created inputfile relies on a checkpointfile to read all data.
#
# Print logging information and warnings nicely.
# If there is an unrecoverable error: display a message and exit.
#
indent ()
{
echo -n "INFO : " "$*"
}
message ()
{
echo "INFO : " "$@"
}
warning ()
{
echo "WARNING: " "$@" >&2
return 1
}
fatal ()
{
echo "ERROR : " "$@" >&2
exit 1
}
#
# Print some helping commands
# The lines are distributed throughout the script and grepped for
#
helpme ()
{
local line
local pattern="^[[:space:]]*#hlp[[:space:]]?(.*)$"
while read -r line; do
[[ $line =~ $pattern ]] && eval "echo \"${BASH_REMATCH[1]}\""
done < <(grep "#hlp" "$0")
exit 0
}
getCheckpointfile ()
{
# The checkpointfile should be indicated in the original input file
# (It is a link 0 command and should therefore before the route section.)
local parseline="$1"
local pattern="^[[:space:]]*%chk=([^[:space:]]+)([[:space:]]+|$)"
if [[ $parseline =~ $pattern ]]; then
checkpointfile="${BASH_REMATCH[1]}"
else
return 1
fi
}
removeComment ()
{
local variableName="$1" variableContent="$2"
local pattern="^[[:space:]]*([^!]+)[!]*[[:space:]]*(.*)$"
if [[ $variableContent =~ $pattern ]] ; then
printf -v "$variableName" "%s" "${BASH_REMATCH[1]}"
[[ ! -z ${BASH_REMATCH[2]} ]] && message "Removed comment: ${BASH_REMATCH[2]}"
else
return 1 # Return false if blank line
fi
}
parseInputfile ()
{
# The route section contains one or more lines.
# It always starts with # folowed by a space or the various verbosity levels
# NPT (case insensitive). The route section is terminated by a blank line.
# It is immediately followed by the title section, which can also consist of
# multiple lines made up of (almost) anything. It is also terminated by a blank line.
# Following that is the charge and multiplicity.
local line appendline
# The hash marks the beginning of the route
local routeStartPattern="^[[:space:]]*#[nNpPtT]?[[:space:]]"
local storeRoute=0 storeTitle=0 storeChargeMultiplicity=0
while read -r line; do
# If we found the checkpointfile, we can skip out of the loop
if [[ -z $checkpointfile ]] ; then
getCheckpointfile "$line" && continue
fi
if (( storeRoute == 0 )) ; then
if [[ $line =~ $routeStartPattern ]] ; then
storeRoute=1
removeComment appendline "$line"
routeSection="$appendline"
continue
fi
fi
if (( storeRoute == 1 )) ; then
if [[ $line =~ ^[[:space:]]*$ ]]; then
storeTitle=1
storeRoute=2
continue
fi
removeComment appendline "$line"
[[ ! -z $appendline ]] && routeSection="$routeSection $appendline"
unset appendline
continue
fi
if (( storeTitle == 1 )) ; then
if [[ $line =~ ^[[:space:]]*$ ]]; then
storeTitle=2
storeChargeMultiplicity=1
continue
fi
removeComment appendline "$line"
[[ ! -z $appendline ]] && titleSection="$titleSection $appendline"
unset appendline
continue
fi
if (( storeChargeMultiplicity == 1 )) ; then
removeComment appendline "$line"
pattern="^[[:space:]]*([0-9]+)[[:space:]]+([0-9]+)[[:space:]]*$"
[[ $appendline =~ $pattern ]]
molCharge="${BASH_REMATCH[1]}"
molMultiplicity="${BASH_REMATCH[2]}"
# We now have everything we need
break
fi
done < "$1"
}
collateKeywordOptions ()
{
# The function takes an inputstring and removes any unnecessary spaces
# needed for collateKeywords
local inputstring="$1"
# The collated section will be saved to
local keepstring transformstring
# Any combination of spaces, equals signs, and opening parentheses
# can and need to be removed
local removeFront="[[:space:]]*[=]?[[:space:]]*[\(]?"
# Any trailing closing parentheses and spaces need to be cut
local removeEnd="[\)]?[[:space:]]*"
[[ $inputstring =~ $removeFront([^\)]+)$removeEnd ]] && inputstring="${BASH_REMATCH[1]}"
# Spaces, tabs, or commas can be used in any combination
# to separate items within the options.
# Does massacre IOPs.
local pattern="[^[:space:],]+([[:space:]]*=[[:space:]]*[^[:space:],]+)?([[:space:],]+|$)"
while [[ $inputstring =~ $pattern ]] ; do
transformstring="${BASH_REMATCH[0]}"
inputstring="${inputstring//${BASH_REMATCH[0]}/}"
# remove stuff
transformstring="${transformstring// /}"
transformstring="${transformstring//,/}"
if [[ -z $keepstring ]] ; then
keepstring="$transformstring"
else
keepstring="$keepstring,$transformstring"
fi
done
echo "$keepstring"
}
collateKeywords ()
{
# This function removes spaces which have been entered in the original input
# so that the folding (to 80 characters) doesn't break a keyword.
local inputstring="$1"
# The collated section will be saved to
local keepstring
# If we encounter a long keyword stack, we need to set a different returncode
local returncode=0
# extract the hashtag of the route section
local routeStartPattern="^[[:space:]]*(#[nNpPtT]?)[[:space:]]"
if [[ $inputstring =~ $routeStartPattern ]] ; then
keepstring="${BASH_REMATCH[1]}"
inputstring="${inputstring//${BASH_REMATCH[0]}/}"
fi
# The following formats for the input of keywords are given in the manual:
# keyword = option
# keyword(option)
# keyword=(option1, option2, …)
# keyword(option1, option2, …)
# Spaces can be added or left out, I could also confirm that the following will work, too:
# keyword (option[1, option2, …])
# keyword = (option[1, option2, …])
# Spaces, tabs, commas, or forward slashes can be used in any combination
# to separate items within a line.
# Multiple spaces are treated as a single delimiter.
# see http://gaussian.com/input/?tabid=1
# The ouptput of this function should only use the keywords without any options, or
# the following format: keyword=(option1,option2,…) [no spaces]
# Exeptions to the above: temperature=500 and pressure=2,
# where the equals is the only accepted form.
# This is probably because they can also be options to 'freq'.
local keywordPattern="[^[:space:],/\(=]+"
local optionPatternEquals="[[:space:]]*=[[:space:]]*[^[:space:],/\(\)]+"
local optionPatternParens="[[:space:]]*[=]?[[:space:]]*\([^\)]+\)"
local keywordOptions="$optionPatternEquals|$optionPatternParens"
local keywordTerminate="[[:space:],/]+|$"
local testPattern="($keywordPattern)($keywordOptions)?($keywordTerminate)"
local keepKeyword keepOptions
local numericalPattern="[[:digit:]]+\.?[[:digit:]]*"
while [[ $inputstring =~ $testPattern ]] ; do
# Unify input pattern and remove unnecessary spaces
# Remove found portion from inputstring:
inputstring="${inputstring//${BASH_REMATCH[0]}/}"
# Keep keword, options, and how it was terminated
keepKeyword="${BASH_REMATCH[1]}"
keepOptions="${BASH_REMATCH[2]}"
keepTerminate="${BASH_REMATCH[3]}"
# Remove spaces from IOPs (only evil people use them there)
if [[ $keepKeyword =~ ^[Ii][Oo][Pp]$ ]] ; then
keepKeyword="$keepKeyword$keepOptions"
keepKeyword="${keepKeyword// /}"
unset keepOptions # unset to not run into next 'if'
fi
if [[ ! -z $keepOptions ]] ; then
# remove spaces, equals, parens from front and end
# substitute option separating spaces with commas
keepOptions=$(collateKeywordOptions "$keepOptions")
# Check for the exceptions to the desired format
if [[ $keepKeyword =~ ^[Tt][Ee][Mm][Pp].*$ ]] ; then
if [[ ! $keepOptions =~ ^$numericalPattern$ ]] ; then
warning "Unrecognised format for temperature: $keepOptions."
returncode=1
fi
keepKeyword="$keepKeyword=$keepOptions"
elif [[ $keepKeyword =~ ^[Pp][Rr][Ee].*$ ]] ; then
if [[ ! $keepOptions =~ ^$numericalPattern$ ]] ; then
warning "Unrecognised format for temperature: $keepOptions."
returncode=1
fi
keepKeyword="$keepKeyword=$keepOptions"
else
keepKeyword="$keepKeyword($keepOptions)"
fi
fi
if [[ $keepTerminate =~ / ]] ; then
keepKeyword="$keepKeyword/"
fi
if (( ${#keepKeyword} > 80 )) ; then
returncode=1
warning "Found extremely long keyword, heck input before running the calculation."
fi
if [[ $keepstring =~ /$ ]] ; then
keepstring="$keepstring$keepKeyword"
elif [[ -z $keepstring ]] ; then
keepstring="$keepKeyword"
else
keepstring="$keepstring $keepKeyword"
fi
done
echo "$keepstring"
return $returncode
}
removeAnyKeyword ()
{
# Takes in a string (the route section) and
local testLine="$1"
# removes the pattern (keyword) if present and
local testPattern="$2"
# stores the result to the new route section.
# Since spaces have been removed form within the keywords previously with collateKeywords,
# and inter-keyword delimiters are set to spaces only also,
# it is safe to use that as a criterion to remove unnecessary keywords.
# The test pattern is extended to catch the whole keyword including options.
local extendedPattern="($testPattern[^[:space:]]*)([[:space:]]+|$)"
if [[ $testLine =~ $extendedPattern ]] ; then
#echo "-->|${BASH_REMATCH[0]}|<--" #(Debug Pattern:)
local foundPattern=${BASH_REMATCH[1]}
message "Removed keyword '$foundPattern'."
newRouteSection="${testLine/$foundPattern/}"
return 1
fi
}
removeOptKeyword ()
{
# Assigns the opt keyword to the pattern
local testRouteSection="$1"
local pattern
pattern="[Oo][Pp][Tt]"
removeAnyKeyword "$testRouteSection" "$pattern" || return 1
}
removeFreqKeyword ()
{
# Assign the freq keyword to the pattern
local testRouteSection="$1"
local functionExitStatus=0
local pattern
pattern="[Ff][Rr][Ee][Qq]"
removeAnyKeyword "$testRouteSection" "$pattern" || functionExitStatus=1
if (( functionExitStatus != 0 )) && [[ $rerunFreqAnalysis == "false" ]] ; then
warning "It appears that you want to run a frequency calculation based on a frequency calculation."
fi
return $functionExitStatus
}
removeTempKeyword ()
{
# Assign the temp keyword to the pattern
local testRouteSection="$1"
local functionExitStatus=0
local pattern
pattern="[Tt][Ee][Mm][Pp]"
removeAnyKeyword "$testRouteSection" "$pattern" || functionExitStatus=1
if (( functionExitStatus != 0 )) ; then
message "Avoiding double specification."
fi
return $functionExitStatus
}
removePresKeyword ()
{
# Assign the temp keyword to the pattern
local testRouteSection="$1"
local functionExitStatus=0
local pattern
pattern="[Pp][Rr][Ee]"
removeAnyKeyword "$testRouteSection" "$pattern" || functionExitStatus=1
if (( functionExitStatus != 0 )) ; then
message "Avoiding double specification."
fi
return $functionExitStatus
}
removeGuessKeyword ()
{
# Assigns the guess keyword to the pattern
local testRouteSection="$1"
local pattern
pattern="[Gg][Uu][Ee][Ss][Ss]"
removeAnyKeyword "$testRouteSection" "$pattern" || return 1
}
removeGeomKeyword ()
{
# Assigns the geom keyword to the pattern
local testRouteSection="$1"
local pattern
pattern="[Gg][Ee][Oo][Mm]"
removeAnyKeyword "$testRouteSection" "$pattern" || return 1
}
removeGenKeyword ()
{
# Assigns the gen keyword to the pattern
local testRouteSection="$1"
local pattern
pattern="[Gg][Ee][Nn]"
removeAnyKeyword "$testRouteSection" "$pattern" || return 1
}
removePopKeyword ()
{
local testRouteSection="$1"
local functionExitStatus=0
local pattern
pattern="[Pp][Oo][Pp]"
removeAnyKeyword "$testRouteSection" "$pattern" || functionExitStatus=1
if (( functionExitStatus != 0 )) ; then
message "It is safer to perform a population analysis with a property run."
fi
return $functionExitStatus
}
removeOutputKeyword ()
{
local testRouteSection="$1"
local functionExitStatus=0
local pattern
pattern="[Oo][Uu][Tt][Pp][Uu][Tt]"
removeAnyKeyword "$testRouteSection" "$pattern" || functionExitStatus=1
if (( functionExitStatus != 0 )) ; then
warning "Presence opt the 'OUTPUT' keyword might indicate that the calculation is not suited for a frequency calculation."
fi
return $functionExitStatus
}
warnAnyKeyword ()
{
# Takes in a string (the route section) and
local testLine="$1"
# tests for a pattern (keyword)
local testPattern="$2"
# and if present issues a warning.
# Since spaces have been removed form within the keywords previously with collateKeywords,
# and inter-keyword delimiters are set to spaces only also,
# it is safe to use that as a criterion to find keywords.
# The test pattern is extended to catch the whole keyword including options.
local extendedPattern="($testPattern[^[:space:]]*)([[:space:]]+|$)"
if [[ $testLine =~ $extendedPattern ]] ; then
#echo "-->|${BASH_REMATCH[0]}|<--" #(Debug Pattern:)
local foundPattern=${BASH_REMATCH[1]}
warning "Found keyword '$foundPattern'."
return 1
fi
}
warnDenfitKeyword ()
{
# Assigns the gen keyword to the pattern, extends to GenECP, too
# (used to specify own basis set)
local testRouteSection="$1"
local pattern
pattern="[Dd][Ee][Nn][Ff][Ii][Tt]"
warnAnyKeyword "$testRouteSection" "$pattern" || return 1
}
warnGenKeyword ()
{
# Assigns the gen keyword to the pattern, extends to GenECP, too
# (used to specify own basis set)
local testRouteSection="$1"
local pattern
pattern="[Gg][Ee][Nn]"
warnAnyKeyword "$testRouteSection" "$pattern" || return 1
}
warnAndSubAnyKeyword ()
{
# Takes in a string (the route section)
local testLine="$1"
# and tests for a pattern (keyword)
local testPattern="$2"
# and if present issues a warning
# and subsititutes with alternative pattern.
local subPattern="$3"
# Since spaces have been removed form within the keywords previously with collateKeywords,
# and inter-keyword delimiters are set to spaces only also,
# it is safe to use that as a criterion to find keywords.
# The test pattern is extended to catch the whole keyword including options.
local extendedPattern="($testPattern[^[:space:]]*)([[:space:]]+|$)"
if [[ $testLine =~ $extendedPattern ]] ; then
#echo "-->|${BASH_REMATCH[0]}|<--" #(Debug Pattern:)
local foundPattern=${BASH_REMATCH[1]}
warning "Substitute keyword '$foundPattern' with '$subPattern'."
newRouteSection="${testLine/$foundPattern/$subPattern}"
return 1
fi
}
warnAndSubGenKeyword ()
{
# Assigns the gen keyword to the pattern, extends to GenECP, too
# (used to specify own basis set)
local testRouteSection="$1"
local pattern
pattern="[Gg][Ee][Nn]"
warnAndSubAnyKeyword "$testRouteSection" "$pattern" "ChkBasis" || return 1
}
testAndFormatTempKeyword ()
{
local numericalPattern="[[:digit:]]+\.?[[:digit:]]*"
if [[ $1 =~ ^$numericalPattern$ ]] ; then
echo "Temperature=$1"
else
fatal "The value '$1' for the temperature is not numerical."
fi
}
testAndFormatPresKeyword ()
{
local numericalPattern="[[:digit:]]+\.?[[:digit:]]*"
if [[ $1 =~ ^$numericalPattern$ ]] ; then
echo "Pressure=$1"
else
fatal "The value '$1' for the pressure is not numerical."
fi
}
addRunKeywords ()
{
local newKeywords
newKeywords="geom(check) guess(read)"
newKeywords="$newKeywords $addFrequencyKeyword $addTempKeyword $addPresKeyword $customRouteInput"
newKeywords=$(collateKeywords "$newKeywords")
echo "$newKeywords"
}
createNewInputFileData ()
{
parseInputfile "$1"
# If there were any long keywords, then return value is not 0.
# A warning must be issued
newRouteSection=$(collateKeywords "$routeSection")
while ! removeOptKeyword "$newRouteSection" ; do : ; done
while ! removeFreqKeyword "$newRouteSection" ; do : ; done
while ! removeTempKeyword "$newRouteSection" ; do : ; done
while ! removePresKeyword "$newRouteSection" ; do : ; done
while ! removeGuessKeyword "$newRouteSection" ; do : ; done
while ! removeGeomKeyword "$newRouteSection" ; do : ; done
while ! removePopKeyword "$newRouteSection" ; do : ; done
while ! removeOutputKeyword "$newRouteSection" ; do : ; done
newRouteSection="$newRouteSection $(addRunKeywords)"
if ! warnAndSubGenKeyword "$newRouteSection" ; then
warning "Additional basis set specifications have not been read,"
warning "but will be retrieved from the checkpointfile."
while ! removeGenKeyword "$newRouteSection" ; do : ; done
if ! warnDenfitKeyword "$newRouteSection" ; then
warning "Please check density fitting settings are compatible with 'ChkBasis'."
fi
fi
# If the checkpoint file was not specified in the input file, guess it
if [[ -z $checkpointfile ]] ; then
checkpointfile="${1%.*}.chk"
# Check if the guessed checkpointfile exists
# (We'll trust the user if it was specified in the input file,
# after all the calculation might not be completed yet.)
[[ ! -e $checkpointfile ]] && fatal "Cannot find '$checkpointfile'."
fi
# Check if new checkpointfile already exists
if [[ $rerunFreqAnalysis == "true" ]] ; then
newCheckpointfile=${checkpointfile%.chk}.$rerunSuffix.chk
else
newCheckpointfile=${checkpointfile%.chk}.$calcSuffix.chk
fi
[[ -e $newCheckpointfile ]] && fatal "File '$newCheckpointfile' already exists. Rename or delete it."
}
# Print the input file in a more readable form
printNewInputFile ()
{
echo "%oldchk=$checkpointfile"
echo "%chk=$newCheckpointfile"
[[ $rerunFreqAnalysis == "true" ]] && echo "%NoSave"
fold -w80 -c -s <<< "$newRouteSection"
echo ""
fold -w80 -c -s <<< "$titleSection"
echo ""
echo "$molCharge $molMultiplicity"
echo ""
if [[ ! -z $customTail ]] ; then
echo "$customTail"
echo ""
fi
echo "! Input file created with: "
echo "! $how_called"
}
#
# Main
#
(( $# == 0 )) && helpme
rerunFreqAnalysis="false"
declare calcSuffix rerunSuffix
# Evaluate options
#
#hlp Usage: $scriptname [options] filename
#hlp
#hlp Options:
while getopts :o:RT:P:r:t:hu options ; do
case $options in
#hlp -o <ARG> Adds options <ARG> to the frequency keyword.
#hlp May be specified multiple times.
#hlp The stack will be collated, but no sanity check will be performed.
#hlp Example Options: NoRaman, VCD, ReadFC
#hlp
o) if [[ -z $addFrequencyOptions ]] ; then
addFrequencyOptions="$OPTARG"
else
addFrequencyOptions="$addFrequencyOptions, $OPTARG"
fi
;;
#hlp -R Writes a property run input file to redo a frequency calculation.
#hlp Adds option 'ReadFC' to the frequency option list.
#hlp Should be specified with a temperature or pressure
#hlp via the '-T <ARG>' or '-P <ARG>' switches.
#hlp No check is performed whether the supplied input file is a
#hlp frequency calculation.
#hlp
R) rerunFreqAnalysis="true"
if [[ -z $addFrequencyOptions ]] ; then
addFrequencyOptions="ReadFC"
else
addFrequencyOptions="ReadFC, $addFrequencyOptions"
fi
warning "If not based on a frequency calculation, this will produce an error."
;;
#hlp -T <ARG> Specify temperature in kelvin.
#hlp Writes 'Temperature=<ARG>' to the route section.
#hlp If specified multiple times, only the last one has an effect.
#hlp It will, however, mess with the filename.
#hlp
T) addTempKeyword=$(testAndFormatTempKeyword "$OPTARG") || exit $?
calcSuffix="T${OPTARG//\./-}${calcSuffix}"
;;
#hlp -P <ARG> Specify pressure in atmosphere.
#hlp Writes 'Pressure=<ARG>' to the route section.
#hlp If specified multiple times, only the last one has an effect.
#hlp It will, however, mess with the filename.
#hlp
P) addPresKeyword=$(testAndFormatPresKeyword "$OPTARG") || exit $?
calcSuffix="${calcSuffix}P${OPTARG//\./-}"
;;
#hlp -r <ARG> Adds custom command <ARG> to the route section.
#hlp May be specified multiple times.
#hlp The stack will be collated, but no sanity check will be performed.
#hlp
r) customRouteInput="$customRouteInput $OPTARG" ;;
#hlp -t <ARG> Adds <ARG> to the end (tail) of the new input file.
#hlp If specified multiple times, only the last one has an effect.
#hlp
t) customTail="$OPTARG" ;;
#hlp -h Prints this help message.
#hlp
h) helpme ;;
u) helpme ;;
\?) warning "Invalid option: -$OPTARG." ;;
:) fatal "Option -$OPTARG requires an argument." ;;
esac
done
shift $((OPTIND-1))
if [[ $rerunFreqAnalysis == "true" ]] ; then
rerunSuffix="rep$calcSuffix"
elif [[ -z $calcSuffix ]] ; then
calcSuffix="freq"
else
calcSuffix="freq.$calcSuffix"
fi
[[ -z $1 ]] && fatal "No filename specified."
inputFilename="$1"
[[ ! -e "$inputFilename" ]] && fatal "Cannot access '$inputFilename'."
[[ ! -r "$inputFilename" ]] && fatal "Cannot access '$inputFilename'."
shift
(( $# > 0 )) && warning "Additional input ($*) will be ignored."
if [[ $rerunFreqAnalysis == "true" ]] ; then
outputFilename="${inputFilename%.freq.*}.freq.$rerunSuffix.com"
else
outputFilename="${inputFilename%.*}.$calcSuffix.com"
fi
[[ -e "$outputFilename" ]] && fatal "File '$outputFilename' exists. Rename or delete it."
if [[ -z $addFrequencyOptions ]] ; then
addFrequencyKeyword="freq"
else
addFrequencyKeyword="freq($addFrequencyOptions)"
fi
createNewInputFileData "$inputFilename"
printNewInputFile > "$outputFilename"
message "Modified '$inputFilename'."
message "New input is called '$outputFilename'."
#hlp (Martin; $version; $versiondate.)
message "$scriptname is part of tools-for-g09.bash $version ($versiondate)"