source: TOOLS/WATER_BUDGET/libIGCM.py

Last change on this file was 6620, checked in by omamce, 8 months ago

WATER_BUDET (by OM) : OK for SECHIBA on LMD grid. Still need improvment for ICO.

File size: 5.2 KB
Line 
1import sys, os, subprocess, pathlib
2
3
4# Where do we run ?
5SysName, NodeName, Release, Version, Machine = os.uname ()
6
7def unDefined (char) :
8    if char in globals () :
9        if globals ()[char] == None : unDefined = True
10        else                        : unDefined = False
11    else : unDefined = True
12    return unDefined
13
14def Mach () :
15
16    Mach     = 'unknown'
17   
18    if SysName == 'Darwin' and 'lsce5138' in NodeName : Mach = 'Spip'
19    if 'obelix'    in NodeName : Mach = 'Obelix'
20    if 'forge'     in NodeName : Mach = 'Forge'
21    if 'ciclad'    in NodeName : Mach = 'Ciclad' 
22    if 'spiritx'   in NodeName : Mach = 'SpiritX'
23    if 'spiritj'   in NodeName : Mach = 'SpiritJ'
24    if 'spirit'    in NodeName : Mach = 'SpiritJ'
25    if 'irene'     in NodeName : Mach = 'Irene'               
26    if 'jean-zay'  in NodeName : Mach = 'Jean-Zay'
27
28    return Mach
29
30def MachFull () :
31    _Mach = Mach ()
32    MachFull = _Mach
33   
34    if _Mach == 'Irene' :
35        lscpu  = subprocess.getoutput ('lscpu')
36        ccc_os = subprocess.getoutput ('ccc_os')
37       
38        if "Intel(R) Xeon(R) Platinum" in lscpu:
39            if "Atos_7__x86_64" in ccc_os : MachFull = 'Irene'
40            if "Rhel_8__x86_64" in ccc_os : MachFull = 'Irene-Next'
41                   
42        if "AMD" in lscpu | grep : 
43            if "Atos_7__x86_64" in ccc_os : MachFull = 'Rome'
44            if "Rhel_8__x86_64" in ccc_os : MachFull = 'Rome-Next'
45               
46    return MachFull
47
48def config ( TagName=None, SpaceName=None, ExperimentName=None, JobName=None, User=None, Project=None,
49             ARCHIVE=None, SCRATCHDIR=None, STORAGE=None, R_IN=None, R_OUT=None, R_FIG=None,
50             R_SAVE=None, R_FIGR=None, R_BUFR=None, R_BUF_KSH=None, REBUILD_DIR=None, POST_DIR=None, rebuild=None ) :
51
52    if User == None : User == os.environ ['USER']
53    _Mach = Mach ()
54   
55    if _Mach == 'Spip' :
56        if unDefined ( 'ARCHIVE'    ) : ARCHIVE     = os.path.join ( pathlib.Path.home (), 'Data' )
57        if unDefined ( 'SCRATCHDIR' ) : SCRATCHDIR  = os.path.join ( pathlib.Path.home (), 'Scratch' )
58        if unDefined ( 'STORAGE'    ) : STORAGE     = ARCHIVE
59   
60    if _Mach == 'Irene' :
61        if Project == None : Project = os.path.basename ( os.environ ['ALL_CCCHOME'] )
62        if unDefined ( 'R_IN' ) : R_IN = os.path.join ( subprocess.getoutput ( f'ccc_home --cccwork -d igcmg -u igcmg' ), 'IGCM')
63        if Project == None or User == None : 
64            ARCHIVE     = os.environ ['CCCSTOREDIR']
65            STORAGE     = os.environ ['CCCWORKDIR']
66            SCRATCHDIR  = os.environ ['CCCSCRATCHDIR']
67        else :
68            if unDefined ( 'ARCHIVE'    ) : ARCHIVE     = subprocess.getoutput ( f'ccc_home --cccstore   -u {User} -d {Project}' )
69            if unDefined ( 'STORAGE'    ) : STORAGE     = subprocess.getoutput ( f'ccc_home --cccwork    -u {User} -d {Project}' )
70            if unDefined ( 'SCRATCHDIR' ) : SCRATCHDIR  = subprocess.getoutput ( f'ccc_home --cccscratch -u {User} -d {Project}' )
71
72    if unDefined ('rebuild' ) :
73        rebuild = os.path.join ( subprocess.getoutput ( f'ccc_home --ccchome -d igcmg -u igcmg' ), 'Tools', Machine, 'rebuild_nemo', 'bin', 'rebuild_nemo' )
74               
75    if _Mach == 'Jean-Zay' :               
76        if unDefined ( 'ARCHIVE'    ) : ARCHIVE     = os.getenv ( 'CCFRSTORE'   )
77        if unDefined ( 'STORAGE'    ) : STORAGE     = os.getenv ( 'CCFRWORK'    ) 
78        if unDefined ( 'SCRATCHDIR' ) : SCRATCHDIR  = os.getenv ( 'CCFRSCRATCH' ) 
79        if unDefined ( 'R_IN'       ) : R_IN        = os.path.join ('/', 'gpfswork', 'rech', 'psl', 'commun', 'IGCM' )
80        if unDefined ( 'rebuild'    ) :
81            rebuild    = os.path.join ( '/', 'gpfswork', 'rech', 'psl', 'commun', 'Tools', 'rebuild', 'modipsl_IOIPSL_PLUS_v2_2_4', 'bin', 'rebuild' )
82## The construction of the following variables is not machine dependant
83
84    if SpaceName == 'TEST' :
85        if unDefined ( 'R_OUT' ) : R_OUT = os.path.join ( SCRATCHDIR, 'IGCM_OUT' )
86        if unDefined ( 'R_FIG' ) : R_FIG = os.path.join ( SCRATCHDIR, 'IGCM_OUT' )
87    else  :
88        if unDefined ( 'R_OUT' ) : R_OUT = os.path.join ( ARCHIVE   , 'IGCM_OUT' )
89        if unDefined ( 'R_FIG' ) : R_FIG = os.path.join ( STORAGE   , 'IGCM_OUT' )
90       
91    if unDefined ( 'R_BUF'  ) : R_BUF  = os.path.join ( SCRATCHDIR, 'IGCM_OUT' )
92    IGCM_OUT = R_OUT
93
94    L_EXP = os.path.join (TagName, SpaceName, ExperimentName, JobName)
95   
96    if unDefined ( 'R_SAVE'      ) : R_SAVE      = os.path.join ( R_OUT     , L_EXP )
97    if unDefined ( 'R_SAVE'      ) : R_FIGR      = os.path.join ( STORAGE   , 'IGCM_OUT', L_EXP )
98    if unDefined ( 'R_BUFR'      ) : R_BUFR      = os.path.join ( R_BUF     , L_EXP )
99    if unDefined ( 'R_BUF_KSH'   ) : R_BUF_KSH   = os.path.join ( R_BUFR    , 'Out' )
100    if unDefined ( 'REBUILD_DIR' ) : REBUILD_DIR = os.path.join ( R_BUF     , L_EXP, 'REBUILD' )
101    if unDefined ( 'POST_DIR'    ) : POST_DIR    = os.path.join ( R_BUF     , L_EXP, 'Out' )
102       
103    libIGCM = {'ARCHIVE':ARCHIVE,'STORAGE':STORAGE, 'SCRATCHDIR':SCRATCHDIR, 'R_OUT':R_OUT, 'R_BUF':R_BUFR, 'IGCM_OUT':IGCM_OUT, 
104               'R_SAVE':R_SAVE, 'R_FIGR':R_FIGR, 'R_BUFR':R_BUFR, 'REBUILD_DIR':REBUILD_DIR, 'POST_DIR':POST_DIR, 'rebuild':rebuild
105                'User':User }
106
107    return libIGCM
108
Note: See TracBrowser for help on using the repository browser.