diff --git a/source/python/_config.py b/source/python/_config.py index e35a73de265d43b80b4c56e4eb67cc8ec03dd73e..9354d080926e35c96859c3aeda955815d98fdb89 100644 --- a/source/python/_config.py +++ b/source/python/_config.py @@ -27,13 +27,18 @@ and pathes. import os import sys import inspect +import socket _VERSION_STR = '7.1' +FLAG_ON_ECMWFSERVER = 'ecmwf' in socket.gethostname() + QUEUES_LIST = ['ecgate', 'cca', 'ccb'] INSTALL_TARGETS = ['local', 'ecgate', 'cca'] +CDS_DATASET = 'reanalysis-era5-complete' + # up-to-date available maximum level numbers at ECMWF, 05.10.2018 MAX_LEVEL_LIST = [16, 19, 31, 40, 50, 60, 62, 91, 137] diff --git a/source/python/classes/ControlFile.py b/source/python/classes/ControlFile.py index 772169dfc82b410faacbdd8924ee5afcee25fb6d..f6c4353f92290d6508435879470fce3893a575bf 100644 --- a/source/python/classes/ControlFile.py +++ b/source/python/classes/ControlFile.py @@ -317,8 +317,12 @@ class ControlFile(object): possible data sets. Public data sets (1) and Memberstate data sets (0). Default value is 0. - ecapi : boolean - Tells wether the ECMWF Web APi was able to load or not. + ec_api : boolean + Tells wether the ECMWF Web API was able to load or not. + Default value is None. + + cds_api : boolean + Tells wether the CDS API was able to load or not. Default value is None. purefc : int @@ -416,7 +420,8 @@ class ControlFile(object): self.oper = 0 self.request = 0 self.public = 0 - self.ecapi = None + self.ec_api = None + self.cds_api = None self.purefc = 0 self.rrint = 0 @@ -480,8 +485,7 @@ class ControlFile(object): if var is not None: data[1] = data[1][:i] + var + data[1][k+1:] else: - my_error(self.mailfail, - 'Could not find variable ' + my_error('Could not find variable ' + data[1][j+1:k] + ' while reading ' + self.controlfile) setattr(self, data[0].lower() + '_expanded', data[1]) diff --git a/source/python/classes/EcFlexpart.py b/source/python/classes/EcFlexpart.py index 22214d46de1ebc8d5ca928d8bc43b6a304153e62..8213bf26425a527eeb0c4262374a0ee1ba1cc4dc 100644 --- a/source/python/classes/EcFlexpart.py +++ b/source/python/classes/EcFlexpart.py @@ -72,12 +72,12 @@ from eccodes import (codes_index_select, codes_new_from_index, codes_get, # software specific classes and modules from flex_extract sys.path.append('../') import _config -from GribUtil import GribUtil +from .GribUtil import GribUtil from mods.tools import (init128, to_param_id, silent_remove, product, my_error, make_dir, get_informations, get_dimensions, - execute_subprocess) -from MarsRetrieval import MarsRetrieval -from UioFiles import UioFiles + execute_subprocess, to_param_id_with_tablenumber) +from .MarsRetrieval import MarsRetrieval +from .UioFiles import UioFiles import mods.disaggregation as disaggregation # ------------------------------------------------------------------------------ @@ -402,13 +402,13 @@ class EcFlexpart(object): self.params['SH__ML'] = ['U/V/D', 'ML', self.glevelist, 'OFF'] elif not gauss and not eta: self.params['OG__ML'][0] += '/U/V' - else: - print('Warning: Collecting etadot and parameters for gaussian grid \ - is a very costly parameter combination, \ - use this combination only for debugging!') - self.params['GG__SL'] = ['Q', 'ML', '1', \ + else: # GAUSS and ETA + print('Warning: Collecting etadot and parameters for gaussian grid ' + 'is a very costly parameter combination, ' + 'use this combination only for debugging!') + self.params['GG__SL'] = ['Q', 'ML', '1', '{}'.format((int(self.resol) + 1) / 2)] - self.params['GG__ML'] = ['U/V/D/77', 'ML', self.glevelist, \ + self.params['GG__ML'] = ['U/V/D/ETADOT', 'ML', self.glevelist, '{}'.format((int(self.resol) + 1) / 2)] if omega: @@ -418,11 +418,12 @@ class EcFlexpart(object): self.params['OG__ML'][0] += '/CLWC/CIWC' # ADDITIONAL FIELDS FOR FLEXPART-WRF MODEL (IF QUESTIONED) - #----------------------------------------------------------------------- + # ----------------------------------------------------------------------- if wrf: self.params['OG__ML'][0] += '/Z/VO' if '/D' not in self.params['OG__ML'][0]: self.params['OG__ML'][0] += '/D' + wrf_sfc = ['SP','SKT','SST','CI','STL1','STL2', 'STL3','STL4', 'SWVL1','SWVL2','SWVL3','SWVL4'] for par in wrf_sfc: @@ -451,7 +452,7 @@ class EcFlexpart(object): ------ ''' - self.params['OG_acc_SL'] = ["LSP/CP/SSHF/EWSS/NSSS/SSR", \ + self.params['OG_acc_SL'] = ["LSP/CP/SSHF/EWSS/NSSS/SSR", 'SFC', '1', self.grid] return @@ -683,7 +684,9 @@ class EcFlexpart(object): self._mk_targetname(ftype, pk, retr_param_dict['date'].split('/')[0]) - retr_param_dict['param'] = pv[0] + table128 = init128(_config.PATH_GRIBTABLE) + ids = to_param_id_with_tablenumber(pv[0], table128) + retr_param_dict['param'] = ids retr_param_dict['levtype'] = pv[1] retr_param_dict['levelist'] = pv[2] retr_param_dict['grid'] = pv[3] @@ -1237,7 +1240,7 @@ class EcFlexpart(object): ------ ''' - print('... disaggregation or precipitation with new method.') + print('... disaggregation of precipitation with new method.') lsp_new_np = np.zeros((ni * nj, nt * 3), dtype=np.float64) cp_new_np = np.zeros((ni * nj, nt * 3), dtype=np.float64) @@ -1268,11 +1271,6 @@ class EcFlexpart(object): filename1 = c.prefix + date.strftime('%y%m%d%H') + '_1' filename2 = c.prefix + date.strftime('%y%m%d%H') + '_2' - # collect for final processing - self.outputfilelist.append(os.path.basename(fluxfilename)) - self.outputfilelist.append(os.path.basename(filename1)) - self.outputfilelist.append(os.path.basename(filename2)) - # write original time step to flux file as usual fluxfile = GribUtil(os.path.join(c.inputdir, fluxfilename)) fluxfile.set_keys(tmpfile, filemode='a', strict=True, @@ -1448,7 +1446,7 @@ class EcFlexpart(object): timestamp += timedelta(hours=int(cstep)) cdate_hour = datetime.strftime(timestamp, '%Y%m%d%H') - # eliminate all temporary times + # skip all temporary times # which are outside the retrieval period if timestamp < start_period or \ timestamp > end_period: @@ -1544,12 +1542,12 @@ class EcFlexpart(object): pwd = os.getcwd() os.chdir(c.inputdir) if os.stat('fort.21').st_size == 0 and c.eta: - print('Parameter 77 (etadot) is missing, most likely it is \ - not available for this type or date/time\n') + print('Parameter 77 (etadot) is missing, most likely it is ' + 'not available for this type or date / time\n') print('Check parameters CLASS, TYPE, STREAM, START_DATE\n') - my_error(c.mailfail, 'fort.21 is empty while parameter eta \ - is set to 1 in CONTROL file') -#============================================================================================ + my_error('fort.21 is empty while parameter eta ' + 'is set to 1 in CONTROL file') +# ============================================================================================ # write out all output to log file before starting fortran programm sys.stdout.flush() @@ -1559,7 +1557,7 @@ class EcFlexpart(object): error_msg='FORTRAN PROGRAM FAILED!')#shell=True) os.chdir(pwd) -#============================================================================================ +# ============================================================================================ # create name of final output file, e.g. EN13040500 (ENYYMMDDHH) if c.purefc: suffix = cdate[2:8] + '.' + ctime + '.' + cstep @@ -1576,7 +1574,11 @@ class EcFlexpart(object): print("outputfile = " + fnout) # collect for final processing self.outputfilelist.append(os.path.basename(fnout)) -#============================================================================================ + # get additional precipitation subgrid data if available + if c.rrint: + self.outputfilelist.append(os.path.basename(fnout + '_1')) + self.outputfilelist.append(os.path.basename(fnout + '_2')) +# ============================================================================================ # create outputfile and copy all data from intermediate files # to the outputfile (final GRIB input files for FLEXPART) orolsm = os.path.basename(glob.glob(c.inputdir + @@ -1596,7 +1598,7 @@ class EcFlexpart(object): with open(os.path.join(c.outputdir, 'OMEGA'), 'wb') as fout: shutil.copyfileobj(open(os.path.join(c.inputdir, 'fort.25'), 'rb'), fout) -#============================================================================================ +# ============================================================================================ if c.wrf: fwrf.close() @@ -1691,7 +1693,7 @@ class EcFlexpart(object): print('\n\nPostprocessing:\n Format: {}\n'.format(c.format)) - if not c.ecapi: + if _config.FLAG_ON_ECMWFSERVER: print('ecstorage: {}\n ecfsdir: {}\n'. format(c.ecstorage, c.ecfsdir)) print('ectrans: {}\n gateway: {}\n destination: {}\n ' @@ -1713,13 +1715,13 @@ class EcFlexpart(object): error_msg='RENAMING FOR NEW GRIB2 FORMAT ' 'FILES FAILED!') - if c.ectrans and not c.ecapi: + if c.ectrans and _config.FLAG_ON_ECMWFSERVER: execute_subprocess(['ectrans', '-overwrite', '-gateway', c.gateway, '-remote', c.destination, '-source', ofile], error_msg='TRANSFER TO LOCAL SERVER FAILED!') - if c.ecstorage and not c.ecapi: + if c.ecstorage and _config.FLAG_ON_ECMWFSERVER: execute_subprocess(['ecp', '-o', ofile, os.path.expandvars(c.ecfsdir)], error_msg='COPY OF FILES TO ECSTORAGE ' diff --git a/source/python/classes/MarsRetrieval.py b/source/python/classes/MarsRetrieval.py index a8e290291369c83a035cc54a79201fa273277c1d..76f4a22cdecf7fa3fa5e8ca043a6ee717a9044fb 100644 --- a/source/python/classes/MarsRetrieval.py +++ b/source/python/classes/MarsRetrieval.py @@ -34,10 +34,22 @@ import os import sys import subprocess +import traceback # software specific classes and modules from flex_extract sys.path.append('../') import _config +try: + ec_api = True + import ecmwfapi +except ImportError: + ec_api = False + +try: + cds_api = True + import cdsapi +except ImportError: + cds_api = False # ------------------------------------------------------------------------------ # CLASS # ------------------------------------------------------------------------------ @@ -129,7 +141,7 @@ class MarsRetrieval(object): Specifies the meteorological parameter. ''' - def __init__(self, server, public, marsclass="ei", dataset="", type="", + def __init__(self, server, public, marsclass="EA", dataset="", type="", levtype="", levelist="", repres="", date="", resol="", stream="", area="", time="", step="", expver="1", number="", accuracy="", grid="", gaussian="", target="", @@ -157,8 +169,8 @@ class MarsRetrieval(object): marsclass : str, optional Characterisation of dataset. E.g. EI (ERA-Interim), - E4 (ERA40), OD (Operational archive), ea (ERA5). - Default is the ERA-Interim dataset "ei". + E4 (ERA40), OD (Operational archive), EA (ERA5). + Default is the ERA5 dataset "EA". dataset : str, optional For public datasets there is the specific naming and parameter @@ -428,7 +440,7 @@ class MarsRetrieval(object): def data_retrieve(self): '''Submits a MARS retrieval. Depending on the existence of - ECMWF Web-API it is submitted via Python or a + ECMWF Web-API or CDS API it is submitted via Python or a subprocess in the Shell. The parameter for the mars retrieval are taken from the defined class attributes. @@ -451,7 +463,7 @@ class MarsRetrieval(object): del attrs['marsclass'] attrs['class'] = mclass - # prepare target variable as needed for the Web API mode + # prepare target variable as needed for the Web API or CDS API mode # within the dictionary for full access # as a single variable for public access target = attrs.get('target') @@ -474,33 +486,34 @@ class MarsRetrieval(object): # MARS request via Python script if self.server: try: - if self.public: - print('RETRIEVE PUBLIC DATA!') + if cds_api and isinstance(self.server, cdsapi.Client): + print('RETRIEVE ERA5 WITH CDS API!') + self.server.retrieve(_config.CDS_DATASET, + attrs, target) + elif ec_api and isinstance(self.server, ecmwfapi.ECMWFDataServer): + print('RETRIEVE PUBLIC DATA (NOT ERA5)!') self.server.retrieve(attrs) - else: - print('EXECUTE NON-PUBLIC RETRIEVAL!') + elif ec_api and isinstance(self.server, ecmwfapi.ECMWFService): + print('EXECUTE NON-PUBLIC RETRIEVAL (NOT ERA5)!') self.server.execute(attrs, target) - except: - e = sys.exc_info()[0] - print("ERROR: ", e) - print('MARS Request failed!') - if not self.public and os.stat(target).st_size == 0: - print('MARS Request returned no data - ' - 'please check request') - raise IOError - elif self.public and os.stat(target).st_size == 0: - print('Public MARS Request returned no data - ' - 'please check request') - raise IOError else: + print('ERROR:') + print('No match for Web API instance!') raise IOError - # MARS request via extra process in shell + except Exception as e: + print('\n\nMARS Request failed!') + print(e) + tb = sys.exc_info()[2] + print(traceback.format_exc()) + sys.exit() + + # MARS request via call in shell else: request_str = 'ret' for key, value in attrs.iteritems(): request_str = request_str + ',' + key + '=' + str(value) request_str += ',target="' + target + '"' - p = subprocess.Popen(['mars'], + p = subprocess.Popen(['mars', '-p'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, diff --git a/source/python/mods/checks.py b/source/python/mods/checks.py index 9b6d5340cbdd225edc1779bd4b3e6f9018876713..97c27b8ad6569b11f9da9228796c4eb5ae74e95e 100644 --- a/source/python/mods/checks.py +++ b/source/python/mods/checks.py @@ -26,8 +26,11 @@ import os import sys import _config -import exceptions -from tools import my_error, silent_remove +try: + import exceptions +except ImportError: + import builtins as exceptions +from .tools import my_error, silent_remove from datetime import datetime import numpy as np # ------------------------------------------------------------------------------ @@ -295,7 +298,7 @@ def check_step(step, mailfail): int(steps[4])) step = ['{:0>3}'.format(i) for i in ilist] elif 'to' in step.lower() and 'by' not in step.lower(): - my_error(mailfail, step + ':\n' + + my_error(step + ':\n' + 'if "to" is used in steps parameter, ' 'please use "by" as well') else: diff --git a/source/python/mods/get_mars_data.py b/source/python/mods/get_mars_data.py index 4d8aa5e8952b9e93a87eeb330aa79912a861b61a..6dc9dd04e8e0d4ee6164c3accf2861803a66d23e 100755 --- a/source/python/mods/get_mars_data.py +++ b/source/python/mods/get_mars_data.py @@ -66,17 +66,23 @@ from datetime import datetime, timedelta sys.path.append(os.path.dirname(os.path.abspath( inspect.getfile(inspect.currentframe()))) + '/../') import _config -from tools import (my_error, normal_exit, get_cmdline_args, +from .tools import (setup_controldata, my_error, normal_exit, get_cmdline_args, read_ecenv, make_dir) from classes.EcFlexpart import EcFlexpart from classes.UioFiles import UioFiles from classes.MarsRetrieval import MarsRetrieval try: - ecapi = True + ec_api = True import ecmwfapi except ImportError: - ecapi = False + ec_api = False + +try: + cds_api = True + import cdsapi +except ImportError: + cds_api = False # ------------------------------------------------------------------------------ # FUNCTION # ------------------------------------------------------------------------------ @@ -94,16 +100,9 @@ def main(): ''' - args = get_cmdline_args() - c = ControlFile(args.controlfile) - - env_parameter = read_ecenv(_config.PATH_ECMWF_ENV) - c.assign_args_to_control(args) - c.assign_envs_to_control(env_parameter) - c.check_conditions(args.queue) - + c, _, _, _ = setup_controldata() get_mars_data(c) - normal_exit(c.mailops, c.queue, 'Done!') + normal_exit('Retrieving MARS data: Done!') return @@ -124,7 +123,8 @@ def get_mars_data(c): ------ ''' - c.ecapi = ecapi + c.ec_api = ec_api + c.cds_api = cds_api if not os.path.exists(c.inputdir): make_dir(c.inputdir) @@ -181,7 +181,11 @@ def write_reqheader(marsfile): return def mk_server(c): - '''Creates server connection if ECMWF WebAPI is available. + '''Creates a server connection with available python API. + + Which API is used depends on availability and the dataset to be retrieved. + The CDS API is used for ERA5 dataset no matter if the user is a member or + a public user. ECMWF WebAPI is used for all other available datasets. Parameters ---------- @@ -191,19 +195,24 @@ def mk_server(c): Return ------ - server : ECMWFDataServer or ECMWFService - Connection to ECMWF server via python interface ECMWF WebAPI. + server : ECMWFDataServer, ECMWFService or Client + Connection to ECMWF server via python interface ECMWF WebAPI or CDS API. ''' - if c.ecapi: + if cds_api and (c.marsclass.upper() == 'EA'): + server = cdsapi.Client() + c.ec_api = False + elif c.ec_api: if c.public: server = ecmwfapi.ECMWFDataServer() else: server = ecmwfapi.ECMWFService("mars") + c.cds_api = False else: server = False - print('Using ECMWF WebAPI: ' + str(c.ecapi)) + print('Using ECMWF WebAPI: ' + str(c.ec_api)) + print('Using CDS API: ' + str(c.cds_api)) return server @@ -352,7 +361,7 @@ def do_retrievement(c, server, start, end, delta_t, fluxes=False): try: flexpart.retrieve(server, dates, c.public, c.request, c.inputdir) except IOError: - my_error(c.mailfail, 'MARS request failed') + my_error('MARS request failed') day += delta_t diff --git a/source/python/mods/prepare_flexpart.py b/source/python/mods/prepare_flexpart.py index f0f1904316515bad4b0bcce8cf2c0a41ae4c633a..b55494492b6a85c68c67347a6924e14c06feb5e0 100755 --- a/source/python/mods/prepare_flexpart.py +++ b/source/python/mods/prepare_flexpart.py @@ -70,19 +70,13 @@ import socket sys.path.append(os.path.dirname(os.path.abspath( inspect.getfile(inspect.currentframe()))) + '/../') import _config -from checks import check_ppid +from .checks import check_ppid from classes.UioFiles import UioFiles from classes.ControlFile import ControlFile -from tools import clean_up, get_cmdline_args, read_ecenv, make_dir +from .tools import (setup_controldata, clean_up, get_cmdline_args, + read_ecenv, make_dir) from classes.EcFlexpart import EcFlexpart -ecapi = 'ecmwf' not in socket.gethostname() -try: - if ecapi: - import ecmwfapi -except ImportError: - ecapi = False - # ------------------------------------------------------------------------------ # FUNCTION # ------------------------------------------------------------------------------ @@ -100,15 +94,9 @@ def main(): ''' - args = get_cmdline_args() - c = ControlFile(args.controlfile) - - env_parameter = read_ecenv(_config.PATH_ECMWF_ENV) - c.assign_args_to_control(args) - c.assign_envs_to_control(env_parameter) - c.check_conditions(args.queue) - - prepare_flexpart(args.ppid, c) + c, ppid, _, _ = setup_controldata() + prepare_flexpart(ppid, c) + normal_exit('Preparing FLEXPART output files: Done!') return @@ -136,8 +124,6 @@ def prepare_flexpart(ppid, c): ''' check_ppid(c, ppid) - c.ecapi = ecapi - # create the start and end date start = datetime.date(year=int(c.start_date[:4]), month=int(c.start_date[4:6]), diff --git a/source/python/mods/tools.py b/source/python/mods/tools.py index e498c308e21f95ac6fc2922afd6042b43b464d6e..2cd1ec9ab87afd54911cb6becb73cde9229e754f 100644 --- a/source/python/mods/tools.py +++ b/source/python/mods/tools.py @@ -64,14 +64,54 @@ import sys import glob import subprocess import traceback -import exceptions +try: + import exceptions +except ImportError: + import builtins as exceptions from datetime import datetime from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter + + # ------------------------------------------------------------------------------ # METHODS # ------------------------------------------------------------------------------ +def setup_controldata(): + '''Collects, stores and checks controlling arguments from command line, + CONTROL file and ECMWF_ENV file. + + Parameters + ---------- + + Return + ------ + c : ControlFile + Contains all the parameters of CONTROL file and + command line. + + ppid : str + Parent process id. + + queue : str + Name of queue for submission to ECMWF (e.g. ecgate or cca ) + + job_template : str + Name of the job template file for submission to ECMWF server. + ''' + import _config + from classes.ControlFile import ControlFile + + args = get_cmdline_args() + c = ControlFile(args.controlfile) + c.assign_args_to_control(args) + if os.path.isfile(_config.PATH_ECMWF_ENV): + env_parameter = read_ecenv(_config.PATH_ECMWF_ENV) + c.assign_envs_to_control(env_parameter) + c.check_conditions(args.queue) + + return c, args.ppid, args.queue, args.job_template + def none_or_str(value): '''Converts the input string into pythons None-type if the string contains string "None". @@ -258,14 +298,12 @@ def clean_up(c): print("... clean inputdir!") - cleanlist = glob.glob(os.path.join(c.inputdir, "*")) + cleanlist = [file for file in glob.glob(os.path.join(c.inputdir, "*")) + if not os.path.basename(file).startswith(c.prefix)] if cleanlist: for element in cleanlist: - if c.prefix not in element: - silent_remove(element) - if c.ecapi is False and (c.ectrans == 1 or c.ecstorage == 1): - silent_remove(element) + silent_remove(element) print("... done!") else: print("... nothing to clean!") @@ -273,17 +311,12 @@ def clean_up(c): return -def my_error(users, message='ERROR'): +def my_error(message='ERROR'): '''Prints a specified error message which can be passed to the function before exiting the program. Parameters ---------- - user : list of str - Contains all email addresses which should be notified. - It might also contain just the ecmwf user name which wil trigger - mailing to the associated email address for this user. - message : str, optional Error message. Default value is "ERROR". @@ -463,8 +496,8 @@ def init128(filepath): 'table file: ' + str(filepath)) else: for data in fdata: - if data[0] != '!': - table128[data[0:3]] = data[59:64].strip() + if data != '' and data[0] != '!': + table128[data[0:3]] = data[59:65].strip() return table128 @@ -508,6 +541,47 @@ def to_param_id(pars, table): return ipar +def to_param_id_with_tablenumber(pars, table): + '''Transform parameter names to parameter ids and add table id. + + Conversion with ECMWF grib table 128. + + Parameters + ---------- + pars : str + Addpar argument from CONTROL file in the format of + parameter names instead of ids. The parameter short + names are sepearted with "/" and they are passed as + one single string. + + table : dict + Contains the ECMWF grib table 128 information. + The key is the parameter number and the value is the + short name of the parameter. + + Return + ------ + spar : str + List of addpar parameters from CONTROL file transformed to + parameter ids in the format of integer. + ''' + if not pars: + return [] + if not isinstance(pars, str): + pars=str(pars) + + cpar = pars.upper().split('/') + spar = [] + for par in cpar: + for k, v in table.iteritems(): + if par == k or par == v: + spar.append(k + '.128') + break + else: + print('\n\n\t\tWarning: par ' + par + ' not found in table 128\n\n') + + return '/'.join(spar) + def get_list_as_string(list_obj, concatenate_sign=', '): '''Converts a list of arbitrary content into a single string. diff --git a/source/python/submit.py b/source/python/submit.py index bd9ab6ffe76c7b0921d3f722e0b688ebfdba893f..bd9f74e0c0b7d9714b79388512595ef07871a796 100755 --- a/source/python/submit.py +++ b/source/python/submit.py @@ -66,7 +66,7 @@ from datetime import datetime, timedelta # software specific classes and modules from flex_extract import _config -from mods.tools import (normal_exit, get_cmdline_args, +from mods.tools import (setup_controldata, normal_exit, get_cmdline_args, submit_job_to_ecserver, read_ecenv) from mods.get_mars_data import get_mars_data from mods.prepare_flexpart import prepare_flexpart @@ -90,31 +90,25 @@ def main(): ''' - args = get_cmdline_args() - c = ControlFile(args.controlfile) - - env_parameter = read_ecenv(_config.PATH_ECMWF_ENV) - c.assign_args_to_control(args) - c.assign_envs_to_control(env_parameter) - c.check_conditions(args.queue) + c, ppid, queue, job_template = setup_controldata() # on local side - # on ECMWF server this would also be the local side + # starting from an ECMWF server this would also be the local side called_from_dir = os.getcwd() - if args.queue is None: + if queue is None: if c.inputdir[0] != '/': c.inputdir = os.path.join(called_from_dir, c.inputdir) if c.outputdir[0] != '/': c.outputdir = os.path.join(called_from_dir, c.outputdir) get_mars_data(c) if c.request == 0 or c.request == 2: - prepare_flexpart(args.ppid, c) + prepare_flexpart(ppid, c) exit_message = 'FLEX_EXTRACT IS DONE!' else: exit_message = 'PRINTING MARS_REQUESTS DONE!' # send files to ECMWF server else: - submit(args.job_template, c, args.queue) + submit(job_template, c, queue) exit_message = 'FLEX_EXTRACT JOB SCRIPT IS SUBMITED!' normal_exit(exit_message)