From 18f2145b3fe652c1f99bbe0f40255b68ba70ccb3 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 22 Jul 2017 12:50:11 +0200 Subject: [PATCH] Added mpirun in OCaml --- ocaml/qp_run.ml | 14 ++++++++++---- plugins/MPI/bcast.irp.f | 1 + plugins/MPI/utils.irp.f | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ocaml/qp_run.ml b/ocaml/qp_run.ml index 5a656d2d..9d3121c9 100644 --- a/ocaml/qp_run.ml +++ b/ocaml/qp_run.ml @@ -15,7 +15,7 @@ let print_list () = let () = Random.self_init () -let run slave exe ezfio_file = +let run slave mpi_command exe ezfio_file = (** Check availability of the ports *) @@ -115,13 +115,17 @@ let run slave exe ezfio_file = match Sys.getenv "QP_PREFIX" with | Some x -> x^" " | None -> "" + and mpi_command = + match mpi_command with + | Some mpirun -> mpirun^" " + | None -> "" and exe = match (List.find ~f:(fun (x,_) -> x = exe) executables) with | Some (_,x) -> x^" " | None -> assert false in let exit_code = - match (Sys.command (prefix^exe^ezfio_file)) with + match (Sys.command (prefix^mpi_command^exe^ezfio_file)) with | 0 -> 0 | i -> (Printf.printf "Program exited with code %d.\n%!" i; i) in @@ -142,6 +146,8 @@ let spec = empty +> flag "slave" no_arg ~doc:(" Needed for slave tasks") + +> flag "mpirun" (optional string) + ~doc:(" mpi launcher with its options") +> anon ("executable" %: string) +> anon ("ezfio_file" %: string) ;; @@ -159,8 +165,8 @@ Executes a Quantum Package binary file among these:\n\n" ) ) spec - (fun slave exe ezfio_file () -> - run slave exe ezfio_file + (fun slave mpi_command exe ezfio_file () -> + run slave mpi_command exe ezfio_file ) |> Command.run ~version: Git.sha1 ~build_info: Git.message diff --git a/plugins/MPI/bcast.irp.f b/plugins/MPI/bcast.irp.f index 493ffc83..7a9e1a92 100644 --- a/plugins/MPI/bcast.irp.f +++ b/plugins/MPI/bcast.irp.f @@ -7,6 +7,7 @@ subroutine mpi_bcast_psi() integer :: ierr IRP_IF MPI + include 'mpif.h' call MPI_BCast(N_states, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) call MPI_BCast(N_det, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) call MPI_BCast(psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) diff --git a/plugins/MPI/utils.irp.f b/plugins/MPI/utils.irp.f index aa4e0742..81abca7d 100644 --- a/plugins/MPI/utils.irp.f +++ b/plugins/MPI/utils.irp.f @@ -29,6 +29,7 @@ END_PROVIDER PROVIDE MPI_Initialized IRP_IF MPI + include 'mpif.h' integer :: ierr call mpi_comm_size(MPI_COMM_WORLD, MPI_size, ierr) if (ierr /= 0) then @@ -56,6 +57,7 @@ subroutine qp_mpi_finalize() implicit none PROVIDE MPI_Initialized IRP_IF MPI + include 'mpif.h' integer :: ierr call MPI_Finalize(ierr) if (ierr /= 0) then