#! /bin/sh # $Header: /home/ubuntu/mnt/e9_copy/MITgcm_contrib/jmc_script/run_cpl_test.beagle,v 1.1 2010/12/06 02:56:35 jmc Exp $ # $Name: $ #- default: #Npr=3 ; NpOc=1 ; Npr=25; NpOc=12; MTH= MTHo= MTHa= GMKopt='-ieee' #GMKopt= rnkO=1 ; rnkA=`expr $rnkO + $NpOc` #- parse options: if [ $# -ge 1 ] ; then if test $1 = '-mth' ; then MTH='-omp' ; shift if test -f input_ocn/eedata.mth ; then MTHo=$MTH ; fi if test -f input_atm/eedata.mth ; then MTHa=$MTH ; fi fi ; fi if [ $# -ne 1 ] then echo 'Usage:'`basename $0`' [opt] step' echo ' => test coupled set-up on linux box (1.cpu)' echo 'opt = -mth : compile and run (if eedata.mth) 2-threads for ocn & atm' echo ' step = 0 : clean all directories' echo ' step = 1 : compile the 3 executables (cpl,ocn,atm)' echo ' step = 2 : copy input files and dir(s)' echo " step = 3 : run with $Npr mpi processes" echo ' step = 4 : check the results' echo ' step = 5 : remove output files in rank_0,1,2 dir.' exit fi kpr=$1 dir=`pwd` #============================================================================ if test $kpr = 0 then rm -f pr_group std_outp comp_res.{ocn,atm,land,sice} rm -f build_???/TTT.*make.* build_???/TTT.mkdepend.* /bin/rm -r -f rank_? rank_1? rank_2? if test -f build_cpl/Makefile ; then cd build_cpl ; make Clean ; cd .. ; fi if test -f build_ocn/Makefile ; then cd build_ocn ; make Clean ; cd .. ; fi if test -f build_atm/Makefile ; then cd build_atm ; make Clean ; cd .. ; fi fi if test $kpr = 5 then echo 'remove output files in rank_0,1,2 dir.' rm -f pr_group std_outp comp_res.{ocn,atm,land,sice} if test -d rank_0 ; then cd rank_0 ; rm -f Coupler.0000.clog ; cd .. ; fi if test -d rank_$rnkO then cd rank_$rnkO ; rm -f *.data *.meta STD???.0000 UV-*.0001.clog ; cd .. ; fi if test -d rank_$rnkA then cd rank_$rnkA ; rm -f *.data *.meta STD???.0000 UV-*.0001.clog ; cd .. ; fi fi if test $kpr = 1 then #- choice of the optfile: take a local one in dir verification with sufix '+mpi' nbOpF=`ls ../linux_* | grep '+mpi' 2> /dev/null | wc -l` if test $nbOpF = 1 ; then OPTFILE=`ls ../linux_* | grep '+mpi'` zz=`grep '^FC=' $OPTFILE` echo " Using optfile: $OPTFILE (compiler=$zz) $MTH" elif [ $nbOpF -ge 2 ] ; then echo "pick the 1rst of these ( $nbOpF ) optfiles:" ls ../linux_* | grep '+mpi' OPTFILE=`ls ../linux_* | grep '+mpi' | head -1` zz=`grep '^FC=' $OPTFILE` echo " Using optfile: $OPTFILE (compiler=$zz) $MTH" else echo "Pb in finding optfile: found $nbOpF :" ls ../linux_* | grep '+mpi' ; exit fi zz=`echo $OPTFILE | grep -c '^\/'` if test $zz = 0 ; then OPTFILE="../$OPTFILE" ; fi #--- echo '==== compile coupler:' cd build_cpl echo ' --- genmake2 (cpl):' ../../../tools/genmake2 -of $OPTFILE -mpi $GMKopt > TTT.genmake.$$ tail -5 TTT.genmake.$$ echo ' --- make depend (cpl):' make depend > TTT.mkdepend.$$ tail -5 TTT.mkdepend.$$ echo ' --- make (cpl):' make > TTT.make.$$ 2>&1 tail -10 TTT.make.$$ echo ' ' ; cd $dir echo '==== compile OGCM:' cd build_ocn echo ' --- genmake2 (ocn):' ../../../tools/genmake2 -of $OPTFILE -mpi $MTHo $GMKopt > TTT.genmake.$$ tail -5 TTT.genmake.$$ echo ' --- make depend (ocn):' make depend > TTT.mkdepend.$$ tail -10 TTT.mkdepend.$$ echo ' --- make (ocn):' make > TTT.make.$$ 2>&1 tail -10 TTT.make.$$ echo ' ' ; cd $dir echo '==== compile AGCM:' cd build_atm echo ' --- genmake2 (atm):' ../../../tools/genmake2 -of $OPTFILE -mpi $MTHa $GMKopt > TTT.genmake.$$ tail -5 TTT.genmake.$$ echo ' --- make depend (atm):' make depend > TTT.mkdepend.$$ tail -10 TTT.mkdepend.$$ echo ' --- make (atm):' make > TTT.make.$$ 2>&1 tail -10 TTT.make.$$ echo ' ' ; cd $dir ls -l build_???/mitgcmuv fi if test $kpr = 2 then echo 'rm dir:' rank_? rank_1? rank_2? /bin/rm -r -f rank_? rank_1? rank_2? echo 'Link files from dir:' input_cpl '->' rank_0 mkdir rank_0 ( cd rank_0 ; ln -s ../input_cpl/* . ) n=$rnkO echo 'Link files from dir:' input_ocn '->' rank_$n mkdir rank_$n cd rank_$n ln -s ../input_ocn/* . if test -x prepare_run ; then ./prepare_run ; fi if test "x$MTHo" != x ; then echo " MTH run: mv -f eedata.mth eedata" if test -h eedata ; then rm -f eedata ; fi mv -f eedata.mth eedata fi cd $dir n=`expr $n + 1` while [ $n -le $NpOc ] ; do ln -s rank_$rnkO rank_$n n=`expr $n + 1` done n=$rnkA echo 'Link files from dir:' input_atm '->' rank_$n mkdir rank_$n cd rank_$n ln -s ../input_atm/* . if test -x prepare_run ; then ./prepare_run ; fi if test "x$MTHa" != x ; then echo " MTH run: mv -f eedata.mth eedata" if test -h eedata ; then rm -f eedata ; fi mv -f eedata.mth eedata fi cd $dir n=`expr $n + 1` while [ $n -lt $Npr ] ; do ln -s rank_$rnkA rank_$n n=`expr $n + 1` done fi if test $kpr = 3 then ROOTDIR=$dir # rm -f rank_?/pickup*.ckptA.00?.00?.??ta echo $ROOTDIR tmpfil=TTT.$$ #--- running on the same node: list='' ; nc=0; xx=`hostname` while [ $nc -lt $Npr ] ; do list="$list $xx" ; nc=`expr $nc + 1` ; done #-- On darwin cluster node (from qrsh session): JOB_ID=`qstat | sed -n '3,$ p' | grep " $USER " | awk '{print $1}'` NODEFILE="/tmp/$JOB_ID.1.darwin/machines" echo " JOB_ID = '$JOB_ID' ; NODEFILE = '$NODEFILE'" #-- On ACES cluster (in PBS batch job): # NODEFILE=$PBS_NODEFILE #--- running on different nodes: ls -l $NODEFILE nprc=`cat $NODEFILE | uniq | wc -l` if [ $nprc -ge $Npr ] ; then list=`cat $NODEFILE | uniq | head -$Npr` else list=`cat $NODEFILE | head -$Npr` fi nc=0; nn=0; dd1=cpl ; rm -f pr_group ; touch pr_group for xx in $list do echo $xx $nn $dir/build_$dd1/mitgcmuv >> pr_group nc=`expr $nc + 1` if [ $nc -le $NpOc ] ; then dd1=ocn ; else dd1=atm ; fi nn=1 done cd $ROOTDIR if test "x$MTH" != x ; then export OMP_NUM_THREADS=2 ; export KMP_STACKSIZE=400m if test "x$MTHo" != x ; then echo -n " run OCN ($MTHo) with $OMP_NUM_THREADS threads ;" fi if test "x$MTHa" != x ; then echo -n " run ATM ($MTHa) with $OMP_NUM_THREADS threads ;" fi echo "" fi # /usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/bin/mpirun.ch_gm -pg pr_group -wd $ROOTDIR --gm-kill 5 -v ./build_cpl/mitgcmuv > std_outp 2>&1 #- with mpich-1 (on danton, ACES): # mpirun -p4pg pr_group -v ./build_cpl/mitgcmuv > std_outp 2>&1 #- with mpich-mx (on beagle): mpirun -pg pr_group -v ./build_cpl/mitgcmuv > std_outp 2>&1 tail -20 std_outp ls -l rank_$rnkO/pickup*.ckptA.001.001.data ls -l rank_$rnkA/pickup*.ckptA.001.001.data fi if test $kpr = 4 then if test -f rank_$rnkO/STDOUT.0000 then echo '==> check Ocean output:' /home/jmc/bin/comp_res rank_$rnkO/STDOUT.0000 results/ocnSTDOUT.0000 mv -f comp_res.log comp_res.ocn echo ' ' else echo "No Ocean output file in rank_$rnkO" ; fi if test -f rank_$rnkA/STDOUT.0000 then echo '==> check Atmos output:' /home/jmc/bin/comp_res rank_$rnkA/STDOUT.0000 results/atmSTDOUT.0000 mv -f comp_res.log comp_res.atm echo '==> check Land output:' /home/jmc/bin/comp_res rank_$rnkA/STDOUT.0000 results/atmSTDOUT.0000 L mv -f comp_res.log comp_res.land echo '==> check thSIce output:' /home/jmc/bin/comp_res rank_$rnkA/STDOUT.0000 results/atmSTDOUT.0000 I mv -f comp_res.log comp_res.sice echo ' ' else echo "No Atmos output file in rank_$rnkA" ; fi fi exit 0