Ignore:
Timestamp:
Sep 23, 2018, 11:40:28 AM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
4971f63
Parents:
5d42acd
Message:

changed whole tree structure of flex_extract to have better overview

File:
1 moved

Legend:

Unmodified
Added
Removed
  • source/pythontest/TestInstallTar/flex_extract_v7.1_ecgate/source/python/submit.py

    r2fb99de r25b14be  
    1616#        - added documentation
    1717#        - minor changes in programming style (for consistence)
     18#        - changed path names to variables from config file
     19#        - added option for writing mars requests to extra file
     20#          additionally,as option without submitting the mars jobs
    1821#
    1922# @License:
     
    4851# software specific classes and modules from flex_extract
    4952import _config
    50 from tools import normal_exit, get_cmdline_arguments, submit_job_to_ecserver, \
    51                   read_ecenv
    52 from get_mars_data import get_mars_data
    53 from prepare_flexpart import prepare_flexpart
    54 from ControlFile import ControlFile
     53from mods.tools import (normal_exit, get_cmdline_arguments,
     54                        submit_job_to_ecserver, read_ecenv)
     55from mods.get_mars_data import get_mars_data
     56from mods.prepare_flexpart import prepare_flexpart
     57from classes.ControlFile import ControlFile
    5558
    5659# ------------------------------------------------------------------------------
     
    7376    '''
    7477
    75     called_from_dir = os.getcwd()
    76 
    7778    args = get_cmdline_arguments()
    7879
     
    8081        c = ControlFile(args.controlfile)
    8182    except IOError:
    82         try:
    83             c = ControlFile(_config.PATH_LOCAL_PYTHON + args.controlfile)
    84         except IOError:
    85             print 'Could not read CONTROL file "' + args.controlfile + '"'
    86             print 'Either it does not exist or its syntax is wrong.'
    87             print 'Try "' + sys.argv[0].split('/')[-1] + \
    88                   ' -h" to print usage information'
    89             sys.exit(1)
    90 
    91     env_parameter = read_ecenv(c.ecmwfdatadir + 'python/ECMWF_ENV')
     83        print('Could not read CONTROL file "' + args.controlfile + '"')
     84        print('Either it does not exist or its syntax is wrong.')
     85        print('Try "' + sys.argv[0].split('/')[-1] + \
     86              ' -h" to print usage information')
     87        sys.exit(1)
     88
     89    env_parameter = read_ecenv(_config.PATH_ECMWF_ENV)
    9290    c.assign_args_to_control(args)
    9391    c.assign_envs_to_control(env_parameter)
    94     c.check_conditions()
     92    c.check_conditions(args.queue)
    9593
    9694    # on local side
    9795    # on ECMWF server this would also be the local side
     96    called_from_dir = os.getcwd()
    9897    if args.queue is None:
    9998        if c.inputdir[0] != '/':
     
    107106        else:
    108107            normal_exit(c.mailfail, 'PRINTING MARS_REQUESTS DONE!')
    109     # on ECMWF server
     108    # send files to ECMWF server and install there
    110109    else:
    111110        submit(args.job_template, c, args.queue)
     
    120119    @Input:
    121120        jtemplate: string
    122             Job template file for submission to ECMWF. It contains all necessary
     121            Job template file from sub-directory "_templates" for
     122            submission to ECMWF. It contains all necessary
    123123            module and variable settings for the ECMWF environment as well as
    124124            the job call and mail report instructions.
     
    146146
    147147    # read template file and get index for CONTROL input
    148     with open(jtemplate) as f:
     148    with open(os.path.join(_config.PATH_TEMPLATES, jtemplate)) as f:
    149149        lftext = f.read().split('\n')
    150150    insert_point = lftext.index('EOF')
     
    153153    # --------- create on demand job script ------------------------------------
    154154        if c.maxstep > 24:
    155             print '---- Pure forecast mode! ----'
     155            print('---- Pure forecast mode! ----')
    156156        else:
    157             print '---- On-demand mode! ----'
    158         job_file = jtemplate[:-4] + 'ksh'
     157            print('---- On-demand mode! ----')
     158        job_file = os.path.join(_config.PATH_JOBSCRIPTS,
     159                                jtemplate[:-4] + 'ksh')
    159160        clist = c.to_list()
    160161
     
    164165            f.write('\n'.join(lftextondemand))
    165166
    166         result_code = submit_job_to_ecserver(queue, job_file)
     167        submit_job_to_ecserver(queue, job_file)
    167168
    168169    else:
    169170    # --------- create operational job script ----------------------------------
    170         print '---- Operational mode! ----'
    171         job_file = jtemplate[:-5] + 'oper.ksh'
    172         #colist = []
     171        print('---- Operational mode! ----')
     172        job_file = os.path.join(_config.PATH_JOBSCRIPTS,
     173                                jtemplate[:-5] + 'oper.ksh')
    173174
    174175        if c.maxstep:
     
    190191            f.write('\n'.join(lftextoper))
    191192
    192         result_code = submit_job_to_ecserver(queue, job_file)
     193        submit_job_to_ecserver(queue, job_file)
    193194
    194195    # --------------------------------------------------------------------------
    195     print 'You should get an email with subject flex.hostname.pid'
     196    print('You should get an email with subject flex.hostname.pid')
    196197
    197198    return
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG