From a722da899bb0c18994b8cfff436772bc8a30fafb Mon Sep 17 00:00:00 2001 From: Courtney Peverley Date: Tue, 7 Nov 2023 15:21:48 -0700 Subject: [PATCH] sort sets before writing to files to ease comparison between runs --- scripts/ccpp_suite.py | 4 ++-- scripts/host_cap.py | 4 ++-- scripts/suite_objects.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/ccpp_suite.py b/scripts/ccpp_suite.py index 130a828c..fc8cf1b6 100644 --- a/scripts/ccpp_suite.py +++ b/scripts/ccpp_suite.py @@ -1088,7 +1088,7 @@ def write_var_set_loop(ofile, varlist_name, var_list, indent, ofile.write("allocate({}({}))".format(varlist_name, len(var_list)), indent) # end if - for ind, var in enumerate(var_list): + for ind, var in enumerate(sorted(var_list)): if start_var: ind_str = "{} + {}".format(start_var, ind + start_index) else: @@ -1136,7 +1136,7 @@ def write_req_vars_sub(self, ofile, errmsg_name, errcode_name): ofile.write("\nsubroutine {}({})".format(API.__vars_fname, inargs), 1) # Declare use statements for suite varlist routines mlen = max([len(x.module) for x in self.suites]) - for suite in self.suites: + for suite in sorted(self.suites): mod = f"{suite.module}{' '*(mlen - len(suite.module))}" ofile.write(f"use {mod}, only: {suite.req_vars_subname()}", 2) # end for diff --git a/scripts/host_cap.py b/scripts/host_cap.py index d2b3066f..4809b158 100644 --- a/scripts/host_cap.py +++ b/scripts/host_cap.py @@ -432,7 +432,7 @@ def write_host_cap(host_model, api, module_name, output_dir, run_env): mlen = max([len(x.module) for x in api.suites]) maxmod = max(maxmod, mlen) maxmod = max(maxmod, len(CONST_DDT_MOD)) - for mod in modules: + for mod in sorted(modules): mspc = (maxmod - len(mod[0]))*' ' cap.write("use {}, {}only: {}".format(mod[0], mspc, mod[1]), 1) # End for @@ -530,7 +530,7 @@ def write_host_cap(host_model, api, module_name, output_dir, run_env): for suite in api.suites: mspc = (max_suite_len - len(suite.module))*' ' spart_list = suite_part_list(suite, stage) - for spart in spart_list: + for spart in sorted(spart_list): stmt = "use {}, {}only: {}" cap.write(stmt.format(suite.module, mspc, spart.name), 2) # End for diff --git a/scripts/suite_objects.py b/scripts/suite_objects.py index 5a710548..f6ced28a 100644 --- a/scripts/suite_objects.py +++ b/scripts/suite_objects.py @@ -1787,7 +1787,7 @@ def write(self, outfile, host_arglist, indent, const_mod, # end if # Write out the scheme use statements scheme_use = 'use {},{} only: {}' - for scheme in self._local_schemes: + for scheme in sorted(self._local_schemes): smod = scheme[0] sname = scheme[1] slen = ' '*(modmax - len(smod)) @@ -1853,7 +1853,7 @@ def write(self, outfile, host_arglist, indent, const_mod, 'funcname' : self.name}) # Allocate local arrays alloc_stmt = "allocate({}({}))" - for lname in allocatable_var_set: + for lname in sorted(allocatable_var_set): var = subpart_vars[lname][0] dims = var.get_dimensions() alloc_str = self.allocate_dim_str(dims, var.context) @@ -1886,7 +1886,7 @@ def write(self, outfile, host_arglist, indent, const_mod, item.write(outfile, errcode, indent + 1) # end for # Deallocate local arrays - for lname in allocatable_var_set: + for lname in sorted(allocatable_var_set): outfile.write('deallocate({})'.format(lname), indent+1) # end for # Deallocate suite vars