3 from SpawnAnalyzeStatsArgs
import args
4 import AnalyzeStats
as mainScript
5 from Analyses
import anWorkingDir
8 from predefined_configs
import outerIter
9 from copy
import deepcopy
10 import JobScript
as js
12 from pathlib
import Path
23 module load python/3.7.5
24 source /glade/u/apps/ch/opt/usr/bin/npl/ncar_pylib.csh
26 setenv pySourceDir PYSOURCE
28 set mainScript = '''+mainScript.__name__+
'''
35 for dep
in mainScript.depends_on:
36 jobbody += [
' '+dep+
' \\']
39 foreach pySource ($pyDepends)
40 ln -sf ${pySourceDir}/${pySource}.py ./
46 python ${mainScript}.py -n NPWORK -r NPREAD -d DIAGSPACE -app JEDIAPP -nout NOUTER >& an.log
47 grep 'Finished main() successfully' an.log
48 if ( $status != 0 ) then
61 Main function that sequentially
62 () collates command-line agruments (SpawnAnalyzeStatsArgs) and static
63 configuration module (config)
64 () loops over selected DiagSpaces, and for each
65 - spawns a job that executes AnalyzeStats on multiple processors
67 DiagSpaceConfig = deepcopy(conf.DiagSpaceConfig)
68 for key
in sorted(DiagSpaceConfig):
69 if not DiagSpaceConfig[key][
'process']: del DiagSpaceConfig[key]
72 selectDiagSpaces =
None
74 selectDiagSpaces = str(args.diagSpaces).split(
',')
77 for key
in sorted(DiagSpaceConfig):
78 if selectDiagSpaces
is not None:
80 for space
in selectDiagSpaces:
81 if space
in key: match =
True
82 if not match: del DiagSpaceConfig[key]
87 scriptDir = Path(args.scriptdir)
90 scriptDir = Path(os.getcwd())
95 if args.account: jobConf[
'account'] = args.account
96 if args.queue: jobConf[
'queue'] = args.queue
97 if args.memory: jobConf[
'memory'] = args.memory
99 jobConf[
'env'] = jobenv
102 for DiagSpace, dsConf
in DiagSpaceConfig.items():
103 myJobConf = deepcopy(jobConf)
105 anGroup = dsConf[
'anGrp']
106 grpAtt = conf.anGroupConfig[anGroup]
107 npwork = grpAtt[
'npwork']
108 npread = grpAtt[
'npread']
109 myJobConf[
'nppernode'] = max(npwork, npread)
110 myJobConf[
'walltime'] = grpAtt[
'analyze_walltime']
112 myJobConf[
'name'] =
'AnStat_'+DiagSpace
115 myJobConf[
'script'] = []
117 'DIAGSPACE': DiagSpace,
119 'PYSOURCE': str(scriptDir),
120 'NPWORK': str(npwork),
121 'NPREAD': str(npread),
122 'JEDIAPP': args.jediAppName,
123 'NOUTER': str(args.nOuterIter),
127 for key, val
in substitutions.items():
128 newline = re.sub(key, val, newline)
129 myJobConf[
'script'] += [newline+
'\n']
131 job = js.JobScriptFactory(myJobConf)
135 if __name__ ==
'__main__':
main()
def anWorkingDir(DiagSpace)