forked from NCAR/MPAS-Workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExternalAnalysisToMPAS.csh
More file actions
executable file
·130 lines (100 loc) · 3.41 KB
/
ExternalAnalysisToMPAS.csh
File metadata and controls
executable file
·130 lines (100 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/csh -f
# Process arguments
# =================
## args
# ArgMesh: str, mesh name, one of model.allMeshes
set ArgMesh = "$1"
# ArgDT: int, valid time offset beyond CYLC_TASK_CYCLE_POINT in hours
set ArgDT = "$2"
set test = `echo $ArgDT | grep '^[0-9]*$'`
set isNotInt = ($status)
if ( $isNotInt ) then
echo "ERROR in $0 : ArgDT must be an integer, not $ArgDT"
exit 1
endif
date
# Setup environment
# =================
source config/model.csh
source config/experiment.csh
source config/builds.csh
source config/environmentJEDI.csh
source config/applications/initic.csh
source config/externalanalyses.csh
source config/tools.csh
set yymmdd = `echo ${CYLC_TASK_CYCLE_POINT} | cut -c 1-8`
set hh = `echo ${CYLC_TASK_CYCLE_POINT} | cut -c 10-11`
set thisCycleDate = ${yymmdd}${hh}
set thisValidDate = `$advanceCYMDH ${thisCycleDate} ${ArgDT}`
source ./getCycleVars.csh
# static work directory
if ("$ArgMesh" == "$outerMesh") then
set WorkDir = ${ExternalAnalysisDirOuter}
set nCells = $nCellsOuter
set filePrefix = $externalanalyses__filePrefixOuter
else if ("$ArgMesh" == "$innerMesh") then
set WorkDir = ${ExternalAnalysisDirInner}
set nCells = $nCellsInner
set filePrefix = $externalanalyses__filePrefixInner
else if ("$ArgMesh" == "$ensembleMesh") then
set WorkDir = ${ExternalAnalysisDirEnsemble}
set nCells = $nCellsEnsemble
set filePrefix = $externalanalyses__filePrefixEnsemble
else
echo "$0 (ERROR): invalid ArgMesh ($ArgMesh)"
exit 1
endif
echo "WorkDir = ${WorkDir}"
mkdir -p ${WorkDir}
cd ${WorkDir}
# ================================================================================================
# only need to continue if output file does not already exist
set outputFile = $filePrefix.$thisMPASFileDate.nc
if ( -e $outputFile ) then
set oSize = `du -sh $outputFile | sed 's@'$outputFile'@@'`
if ( "$oSize" != "0" ) then
echo "$0 (INFO): outputFile ($outputFile) already exists, exiting with success"
echo "$0 (INFO): if regenerating the outputFile is desired, delete the original"
date
exit 0
endif
rm $outputFile
endif
# ================================================================================================
## link ungribbed files
ln -sfv ${ExternalAnalysisDir}/${externalanalyses__UngribPrefix}* ./
## link MPAS mesh graph info and static field
rm ./x1.${nCells}.graph.info*
ln -sfv $GraphInfoDir/x1.${nCells}.graph.info* .
ln -sfv $GraphInfoDir/x1.${nCells}.static.nc .
## link lookup tables
foreach fileGlob ($MPASLookupFileGlobs)
rm ./*${fileGlob}
ln -sfv ${MPASLookupDir}/*${fileGlob} .
end
## copy/modify dynamic streams file
rm ${StreamsFileInit}
cp -v $ModelConfigDir/$AppName/${StreamsFileInit} .
sed -i 's@{{nCells}}@'${nCells}'@' ${StreamsFileInit}
sed -i 's@{{PRECISION}}@'${model__precision}'@' ${StreamsFileInit}
## copy/modify dynamic namelist
rm ${NamelistFileInit}
cp -v $ModelConfigDir/$AppName/${NamelistFileInit} .
sed -i 's@startTime@'${thisMPASNamelistDate}'@' $NamelistFileInit
sed -i 's@nCells@'${nCells}'@' $NamelistFileInit
sed -i 's@{{UngribPrefix}}@'${externalanalyses__UngribPrefix}'@' $NamelistFileInit
# Run the executable
# ==================
rm ./${InitEXE}
ln -sfv ${InitBuildDir}/${InitEXE} ./
mpiexec ./${InitEXE}
# Check status
# ============
grep "Finished running the init_${MPASCore} core" log.init_${MPASCore}.0000.out
if ( $status != 0 ) then
rm $outputFile
echo "ERROR in $0 : MPAS-init failed" > ./FAIL
exit 1
endif
date
exit 0