Changeset efdb01a in flex_extract.git for python/submit.py


Ignore:
Timestamp:
May 9, 2018, 12:15:00 PM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
991df6a
Parents:
02c8c50
Message:

whole bunch of modifications due to new structure of ECMWFDATA, added basics of documentation, minor programming corrections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/submit.py

    • Property mode changed from 100644 to 100755
    r02c8c50 refdb01a  
    33#************************************************************************
    44# TODO AP
    5 #AP
     5#
    66# - Change History ist nicht angepasst ans File! Original geben lassen
    77# - dead code ? what to do?
    88# - seperate operational and reanlysis for clarification
     9# - add correct file description
     10# - divide in two submits , ondemand und operational
     11# -
    912#************************************************************************
    1013"""
     
    1518@ChangeHistory:
    1619    November 2015 - Leopold Haimberger (University of Vienna):
    17         - using the WebAPI also for general MARS retrievals
    1820        - job submission on ecgate and cca
    1921        - job templates suitable for twice daily operational dissemination
    20         - dividing retrievals of longer periods into digestable chunks
    21         - retrieve also longer term forecasts, not only analyses and
    22           short term forecast data
    23         - conversion into GRIB2
    24         - conversion into .fp format for faster execution of FLEXPART
    2522
    2623    February 2018 - Anne Philipp (University of Vienna):
    2724        - applied PEP8 style guide
    2825        - added documentation
    29         - minor changes in programming style for consistence
     26        - minor changes in programming style (for consistence)
    3027
    3128@License:
    32     (C) Copyright 2014 UIO.
     29    (C) Copyright 2014-2018.
    3330
    3431    This software is licensed under the terms of the Apache Licence Version 2.0
     
    3734@Requirements:
    3835    - A standard python 2.6 or 2.7 installation
    39     - dateutils
    40     - matplotlib (optional, for debugging)
    41     - ECMWF specific packages, all available from https://software.ecmwf.int/
    42         ECMWF WebMARS, gribAPI with python enabled, emoslib and
    43         ecaccess web toolkit
    4436
    4537@Description:
    4638    Further documentation may be obtained from www.flexpart.eu.
    4739
    48     Functionality provided:
    49         Prepare input 3D-wind fields in hybrid coordinates +
    50         surface fields for FLEXPART runs
     40
    5141"""
    5242# ------------------------------------------------------------------------------
    5343# MODULES
    5444# ------------------------------------------------------------------------------
    55 import calendar
    56 import shutil
    57 import datetime
    58 import time
    59 import os, sys, glob
     45import os
     46import sys
     47import glob
    6048import subprocess
    6149import inspect
    62 # add path to submit.py to pythonpath so that python finds its buddies
     50# add the pythondir path so that python finds its buddies (from flex_extract)
    6351localpythonpath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
    6452sys.path.append(localpythonpath)
    65 from UIOTools import UIOFiles
    66 from string import strip
    67 from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
    68 from GribTools import GribTools
    69 from FlexpartTools import ECFlexpart, Control, interpret_args_and_control, normalexit, myerror
     53
     54# software specific classes and modules from flex_extract
     55from Tools import interpret_args_and_control, normalexit
    7056from getMARSdata import getMARSdata
    7157from prepareFLEXPART import prepareFLEXPART
     
    7662    '''
    7763    @Description:
    78         Get the arguments from script call and initialize an object from
    79         Control class. Decides from the argument "queue" if the local version
    80         is done "queue=None" or the gateway version "queue=ecgate".
     64        Get the arguments from script call and from Control file.
     65        Decides from the argument "queue" if the local version
     66        is done "queue=None" or the gateway version with "queue=ecgate"
     67        or "queue=cca".
    8168
    8269    @Input:
     
    8875    calledfromdir = os.getcwd()
    8976    args, c = interpret_args_and_control()
     77    # on local side
    9078    if args.queue is None:
    9179        if c.inputdir[0] != '/':
     
    9684        prepareFLEXPART(args, c)
    9785        normalexit(c)
     86    # on ECMWF server
    9887    else:
    9988        submit(args.job_template, c, args.queue)
     
    10291
    10392def submit(jtemplate, c, queue):
    104     #AP divide in two submits , ondemand und operational
    10593    '''
    10694    @Description:
     
    138126        lftext = f.read().split('\n')
    139127        insert_point = lftext.index('EOF')
    140 #AP es gibt mehrere EOFs überprüfen!
    141128
    142129    # put all parameters of control instance into a list
    143     clist = c.tolist()  # reanalysis (EI)
     130    clist = c.tolist()
    144131    colist = []  # operational
    145132    mt = 0
    146133
    147134#AP wieso 2 for loops?
    148 #AP dieser part ist für die CTBTO Operational retrieves bis zum aktuellen Tag.
    149135    for elem in clist:
    150136        if 'maxstep' in elem:
     
    162148            elem = 'time ' + '${MSJ_BASETIME} {MSJ_BASETIME}'
    163149        colist.append(elem)
    164 #AP end
    165 
    166 #AP whats the difference between clist and colist ?! What is MSJ?
    167150
    168151    lftextondemand = lftext[:insert_point] + clist + lftext[insert_point + 2:]
     
    172155        h.write('\n'.join(lftextondemand))
    173156
    174 #AP this is not used ?! what is it for?
    175 #maybe a differentiation is needed
    176     h = open('joboper.ksh', 'w')
    177     h.write('\n'.join(lftextoper))
    178     h.close()
    179 #AP end
     157    with open('joboper.ksh', 'w') as h:
     158        h.write('\n'.join(lftextoper))
    180159
    181160    # submit job script to queue
    182161    try:
    183162        p = subprocess.check_call(['ecaccess-job-submit', '-queueName',
    184                                    queue,' job.ksh'])
     163                                   queue, 'job.ksh'])
    185164    except:
    186165        print('ecaccess-job-submit failed, probably eccert has expired')
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG