# slope of the free surface
Define ALPHA 1e-4
# slope of the thermoclime
Define ALPHAT 1e-3

1 0 GfsRiver GfsBox GfsGEdge {} {
    Layers NL
    Refine LEVEL
    InitMask {} (y < RATIO*(0.5 - 1./pow(2,LEVEL)))
    VariableTracer DRHO
    PhysicalParams {
	L = RATIO g = 1./(ALPHA*RE)
	alpha = 1./(1. + DRHO)
    }
    Init {} {
	P = 1
	DRHO = (z > 0.75 ? 0 : ALPHA/ALPHAT)*P/NL
    }
    Time { end = 100 }
    OutputSimulation { start = end } end-NL.txt { format = text }
    OutputSimulation { start = end } {
	awk '{
  	  nl = NL;
          if ($1 == "#") {
            for (i = 2; i <= NF; i++) {
              split($i,a,":")
              if (a[2] == "U0")
                start = a[1];
            }
          }
          else if ($1 == RATIO/2**(LEVEL + 1)) {
            dz = $4/nl;
  	    for (i = 0; i < nl; i++) {
              z = dz*(0.5+i)
              print $1,$2,z,$(start+i)/dz
            }
          }
        }' > uprof-NL
    } { format = text }
} {
    # vertical viscosity
    nu = 1./RE
    # Neumann condition at the surface
    dut = 1.
}
GfsBox {
    right = Boundary
    left = Boundary
}