Index: /issm/trunk/src/m/qmu/preqmu.m
===================================================================
--- /issm/trunk/src/m/qmu/preqmu.m	(revision 6614)
+++ /issm/trunk/src/m/qmu/preqmu.m	(revision 6615)
@@ -43,6 +43,6 @@
 
 %expand variables and responses
-variables=expandvariables(md,md.variables);
-responses=expandresponses(md,md.responses);
+variables=expandvariables(md,variables);
+responses=expandresponses(md,responses);
 
 %go through variables and responses, and check they don't have more than md.npart values. Also determine numvariables and numresponses{{{1
@@ -52,6 +52,8 @@
 	field_name=variable_fieldnames{i};
 	fieldvariables=variables.(field_name);
-	if numel(fieldvariables)>md.npart,
-		error('preqmu error message: one of the expanded variables has more values than the number of partitions (setup in md.npart)');
+	for j=1:numel(fieldvariables)
+		if strncmpi(fieldvariables(j).descriptor,'scaled_',7) && str2int(fieldvariables(j).descriptor,'last')>md.npart,
+			error('preqmu error message: one of the expanded variables has more values than the number of partitions (setup in md.npart)');
+		end
 	end
 	numvariables=numvariables+numel(variables.(field_name));
@@ -63,6 +65,8 @@
 	field_name=response_fieldnames{i};
 	fieldresponses=responses.(field_name);
-	if numel(fieldresponses)>md.npart,
-		error('preqmu error message: one of the expanded responses has more values than the number of partitions (setup in md.npart)');
+	for j=1:numel(fieldresponses)
+		if strncmpi(fieldresponses(j).descriptor,'scaled_',7) && str2int(fieldresponses(j).descriptor,'last')>md.npart,
+			error('preqmu error message: one of the expanded responses has more values than the number of partitions (setup in md.npart)');
+		end
 	end
 	numresponses=numresponses+numel(responses.(field_name));
@@ -76,15 +80,21 @@
 %build a list of variables and responses descriptors. the list is not expanded. {{{1
 variabledescriptors={};
-variable_fieldnames=fieldnames(md.variables);
+variable_fieldnames=fieldnames(md.variables(options.ivar));
 for i=1:length(variable_fieldnames),
 	field_name=variable_fieldnames{i};
-	variabledescriptors{end+1}=md.variables.(field_name).descriptor;
+	fieldvariables=md.variables(options.ivar).(field_name);
+	for j=1:numel(fieldvariables)
+		variabledescriptors{end+1}=fieldvariables(j).descriptor;
+	end
 end
 
 responsedescriptors={};
-response_fieldnames=fieldnames(md.responses);
+response_fieldnames=fieldnames(md.responses(options.iresp));
 for i=1:length(response_fieldnames),
 	field_name=response_fieldnames{i};
-	responsedescriptors{end+1}=md.responses.(field_name).descriptor;
+	fieldresponses=md.responses(options.iresp).(field_name);
+	for j=1:numel(fieldresponses)
+		responsedescriptors{end+1}=fieldresponses(j).descriptor;
+	end
 end
 %}}}
