source: flex_extract.git/Source/Python/_config.py @ 5cff464

dev
Last change on this file since 5cff464 was 5cff464, checked in by Anne Tipka <anne.tipka@…>, 19 months ago

switched using compilejob.sh and using batch submit to install software

  • Property mode set to 100644
File size: 7.3 KB
Line 
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3#*******************************************************************************
4# @Author: Anne Philipp (University of Vienna)
5#
6# @Date: August 2018
7#
8# @Change History:
9#      June 2020 - Anne Philipp
10#         - changed template filenames to .template
11#      August 2020 - Leopold Haimberger
12#         - added another target for installation
13#         - added filename which will contain paths for system version
14#         - checks if software runs in normal local mode or system local mode
15#           and defines paths to user directory and executable paths
16#      July 2022 - Anne Tipka (formerly Philipp)
17#         - modified to account for changes on Bologna servers,
18#           e.g. queue names and hostnames
19#      August 2022 - Anne Tipka (formerly Philipp)
20#         - changed name of compilejob.ksh to compilejob.sh
21#
22# @License:
23#    (C) Copyright 2014-2020.
24#    Anne Philipp, Leopold Haimberger
25#
26#    SPDX-License-Identifier: CC-BY-4.0
27#
28#    This work is licensed under the Creative Commons Attribution 4.0
29#    International License. To view a copy of this license, visit
30#    http://creativecommons.org/licenses/by/4.0/ or send a letter to
31#    Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
32#*******************************************************************************
33'''Configurations for flex_extract.
34
35Defines a couple of global constant parameters as well as filenames
36and pathes.
37'''
38# ------------------------------------------------------------------------------
39# MODULES
40# ------------------------------------------------------------------------------
41import os
42import sys
43import inspect
44import platform
45
46# ------------------------------------------------------------------------------
47# PARAMETERS
48# ------------------------------------------------------------------------------
49
50_VERSION_STR = '7.1.3'
51
52HOSTNAMES_BOLOGNA_LIST = ['ecs', 'aa', 'ab', 'ac', 'ad']
53HOSTNAMES_READING_LIST = ['ecgb', 'cca', 'ccb']
54
55# name of environment variable on ECMWF Bologna servers
56# that indicates which cluster / host we are on
57HOSTENV_BOLOGNA = 'EC_CLUSTER'
58# name of environment variable on ECMWF Reading servers
59# that indicates which cluster / host we are on
60HOSTENV_READING = 'ECPLATFORM'
61
62# test if we are on a Bologna or Reading server
63
64# Test and set ECMWF Bologna server values
65if os.getenv(HOSTENV_BOLOGNA) is not None:
66    ec_hostname = os.getenv(HOSTENV_BOLOGNA)
67    FLAG_ON_ECMWFSERVER = ec_hostname in HOSTNAMES_BOLOGNA_LIST
68    QUEUES_LIST = ['ecs', 'hpc']
69# Test and set ECMWF Reading server values
70elif os.getenv(HOSTENV_READING) is not None:
71    ec_hostname = os.getenv(HOSTENV_READING)
72    FLAG_ON_ECMWFSERVER = ec_hostname in HOSTNAMES_READING_LIST
73    QUEUES_LIST = ['ecgate', 'cca', 'ccb']
74else:
75    FLAG_ON_ECMWFSERVER = False
76
77QUEUES_LIST_ALL = ['ecs', 'hpc', 'ecgate', 'cca', 'ccb']
78
79INSTALL_TARGETS = ['local', 'syslocal', 'ecgate', 'cca', 'ccb', 'ecs', 'hpc']
80
81CDS_DATASET_ML = 'reanalysis-era5-complete'
82CDS_DATASET_SFC = 'reanalysis-era5-single-levels'
83
84# up-to-date available maximum level numbers at ECMWF, 05.10.2018
85MAX_LEVEL_LIST = [16, 19, 31, 40, 50, 60, 62, 91, 137]
86
87# ------------------------------------------------------------------------------
88# FILENAMES
89# ------------------------------------------------------------------------------
90
91FILE_MARS_REQUESTS = 'mars_requests.csv'
92FORTRAN_EXECUTABLE = 'calc_etadot'
93TEMPFILE_USER_ENVVARS = 'ECMWF_ENV.template'
94FILE_USER_ENVVARS = 'ECMWF_ENV'
95TEMPFILE_INSTALL_COMPILEJOB = 'installscript.template'
96FILE_INSTALL_COMPILEJOB = 'compilejob.sh'
97TEMPFILE_INSTALL_JOB = 'jobscript.template'
98TEMPFILE_JOB = 'submitscript.template'
99FILE_JOB_OD = 'job.ksh'
100FILE_JOB_OP = 'jopoper.ksh'
101TEMPFILE_NAMELIST = 'calc_etadot_nml.template'
102FILE_NAMELIST = 'fort.4'
103FILE_GRIB_INDEX = 'date_time_stepRange.idx'
104FILE_GRIBTABLE = 'ecmwf_grib1_table_128'
105FILE_SYS_CONFIG = '.setup.rc'
106
107# ------------------------------------------------------------------------------
108# DIRECTORY NAMES
109# ------------------------------------------------------------------------------
110
111FLEXEXTRACT_DIRNAME = 'flex_extract_v' + _VERSION_STR
112INPUT_DIRNAME_DEFAULT = 'Workspace'
113
114# ------------------------------------------------------------------------------
115#  LOAD ENVIRONMENT VARIABLES FOR SYS VERSION; IF NECESSARRY
116# ------------------------------------------------------------------------------
117
118# path to the local python source files
119# first thing to get because the submitted python script starts in here
120PATH_LOCAL_PYTHON = os.path.dirname(os.path.abspath(
121    inspect.getfile(inspect.currentframe())))
122# add path to pythonpath
123if PATH_LOCAL_PYTHON not in sys.path:
124    sys.path.append(PATH_LOCAL_PYTHON)
125
126# ------------------------------------------------------------------------------
127#  PATHES
128# ------------------------------------------------------------------------------
129
130PATH_FLEXEXTRACT_DIR = os.path.normpath(os.path.dirname(os.path.abspath(
131    inspect.getfile(inspect.currentframe()))) + '/../../')
132if not os.path.isdir(os.path.join(PATH_FLEXEXTRACT_DIR,'Run')):
133    # if it does not exist, we have a system installation in place
134    # we need to have a sys and user path
135    # configure correct system path
136    PATH_SYSTEM_DIR = os.path.join(PATH_FLEXEXTRACT_DIR, FLEXEXTRACT_DIRNAME)
137    # configure correct user path
138    PATH_FLEXEXTRACT_DIR = os.environ.get('FLEXEXTRACT_USER_DIR')
139else:
140    PATH_SYSTEM_DIR = PATH_FLEXEXTRACT_DIR
141
142PATH_RUN_DIR = os.path.join(PATH_FLEXEXTRACT_DIR, 'Run')
143PATH_SOURCES = os.path.join(PATH_SYSTEM_DIR, 'Source')
144PATH_TEMPLATES = os.path.join(PATH_FLEXEXTRACT_DIR, 'Templates')
145PATH_ECMWF_ENV = os.path.join(PATH_RUN_DIR, FILE_USER_ENVVARS)
146PATH_GRIBTABLE = os.path.join(PATH_TEMPLATES, FILE_GRIBTABLE)
147PATH_JOBSCRIPTS = os.path.join(PATH_RUN_DIR, 'Jobscripts')
148if os.path.isdir(os.path.join(PATH_SYSTEM_DIR,'Fortran')):
149    PATH_FORTRAN_SRC = PATH_SYSTEM_DIR
150else:
151    PATH_FORTRAN_SRC = os.path.join(PATH_SOURCES, 'Fortran')
152PATH_PYTHONTEST_SRC = os.path.join(PATH_SOURCES, 'Pythontest')
153PATH_INPUT_DIR = os.path.join(PATH_RUN_DIR, INPUT_DIRNAME_DEFAULT)
154PATH_TEST = os.path.join(PATH_FLEXEXTRACT_DIR, 'Testing')
155if os.getenv('CONTROL'):
156    # this is only needed if (gateway) version with job script is used!
157    # because job is directly submitted from SCRATCH and because the
158    # CONTROL file is stored there, the normal path is not valid.
159    PATH_CONTROLFILES = '.'
160else:
161    PATH_CONTROLFILES = os.path.join(PATH_RUN_DIR, 'Control')
162#
163# ------------------------------------------------------------------------------
164# RELATIVE PATHES FOR INSTALLATION TAR-BALL
165# ------------------------------------------------------------------------------
166
167PATH_REL_PYTHON_SRC = os.path.relpath(PATH_LOCAL_PYTHON, PATH_FLEXEXTRACT_DIR)
168PATH_REL_PYTHONTEST_SRC = os.path.relpath(PATH_PYTHONTEST_SRC, PATH_FLEXEXTRACT_DIR)
169PATH_REL_CONTROLFILES = os.path.relpath(PATH_CONTROLFILES, PATH_FLEXEXTRACT_DIR)
170PATH_REL_TEMPLATES = os.path.relpath(PATH_TEMPLATES, PATH_FLEXEXTRACT_DIR)
171PATH_REL_ECMWF_ENV = os.path.relpath(PATH_ECMWF_ENV, PATH_FLEXEXTRACT_DIR)
172PATH_REL_RUN_DIR = os.path.relpath(PATH_RUN_DIR, PATH_FLEXEXTRACT_DIR)
173PATH_REL_JOBSCRIPTS = os.path.relpath(PATH_JOBSCRIPTS, PATH_FLEXEXTRACT_DIR)
174PATH_REL_FORTRAN_SRC = os.path.relpath(PATH_FORTRAN_SRC, PATH_FLEXEXTRACT_DIR)
175PATH_REL_TEST = os.path.relpath(PATH_TEST, PATH_FLEXEXTRACT_DIR)
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG