Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bin/ExternalAnalysisToMPAS.csh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ sed -i 's@nCells@'${ArgNCells}'@' $NamelistFileInit
sed -i 's@{{meshRatio}}@'${ArgRatio}'@' $NamelistFileInit
sed -i 's@{{UngribPrefix}}@'${externalanalyses__UngribPrefix}'@' $NamelistFileInit

# ERA5 adjustments
if ( "${externalanalyses__UngribPrefix}" == "ERA5" ) then
sed -i "s@config_met_prefix = .*@config_met_prefix = 'ERA5'@g" $NamelistFileInit
sed -i "s@config_nfglevels = .*@config_nfglevels = 138@g" $NamelistFileInit
sed -i "s@config_use_spechumd = .*@config_use_spechumd = true@g" $NamelistFileInit
endif

# Run the executable
# ==================
rm ./${InitEXE}
Expand Down
92 changes: 92 additions & 0 deletions bin/GetERA5AnalysisFromGDEX.csh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/csh -f

# (C) Copyright 2023 UCAR
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.

# Get GFS analysis (0-h forecast) for cold start initial conditions

# Process arguments
# =================
## args
# ArgDT: int, valid time offset beyond CYLC_TASK_CYCLE_POINT in hours
set ArgDT = "$1"

# ArgWorkDir: my location
set ArgWorkDir = "$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/auto/build.csh
source config/auto/experiment.csh
source config/tools.csh
set ccyymmdd = `echo ${CYLC_TASK_CYCLE_POINT} | cut -c 1-8`
set hh = `echo ${CYLC_TASK_CYCLE_POINT} | cut -c 10-11`
set thisCycleDate = ${ccyymmdd}${hh}
set thisValidDate = `$advanceCYMDH ${thisCycleDate} ${ArgDT}`
set prevValidDate = `$advanceCYMDH ${thisCycleDate} -6`

source ./bin/getCycleVars.csh

set cyyyy = `echo ${thisValidDate} | cut -c1-4`
set cmm = `echo ${thisValidDate} | cut -c5-6`
set cdd = `echo ${thisValidDate} | cut -c7-8`
set chh = `echo ${thisValidDate} | cut -c9-10`
set datestr = "${cyyyy}-${cmm}-${cdd}_${chh}"

set WorkDir = ${ExperimentDirectory}/`echo "$ArgWorkDir" \
| sed 's@{{thisValidDate}}@'${thisValidDate}'@' \
`
echo "WorkDir = ${WorkDir}"
mkdir -p ${WorkDir}
cd ${WorkDir}

# ================================================================================================

if ( -e GETSUCCESS ) then
echo "$0 (INFO): GETSUCCESS file already exists, exiting with success"
echo "$0 (INFO): if regenerating the output files is desired, delete GETSUCCESS"

date

exit 0
endif

# ================================================================================================

echo "Getting ERA5 analysis from GDEX"

# Link ECMWF coefficients
ln -sf $era5_to_intBuildDir/ecmwf_coeffs .

# Convert ERA5 NetCDF to WPS intermediate
Comment thread
jim-p-w marked this conversation as resolved.
setenv myCommand `$era5_to_intBuildDir/$era5_to_int ${datestr}`
echo "$myCommand"
${myCommand}

# Build ERA5 intermediate filename (YYYY-MM-DD_HH)
set era5file = ERA5:${datestr}

# Check that ERA5 intermediate file exists
if ( ! -e ${era5file} ) then
echo "${era5file} not found -- exiting"
exit 1
endif

echo "ERA5 intermediate file created successfully: ${era5file}"

date

touch GETSUCCESS

exit 0
34 changes: 28 additions & 6 deletions initialize/data/ExternalAnalyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ def __init__(self, config:Config, hpc:HPC, meshes:dict):
'queue': {'def': hpc['SharedQueue']},
'account': {'def': hpc['CriticalAccount']},
}
ungribjob = Resource(self._conf, attr, ('job', 'ungrib'))
self.__ungribtask = TaskLookup[hpc.system](ungribjob)
if self['externalanalyses__UngribPrefix'] == 'GFS':
ungribjob = Resource(self._conf, attr, ('job', 'ungrib'))
self.__ungribtask = TaskLookup[hpc.system](ungribjob)
else:
self.__ungribtask = None

#########
# outputs
Expand Down Expand Up @@ -169,6 +172,25 @@ def export(self, dtOffsets:list=[0]):
[['''+base+''']]
inherit = '''+base+zeroHR]

# ERA5 GDEX
base = 'GetERA5AnalysisFromGDEX'
queue = 'GetExternalAnalyses'
if base in self['PrepareExternalAnalysisOuter']:
subqueues.append(queue)
taskNames[base] = base+dtLen
self._tasks += ['''
[['''+taskNames[base]+''']]
inherit = '''+queue+''', SingleBatch
script = $origin/bin/'''+base+'''.csh '''+dt_work_Args+'''
execution time limit = PT20M
execution retry delays = '''+self.__getRetry]

# generic 0hr task name for external classes/tasks to grab
if dt == 0:
self._tasks += ['''
[['''+base+''']]
inherit = '''+base+zeroHR]

# GFS RDA
base = 'GetGFSAnalysisFromRDA'
queue = 'GetExternalAnalyses'
Expand Down Expand Up @@ -210,13 +232,13 @@ def export(self, dtOffsets:list=[0]):
# ungrib
base = 'UngribExternalAnalysis'
queue = 'UngribExternalAnalyses'
if base in self['PrepareExternalAnalysisOuter']:
if base in self['PrepareExternalAnalysisOuter'] and self['externalanalyses__UngribPrefixOuter'] != 'ERA5':
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I try to run test/testinput/3dvar_OIE120km_ColdStart.yaml this line is throwing an exception. It looks like the key externalanalyses__UngribPrefixOuter doesn't exist for that scenario.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out @jim-p-w! I should have checked this more carefully. I found a solution by doing if self.__ungribtask is not None: instead. I will add this fix into my open PR.

subqueues.append(queue)
taskNames[base] = base+dtLen
self._tasks += ['''
[['''+taskNames[base]+''']]
inherit = '''+queue+''', BATCH
script = $origin/bin/'''+base+'''.csh '''+dt_work_Args+'''
[['''+taskNames[base]+''']]
inherit = '''+queue+''', BATCH
script = $origin/bin/'''+base+'''.csh '''+dt_work_Args+'''
'''+self.__ungribtask.job()+self.__ungribtask.directives()]

# generic 0hr task name for external classes/tasks to grab
Expand Down
4 changes: 4 additions & 0 deletions initialize/framework/Build.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ def __init__(self, config:Config, model:Model=None):
# Non-bundle applications
# =======================

# ERA5 to intermediate file
self._set('era5_to_int', 'era5_to_int.py')
self._set('era5_to_intBuildDir', '/glade/campaign/mmm/parc/ivette/pandac/converters/era5_to_int')

# Ungrib
# ------
self._set('ungribEXE', 'ungrib.exe')
Expand Down
17 changes: 17 additions & 0 deletions scenarios/GenerateERA5Analyses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
suite: GenerateExternalAnalyses

externalanalyses:
resource: "ERA5.GDEX"
experiment:
name: 'GenerateERA5Analyses'
prefix: ''
model:
outerMesh: 120km
hpc:
CriticalPriority: economy
NonCriticalPriority: economy
#CriticalQueue: main
#NonCriticalQueue: main
workflow:
first cycle point: 20220606T00
final cycle point: 20220606T06
Comment thread
jim-p-w marked this conversation as resolved.
12 changes: 12 additions & 0 deletions scenarios/defaults/externalanalyses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,15 @@ externalanalyses:
- "GetGDASAnalysisFromFTP"
#Vtable: /glade/campaign/mmm/parc/liuz/pandac_common/vtables/Vtable.GFS.O3MR
retry: '40*PT10M'

ERA5:
GDEX:
common:
UngribPrefix: ERA5
PrepareExternalAnalysisTasks:
- "GetERA5AnalysisFromGDEX"
- "ExternalAnalysisToMPAS-{{mesh}}"
- "ExternalAnalysisReady__"
job:
GetAnalysisFrom:
retry: '3*PT5S'