File: writecar

package info (click to toggle)
viewmol 2.4.1-13
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,212 kB
  • ctags: 2,054
  • sloc: ansic: 30,727; python: 1,849; sh: 921; awk: 433; makefile: 205
file content (105 lines) | stat: -rwxr-xr-x 3,287 bytes parent folder | download | duplicates (8)
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
#! /bin/sh
#*******************************************************************************
#                                                                              *
#                                   Viewmol                                    *
#                                                                              *
#                               W R I T E C A R                                *
#                                                                              *
#                 Copyright (c) Joerg-R. Hill, October 2003                    *
#                                                                              *
#*******************************************************************************
#
# $Id: writecar,v 1.4 2003/11/07 12:58:41 jrh Exp $
# $Log: writecar,v $
# Revision 1.4  2003/11/07 12:58:41  jrh
# Release 2.4
#
# Revision 1.3  2000/12/10 15:19:14  jrh
# Release 2.3
#
# Revision 1.2  1999/05/24 01:28:01  jrh
# Release 2.2.1
#
# Revision 1.1  1999/02/07 22:00:01  jrh
# Initial revision
#
#

case `uname -s` in
  SunOS*) AWK=nawk
	    ;;
  IRIX*)  AWK=nawk
	    ;;
  *)      AWK=awk
	    ;;
esac

export LANG="C"
cat | $AWK 'BEGIN {cell=0;
			 first=1;
			}
            /^\$/ {readcoord=0;
			 readgrad=0;
			}
		      {if (readcoord == 1)
		 	 {
			   symbol=toupper($4) na;
			   printf("%-5s%15.9f%15.9f%15.9f XXX  ND     %-2s      %-2s  0.000\n", symbol, $1*0.52917706, $2*0.52917706, $3*0.52917706, tolower($4), $4);
			   na++;
			 }
			 if (readgrad == 1 && NF == 4)
			 {
			   symbol=toupper($4) na;
			   printf("%-5s%15.9f%15.9f%15.9f XXX  ND     %-2s      %-2s  0.000\n", symbol, $1*0.52917706, $2*0.52917706, $3*0.52917706, tolower($4), $4);
			   na++;
			 }
		      }
      /^\$unitcell/ {a=$2*0.52917706;
                     b=$3*0.52917706;
                     c=$4*0.52917706;
                     alpha=$5;
                     beta=$6;
                     gamma=$7;
                     cell=1;
                    }
      /^\$coord/  {if (format == "car")
			 {
			   readcoord=1;
                     if (cell == 1)
                       printf("!BIOSYM archive 3\nPBC=ON\n\n!DATE     ");
                     else
                       printf("!BIOSYM archive 3\nPBC=OFF\n\n!DATE     ");
                     system("date +\"%b %d %H:%M:%S %Y\"");
                     if (cell == 1)
                       printf("PBC%10.4f%10.4f%10.4f%10.4f%10.4f%10.4f\n", a, b, c, alpha, beta, gamma);
                     na=1;
		       }
	            }
	/^\$grad/   {if (format == "arc")
			 {
			   readgrad=1;
                     if (cell == 1)
                       printf("!BIOSYM archive 3\nPBC=ON\n");
                     else
                       printf("!BIOSYM archive 3\nPBC=OFF\n");
			 }
		  	}
      /^  cycle/  {if (readgrad == 1)
			 {
			   na=1;
			   if (first == 1)
			   {
			     first=0;
                     }
			   else
			   {
			     printf("end\nend\n");
			   }
			   printf("%-64s%16.4f\n", " ", $7);
			   printf("!DATE     ");
                     system("date +\"%b %d %H:%M:%S %Y\"");
			 }
			}
      /^  unitcell/ {printf("PBC%10.4f%10.4f%10.4f%10.4f%10.4f%10.4f (P1)\n", a, b, c, alpha, beta, gamma);}
      END         {printf("end\nend\n");
			}' format="$1" > "$2"