Example #1
0
def main():
    """ Main function of partel.py """
    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n' + 72 * '~' + '\n')
    parser = argparse.ArgumentParser(description='Translate a keyword')
    parser = add_config_argument(parser)
    parser.add_argument("module",
                        choices=[
                            'postel3d', 'telemac2d', 'telemac3d', 'tomawac',
                            'artemis', 'sisyphe', 'waqtel', 'khione', 'stbtel'
                        ],
                        help="Name of the module for which to translate")
    parser.add_argument(
        "cas_file",
        help="Name of the steering file to translatefile to be partitionned")
    args = parser.parse_args()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    update_config(args)
    cfg = CFGS.configs[CFGS.cfgname]
    CFGS.compute_execution_info()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # Searching for the dictionary associated with the steering case
    dico_file = path.join(cfg['MODULES'][args.module]['path'],
                          args.module + '.dico')
    if not path.exists(dico_file):
        raise TelemacException(\
            'Could not find the dictionary file: {}'.format(dico_file))
    cas = TelemacCas(args.cas_file, dico_file, check_files=False)

    cas.write_fr_gb()

    print('\n\nMy work is done\n\n')
    sys.exit(0)
def main():
    """
        Main function of doxygenTELEMAC
    """
    bypass = False  # /!\ Temporary bypass for subroutine within programs

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n'+'~'*72+'\n')
    parser = ArgumentParser(\
        formatter_class=RawDescriptionHelpFormatter,
        description=('''\n
Generate the DOXYGEN documentation of the whole TELEMAC system.
        '''),
        usage=' (--help for help)\n---------\n       =>  '\
                '%(prog)s [options] \n---------')
    parser = add_config_argument(parser)
    parser.add_argument(\
        "-d", "--doxydir",
        dest="doxyDir", default='',
        help="specify the root, default is taken from config file")
    parser.add_argument(\
        "-m", "--modules",
        dest="modules", default='',
        help="specify the list modules, default is taken from config file")
    options = parser.parse_args()


# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    update_config(options)

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ banners ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    svn_banner(CFGS.get_root())

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Works for one configuration only ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Works for only one configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cfg = CFGS.configs[CFGS.cfgname]

    # still in lower case
    if options.modules != '':
        cfg['modules'] = options.modules.replace(',', ' ')\
                                        .replace(';', ' ')\
                                        .replace('.', ' ')
    if options.doxyDir == '':
        cfg.update({'doxydocs':path.join(cfg['root'],
                                         'documentation',
                                         CFGS.cfgname)})
    else:
        cfg.update({'doxydocs':options.doxyDir})
    if not path.isdir(cfg['doxydocs']):
        create_directories(cfg['doxydocs'])
    # parsing for proper naming
    CFGS.compute_doxy_info()
    print('\n\nScanning the source code for:\n'+'~'*72+'\n')
    CFGS.light_dump()

    # ~~ Scans all source files to build a relation database ~~
    fic, _, _, _, _, _, _, racine = scan_sources(CFGS.cfgname, cfg, bypass)

    # ~~ Scann all source files to update Doxygen ~~~~~~~~~~~~~~~~
    for mod in fic:
        print('\nCreating the DOXYGEN headers for ' + mod + '\n'+'~'*72+'\n')
        for ifile in fic[mod]:

            # ~~ Read the content of the source file ~~~~~~~~~~~~
            ilines = get_file_content(ifile)
            # ~~ Update its Doxygen content ~~~~~~~~~~~~~~~~~~~~~
            olines = create_doxygen(ifile, ilines, mod, racine)
            # ~~ Make sure the distination exists ~~~~~~~~~~~~~~~
            ofile = ifile.replace(cfg['root'], cfg['doxydocs'])
            create_directories(path.dirname(ofile))
            # ~~ Write the content of the source file ~~~~~~~~~~~
            put_file_content(ofile, olines)

    # ~~ Run Doxygen ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\nNow running DOXYGEN within ' + cfg['doxydocs'] + '\n'+'~'*72+'\n')
    chdir(cfg['doxydocs'])
    if not path.exists(cfg['cmd_doxygen']):
        raise Exception('Do not know where to find {}\n '
                        '... you can correct this through the key '
                        'cmd_doxygen in your configuration file'
                        ''.format(cfg['cmd_doxygen']))
    if sp.call([cfg['cmd_doxygen']]):
        raise Exception

    # ~~ Scan all HTML files and replace template in phases
    replace_doxygen(path.join(cfg['doxydocs'], 'html'))


# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Jenkins' success message ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nMy work is done\n\n')

    sys.exit(0)
            if clean:
                chdir(module_dir + sep + test_case)
                shutil.rmtree(module_dir + sep + test_case + sep + 'tmp')

        fichier.write('my work is done ' + '\n')


if __name__ == "__main__":
    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n' + 72 * '~' + '\n')
    PARSER = ArgumentParser(\
        description='Make the validation of Telemac-Mascaret API '\
            'and/or executable using the API')
    PARSER = add_config_argument(PARSER)
    PARSER.add_argument(\
        "-m", "--module",
        dest='modules',
        default="telemac2d",
        help="specify the list of folder to validate seprated by ,")
    PARSER.add_argument(\
        "--clean",
        action="store_true",
        dest="clean",
        default=False,
        help="Remove tmp folders")
    PARSER.add_argument(\
        "-n", "--cnsize",
        dest='ncsize',
        default=4,
def main():
    """ Main function of compileTELEMAC """

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n' + 72 * '~' + '\n')
    parser = ArgumentParser(
        formatter_class=RawDescriptionHelpFormatter,
        description=('''\n
Compile the TELEMAC system:\n
1. rescan the tree dependencies if necessary
2. check which files need re-compilation
3. create object files, libraries, executable, and other binaries
    depending on your configuration settings
Work with all active configurations.
        '''))

    parser = add_config_argument(parser)
    parser.add_argument(
        "-m", "--modules", metavar="modules",
        dest="modules", default='',
        help="specify the list modules . separated, default is taken from config file")
    parser.add_argument(
        "-b", "--bypass", action="store_true",
        dest="bypass", default=False,
        help="will bypass execution failures and try to carry on "
             "(final report at the end)")
    parser.add_argument(
        "--rescan", action="store_true",
        dest="rescan", default=False,
        help="will redo the scan of sources for an update of "
             "all the cmdf files")
    parser.add_argument(
        "--clean", action="store_true",
        dest="cleanup", default=False,
        help="will erase all object, executable libraries from folder "
             "on the selected configs/modules")
    parser.add_argument(
        "-j", type=int,
        dest="ncsize", default=0,
        help="set the number of core used for the parallel "
             "compilation of objects")
    parser.add_argument(
        "-v", "--verbose", action="store_true",
        dest="verbose", default=False,
        help="If given will print every command")
    options = parser.parse_args()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    update_config(options)

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ banners ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    svn_banner(CFGS.get_root())

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Separately dealing with rescan for all configs ? ~~~~~~~~~~~~
    for cfgname in CFGS.configs:
        # Setting configuration name
        CFGS.cfgname = cfgname
        # Getting configuration
        cfg = CFGS.configs[cfgname]

        if options.cleanup:
            CFGS.clean_install(cfgname)

        print('\n\n' + '\n'.join(banner(cfgname)))
        print('Scanning the source code for:\n' + '~' * 72 + '\n')

        compute_config(options.cleanup and options.rescan,
                       options.bypass)
        CFGS.light_dump()
        # Only if we ask for a scan
        if options.rescan:
            update_cmdf(options.bypass, options.cleanup, options.verbose)

        # /!\ multiple configurations will now generate multiple rescan
        # (because of tags and adds, specific to some configurations)
        compute_config(False, options.bypass)

        # ~~ Scans all cmdf files found in all modules ~~~~~~~~~~~~~~~~~~~~~
        # Specifying what module to compile
        if options.modules == '':
            modules = []
        else:
            modules = options.modules.split(".")
        compile_cmdf(options.ncsize, modules, options.verbose)

        # Compiling api if asked for
        cfg_opt = cfg.get('options', [])
        if 'api' in cfg_opt:
            compile_api_files(silent=not options.verbose,
                              static='static' in cfg_opt,
                              hermes_only='hermes_only' in cfg_opt)

    print('\n\nMy work is done\n\n')
    sys.exit(0)
Example #5
0
def main():
    """ Main function of partel.py """
    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n' + 72 * '~' + '\n')
    parser = argparse.ArgumentParser(
        description='Run the partitionning step (partel)')
    parser = add_config_argument(parser)
    parser.add_argument("--input-file",
                        dest="input_file",
                        default='',
                        help="Name of partel parameter file (PARTEL.PAR)."
                        " This option will surcharge all the others")
    parser.add_argument("--file",
                        dest="geo_file",
                        default='T2DGEO',
                        help="Name of the file to be partitionned")
    parser.add_argument(
        "--file-format",
        dest="geo_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 associated to the mesh file, "
        "default is T2DCLI")
    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(
        "--section-name",
        dest="section_file",
        default='',
        help="Name of the section file, default no section file")
    parser.add_argument("--zone-name",
                        dest="zone_file",
                        default='',
                        help="Name of the zone file, default no zone file")
    parser.add_argument("--weir-name",
                        dest="weir_file",
                        default='',
                        help="Name of the weir file, default no weir file")
    parser.add_argument(
        "--partitioning-method",
        dest="part_method",
        default=1,
        help="Method used for the partitionning (1:metis, 2:scotch)")
    parser.add_argument("--concat",
                        dest="concat",
                        action="store_true",
                        default=False,
                        help="If true concatenate partel output")
    parser.add_argument(
        "--mpi",
        dest="mpi",
        action="store_true",
        default=False,
        help="Run partel as executable (note using command given in systel.cfg)"
    )
    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_file = f.readline().strip('\n')
            ncsize = f.readline().strip('\n')
            part_method = f.readline().strip('\n')
            section_file = f.readline().strip('\n')
            zone_file = f.readline().strip('\n')
            weir_file = f.readline().strip('\n')
            _ = f.readline().strip('\n')
            _ = f.readline().strip('\n')
            concat = f.readline().strip('\n')
    else:
        concat = 'YES' if args.concat else 'NO'
        geo_file = args.geo_file
        geo_file_fmt = args.geo_file_fmt
        bnd_file = args.bnd_file
        ncsize = args.ncsize
        section_file = args.section_file
        zone_file = args.zone_file
        weir_file = args.weir_file
        part_method = args.part_method

    # Getting partel command from configuration
    pbin = path.join(CFGS.get_root(), 'builds', CFGS.cfgname, 'bin')
    if args.mpi:
        exe_ext = CFGS.configs[CFGS.cfgname]['SYSTEM']['sfx_exe']
        parcmd = path.join(pbin, 'partel'+exe_ext+\
                                 ' < <partel.par> >> <partel.log>')
    else:
        parcmd = get_partel_cmd(pbin, CFGS.configs[CFGS.cfgname], '')
    # Running paritionning

    run_partel(parcmd, geo_file, geo_file_fmt, bnd_file, ncsize, False,
               section_file, zone_file, weir_file, geo_file, geo_file_fmt,
               part_method, concat)

    print('\n\nMy work is done\n\n')
    sys.exit(0)
Example #6
0
def main():
    """ Main function of compactTELEMAC """
    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n' + 72 * '~' + '\n')
    parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,
                            description=('''\n\
Compact the TELEMAC system files, into various archived:\n
1. archiving sources if necessary
2. archiving examples if necessary
3. archiving binaries if necessary
4. ...
        '''),
                            usage=' (--help for help)\n---------\n       =>'
                            '  %(prog)s [options] \n---------')
    parser = add_config_argument(parser)
    parser.add_argument(
        "-a",
        "--archive-name",
        metavar="archive name",
        dest="archive_name",
        default='',
        help="specify the archive name, default is taken as the config name")
    parser.add_argument(
        "-m",
        "--modules",
        metavar="modules",
        dest="modules",
        default='',
        help="specify the list modules, default is taken from config file")
    parser.add_argument(
        "--src",
        action="store_true",
        dest="src_only",
        default=False,
        help="create a zip containing only the sources i.e. the "
        "bare minimum to use telemac-mascaret")
    parser.add_argument(
        "--examples",
        action="store_true",
        dest="examplesOnly",
        default=False,
        help="create a zip containing only the sources i.e. the "
        "bare minimum to use telemac-mascaret")
    options = parser.parse_args()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    update_config(options)
    root_dir = CFGS.get_root()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ banners ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    svn_banner(root_dir)

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Works for only one common root and zipper ~~~~~~~~~~~~~~~~~~~
    CFGS.compute_zip_info()
    cfg = CFGS.configs[CFGS.cfgname]
    version = cfg['version']
    zip_ext = cfg['ZIPPER']

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ srcOnlly is independent of config ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    if options.src_only:
        # ~~> create the archive directory
        if options.archive_name != '':
            archive_name = options.archive_name
        else:
            archive_name = 'otm_' + version + '-src'
        print('\n\nArchive ' + archive_name + '\n' + '~' * 72 + '\n')
        tmp_dir = path.join(root_dir, archive_name)
        if path.exists(tmp_dir):
            remove_directories(tmp_dir)
        create_directories(tmp_dir)
        # ~~> copy the content of the following dirs into the archive directory
        dirs = ['optionals', 'scripts', 'sources', 'documentation', 'configs']
        for pid in dirs:
            input_path = path.join(root_dir, pid)
            output_path = input_path.replace(root_dir, tmp_dir)
            copytree(input_path,
                     output_path,
                     ignore=ignore_patterns('.svn', '*.pyc'))
            print('    +> ' + input_path)
        # ~~> copy the following files into the archive directory
        files = ['NEWS.txt', 'README.txt']
        for pid in files:
            input_path = path.join(root_dir, pid)
            output_path = input_path.replace(root_dir, tmp_dir)
            copy_file(input_path, output_path)
            print('    +> ' + input_path)
        # ~~> prepare an empty diretory for future builds
        pid = path.join(root_dir, 'builds')
        output_path = pid.replace(root_dir, tmp_dir)
        create_directories(output_path)
        # ~~> zipping the archive directory
        print('\n... now packaging ' + archive_name)
        tel_zip(archive_name, tmp_dir, zip_ext)
        # ~~> cleaning the archive directory
        print('\n... now cleaning ')
        remove_directories(tmp_dir)

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ examplesOnly is independent of config ~~~~~~~~~~~~~~~~~~~~~~~
    elif options.examplesOnly:
        # ~~> create the archive directory
        if options.archive_name != '':
            archive_name = options.archive_name
        else:
            archive_name = 'otm_' + version + '-examples'
        print('\n\nArchive ' + archive_name + '\n' + '~' * 72 + '\n')
        tmp_dir = path.join(root_dir, archive_name)
        if path.exists(tmp_dir):
            remove_directories(tmp_dir)
        create_directories(tmp_dir)
        # ~~> copy the content of the following dir into the archive directory
        dirs = ['examples']
        for pid in dirs:
            input_path = path.join(root_dir, pid)
            output_path = input_path.replace(root_dir, tmp_dir)
            copytree(input_path,
                     output_path,
                     ignore=ignore_patterns('.svn', '*.pyc'))
            print('    +> ' + input_path)
        # ~~> zipping the archive directory
        print('\n... now packaging ' + archive_name)
        tel_zip(archive_name, tmp_dir, zip_ext)
        # ~~> cleaning the archive directory
        print('\n... now cleaning ')
        remove_directories(tmp_dir)

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Works for all configurations unless specified ~~~~~~~~~~~~~~~
    else:
        for cfgname in CFGS.configs:
            if options.modules != '':
                cfg['modules'] = \
                    options.modules.replace(',', ' ')\
                                   .replace(';', ' ').replace('.', ' ')
            # parsing for proper naming
            CFGS.compute_compact_info()
            CFGS.light_dump()

            # ~~ Scans all source files to build a relation database ~~~~~~~~~~~
            if cfg['MODULES'] == {}:
                raise TelemacException(\
                        '\nNot able to find any modules within'
                        'your root directory {}\n'.format(cfg['root']))

            # ~~> create the archive directory
            if options.archive_name != '':
                archive_name = options.archive_name
            else:
                archive_name = 'otm_' + version + '-builds-' + cfgname
            print('\n\nArchive ' + archive_name + '\n' + '~' * 72 + '\n')
            tmp_dir = path.join(root_dir, archive_name)
            if path.exists(tmp_dir):
                remove_directories(tmp_dir)
            create_directories(tmp_dir)
            # ~~> copy the content of the following dir
            # into the archive directory
            dirs = ['builds' + sep + cfgname, 'scripts', 'sources', 'configs']
            for pid in dirs:
                input_path = path.join(root_dir, pid)
                output_path = input_path.replace(root_dir, tmp_dir)
                copytree(input_path,
                         output_path,
                         ignore=ignore_patterns('.svn', '*.pyc'))
                print('    +> ' + input_path)
            # ~~> zipping the archive directory
            print('\n... now packaging ' + cfgname)
            tel_zip(cfgname, tmp_dir, cfg['ZIPPER'])
            # ~~> cleaning the archive directory
            print('\n... now cleaning ')
            remove_directories(tmp_dir)


# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Jenkins' success message ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nMy work is done\n\n')

    sys.exit(0)
Example #7
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)
def main():
    """
    Main program for the compilation of the documentation of
    the telemac-mascaret system
    """
# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n'+'~'*72+'\n')
    parser = ArgumentParser(
        formatter_class=RawDescriptionHelpFormatter,
        description=('''\n
By Default all the documentation are generated\n
use the options --validation/reference/user/release/theory to compile only one
        '''))
    parser = add_config_argument(parser)
    parser.add_argument(
        "-v", "--verbose", action="store_true",
        dest="verbose", default=False,
        help="Will display listing for all commands")
    parser.add_argument(
        "-m", "--modules",
        dest="modules", default='',
        help="specify the list modules (, separated), default is all of them")
    parser.add_argument(
        "-M", "--misc",
        dest="misc", default='',
        help="specify the list of misc documentation (, separated) to compile, "
             "default is all of them")
    parser.add_argument(
        "--validation", action="store_true",
        dest="validation", default=False,
        help="Will generate the validation documentation")
    parser.add_argument(
        "--case-list",
        dest="case_list", default='',
        help="List of cas to include in the validation documentation"
             "separated by ',' (default all of them)")
    parser.add_argument(
        "--reference", action="store_true",
        dest="reference", default=False,
        help="Will generate the reference documentation")
    parser.add_argument(
        "--user", action="store_true",
        dest="user", default=False,
        help="Will generate the user documentation")
    parser.add_argument(
        "--release", action="store_true",
        dest="release_note", default=False,
        help="Will generate the release note")
    parser.add_argument(
        "--theory", action="store_true",
        dest="theory_guide", default=False,
        help="Will generate the theory guide")
    parser.add_argument(
        "--clean", action="store_true",
        dest="cleanup", default=False,
        help="Will remove all temporary file generated by pdflatex")
    parser.add_argument(
        "--fullclean", action="store_true",
        dest="fullcleanup", default=False,
        help="Same as clean but removes the pdf as well")

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    options = parser.parse_args()
    update_config(options)

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Works for all configurations unless specified ~~~~~~~~~~~~~~~
# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Compile the valiation documentation
    doall = not (options.validation or options.user or options.reference
                 or options.release_note or options.theory_guide)
    cfg = CFGS.configs[CFGS.cfgname]
    # still in lower case
    root = CFGS.get_root()
    # Get what i to be compiled
    # By default everything if something is defined compiling only that
    if options.modules != '':
        module_list = options.modules.split(',')
    else:
        # all modules
        module_list = ['artemis', 'stbtel', 'sisyphe', 'postel3d',
                       'telemac2d', 'telemac3d', 'tomawac', 'waqtel',
                       'telapy', 'mascaret', 'gaia', 'nestor', 'khione']
    if options.misc != '':
        misc_list = options.misc.split(',')
        module_list = []
    else:
        # all docs
        misc_list = ['developer_guide', 'software_quality_plan',
                     'TelemacDocTemplate', 'git_guide',
                     'doxypydocs']
        # If a module was specified or a specific documentation for modules
        # not compiling Misc documentation
        if options.modules != '' or not doall:
            misc_list = []

    CFGS.compute_vnv_info()

    # Get version in config if it exist use trunk otherwise
    version = cfg.get('version', 'trunk')

    # Initialise output message
    output_mess = '\n\n'
    # Look on all the modules for the documentation
    for code_name in module_list:
        print('\nCompilation of the documentation for ' + code_name
              + '\n'+'~'*72)
        # list of what to do for the module
        todo = []
        if options.validation or doall:
            if code_name not in ['telapy', 'mascaret']:
                # Building Validation LaTeX file
                doc_dir = path.join(root, 'documentation',
                                    code_name, 'validation')
                chdir(doc_dir)
                if options.case_list != '':
                    list_of_case = options.case_list.split(',')
                else:
                    list_of_case = list(cfg['VALIDATION'][code_name].keys())
                    list_of_case.remove('path')
                skiped_case = \
                    create_case_list_file(
                        doc_dir,
                        cfg['VALIDATION'][code_name]['path'],
                        list_of_case,
                        options.cleanup or options.fullcleanup)
                for case in skiped_case:
                    output_mess += r'   - /!\ Missing LaTeX file for ' + \
                                   case+'\n'
                todo.append('validation')
        if options.reference or doall:
            if code_name not in ['telapy', 'mascaret', 'nestor']:
                # Path to the dictionary
                dictionary = path.join(root, 'sources', code_name,
                                       code_name+'.dico')
                # Path to latex File
                latex_file = path.join(root, 'documentation',
                                       code_name, 'reference',
                                       'latex', 'Corpus.tex')
                # English only for now
                lng = '2'
                # Path to bin directory
                exe_path = path.join(\
                        root, 'builds', CFGS.cfgname,
                        'bin', 'damocles'+cfg['SYSTEM']['sfx_exe'])
                generate_ref_from_dict(\
                        exe_path, dictionary, latex_file, lng,
                        options.cleanup or options.fullcleanup,
                        options.verbose)
                todo.append('reference')
        if options.user or doall:
            if code_name not in ['mascaret']:
                # Normal Compilation of a LaTeX file
                todo.append('user')
        if options.theory_guide or doall:
            # theory guide only available for telemac3d
            if code_name in ['telemac3d', 'mascaret', 'waqtel']:
                todo.append('theory_guide')
        for doc_type in todo:
            print('\n     ~> Compilation of the {} documentation'\
                  .format(doc_type))
            doc_dir = path.join(root, 'documentation',
                                code_name, doc_type)
            chdir(doc_dir)
            # Check if the file exist
            if path.exists(path.join(doc_dir,
                                     code_name + "_" + doc_type + ".tex")):
                compile_doc(doc_dir, code_name+'_'+doc_type,
                            version,
                            options.cleanup, options.fullcleanup,
                            options.verbose)
            else:
                raise TelemacException(\
                        "   - Error for {} {}, {}.tex "
                        "not found ".format(code_name,
                                            path.basename(doc_dir),
                                            code_name+"_"+doc_type))
            if not (options.cleanup or options.fullcleanup):
                output_mess += '   - Created %s_%s_%s.pdf\n' % \
                              (code_name, doc_type, version)
    # List of the other documentation
    print('\nCompilation of the documentation for Misc'
          + '\n'+'~'*72)
    for doc in misc_list:
        print('\n     ~> Compilation of the {} documentation'.format(doc))
        doc_dir = path.join(root, 'documentation',
                            'Misc', doc)

        if doc == 'notebook':
            notebook_dir = path.join(root, 'notebooks')
            generate_notebook_pdf(doc_dir, notebook_dir)
        elif doc in ['doxydocs', 'doxypydocs']:
            generate_doxygen(doc, options.verbose)
        else:
            chdir(doc_dir)
            if path.exists(path.join(doc_dir, doc + ".tex")):
                compile_doc(doc_dir, doc,
                            version,
                            options.cleanup, options.fullcleanup,
                            options.verbose)
            else:
                raise TelemacException(\
                        "   - Error in {}, {}.tex "
                        "not found ".format(path.basename(doc_dir), doc))
        if not (options.cleanup or options.fullcleanup) or \
           doc not in ['notebooks', 'doxydocs', 'doxypydocs']:
            output_mess += '   - Created %s_%s.pdf\n' % \
                          (doc, version)

    print(output_mess)
    print('\n\n'+'~'*72)

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Jenkins' success message ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nMy work is done\n\n')

    sys.exit(0)
Example #9
0
def main():
    """
       Main program for the execution of damocles
    """
    #   ~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n' + '~' * 72 + '\n')
    parser = ArgumentParser()
    parser = add_config_argument(parser)
    parser.add_argument(\
                  "-m", "--modules",
                  dest="modules",
                  default='',
                  help="specify the list modules, default is "\
                      "taken from config file")
    parser.add_argument(\
                  "--dump",
                  action="store_true",
                  dest="dump",
                  default=False,
                  help="Will dump a reordered dictionary by rubrique")
    parser.add_argument(\
                  "--dump2",
                  action="store_true",
                  dest="dump2",
                  default=False,
                  help="Will dump a reordered dictionary by index")
    parser.add_argument(\
                  "--eficas",
                  action="store_true",
                  dest="eficas",
                  default=False,
                  help="Will generate the eficas Catalogue from the dictionary")
    parser.add_argument(\
                  "--latex",
                  action="store_true",
                  dest="latex",
                  default=False,
                  help="Will generate the LaTeX file for the reference manual")

    #   ~~~~ Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    args = parser.parse_args()
    # path to the root

    #   ~~~~ Works for all configurations unless specified ~~~~~~~~~~~~~~~
    update_config(args)
    cfg = CFGS.configs[CFGS.cfgname]
    #   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # Defining which modules to use
    if args.modules is '':
        module_list = [
            'artemis', 'postel3d', 'stbtel', 'sisyphe', 'telemac2d',
            'telemac3d', 'tomawac', 'waqtel', 'gaia', 'khione'
        ]
    else:
        module_list = args.modules.split(';')
    # Identify Root value
    CFGS.compute_vnv_info()
    root = CFGS.get_root()
    exe_path = path.join(root, 'builds', CFGS.cfgname,\
                         'bin', 'damocles'+\
                         cfg['SYSTEM']['sfx_exe'])
    # Looping on all modules
    for module in module_list:
        module_path = path.join(root, 'sources', module)
        if args.dump:
            input_dict = path.join(module_path, module + ".dico")
            output_dict = path.join(module_path, module + "2.dico")
            gen_dump(exe_path, input_dict, output_dict)

        if args.dump2:
            input_dict = path.join(module_path, module + ".dico")
            output_dict = path.join(module_path, module + "2.dico")
            gen_dump2(exe_path, input_dict, output_dict)

        if args.eficas:

            # Creating eficas folder and __init__ if it does not exists
            eficas_path = path.join(root, 'scripts', 'python3', 'eficas')
            if not path.exists(eficas_path):
                mkdir(eficas_path)
                with open(path.join(eficas_path, '__init__.py'), 'w') as fobj:
                    fobj.write("#! /usr/bin/env python")
                    fobj.write("# -*- coding: utf-8 -*")

            input_dict = path.join(module_path, module + ".dico")
            input_dep = path.join(module_path, module + ".dico.dep")
            fancy_module = module
            cata_name = path.join(eficas_path, fancy_module + "_cata_auto.py")
            enum_name = path.join(eficas_path, fancy_module + "_enum_auto.py")
            ts_path = eficas_path
            gen_cata(module.upper(), exe_path, input_dict, input_dep,
                     cata_name, enum_name, ts_path + path.sep)

        if args.latex:
            input_dict = path.join(module_path, module + ".dico")
            latex_name = path.join(root, 'documentation', module, 'reference',\
                                  'latex', 'Corpus.tex')
            # English only
            lng = '2'
            gen_latex(exe_path, input_dict, latex_name, lng)


#   ~~~~ Compile the valiation documentation

    print('\n\n' + '~' * 72)

    #   ~~~~ Jenkins' success message ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nMy work is done\n\n')

    sys.exit(0)
Example #10
0
def run_mascaret():
    """
    Main function that runs the mascaret executable in the current folder
    """

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n'+72*'~'+'\n')
    parser = ArgumentParser(
        formatter_class=RawDescriptionHelpFormatter,
        description=('''\n\
Run the mascaret executable in the current folder, given a CAS file.
        '''))
    parser.add_argument("args", nargs='*')
    # ~~> Environment
    parser = add_config_argument(parser)
    parser.add_argument(
        "-s", "--sortiefile", action="store_true", dest="sortie_file",
        default=False,
        help="specify whether there is a sortie file, default is no")
    parser.add_argument(
        "-b", "--bypass", action="store_true",
        dest="bypass", default=False,
        help="will bypass execution failures and try to carry on "
             "(final report at the end)")
    options = parser.parse_args()

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    update_config(options)

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ banners ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    svn_banner(CFGS.get_root())

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Works for one configuration only ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    if len(options.args) < 1:
        print('\nThe name of the CAS file is required\n')
        parser.print_help()
        sys.exit(1)

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Reads command line arguments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cas = options.args[0]
# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Works for only one configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    xcpts = Messages()

    # still in lower case
    # parsing for proper naming
    CFGS.compute_execution_info()
    cfg = CFGS.configs[CFGS.cfgname]

    create_mascaret_files(cfg, cas)

    mascaret_exe = path.join(cfg['root'], 'builds', CFGS.cfgname, 'bin',
                             'mascaret' + cfg['sfx_exe'])
    _, code = xcpts.run_cmd(mascaret_exe, options.bypass)

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Reporting errors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    if xcpts.not_empty() or code != 0:
        print('\n\nHummm ... I could not complete my work.\n'+'~'*72
              + xcpts.except_messages())
        sys.exit(1)

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Jenkins' success message ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    else:
        print('\n\nMy work is done\n\n')
        sys.exit(0)
def add_runcode_argument(parser, module=None):
    """
    Adding argument for runcode

    @param (ArgumentParser) where to add the arguemnts

    @return (ArgumentParser) The updated parser
    """
    # ~~> Environment
    parser = add_config_argument(parser)
    parser.add_argument(
        "-s",
        "--sortiefile",
        action="store_true",
        dest="sortie_file",
        default=False,
        help="specify whether there is a sortie file, default is no")
    parser.add_argument(
        "-t",
        "--tmpdirectory",
        action="store_false",
        dest="tmpdirectory",
        default=True,
        help="specify whether the temporary directory is removed, "
        "default is yes")
    parser.add_argument(
        "-w",
        "--workdirectory",
        dest="w_dir",
        default='',
        help="specify whether to re-run within a defined subdirectory")
    parser.add_argument("--nozip",
                        action="store_true",
                        dest="nozip",
                        default=False,
                        help="specify whether to zip the extra sortie file if "
                        "simulation in parallel")
    # ~~> HPC / parallel
    parser = add_hpc_argument(parser, module=module)
    parser = add_mpi_argument(parser)

    parser.add_argument(
        "--sequential",
        action="store_true",
        dest="sequential",
        default=False,
        help="if present, imposes that multiple CAS files are launched "
        "one after the other")
    parser.add_argument(
        "--mpi",
        action="store_true",
        dest="mpi",
        default=False,
        help="make sure the mpi command is executed, ignoring any hpc command")

    # Splitting execution arguments
    group = parser.add_mutually_exclusive_group()
    group.add_argument(
        "--split",
        action="store_true",
        dest="split",
        default=False,
        help="will only do the trace (and the split in parallel) if option "
        "there")
    group.add_argument("--run",
                       action="store_true",
                       dest="run",
                       default=False,
                       help="will only run the simulation if option there")
    group.add_argument(
        "-x",
        "--compileonly",
        action="store_true",
        dest="compileonly",
        default=False,
        help="specify whether to only create an executable but not run, "
        "default is no")
    group.add_argument(
        "--merge",
        action="store_true",
        dest="merge",
        default=False,
        help="will only do the output copying (and recollection in parallel) "
        "if option there")
    # ~~> Other
    parser.add_argument(
        "--use-link",
        action="store_true",
        dest="use_link",
        default=False,
        help="Will use link instead of copy in the temporary folder"
        " (Unix system only)")
    return parser
Example #12
0
def main():
    """ Main function of manip_cas.py """
    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n' + 72 * '~' + '\n')
    parser = argparse.ArgumentParser(description='Translate a keyword')
    parser = add_config_argument(parser)
    parser.add_argument("module",
                        choices=[
                            'postel3d', 'telemac2d', 'telemac3d', 'tomawac',
                            'artemis', 'sisyphe', 'waqtel', 'khione', 'stbtel'
                        ],
                        help="Name of the module for which to translate")
    parser.add_argument(
        "-t",
        "--translate",
        action="store_true",
        dest="translate",
        default=False,
        help="Generate a french and english version of the steering file "
        "(cas_file suffixed with _fr and _gb)")

    parser.add_argument(
        "-s",
        "--sort",
        action="store_true",
        dest="sort",
        default=False,
        help="Rewrites the steering file using rubriques to sort the keywords "
        "cas_file suffixed with _sorted")

    parser.add_argument("--keep-comments",
                        action="store_true",
                        dest="keep_comments",
                        default=False,
                        help="When sorting will append all original comments "
                        "at the end of the file")

    parser.add_argument("cas_file", help="Name of the steering file to read")

    args = parser.parse_args()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    update_config(args)
    cfg = CFGS.configs[CFGS.cfgname]
    CFGS.compute_execution_info()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # Searching for the dictionary associated with the steering case
    dico_file = path.join(cfg['MODULES'][args.module]['path'],
                          args.module + '.dico')
    if not path.exists(dico_file):
        raise TelemacException(\
            'Could not find the dictionary file: {}'.format(dico_file))
    cas = TelemacCas(args.cas_file, dico_file, check_files=False)

    check_cas(cas)

    if args.translate:
        translate(cas)
    if args.sort:
        sort(cas, args.keep_comments)

    print('\n\nMy work is done\n\n')
    sys.exit(0)
def main():
    """ Main function of parserDELWAQ """

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nLoading Options and Configurations\n' + '~' * 72 + '\n')
    parser = ArgumentParser(\
        formatter_class=RawDescriptionHelpFormatter,
        description=('''\n\
Tools for handling DELWAQ files when created by TELEMAC
        '''),
        usage=' (--help for help)\n---------\n       =>  '\
                '%(prog)s [option] delwaq.cas \n---------')
    parser = add_config_argument(parser)
    parser.add_argument(\
        "--reset", action="store_true",
        dest="areset", default=False,
        help="reset the start time to zero")
    parser.add_argument(\
        "--minvol",
        dest="minvol", default='0.001',
        help="make sure there is a minimum volume")
    parser.add_argument(\
        "--from",
        dest="tfrom", default="1",
        help="specify the first frame included")
    parser.add_argument(\
        "--stop",
        dest="tstop", default="-1",
        help="specify the last frame included (negative from the end)")
    parser.add_argument("args", nargs="+")
    options = parser.parse_args()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Works for only one configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    update_config(options)
    CFGS.compute_compilation_info()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Reads command line arguments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    if len(options.args) < 1:
        print('\nAt least one DELWAQ steering file name is required\n')
        parser.print_help()
        raise Exception
    file_names = options.args

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Loop over the DELWAQ files ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    for fle in file_names:

        # ~~> Parse DELWAQ steering file
        print('      ~> scanning your DELWAQ file: ' + path.basename(fle))
        dwq = DELWAQ(fle)

        # ~~> Possible options so far
        if options.areset:
            dwq.reset_dwq()
        dwq.minvol_dwq(options.minvol)
        dwq.sample_dwq(options.tfrom, options.tstop)

        # ~~> Convert to Little Endian
        dwq.big2little()


# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Jenkins' success message ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nMy work is done\n\n')

    sys.exit(0)