source: flex_extract.git/Source/Python/_config.py @ 01bd8aa

dev
Last change on this file since 01bd8aa was 01bd8aa, checked in by Anne Tipka <anne.tipka@…>, 22 months ago

added history comments to previous commit changes and minor additional corrections

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