## 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): case( ${i+1}) %if rank(var) > 0: if (associated(s%${var["name"]})) deallocate(s%${var["name"]}) allocate(s%${var["name"]}(${shape(var)})) %endif %endfor ## vim: filetype=mako