[Wien] Spin-Orbit compatibility - problem in WIEN2k_14

Peter Blaha pblaha at theochem.tuwien.ac.at
Fri Sep 19 11:49:49 CEST 2014


Hi,

Yes, now I can verify the problem:

In a "real" case (case.in1, not case.in1c) after running

x lapw2 -so -qtl

the file case.in2c was not set back to "TOT, but the switch QTL was 
kept, which would cause a failure of subsequent scf calculations.

The problem does not happen when you have no inversion symmetry anyway 
(case.in1c).

The problem is present since WIEN2k_11 !!! so apparently nobody 
continued ever after a first   x lapw2 -qtl -so   with another scf cycle.

Fix:   AFTER    x lapw2 -so -qtl   edit case.in2c and set TOT instead of 
QTL.

Alternatively replace  in $WIENROOT  x_lapw with the attached file 
(only for version 14.1 users !!!)


Thanks for the report and the analysis, which makes it then easy to fix it.


On 09/18/2014 03:52 PM, Fecher, Gerhard wrote:
> Hallo Peter and Gavin
>
> I found the problem
>
> After calculating the DOS, x lapw2 -so -qtl
> the file case.in2c contains QTL instead of TOT
>
> It appears only for centro symmetric systems (not a complex calculations) with SO (also for spin polarized cases)
> In all other cases case.in2 or case.in2c stay unchanged
> case.in2c stays also unchanged if calculating the band structure ( x lapw2 -so -band -qtl)
>
> It did not appear before Feb 2011 but may be for all later versions, for sure in 13.1 (I checked this one).
>
>
> Ciao
> Gerhard
>
> DEEP THOUGHT in D. Adams; Hitchhikers Guide to the Galaxy:
> "I think the problem, to be quite honest with you,
> is that you have never actually known what the question is."
>
> ====================================
> Dr. Gerhard H. Fecher
> Institut of Inorganic and Analytical Chemistry
> Johannes Gutenberg - University
> 55099 Mainz
> and
> Max Planck Institute for Chemical Physics of Solids
> 01187 Dresden
> ________________________________________
> Von: wien-bounces at zeus.theochem.tuwien.ac.at [wien-bounces at zeus.theochem.tuwien.ac.at]" im Auftrag von "Fecher, Gerhard [fecher at uni-mainz.de]
> Gesendet: Mittwoch, 17. September 2014 18:40
> An: A Mailing list for WIEN2k users
> Betreff: Re: [Wien] Spin-Orbit compatibility -  problem  in WIEN2k_14
>
> Hi Peter,
> I checked, it happens after I was calculating the DOS.
>
> when I run a new scf cycle after I was calculating the DOS, the error appears (only running x lapw2 -qtl -so and x tetra)
> I checked, before the DOS there was no ghostband, however in the new scf2 file after the crash there is a ghostband announced.
>
> If I restore the calculation (with overwriting of the files) after calculation of the DOS, then everything is fine again and the scf cycle runs smooth.
>
> I don't remeber that I had the same problem with older Versions.
>
> I will do some more tests if needed.
>
> Ciao
> Gerhard
>
> DEEP THOUGHT in D. Adams; Hitchhikers Guide to the Galaxy:
> "I think the problem, to be quite honest with you,
> is that you have never actually known what the question is."
>
> ====================================
> Dr. Gerhard H. Fecher
> Institut of Inorganic and Analytical Chemistry
> Johannes Gutenberg - University
> 55099 Mainz
> ________________________________________
> Von: wien-bounces at zeus.theochem.tuwien.ac.at [wien-bounces at zeus.theochem.tuwien.ac.at]" im Auftrag von "Peter Blaha [pblaha at theochem.tuwien.ac.at]
> Gesendet: Mittwoch, 17. September 2014 14:33
> An: A Mailing list for WIEN2k users
> Betreff: Re: [Wien] Spin-Orbit compatibility -  problem  in WIEN2k_14
>
> Hi,
>
> Hard to answer this, as I cannot really reproduce it.
>
> lapw2 has got some modifications in case of SO   AND   the -qtl switch
> (or when ghostbands appear and outp.f is called).
>
> It could be that your case is such that you have qtl-b warnings ??
>
> on unit 1001 the partial charges of the 1st atoms should be written.
> unit 31 should not be used anymore.
> But maybe there is a certain situation where problems can happen, but as
> you said, starting with wien2k_14 from the beginning, the error cannot
> be reproduced.
>
> --------------------
> Similar with your second report, since I cannot reproduce it nor know
> any details, it is hard to comment on it. For sure, the format of the
> case.scf file has been changed in a few places which could eventually
> cause problems for certain tools.
>
> It is for instance clear, that the "analysis" in w2web (or the
> "scfmonitor" on the command line) will not work properly with "old"
> scf-files.
>
>
> Am 17.09.2014 10:10, schrieb Fecher, Gerhard:
>> Hallo Peter,
>> it is me again,
>>
>> The following error appears when I run a spin orbit calculation (not spin polarized, simple fcc Pt)  for an old case that was already converged using Wien2k_11 or _13:
>>
>> LAPWSO END
>> forrtl: severe (24): end-of-file during read, unit 1001, file /home/fecher/Bands_Work/Wien2k/test/Pt_SO_aopt/031
>>
>> that causes
>>
>> error: command   /home/fecher/FortranWork/Wien2k/lapw2c lapw2.def   failed
>>>     lapw2    -c -so   (09:42:41) 2.284u 0.112s 0:00.91 262.6% 0+0k 0+1032io 0pf+0w
>>
>> the error persists when I re-initialize (batch mode) the calculation including initso afterwards.
>>
>> The error does NOT appear when I start with Wien2k_14 in a new directory from scratch.
>>
>> the def file contains
>> 231,'Pt_SO_aopt.dmftsym',   'unknown',    'formatted',0
>>
>> but not a unit 1001 or a file 031  ( an empty file with name 31 is created).
>>
>> I had a similar compatibility issue with mixer
>> when I prepare a phonon calculation with Wien2k_14, it does not run with Wien2k_13
>> it seems also that some files have been renamed or LUs have been changed between the versions.
>>
>> Ciao
>> Gerhard
>>
>> DEEP THOUGHT in D. Adams; Hitchhikers Guide to the Galaxy:
>> "I think the problem, to be quite honest with you,
>> is that you have never actually known what the question is."
>>
>> ====================================
>> Dr. Gerhard H. Fecher
>> Institut of Inorganic and Analytical Chemistry
>> Johannes Gutenberg - University
>> 55099 Mainz
>> ________________________________________
>> Von: wien-bounces at zeus.theochem.tuwien.ac.at [wien-bounces at zeus.theochem.tuwien.ac.at]" im Auftrag von "Peter Blaha [pblaha at theochem.tuwien.ac.at]
>> Gesendet: Montag, 8. September 2014 15:12
>> An: A Mailing list for WIEN2k users
>> Betreff: [Wien] WIEN2k_14
>>
>> Dear wien2k users,
>>
>> After quite some struggle a new version, WIEN2k_14.1, has been released.
>>
>> It contains among others:
>>
>> - new versions of
>>         lapwso mpi-version, bug fixes),
>>         lapw0 (major changes and fixes, new XC-specification)
>>         lapw5  (new STM-mode)
>>         nmr
>>         w2web interface (batch-initialization as default, updated
>>              scf-switches, more optional steps in various "tasks".
>>         and many others
>> -new packages:
>>         wien2wannier,
>>         BerryPI,
>>         IRelast
>> -many new options and features:
>>         run(sp)_lapw  -dftd3 -min
>>         save_lapw (saves now by default also input files)
>>         init_mbj (varios parametrizations), better scf-convergence of mBJ
>>
>> For a more detailed list of changes see:
>>                      http://www.wien2k.at/reg_user/updates/
>>
>> I strongly recommend to update.
>>
>> Please report any problems via the mailing list and I'll update quickly
>> if I can confirm the problem.
>>
>> --
>>
>>                                          P.Blaha
>> --------------------------------------------------------------------------
>> Peter BLAHA, Inst.f. Materials Chemistry, TU Vienna, A-1060 Vienna
>> Phone: +43-1-58801-165300             FAX: +43-1-58801-165982
>> Email: blaha at theochem.tuwien.ac.at    WWW:
>> http://info.tuwien.ac.at/theochem/
>> --------------------------------------------------------------------------
>> _______________________________________________
>> Wien mailing list
>> Wien at zeus.theochem.tuwien.ac.at
>> http://zeus.theochem.tuwien.ac.at/mailman/listinfo/wien
>> SEARCH the MAILING-LIST at:  http://www.mail-archive.com/wien@zeus.theochem.tuwien.ac.at/index.html
>> _______________________________________________
>> Wien mailing list
>> Wien at zeus.theochem.tuwien.ac.at
>> http://zeus.theochem.tuwien.ac.at/mailman/listinfo/wien
>> SEARCH the MAILING-LIST at:  http://www.mail-archive.com/wien@zeus.theochem.tuwien.ac.at/index.html
>>
>
> --
> Peter Blaha
> Inst.Materials Chemistry
> TU Vienna
> Getreidemarkt 9
> A-1060 Vienna
> Austria
> +43-1-5880115671
> _______________________________________________
> Wien mailing list
> Wien at zeus.theochem.tuwien.ac.at
> http://zeus.theochem.tuwien.ac.at/mailman/listinfo/wien
> SEARCH the MAILING-LIST at:  http://www.mail-archive.com/wien@zeus.theochem.tuwien.ac.at/index.html
> _______________________________________________
> Wien mailing list
> Wien at zeus.theochem.tuwien.ac.at
> http://zeus.theochem.tuwien.ac.at/mailman/listinfo/wien
> SEARCH the MAILING-LIST at:  http://www.mail-archive.com/wien@zeus.theochem.tuwien.ac.at/index.html
> _______________________________________________
> Wien mailing list
> Wien at zeus.theochem.tuwien.ac.at
> http://zeus.theochem.tuwien.ac.at/mailman/listinfo/wien
> SEARCH the MAILING-LIST at:  http://www.mail-archive.com/wien@zeus.theochem.tuwien.ac.at/index.html
>

-- 

                                       P.Blaha
--------------------------------------------------------------------------
Peter BLAHA, Inst.f. Materials Chemistry, TU Vienna, A-1060 Vienna
Phone: +43-1-58801-165300             FAX: +43-1-58801-165982
Email: blaha at theochem.tuwien.ac.at    WWW: 
http://info.tuwien.ac.at/theochem/
--------------------------------------------------------------------------
-------------- next part --------------
#!/bin/csh -f
unalias rm

set running = ".running.$$.`hostname`.`date +%d%m%H%M%S`"
echo $$ >$running
onintr clear
alias error	'echo ">>> ($name) \!* -> exit"; goto error'

set name	= $0		#full name of script-file
set bin		= $name:h	#default directory for WIEN-executables
if !(-d $bin) set bin = .
set name	= $name:t

set def 	= def		#def-file
set tmp		= ( )		#tmp-files, to be deleted before exit
set log		= :log		#log-file
set t		= time		#
set updn			# spinpolarization switch
set dnup	= 'dn'		# spinpolarization switch
set spin=1                      # for -it in lapw1
#set ne_it=1.1                   # for -it in lapw1
set emin=-999.0                 # for -emin XX   in lapw2
set emax=999.0                  # for -all XX YY in lapw2
set settol=0.00001              # tol parameter for sgroup
set wf=0                        # wplot: WF to plot (0 = read from file)
set sc				# semicore-switch
set so				# spinorbit-switch
set sodum			# spinorbit-switch
#set cmplx
set cmplx1
set cmplx2
set para                        # parallel execution 
set dopara                        # parallel execution 
set sel                         # standard vector file in lapw7
set band1                       # regular run in lapw1
set eece                       
set grr
set lcore                       
set hf
set diaghf
set nonself
set noibz
set newklist
set redklist
set nmrhf
set gw
set dftd3
set ending
set ending3
unset enefile
unset orb                      # LDA+U in lapw1
unset nmat_only                 # determines matrixsize in lapw1
unset iter                      # iterative diagonalization
unset nohns                     # without HNS in lapw1
unset qtl                       # regular run in lapw2
unset alm                       # writes alm in lapw2
unset almd                       # charge calculation from dmft densmat in lapw2
unset qdmft                     # charge calculation from dmft densmat in lapw2
unset sigma                      # regular run in lstart
unset band                       # regular run in lapw2
unset fermi                     # regular run in lapw2
unset efg                       # regular run in lapw2
unset emin1                       # regular run in lapw2
unset emax1                     # regular run in lapw2
unset command			#command
unset file			#file-head
unset deffile_only		#create just def file
unset fftstop			#for dstart	
unset vresp			#for lapw2
unset help_files 		#for lapw2
unset super                     # for dstart, creates new.clmsum
unset rxes                      # for tetra, uses rxes-weight file
unset rxesw                     # for tetra, writes rxes-weight file
unset delta
unset copy
unset txt                       
set readHinv
unset writeHinv                  
unset in1orig
unset fbz                       # for kgen, generates full BZ mesh
unset make_inq                  # for qtl, construct case.inq from case.innes
unset Rsum                      #for RMTCheck
unset nmr
unset writehs
unset efermi
set scratch =                   #eg: /scr1/pblaha/   for vectors, help-files,
set scratchstring =

if ( $?SCRATCH && $SCRATCH != '') then
  set scratch=`echo $SCRATCH  | sed -e 's/\/$//'`/ # we are afraid
				# different settings in different 
				# computing centers
			        #use global variable for scratch if set
endif
set argv1=($argv)

while ($#argv)
  switch ($1)
  case -f:
    shift; set file = $1
    shift; breaksw
  case -h:
  case -H: 
    set help
    shift; breaksw
  case -[t|T]:
    set t
    shift; breaksw
  case -up:
    set spin=2
    set updn = 'up'
    set dnup = 'dn'
    shift; breaksw
  case -dn:
    set spin=2
    set updn = 'dn'
    set dnup = 'up'
    shift; breaksw
  case -du:
    set du = 'du'
    set updn = 'up'
    shift; breaksw
  case -sc:
    set sc = 's'
    shift; breaksw
  case -d:
    set deffile_only
    shift; breaksw
  case -fft:
    set fftstop
    shift; breaksw
  case -c:
    set cmplx = c
    set cmplx2='-c'
    shift; breaksw
  case -[p|P]
    set para = para
    shift; breaksw
  case -it:
    set iter
    shift; breaksw	
  case -noHinv:
    set iter
    unset readHinv                  
    shift; breaksw	
  case -noHinv0:
    set iter
    unset readHinv
    set writeHinv                  
    shift; breaksw	
#  case -ne_it:
#    shift;set ne_it=$1
#    shift; breaksw  
  case -emin:
    shift;set emin=$1;set emin1
    set testreal=`echo $emin | grep "\." `
    if($#testreal == 0) set emin=${emin}.
    shift; breaksw  
  case -emax:
    shift;set emax=$1;set emax1
    shift; breaksw  
  case -all:
    shift;set emin=$1;set emin1
    set testreal=`echo $emin | grep "\." `
    if($#testreal == 0) set emin=${emin}.
    shift;set emax=$1;set emax1
    set testreal=`echo $emax | grep "\." `
    if($#testreal == 0) set emax=${emax}.
    shift; breaksw  
  case -help_files:
    set help_files
    shift; breaksw	
  case -vresp:
    set vresp
    shift; breaksw	
  case -eece:
    set eece=eece
    shift; breaksw	
  case -grr:
    set grr=grr
    shift; breaksw	
  case -orb:
    set orb
    shift; breaksw	
  case -nmat_only:
    set nmat_only
    shift; breaksw	
  case -nohns:
    set nohns
    shift; breaksw	
  case -enefile:
    set enefile
    shift; breaksw	
  case -rxes:
    set rxes
    shift; breaksw	
  case -rxesw:
    set rxesw
    shift;set rxese1 = $1
    shift;set rxese2 = $1
    shift; breaksw	
  case -so:
    set so = 'so'
    set sodum = 'dum'
    set cmplx = c
    set cmplx2='-c'
    shift; breaksw
  case -in1orig:
    set in1orig
    shift; breaksw
  case -band:
    set band
    set band1='_band'
    shift; breaksw
  case -qtl:
    set help_files
    set qtl
    shift; breaksw
  case -alm:
    set alm
    shift; breaksw
  case -almd:
    set almd
    shift; breaksw
  case -qdmft:
# ??    set help_files
    set qdmft
    shift; breaksw
  case -fbz:
    set fbz
    shift; breaksw
  case -sigma:
    set sigma
    shift; breaksw
  case -efg:
    set efg
    shift; breaksw
  case -hf:
    set hf = 'hf'
    shift; breaksw
  case -diaghf:
    set diaghf = 'diaghf'
    shift; breaksw
  case -nonself:
    set nonself = 'nonself'
    shift; breaksw
  case -noibz:
    set noibz = 'noibz'
    shift; breaksw
  case -newklist:
    set newklist = 'newklist'
    shift; breaksw
  case -redklist:
    set redklist = 'redklist'
    shift; breaksw
  case -nmrhf:
    set nmrhf = 'nmrhf'
    shift; breaksw
  case -gw:
    set gw = 'gw'
    shift; breaksw
  case -dftd3:
    set dftd3 = 'dftd3'
    shift; breaksw
  case -sel:
    set sel = f
    shift; breaksw
  case -fermi:
    set fermi
    shift; breaksw  
  case -super:
    set super
    shift; breaksw  
  case -settol:
    shift;set settol = $1
    shift; breaksw  
  case -delta:
    set delta
    shift; breaksw  
  case -lcore:
    set lcore=lcore
    shift; breaksw  
  case -copy:
    set copy
    shift; breaksw  
  case -telnes:             #Kevin Jorissen
    set make_inq
    shift; breaksw
  case -nmr:
    set nmr
    shift; breaksw
   case -writehs:     
    set writehs 
    shift; breaksw     
  case -sum
    set Rsum
    shift; breaksw      
  case -txt
    set txt
    shift; breaksw      
  case -scratch:
    shift;set scratch = $1
    set ncar=`echo $scratch |wc -m`
    @ ncar --
    set lcar=`echo $scratch | cut -c$ncar`
    if("$lcar" != '/' ) set scratch=`echo "${scratch}/"`
    set scratchstring="-scratch $scratch"
    if ( "$scratch" == "./" ) then
        set scratch=
        set scratchstring=
    else if(! -e "$scratch" ) then
        makescratch_lapw $scratch
    endif
    shift; breaksw  
## w2w stuff ##
  case -pp:			# passed on to Wannier90
    shift; breaksw
  case -wf:
    shift; set wf = $1
    shift; breaksw
  case -efermi:
    shift; set efermi = $1
    shift; breaksw
## w2w end ##
  default:
    set optiontest = `echo $1|cut -c1`
    if ( "$optiontest" == '-' ) then
        echo "error in your arguments:  $1   is not a valid option"
        exit(3)
    endif
    set command = $1
##    if($command == 'join_vectorfiles') goto continue
    shift; breaksw
  endsw
end

continue:

if !($?file) then 
set file    = `pwd`
set file    = $file:t		#tail of file-names
endif

touch $file.struct
set cmplx1=`cut -b -6 $file.struct |awk 'BEGIN{c="c"};{if ($0 == "-1 0 0") {getline; {if ($0 == " 0-1 0"){getline; {if ($0 == " 0 0-1"){c= ""}}}}}};END{print c}'` 
if !($?cmplx) then
  set cmplx=$cmplx1
  if($cmplx == c ) set cmplx2='-c'
endif


if ( $?help ) goto help

if !($?command) then
  error no command
endif

if ($command == lapw1c) then
  set cmplx = c
  set command = lapw1
else if ($command == lapw1it) then
  set iter
  set command = lapw1
else if ($command == lapw1itc) then
  set cmplx = c
  set iter
  set command = lapw1
else if ($command == lapw2c) then
  set cmplx = c
  set command = lapw2
else if ($command == hfc) then
  set cmplx = c
  set command = hf
else if ($command == lapwdmc) then
  set cmplx = c
  set command = lapwdm
else if ($command == dmatc) then
  set cmplx = c
  set command = dmat
else if ($command == filtvecc) then
  set cmplx = c
  set command = filtvec
else if ($command == lapw7c) then
  set cmplx = c
  set command = lapw7
else if ($command == lapw5c) then
  set cmplx = c
  set command = lapw5
else if ($command == spinorbitc) then
  set cmplx = c
  set command = spinorbit
else if ($command == opticc) then
  set cmplx = c
  set command = optic
#Clas-start     
else if ($command == lapwkpc) then
   set cmplx = c  
   set command = lapwkp         
 #Clas-end      
else if ($command == w2wc) then
  set cmplx = c
  set command = w2w
endif
else if ($command == wplotc) then
  set cmplx = c
  set command = wplot
endif

#echo "`date`> ($name) $command $argv1[2-]" >> $log
echo "`date`> ($name) $argv1" >> $log

set def	= $updn$command$sc.def
#touch $def

switch ($command)


##case join_vectorfiles:
##set exe=($argv1)
##set def=
##if($#argv1 < 3) goto help
##breaksw

case lcore:
set exe = lcore
cat << theend > $def
 5,'$file.inc',         'old',    'formatted',0
 6,'$file.outputc$updn','unknown','formatted',0
 8,'$file.vsp$updn',    'old',    'formatted',0
 9,'$file.clmcor$updn', 'unknown','formatted',0
19,'$file.vns$updn',    'unknown','formatted',0
20,'$file.struct',      'old',    'formatted',0         
21,'$file.scfc$updn',   'unknown','formatted',0
28,'$file.vrespcor$updn',   'unknown','formatted',0
29,'$file.corewf$updn',   'unknown','formatted',0
83,'$file.rsplcore$updn',   'unknown','formatted',0
theend
breaksw

case dstart:
set exe = dstart$para
set dopara = 1
cat << theend > $def
 6,'$file.outputd$updn','unknown','formatted',0
13,'$file.in0_std','unknown',    'formatted',0
14,'$file.in0','old',    'formatted',0
15,'$file.in2$cmplx',   'old',    'formatted',0
17,'$file.in1$cmplx',   'old',    'formatted',0
16,'$file.test',        'unknown','formatted',0
20,'$file.struct',      'old',    'formatted',0
81,'$file.rsp$lcore$updn',    'old',    'formatted',0
theend
   if ($updn == '') then
     if ($?super) then
       echo " 51,'new_super.clmsum',    'unknown','formatted',0">>$def
     else if ($lcore == 'lcore') then
       echo " 51,'$file.clmsc',    'unknown','formatted',0">>$def
     else
       echo " 51,'$file.clmsum',    'unknown','formatted',0">>$def
     endif
   else
     if ($?super) then
       echo " 51,'new_super.clm$updn',    'unknown','formatted',0">>$def
     else if($lcore == 'lcore') then
       echo " 51,'$file.clmsc$updn',    'unknown','formatted',0">>$def
     else
       echo " 51,'$file.clm$updn',    'unknown','formatted',0">>$def
     endif
   endif
if ($?fftstop) then
echo " 4,'$file.fftstop',  'unknown','formatted',0">>$def
endif
breaksw

case kgen:
set exe = kgen
cat << theend > $def
 8,'$file.klist',     'unknown','formatted',0    
15,'$file.kgen',      'unknown','formatted',0      
66,'$file.outputkgen','unknown','formatted',0
theend
if ( $hf == 'hf' ) echo "10,'$file.outputkgenhf','unknown','formatted',0" >>$def
if ($?fbz) then
  sed "/NUMBER/,$ d " $file.struct > $file.ksym
  echo "  1   NUMBER OF SYMMETRY OPERATIONS" >> $file.ksym
  echo " 1 0 0 0.000000" >> $file.ksym
  echo " 0 1 0 0.000000" >> $file.ksym
  echo " 0 0 1 0.000000" >> $file.ksym
  echo "       1 "       >> $file.ksym
  set so = 'so'
endif
if ($so == so ) then
  if (-e $file.ksym && ! -z $file.ksym) then
    echo "20,'$file.ksym',      'old','formatted',0" >>$def
  else
    echo "$file.ksym not present, using $file.struct because inversion is present"
    echo "20,'$file.struct',    'old','formatted',0" >>$def   
  endif
else
  echo "20,'$file.struct',    'old','formatted',0" >>$def   
endif
breaksw

case lapw0: 
set exe = lapw0$para
set dopara = 1
set tmp = ($file.poissn $file.r2v $file.vcoul)
if (-e $file.clmup &&  ! -z $file.clmup) then
    set updn = 'up'
endif
set endup = 'up'
set endvup = 'up'
if ($eece == 'eece') then
    set endup = 'valupeece'
    set endvup = 'valup'
endif
set enddn = 'dn'
set endvdn = 'dn'
if ($eece == 'eece') then
    set enddn = 'valdneece'
    set endvdn = 'valdn'
endif
set grr2
if ($grr == 'grr') then
    set grr2 = '_grr'
endif
echo "dynamical mixing for mbj from greed of *scfm" >$file.mbjmix
if(-e $file.scfm ) grep :MIX *scfm  >> $file.mbjmix
cat << theend > $def
 3,'$file.rhopw',   'unknown','formatted',0
 4,'$file.inm',     'unknown','formatted',0
 5,'$file.in0$grr2$eece',     'old',    'formatted',0
 6,'$file.output0$grr2', 'unknown','formatted',0
 7,'$file.vorbup',  'unknown','formatted',0
 8,'$file.clmsum',  'old',    'formatted',0
 9,'$file.vtotal$grr2',  'unknown','formatted',0
10,'$file.vcoul$grr2',   'unknown','formatted',0
11,'$file.r2v$grr2',     'unknown','formatted',0
12,'$file.clm$endup',   'unknown','formatted',0
13,'$file.clm$enddn',   'unknown','formatted',0
14,'$file.mbjmix',     'unknown','formatted',0
16,'$file.vsp$grr2$updn','unknown','formatted',0
17,'$file.vsp${grr2}dn',   'unknown','formatted',0
18,'$file.vns$grr2$updn','unknown','formatted',0
19,'$file.vns${grr2}dn',   'unknown','formatted',0
20,'$file.struct',  'old',    'formatted',0         
21,'$file.scf0$grr2',    'unknown','formatted',0
28,'$file.vrespsum','unknown','formatted',0
29,'$file.vresp$endvup', 'unknown','formatted',0
30,'$file.vresp$endvdn', 'unknown','formatted',0
50,'$file.eeceup', 'unknown','formatted',0
51,'$file.eecedn', 'unknown','formatted',0
62,'$file.grr',    'unknown','formatted',0
theend
if ($grr == '') then
  echo "61,'$file.in0abp',     'unknown','formatted',0" >>$def
else if ($grr == 'grr') then
  echo "60,'$file.inhf',   'unknown','formatted',0" >>$def
  echo "61,'$file.in0xy',  'unknown','formatted',0" >>$def
endif

breaksw

case lapw9: 
set exe = lapw9$para
set dopara = 1
set tmp = ($file.poissn $file.r2v $file.vcoul)
if (-e $file.clmup &&  ! -z $file.clmup) then
    set updn = 'up'
endif
set endup = 'up'
set endvup = 'up'
if ($eece == 'eece') then
    set endup = 'valupeece'
    set endvup = 'valup'
endif
set enddn = 'dn'
set endvdn = 'dn'
if ($eece == 'eece') then
    set enddn = 'valdneece'
    set endvdn = 'valdn'
endif
set grr2
if ($grr == 'grr') then
    set grr2 = '_grr'
endif
cat << theend > $def
 3,'$file.rhopw',   'unknown','formatted',0
 4,'$file.inm',     'unknown','formatted',0
 5,'$file.in0$grr2$eece',     'old',    'formatted',0
 6,'$file.output0$grr2', 'unknown','formatted',0
 7,'$file.vorbup',  'unknown','formatted',0
 8,'$file.clmsum',  'old',    'formatted',0
 9,'$file.vtotal$grr2',  'unknown','formatted',0
10,'$file.vcoul$grr2',   'unknown','formatted',0
11,'$file.r2v$grr2',     'unknown','formatted',0
12,'$file.clm$endup',   'unknown','formatted',0
13,'$file.clm$enddn',   'unknown','formatted',0
16,'$file.vsp$grr2$updn','unknown','formatted',0
17,'$file.vsp${grr2}dn',   'unknown','formatted',0
18,'$file.vns$grr2$updn','unknown','formatted',0
19,'$file.vns${grr2}dn',   'unknown','formatted',0
20,'$file.struct',  'old',    'formatted',0         
21,'$file.scf0$grr2',    'unknown','formatted',0
28,'$file.vrespsum','unknown','formatted',0
29,'$file.vresp$endvup', 'unknown','formatted',0
30,'$file.vresp$endvdn', 'unknown','formatted',0
50,'$file.eeceup', 'unknown','formatted',0
51,'$file.eecedn', 'unknown','formatted',0
62,'$file.grr',    'unknown','formatted',0
theend
if ($grr == '') then
  echo "61,'$file.in0abp',     'unknown','formatted',0" >>$def
else if ($grr == 'grr') then
  echo "33,'$file.r2v',   'unknown','formatted',0" >>$def
  echo "60,'$file.inhf',   'unknown','formatted',0" >>$def
  echo "61,'$file.in0xy',  'unknown','formatted',0" >>$def
endif

breaksw


case lapw1:
#if ($?band) then
#  set old="`head -1 $file.in1$cmplx |cut -c1-5`"
#  cp $file.in1$cmplx .oldin1
#  sed "s/UNIT:./UNIT:5/" .oldin1 >$file.in1$cmplx
#endif
set exe = $command$cmplx$para
set dopara = 1
set nmat_string
if ($?nmat_only) set nmat_string='_nmat_only'
#if ($?iter) then
#  set ne=`head -2 $file.in2$cmplx |tail -1 `
#  set ne1=`echo "$ne[2] * $ne_it / $spin + 5 " | bc`
#  echo $ne1 > $file.ne_it
#endif
cat << theend > $def
 4,'$file.klist$sc${band1}',          'unknown','formatted',0
 5,'$file.in1$cmplx$sc',   'old',    'formatted',0
 6,'$file.output1$sc$updn$nmat_string','unknown','formatted',0
10,'${scratch}$file.vector$sc$updn$nmat_string', 'unknown','unformatted',9000
11,'$file.energy$sc$updn$nmat_string', 'unknown','formatted',0
18,'$file.vsp$updn',       'old',    'formatted',0
19,'$file.vns$updn',       'unknown','formatted',0
20,'$file.struct',         'old',    'formatted',0
21,'$file.scf1$sc$updn$nmat_string',   'unknown','formatted',0
55,'$file.vec',            'unknown','formatted',0
71,'$file.nsh$sc$updn$nmat_string',    'unknown','formatted',0
theend
if ($?orb) echo " 7,'$file.vorb$updn'     ,'unknown','formatted',0" >> $def
if ($?nmat_only) echo "72,'$file.nmat_only'     ,'unknown','formatted',0" >> $def
if ($?iter) then
  echo "98,'${scratch}$file.vector$sc$updn.old', 'unknown','unformatted',9000" >> $def
  if($?readHinv) then
    echo "200,'${scratch}$file.storeHinv$sc$updn$nmat_string', 'unknown','unformatted',9000" >> $def
  else
    echo "200,'${scratch}$file.storeHinv$sc$updn$nmat_string', 'replace','unformatted',9000" >> $def
    if($?writeHinv) then
      echo "201,'${scratch}$file.storeHinv$sc$updn$nmat_string', 'unknown','unformatted',9000" >> $def
    endif
  endif
else
  echo "200,'${scratch}$file.storeHinv$sc$updn$nmat_string', 'replace','unformatted',9000" >> $def
endif
if ($?nohns) echo "97,'${scratch}$file.nohns', 'unknown','formatted',9000" >> $def
if ($?writehs) then
   echo "12,'${scratch}$file.ham', 'unknown','unformatted',0" >> $def
endif
if ($?nmr) then
   echo "3,'$file.qvec', 'unknown','formatted',0" >> $def
endif

breaksw

#Clas-start
case lapwkp:
set exe = $command$cmplx
if ($hf == hf) then
  set ending = '_fbz'
endif
cat << theend > $def
3, '$file.inkp',                 'OLD',     'FORMATTED',  0
6, '$file.outputkp$updn',        'UNKNOWN', 'FORMATTED',  0
8, '$file.output1$updn',         'OLD',     'FORMATTED',  0
10,'${scratch}$file.vector$hf$updn','OLD',     'UNFORMATTED',9000
20,'$file.struct',               'OLD',     'FORMATTED',  0
22,'$file.klist$ending',                'UNKNOWN', 'FORMATTED',  0
30,'$file.energy$hf$updn',          'UNKNOWN', 'FORMATTED',  0
40,'$file.pmat$updn',            'OLD',     'FORMATTED',  0
theend
breaksw
#Clas-end


case lapw2:
if ($nmrhf != 'nmrhf') then
  if ( $para == para && $hf == hf ) then
    echo "Parallel lapw2 with HF-option is not allowed. Stop"
    goto error
  endif
endif
rm -f .oldin2 .oldin2a
if ($?band) then
  set old="`head -1 $file.in2$cmplx |cut -c1-5`"
  cp $file.in2$cmplx .oldin2
  sed "3s/^...../ROOT /" .oldin2 >.oldin2t
  sed "1s/^...../QTL  /" .oldin2t >$file.in2$cmplx
  rm .oldin2t
  unset qtl
endif
if ($?qtl) then
  set old="`head -1 $file.in2$cmplx |cut -c1-5`"
  if(! -e .oldin2) cp $file.in2$cmplx .oldin2
  sed "1s/^...../QTL  /" .oldin2 >$file.in2$cmplx
endif
if ($?alm) then
  set old="`head -1 $file.in2$cmplx |cut -c1-5`"
  if(! -e .oldin2) cp $file.in2$cmplx .oldin2
  sed "1s/^...../ALM  /" .oldin2 >$file.in2$cmplx
endif
if ($?almd) then
  set old="`head -1 $file.in2$cmplx |cut -c1-5`"
  if(! -e .oldin2) cp $file.in2$cmplx .oldin2
  sed "1s/^...../ALMD /" .oldin2 >$file.in2$cmplx
endif
if ($?qdmft) then
  set old="`head -1 $file.in2$cmplx |cut -c1-5`"
  if(! -e .oldin2) cp $file.in2$cmplx .oldin2
  sed "1s/^...../QDMFT/" .oldin2 >$file.in2$cmplx
endif
if ($?efg) then
  set old="`head -1 $file.in2$cmplx |cut -c1-5`"
  if(! -e .oldin2) cp $file.in2$cmplx .oldin2
  sed "1s/^...../EFG  /" .oldin2 >$file.in2$cmplx
endif
if ($?fermi) then
  set old="`head -1 $file.in2$cmplx |cut -c1-5`"
  if(! -e .oldin2) cp $file.in2$cmplx .oldin2
  sed "1s/^...../FERMI/" .oldin2 >$file.in2$cmplx
endif
if ($?emin1) then
  set old1=`head -2 $file.in2$cmplx |tail -1`
  if(! -e .oldin2) cp $file.in2$cmplx .oldin2
  cp $file.in2$cmplx .oldin2a
  sed "2s/$old1[1]/$emin/" .oldin2a >$file.in2$cmplx
  if ($?emax1) then
    cp $file.in2$cmplx .oldin2a
    set old2=`head -3 $file.in2$cmplx |tail -1`
    sed "3s/^...../ALL  /" .oldin2a >$file.in2$cmplx
    cp $file.in2$cmplx .oldin2a
    sed "3s/$old2[2]/$emax/" .oldin2a >$file.in2$cmplx
    rm .oldin2a
  endif
endif
#if ($?emin1) then
#  set old1=`head -2 $file.in2$cmplx |tail -1`
#  if(! -e .oldin2) cp $file.in2$cmplx .oldin2
#  sed "2s/$old1[1]/$emin/" .oldin2 >$file.in2$cmplx
#  if ($?emax1) then
#    cp $file.in2$cmplx .oldin2a
#    set old2=`head -3 $file.in2$cmplx |tail -1`
#    sed "3s/^...../ALL  /" .oldin2a >$file.in2$cmplx
#    cp $file.in2$cmplx .oldin2a
#    sed "3s/$old2[2]/$emax/" .oldin2a >$file.in2$cmplx
#    rm .oldin2a
#  endif
#endif
set exe = $command$cmplx$para
set dopara = 1
set ending = 'val'
if ($sc == 's') set ending = 'sc'
if ($hf == hf) then
  if ($nmrhf == 'nmrhf') then
    set ending3 = '_ibz'
  else
    set ending3 = '_fbz'
  endif
endif
if ($sodum != 'dum') then
  set sodum=$dnup
endif
cat << theend > $def
 2,'$file.nsh$sc$updn',    'unknown','formatted',0
 3,'$file.in1$cmplx1$sc',   'unknown','formatted',0
 4,'$file.inso',           'unknown','formatted',0
 5,'$file.in2$cmplx$sc$eece',   'old',    'formatted',0
 6,'$file.output2$sc$hf$updn$eece','unknown','formatted',0
 7,'$file.vorb$updn','unknown','formatted',0
 8,'$file.clm$ending$updn$eece','unknown','formatted',0
10,'${scratch}$file.vector$sc$hf$so$updn', 'unknown','unformatted',9000
11,'$file.weight$sc$hf$updn',    'unknown','formatted',0
13,'$file.recprlist',      'unknown','unformatted',9000
14,'$file.kgen$sc$ending3',        'unknown','formatted',0
15,'$file.tmp$updn',       'unknown','unformatted',0
16,'$file.qtl$updn',       'unknown','formatted',0
17,'$file.weightaver$so$updn','unknown','formatted',0
18,'$file.vsp$updn',       'old',    'formatted',0
19,'$file.vns$updn',       'unknown','formatted',0
20,'$file.struct',         'old',    'formatted',0
21,'$file.scf2$sc$hf$updn','unknown','formatted',0
922,'$file.rotlm',   'unknown',    'formatted',0
23,'$file.radwf$updn',   'unknown',    'formatted',0
26,'$file.weigh$hf$updn',   'unknown','unformatted',0
27,'$file.weigh$hf$dnup',   'unknown','unformatted',0
29,'$file.energy$sc$hf$sodum','unknown','formatted',0
30,'$file.energy$sc$hf$so$updn', 'unknown','formatted',0
32,'$file.qdmft$updn',   'unknown',    'formatted',0
34,'$file.oubwin$updn',   'unknown',    'formatted',0
231,'$file.dmftsym',   'unknown',    'formatted',0
theend
if ($so == so ) echo "12,'$file.norm$sc$so$updn',    'unknown','formatted',0" >>$def
if ($?orb) echo "25,'$file.indm$cmplx',   'old','formatted',0" >>$def
if ($?orb) echo "22,'$file.dmat$updn', 'unknown','formatted',0" >>$def
if ($?vresp) echo "28,'$file.vresp$ending$updn',   'unknown','formatted',0" >>$def
if ($?help_files) echo "31,'${scratch}$file.help$updn', 'unknown','formatted',0" >>$def
if ($?alm)  echo "24,'$file.almblm$hf$updn','unknown',  'formatted',0" >>$def
if ($?almd) echo "24,'$file.almblm$hf$updn','unknown',  'formatted',0" >>$def

breaksw

case lapwso:
set dnup1
if ( $updn == up ) set dnup1=dn
set exe = lapwso$para
set dopara = 1
set def = lapwso.def
cat << theend > $def
4 ,'$file.in1$cmplx$sc',   'old',    'formatted',0   
5 ,'$file.inso', 'old',    'formatted',0
6 ,'$file.outputso',   'unknown','formatted',0
8 ,'$file.scfso',       'unknown','formatted',0
9 ,'${scratch}$file.vector$dnup1',    'old',    'unformatted',9000
10 ,'${scratch}$file.vectorup',    'unknown',    'unformatted',9000
18,'$file.vsp$dnup1',  'old','formatted',0
19,'$file.vspup',  'unknown','formatted',0
20 ,'$file.struct',    'old',    'formatted',0
22,'$file.vns$dnup1',  'old','formatted',0
23,'$file.vnsup',  'unknown','formatted',0
41,'${scratch}$file.vectorsodn',  'unknown','unformatted',9000
42,'${scratch}$file.vectorso$updn',  'unknown','unformatted',9000
44,'$file.vect1',  'unknown','unformatted',9000
45,'$file.normsodn',  'unknown','formatted',0
46,'$file.normsoup',  'unknown','formatted',0
51,'$file.energysodn',  'unknown','formatted',9000
52,'$file.energyso$updn',  'unknown','formatted',9000
53,'$file.energydum',  'unknown','formatted',9000
54,'$file.energy$dnup1',  'old','formatted',9000
55 ,'$file.energyup',    'unknown',    'formatted',9000
theend
if($?orb) echo "11,'$file.vorbdn',  'unknown','formatted',0" >> $def
if($?orb) echo "12,'$file.vorbup',  'unknown','formatted',0" >> $def
if($?orb) echo "13,'$file.vorbdu',  'unknown','formatted',0" >> $def
breaksw

case lapwdm:
set exe = $command$cmplx$para
set dopara = 1
cat << theend > $def
 4,'$file.inso',   'unknown',    'formatted',0
 5,'$file.indm$cmplx',   'old',    'formatted',0
 6,'$file.outputdm$updn','unknown','formatted',0
 7,'$file.dmat$updn','unknown','formatted',0
 8,'$file.dmat$dnup','unknown','formatted',0
 9,'${scratch}$file.vector$sc$hf$so$updn', 'unknown','unformatted',9000
10,'${scratch}$file.vector$sc$hf$so$dnup', 'unknown','unformatted',9000
18,'$file.vsp$updn',       'old',    'formatted',0
19,'$file.vsp$dnup',       'unknown','formatted',0
20,'$file.struct',         'old',    'formatted',0
21,'$file.scfdm$updn',   'unknown','formatted',0
26,'$file.weigh$hf$updn',   'unknown','unformatted',0
50,'$file.energy$sc$hf$so$updn', 'unknown','formatted',9000
51,'$file.energy$sc$hf$so$dnup', 'unknown','formatted',9000
12,'$file.vorb$updn',     'unknown','formatted',0
theend
###14,'$file.kgen$sc',        'unknown','formatted',0
if ($?so) echo "11,'$file.dmatud'     ,'unknown','formatted',0" >> $def
breaksw

case dmftproj:
set exe = $command
set dopara = 1
echo $file  > $def
breaksw

case orb:
set pip
set exe = orb
set updn_old=$updn{_old}
if ( $para == para ) then
    set pip = '_1'
    set para
    endif  
cat << theend > $def
 5,'$file.inorb',         'old',    'formatted',0
 6,'$file.outputorb$updn',   'unknown','formatted',0
 9,'$file.dmat$dnup',      'unknown','formatted',0
10,'$file.dmat$updn',      'unknown','formatted',0
20,'$file.struct',        'old',    'formatted',0
31,'$file.br1orb$updn',    'unknown','unformatted',0
32,'$file.br2orb$updn',    'unknown','unformatted',0
theend
if ($?du) then
cat << theend >> $def
11,'$file.dmatud'     ,'unknown','formatted',0
12,'$file.vorbdu',     'unknown','formatted',0
13,'$file.vorbdu_old',     'unknown','formatted',0
14,'$file.energyup$pip',      'unknown','formatted',0
18,'$file.vspup',       'unknown','formatted',0
21,'$file.scforbdu',      'unknown','formatted',0
theend
else
cat << theend >> $def
12,'$file.vorb$updn',     'unknown','formatted',0
13,'$file.vorb$updn_old',     'unknown','formatted',0
14,'$file.energy$updn$pip',      'unknown','formatted',0
18,'$file.vsp$updn',       'unknown','formatted',0
21,'$file.scforb$updn',      'unknown','formatted',0
50,'$file.eece$updn',    'unknown','formatted',0
theend
endif
breaksw

case hf:
set exe = $command$cmplx$para
set dopara = 1
if (($updn == '') || ($updn == 'up')) then
  set ending1 = 'up'
  set ending2 = ''
else
  set ending1 = 'dn'
  set ending2 = 'dn'
endif
if ($nmrhf == 'nmrhf') then
  set ending3 = '_nmr'
endif
cat << theend > $def
 4,'$file.inhf',                               'old',    'formatted',0
 5,'$file.in0',                                'old',    'formatted',0
 6,'$file.outputhf$updn',                      'unknown','formatted',0
 7,'$file.clmsum',                             'old',    'formatted',0
 8,'$file.clm$ending1',                        'unknown','formatted',0
 9,'$file.in1$cmplx$ending3',                  'old',    'formatted',0
10,'${scratch}$file.vector$sc$so$updn',        'old',    'unformatted',9000
11,'${scratch}$file.vectorhf$sc$so${updn}_old','old',    'unformatted',9000
12,'${scratch}$file.vectorhf$sc$so$updn',      'unknown','unformatted',9000
14,'$file.r2v_grr$ending2',                    'old',    'formatted',0
15,'$file.klist_fbz',                          'old',    'formatted',0
16,'$file.klist_ibz',                          'old',    'formatted',0
17,'$file.outputkgenhf',                       'old',    'formatted',0
19,'$file.clmcor$updn',                        'old',    'formatted',0
20,'$file.struct',                             'old',    'formatted',0
21,'$file.scfhf$updn',                         'unknown','formatted',0
26,'$file.weighhf$updn',                       'old',    'unformatted',0
28,'$file.inc',                                'old',    'formatted',0
29,'$file.corewf$updn',                        'old',    'formatted',0
31,'$file.energyhf$so$updn',                   'unknown','formatted',0
32,'$file.vsp$updn',                           'old',    'formatted',0
33,'$file.vsp${updn}_old',                     'old',    'formatted',0
theend
if ( $band1 == '_band' )                                  echo "40,'$file.klist_band'    ,'unknown','formatted',0" >>$def
if ( $diaghf == 'diaghf' )                                echo "41,'$file.diaghf'        ,'unknown','formatted',0" >>$def
if ( $newklist == 'newklist' )                            echo "42,'$file.klist_fbz_old' ,'unknown','formatted',0" >>$def
if ( $noibz == 'noibz' )                                  echo "43,'$file.noibz'         ,'unknown','formatted',0" >>$def
if ( $nonself == 'nonself' )                              echo "44,'$file.nonself'       ,'unknown','formatted',0" >>$def
if ( $para == 'para' )                                    echo "45,'$file.para'          ,'unknown','formatted',0" >>$def
if ( $redklist == 'redklist' && $newklist != 'newklist' ) echo "46,'$file.klist_rfbz'    ,'unknown','formatted',0" >>$def
if ( $nmrhf == 'nmrhf' )                                  echo "47,'$file.qvec'          ,'unknown','formatted',0" >>$def
if ( $gw == 'gw' )                                        echo "48,'$file.gw$updn'       ,'unknown','formatted',0" >>$def
if ( $redklist == 'redklist' && $newklist == 'newklist' ) echo "49,'$file.klist_rfbz_old','unknown','formatted',0" >>$def
breaksw

case averx:
set exe = averx
set def = averx.def
cat << theend > $def
5 ,'$file.inaverx', 'old',    'formatted',0
6 ,'$file.outputaverx',   'unknown','formatted',0
8 ,'$file.scfaverx',       'unknown','formatted',0
9 ,'${scratch}$file.vectordn',    'old',    'unformatted',9000
10 ,'${scratch}$file.vectorup',    'old',    'unformatted',9000
16,'$file.weightaversoup',  'old','formatted',0
18,'$file.vspdn',  'old','formatted',0
19,'$file.vspup',  'old','formatted',0
20 ,'$file.struct',    'old',    'formatted',0
26,'$file.weightaverdn',  'unknown','formatted',0
27,'$file.weightaverup',  'unknown','formatted',0
41,'${scratch}$file.vectorsodn',  'unknown','unformatted',9000
42,'${scratch}$file.vectorsoup',  'unknown','unformatted',9000
43,'${scratch}$file.vectordum',  'unknown','unformatted',9000
44,'$file.vect1',  'unknown','unformatted',9000
theend
breaksw

case optimize:
set exe = optimize
  touch optimize.job
  chmod +x optimize.job
cat << theend > $def
20,'${file}_initial.struct',      'unknown',    'formatted',0         
16,'optimize.job','unknown','formatted',0
17,'$file.struct',      'old',    'formatted',0         
theend
breaksw

case eosfit:
set exe = eosfit
cat << theend > $def
20,'$file.struct',     'old',    'formatted',0         
55,'$file.vol',        'old',    'formatted',0         
66,'$file.outputeos',     'unknown','formatted',0         
9,'$file.eosfit',     'unknown','formatted',0         
11,'$file.eosfitb',     'unknown','formatted',0         
theend
breaksw

case eosfit6:
set exe = eosfit6
cat << theend > $def
10,'$file.ene',        'old',    'formatted',0         
11,'$file.latparam',        'old',    'formatted',0         
12,'$file.enefit',     'unknown','formatted',0         
66,'$file.outputeos6',     'unknown','formatted',0         
theend
breaksw

case optic:
if ( $para == para && $hf == hf ) then
  echo "Parallel optic with HF-option is not allowed. Stop"
  goto error
endif
set exe = $command$cmplx$para
set dopara = 1
cat << theend > $def
4, '${scratch}$file.mommat2$updn' ,  'UNKNOWN',    'FORMATTED',  0
5, '$file.inop'     ,      'OLD',    'FORMATTED',  0
6, '$file.outputop$updn' ,  'UNKNOWN',    'FORMATTED',  0
3, '${scratch}$file.symmat$updn'   ,  'UNKNOWN',    'FORMATTED',  0
13, '${scratch}$file.symmat1$updn'   ,  'UNKNOWN',    'FORMATTED',  0
14, '${scratch}$file.symmat2$updn'   ,  'UNKNOWN',    'FORMATTED',  0
9, '${scratch}$file.mat_diag$updn' ,  'UNKNOWN',    'FORMATTED',  0
10,'${scratch}$file.vector$sc$hf$so$updn'   ,      'OLD',  'UNFORMATTED',  0
11,'${scratch}$file.vector$sc$hf$so$dnup'  ,   'UNKNOWN'  , 'UNFORMATTED' ,0
18,'$file.vsp$updn'      ,      'OLD',    'FORMATTED',  0
19,'$file.vsp$dnup'     ,    'UNKNOWN' , 'FORMATTED',  0
20,'$file.struct'   ,      'OLD',    'FORMATTED',  0
28,'$file.inso'    ,     'UNKNOWN',    'FORMATTED' , 0
24,'${scratch}$file.mme$updn'       ,  'UNKNOWN',   'FORMATTED', 0
25,'$file.symop'     ,  'UNKNOWN',   'FORMATTED', 0
30,'$file.inc',         'UNKNOWN',    'formatted',0
35,'$file.corewf$updn',   'UNKNOWN','formatted',0
36,'$file.corewf$dnup',   'UNKNOWN','formatted',0
40,'$file.pmat$updn',  'UNKNOWN',   'FORMATTED', 0
theend

breaksw

case nlo_core:
set exe = $command
if ($hf == hf) then
  set ending = '_fbz'
endif
cat << theend > $def
3,'$file.mme$updn',  'OLD',   'FORMATTED', 0
4,'$file.klist$ending'   ,  'OLD','FORMATTED',  0
10,'$file.kgen$ending'   ,  'OLD','FORMATTED',  0
17,'$file.weight$hf$updn','OLD','FORMATTED',  0
20,'$file.meta$updn' ,'UNKNOWN',    'FORMATTED',  0
21,'$file.innlo_core'     ,'OLD',    'FORMATTED',  0
25,'$file.symop'     ,'OLD',   'FORMATTED', 0
theend

breaksw

case nlo_tet:
set exe = $command
cat << theend > $def
4,'$file.klist'   ,  'OLD','FORMATTED',  0
10,'$file.kgen'   ,  'OLD','FORMATTED',  0
17,'$file.innlo_tet',    'OLD','FORMATTED',  0
18,'$file.nlo$updn' ,'UNKNOWN',    'FORMATTED',  0
20,'$file.meta$updn','OLD',    'FORMATTED',  0
theend

breaksw


case joint:
set exe = $command
if ($hf == hf) then
  set ending = '_fbz'
endif
cat << theend > $def
 3,'${scratch}$file.symmat$updn' ,  'OLD','FORMATTED',  0
 4,'$file.weight$hf$updn' ,  'OLD','FORMATTED',  0
 5,'$file.injoint'   ,  'OLD','FORMATTED',  0
 6,'$file.outputjoint$updn',  'UNKNOWN','FORMATTED',  0
 7,'$file.joint$updn'  ,  'UNKNOWN','FORMATTED',  0
 8,'$file.sigma_intra2$updn'  ,  'UNKNOWN','FORMATTED',  0
 9, '${scratch}$file.mat_diag$updn' ,  'UNKNOWN',    'FORMATTED',  0
11,'$file.intra2$updn'  ,  'UNKNOWN','FORMATTED',  0
14,'$file.kgen$ending'   ,  'OLD','FORMATTED',  0
20,'$file.struct' ,  'OLD',    'FORMATTED',  0
23,'${scratch}$file.symmat1$updn' ,  'UNKNOWN','FORMATTED',  0
24,'${scratch}$file.symmat2$updn' ,  'UNKNOWN','FORMATTED',  0
33,'$file.joint1$updn'  ,  'UNKNOWN','FORMATTED',  0
34,'$file.joint2$updn'  ,  'UNKNOWN','FORMATTED',  0
35,'$file.joint1$dnup'  ,  'UNKNOWN','FORMATTED',  0
36,'$file.joint2$dnup'  ,  'UNKNOWN','FORMATTED',  0
40,'$file.xmcd'  ,  'UNKNOWN','FORMATTED',  0
41,'$file.rawxmcd'  ,  'UNKNOWN','FORMATTED',  0
98,'$file.raw1'  ,  'UNKNOWN','FORMATTED',  0
99,'$file.raw2'  ,  'UNKNOWN','FORMATTED',  0
63,'$file.broad1'  ,  'UNKNOWN','FORMATTED',  0
64,'$file.broad2'  ,  'UNKNOWN','FORMATTED',  0
theend

breaksw

case kram:
set exe = $command
cat << theend > $def
 5,'$file.inkram'   ,  'OLD','FORMATTED',  0
10,'$file.joint$updn'  ,  'OLD','FORMATTED',  0
11,'$file.intra$updn'  ,  'UNKNOWN','FORMATTED',  0
12,'$file.epsilon$updn'  ,  'UNKNOWN','FORMATTED',  0
13,'$file.sigmak$updn'  ,  'UNKNOWN','FORMATTED',  0
14,'$file.absorp$updn'  ,  'UNKNOWN','FORMATTED',  0
15,'$file.eloss$updn'  ,  'UNKNOWN','FORMATTED',  0
16,'$file.refraction$updn',  'UNKNOWN','FORMATTED',0
17,'$file.reflectivity$updn','UNKNOWN','FORMATTED',0
77,'$file.sumrules$updn'  ,  'UNKNOWN','FORMATTED',  0
theend

breaksw

case sumpara:
set exe = sumpara
set deffile_only
cat << theend > $def
 6,'$file.outputsum',   'unknown','formatted',0
 8,'$file.scfdm$updn',    'unknown','formatted',0
17,'$file.clmval$updn$eece',    'unknown','formatted',0
20,'$file.struct',    'old',    'formatted',0
21,'$file.scf2$updn',      'unknown','formatted',0
22,'$file.scf2p',       'unknown','formatted',0
theend
if ($?du) then
cat << theend >> $def
10,'$file.dmatup'     ,'unknown','formatted',0
11,'$file.dmatdn'     ,'unknown','formatted',0
12,'$file.dmatud'     ,'unknown','formatted',0
theend
else
cat << theend >> $def
10,'$file.dmat$updn',    'unknown','formatted',0
theend
endif

breaksw


case sumpara_vresp:
set exe = sumpara
set deffile_only
cat << theend > $def
 6,'$file.outputsum',   'unknown','formatted',0
17,'$file.vrespval$updn',    'unknown','formatted',0
20,'$file.struct',    'old',    'formatted',0
21,'$file.scf2$updn',      'unknown','formatted',0
22,'$file.scf2p',       'unknown','formatted',0
theend

breaksw

case sumhfpara:
set exe = sumhfpara$cmplx
set deffile_only
cat << theend > $def
 6,'$file.outputhfsum$updn', 'unknown','formatted',0
15,'$file.klist_fbz',        'old',    'formatted',0
16,'$file.klist_ibz',        'old',    'formatted',0
18,'$file.vectorhf$updn',    'unknown','unformatted',0
19,'$file.energyhf$updn',    'unknown','formatted',0
20,'$file.struct',           'old',    'formatted',0
theend
if ( $band1 == '_band' )       echo "40,'$file.klist_band'   ,'unknown','formatted',0" >>$def
if ( $nmrhf == 'nmrhf' )       echo "47,'$file.qvec'         ,'unknown','formatted',0" >>$def
if ( $gw == 'gw' )             echo "48,'$file.gw$updn'      ,'unknown','formatted',0" >>$def
breaksw

case lstart:
set exe = lstart  
#touch $file.inst_sigma
if ($?sigma) then
#  if(  -z $file.inst_sigma ) then
    sed "s/ N/ P/" $file.inst >$file.inst_sigma
#  endif
endif
cat << theend > $def
 6,'$file.outputst',      'unknown','formatted'
 7,'$file.tmpden',        'unknown','formatted'
10,'$file.tmp',	          'unknown','unformatted'
11,'$file.vsp_st',           'unknown','formatted'
12,'$file.vspdn_st',         'unknown','formatted'
13,'$file.sigma',         'unknown','formatted'
 4,'$file.inq_st',        'unknown','formatted'
14,'$file.in0_st',        'unknown','formatted'
15,'$file.in1_st',        'unknown','formatted'
16,'$file.inc_st',        'unknown','formatted'
17,'$file.in2_ls',        'unknown','formatted'
18,'$file.inm_st',        'unknown','formatted'
19,'$file.inm_restart_st','unknown','formatted'
20,'$file.struct',        'old',    'formatted'
81,'$file.rspup',         'unknown','formatted'
82,'$file.rspdn',         'unknown','formatted'
83,'$file.rsp',           'unknown','formatted'
94,'$file.rsigma',         'unknown','formatted'
theend
if ($?sigma) then
  echo " 5,'$file.inst_sigma',          'old',    'formatted'" >>$def
else
  echo " 5,'$file.inst',          'old',    'formatted'" >>$def
endif
breaksw
 
case mini:
set exe = mini
if !(-e $file.clmvalup || -z $file.clmvalup) then
cat << theend > $def
5 ,'$file.inM',       'old','formatted',0
6 ,'$file.outputM',   'unknown','formatted',0
20,'$file.struct',    'old',    'formatted',0
10,'$file.clmsum',    'unknown',    'formatted',0
13,'$file.clmhist',   'unknown',    'formatted',0
15,'$file.finM',      'old',    'formatted',0
16,'$file.tmpM',      'unknown','formatted',0
17,'$file.tmpM1',     'unknown','formatted',0
21,'$file.struct1',   'unknown','formatted',0
22,'$file.scf','unknown','formatted',0
23,'$file.scf_mini','unknown','formatted',0
24,'$file.scf_mini1','unknown','formatted',0
25,'$file.constraint','unknown','formatted',0
51,'$file.clmsum_inter',    'unknown',    'formatted',0
theend
        else
cat << theend > $def
5 ,'$file.inM',       'old','formatted',0
6 ,'$file.outputM',   'unknown','formatted',0
20,'$file.struct',    'old',    'formatted',0
10,'$file.clmup',    'old',    'formatted',0
60,'$file.clmdn',    'old',    'formatted',0
13,'$file.clmhist',      'unknown',    'formatted',0
15,'$file.finM',      'old',    'formatted',0
16,'$file.tmpM',      'unknown','formatted',0
17,'$file.tmpM1',      'unknown','formatted',0
21,'$file.struct1',   'unknown','formatted',0
22,'$file.scf','unknown','formatted',0
23,'$file.scf_mini','unknown','formatted',0
24,'$file.scf_mini1','unknown','formatted',0
11,'$file.clmsum_inter',    'unknown',    'formatted',0
51,'$file.clmup_inter',    'unknown',    'formatted',0
52,'$file.clmdn_inter',    'unknown',    'formatted',0
theend
endif
breaksw


case mixer_vresp:
set exe = mixer
	if !(-e $file.clmvalup || -z $file.clmvalup) then
cat << theend > $def
 5,'$file.inm_vresp',       'old',    'formatted',0
 6,'$file.outputm_vresp',   'unknown','formatted',0
 7,'$file.inc',       'old',    'formatted',0
10,'$file.vrespsum_old','unknown','formatted',0
17,'$file.vrespval',    'unknown','formatted',0
18,'$file.vrespsc',     'unknown','formatted',0
19,'$file.vrespcor',    'unknown','formatted',0
20,'$file.struct',    'old',    'formatted',0
21,'$file.scfm_vresp',     'unknown','formatted',0
31,'$file.vrespbroyd1',    'unknown','unformatted',164896
32,'$file.vrespbroyd2',    'unknown','unformatted',164896
51,'$file.vrespsum',    'unknown','formatted',0
theend
	else
cat << theend > $def
 5,'$file.inm_vresp',      'old',    'formatted',0
 6,'$file.outputm_vresp',  'unknown','formatted',0
 7,'$file.inc',       'old',    'formatted',0
10,'$file.vrespup_old','unknown','formatted',0
60,'$file.vrespdn_old','unknown','formatted',0
17,'$file.vrespvalup', 'unknown','formatted',0
18,'$file.vrespscup',  'unknown','formatted',0
19,'$file.vrespcorup', 'unknown','formatted',0
20,'$file.struct',   'old',    'formatted',0
21,'$file.scfm_vresp',     'unknown','formatted',0
31,'$file.vrespbroyd1',   'unknown','unformatted',164896
32,'$file.vrespbroyd2',   'unknown','unformatted',164896
47,'$file.vrespvaldn', 'unknown','formatted',0
48,'$file.vrespscdn',  'unknown','formatted',0
49,'$file.vrespcordn', 'unknown','formatted',0
51,'$file.vrespup',    'unknown','formatted',0
52,'$file.vrespdn',    'unknown','formatted',0
11,'$file.vrespsum',   'unknown','formatted',0
theend
	endif
   breaksw


case mixer:
case mixer_New:
# cp case.struct for MSR1a
set testmsr=`head -1 $file.inm | grep "MSR[12]a" | cut -c1-3`
set testmsr1=`head -1 $file.inm | grep "MSECa" | cut -c1-5`
if($testmsr1 == 'MSECa') set testmsr=MSR
if ($testmsr == 'MSR') then
   cp $file.struct $file.struct_old
endif
set exe = $command
	if !(-e $file.clmvalup || -z $file.clmvalup) then
cat << theend > $def
 5,'$file.inm',       'old',    'formatted',0
 6,'$file.outputm',   'unknown','formatted',0
 7,'$file.inc',       'old',    'formatted',0
10,'$file.clmsum_old','unknown','formatted',0
17,'$file.clmval',    'unknown','formatted',0
18,'$file.clmsc',     'unknown','formatted',0
19,'$file.clmcor',    'unknown','formatted',0
20,'$file.struct',    'old',    'formatted',0
21,'$file.scfm',      'unknown','formatted',0
22,'$file.scf',       'unknown','formatted',0
31,'$file.broyd1',    'unknown','unformatted',164896
32,'$file.broyd2',    'unknown','unformatted',164896
51,'$file.clmsum',    'unknown','formatted',0
theend
	else
cat << theend > $def
 5,'$file.inm',      'old',    'formatted',0
 6,'$file.outputm',  'unknown','formatted',0
 7,'$file.inc',       'old',    'formatted',0
10,'$file.clmup_old','unknown','formatted',0
60,'$file.clmdn_old','unknown','formatted',0
17,'$file.clmvalup', 'unknown','formatted',0
18,'$file.clmscup',  'unknown','formatted',0
19,'$file.clmcorup', 'unknown','formatted',0
20,'$file.struct',   'old',    'formatted',0
21,'$file.scfm',     'unknown','formatted',0
22,'$file.scf',      'unknown','formatted',0
31,'$file.broyd1',   'unknown','unformatted',164896
32,'$file.broyd2',   'unknown','unformatted',164896
47,'$file.clmvaldn', 'unknown','formatted',0
48,'$file.clmscdn',  'unknown','formatted',0
49,'$file.clmcordn', 'unknown','formatted',0
51,'$file.clmup',    'unknown','formatted',0
52,'$file.clmdn',    'unknown','formatted',0
11,'$file.clmsum',   'unknown','formatted',0
theend
if ($?orb && $eece != 'eece') then
echo "71,'$file.dmatup','unknown','formatted',0" >> $def
echo "72,'$file.dmatdn','unknown','formatted',0" >> $def
echo "73,'$file.dmatud','unknown','formatted',0" >> $def
echo "74,'$file.dmatup_old','unknown','formatted',0" >> $def
echo "75,'$file.dmatdn_old','unknown','formatted',0" >> $def
echo "76,'$file.dmatud_old','unknown','formatted',0" >> $def
endif
	endif

if($eece  == 'eece') then
echo "71,'$file.vorbup','unknown','formatted',0" >> $def
echo "72,'$file.vorbdn','unknown','formatted',0" >> $def
echo "73,'$file.vorbud','unknown','formatted',0" >> $def
echo "74,'$file.vorbup_old','unknown','formatted',0" >> $def
echo "75,'$file.vorbdn_old','unknown','formatted',0" >> $def
echo "76,'$file.vorbud_old','unknown','formatted',0" >> $def
#  sed 's/dmat/vorb/g' $def > help_1234
#  mv help_1234 $def
endif
if ("$dftd3" == 'dftd3') then
echo "80,'.EDISP',        'old','formatted',0" >> $def
if ((-e dftd3_gradient) && !(-z dftd3_gradient)) then
echo "81,'dftd3_gradient','old','formatted',0" >> $def
endif
endif

   breaksw


case nn:
set exe = nn
cat << theend > $def
66,'$file.outputnn','unknown','formatted',0
67,'$file.nnshells','unknown','formatted',0
88,'$file.bva','unknown','formatted',0
20,'$file.struct',  'old',    'formatted',0
21,'$file.struct_nn','unknown','formatted',0
theend
breaksw

case dipan:
set exe = dipan
cat << theend > $def
5 ,'$file.indipan',    'old','formatted',0
6 ,'$file.outputdipan','unknown','formatted',0
20,'$file.struct',     'old',    'formatted',0
66 ,'$file.nn_dipan','unknown','formatted',0
theend
breaksw

case tetra:
set exe = tetra  
if ($hf == hf) then
  set ending = '_fbz'
endif
cat << theend > $def
5 ,'$file.int',         'old','formatted',0
6 ,'$file.outputt$updn','unknown','formatted',0
3 ,'$file.kgen$ending',        'old',    'formatted',0
2 ,'$file.klist$ending',        'unknown',    'formatted',0
7 ,'$file.dos1$updn',   'unknown','formatted',0
57,'$file.dos1ev$updn', 'unknown','formatted',0
theend
if($?rxes) echo "8, '$file.rxes$updn',  'old','formatted',0" >>$def
if($?rxesw) then
echo "9, '$file.rxes$updn',  'unknown','formatted',0" >>$def
  cp $file.int .oldint
  sed "2s/.*/$rxese1 0.001 $rxese2 0.0 /" .oldint >$file.int
endif
if($?enefile) then
  echo "108 ,'$file.energy$so$hf$updn',    'old','formatted',0" >>$def
  echo "109 ,'$file.scf2$hf$updn',    'old','formatted',0" >>$def
else
  echo "4 ,'$file.qtl$updn',    'old','formatted',0" >>$def
endif
breaksw

case lapw5:
set exe = lapw5$cmplx  
cat << theend > $def
5 ,'$file.in5$cmplx', 'old',    'formatted',0
6 ,'$file.output5',   'unknown','formatted',0
8 ,'$file.struct',    'old',    'formatted',0
9 ,'$file.clmval$updn',    'old',    'formatted',0
10,'$file.tmp',       'unknown','unformatted',0
11,'$file.clmval$dnup',  'unknown','formatted',0
12,'$file.sigma',     'unknown','formatted',0
20,'$file.rho_onedim','unknown','formatted',0
21,'$file.rho',       'unknown','formatted',0
theend
breaksw

case filtvec:
set exe = filtvec$cmplx
cat << theend > $def
5 ,'$file.inf$cmplx',   'old',    'formatted',0
6 ,'$file.outputf$updn','unknown','formatted',0
10,'${scratch}$file.vector$hf$updn', 'old',    'unformatted',0
12,'$file.vectorf$hf$updn','unknown','unformatted',0
20,'$file.struct',      'old',    'formatted',0
theend
breaksw

case lapw7:
set exe = lapw7$cmplx
set vecloc = $scratch; if ($sel == f) set vecloc =
cat << theend > $def
2 ,'$file.tmp'             'unknown','formatted',0
5 ,'$file.in7$cmplx',      'old',    'formatted',0
6 ,'$file.output7$updn',   'unknown','formatted',0
7 ,'$file.grid',           'unknown','formatted',0
8 ,'$file.struct',         'old',    'formatted',0
10,'${vecloc}$file.vector$sel$hf$updn','old',    'unformatted',0
12,'$file.abc$updn',       'unknown','unformatted',0
18,'$file.vsp$updn',       'old',    'formatted',0
21,'$file.psink',          'unknown','formatted',0
theend
breaksw

case lapw3:
set exe = $command$cmplx  
cat << theend > $def
66,'$file.output3',  'unknown','formatted',0
4 ,'$file.in2$cmplx','old',    'formatted',0
8 ,'$file.clmsum',   'old',    'formatted',0
15,'$file.tmp3',      'unknown','unformatted',0
20,'$file.struct',   'old',    'formatted',0
theend
breaksw

case symmetry:
set exe = symmetry  
cat << theend > $def
6, '$file.outputs','unknown','formatted',0
17,'$file.in2_sy', 'unknown','formatted',0
20,'$file.struct', 'old',    'formatted',0
21,'$file.struct_st', 'unknown',    'formatted',0
theend
breaksw

case symmetso:
set exe = symmetso  
cat << theend > $def
 5,'$file.inso',   'old',    'formatted',0
 6,'$file.outsymso','unknown','formatted',0
25,'$file.vspdn',         'unknown',    'formatted',0
45,'$file.vspdn_so',         'unknown',    'formatted',0
26,'$file.vspup',         'unknown',    'formatted',0
46,'$file.vspup_so',         'unknown',    'formatted',0
27,'$file.vnsdn',         'unknown',    'formatted',0
47,'$file.vnsdn_so',         'unknown',    'formatted',0
28,'$file.vnsup',         'unknown',    'formatted',0
48,'$file.vnsup_so',         'unknown',    'formatted',0
20,'$file.struct_interm',         'unknown',    'formatted',0
21,'$file.struct_so',         'unknown',    'formatted',0
22,'$file.struct'           'old',    'formatted',0
23,'$file.ksym',         'unknown',    'formatted',0
24,'$file.temp',         'unknown',    'formatted',0
29,'$file.in1$cmplx',         'unknown',    'formatted',0
49,'$file.in1${cmplx}_so',         'unknown',    'formatted',0
30,'$file.inc',         'unknown',    'formatted',0
50,'$file.inc_so',         'unknown',    'formatted',0
31,'$file.inorb',         'unknown',    'formatted',0
51,'$file.inorb_so',         'unknown',    'formatted',0
32,'$file.vorbdn',         'unknown',    'formatted',0
52,'$file.vorbdn_so',         'unknown',    'formatted',0
33,'$file.vorbup',         'unknown',    'formatted',0
53,'$file.vorbup_so',         'unknown',    'formatted',0
34,'$file.in2$cmplx',         'unknown',    'formatted',0
54,'$file.in2${cmplx}_so',         'unknown',    'formatted',0
35,'$file.clmsum',         'unknown',    'formatted',0
55,'$file.clmsum_so',         'unknown',    'formatted',0
36,'$file.clmup',         'unknown',    'formatted',0
56,'$file.clmup_so',         'unknown',    'formatted',0
37,'$file.clmdn',         'unknown',    'formatted',0
57,'$file.clmdn_so',         'unknown',    'formatted',0
38,'$file.indm${cmplx}',         'unknown',    'formatted',0
58,'$file.indm${cmplx}_so',         'unknown',    'formatted',0
42,'$file.dmatup',         'unknown',    'formatted',0
62,'$file.dmatup_so',         'unknown',    'formatted',0
43,'$file.dmatdn',         'unknown',    'formatted',0
63,'$file.dmatdn_so',         'unknown',    'formatted',0
theend
breaksw


case spaghetti:
set exe = spaghetti  
set typ=1
set updnso=$updn
if ($so == so ) then
    set typ=so
    set updnso=
endif
if ($hf == hf ) then
    set typ=hf
endif
if($para == para) then
    set cnum=0
    if(-f .processes) then
	@ cnum=`grep -ce "^[0-9][0-9]* :" .processes`
#	@ cnum+=1
    endif
    #the original file will only be removed if there are sources to concat
    if(-f "$file.output$typ$updnso" && $cnum>0) then
	rm "$file.output$typ$updnso"
    endif
    unset irr
    if(-f "$file.irrep$hf$so${updn}_$cnum" && $cnum>0) then
	if(-f "$file.irrep$hf$so${updn}" ) rm "$file.irrep$hf$so${updn}"
        head -2 "$file.irrep$hf$so${updn}_$cnum" >"$file.irrep$hf$so${updn}"
        set irr
    endif
    set count=1
    while($count <= $cnum)
        if($?irr) then
           tail -n +3 $file.irrep$hf$so${updn}_$count >>$file.irrep$hf$so${updn}
	endif
        cat "$file.output$typ${updnso}_$count" >>"$file.output$typ$updnso"
	@ count++
    end
    echo $file.output$typ$updnso created from $cnum parallel files
endif
cat << theend > $def
5, '$file.insp',         'old',    'formatted',0
6, '$file.outputsp$updn',     'unknown','formatted',0
9, '$file.qtl$updn',          'unknown','formatted',0
10,'$file.spaghetti${updn}_ene','unknown','formatted',0
11,'$file.spaghetti${updn}_ps', 'unknown','formatted',0
20,'$file.struct',       'old',    'formatted',0
30,'$file.irrep$hf$so$updn',          'unknown','formatted',0
40,'$file.bands${updn}.agr',       'unknown','formatted',0
theend
#if ($so == so ) then
#echo "7, '$file.outputso',      'old','formatted',0" >>$def
#else
if(! $?enefile) then
  echo "7, '$file.output$typ$updnso',  'old','formatted',0" >>$def
else
  echo "8, '$file.energy$so$updn',  'old','formatted',0" >>$def           
endif
#endif
breaksw

case xspec:
set exe = $command
cat << theend > $def
 5,'$file.inxs',   'old',    'formatted',0
 6,'$file.outputx','unknown','formatted',0
 7,'$file.inc',   'old',    'formatted',0
 8,'$file.int','unknown','formatted',0
 9,'$file.corewfx$updn', 'unknown','formatted',0
18,'$file.vsp$updn',       'old',    'formatted',0
20,'$file.struct',         'old',    'formatted',0
30,'$file.qtl$updn', 'old',    'formatted',0
32,'$file.dos1ev$updn',        'unknown','formatted',0
46,'$file.xspec$updn',            'unknown','formatted',0
47,'$file.txspec$updn',            'unknown','formatted',0
53,'$file.m1$updn',            'unknown','formatted',0
54,'$file.m2$updn',            'unknown','formatted',0
theend
breaksw

case initxspec:
set exe = $command
cat << theend > $def
 5,'$file.inxs',   'old',    'formatted',0
 8,'$file.int','unknown','formatted',0
30,'$file.qtl$updn', 'old',    'formatted',0
theend
breaksw

case txspec:
set exe = $command
cat << theend > $def
 5,'$file.inxs',   'old',    'formatted',0
 6,'$file.outputx','unknown','formatted',0
 7,'$file.inc',   'old',    'formatted',0
 9,'$file.corewfx$updn',   'unknown','formatted',0
18,'$file.vsp$updn',        'old',    'formatted',0
20,'$file.struct',          'old',    'formatted',0
21,'$file.scfc$updn',       'unknown','formatted',0
30,'$file.qtl$updn',        'old',    'formatted',0
32,'$file.dos1ev$updn',     'old','formatted',0
47,'$file.txspec$updn',     'unknown','formatted',0
53,'$file.m1$updn',         'unknown','formatted',0
54,'$file.m2$updn',         'unknown','formatted',0
theend
breaksw

case lorentz:
set exe = $command
cat << theend > $def
 5,'$file.inxs',             'old',    'formatted',0
46,'$file.xspec$updn',       'unknown','formatted',0
47,'$file.txspec$updn',      'old',    'formatted',0
theend
breaksw

case telnes2:
set exe = $command
cut -f1 -d' ' $file.innes > .temp_making_elnes.def
if (`grep -i xqtl .temp_making_elnes.def` != ) then
  set number = `head -n 2 $file.innes | tail -n 1`
  if ($#number > 1) set number = $number[1]
else
  set number =
endif
if ($hf == hf) then
  set ending = '_fbz'
endif
cat << theend > $def
3, '$file.kgen$ending','unknown','formatted',0
5, '$file.innes',           'old',    'formatted',0
6, '$file.outputelnes$updn',       'unknown','formatted',0
7, '$file.inc',             'unknown',    'formatted',0
8, '$file.inb','unknown','formatted',0
9, '$file.corewavef$updn',   'unknown','formatted',0
10,'$file.final$updn',              'unknown','formatted',0
18,'$file.vsp$updn',        'unknown',    'formatted',0
20,'$file.struct',          'old',    'formatted',0
30,'$file.qtl$number$updn',        'unknown',    'formatted',0
31,'$file.rotij',           'unknown',    'formatted',0
46,'$file.ortho$updn',         'unknown','formatted',0
47,'$file.elnes$updn',        'unknown','formatted',0
48,'$file.ctr$updn',        'unknown','formatted',0
49,'$file.sdlm$updn',        'unknown','formatted',0
50,'$file.matrix$updn','unknown','formatted',0
56,'$file.cdos$updn','unknown','formatted',0
57,'$file.dos$updn',     'unknown',    'formatted',0
58,'$file.xdos$updn','unknown','formatted',0
59,'$file.sp2$updn','unknown','formatted',0
60,'$file.angular$updn','unknown','formatted',0
theend
breaksw

## Remove the section for telnes2 and replace it by:
case telnes3:
set exe = $command
if ($hf == hf) then
  set ending = '_fbz'
endif
cat << theend > $def
3, '$file.kgen$ending','unknown','formatted',0
5, '$file.innes',           'old',    'formatted',0
6, '$file.outputelnes$updn',       'unknown','formatted',0
7, '$file.inc',             'unknown',    'formatted',0
8, '$file.inb','unknown','formatted',0
9, '$file.corewavef$updn',   'unknown','formatted',0
10,'$file.final$updn',              'unknown','formatted',0
18,'$file.vsp$updn',        'unknown',    'formatted',0
19,'$file.vtotal$updn','unknown','formatted',0
20,'$file.struct',          'old',    'formatted',0
30,'$file.qtl$updn',        'unknown',    'formatted',0
31,'$file.rotij',           'unknown',    'formatted',0
46,'$file.ortho$updn',         'unknown','formatted',0
47,'$file.elnes$updn',        'unknown','formatted',0
48,'$file.ctr$updn',        'unknown','formatted',0
49,'$file.sdlm$updn',        'unknown','formatted',0
50,'$file.matrix$updn','unknown','formatted',0
56,'$file.cdos$updn','unknown','formatted',0
57,'$file.dos$updn',     'unknown',    'formatted',0
58,'$file.xdos$updn','unknown','formatted',0
59,'$file.sp2$updn','unknown','formatted',0
60,'$file.angular$updn','unknown','formatted',0
69,'$file.eelstable','unknown','formatted',0
theend
breaksw

case broadening:
set exe = broadening
cat << theend > $def
 5,'$file.inb','old','formatted',0
 6,'$file.outputbroadening$updn','unknown','formatted',0
46,'$file.broadspec$updn','unknown','formatted',0
47,'$file.elnes$updn','old','formatted',0
theend
breaksw

case hex2rhomb:
set exe = $command
breaksw

case rhomb_in5:
set exe = $command
breaksw

case veccopy:
if($sc == 's') set ending = 'sc'
set exe = veccopy$cmplx
cat << theend > $def
5, '$file.inveccopy',    'old',    'formatted', 0
6, '$file.outputveccopy','unknown','formatted', 0
20,'$file.struct',       'old',    'formatted', 0
10,'${scratch}$file.vectorup', 'old','unformatted',9000
30,'${scratch}$file.vectordn', 'unknown','unformatted',9000
71,'$file.nshup',    'unknown','formatted',0
81,'$file.nshdn',    'unknown','formatted',0
theend
breaksw

case clmcopy:
set ending = 'val'
set updn = 'up'
if($sc == 's') set ending = 'sc'
set exe = clmcopy
cat << theend > $def
5, '$file.inclmcopy',    'old',    'formatted', 0
6, '$file.outputclmcopy','unknown','formatted', 0
7, '$file.dmatup',       'unknown','formatted', 0
8, '$file.dmatdn',       'unknown','formatted', 0
20,'$file.struct',       'old',    'formatted', 0
21,'$file.scf2$sc$updn',       'unknown',    'formatted',       0
22,'$file.scf2$sc$dnup',       'unknown',    'formatted',       0
theend
if ($?vresp) then
  echo "17,'$file.vresp$ending$updn',     'old',    'formatted',  0" >>$def
  echo "18,'$file.vresp$ending$dnup',     'unknown','formatted',  0" >>$def
else
  echo "17,'$file.clm$ending$updn',     'old',    'formatted',  0" >>$def
  echo "18,'$file.clm$ending$dnup',     'unknown','formatted',  0" >>$def
endif
breaksw

case struct_afm_check:
set exe = struct_afm_check
cat << theend > $def
5, '$file.inclmcopy',    'old',    'formatted', 0
6, '$file.outputstruct_afm_check','unknown','formatted', 0
20,'$file.struct',       'old',    'formatted', 0
21,'$file.struct_afm_check',       'unknown',    'formatted',       0
theend
breaksw

case clminter:
if ($updn == '' ) set updn = 'sum'
set exe = clminter
cat << theend > $def
6, '$file.outputclminter','unknown','formatted', 0
17,'$file.clm$updn',     'old',    'formatted',  0
18,'$file.clm${updn}_new',     'unknown','formatted',  0
20,'$file.struct',       'old',    'formatted', 0
21,'$file.struct_new',       'old',    'formatted',       0
theend
breaksw

case conv2prim:
set exe = conv2prim
cat << theend > $def
20,'$file.struct','old','formatted',0
21,'${file}_prim.struct','unknown','formatted',0
theend
touch conv2prim.error
breaksw

case struct2poscar:
set exe = struct2poscar
cat << theend > $def
20,'$file.struct','old','formatted',0
21,'$file.poscar','unknown','formatted',0
22,'$file.xyz','unknown','formatted',0
theend
touch struct2poscar.error
breaksw

case dftd3:
if (!(-e $file.indftd3) || (-z $file.indftd3)) then
      cp $WIENROOT/SRC_templates/template.indftd3 $file.indftd3
      echo "$file.indftd3 created"
endif
if (!(-e $file.poscar) || (-z $file.poscar)) then
      x struct2poscar
      echo "$file.poscar created"
endif

rm -f .EDISP dftd3_gradient dftd3_cellgradient dftd3.error
set dftd3_abc
set line1=`grep -i abc $file.indftd3`
if ($#line1 != 0) then
  if ($line1[2] == 'yes') set dftd3_abc=-abc
endif
set dftd3_cnthr
set dftd3_cnthr_value
set line1=`grep -i cnthr $file.indftd3`
if ($#line1 != 0) then
  set dftd3_cnthr=-cnthr
  set dftd3_cnthr_value=$line1[2]
endif
set dftd3_cutoff
set dftd3_cutoff_value
set line1=`grep -i cutoff $file.indftd3`
if ($#line1 != 0) then
  set dftd3_cutoff=-cutoff
  set dftd3_cutoff_value=$line1[2]
endif
set dftd3_pbc=-pbc
set dftd3_format=poscar
set line1=`grep -i pbc $file.indftd3`
if ($#line1 != 0) then
  if ($line1[2] == 'no') then
    set dftd3_pbc
    set dftd3_format=xyz
  endif
endif
set line1=`grep -i func $file.indftd3`
if ($line1[2] == 'default') then
  set dftd3_func=-func
  set line2= (`head -1 $file.in0`)
  if($#line2 < 3) then
    set line2= ( $line2 none )
  endif
  if (($line2[2] == 24) || (($line2[2] == 'EX_B88') && ("$line2[3]" == 'EC_LYP'))) then
    set dftd3_func_value=b-lyp
  else if (($line2[2] == 13) || ($line2[2] == 'XC_PBE') || (($line2[2] == 'EX_PBE') && ("$line2[3]" == 'EC_PBE'))) then
    set dftd3_func_value=pbe
  else if (($line2[2] == 'EX_REVPBE') && ("$line2[3]" == 'EC_PBE')) then
    set dftd3_func_value=revpbe
  else if (($line2[2] == 16) || (($line2[2] == 'EX_RPBE') && ("$line2[3]" == 'EC_PBE'))) then
    set dftd3_func_value=rpbe
  else if (($line2[2] == 19) || ($line2[2] == 'XC_PBESOL') || (($line2[2] == 'EX_PBESOL') && ("$line2[3]" == 'EC_PBESOL'))) then
    set dftd3_func_value=pbesol
  else if (($line2[2] == 'EX_B88') && ("$line2[3]" == 'EC_PBE')) then
    set dftd3_func_value=bpbe
  else if (($line2[2] == 27) || (($line2[2] == 'EX_TPSS') && ("$line2[3]" == 'EC_TPSS'))) then
    set dftd3_func_value=tpss
  else
    set dftd3_func_value=not_valid
  endif
else if ($line1[2] == 'none') then
  set dftd3_func
  set dftd3_func_value
  if (!(-e ~/.dftd3par.`hostname`) || (-z ~/.dftd3par.`hostname`)) exit(9)
else
  set dftd3_func=-func
  set dftd3_func_value=$line1[2]
endif
set dftd3_grad=-grad
set line1=`grep -i grad $file.indftd3`
if ($#line1 != 0) then
  if ($line1[2] == 'no') set dftd3_grad
endif
set dftd3_method=-bj
set line1=`grep -i method $file.indftd3`
if ($#line1 != 0) then
  set dftd3_method=-$line1[2]
endif
set dftd3_num
set line1=`grep -i num $file.indftd3`
if ($#line1 != 0) then
  if ($line1[2] == 'yes') set dftd3_num=-num
endif

set exe = $command
$t $bin/$command $file.$dftd3_format $dftd3_pbc $dftd3_method \
  $dftd3_func $dftd3_func_value $dftd3_grad $dftd3_abc \
  $dftd3_cutoff $dftd3_cutoff_value $dftd3_cnthr $dftd3_cnthr_value \
  $dftd3_num > $file.scfdftd3
if (!(-e .EDISP)) then
   echo "Error in DFTD3: file .EDISP is not present" > dftd3.error
   exit(9)
else
   touch dftd3.error
endif
rm $running
exit(0)
breaksw

case fleur2wien:
set exe = fleur2wien
cat << theend > $def
5 ,'$file.in2$cmplx','old','formatted',0
6 ,'$file.outputfleur2wien','unknown','formatted',0
20,'$file.struct','old','formatted',0
10,'$file.lattice_harmonics','old','formatted',0
11,'$file.potential','old','formatted',0
12,'$file.r2v','unknown','formatted',0
13,'$file.r2vdn','unknown','formatted',0
theend
touch fleur2wien.error
breaksw

case afminput:
set exe = afminput
cat << theend > $def
14, '$file.outputafminput',  'unknown','formatted', 0
15, '$file.inclmcopy_st',    'unknown','formatted', 0
16,'$file.clmup',            'old',    'formatted', 0
17,'$file.clmdn',            'old',    'formatted', 0
20,'$file.struct',           'old',    'formatted', 0
21,'$file.struct_supergroup','unknown','formatted', 0
theend
breaksw

case irrep:
set exe = irrep$para
set dopara = 1
cat << theend > $def
5, '$file.irrep$hf$so$updn',      'unknown','formatted',0
6, '$file.outputir$hf$so$updn',    'unknown','formatted',0
9, '${scratch}$file.vector$hf$so$dnup',      'unknown',    'unformatted',9000
10,'${scratch}$file.vector$hf$so$updn',      'old',    'unformatted',9000
20,'$file.struct',          'old',    'formatted',0
theend
breaksw

case xyz2struct:
if (-e $file.xyz ) then
xyz2struct <$file.xyz
echo "File  xyz2struct.struct   has been created"
exit(0)
else
 echo "You need a xyz-file: $file.xyz " 
 exit(1)
endif
breaksw

case supercell:
set exe = supercell
cat << theend > $def

theend
breaksw

case plane:
if (-e plane.input) then
 plane <plane.input
else
 echo "You need a file:  plane.input (see top of $WIENROOT/SRC_trig/plane.f)" 
 exit(1)
endif
breaksw

case qtl:
if ($?make_inq) then        #Kevin Jorissen, for use with telnes3
   write_inq_lapw
endif
set exe = $command$para
set dopara = 1
cat << theend > $def
 4,'$file.inso',   'unknown',    'formatted',0
 5,'$file.inq',   'old',    'formatted',0
 6,'$file.outputq$updn','unknown','formatted',0
 8,'$file.scf2$hf$updn',       'old',    'formatted',0
 9,'${scratch}$file.vector$hf$so$updn', 'unknown','unformatted',9000
10,'${scratch}$file.vector$hf$so$dnup', 'unknown','unformatted',9000
12,'$file.dmat$updn',       'unknown','formatted',0
16,'$file.qtl$updn',       'unknown','formatted',0
18,'$file.vsp$updn',       'old',    'formatted',0
19,'$file.vsp$dnup',       'unknown','formatted',0
20,'$file.struct',         'old',    'formatted',0
21,'$file.scfq$updn',   'unknown',    'formatted',0
22,'$file.rotlm',   'unknown',    'formatted',0
26,'$file.weigh$hf$updn',       'old',    'unformatted',9000
29,'$file.tmp$updn','unknown','unformatted',9000
30,'$file.qtltext$updn','unknown','formatted',0
31,'$file.qtlatom$updn','unknown','formatted',0
59,'$file.energy$hf$so$dnup', 'unknown','formatted',0
60,'$file.energy$hf$so$updn', 'unknown','formatted',0
theend
###45,'$file.normsoup','unknown','formatted',0
###46,'$file.normsodn','unknown','formatted',0
set natom=`head -2 $file.inq | tail -1 | cut -c1-10`
set iatom=1
while ($iatom <= $natom)
set cf=`expr 31 + $iatom`
set int=`expr 70 + $iatom`
     echo "$cf,'$file.cf$iatom','unknown','formatted',0">>$def
     echo "$int,'$file.int$iatom$updn','unknown','formatted',0">>$def
   @ iatom ++
end
if ($cmplx == c ) then
  echo " 7,'$file.in1c',   'unknown',    'formatted',0">>$def
endif
breaksw

case struct2mol:
set exe = struct2mol
set molf='xtl'
cat << theend > $def
2, '$file.$molf',       'unknown',    'formatted',0
20,'$file.struct','old','formatted',0
theend
breaksw

case struct2cif:
set exe = struct2cif
cat << theend > $def
 6,'$file.output2cif','unknown','formatted',0
31, '$file.cif',       'unknown',    'formatted',0
20,'$file.struct','old','formatted',0
theend
breaksw

case struct2xyz:
set exe = struct2xyz
cat << theend > $def
 6,'$file.output2xyz','unknown','formatted',0
32, '$file.xyz',       'unknown',    'formatted',0
20,'$file.struct','old','formatted',0
theend
breaksw

case orbstr:
set exe = orbstr
cat << theend > $def
6, '$file.outputorbstr', 'unknown', 'formatted',0
8, '$file.inso',       'old',    'formatted',0
20,'$file.struct','old','formatted',0
21,'$file.struct_orbstr','unknown','formatted',0
theend
breaksw

case aim:
set exe = $command$cmplx
cat << theend > $def
5 ,'$file.inaim', 'old',    'formatted',0
6 ,'$file.outputaim',   'unknown','formatted',0
8 ,'$file.struct',    'old',    'formatted',0
9 ,'$file.clmsum',    'old',    'formatted',0
21,'$file.surf',       'unknown','formatted',0
22,'$file.crit',       'unknown','formatted',0
77,'$file.aim_surface_errors',       'unknown','formatted',0
theend
breaksw

case sgroup:
set settol1 = `echo "scale = 8; $settol / 10" | bc`
set exe = $command
$bin/$command -wi $file.struct  -set-TOL=$settol $file.outputsgroup 
$bin/$command -wi $file.struct  -set-TOL=$settol1 $file.outputsgroup1 
set test=`diff $file.outputsgroup $file.outputsgroup1 |wc`
if ( $test[1] != '0' ) then
    echo "Accuracy problem. Please run with different tolerance (x sgroup -settol $settol1)"
endif
set def = "-wi $file.struct -wo $file.struct_sgroup  -set-TOL=$settol"
breaksw

case nlo_KK:
set exe = $command
set def = "-w -i$file.innlo_KK -o$file.KK$updn $file.nlo$updn "
breaksw

case kzsurf:
set exe = $command
cat << theend > $def
6 ,'$file.outputkzsurf',   'unknown','formatted',0
20 ,'$file.struct',    'old',    'formatted',0
10 ,'$file.vector$updn',    'old',    'unformatted',0
theend
breaksw

case pairhess:
set exe = pairhess
cat << theend > $def
 5,'$file.inM','unknown','formatted',0
 6,'$file.outputpair','unknown','formatted',0
10,'$file.inpair',    'unknown',    'formatted',0
20,'$file.struct',    'old',    'formatted',0
21,'$file.inM_st',    'unknown',    'formatted',0
22,'$file.hess',    'unknown',    'formatted',0
theend
breaksw

case eigenhess:
set exe = eigenhess
cat << theend > $def
5,'$file.inM',    'old',    'formatted',0
6,'$file.outputeigenhess','unknown','formatted',0
10,'.min_hess',    'old',    'formatted',0
11,'.minpair',    'unknown',    'formatted',0
20,'$file.struct',    'old',    'formatted',0
22,'$file.hess',    'unknown',    'formatted',0
23,'$file.ineigenhess',   'unknown',    'formatted',0
theend
breaksw

case patchsymm:
set exe = patchsymm
cat << theend > $def
 6,'$file.outputpatch','unknown','formatted',0
20,'$file.struct',    'old',    'formatted',0
21,'$file.struct_patchsymm',    'unknown',    'formatted',0
theend
breaksw

case clmcreate:
set exe = clmcreate
cat << theend > $def
6, '$file.outputcreate','unknown','formatted', 0
17,'$file.clmsum',     'old',    'formatted',  0
18,'$file.clmsum_new',     'unknown','formatted',  0
20,'$file.struct',       'old',    'formatted', 0
21,'$file.increate',    'unknown','formatted', 0
theend
breaksw

case clmaddsub:
set exe = clmaddsub
if ($updn == '' ) set updn=sum
cat << theend > $def
11,'$file.struct',       'old',    'formatted',       0
12,'old.clm$updn',     'old',    'formatted',  0
13,'old_super.clm$updn',     'old','formatted',  0
14,'new_super.clm$updn',       'old',    'formatted', 0
15,'$file.clm$updn',     'unknown','formatted',  0
theend
breaksw

case extend_potential:
set exe = extend_potential
if ($updn == '' ) set updn=sum
cat << theend > $def
6, '$file.output_ext_pot',     'unknown',    'formatted',  0
9 ,'$file.vtotal',       'old',    'formatted',       0
18,'$file.vsp_ext_pot',     'unknown','formatted',  0
20,'$file.struct',       'old',    'formatted',       0
49,'$file.vsp',     'unknown','formatted',  0
theend
breaksw

case arrows:
set exe = arrows
if($?delta) then
cat << theend > $def
6,'$file.outputarrows',     'unknown','formatted',  0
11,'${file}_initial.struct',       'old',    'formatted',       0
12,'${file}_final.struct',     'old',    'formatted',  0
16,'${file}_initial.xsf',     'old','formatted',  0
18,'${file}_delta.xsf',     'unknown','formatted',  0
theend
else
cat << theend > $def
6,'$file.outputarrows',     'unknown','formatted',  0
10,'${file}_initial.scf',       'old',    'formatted',       0
11,'${file}_initial.struct',       'old',    'formatted',       0
15,'${file}_initial.forces',  'unknown',    'formatted', 0
16,'${file}_initial.xsf',     'old','formatted',  0
17,'${file}_forces.xsf',     'unknown','formatted',  0
theend
endif
breaksw

case cif2struct:
set exe = cif2struct
set def = $file.cif
if($?txt) set def = $file.txt
breaksw

case RMTCheck:
set exe = RMTCheck$cmplx
set RMV = clm
if ($?vresp) set RMV = vresp
   if ($updn == '') then
set RSS = val ; if ($?Rsum) set RSS = sum
cat << theend > $def
 6,'$file.outputRMT',  'unknown','formatted',0
 8,'$file.struct',   'old',    'formatted',0
 9,'$file.${RMV}$RSS',   'unknown','formatted',0
theend
   else
set RSS = val ; if ($?Rsum) set RSS = ''
cat << theend > $def
 6,'$file.outputRMT$updn','unknown','formatted',0
 8,'$file.struct',      'old',    'formatted',0
 9,'$file.${RMV}$RSS$updn',    'unknown','formatted',0
theend
   endif
breaksw

### w2w stuff ###
case w2w:
set exe = w2w$cmplx$para
if ( $para == para ) set dopara=1
if ( $so == so && $updn == '' ) then
  error "w2w: -so is only allowed with -up/-dn"
endif
set soupdn=$so$updn
set w90updn=$updn
if ( $so == so &&               # non-sp SO \
     -s $file.vector$sc$hf$so && ! -s {$file.vector$sc$hf$so}up ) then
  if      ( $updn == up ) then
    set soupdn=so
  else if ( $updn == dn) then
    set soupdn=sodn
  endif
  set updn=
endif
    
cat <<EOF >$def
  5,'$file.inwf',            'old',    'formatted',  0
  6,'$file.outputwf$updn',   'unknown','formatted',  0
  7,'$file.amn$w90updn',     'unknown','formatted',  0
  8,'$file.mmn$w90updn',     'unknown','formatted',  0
  9,'${scratch}$file.vector$sc$hf$soupdn', 'unknown','unformatted',9000
 10,'$file.nnkp',	     'old',    'formatted',  0
 12,'$file.eig$updn',	     'unknown','formatted',  0
 18,'$file.vsp$updn',        'old',    'formatted',  0
 20,'$file.struct',   	     'old',    'formatted',  0
 50,'$file.energy$soupdn',   'old',    'formatted',  0
 51,'$file.fermi$updn'       'old',    'formatted',  0
EOF
breaksw

case wplot:
set exe = wplot$cmplx$para
set soupdn=$updn
if ( $so == so ) set soupdn=
if ( $para == para ) set dopara=1
cat <<EOF >$def
  5,'$file.inwplot',          'old',     'formatted',          0
  6,'$file.outputwplot$updn', 'unknown', 'formatted',          0
  7,'$file.grid',             'unknown', 'formatted',          0
  8,'$file.struct',           'old',     'formatted',          0
 10,'${scratch}$file.vector$sc$hf$so$updn','old','unformatted', 0
 18,'$file.vsp$updn',         'old',     'formatted',          0
 21,'$file.psink$updn',       'unknown', 'formatted',          0
 22,'$file.psiarg$updn',      'unknown', 'formatted',          0
 31,'$file.inwf',             'unknown', 'formatted',          0
 32,'$file.chk$soupdn',         'old',     'unformatted',        0
 90,'$file.tmp$updn',         'unknown', 'unformatted',        0
EOF
set def = ($def $wf)
breaksw

case find_bands:
case findbands:
## adapted from ‘spaghetti’
set typ=1
set updnso=$updn
if ($so == so ) then
    set typ=so
    set updnso=
endif
if ($hf == hf ) then
    set typ=hf
endif
if ($para == para) then
    set cnum=0
    if(-f .processes) then
	@ cnum=`grep -ce "^[0-9][0-9]* :" .processes`
    endif
    #the original file will only be removed if there are sources to concat
    if(-f "$file.output$typ$updnso" && $cnum>0) then
	rm "$file.output$typ$updnso"
    endif
    set count=1
    while($count <= $cnum)
        cat "$file.output$typ${updnso}_$count" >>"$file.output$typ$updnso"
	@ count++
    end
    echo $file.output$typ$updnso created from $cnum parallel files
endif
cat >$def <<EOF
  5,'$file.infind',           'old',    'formatted', 0
  6,'$file.outputfind$updn',  'unknown','formatted', 0
 51,'$file.output$typ$updnso','old',	'formatted', 0
EOF
if ( ! $?efermi ) then
  if ( -s $file.fermi$updn ) then
    set efermi = `cat $file.fermi$updn`
  else
    echo "Warning: Fermi energy not supplied and $file.fermi$updn not found."
    echo "         Continuing with EF=0."
    set efermi = 0
  endif
endif
echo $emin $emax $efermi > $file.infind
set exe = findbands
breaksw

case join_vectorfiles: # for backwards-compatibility
case joinvec:
set exe=joinvec
set dopara=1 para=para
cat <<EOF >$def
  4,'$file.klist',                          'old',    'formatted',  0
 10,'${scratch}$file.vector$sc$hf$so$updn', 'old',    'unformatted',0
 11,'$file.vector$sc$hf$so$updn',	    'unknown','unformatted',0
 20,'$file.struct',   	     		    'old',    'formatted',  0
 50,'$file.energy$so$updn',                 'old',    'formatted',  0
 51,'$file.energy$so$updn',                 'unknown','formatted',  0
EOF
breaksw

case combine_spinfiles:
case w2waddsp:
true >$def
if (-s $file.mmnup ^ -s $file.mmndn) then
  error "w2waddsp: mmn file present for one spin only"
endif
if (-s $file.amnup ^ -s $file.amndn) then
  error "w2waddsp: amn file present for one spin only"
endif
if (! -s $file.amnup && ! -s $file.mmnup) then
  error "w2waddsp: neither mmn nor amn files present -- nothing to do"
endif
if (-s $file.mmnup) then
  cat >>$def <<EOF
 11, '$file.mmnup',  'old',          'formatted', 0
 12, '$file.mmndn',  'old',          'formatted', 0
 13, '$file.mmn',    'unknown',      'formatted', 0
EOF
endif
if (-s $file.amnup) then
  cat >>$def <<EOF
 21, '$file.amnup',  'old',          'formatted', 0
 22, '$file.amndn',  'old',          'formatted', 0
 23, '$file.amn',    'unknown',      'formatted', 0
EOF
endif
set exe=w2waddsp
cp $file.eigup $file.eig
breaksw

case wannier90:
set exe=($argv1)
set def=
breaksw

case shift_energy:
case shifteig:
if ( ! $?efermi ) then
  error 'shifteig: -efermi must be given'
endif
cat >$def <<EOF
 11, '$file.eig$updn',  'old', 'formatted', 0
EOF
set exe=shifteig
set def=($def $efermi)
breaksw

case convert_Hamiltonian:
case convert_hamiltonian:
case convham
cat >$def <<EOF
  4, '$file.klist$band1', 'unknown',    'formatted', 0
  8, '$file.struct',      'old',        'formatted', 0
  9, '${file}_hr.dat',    'old',        'formatted', 0
 10, '$file.hk',    'unknown',    'formatted', 0
EOF
set exe=convham
breaksw
### end w2w   ###

default:
error	command $command does not exist
breaksw

endsw

if ($?deffile_only) then
  if($exe == lapw1para || $exe == lapw1cpara ) then
     $t $bin/$exe -norun $cmplx2 $scratchstring  $def 
  endif
  rm $running
  exit(0)
endif

if ( $para == para && $dopara) then
   if($exe == lapw1para || $exe == lapw1cpara ) then
      set exe = ($exe $scratchstring )
   endif
   if ( $updn == up ) then
      set exe = ($exe -up)
   else if ($updn == dn ) then
      set exe = ($exe -dn)
   endif
   if ($cmplx == c ) then
      set exe = ($exe -c)
   endif
   if ($hf == hf) then
      set exe = ($exe -hf)
   endif
   if ($so == so) then
      set exe = ($exe -so)
   endif
   if ($eece == eece) then
      set exe = ($exe -eece)
   endif
   if ($band1 == '_band') then
      set exe = ($exe -band)
   endif
   if ($nmrhf == 'nmrhf') then
      set exe = ($exe -nmrhf)
   endif
   if ($gw == 'gw') then
      set exe = ($exe -gw)
   endif
endif  	

echo $exe >>$running
$t $bin/$exe $def 

if($status != 0) then
  echo "error: command   $bin/$exe $def   failed"
  if ($?qtl || $?alm || $?almd || $?qdmft || $?band || $?fermi || $?efg || $?emin1 || $?emax1 ) then
    if( -e .oldin2 ) mv .oldin2 $file.in2$cmplx
  endif
  if ($?rxesw ) then
    if( -e .oldint ) mv .oldint $file.int
  endif
  if (-f $running) rm $running
  exit(9)
endif
if ("$exe" == 'pairhess' & $?copy ) then
  echo .minpair copied
  cp .minpair .min_hess
  cp .minpair .minrestart
endif

set lapw2test=`echo $exe | cut -c 1-5`
if("$lapw2test" == 'lapw2') then
    if ($?qtl || $?alm || $?almd || $?qdmft || $?band || $?fermi || $?efg || $?emin1 || $?emax1 ) then
      if( -e .oldin2 ) mv .oldin2 $file.in2$cmplx
    endif
    if(! $?in1orig & ! $?band & ! $?emin1 & ! $?emax1) then
	if( -e $file.scf2$sc$updn && ! -z $file.scf2$sc$updn) then 
	    if($cmplx == 'c') then
              if(! (-e $file.in1$cmplx$sc && ! -z $file.in1$cmplx$sc)) set cmplx
            endif 
	    set eferm=`grep ':FER  :' $file.scf2$sc$updn|cut -f 2 -d=`
	    set efold=`head -1 $file.in1$cmplx${sc}|cut -c11-17 | sed -e "s/[a-zA-Z(,=]//g"`
            if($#efold == 0 ) set efold=0.5
	    set eferm=`echo " if($eferm > $efold) {if ($eferm > $efold + 0.2) {$efold + 0.2} else {$eferm} } else {if($eferm < $efold - 0.2) {$efold - 0.2} else ($eferm*0.75+$efold*0.25) }" | bc -l`    # allow for max change of ef-old +- 0.2, pratt mix
	    set modus=`head -1 $file.in1$cmplx${sc} | cut -c1-5`
	    echo "$modus  EF=$eferm   (WFFIL, WFPRI, ENFIL, SUPWF) " >$file.in1$cmplx${sc}_tmp
	    tail -n +2 $file.in1$cmplx${sc} >> $file.in1$cmplx${sc}_tmp
	    mv $file.in1$cmplx${sc}_tmp $file.in1$cmplx${sc}
	endif
    endif
endif

clear:
#cleanup
  if ($?rxesw ) then
    if( -e .oldint ) mv .oldint $file.int
  endif
if (-f $running) rm $running
exit(0)

error:
rm $running

help:					#help exit 
cat << theend 

USAGE:	$0 PROGRAMNAME [flags] 

PURPOSE:runs WIEN executables:  afminput,aim,arrows,broadening,cif2struct,
      clmaddsub,clmcopy,clminter,convham,conv2prim,dftd3,dipan,dmftproj,
      dstart,eosfit,eosfit6,filtvec,findbands,fleur2wien,hex2rhomb,hf,
      initxspec,irrep,joint,joinvec,kgen,kram,lapw0,lapw1,lapw2,
      lapw3,lapw5,lapw7,lapwdm,lapwso,lcore,lorentz,lstart,mini,mixer,nn,
      optimize,orb,pairhess,plane,rhomb_in5,sgroup,shifteig,spaghetti,
      struct2cif,struct2poscar,struct_afm_check,sumpara,supercell,symmetry,
      symmetso,telnes3,tetra,txspec,wannier90,w2w,w2waddsp,wplot,xspec

FLAGS:
-f FILEHEAD ->	FILEHEAD for path of struct & input-files
-t/-T ->	suppress output of running time
-h/-H ->	help
-d    ->	create only the def-file 
-up   ->	runs up-spin
-dn   ->	runs dn-spin
-du   ->	runs up/dn-crossterm
-sc   ->	runs semicore calculation
-c    ->	complex calculation (no inversion symmetry present)	
-p    ->        run lapw0/1/2/hf/so/dm/optic in parallel (needs .machines or .processes file)
-scratch dir/ ->defines (and makes) $SCRATCH variable
-grr  ->        lapw0 for mBJ or hf (using $file.in0_grr)
-eece ->        for hybrid-functionals (lapw0,lapw2,mixer,orb,sumpara)
-band ->        for lapw1/2/hf bandstructures: uses *klist_band
-orb  ->	runs lapw1 with LDA+U/OP or B-ext correction, mixer with dmat
-it   ->	runs lapw1 with iterative diagonalization
-noHinv   ->	runs lapw1 with iterative diag. without  Hinv
-noHinv0  ->	runs lapw1 with iterative diag. writing new Hinv
-nohns ->	runs lapw1 without HNS
-nmat_only->	runs lapw1 and yields only the matrixsize
-nmr  ->	runs lapw1 in NMR mode
-in1orig  ->	runs lapw2 but does not modify case.in1 
-emin X ->	runs lapw2 with EMIN=X (in $file.in2$cmplx)
-all X Y ->	runs lapw2 with ALL and E-window X-Y (in $file.in2$cmplx)
-qtl  ->        runs lapw2 and calculates QTL 
-alm  ->        runs lapw2 and calculates ALM,BLM 
-almd  ->       runs lapw2 and calculates ALM,BLM in lapw2 for DMFT (Aichhorn)
-qdmft ->       runs lapw2 and calculates charges including DMFT (Aichhorn)
-help_files ->  runs lapw2 and creates case.helpXX files 
-vresp->        runs lapw2 and creates case.vrespval (for TAU/meta-GGA)
-fermi->        runs lapw2 with FERMI switch
-efg  ->        runs lapw2 with EFG switch
-so   ->	runs lapw2/optic/spaghetti with def-file for spin-orbit calc.
-hf  ->         runs lapw2 with Hartree-Fock/hybrid vectors
-diaghf  ->     calculates only the diagonal elements of HF Hamiltonian
-nonself  ->    calculates hf with Ex only (no eigenvalues/vectors)
-fbz   ->	runs kgen and generates a full mesh in the BZ
-fft  ->        runs dstart only up to case.in0_std creation
-super->        runs dstart and creates new_super.clmsum (and not $file.clmsum)
-lcore->        runs dstart with $file.rsplcore (produces $file.clmsc)
-sel  ->        use reduced vector file in lapw7
-settol 0.000x -> run sgroup with different tolerance
-sigma->        run lstart with case.inst_sigma (autogenerated) for diff.dens.
-rxes->         run tetra using case.rxes weight file for RXES-spectroscopy.
-rxesw E1 E2->  run tetra and create case.rxes file for RXES for energies E1-E2
-enefile    ->  spaghetti+tetra with case.energy instead case.qtl (only tot-DOS)
-delta->        run arrows program with difference between two structures
-copy ->        runs pairhess and copies .minpair to .minrestart and .minhess
-telnes  ->     run qtl after generating case.inq based on case.innes
-txt  ->        runs cif2struct using case.txt (see UG)
-pp   ->        run wannier90 in "preprocessing mode"
-wf N ->        run wplot for Wannier function N
-efermi EF  ->  run findbands (unit:Ryd) / shifteig (unit:eV) with Fermi energy EF
-emax Y ->      for findbands
theend
if !($?command) then
  set command
endif

switch ($command)

case afminput:
echo 'x afminput'
breaksw
case aim:
echo 'x aim [-c]'
breaksw
case arrows:
echo 'x arrows |-delta] '
breaksw
case broadening:
echo 'x broadening |-up/dn] '
breaksw
case cif2struct:
echo 'x cif2struct [-txt]'
case clmaddsub:
echo 'x clmaddsub  |-up/dn]'
case clmcopy:
echo 'x clmcopy'
breaksw
case clminter:
echo 'x clminter |-up/dn]'
breaksw
case conv2prim:
echo 'x conv2prim'
breaksw
case struct2poscar:
echo 'x struct2poscar'
breaksw
case dftd3:
echo 'x dftd3'
breaksw
case dipan:
echo 'x dipan'
breaksw
case dmftproj:
echo 'x dmftproj '
breaksw
case dstart:
echo 'x dstart [-up/-dn -c -fft -super -lcore -p]'
breaksw
case eosfit: 
echo 'x eosfit'
breaksw
case eosfit6 
echo 'x eosfit6'
breaksw
case fleur2wien:
echo 'x fleur2wien'
breaksw
case initxspec: 
echo 'x initxspec [-up/-dn]'
breaksw
case irrep: 
echo 'x irrep [-so -up/-dn -p -hf -scratch dir]'
breaksw
case joint: 
echo 'x joint [-up/-dn -hf -scratch dir]'
breaksw
#case join_vectorfiles: 
#echo 'x join_vectorfiles [-up/-dn/-so/soup/-sodn] [-c] case number_of_parallel_files'
#breaksw
case kgen: 
echo 'x kgen [-so -fbz -hf]     (-so switch does not add inversion and uses case.ksym file generated by initso_lapw)'
breaksw
case kram: 
echo 'x kram [-up/-dn]'
breaksw
case lapw0: 
echo 'x lapw0 [-p -eece -grr]'
breaksw
case lapw1: 
echo 'x lapw1 [-c -up/-dn -it -noHinv -noHinv0 -p -nohns -orb -band -nmat_only -nmr -scratch dir]'
breaksw
case lapw2: 
echo 'x lapw2 [-c -up/-dn -p -so -qtl -alm -almd -qdmft -fermi -efg -hf -band -eece -vresp -in1orig -help_files -emin X -all X Y -scratch dir ]'
breaksw
case hf: 
echo 'x hf [-c -up/-dn -p -band -diaghf -gw -nonself -noibz -newklist -redklist -nmrhf -scratch dir]'
breaksw
case lapw3: 
echo 'x lapw3 [-c]'
breaksw
case lapw5: 
echo 'x lapw5 [-c -up/-dn]'
breaksw
case filtvec: 
echo 'x filtvec [-c -up/-dn -hf -scratch dir ]'
breaksw
case lapw7: 
echo 'x lapw7 [-c -up/-dn -sel -hf -scratch dir]'
breaksw
case lapwdm: 
echo 'x lapwdm [ -up -p -c -hf  -scratch dir]'
breaksw
case lapwso: 
echo 'x lapwso [ -up -p -c -orb -scratch dir ]'
breaksw
case lcore: 
echo 'x lcore [-up/-dn]'
breaksw
case lorentz: 
echo 'x lorentz [-up/-dn]'
breaksw
case lstart: 
echo 'x lstart [-sigma]'
breaksw
case mini: 
echo 'x mini'
breaksw
case mixer: 
echo 'x mixer [-eece -orb]'
breaksw
case nn: 
echo 'x nn'
breaksw
case optic: 
echo 'x optic [-c -up/-dn -so -p -hf  -scratch dir]'
breaksw
case optimize: 
echo 'x optimize'
breaksw
case orb: 
echo 'x orb [ -up/-dn/-du -eece]'
breaksw
case pairhess: 
echo 'x pairhess [-copy]'
breaksw
case plane: 
echo 'x plane  ( needs plane.input, see   head $WIENROOT/SRC_trig/plane.f )'
breaksw
case qtl: 
echo 'x qtl [ -up/-dn -so -p -telnes -hf -scratch dir]'
breaksw
case sgroup: 
echo 'x sgroup [-settol 0.000x]  (try 0.001 - 0.0000001)'
breaksw
case spaghetti: 
echo 'x spaghetti [-up/-dn -so -p -hf -enefile]'
breaksw
case struct2cif:
echo 'x struct2cif '
breaksw
case struct_afm_check:
echo 'x struct_afm_check '
breaksw
case sumpara: 
echo 'x sumpara -d [-up/-dn/-dui -eece]     and than '
echo 'sumpara [up/dn]sumpara.def #_of_processors'
breaksw
case supercell: 
echo 'x supercell'
breaksw
case symmetry: 
echo 'x symmetry'
breaksw
case symmetso: 
echo 'x symmetso [-c]'
breaksw
case tetra: 
echo 'x tetra [-up/-dn -rxes  -rxesw E1 E2 -hf -enefile -so]'
breaksw
case txspec: 
echo 'x txspec [-up/-dn]'
breaksw
case xspec: 
echo 'x xspec [-up/-dn]'
breaksw
case telnes3:
echo 'x telnes3 [-up/-dn -hf]'
breaksw
case RMTCheck:
echo 'x RMTCheck [-up/dn -vresp -sum]'
echo '-up/dn flags as normal'
echo '-vresp to analyze this'
echo '-sum   to analyze total density rather than just valence'
breaksw
### w2w stuff ###
case w2w:
echo 'x w2w [-up/-dn -c -so -p]'
breaksw
case wplot:
echo 'x wplot [-up/-dn -c -so -p -wf N]'
breaksw
case find_bands:
case findbands:
echo 'x findbands (-emin e -emax E | -all e E) [-up/-dn -so -hf -efermi EF]'
breaksw
case join_vectorfiles:
case joinvec:
echo 'x joinvec [-up/-dn -so]'
breaksw
case combine_spinfiles:
case w2waddsp:
echo 'x w2waddsp'
breaksw
case wannier90:
echo 'x wannier90 [-up/-dn -so] | -pp'
breaksw
case shift_energy:
case shifteig:
echo 'x shifteig [-up/-dn] -efermi EF'
breaksw
case convert_hamiltonian:
case convert_Hamiltonian:
case convham:
echo 'x convham [-band]'
breaksw
### end w2w   ###

default:
echo 'USE: x -h PROGRAMNAME   for valid flags for a specific program'
breaksw

endsw
if (-e $running) rm $running

exit(1)


More information about the Wien mailing list