diff --git a/doc/ai4dev/README.md b/doc/ai4dev/README.md new file mode 100644 index 0000000..73cff2c --- /dev/null +++ b/doc/ai4dev/README.md @@ -0,0 +1,34 @@ +Set Up +----------- +With your present working directory set to `doc/ai4dev`, execute +```bash +cd ../../scripts/ +./create-single-source-file-programs.sh +cd ../build/single-file-programs +``` + +Vibe Coding +----------- +1. Compile and execute `diffusion-app.F90` to ensure that the program + terminates normally. For example, with the `gfortran` compiler, + run `gfortran -fcoarray=single -o diffusion-app diffusion-app.F90` + followed by `./diffusion-app`. +2. Edit `diffusion-app.F90` to remove the lines beginning and ending with + `module procedure laplacian` and `end procedure laplacian`, respectively. +3. Enter the file `doc/ai4dev/vibe-coding/README.md` as your prompt and + attach the edited `diffusion-app.F90` file. +4. Insert the resulting function into the `subdomain_s` submodule and + try compiling and executing again to check the result. + +Idiomtic Vibe Coding +-------------------- +1. Compile and execute `test-suite.F90` to and check that the output + reports that all tests pass. For example, with the `gfortran` compiler, + run `gfortran -fcoarray=single -o test-suite test-suite.F90` followed + by `./test-suite`. +2. Edit `test-suite.F90` to remove the lines beginning and ending with + `module procedure laplacian` and `end procedure laplacian`, respectively. +3. Enter the file `doc/ai4dev/idiomaic-vibe-coding/README.md` as your prompt + and attach the edited `tgest-sutie.F90` file. +4. Insert the resulting function into the `subdomain_s` submodule and + try compiling and executing again to check the result. diff --git a/doc/ai4dev/idiomatic-vibe-coding/README.md b/doc/ai4dev/idiomatic-vibe-coding/README.md new file mode 100644 index 0000000..e862b76 --- /dev/null +++ b/doc/ai4dev/idiomatic-vibe-coding/README.md @@ -0,0 +1,14 @@ + +You are a research software engineer who is familiar with Fortran 2018, experienced in parallel and object-oriented programming, and building a software library named "Matcha". All source code that you need is in the attached file. The main program runs a test suite that uses a module subdomain_test_m to report on several correctness checks on the subdomain_m module and subdomain_s submodule. The subdomain_m module also contains a module function interface body named "laplacian". Everything in the source code is complete except that there is no defintion for the "laplacian" function. Provide a defintion for the laplacian function definition using the following steps: + +1. Write an empty module procecure named "laplacian" into which you will insert executable statements and comments that explain what your code is doing. +2. Allocate the laplacian_rhs% component to a shape [my_nx, ny, nz] +3. Use one or more "do concurrent" constructs, each with "default(none)" and any othe required locality specifiers, to compute a 2nd-order central difference approximation to the Laplacian of the "s_" array component of the "laplacian" function's "rhs" dummy argument. +4. Store the Laplacian approximation in the s_ component of the laplacian_rhs function result. +5. When an expresssion requires the value rhs%s_(1,:,:) and me==1, instead use halo_x(west,:,:) for the required value. +5. When an expresssion requires the value rhs%s_(ubound(rhs%s_,1),:,:) and me==num_subdomains, instead use halo_x(east,:,:) for the required value. +6. Set result component laplacian_rhs%s_ to zero for the subscript values (:, 1,:), (:,ny,:), (:,:, 1), (:,:,nz). +7. Also set laplacian_rhs%s_ to zero for the subscript values (1,:,:) if me==1 +8. Also set laplacian_rhs%s_ to zero for the subscript values (my_nx,:,:) if me==num_subdomains. + +When "laplacian" function is incorporated into the subdomain_m module, the attached file must compile and report that all tests passing when executed. diff --git a/scripts/create-single-source-file-programs.sh b/scripts/create-single-source-file-programs.sh index 0d44762..0db79a0 100755 --- a/scripts/create-single-source-file-programs.sh +++ b/scripts/create-single-source-file-programs.sh @@ -7,6 +7,7 @@ export assert_dir="../build/dependencies/assert" export julienne_dir="../build/dependencies/julienne" export matcha_dir=".." +export test_dir="../test" export destination_dir="../build/single-file-programs" echo "" @@ -80,3 +81,7 @@ cp "$julienne_dir/include/julienne-assert-macros.h" "$destination_dir" echo "Concatenating Assert, Julienne, and Matcha src and app into $destination_dir/diffusion-app.F90" cat "$destination_dir"/assert.F90 "$destination_dir"/julienne.F90 "$destination_dir"/matcha.F90 "$matcha_dir/app/diffusion.f90" > $destination_dir/diffusion-app.F90 + +echo "Concatenating Assert, Julienne, and Matcha src and test into $destination_dir/test-suite.F90" +test_modules=$(find "$test_dir" -name '*_m.?90') +cat "$destination_dir"/assert.F90 "$destination_dir"/julienne.F90 "$destination_dir"/matcha.F90 $test_modules "$test_dir"/main.F90 > $destination_dir/test-suite.F90 diff --git a/src/matcha/subdomain_s.F90 b/src/matcha/subdomain_s.F90 index afdddf0..fb80ec9 100644 --- a/src/matcha/subdomain_s.F90 +++ b/src/matcha/subdomain_s.F90 @@ -142,7 +142,7 @@ if (me==1) laplacian_rhs%s_(1,:,:) = 0. ! low-x boundary if (me==num_subdomains) laplacian_rhs%s_(my_nx,:,:) = 0. ! high-x boundary - end procedure + end procedure laplacian module procedure multiply call_assert(allocated(rhs%s_))