variable command in then statement of if command

Is it possible to used a variable command after an if command is said to be true. I want to save the current timestep at which the if statement is true

if " ${time_step} >= 90 " then “variable timestep equal “step””

I get this error ERROR: Input line quote not followed by whitespace

If I try it this way

if " ${time_step} >= 90 " then "variable timestep equal 1 "

I get that “illegal variable substitution”

Thanks.

Is it possible to used a variable command after an if command is said to be
true. I want to save the current timestep at which the if statement is true

if " ${time_step} >= 90 " then "variable timestep equal "step""

I get this error ERROR: Input line quote not followed by whitespace

you cannot have quotes within quotes without escaping them. they don't
seem needed here anyway.

If I try it this way

if " ${time_step} >= 90 " then "variable timestep equal 1 "

is there a valid variable called "time_step" at this point?
you can use the "info variables" command to dump a list of all
variables defined at that specific point in the input.

axel.

Thank you for your reply. However, I do need the timestep at which the ‘if’ statement becomes true. I will attach the full portion of the script to give a clearer picture.

read_restart restart.mpiio

variable dump equal 300
variable imax equal 72
variable i loop {imax}* *variable jmax equal 100* *variable j loop {max}

#------------------------DEPOSIT N2----------------------------------
reset_timestep 0
molecule nitrogen nitrogen.dat
fix ensemble all nve

label simulation
reset_timestep 0
fix print3 n2 print 30 “((c_Vx)*100000) ((c_Vy)*100000) ((c_Vz)*100000) (c_Xcoord) (c_Ycoord) ((c_Zcoord)-2.8)” file {r}_{j}.dat screen no

#random velocity generation for nitrogen molecule#
variable phi_ equal random(0,3.14159,123456789)
variable phi equal ${phi_}
variable theta equal 0.34906585 #20Degrees
variable velx equal “-10.01453cos(v_theta)cos(v_phi)"
variable vely equal "-1
0.01453cos(v_theta)sin(v_phi)"
variable velz equal "-1
0.01453
sin(v_theta)”

print “phi equals {phi} in radians"* *print "Vx = {velx}”
print “Vy = {vely}"* *print "Vz = {velz}”

#deposition of nitrogen on substrate#
fix 4 n2 deposit 1 1 1 2178351 mol nitrogen region addatoms vx {velx} {velx} vy {vely} {vely} vz {velz} {velz} units box

variable zc equal “c_Zcoord”
variable time_step equal “step”
label loopstart
run 50

#checking if z-coordinate goes over 8Å over the substrate surface or simulation time exceeds 9ps in which case it is terminated and new trajectory is started#

if “{zc} > 12.0 || {time_step} >= 36000 + ${prev_timestep}” then “variable prev_timestep equal “step”” “delete_atoms group n2” “next j” “jump SELF simulation” else “next i” “jump SELF loopstart”

Now, I am checking for the ‘if’ condition every 500 timesteps. But since I cannot “reset_timestep 0” after the label si elation, I need to come up with a way to store the timestep at which the if statement is evaluated to be true so that when the number of time steps reaches 36000 for each time the trajectory simulation is restarted, I can ensure that the whole simulation doesn’t exceed 36000 steps. Some cases go on indefinitely so this is required.

Thank you for your help.

Actually, I figured a way to do it. Thank you again for your time.