Illegal fix ave/correlate command

I modified the example script Sample thermal conductivity of Argon for sw silicon. I am getting the error:
“Illegal fix ave/correlate command”. How can I fix this?

Here is my input script:

Input Script for thermal conductivity of Silicon

units metal
variable T equal 1000
variable V equal vol
variable p equal 20 # correlation length
variable s equal 10 # sample interval
variable d equal $p*$s # dump interval

convert from LAMMPS metal units to SI

variable kB equal 1.3806504e-23 # [J/K] Boltzmann
variable eV2J equal 1.602176565e-19
variable A2m equal 1.0e-10
variable ps2s equal 1.0e-12
variable convert equal {eV2J}*{eV2J}/{ps2s}/{A2m}

setup problem

dimension 3
boundary p p p
atom_style atomic
lattice diamond 5.430710 orient x 1 0 0 orient &
y 0 1 0 orient z 0 0 1
region box block 0 5 0 5 0 5
create_box 1 box
create_atoms 1 box
mass 1 28.085
pair_style sw
pair_coeff * * Si.sw Si
thermo $d

equilibration and thermalization

velocity all create $T 102485 mom yes rot yes dist gaussian
fix NVT all nvt temp $T $T 10 drag 0.2
run 8000

thermal conductivity calculation, switch to NVE if desired

unfix NVT
fix NVE all nve

reset_timestep 0
compute myKE all ke/atom
compute myPE all pe/atom
compute myStress all stress/atom virial
compute flux all heat/flux myKE myPE myStress
variable Jx equal c_flux[1]/vol
variable Jy equal c_flux[2]/vol
variable Jz equal c_flux[3]/vol

fix JJ all ave/correlate $s $p d c_flux[1] c_flux[2] & c_flux[3] type auto ave running file J0Jt.dat variable scale equal {convert}/${kB}/$T/$T/$V*s*0.001 variable k11 equal trap(f_JJ[3])*{scale}
variable k22 equal trap(f_JJ[4])*{scale} variable k33 equal trap(f_JJ[5])*{scale}
thermo_style custom step temp v_Jx v_Jy v_Jz v_k11 v_k22 &

run 100000
variable k equal (v_k11+v_k22+v_k33)/3.0
variable ndens equal count(all)/vol

print “average conductivity: $k[W/mK] @ T K, {ndens} /A^3”



If you didn’t modify this line:

fix JJ all ave/correlate $s $p $d c_flux[1] c_flux[2] &
c_flux[3] type auto ave running file J0Jt.dat

then my guess would be the 2-line format is messed
up, e.g. you have an extra space after the &, or some
funny new-line character - try putting that entire command
on one line.