#!/bin/bash # Pipe output to file #exec &> 'profiles.log' # Function to handle the interrupt signal function handle_interrupt() { echo "Caught interrupt signal..." exit 0 } # Set the trap to call the handle_interrupt function when SIGINT is received trap handle_interrupt SIGINT # Find executables in cgcam directory function check_exec() { cgcam_dir="$HOME/cgcam/src" if [ -z "$1" ]; then echo "ERROR: supply executable for check_exec" exit 1 fi if [ ! -e "$1" ]; then if [ ! -e "$cgcam_dir/$1" ]; then echo "ERROR: Unable to find $1 in $cgcam_dir" exit 1 fi ln -s $cgcam_dir/$1 . fi } # Round down UTC times for data sampled on the hour function round_time() { if [ -z "$1" ]; then echo "ERROR: supply time for round_time" exit 1 fi IFS_OLD=$IFS IFS=":" read -ra utc <<< "$1" if [[ ${#utc[@]} -gt 1 ]]; then time=${utc[0]} mins=${utc[1]} # if [[ $mins -gt 50 ]]; then # time=$(( $time + 1 )) # fi else time=$utc fi IFS=$IFS_OLD return $time } # Command line arguments -f:force rerun of found directory -s:skip python/merge_wind # To replot use (-f -s) force='false' skip='false' argc=$# argv=("$@") for (( j=0; j apiera.py if [ $skip == 'false' ]; then echo -e "\nRetrieving ERA5 file for $mm/$dd/$yyyy" python3 apiera.py fi cd $case_dir fi # JAWARA should already be downloaded jawara_file="$yy$mm.nc" if [ ! -f "$jawara_dir/Z$jawara_file" ]; then echo "ERROR: Unable to locate jawara data $jawara_dir/?$jawara_file" continue fi # Convert data sed -e "s|YEAR|$yyyy|g" -e "s|MONTH|$mm|g" -e "s|DAY|$dd|g" -e "s|LON|$lon|g" -e "s|LAT|$lat|g" -e "s|ITIME|$time|g" -e "s|ERA_FILE|$era_file|g" -e "s|ERA_DIR|$era_dir|g" -e "s|JAWARA_FILE|$jawara_file|g" -e "s|JAWARA_DIR|$jawara_dir|g" input_tmp.py > input_convert.py check_exec "convert_assim_data.py" if [ $skip == 'false' ]; then echo -e "\nConverting Data" python3 convert_assim_data.py fi # Merge wind to get profile check_exec "merge_wind" echo -e "zo0 $z0\nzo1 $z1\ndz0 $dz\nref_lon $lon\nref_lat $lat\nref_itime 1\nz_blend1 $z_blend\ndz_blend1 $dz_blend\nn_smooth_z $n_smooth" > merge_wind.inp if [ $skip == 'false' ]; then echo -e "\nMerging Sources" ./merge_wind fi # Plot winds file=$(ls out*prof.out) if (( $(echo "$lon < 0" | bc -l) )); then lon=${lon/"-"} hem_ew='W' else lon=$lon hem_ew='E' fi if (( $(echo "$lat < 0" | bc -l) )); then lat=${lat/"-"} hem_ns='S' else lat=$lat hem_ns='N' fi sed -e "s|YY|$yy|g" -e "s|MM|$mm|g" -e "s|DD|$dd|g" -e "s|LON|$lon|g" -e "s|HEM_EW|$hem_ew|g" -e "s|LAT|$lat|g" -e "s|HEM_NS|$hem_ns|g" -e "s|TIM|$tt|g" -e "s|YTICS|$ytics|g" -e "s|XTICS|$xtics|g" -e "s|FILE|$file|g" wind_tmp.gpt > wind.gpt echo -e "\nPlotting Wind (ignore terminal warning)" gnuplot wind.gpt cd $wrk_dir done