NEQNF over only some variables

I want to solve a nonlinear system of equations F(x,y) = 0, where y is a fixed parameter and the solving happens only through manipulation of x.

As a simple example, let's say the equation is

2*x + y = 0

I want to solve for x while specifying various values of y.

It seems like NEQNF can do this if you pass it a function FCN whose output is 1-dimensional but pass a 2-dimensional output vector X and a 2-dimensional guess vector XGUESS which has as its second element the value for y. But am I guaranteed that NEQNF will not manipulate y in its final solution?

Below is Fortran code that solves the above equation for y = 4:

program test

use neqnf_int

real :: sols(2), guess(2), err

external fcn

guess(1) = 15.0

guess(2) = 4.0

call neqnf(fcn, sols, xguess = guess, fnorm = err)

print*, sols, err

end

subroutine fcn(x, f, n)

integer :: n

real :: x(2), f(1)

f(1) = 2*x(1) - x(2)

print*, x

end subroutine

The program's output, which shows the intermediate guesses on the way to the solution, is as follows:

15.00000000 4.000000000

15.00517941 4.000000000

15.00000000 4.001380920

2.001006126 4.000000000

2.000000000 4.000000000

2.000000000 4.000000000 0.0000000000E+00

Notice that it gets the answer right, but in the third iteration, it manipulates y! This makes me nervous that sometimes, I will get solutions that don't preserve the original value of y. Is there any way to guarantee that y will be untouched?