!call      F_Expr_Sys(f_source, n, 1, i, f_text(i))
subroutine F_Expr_Sys(f_source, n, n_char, k, f_text)
intent(in) :: n,k
intent(out) :: f_text

character(132) f_source

character(132) line, f_text

character(1) k_char, i_char, j_char
character(4) str, str_1*5, str_2*6
character(7) jstr, jstr_1*8, jstr_2*9
character(1) TAB, sp, eq

integer ii(n*n), jj(n*n)

!f_text =' '    ! on input

!Set i(k), j(k):
do i=1,n
do j=1,n
kk =(i-1)*n+j
ii(kk) =i; jj(kk) =j;
enddo
enddo

open(10, file =f_source, status ='old', form ='formatted', iostat =k_open)
if(k_open /=0) RETURN

TAB =char( ichar("	") )
sp =char(32)
eq ='='

! Search in "line" for "f(1) =", OR jf(1,1) =":
IF(n_char ==1) THEN
write(k_char, '(I1)') k
str ='f('//k_char//')'
str_1 =str//'='
str_2 =str//' ='

ELSE
write(i_char,'(I1)') ii(k)
write(j_char,'(I1)') jj(k)
jstr ='jf('//i_char//','//j_char//')'
jstr_1 =jstr//'='
jstr_2 =jstr//' ='

ENDIF


WH_DO: DO WHILE (.not.EOF(10))
read(10, '(a)') line
if(len_trim(line) ==0) cycle WH_DO
if(line(1:1) =='!') cycle WH_DO     ! Primul caracter ='!'

! Replace leading tab(s) by space(s):
i =0
100 i =i+1
if(line(i:i) ==TAB) then
line(i:i) =sp
else
goto 200
endif

goto 100

200 continue
line =adjustl(line)
ll =len_trim(line)

if(line(1:1) =='!') cycle WH_DO     ! Primul caracter ='!'

i_f1 =0; i_f2 =0;
IF(n_char ==1) THEN
i_f1 =index(line(:ll), str_1)
i_f2 =index(line(:ll), str_2)
    f_text =str_2//' ?'

ELSE
i_f1 =index(line(:ll), jstr_1)
i_f2 =index(line(:ll), jstr_2)
    f_text =jstr_2//' ?'
ENDIF

j1 =1
IF(i_f1 /=0 .or. i_f2 /=0) THEN
    if(i_f1 /=0) then
    j1 =i_f1
    else
    j1 =i_f2
    endif

!if(j1 ==0) j1 =1

!f_text =line(:ll)

! Find in line: ";"
j2 =index(line(j1:ll), ';')
if(j2 ==0) then
j2 =ll
else
j2 =j2+j1
endif

f_text =line(j1:j2)

GOTO 500     !EXIT WH_DO
ELSE
!cycle WH_DO
ENDIF

ENDDO WH_DO

IF(n_char ==1) THEN
    f_text =str_2//' ?'
    ELSE
    f_text =jstr_2//' ?'
    ENDIF
500 close(10)

END
