From 797e294b5f1180fe29c4d7678f1ba2f120bd85ea Mon Sep 17 00:00:00 2001
From: Damian Rouson <rouson@lbl.gov>
Date: Sun, 10 Nov 2024 21:22:23 -0800
Subject: [PATCH 1/2] chore(assert): update dependency version to 2.0.0

---
 fpm.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fpm.toml b/fpm.toml
index 379178226..0f4888a70 100644
--- a/fpm.toml
+++ b/fpm.toml
@@ -5,5 +5,5 @@ author = "Damian Rouson, Tan Nguyen, Jordan Welsman, David Torres, Brad Richards
 maintainer = "rouson@lbl.gov"
 
 [dependencies]
-assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.7.0"}
+assert = {git = "https://github.com/sourceryinstitute/assert", tag = "2.0.0"}
 julienne = {git = "https://github.com/berkeleylab/julienne", tag = "1.5.3"}

From 61956696bc1d048f3a3313121ba0561ef98cfe26 Mon Sep 17 00:00:00 2001
From: Damian Rouson <rouson@lbl.gov>
Date: Sun, 10 Nov 2024 21:22:58 -0800
Subject: [PATCH 2/2] chore(script): auomate file search

---
 scripts/create-single-source-file-programs.sh | 131 ++++--------------
 1 file changed, 25 insertions(+), 106 deletions(-)

diff --git a/scripts/create-single-source-file-programs.sh b/scripts/create-single-source-file-programs.sh
index 69d41afb1..02eb5d9ac 100755
--- a/scripts/create-single-source-file-programs.sh
+++ b/scripts/create-single-source-file-programs.sh
@@ -4,14 +4,18 @@
 # ----
 # This script concatenates the Fiats software stack into single-source-file programs.
 
+export assert_dir="../build/dependencies/assert"
+export julienne_dir="../build/dependencies/julienne"
+export fiats_dir=".."
+
 echo ""
 echo "---------------------- create-single-source-file.sh ----------------------------"
-if [ ! -d ../build/dependencies/assert ] || [ ! -d ../build/dependencies/julienne ]; then
+if [ ! -d "$assert_dir" ] || [ ! -d $julienne_dir ]; then
   echo ""
   echo ""
-  echo "Dependencies assert and julienne were not found in ../build/dependencies." 
-  echo "Running fpm build to download the dependencies." 
-  echo "This unavoidably builds fiats too." 
+  echo "Dependencies assert and/or julienne were not found in ../build/dependencies."
+  echo "Running fpm build to download the dependencies."
+  echo "This unavoidably builds fiats too."
   echo ""
   echo ""
   fpm build
@@ -24,110 +28,25 @@ else
   exit 1
 fi
 
-echo "Concatenating Assert, Julienne, and Fiats." 
-cat \
-  ../build/dependencies/assert/src/assert/characterizable_m.f90 \
-  ../build/dependencies/assert/src/assert/intrinsic_array_m.F90 \
-  ../build/dependencies/assert/src/assert/assert_subroutine_m.F90 \
-  ../build/dependencies/assert/src/assert/intrinsic_array_s.F90 \
-  ../build/dependencies/assert/src/assert/assert_subroutine_s.F90 \
-  ../build/dependencies/assert/src/assert_m.f90 \
-> single-file.F90
-
-cat \
-  ../build/dependencies/julienne/src/julienne/julienne_github_ci_m.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_bin_m.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_command_line_m.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_formats_m.F90 \
-  ../build/dependencies/julienne/src/julienne/julienne_user_defined_collectives_m.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_string_m.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_file_m.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_test_result_m.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_test_description_m.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_test_m.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_vector_test_description_m.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_bin_s.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_command_line_s.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_formats_s.F90 \
-  ../build/dependencies/julienne/src/julienne/julienne_user_defined_collectives_s.F90 \
-  ../build/dependencies/julienne/src/julienne/julienne_string_s.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_file_s.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_test_result_s.F90 \
-  ../build/dependencies/julienne/src/julienne/julienne_test_description_s.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_test_s.F90 \
-  ../build/dependencies/julienne/src/julienne/julienne_vector_test_description_s.f90 \
-  ../build/dependencies/julienne/src/julienne/julienne_github_ci_s.f90 \
-  ../build/dependencies/julienne/src/julienne_m.f90 \
->> single-file.F90
-  
-cat \
-  ../src/fiats/kind_parameters_m.f90 \
-  ../src/fiats/double_precision_file_m.f90 \
-  ../src/fiats/double_precision_string_m.f90 \
-  ../src/fiats/activation_m.f90 \
-  ../src/fiats/hyperparameters_m.f90 \
-  ../src/fiats/network_configuration_m.f90 \
-  ../src/fiats/training_configuration_m.f90 \
-  ../src/fiats/neuron_m.f90 \
-  ../src/fiats/neural_network_m.f90 \
-  ../src/fiats/metadata_m.f90 \
-  ../src/fiats/tensor_m.f90 \
-  ../src/fiats/tensor_names_m.f90 \
-  ../src/fiats/input_output_pair_m.f90 \
-  ../src/fiats/mini_batch_m.f90 \
-  ../src/fiats/tensor_map_m.f90 \
-  ../src/fiats/layer_m.f90 \
-  ../src/fiats/trainable_network_m.F90 \
-  ../src/fiats_m.f90 \
-  ../src/fiats/double_precision_file_s.f90 \
-  ../src/fiats/double_precision_string_s.f90 \
-  ../src/fiats/training_configuration_s.F90 \
-  ../src/fiats/activation_s.f90 \
-  ../src/fiats/unmapped_network_s.f90 \
-  ../src/fiats/workspace_s.f90 \
-  ../src/fiats/network_configuration_s.F90 \
-  ../src/fiats/hyperparameters_s.f90 \
-  ../src/fiats/input_output_pair_s.f90 \
-  ../src/fiats/neuron_s.f90 \
-  ../src/fiats/neural_network_s.F90 \
-  ../src/fiats/layer_s.f90 \
-  ../src/fiats/metadata_s.f90 \
-  ../src/fiats/mini_batch_s.f90 \
-  ../src/fiats/tensor_s.f90 \
-  ../src/fiats/tensor_map_s.f90 \
-  ../src/fiats/tensor_names_s.f90 \
-  ../src/fiats/trainable_network_s.F90 \
->> single-file.F90
-
-echo "Creating concurrent-inferences.F90"
-cat single-file.F90 \
-  ../example/concurrent-inferences.f90 \
-> concurrent-inferences.F90
+echo "Concatenating Assert." 
+assert_modules=$(find "$assert_dir/src" -name '*_m.?90')
+assert_submodules=$(find "$assert_dir/src" -name '*_s.?90')
+cat ${assert_include:-} $assert_modules $assert_submodules > assert.F90
 
-if [ ! -f concurrent-inferences.F90 ]; then
-  echo "concurrent-inferences.F90 wasn't created -- something went wrong"
-  exit 1
-fi
+echo "Concatenating Julienne." 
+julienne_modules=$(find "$julienne_dir/src" -name '*_m.?90')
+julienne_submodules=$(find "$julienne_dir/src" -name '*_s.?90')
+cat $julienne_modules $julienne_submodules > julienne.F90
 
-echo "Creating saturated-mixing-ratio.F90"
-cat single-file.F90 \
-  ../example/supporting-modules/saturated_mixing_ratio_m.f90 \
-  ../example/learn-saturated-mixing-ratio.F90 \
-> saturated-mixing-ratio.F90
+echo "Concatenating Fiats." 
+fiats_modules=$(find "$fiats_dir/src" -name '*_m.?90')
+fiats_submodules=$(find "$fiats_dir/src" -name '*_s.?90')
+cat $fiats_modules $fiats_submodules > fiats.F90
 
-if [ ! -f saturated-mixing-ratio.F90 ]; then
-  echo "saturated-mixing-ratio.F90 wasn't created -- something went wrong"
-  exit 1
-fi
-
-echo "saturated-mixing-ratio.F90 and concurrent-inferences.F90 created."
-echo ""
-echo "Example compile commands:"
-echo 'gfortran -fcoarray=single -O3 -o saturated-mixing-ratio saturated-mixing-ratio.F90'
-echo 'flang-new -O3 -mmlir -allow-assumed-rank -o saturated-mixing-ratio saturated-mixing-ratio.F90'
-echo 'nagfor -fpp -O4 -o saturated-mixing-ratio saturated-mixing-ratio.F90'
-echo 'ifx -O3 -o saturated-mixing-ratio saturated-mixing-ratio.F90'
+echo "Copying include files." 
+cp "$assert_dir/include/assert_macros.h" .
+cat "$julienne_dir/include/language-support.F90" "$fiats_dir/include/language-support.F90" > language-support.F90
 
-rm single-file.F90
 
-echo "-------------------------------------------------------------------------"
+echo "Concatenating Assert, Julienne, Fiats, and example/concurrent-inferences.f90." 
+cat assert.F90 julienne.F90 fiats.F90 "$fiats_dir/example/concurrent-inferences.f90" > concurrent-inferences-single-file.F90
