Index: trunk/NEMOGCM/SETTE/prepare_job.sh
===================================================================
--- trunk/NEMOGCM/SETTE/prepare_job.sh	(revision 4814)
+++ trunk/NEMOGCM/SETTE/prepare_job.sh	(revision 5480)
@@ -226,5 +226,56 @@
                                         # round up the number of nodes required.
                                         #
-                                        NB_NODES=$( echo $NB_NODES $NXIO_PROC | awk '{print ($1 + ( $2 / 4 ) + 1)}')                    
+                                        NB_NODES=$( echo $NB_NODES $NXIO_PROC | awk '{print ($1 + ( $2 / 4 ) + 1)}') 
+                                fi
+                                ;;
+                        XC40_METO*) #Setup for Met Office XC40 with any compiler
+                                # ocean cores are packed 32 to a node
+                                # If we need more than one node then have to use parallel queue and XIOS must have a node to itself
+                                NB_REM=$( echo $NB_PROC | awk '{print ( $1 % 32 ) }')
+                                if [ ${NB_REM} == 0 ] ; then
+                                        # number of processes required is an integer multiple of 32
+                                        #
+                                        NB_NODES=$( echo $NB_PROC $NXIO_PROC | awk '{print ($1) / 32}')
+                                else
+                                        #
+                                        # number of processes required is not an integer multiple of 32
+                                        # round up the number of nodes required.
+                                        #
+                                        NB_NODES=$( echo $NB_PROC $NXIO_PROC | awk '{printf("%d",($1) / 32 + 1 )}')
+                                fi
+                                # xios cores are sparsely packed at 4 to a node
+                                if [ $NXIO_PROC == 0 ] ; then
+                                    NB_XNODES=0
+                                else
+                                    NB_REM=$( echo $NXIO_PROC | awk '{print ( $1 % 4 ) }')
+                                    if [ ${NB_REM} == 0 ] ; then
+                                            # number of processes required is an integer multiple of 4                           
+                                            #
+                                            NB_XNODES=$( echo $NXIO_PROC | awk '{print (( $1 / 4 ) + 1)}') 
+                                    else
+                                            #
+                                            # number of processes required is not an integer multiple of 4                             
+                                            # round up the number of nodes required.
+                                            #
+                                            NB_XNODES=$( echo $NXIO_PROC | awk '{printf("%d",($1) / 4 + 1) }')                    
+                                    fi
+                                fi
+                                if [ ${NB_XNODES} -ge 1 ] ; then
+                                   NB_NODES=$((NB_NODES+NB_XNODES))
+                                fi
+                                echo NB_XNODES=${NB_XNODES} 
+                                echo Total NB_NODES=${NB_NODES}
+                                if [ ${NB_NODES} -eq 1 ] ; then
+                                   QUEUE=shared
+                                   #Not using XIOS in detatched mode and using less than one node so should be ok on shared node
+                                   #Load snplauncher module to allow use of mpiexec
+                                   SELECT="select=1:ncpus=$((NXIO_PROC + NB_PROC))":mem=15GB
+                                   module load cray-snplauncher
+                                   echo 'Shared Queue'
+                                else
+                                   QUEUE=normal
+                                   SELECT="select=$NB_NODES"
+                                   module unload cray-snplauncher #Make sure snplauncher module is not loaded
+                                   echo 'Normal Queue'
                                 fi
                                 ;;
@@ -279,4 +330,9 @@
                     cat run_sette_test.job | sed -e"s/NPROC_NODE/${NB_PROC_NODE}/" \
                                                  -e"s:QUEUE:${QUEUE}:" > run_sette_test1.job
+                    mv run_sette_test1.job run_sette_test.job
+                    ;;
+              XC40_METO*)
+                    cat run_sette_test.job | sed -e"s/QUEUE/${QUEUE}/" \
+                                                 -e"s/SELECT/${SELECT}/" > run_sette_test1.job
                     mv run_sette_test1.job run_sette_test.job
                     ;;
