Nested loops in ngspice
Your loop is wrong - you are not resetting g_act to g_start in the inner loop.
Try this:
(I've commented out the alter and op statements, you can add them back in with your circuit)

 *Loop Test
 .CONTROL
 let start_d = 0
 let delta_d = 0.5
 let stop_d = 1.81
 let start_g = -3
 let delta_g = 0.5
 let stop_g = 0.01
 let d_act = start_d
 let g_act = start_g

 while d_act le stop_d
      *alter vd0 dc d_act
     let g_act = start_g
      while g_act &lt; stop_g
         *alter vg0 dc g_act
         *op
         echo run sim with d_act:"$&amp;d_act" and g_act:"$&amp;g_act"
         let g_act = g_act + delta_g
         end
 let d_act = d_act + delta_d
 end
 .ENDC
 .END