Skip to content

Commit

Permalink
Add mstm serial and parallel
Browse files Browse the repository at this point in the history
Make the parallel version default
  • Loading branch information
arunoruto committed Oct 21, 2024
1 parent f4679a5 commit b9696f9
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pkgs: {
zluda-rocm5 = pkgs.callPackage ./zluda-rocm5/package.nix {};
candy-icons = pkgs.callPackage ./candy-icons/package.nix {};
mstm = pkgs.callPackage ./mstm/parallel.nix {};
}
34 changes: 34 additions & 0 deletions pkgs/mstm/example1.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
! calculations for figure 1
output_file
mstm-2022b-fig1.dat
number_spheres
2
sphere_data
0.d0,0.d0,-5.d0,5.d0,(1.6d0,0.d0)
0.d0,0.d0,2.5d0,2.5d0,(1.d0,0.d0)
end_of_sphere_data
number_plane_boundaries
2
layer_thickness
5.d0
layer_ref_index
(1.d0,0.d0),(1.6d0,0.d0),(1.d0,0.d0)
incident_beta_deg
0.d0
incident_alpha_deg
0.d0
length_scale_factor
1.d0
calculate_scattering_matrix
f
calculate_near_field
t
near_field_minimum_border
-10.d0,0.d0,-10.d0
near_field_maximum_border
10.d0,0.d0,10.d0
near_field_step_size
0.1d0
near_field_output_file
nf-fig1.dat
end_of_options
73 changes: 73 additions & 0 deletions pkgs/mstm/parallel.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
stdenv,
lib,
makeWrapper,
fetchFromGitHub,
gfortran,
mpi,
}:
stdenv.mkDerivation rec {
pname = "mstm";
version = "v4.0.0";
# version = "4-2024-02-08";

src = fetchFromGitHub {
owner = "dmckwski";
repo = pname;
rev = version;
hash = "sha256-gIlZMHE7vNDtRtzdYRtXeo+PBgJHi911AJaXzMn/wpI=";
};

buildInputs = [
makeWrapper
];

nativeBuildInputs = [
gfortran
mpi
];

preInstallPhase = ''
mkdir -p $out/bin
cat >> $out/bin/mstm << EOF
#!/usr/bin/env bash
if [[ \$# -eq 1 ]]; then
mpiexec -n 4 $out/bin/mstm-mpi \$1
else
mpiexec -n \$1 $out/bin/mstm-mpi \$2
fi
EOF
chmod +x $out/bin/mstm
'';

buildPhase = ''
cd ./code
mpif90 -O2 -fallow-argument-mismatch -c -o mstm-intrinsics.obj mstm-intrinsics.f90
mpif90 -O2 -fallow-argument-mismatch -c -o mpidefs-parallel.obj mpidefs-parallel.f90
mpif90 -O2 -fallow-argument-mismatch -c -o mstm.obj mstm-v4.0.f90
mpif90 -O2 -fallow-argument-mismatch -o mstm-mpi mstm-intrinsics.obj mpidefs-parallel.obj mstm.obj
'';

installPhase = ''
runHook preInstallPhase
mkdir -p $out/bin
cp ${pname}-mpi $out/bin
runHook postInstallPhase
'';

postInstallPhase = ''
wrapProgram $out/bin/mstm \
--prefix PATH : ${lib.makeBinPath [mpi]}
'';

meta = with lib; {
homepage = "https://github.com/dmckwski/MSTM";
description = "Multiple Sphere T Matrix code in Fortran - parallel edition";
license = licenses.mit;
platforms = platforms.linux;
maintainers = with maintainers; [arunoruto];
};
}
43 changes: 43 additions & 0 deletions pkgs/mstm/serial.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
stdenv,
lib,
fetchFromGitHub,
gfortran,
}:
stdenv.mkDerivation rec {
pname = "mstm";
version = "v4.0.0";
# version = "4-2024-02-08";

src = fetchFromGitHub {
owner = "dmckwski";
repo = pname;
rev = version;
hash = "sha256-gIlZMHE7vNDtRtzdYRtXeo+PBgJHi911AJaXzMn/wpI=";
};

nativeBuildInputs = [
gfortran
];

buildPhase = ''
cd ./code
gfortran -O2 -fallow-argument-mismatch -c -o mstm-intrinsics.obj mstm-intrinsics.f90
gfortran -O2 -fallow-argument-mismatch -c -o mpidefs-serial.obj mpidefs-serial.f90
gfortran -O2 -fallow-argument-mismatch -c -o mstm.obj mstm-v4.0.f90
gfortran -O2 -fallow-argument-mismatch -o mstm mstm-intrinsics.obj mpidefs-serial.obj mstm.obj
'';

installPhase = ''
mkdir -p $out/bin
cp ${pname} $out/bin
'';

meta = with lib; {
homepage = "https://github.com/dmckwski/MSTM";
description = "Multiple Sphere T Matrix code in Fortran";
license = licenses.mit;
platforms = platforms.linux;
maintainers = with maintainers; [arunoruto];
};
}

0 comments on commit b9696f9

Please sign in to comment.