#
# start-methods.ccl
#
# This file contains the system start method definitions for ANSYS CFX
#
# Local changes to this file may be made by copying it into
#   <CFX_ROOT>/config/start-methods.ccl
# for system-wide changes, or for per-user modifications,
#   <HOME>/.cfx/<CFXBUILDID>/start-methods.ccl
# or
#   <USERPROFILE>\.cfx\<CFXBUILDID>\start-methods.ccl
# for Windows systems.
#
# $Id: start-methods.ccl 133175 2014-12-04 17:57:11Z cfxs $
#
SIMULATION CONTROL:
  EXECUTION CONTROL:
    START METHOD LIBRARY:
      START METHOD: Serial
              Option = Direct
              Start Command = %{executable} %{arguments}
!if($^O eq "MSWin32" or $^O =~ m/linux/i){
              Executable Suffix = -pcmpi
!} else {
              Executable Suffix = -pvm
!}
              Shared Disk Requirement = Master
              Use Host List = No
              Minimum Partition Count = 1
              Maximum Partition Count = 1
              Menu Position = 0.1
      END

      START METHOD: Platform MPI Local Parallel
              Option = Direct
!if($^O eq "MSWin32"){
!  if (defined $ENV{CFX_MPI_WORKAROUND}){
              Start Command = "%{pcmpidir}/bin/mpirun" -nopass -affcycle=socket -affwidth=numa -f "%{req:appfile}" >NUL
!  } else {
              Start Command = "%{pcmpidir}/bin/mpirun" -nopass -affcycle=socket -affwidth=numa -f "%{req:appfile}"
!  }
!} else {
              Start Command = "%{pcmpidir}/bin/mpirun" -affcycle=socket -affwidth=numa -f "%{req:appfile}"
!}
              Appfile Host Entry = -np %{partitions} %{executable} %{arguments}
              Start Command Prerequisites = pcmpi_maxpart
              Executable Suffix = -pcmpi
              Use Host List = No
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Platform List = linux, linux-amd64, linux-ia64, winnt, winnt-amd64
              Menu Position = 0.2
      END

      START METHOD: Platform MPI Distributed Parallel
              Option = Direct
!if($^O eq "MSWin32"){
!  if (defined $ENV{CFX_MPI_WORKAROUND}){
              Start Command = "%{pcmpidir}/bin/mpirun" -nopass -affcycle=socket -affwidth=numa -f "%{req:appfile}" >NUL
!  } else {
              Start Command = "%{pcmpidir}/bin/mpirun" -nopass -affcycle=socket -affwidth=numa -f "%{req:appfile}"
!  }
!} else {
              Start Command = "%{pcmpidir}/bin/mpirun" -affcycle=socket -affwidth=numa -f "%{req:appfile}"
!}
!if ($ENV{CFX_SOLVE_USE_REMOTE_HELPER} eq '0') {
              Appfile Host Entry = -h %{hostname} -l %{remoteuser} -np %{hostprocs} -e %{ldpathvar}=%{cfxlibdir} %{executable} %{arguments}
!} else {
              Appfile Host Entry = -h %{hostname} -l %{remoteuser} -np %{hostprocs} %{cfx5remote} %{executable} %{arguments}
!}
              Start Command Prerequisites = pcmpi_maxpart
              Executable Suffix = -pcmpi
              Homogeneous Parallel Only = Yes
              Use Host List = Yes
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Platform List = linux, linux-amd64, linux-ia64, winnt, winnt-amd64
              Menu Position = 0.3
      END

      START METHOD: Platform MPI Local Parallel Flush Cache
              Option = Direct
!if($^O eq "MSWin32"){
!  if (defined $ENV{CFX_MPI_WORKAROUND}){
              Start Command = "%{pcmpidir}/bin/mpirun" -nopass -affcycle=socket -affwidth=numa -e MPI_FLUSH_FCACHE=20 -f "%{req:appfile}" >NUL
!  } else {
              Start Command = "%{pcmpidir}/bin/mpirun" -nopass -affcycle=socket -affwidth=numa -e MPI_FLUSH_FCACHE=20 -f "%{req:appfile}"
!  }
!} else {
              Start Command = "%{pcmpidir}/bin/mpirun" -affcycle=socket -affwidth=numa -e MPI_FLUSH_FCACHE=20 -f "%{req:appfile}"
!}
              Appfile Host Entry = -np %{partitions} %{executable} %{arguments}
              Start Command Prerequisites = pcmpi_maxpart
              Executable Suffix = -pcmpi
              Use Host List = No
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Platform List = none
      END

      START METHOD: Platform MPI Distributed Parallel Flush Cache
              Option = Direct
!if($^O eq "MSWin32"){
!  if (defined $ENV{CFX_MPI_WORKAROUND}){
              Start Command = "%{pcmpidir}/bin/mpirun" -nopass -affcycle=socket -affwidth=numa -e MPI_FLUSH_FCACHE=20 -f "%{req:appfile}" >NUL
!  } else {
              Start Command = "%{pcmpidir}/bin/mpirun" -nopass -affcycle=socket -affwidth=numa -e MPI_FLUSH_FCACHE=20 -f "%{req:appfile}"
!  }
!} else {
              Start Command = "%{pcmpidir}/bin/mpirun" -affcycle=socket -affwidth=numa -e MPI_FLUSH_FCACHE=20 -f "%{req:appfile}"
!}
!if ($ENV{CFX_SOLVE_USE_REMOTE_HELPER} eq '0') {
              Appfile Host Entry = -h %{hostname} -l %{remoteuser} -np %{hostprocs} -e %{ldpathvar}=%{cfxlibdir} %{executable} %{arguments}
!} else {
              Appfile Host Entry = -h %{hostname} -l %{remoteuser} -np %{hostprocs} %{cfx5remote} %{executable} %{arguments}
!}
              Start Command Prerequisites = pcmpi_maxpart
              Executable Suffix = -pcmpi
              Homogeneous Parallel Only = Yes
              Use Host List = Yes
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Platform List = none
      END

!unless (defined $ENV{CFX5_IMPI_DISALLOW}){
      START METHOD: Intel MPI Local Parallel
              Option = Direct
!if($^O eq "MSWin32"){
              Start Command = "%{impidir}\bin\mpiexec" -np %{partitions} -mapall -localroot -env CFX_SOLVER_OUTPUT_FILE "%{env:CFX_SOLVER_OUTPUT_FILE}" %{executable} %{arguments}
              Shared Library Path = %{impidir}\bin
              Start Command Prerequisites = impi_winsmpd
!} else {
              Start Command = "%{impidir}/bin/mpirun" -np %{partitions} -bootstrap fork %{executable} %{arguments}
              Shared Library Path = %{impidir}/lib
              Start Command Prerequisites = mpd.hosts
              Execution Path = %{impidir}/bin
!}
              Executable Suffix = -impi
              Use Host List = No
              Menu Position = 0.4
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Platform List = linux, linux-amd64, winnt-amd64
      END

      START METHOD: Intel MPI Distributed Parallel
              Option = Direct
!if($^O eq "MSWin32"){
              Start Command = "%{impidir}\bin\mpiexec" -configfile "%{req:appfile}"
              Appfile Host Entry = -localroot -env CFX_SOLVER_OUTPUT_FILE "%{env:CFX_SOLVER_OUTPUT_FILE}" -n %{hostprocs} -host %{hostname} %{executable} %{arguments}
              Shared Library Path = %{impidir}\bin
              Start Command Prerequisites = impi_winsmpd
!} else {
              Start Command = "%{impidir}/bin/mpirun" -genv I_MPI_PLATFORM auto -r "%{env:I_MPI_MPD_RSH}" -configfile "%{req:appfile}"
              Appfile Host Entry = -n %{hostprocs} -host %{hostname} %{executable} %{arguments}
              Shared Library Path = %{impidir}/lib
              Start Command Prerequisites = mpd.hosts,impi.memlock
              Execution Path = %{impidir}/bin
!}
              Executable Suffix = -impi
              Use Host List = Yes
              Host Assignment = Block
              Menu Position = 0.5
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Platform List = linux, linux-amd64, winnt-amd64
      END
!}

      START METHOD: PVM Local Parallel
              Option = Direct
              Start Command = %{executable} %{arguments}
              Executable Suffix = -pvm
              Use Host List = No
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Menu Position = 0.6
              Custom PVM Setup = yes
              #Local Error File = %{tmpdir}/pvml.%{uid}.%{hostname}
              Local Error File = %{tmpdir}/pvml.%{uid}
              Start Command Prerequisites = phst,hst
              Platform List = linux, linux-amd64, linux-ia64, hpux, hpux-ia64, solaris, aix
      END

      START METHOD: PVM Distributed Parallel
              Option = Direct
              Start Command = %{executable} %{arguments}
              Executable Suffix = -pvm
              Use Host List = Yes
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Menu Position = 0.7
              Custom PVM Setup = yes
              #Local Error File = /tmp/pvml.%{uid}.%{hostname}
              Local Error File = /tmp/pvml.%{uid}
              Start Command Prerequisites = phst,hst
              Platform List = linux, linux-amd64, linux-ia64, hpux, hpux-ia64, solaris, aix
      END

      START METHOD: Cray MPI Distributed Parallel
              Option = Direct
              Start Command = aprun -ss -n %{partitions} %{executable} %{arguments}
              Executable Suffix = -craympi
              Homogeneous Parallel Only = Yes
              Use Host List = No
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Platform List = none
              Menu Position = 1.3
      END

!   my $ccphome=$ENV{CCP_HOME};
!   my $submitscript=$ENV{CFX_CCS_SUBMIT_SCRIPT};
!   my $allowrunms=$ENV{_CFX_ENABLE_MSMPI_SM};
!   if (defined $ccphome and defined $submitscript and -d "$ccphome" and -f "$submitscript" ) {
      START METHOD: Submit to Windows CCS or HPC Queue
              Option = Indirect
              Use Host List = No
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Menu Position = 1.2
              Indirect Command = "%{env:CFX_CMD_DIR}\cfx5perl" "%{env:CFX_CCS_SUBMIT_SCRIPT}" -part %{partitions} %{indirect_args} %{arguments}
              Platform List = winnt-amd64
      END

!    if (defined $allowrunms) {
!    my @nodes=split(' ', $ENV{CCP_NODES});
!    my $newnodes=shift(@nodes);
!    while(@nodes){
!      my $host=shift(@nodes);
!      my $count=shift(@nodes);
!      $newnodes.=" $host ".$count/$ENV{_CFX_PROC_PER_SOLVER};
!    }
!    $ENV{CCP_NODES2}=$newnodes;
!    my $msmpi_bindir = $ENV{MSMPI_BIN};
!    $msmpi_bindir = join("\\",$ENV{CCP_HOME},'bin') unless (defined $msmpi_bindir and -d $msmpi_bindir);
      START METHOD: MSMPI
              Option = Direct
!if ($ENV{CFX_SOLVE_USE_REMOTE_HELPER} eq '1') {
              Start Command = "$msmpi_bindir\mpiexec" -wdir "%{workdir}" -env CFX_DATA_DIR "%{env:CFX_DATA_DIR}" -env CFX_SOLVER_OUTPUT_FILE "%{env:CFX_SOLVER_OUTPUT_FILE}" -env CFX_OUTPUT_SUMMARY_OPTION "%{env:CFX_OUTPUT_SUMMARY_OPTION}" -env CFX_CMD_DIR "%{env:CFX_CMD_DIR}" -env ANSYSLIC_DIR "%{env:ANSYSLIC_DIR}" -env ANSYSLI_RESERVE_ID "%{env:ANSYSLI_RESERVE_ID}" -env ANSYSLI_USAGE "%{env:ANSYSLI_USAGE}" -env NO_STOP_MESSAGE 1 -hosts %{env:CCP_NODES2} %{env:MPIEXEC_OPTIONS} %{cfx5remote} %{executable} %{arguments}
!} else {
              Start Command = "$msmpi_bindir\mpiexec" -wdir "%{workdir}" -env CFX_DATA_DIR "%{env:CFX_DATA_DIR}" -env CFX_SOLVER_OUTPUT_FILE "%{env:CFX_SOLVER_OUTPUT_FILE}" -env CFX_OUTPUT_SUMMARY_OPTION "%{env:CFX_OUTPUT_SUMMARY_OPTION}" -env CFX_CMD_DIR "%{env:CFX_CMD_DIR}" -env ANSYSLIC_DIR "%{env:ANSYSLIC_DIR}" -env ANSYSLI_RESERVE_ID "%{env:ANSYSLI_RESERVE_ID}" -env ANSYSLI_USAGE "%{env:ANSYSLI_USAGE}" -env NO_STOP_MESSAGE 1 -env %{ldpathvar} %{cfxlibdir} -hosts %{env:CCP_NODES2} %{env:MPIEXEC_OPTIONS} %{executable} %{arguments}
!}
              Executable Suffix = -msmpi
              Use Host List = No
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Platform List = winnt-amd64
      END
!    }
!  }

!   my $qcfx5solveScript = "$ENV{CFX_CMD_DIR}/../config/qcfx5solve.pl";
!   if (-e $qcfx5solveScript) {
      START METHOD: Submit to PBS Queue
  #
  # Note: This start method requires that a qcfx5solve.pl script exists in
  # the <CFX5ROOT>/config directory of the installation.  An example script can be
  # copied from the <CFX5ROOT>/extras directory.  The supplied script will likely
  # need to be modified to account for the local environment of your queuing
  # system.
  #
	 Option = Indirect
	 # change '-master cluster' in the following line to point to the cluster queue machine
	 Indirect Command = cfx5perl %{env:CFX5ROOT}/config/qcfx5solve.pl -master cluster -n %{partitions} -solver %{cfx5solve} %{indirect_args} %{arguments}
	 Use Host List = No
	 Minimum Partition Count = 1
	 Maximum Partition Count = Any
	 Menu Position = 1.0
      END
!   }
  #
  # Note: Submitting to a unix/linux machine from Windows requires that a common
  # drive be mapped on the Windows machine. The -drivemap argument then searches
  # through common solver arguments and set-up files to substitute the windows drive
  # letter to the correct directory root for the unix machine.  This method has
  # been shown to work for simple cases, but can be easily broken.  The following
  # Start Method is provided as a starting point for launching from Windows to Unix
  # machines.
  #
  #    START METHOD: Submit to PBS Queue from Windows
  #       Option = Indirect
  #       # change '-master cluster' in the following line to point to the cluster queue machine
  #       # change drive map to reflect windows/unix drive root mapping
  #       # -solver should point to the cfx5solve script on the remote machine (or it should be included in the path)
  #       Indirect Command = cfx5perl "%{env:CFX5ROOT}\config\qcfx5solve.pl" -master cluster -n %{partitions} -drivemap Z:\,/home/srelias/ -solver /Projects/CFX5/CFX-5-build/bin/cfx5solve %{indirect_args} %{arguments}
  #       Use Host List = No
  #       Minimum Partition Count = 1
  #       Maximum Partition Count = Any
  #    END
  #
  #
  # Deprecated and unsupported start methods
  # ----------------------------------------
  #
  # These no longer show up in the Solver Manager but are included
  # here for backwards compatibility
  #
      START METHOD: MPICH Local Parallel
              Option = Direct
              Start Command = %{executable} %{arguments} -p4pg p4.pg -p4wd .
              Executable Suffix = -mpich
              Use Host List = No
              Menu Position = 0.8
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Start Command Prerequisites = p4.pg
              Platform List = none
      END

      START METHOD: MPICH Distributed Parallel
              Option = Direct
              Start Command = %{executable} %{arguments} -p4pg p4.pg -p4wd .
              Executable Suffix = -mpich
              Use Host List = Yes
              Homogeneous Parallel Only = Yes
              Menu Position = 0.9
              Start Command Prerequisites = p4.pg
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Platform List = none
      END

      START METHOD: HP MPI Local Parallel
              Option = Direct
!if($^O eq "MSWin32"){
!  if (defined $ENV{CFX_MPI_WORKAROUND}){
              Start Command = "%{hpmpidir}/bin/mpirun" -nopass -cpu_bind -prot -np %{partitions} %{executable} %{arguments} >NUL
!  } else {
              Start Command = "%{hpmpidir}/bin/mpirun" -nopass -cpu_bind -prot -np %{partitions} %{executable} %{arguments}
!  }
!} else {
              Start Command = "%{hpmpidir}/bin/mpirun" -cpu_bind -np %{partitions} %{executable} %{arguments}
!}
              Executable Suffix = -hpmpi
              Selectable Master Host = Yes
              Use Host List = No
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Platform List = none
              Menu Position = 0.4
      END

      START METHOD: HP MPI Distributed Parallel
              Option = Direct
!if($^O eq "MSWin32"){
!  if (defined $ENV{CFX_MPI_WORKAROUND}){
              Start Command = "%{hpmpidir}/bin/mpirun" -nopass -cpu_bind -prot -f "%{req:appfile}" >NUL
!  } else {
              Start Command = "%{hpmpidir}/bin/mpirun" -nopass -cpu_bind -prot -f "%{req:appfile}"
!  }
!} else {
              Start Command = "%{hpmpidir}/bin/mpirun" -cpu_bind -f "%{req:appfile}"
!}
              Appfile Host Entry = -h %{hostname} -l %{remoteuser} -np %{hostprocs} %{cfx5remote} %{executable} %{arguments}
              Executable Suffix = -hpmpi
              Selectable Master Host = Yes
              Homogeneous Parallel Only = Yes
              Use Host List = Yes
              Minimum Partition Count = 2
              Maximum Partition Count = Any
              Platform List = none
              Menu Position = 0.5
      END

    END
  END
END
