|
本帖最后由 liuyuje714 于 2020-8-14 15:05 编辑
不错的东西。如果不考虑awk数据精度的限制和速度,直接就没必要用这个fortran接口了。把脚本中的最后那个./ext_gau $3 $atoms $derivs直接换成下面的代码即可。当然对于这种较高精度运算,用fortran或者C等写接口才靠谱。- WeightedNum=0.500000000
- awk '
- BEGIN {
- natom = "'$atoms'"+0; WeightedNum = "'$WeightedNum'"+0
- }
-
- NR == FNR {
- if(NR == 1) {mp2ene = $1}
- if(NR > 2) {
- for(i = 1; i <= natom; i++) {
- gsub("D", "E", $1); fx2[i] = $1; getline
- gsub("D", "E", $1); fy2[i] = $1; getline
- gsub("D", "E", $1); fz2[i] = $1; getline
- }
- }
- }
- NR != FNR {
- if(FNR == 1) {mp3ene = $1}
- if(FNR > 2) {
- for(i = 1; i <= natom; i++) {
- gsub("D", "E", $1); fx3[i] = $1; getline
- gsub("D", "E", $1); fy3[i] = $1; getline
- gsub("D", "E", $1); fz3[i] = $1; getline
- }
- }
- }
- END {
- enesum=(1-WeightedNum)*mp2ene+WeightedNum*mp3ene
- printf("%20.12e%20.12e%20.12e%20.12e\n", enesum, 0, 0, 0)
- for(j = 1; j <= natom; j++) {
- fxsum=-(1-WeightedNum)*fx2[j]-WeightedNum*fx3[j]
- fysum=-(1-WeightedNum)*fy2[j]-WeightedNum*fy3[j]
- fzsum=-(1-WeightedNum)*fz2[j]-WeightedNum*fz3[j]
- printf("%20.12e%20.12e%20.12e\n", fxsum, fysum, fzsum)
- }
- }
-
- ' cfmp2.out cfmp3.out > $3
复制代码
|
评分 Rate
-
查看全部评分 View all ratings
|