Skip to content
Snippets Groups Projects
Commit 858a469d authored by Oriol Tintó's avatar Oriol Tintó
Browse files

Update prepare_experiment.sh to download additional grid info files.

parent 6a348b1a
No related branches found
No related tags found
No related merge requests found
Pipeline #19093 passed
...@@ -29,12 +29,45 @@ function download_file() { ...@@ -29,12 +29,45 @@ function download_file() {
fi fi
} }
function check_url() {
# Check if the url exists
local url="$1"
status=$(
(curl -s --head $url | head -n 1 | grep "HTTP/2 200 " >/dev/null)
echo $?
)
if [ $status -eq 0 ]; then
echo "true"
else
echo "false"
fi
}
function get_grfinfo_file(){
local filename="$1"
new_suffix="-grfinfo.nc"
new_filename="$(basename "$filename" .nc)$new_suffix"
echo "$new_filename"
}
# Download grid files and external parameters # Download grid files and external parameters
BASEURL=http://icon-downloads.mpimet.mpg.de/grids/public/edzw BASEURL=http://icon-downloads.mpimet.mpg.de/grids/public/edzw
download_file $BASEURL/${DYNAMICS_GRID_FILENAME} download_file $BASEURL/${DYNAMICS_GRID_FILENAME}
download_file $BASEURL/${RADIATION_GRID_FILE} download_file $BASEURL/${RADIATION_GRID_FILE}
download_file $BASEURL/${EXTERNAL_PARAMETERS_FILE} download_file $BASEURL/${EXTERNAL_PARAMETERS_FILE}
# In case the grfinfo files exist, we download them as well
RADIATION_GRID_INFO_FILE=$( get_grfinfo_file ${RADIATION_GRID_FILE} )
DYNAMICS_GRID_INFO_FILE=$( get_grfinfo_file ${DYNAMICS_GRID_FILENAME} )
if [ $( check_url "$BASEURL/${RADIATION_GRID_INFO_FILE}" ) == "true" ]; then
download_file "$BASEURL/${RADIATION_GRID_INFO_FILE}"
fi
if [ $( check_url "$BASEURL/${DYNAMICS_GRID_INFO_FILE}" ) == "true" ]; then
download_file "$BASEURL/${DYNAMICS_GRID_INFO_FILE}"
fi
# Define the function # Define the function
function grid_filename_from_extpar() { function grid_filename_from_extpar() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment