prismdrv_spawn_child.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, CERFACS, Toulouse, France.
00003 ! Copyright 2006-2010, NEC Europe Ltd., London, UK.
00004 ! All rights reserved. Use is subject to OASIS4 license terms.
00005 !-----------------------------------------------------------------------
00006 !BOP
00007 !
00008 ! !Routine: PRISMDrv_spawn_child
00009 !
00010 ! !INTERFACE:
00011 
00012 subroutine prismdrv_spawn_child ( exec, args, n_args, application_number, &
00013    n_hosts, hostnames, npes, intracomm, intercomm, ierror )
00014 !
00015 ! !USES:
00016   USE PRISMDrv, dummy_interface => prismdrv_spawn_child 
00017 
00018   IMPLICIT NONE
00019 !
00020 ! !PARAMETERS:
00021 !
00022   character(len=*),Intent(In)         :: exec
00023 !
00024 !     Name of executable
00025 !
00026   integer,Intent(In)                  :: n_args
00027 !
00028 !     Number of arguments
00029 !
00030   character(len=*),Intent(In)         :: args (n_args)
00031 !
00032 !     List of arguments for the exceutable
00033 !
00034   integer,Intent(In)                  :: application_number
00035 !
00036 !     Number of the application; used to specify the application group
00037 !
00038   integer,Intent(In)                  :: n_hosts
00039 !
00040 !     Host names on which the processes should be spawned
00041 !
00042   character(len=*),Intent(In)         :: hostnames (n_hosts)
00043 !
00044 !     Number of hosts 
00045 !
00046   integer,Intent(In)                  :: npes (n_hosts)
00047 !
00048 !     Number of processes to be spawned per host
00049 !
00050   integer, Intent(In)                 :: intracomm
00051 !
00052 !     Intra communicator used to spawn the processes
00053 !
00054   integer,Intent(Out)                 :: intercomm
00055 !
00056 !     Resulting Inter communicator
00057 !
00058   integer,Intent(Out)                 :: ierror
00059 !
00060 !     Error status
00061 !
00062 ! !DESCRIPTION:
00063 !
00064 !     to spawn processes, called form the coupler
00065 !
00066 !
00067 ! !REVISION HISTORY:
00068 !   Date      Programmer   Description
00069 ! ----------  ----------   -----------
00070 ! 03/12/2001  R. Redler    created
00071 !
00072 ! EOP
00073 !----------------------------------------------------------------------
00074 ! $Id: prismdrv_spawn_child.F90 2889 2011-01-14 12:18:54Z hanke $
00075 ! $Author: hanke $
00076 !----------------------------------------------------------------------
00077 
00078 #if ! defined ( PRISM_with_MPI1 )
00079 !
00080 ! Local declaration
00081 !
00082   character(len=64)                  :: commands (n_hosts)
00083   character(len=64)                  :: argv (n_hosts, n_args+1)
00084   character(len=8)                   :: appl_group
00085   integer                            :: info (n_hosts)
00086   integer                            :: n ! Total number of processes
00087   integer                            :: i
00088 
00089 #ifdef DONT_HAVE_ERRORCODES_IGNORE
00090   integer, allocatable               :: ierrors (:)
00091 #endif
00092 
00093 ! ---------------------------------------------------------------------
00094 !
00095   PRINT *, '| | Enter PRISMDrv_spawn_child'
00096   call psmile_flushstd
00097 !
00098 ! Initialisation
00099 !
00100   intercomm = MPI_COMM_NULL
00101   ierror    = 0
00102 !
00103 ! Compute total number of processes to be spawned
00104 !
00105   n = 0
00106   do i = 1, n_hosts
00107     n = n + max (0, npes(i))
00108   enddo
00109 !
00110 ! Set constant arguments
00111 !
00112   commands (1:n_hosts) = exec
00113 !
00114   do i = 1, n_hosts
00115     argv (i, 1:n_args) = args (1:n_args)
00116   enddo
00117 !
00118   argv (1:n_hosts, n_args+1) = ' '
00119 !
00120 ! Create info objects for spawning the processes
00121 !
00122   write (appl_group, "(i8)") application_number
00123 !
00124 ! ... Set info argument for each host
00125 !
00126 # if !  defined ( PRISM_LAM )
00127   do i = 1, n_hosts
00128     call MPI_Info_create (info(i), ierror)
00129 !
00130 ! ... Specify host name on which the processes should be spawned
00131 !
00132     call MPI_Info_set (info(i), "host", hostnames(i), ierror)
00133 !
00134 ! ... Specify further info's for spawning of processes
00135 !
00136 !     These infos may be system dependent and should be ignored
00137 !     by the system which don't support them.
00138 !
00139 !     The application group specifies a set of processes which should
00140 !     simultaneously run; i.e. they should be simultaneously swapped
00141 !     in and out in order to avoid waitinf for processes swapped out.
00142 !
00143     call MPI_Info_set (info(i), "appl_group", appl_group, ierror)
00144 !
00145   enddo
00146 !
00147 ! Spawn processes 
00148 !
00149 #else
00150   info = MPI_INFO_NULL
00151 #endif
00152 
00153 #ifdef DONT_HAVE_ERRORCODES_IGNORE
00154 !
00155 ! ... Allocate error codes for processes (1 code per process !)
00156 !
00157   Allocate (ierrors(1:n))
00158 
00159   call MPI_Comm_spawn_multiple ( n_hosts, commands, argv, npes,  &
00160      info, PRISM_root, intracomm, intercomm, ierrors, ierror     )
00161 #else
00162   call MPI_Comm_spawn_multiple (n_hosts, commands, argv, npes, info,  &
00163      PRISM_root, intracomm, intercomm, MPI_ERRCODES_IGNORE, ierror    )
00164 #endif
00165 !
00166 ! Free info object
00167 !
00168 # if ! defined ( PRISM_LAM )
00169   do i = 1, n_hosts
00170     call MPI_Info_free  ( info(i), ierror )
00171   end do
00172 #endif
00173 !
00174 ! Deallocate error codes
00175 !
00176 #ifdef DONT_HAVE_ERRORCODES_IGNORE
00177   Deallocate (ierrors)
00178 #endif
00179 !
00180 ! Formats
00181 !
00182 1000 format (1x, '| | | Spawning ', a, ' on', i4, ' processe(s) and', i3, &
00183      ' host(s).' )
00184 
00185   PRINT *, '| | Quit PRISMDrv_spawn_child'
00186   PRINT *, '| |'
00187   call psmile_flushstd
00188 
00189 #else
00190   intercomm = MPI_COMM_NULL
00191   ierror    = 0
00192 #endif
00193 
00194 END SUBROUTINE PRISMDrv_spawn_child
00195 
00196 #ifdef DONT_HAVE_STDMPI2
00197       subroutine MPI_Comm_spawn_multiple ( n_hosts, commands, argv, &
00198                                     npes, dummy1, root, intracomm,  &
00199                                     intercomm, dummy2, ierror)
00200 
00201       integer            :: dummy1, dummy2
00202       integer            :: n_hosts
00203       integer            :: root
00204       integer            :: npes (n_hosts)
00205       character(len=1)   :: commands (n_hosts)
00206       character(len=1)   :: argv (n_hosts, 1)
00207       integer            :: intracomm, intercomm, ierror
00208 
00209       Integer, parameter :: nerrp = 1
00210       Integer            :: ierrp (nerrp)
00211 
00212          call psmile_error_common ( -1, 'Spawing not support with this MPI', &
00213             ierrp, 1, __FILE__, __LINE__ )
00214 
00215          return
00216       end
00217 #endif

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1