This file is indexed.

/usr/share/xcrysden/scripts/pwo2xsf.sh is in xcrysden-data 1.5.60-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
#!/bin/sh
#############################################################################
# Author:                                                                   #
# ------                                                                    #
#  Anton Kokalj                                  Email: Tone.Kokalj@ijs.si  #
#  Department of Physical and Organic Chemistry  Phone: x 386 1 477 3523    #
#  Jozef Stefan Institute                          Fax: x 386 1 477 3811    #
#  Jamova 39, SI-1000 Ljubljana                                             #
#  SLOVENIA                                                                 #
#                                                                           #
# Source: $XCRYSDEN_TOPDIR/scripts/pwo2xsf.sh
# ------                                                                    #
# Copyright (c) 1996-2003 by Anton Kokalj                                   #
#############################################################################

# set locales to C
LANG=C 
LC_ALL=C
export LANG LC_ALL

#
# Purpose: PWscf(v2.0 or latter)-output--to--XSF conversion
# Usage:   pwo2xsf [options] pw-output-file
#
# Written by Tone Kokalj on Mon Feb  9 12:48:10 CET 2004
#            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

cat > pwo2xsfUsage.$$ <<EOF

 Usage: pwo2xsf.sh [-r dim] options [pw-output-file]

 If file is not specified then stadard input is read.

  -r dim 
     Reduce periodic dimension to dim, where dim = 2, 1, or 0.
 
 OPTIONS are:

  --inicoor|-ic [pw-output-file]
     Extract the initial (i.e. input) ionic coordinates.

  --latestcoor|-lc [pw-output-file]
     Extract the latest printed ionic coordinates from pw.x output file.

  --optcoor|-oc [pw-output-file]
     Similar to "--latestcoor" but extracts just the optimized coordinates
     if present or else nothing.

  --animxsf|-a [pw-output-file1] ...
     Extract the coordinates of all ionic steps as Animated-XSF.

  --nebcoor|-nc [PW.out]
     Extract the coordinates and forces from the \fBPW.out\fR file of NEB
     (path) calculation.

EOF


# ------------------------------------------------------------------------
# Utility functions
# ------------------------------------------------------------------------
CleanTmpFiles() {
    if test -f pwo2xsfUsage.$$ ; then rm -f pwo2xsfUsage.$$; fi
    if test -f xsf.$$ ; then rm -f xsf.$$; fi
    if test -f pw.$$ ; then rm -f pw.$$; fi
}
pwoExit() {
    # Usage: $0 exit_status
    CleanTmpFiles
    exit $1
}
pwoUsage() {
    if test $1 ; then
	echo "
Usage: $2
"
	pwoExit 1
    fi
}
pwoGetVersion() {
    grep 'Program PWSCF' $1 | tail -1 | awk '
      {  ver=$3; n=split(ver,v,"."); 
         ii=0; for(i=1; i<=n; i++) if ( v[i] ~ /[0-9]+/ ) vv[ii++]=v[i];  
         if (ii>2) printf "%d.%d%d\n", vv[0],vv[1],vv[2];
         else printf "%d.%d\n", vv[0], vv[1];
      }'
}
pwoCheckPWSCFVersion() {
    #
    # Usage: $0 option file
    #
    # Purpose: if PWSCF version < 1.3 execute the old pwo2xsf_old.sh
    #          script and exit
    version=`pwoGetVersion $input`
    result=`echo "$version < 1.3"|bc -l`
    if test x"$result" = x1 ; then
	if test -f $scriptdir/pwo2xsf_old.sh ; then
    	   # execute pwo2xsf_old.sh
	    $scriptdir/pwo2xsf_old.sh $1 $2
	    pwoExit $?
	else
	    echo "ERROR: PWscf output generated by version < 1.3 !!!"
	    pwoExit 1
	fi
    fi
}


# ------------------------------------------------------------------------
# Function: pwoOptCoor
# Extract:  OPTIMIZED or LATEST coordinates
# Perform:  read PW-output file and print the XSF file according to
#           specified flags
# ------------------------------------------------------------------------
pwoOptCoor() {
    #set -x
    pwoUsage "$# -lt 1" \
	"$0 --latestcoor|-lc [pw-output-file]   or   $0 --optcoor|-oc [pw-output-file]"
    
    option=$1
    case $1 in
	--latestcoor|-lc) type=LATEST;    shift;;
	--optcoor|-oc)    type=OPTIMIZED; shift;;
    esac
    
    if test $# -eq 0 ; then
	input=pw.$$
	cat - >> $input
    else
	input=$1
    fi
    
    pwoCheckPWSCFVersion $option $input

    if test $type = "OPTIMIZED" ; then
	# Check for the presence of "Begin final coordinates"
	# and/or:
	# Check also for the PWSCF-v.1.3.0 which uses the
	# "Final estimate of positions" record
	if test \( "`grep \"Begin final coordinates\" $input`" = "" \) -a \( "`grep 'Final estimate of positions' $input`" = "" \) ; then
	    echo "ERROR: OPTIMIZED coordinates does not exists"
	    pwoExit 1
	fi
    fi

    cat "$input" | awk -v t=$type -v dimen=$dim -f $scriptdir/pwo2xsf_opt.awk
}


# ------------------------------------------------------------------------
# Function: pwoAnimCoor
# Extract:  INITIAL or ALL coordinates
# Perform:  read PW-output file and print the XSF file according to
#           specified flags
# ------------------------------------------------------------------------

pwoAnimCoor() {
    #set -x
    pwoUsage "$# -lt 1" "$0 --animcoor|-ac|--animxsf|-a [pw-output-file1] or   $0 --inicoor|-ic [pw-output-file]"
    
    option=$1
    only_init=0
    case $1 in
	--inicoor|-ic) only_init=1; shift;;
	--animcoor|-ac|--animxsf|-a) only_init=0; shift;;
    esac

    if test $# -eq 0 ; then
	input=pw.$$
	cat - >> $input
    else
	input=$1
    fi

    pwoCheckPWSCFVersion $option $input

    ncoor=`egrep "ATOMIC_POSITIONS" $input | wc | awk '{print $1}'`
    ncoor=`expr $ncoor + 1`; # add another step for initial coordinates
    nvec=`egrep "CELL_PARAMETERS" $input | wc | awk '{print $1}'`
    
    cat "$input" | awk \
	-v ncoor=$ncoor \
	-v nvec=$nvec \
	-v dimen=$dim \
	-v onlyinit=$only_init -f $scriptdir/pwo2xsf_anim.awk > xsf.$$

    if test $only_init -eq 0 ; then
    # Assign the number of ANIMSTEPS here. The reason is that the
    # output file (queue runs) is the result of several job runs, then
    # some of them might be terminated on the "wrong" place, and the
    # initial ANIMSTEPS might be wrong. The most secure way is to extract the 
    # sequential digit from the last "PRIMCOORD id" record.
	#set -x
	nsteps=`grep PRIMCOORD xsf.$$ | wc | awk '{print $1}'`    
	echo "ANIMSTEPS $nsteps" 
    fi
    cat xsf.$$
}


# ------------------------------------------------------------------------
# Function: pwoNebCoor
# Extract:  all coordinates and forces found in PW.out file
# ------------------------------------------------------------------------

pwoNebCoor() {
    #set -x
    pwoUsage "$# -lt 1" "$0 --nebcoor|-nc [PW.out]"
    
    option=$1; shift

    if test $# -eq 0 ; then
	input=pw.$$
	cat - >> $input
    else
	input=$1
    fi

    cat "$input" | awk \
	-v dimen=$dim \
	-f $scriptdir/pwo2xsf_neb.awk > xsf.$$

    # Assign the number of ANIMSTEPS here. The reason is that the
    # output file (queue runs) is the result of several job runs, then
    # some of them might be terminated on the "wrong" place, and the
    # initial ANIMSTEPS might be wrong. The most secure way is to extract the 
    # sequential digit from the last "PRIMCOORD id" record.
	#set -x
    nsteps=`grep PRIMCOORD xsf.$$ | wc | awk '{print $1}'`    
    echo "ANIMSTEPS $nsteps" 
    
    cat xsf.$$
}


#######################################################################
####                              MAIN                              ###
#######################################################################

if test "x`type readlink`" = "x"; then
    # no readlink cmd; make a function-substitute
    readlink() {
	echo `ls -l $1 | awk '{print $1}'`
    }
fi

pathname() {
    file=`type -p $1`
    if test $? -gt 0; then
	file=`which $1`
	if test $? -gt 0; then
	    # give-up
	    file=$1
	fi
    fi
    echo $file
}

pathdir() {
    file=`pathname $1`
    
    while test -h $file; do  
	file=`readlink $file`
    done

    dir=`dirname $file`
    ( cd $dir; pwd )
}

if test -z $XCRYSDEN_TOPDIR; then
    # XCRYSDEN_TOPDIR does not exists, guess it from the process
    scriptdir=`pathdir $0`
    export XCRYSDEN_TOPDIR=`(cd $scriptdir/..; pwd)`
else
    scriptdir=$XCRYSDEN_TOPDIR/scripts
fi


AWK=`type awk`
if test "$AWK" = ""; then 
    echo "ERROR: awk program not found"
    pwoExit 1
fi


if [ $# -eq 0 ]; then
    cat pwo2xsfUsage.$$
    pwoExit 1
fi

dim=3
if test $1 = "-r"; then
    dim=$2;
    shift 2
fi

case $1 in
    --inicoor|-ic)               pwoAnimCoor $@;;
    --latestcoor|-lc)            pwoOptCoor $@;;
    --optcoor|-oc)               pwoOptCoor $@;;
    --animcoor|-ac|--animxsf|-a) pwoAnimCoor $@;;    
    --nebcoor|-nc)               pwoNebCoor $@;;
    --help|-h)                   cat pwo2xsfUsage.$$;;
    *)                           cat pwo2xsfUsage.$$; pwoExit 1;;
esac

pwoExit 0