Skip to content

Commit ccba211

Browse files
Matiasclaude
authored andcommitted
fix: pair instances with weather folders by index in run_c2f.sh
Replace nested loop (all combinations) with a single index loop so instance[i] always runs with weather_folder[i]. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0d754db commit ccba211

1 file changed

Lines changed: 23 additions & 26 deletions

File tree

run_c2f.sh

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,35 @@ COMMON_FLAGS=(
4141
)
4242

4343
# ============================================================
44-
# Loop: each instance × each weather folder
44+
# Loop: instance[i] paired with weather_folder[i]
4545
# ============================================================
46-
for instance in "${INSTANCES[@]}"; do
47-
if [[ -z "$instance" ]]; then
48-
echo "Skipping empty instance entry" >&2
46+
for i in "${!INSTANCES[@]}"; do
47+
instance="${INSTANCES[$i]}"
48+
weather_folder="${WEATHER_FOLDERS[$i]}"
49+
50+
if [[ -z "$instance" || -z "$weather_folder" ]]; then
51+
echo "Skipping empty entry at index $i" >&2
4952
continue
5053
fi
51-
# Derive a short name from the TIF filename (no path, no extension)
52-
instance_name=$(basename "$instance" .tif)
5354

54-
for weather_folder in "${WEATHER_FOLDERS[@]}"; do
55-
if [[ -z "$weather_folder" ]]; then
56-
echo "Skipping empty weather folder entry" >&2
57-
continue
58-
fi
59-
weather_name=$(basename "$weather_folder")
55+
instance_name=$(basename "$instance" .tif)
56+
weather_name=$(basename "$weather_folder")
6057

61-
out_dir="${OUT_BASE}/${instance_name}/${weather_name}"
62-
mkdir -p "$out_dir"
58+
out_dir="${OUT_BASE}/${instance_name}/${weather_name}"
59+
mkdir -p "$out_dir"
6360

64-
echo "============================================================"
65-
echo "Instance : $instance_name"
66-
echo "Weather : $weather_name"
67-
echo "Output : $out_dir"
68-
echo "============================================================"
61+
echo "============================================================"
62+
echo "Run $((i+1))"
63+
echo "Instance : $instance_name"
64+
echo "Weather : $weather_name"
65+
echo "Output : $out_dir"
66+
echo "============================================================"
6967

70-
"$BINARY" \
71-
--instance-tif "$instance" \
72-
--weather-folder "$weather_folder" \
73-
--output-folder "$out_dir" \
74-
"${COMMON_FLAGS[@]}"
68+
"$BINARY" \
69+
--instance-tif "$instance" \
70+
--weather-folder "$weather_folder" \
71+
--output-folder "$out_dir" \
72+
"${COMMON_FLAGS[@]}"
7573

76-
echo ""
77-
done
74+
echo ""
7875
done

0 commit comments

Comments
 (0)