Skip to content

Commit 03d742f

Browse files
correcting to_float() function to print maximum 5 digits after precision point
1 parent df2b36c commit 03d742f

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

canrcm4_wfdei_gem_capa/canrcm4_wfdei_gem_capa.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ unix_epoch () { date --date="$@" +"%s"; }
138138
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }
139139

140140
#convert to float if the number is 'int'
141-
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
141+
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }
142142

143143
#join array element by the specified delimiter
144144
join_by () { local IFS="$1"; shift; echo "$*"; }

conus_i/conus_i.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ format_date () { date --date="$1" +"$2"; }
136136
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }
137137

138138
#convert to float if the number is 'int'
139-
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
139+
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }
140140

141141
#join array element by the specified delimiter
142142
join_by () { local IFS="$1"; shift; echo "$*"; }

conus_ii/conus_ii.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ format_date () { date --date="$1" +"$2"; }
137137
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }
138138

139139
#convert to float if the number is 'int'
140-
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
140+
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }
141141

142142
#join array element by the specified delimiter
143143
join_by () { local IFS="$1"; shift; echo "$*"; }

era5/era5_simplified.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ unix_epoch () { date --date="$@" +"%s"; }
135135
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }
136136

137137
#convert to float if the number is 'int'
138-
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
138+
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }
139139

140140
#join array element by the specified delimiter
141141
join_by () { local IFS="$1"; shift; echo "$*"; }

rdrs/rdrs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ unix_epoch () { date --date="$@" +"%s"; }
135135
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }
136136

137137
#convert to float if the number is 'int'
138-
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
138+
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }
139139

140140
#join array element by the specified delimiter
141141
join_by () { local IFS="$1"; shift; echo "$*"; }

wfdei_gem_capa/wfdei_gem_capa.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ unix_epoch () { date --date="$@" +"%s"; }
139139
check_real () { if [[ "$1" == *'.'* ]]; then echo 'float'; else echo 'int'; fi; }
140140

141141
#convert to float if the number is 'int'
142-
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "$1"; echo; fi; }
142+
to_float () { if [[ $(check_real $1) == 'int' ]]; then printf "%.1f" "$1"; echo; else printf "%.5f" "$1"; echo; fi; }
143143

144144
#join array element by the specified delimiter
145145
join_by () { local IFS="$1"; shift; echo "$*"; }

0 commit comments

Comments
 (0)