if (FSTEADY<>0) then:
  for compv from 1 to NK do:
    utzz[compv]:=0:
    for iv from 1 to 3 do:
       dutdxzz[compv,iv]:=0:
    od:
  od:
fi:


if (FMINIMIZE=0) then:

  for compv from 1 to NK do:
    vzz[compv]:=0:
    for iv from 1 to 3 do:
       dvdxzz[compv,iv]:=0:
    od:
  od:

  for class from 0 to 3 do:
    for compv from 1 to NK do:
      vzz[compv]:=1:
      HF0[compv,class]:=eval(IM[class]):
      vzz[compv]:=0:
      for iv from 1 to class do:
        dvdxzz[compv,iv]:=1:
        HF1[compv,class,iv]:=eval(IM[class]):
        dvdxzz[compv,iv]:=0:
      od:
    od:
  od:
else:
    
  for class from 0 to 3 do:
    for compv from 1 to NK do:
      HF0[compv,class]:=eval(diff(IM[class],uzz[compv])):
      for iv from 1 to class do:
        HF1[compv,class,iv]:=eval(diff(IM[class],dudxzz[compv,iv])):
      od:
    od:
  od:

fi:

for class from 0 to 3 do:
  for compv from 1 to NK do:
    for compu from 1 to NK do:

       HF0U[compv,compu,class]:=diff(HF0[compv,class],uzz[compu]):
       if (FSTEADY<>0) then:
         HF0UT[compv,compu,class]:=0:
       else:
         HF0UT[compv,compu,class]:=diff(HF0[compv,class],utzz[compu]):
       fi:

       for iu from 1 to class do:
        HF0UX[compv,compu,class,iu]:=diff(HF0[compv,class],dudxzz[compu,iu]):
        if (FSTEADY<>0) then:
         HF0UTX[compv,compu,class,iu]:=0:
	else:
         HF0UTX[compv,compu,class,iu]:=diff(HF0[compv,class],dutdxzz[compu,iu]):
        fi:
       od:

       for iv from 1 to class do:
        HF1U[compv,compu,class,iv]:=diff(HF1[compv,class,iv],uzz[compu]):
        if (FSTEADY<>0) then:
           HF1UT[compv,compu,class,iv]:=0:
        else:
           HF1UT[compv,compu,class,iv]:=diff(HF1[compv,class,iv],utzz[compu]):
        fi:
       od:

       for iv from 1 to class do:
         for iu from 1 to class do:
	   HF1UX[compv,compu,class,iv,iu]:=diff(HF1[compv,class,iv],dudxzz[compu,iu]):
           if (FSTEADY<>0) then:
	      HF1UTX[compv,compu,class,iv,iu]:=0:
           else:
	      HF1UTX[compv,compu,class,iv,iu]:=diff(HF1[compv,class,iv],dutdxzz[compu,iu]):
           fi:
         od:
       od:

    od:
  od:
od:

SYM:=VEMtrue:
for class from 0 to 3 do:
  for compv from 1 to NK do:
    for compu from 1 to NK do:

       if (simplify(HF0U[compu,compv,class]-HF0U[compv,compu,class])
                                                      <>0) then :
         SYM:=VEMfalse: 
       fi:

       if (simplify(HF0UT[compu,compv,class]-HF0UT[compv,compu,class])
                                                      <>0) then :
         SYM:=VEMfalse: 
       fi:

       for i from 1 to class do:
         if (simplify(HF0UX[compv,compu,class,i]-HF1U[compu,compv,class,i])
                                                      <>0) then :
           SYM:=VEMfalse: 
         fi:
         if (simplify(HF0UTX[compv,compu,class,i]-HF1UT[compu,compv,class,i])
                                                      <>0) then :
           SYM:=VEMfalse: 
         fi:
       od:

       for iv from 1 to class do:
        for iu from 1 to class do:
	   if (simplify(HF1UX[compu,compv,class,iu,iv]-
	                HF1UX[compv,compu,class,iv,iu])<>0) then :
             SYM:=VEMfalse: 
           fi:
	   if (simplify(HF1UTX[compu,compv,class,iu,iv]-
	                HF1UTX[compv,compu,class,iv,iu])<>0) then :
             SYM:=VEMfalse: 
	   fi:
        od:
       od:

    od:
  od:
od:

for k from 1 to NK do:
  if (DB[k]<>0) then
    fortran([B[k]=DB[k]],filename=`/tmp/vemuserb.%EXT_`):
  fi:
od:

for k from 1 to NK do:
  if (U0[k]<>0) then
    fortran([U0ZZ[k]=U0[k]],filename=`/tmp/vemuseru0.%EXT_`):
  fi:
od:


for class from 0 to 3 do:
  for compv from 1 to NK do:

    L2_old:=[]:

    if (HF0[compv,class]<>0) then
      L2_new:=[op(L2_old),F0[compv,class]=HF0[compv,class]]:
      L2_old:=L2_new:
    fi:

    for iv from 1 to class do:
     if (HF1[compv,class,iv]<>0) then
         L2_new:=[op(L2_old),F1[compv,class,iv]=HF1[compv,class,iv]]:
	 L2_old:=L2_new:
      fi:
    od:

    fortran(L2_old,optimized,filename=`/tmp/vemuserf.%EXT_`):

  od:
od:

for class from 0 to 3 do:
  for compv from 1 to NK do:
    for compu from 1 to NK do:

       L3_old:=[]:
       L4_old:=[]:

       if (HF0U[compv,compu,class]<>0) then
         L3_new:=[op(L3_old),F0U[compv,compu,class]=HF0U[compv,compu,class]]:
	 L3_old:=L3_new:
       fi:
       if (HF0UT[compv,compu,class]<>0) then
         L4_new:=[op(L4_old),F0UT[compv,compu,class]=HF0UT[compv,compu,class]]:
	 L4_old:=L4_new:
       fi:

       for iu from 1 to class do:
         if (HF0UX[compv,compu,class,iu]<>0) then
           L3_new:=[op(L3_old),F0UX[compv,compu,class,iu]=HF0UX[compv,compu,class,iu]]:
	   L3_old:=L3_new:
         fi:
         if (HF0UTX[compv,compu,class,iu]<>0) then
           L4_new:=[op(L4_old),F0UTX[compv,compu,class,iu]=HF0UTX[compv,compu,class,iu]]:
	   L4_old:=L4_new:
         fi:
       od:
 
       for iv from 1 to class do:
         if (HF1U[compv,compu,class,iv]<>0) then
           L3_new:=[op(L3_old),F1U[compv,compu,class,iv]=HF1U[compv,compu,class,iv]]:
	   L3_old:=L3_new:
         fi:
         if (HF1UT[compv,compu,class,iv]<>0) then
           L4_new:=[op(L4_old),F1UT[compv,compu,class,iv]=HF1UT[compv,compu,class,iv]]:
	   L4_old:=L4_new:
         fi:
       od:

       for iu from 1 to class do:
         for iv from 1 to class do:
           if (HF1UX[compv,compu,class,iv,iu]<>0) then
             L3_new:=[op(L3_old),F1UX[compv,compu,class,iv,iu]=
		  HF1UX[compv,compu,class,iv,iu]]:
             L3_old:=L3_new:
           fi:
           if (HF1UTX[compv,compu,class,iv,iu]<>0) then
             L4_new:=[op(L4_old),F1UTX[compv,compu,class,iv,iu]=
		  HF1UTX[compv,compu,class,iv,iu]]:
             L4_old:=L4_new: 
          fi:
         od:
       od:

       fortran(L3_old,optimized,filename=`/tmp/vemusrfu.%EXT_`):
       fortran(L4_old,optimized,filename=`/tmp/vemusrfut.%EXT_`):

    od:
  od:
od:
fortran([LSYM=SYM],filename=`/tmp/vemusermasks.%EXT_`):
quit:
