From 03d742f459a2c0e67f653a9e694c70f51d13222c Mon Sep 17 00:00:00 2001 From: Kasra Farmer Date: Sat, 28 Jan 2023 20:13:18 -0500 Subject: [PATCH] correcting to_float() function to print maximum 5 digits after precision point --- canrcm4_wfdei_gem_capa/canrcm4_wfdei_gem_capa.sh | 2 +- conus_i/conus_i.sh | 2 +- conus_ii/conus_ii.sh | 2 +- era5/era5_simplified.sh | 2 +- rdrs/rdrs.sh | 2 +- wfdei_gem_capa/wfdei_gem_capa.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/canrcm4_wfdei_gem_capa/canrcm4_wfdei_gem_capa.sh b/canrcm4_wfdei_gem_capa/canrcm4_wfdei_gem_capa.sh index 7683fb7..e377a79 100755 --- a/canrcm4_wfdei_gem_capa/canrcm4_wfdei_gem_capa.sh +++ b/canrcm4_wfdei_gem_capa/canrcm4_wfdei_gem_capa.sh @@ -138,7 +138,7 @@ unix_epoch () { date --date="$@" +"%s"; } check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; } #convert to float if the number is 'int' -to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; } +to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; } #join array element by the specified delimiter join_by () { local IFS="$1"; shift; echo "$*"; } diff --git a/conus_i/conus_i.sh b/conus_i/conus_i.sh index 306d92b..ea51461 100755 --- a/conus_i/conus_i.sh +++ b/conus_i/conus_i.sh @@ -136,7 +136,7 @@ format_date () { date --date="$1" +"$2"; } check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; } #convert to float if the number is 'int' -to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; } +to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; } #join array element by the specified delimiter join_by () { local IFS="$1"; shift; echo "$*"; } diff --git a/conus_ii/conus_ii.sh b/conus_ii/conus_ii.sh index 824e231..ad500d2 100755 --- a/conus_ii/conus_ii.sh +++ b/conus_ii/conus_ii.sh @@ -137,7 +137,7 @@ format_date () { date --date="$1" +"$2"; } check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; } #convert to float if the number is 'int' -to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; } +to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; } #join array element by the specified delimiter join_by () { local IFS="$1"; shift; echo "$*"; } diff --git a/era5/era5_simplified.sh b/era5/era5_simplified.sh index 801ddd5..b0bf729 100755 --- a/era5/era5_simplified.sh +++ b/era5/era5_simplified.sh @@ -135,7 +135,7 @@ unix_epoch () { date --date="$@" +"%s"; } check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; } #convert to float if the number is 'int' -to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; } +to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; } #join array element by the specified delimiter join_by () { local IFS="$1"; shift; echo "$*"; } diff --git a/rdrs/rdrs.sh b/rdrs/rdrs.sh index c4c1a36..a8ec96b 100755 --- a/rdrs/rdrs.sh +++ b/rdrs/rdrs.sh @@ -135,7 +135,7 @@ unix_epoch () { date --date="$@" +"%s"; } check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; } #convert to float if the number is 'int' -to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; } +to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; } #join array element by the specified delimiter join_by () { local IFS="$1"; shift; echo "$*"; } diff --git a/wfdei_gem_capa/wfdei_gem_capa.sh b/wfdei_gem_capa/wfdei_gem_capa.sh index 41f87e8..642397e 100755 --- a/wfdei_gem_capa/wfdei_gem_capa.sh +++ b/wfdei_gem_capa/wfdei_gem_capa.sh @@ -139,7 +139,7 @@ unix_epoch () { date --date="$@" +"%s"; } check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; } #convert to float if the number is 'int' -to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; } +to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; } #join array element by the specified delimiter join_by () { local IFS="$1"; shift; echo "$*"; }