# laypick.inc - Select specific layer from current model

SET isf  ="{USER}.sav" ISFILE
IF {isf} = 1
   INCLUDE "{USER}.sav"     # pick up previously saved values

REQUIRE modparam.inc
INCLUDE modparam.inc        # collect layer names and model params
SAVE "{USER}.sav"           # update save file


PARAMETER Layer = " " LT \
 {LAYLIST}, ALL \
 "Select single layer, or ALL"
SAVE "{USER}.sav"


IF {Layer} = ALL      # for ALL, specify complete range of layers
   BEGIN
   SET Lay_1 = 1
   SET Lay_n = {NUMLAY}
   END
ELSE
   BEGIN
   SET ILAY = 1       # otherwise, find specific layer that was selected
   WHILE {ILAY} <= {NUMLAY}
      BEGIN
      IF {Layer} = {LAY{ILAY}}
         BEGIN
         SET Lay_1 = {ILAY}
         SET Lay_n = {ILAY}
         END
      SET ILAY = {ILAY} 1 +
      END
   END


SET ILAY = 1
WHILE {ILAY} <= {NUMLAY}
   BEGIN
   SET has_l_{LAY{ILAY}} = NO    # set default parameters
   SET ILAY = {ILAY} 1 +
   END

SET islim = "limparam.inc" ISFILE
IF {islim} > 0
   BEGIN
   INCLUDE limparam.inc          # override with specifics
   END


SAVE "{USER}.sav"     # store updated values
