Debian Codegraph @

attic/scripts/template.pl

raw
1 #!/usr/bin/perl -w
2 ######################################################################
3 ## Feff input file template generator
4 ## copyright (c) 2000 Bruce Ravel
5 ## [email protected]
6 ## http://feff.phys.washington.edu/~ravel/
7 ##
8 ## The latest version of Atoms can always be found at
9 ## http://feff.phys.washington.edu/~ravel/software/atoms/
10 ##
11 ## -------------------------------------------------------------------
12 ## All rights reserved. This program is free software; you can
13 ## redistribute it and/or modify it under the same terms as Perl
14 ## itself.
15 ##
16 ## This program is distributed in the hope that it will be useful,
17 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ## Artistic License for more details.
20 ## -------------------------------------------------------------------
21 ######################################################################
22 my $cvs_info = '$Id: template.pl,v 1.1 2000/04/01 14:38:46 bruce Exp $ ';
23 ## Time-stamp: <2000/03/09 10:08:25 bruce>
24 ######################################################################
25 ## This simple script reads an ATP file describing an empty template
26 ## for a feff input file and writes out the empty template. This is
27 ## intended to be useful for running feff on non-crystalline compounds
28 ## where one wants a good feff.inp file but needs to type in the
29 ## coordinates by hand.
30 ######################################################################
31 ## Code:
32
33 ##use lib '/usr/local/share/ifeffit/perl';
34 use strict;
35 use Xray::Xtal;
36 $Xray::Xtal::run_level = 0;
37 use Xray::Atoms qw(build_cluster rcfile_name);
38 use Xray::ATP; # qw(parse_atp);
39
40 ## =============================== process command line switches
41 use Getopt::Std;
42 use vars qw(%opt);
43 $opt{o} = "";
44 getopts('678qho:', \%opt);
45 if ($opt{h}) {
46 require Pod::Text;
47 $^W=0;
48 if ($Pod::Text::VERSION < 2.0) {
49 Pod::Text::pod2text($0, *STDOUT);
50 } elsif ($Pod::Text::VERSION >= 2.0) {
51 my $parser = Pod::Text->new;
52 open STDIN, $0;
53 $parser->parse_from_filehandle;
54 };
55 exit;
56 };
57 my $atp = "template6";
58 ($Xray::Atoms::meta{prefer_feff_eight}) and $atp = "template8";
59 $opt{6} and $atp = "template6";
60 $opt{7} and $atp = "template7";
61 $opt{8} and $atp = "template8";
62
63
64 ## =============================== screen messages
65 my $v = (split(" ", $cvs_info))[2];
66 my $date = (split(" ", $cvs_info))[3];
67 my $screen_line = "=" x 71;
68
69 print STDOUT <<EOH
70 $screen_line
71 Feff template generator $v ($^O) $date
72 $screen_line
73 EOH
74 unless ($opt{q});
75
76
77 ## =============================== empty data structures
78 my $cell = Xray::Xtal::Cell -> new();
79 my $keywords = Xray::Atoms -> new();
80 $keywords -> make('identity'=>"the Feff template generator", die=>0);
81
82 ## =============================== make the template
83 my $contents = "";
84 my (@cluster, @neutral);
85 my ($default_name, $is_feff) =
86 &parse_atp($atp, $cell, $keywords, \@cluster, \@neutral, \$contents);
87 next unless ($default_name);
88 my $outfile = $opt{o} || $default_name;
89 my $inputdir = './'; # dirname($file); # if write_to_pwd is false...
90 if ($keywords->{'write_to_pwd'}) {
91 $outfile = $outfile;
92 } else { # e.g. on Mac or Windows
93 $outfile = File::Spec -> catfile($inputdir, $outfile);
94 };
95 ($keywords->{"quiet"}) or
96 print STDOUT " $atp: ",
97 $$Xray::Atoms::messages{'writing'}, " ", $outfile, $/;
98 open (INP, ">".$outfile) or
99 die $$Xray::Atoms::messages{cannot_write} . " " . $outfile . $/;
100 print INP $contents;
101 close INP;
102
103
104 ## =============================== finish up
105 ($opt{q}) or print STDOUT $screen_line, $/, $/;
106 1;
107
108
109 =head1 NAME
110
111 Template - make an empty feff.inp template
112
113 =head1 SYNOPSIS
114
115 template [-678q] [-o file]
116
117 =head1 DESCRIPTION
118
119 This simple program writes an empty template for an input file for
120 feff6, feff7, or feff8. This is useful in a situation where you need
121 a good feff.inp file for a material that is not a crystal and so you
122 need to fill in atom coordinates by hand.
123
124 command line options
125 -6, -7 feff6/feff7 input file
126 -8 feff8 input file
127 -q suppress screen messages
128 -h print this help message
129 -o * write template to the specified file name
130
131 =head1 AUTHOR
132
133 Bruce Ravel, [email protected]
134 http://feff.phys.washington.edu/~ravel