From 324c7b4243c6b332e1c57c2bf1ef4c8de22ce0ea Mon Sep 17 00:00:00 2001
From: Frits Sweijen <tikk3r@noreply.github.com>
Date: Mon, 23 Oct 2023 15:32:25 +0200
Subject: [PATCH] Fix step execution order

---
 workflows/linc_target/gsmcal.cwl | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/workflows/linc_target/gsmcal.cwl b/workflows/linc_target/gsmcal.cwl
index 5bb2ae4e..e0d81bf3 100644
--- a/workflows/linc_target/gsmcal.cwl
+++ b/workflows/linc_target/gsmcal.cwl
@@ -355,7 +355,7 @@ steps:
     in:
       - id: msin
         source: 
-          - aoflag/output_ms
+          - merge_array_concat/output
       - id: group_id
         source: sort_times_into_freqGroups_full/groupnames
       - id: groups_specification
@@ -427,6 +427,15 @@ steps:
     scatter:
       - msin
 
+  - id: merge_array
+    in:
+      - id: input
+        source: check_unflagged_fraction/msout
+    out:
+      - id: output
+    run: ../../steps/merge_array.cwl
+    label: merge_array
+
   - id: merge_array_files
     in:
       - id: input
@@ -444,15 +453,7 @@ steps:
       - id: output
     run: ../../steps/check_filtered_MS_array.cwl
     label: check_filtered_MS_array
-  
-  - id: merge_array
-    in:
-      - id: input
-        source: check_unflagged_fraction/msout
-    out:
-      - id: output
-    run: ../../steps/merge_array.cwl
-    label: merge_array
+
 
   - id: calibrate_target
     in:
@@ -479,7 +480,8 @@ steps:
     label: calibrate_target
     scatter:
       - msin
-    when: $(!inputs.execute)
+    when: $(!inputs.execute || inputs.selfcal_strategy == 'HBA')
+
   - id: selfcal_target
     in:
       - id: max_dp3_threads
-- 
GitLab