Exemple #1
0
    def merge(self):
        """
        Run gretel on file that need it
        """
        # No merging to do
        if self.ncsize <= 1:
            return
        # ~~> Path
        bin_path = path.join(self.cfg['root'], 'builds', self.cfgname, 'bin')
        execmd = get_gretel_cmd(bin_path, self.cfg)\
                  .replace('<root>', self.cfg['root'])
        # ~~> Run GRETEL
        chdir(self.working_dir)
        # Global GEO file
        cas = self.cas
        g_geo, g_fmt_geo, g_bnd = get_glogeo(cas)
        run_recollection(\
                execmd, cas, g_geo, g_fmt_geo, g_bnd,
                self.ncsize)

        # Running it for coupled steering files
        for cas_cpl in self.cpl_cases.values():
            g_geo, g_fmt_geo, g_bnd = get_glogeo(cas_cpl)
            run_recollection(\
                    execmd, cas_cpl, g_geo, g_fmt_geo, g_bnd,
                    self.ncsize)
Exemple #2
0
def main():
    """ Main function of gretel """
    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n' + 72 * '~' + '\n')
    parser = argparse.ArgumentParser(\
            description='Run the merging step (gretel)')
    parser = add_config_argument(parser)
    parser.add_argument(\
              "--input-file",
              dest="input_file",
              default='',
              help="Name of gretel parameter file (GRETEL.PAR). "\
                     "This option will surcharge all the others")
    parser.add_argument(\
              "--geo-file",
              dest="geo_file",
              default='T2DGEO',
              help="Name of the geometry file associated with the "\
                     "file to be merged")
    parser.add_argument(\
              "--geo-file-format",
              dest="geo_file_fmt",
              default='SERAFIN',
              help="Format of the geometry file(SERAFIN,SERAFIND or MED), "\
                     "default is SERAFIN")
    parser.add_argument(\
              "--res-file",
              dest="res_file",
              default='T2DRES',
              help="Name of the file to be merged")
    parser.add_argument(\
              "--res-file-format",
              dest="res_file_fmt",
              default='SERAFIN',
              help="Format of the geometry file(SERAFIN,SERAFIND or MED), "\
                     "default is SERAFIN")
    parser.add_argument(\
              "--bnd-file",
              dest="bnd_file",
              default='T2DCLI',
              help="Name of the boundary file")
    parser.add_argument(\
              "--ncsize",
              dest="ncsize",
              default=8,
              help="Number of partitions (should be equal to number of "\
                     "parallel processors), default is 8")
    parser.add_argument(\
              "--nplan",
              dest="nplan",
              default=0,
              help="Number of horizontal levels ,default is 0")
    args = parser.parse_args()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    update_config(args)

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Works for all configurations unless specified ~~~~~~~~~~~~~~~

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Reporting errors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Works for all configurations unless specified ~~~~~~~~~~~~~~~
    CFGS.compute_execution_info()

    if args.input_file != "":
        with open(args.input_file, 'r') as f:
            geo_file = f.readline().strip('\n')
            geo_file_fmt = f.readline().strip('\n')
            bnd = f.readline().strip('\n')
            res_file = f.readline().strip('\n')
            res_file_fmt = f.readline().strip('\n')
            ncsize = f.readline().strip('\n')
            nplan = f.readline().strip('\n')
    else:
        geo_file = args.geo_file
        geo_file_fmt = args.geo_file_fmt
        bnd = args.bnd_file
        res_file = args.res_file
        res_file_fmt = args.res_file_fmt
        ncsize = args.ncsize
        nplan = args.nplan

    # Getting partel command from configuration
    pbin = path.join(CFGS.get_root(), 'builds', CFGS.cfgname, 'bin')
    grecmd = get_gretel_cmd(pbin, CFGS.configs[CFGS.cfgname])
    # Running paritionning

    run_gretel(grecmd, res_file, res_file_fmt, geo_file, geo_file_fmt, bnd,
               ncsize, nplan, False)

    print('\n\nMy work is done\n\n')
    sys.exit(0)