10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-12-22 20:35:19 +01:00

Added mpirun in OCaml

This commit is contained in:
Anthony Scemama 2017-07-22 12:50:11 +02:00
parent a5d16ebe29
commit 18f2145b3f
3 changed files with 13 additions and 4 deletions

View File

@ -15,7 +15,7 @@ let print_list () =
let () = let () =
Random.self_init () Random.self_init ()
let run slave exe ezfio_file = let run slave mpi_command exe ezfio_file =
(** Check availability of the ports *) (** Check availability of the ports *)
@ -115,13 +115,17 @@ let run slave exe ezfio_file =
match Sys.getenv "QP_PREFIX" with match Sys.getenv "QP_PREFIX" with
| Some x -> x^" " | Some x -> x^" "
| None -> "" | None -> ""
and mpi_command =
match mpi_command with
| Some mpirun -> mpirun^" "
| None -> ""
and exe = and exe =
match (List.find ~f:(fun (x,_) -> x = exe) executables) with match (List.find ~f:(fun (x,_) -> x = exe) executables) with
| Some (_,x) -> x^" " | Some (_,x) -> x^" "
| None -> assert false | None -> assert false
in in
let exit_code = let exit_code =
match (Sys.command (prefix^exe^ezfio_file)) with match (Sys.command (prefix^mpi_command^exe^ezfio_file)) with
| 0 -> 0 | 0 -> 0
| i -> (Printf.printf "Program exited with code %d.\n%!" i; i) | i -> (Printf.printf "Program exited with code %d.\n%!" i; i)
in in
@ -142,6 +146,8 @@ let spec =
empty empty
+> flag "slave" no_arg +> flag "slave" no_arg
~doc:(" Needed for slave tasks") ~doc:(" Needed for slave tasks")
+> flag "mpirun" (optional string)
~doc:(" mpi launcher with its options")
+> anon ("executable" %: string) +> anon ("executable" %: string)
+> anon ("ezfio_file" %: string) +> anon ("ezfio_file" %: string)
;; ;;
@ -159,8 +165,8 @@ Executes a Quantum Package binary file among these:\n\n"
) )
) )
spec spec
(fun slave exe ezfio_file () -> (fun slave mpi_command exe ezfio_file () ->
run slave exe ezfio_file run slave mpi_command exe ezfio_file
) )
|> Command.run ~version: Git.sha1 ~build_info: Git.message |> Command.run ~version: Git.sha1 ~build_info: Git.message

View File

@ -7,6 +7,7 @@ subroutine mpi_bcast_psi()
integer :: ierr integer :: ierr
IRP_IF MPI IRP_IF MPI
include 'mpif.h'
call MPI_BCast(N_states, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) 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(N_det, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
call MPI_BCast(psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr) call MPI_BCast(psi_det_size, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)

View File

@ -29,6 +29,7 @@ END_PROVIDER
PROVIDE MPI_Initialized PROVIDE MPI_Initialized
IRP_IF MPI IRP_IF MPI
include 'mpif.h'
integer :: ierr integer :: ierr
call mpi_comm_size(MPI_COMM_WORLD, MPI_size, ierr) call mpi_comm_size(MPI_COMM_WORLD, MPI_size, ierr)
if (ierr /= 0) then if (ierr /= 0) then
@ -56,6 +57,7 @@ subroutine qp_mpi_finalize()
implicit none implicit none
PROVIDE MPI_Initialized PROVIDE MPI_Initialized
IRP_IF MPI IRP_IF MPI
include 'mpif.h'
integer :: ierr integer :: ierr
call MPI_Finalize(ierr) call MPI_Finalize(ierr)
if (ierr /= 0) then if (ierr /= 0) then