The script is below between the horizontal rules.
echo making land mask emath expr_vars="lsmask" \ expression="x1>0" \ var_name="land" \ var_units="" \ var_type="fl" \ Master land.mask echo making water mask emath expr_vars="lsmask" \ expression="x1<1" \ var_name="water" \ var_units="" \ var_type="fl" \ Master water.mask echo assembling mask file assemble include_vars="land water" \ extend_names="no" \ instantiate="yes" \ land.mask water.mask mask.file \rm land.mask water.mask for I in `ls $1*.reg | cut -c1-14 | sort | uniq` do echo masking $I.reg emath2 file1_vars="avhrr_ch4" \ file2_vars="land" \ expression="x1/x2" \ var_name="avhrr_ch4" \ var_type="fl" \ var_units="" \ $I.reg mask.file land4 emath2 file1_vars="avhrr_ch5" \ file2_vars="land" \ expression="x1/x2" \ var_name="avhrr_ch5" \ var_type="fl" \ var_units="" \ $I.reg mask.file land5 emath2 file1_vars="avhrr_ch4" \ file2_vars="water" \ expression="x1/x2" \ var_name="avhrr_ch4" \ var_type="fl" \ var_units="" \ $I.reg mask.file water4 emath2 file1_vars="avhrr_ch5" \ file2_vars="water" \ expression="x1/x2" \ var_name="avhrr_ch5" \ var_type="fl" \ var_units="" \ $I.reg mask.file water5 echo assembling assemble include_vars="avhrr_ch4 avhrr_ch5" \ extend_names="no" \ instantiate="yes" \ land4 land5 $I.land assemble include_vars="avhrr_ch4 avhrr_ch5" \ extend_names="no" \ instantiate="yes" \ water4 water5 $I.water \rm land4 land5 water4 water5 echo cutting out data sample point_file="outline" \ points_are="outline" \ include_vars="avhrr_ch4 avhrr_ch5" \ output_coords="yes" \ $I.land temp_land sample point_file="outline" \ points_are="outline" \ include_vars="avhrr_ch4 avhrr_ch5" \ output_coords="yes" \ $I.water temp_water echo writing temp ascii files expasc include_vars="latitude longitude avhrr_ch4 avhrr_ch5" \ all_same_dim="" \ list_dims="no" \ temp_land temp_land.asc expasc include_vars="latitude longitude avhrr_ch4 avhrr_ch5" \ all_same_dim="" \ list_dims="no" \ temp_water temp_water.asc echo removing null data points sed '/\*/d' temp_water.asc >$I.water.asc sed '/\*/d' temp_land.asc > $I.land.asc \rm temp_water temp_water.asc temp_land temp_land.asc done