Jump to content

Mod:Hunt Research Group/statis2xmgr

From ChemWiki
#!/bin/sh

if test $1
then
  if test -e ./STATIS
  then

  tmpfile=stat2dl
  columns=$(echo $*)
  /usr/bin/awk -v columns=$columns 'BEGIN{\
split(columns, col, ",");\
getline;\
getline\
}\
{\
###########################################################################\
# Write the number of the column you want ($1 -> steps, $2 -> time (ps) )\ 
t=$2;\
###########################################################################\
nelem=$3;\
nelem_r=int(nelem/5+0.999);\
n=0;\
for (i=1;i<=nelem_r;i++) {\
    getline;\
    if($0 ~ /[A-DF-Za-df-z]/) { print "Warning: There is something wrong in the file STATIS" ; print$0}\
    for(j=1;j<=NF;j++) {\
      n=n+1;\
      data[n]=$j;\
    }\
}\
printf(" "t);\
for (i in col) {\
    printf("\t"data[col[i]])\
}\
printf("\n");\
}' ./STATIS > $tmpfile

  xmgrace -nxy $tmpfile
  cp $tmpfile ./
# rm -f $tmpfile
  exit

  else

    echo "ERROR: STATIS file does not exits"
    exit
  fi

else

   echo "Usage: statis2xmgr [column_list]"
   echo "This program extracts the specified column numbers from the"
   echo "dl_poly file STATIS and plots them against time in xmgr."
   echo "The column_list must be a list of integers separated by a comma."
   echo
   echo "Column correspondence:"
echo " 1) eng_tot    2) temp        3) eng_cfg   4) eng_vdw   5) eng_coulomb "
echo " 6) eng_bond   7) eng_angl    8) eng_dih   9) eng_teth 10) enthalpy "
echo "11) temp_rot  12) virial     13) vir_vdw  14) vir_cou  15) vir_bnd"
echo "16) vir_ang   17) vir_con    18) vir_tet  19) volume   20) temp_shl" 
echo "21) eng_shl   22) vir_shl    23) alpha    24) beta     25) gamma "  
echo "26) vir_pmf   27) press"
echo "next ntpatm entries: mean sq. displ. of each atom type"
echo "next ntpmls entries: mean sq. displ. of each molecule type (dcubero)"
echo "next 9 entries:      all the components of stress tensor"
echo "next 9 entries: (only with NPT sim.) components of the cell vectors"
   exit
fi