## helper functions <% def rank(var): """the number of dimensions""" return len(var["shape"]) def shape(var): # convert dims to strings dims = (str(dim) for dim in var["shape"]) return ",".join(dims) %> %for i, var in enumerate(variables): %if rank(var) > 0: case( ${i+1}) allocate(s%${var["name"]}(${shape(var)})) %endif %endfor ## vim: filetype=mako