source: dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/example.sh @ 4111

Last change on this file since 4111 was 4111, checked in by dubos, 7 years ago

aquaplanet : scripts ported to Irene

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1#!/bin/bash
2# How to use this script :
3# 1    Create a directory EXP for your experiment ; ALL commands below must be run from EXP
4# 2    Create a directory STORE to store the outputs of your experiment ; run "ln -s STORE storedir"
5# 3    run "BASE/example.sh init" where BASE is the directory containing this script
6# 4    (optional) Edit EXP/config.sh, EXP/run_icosa.def, EXP/*.xml
7# 5    run "./example.sh create" (NB : ./example.sh, NOT ../example.sh)
8# 6    run "./example.sh submit"
9
10function fullpath() 
11{ 
12    echo "$(cd -P $1 ; pwd)"
13}
14
15function years()
16{
17    for ((i="$1";i<="$2";i++)) ; do
18        echo $i
19    done
20}
21
22function yeardirs()
23{
24    for ((i="$1";i<="$2";i++)) ; do
25        echo $(printf 'year%02d' $i)
26    done
27}
28
29function cmd_create()
30{
31    source ./config.sh
32    env | grep YEARS
33    ls -l $PWD/storedir || (echo "$PWD/storedir is missing, please create it and retry." ; exit -1) || exit
34    STORE_ROOT=$( fullpath $PWD/storedir )
35    YEARDIRS=$(yeardirs 1 $NB_YEARS)
36    for DIR in ce0l $YEARDIRS ; do
37        rm -rf $DIR $STORE_ROOT/$DIR
38    done
39    STORE0L="$STORE_ROOT/ce0l"
40    $BASEDIR/prepare.sh ce0l ce0l "$STORE0L" 1980
41    $BASEDIR/prepare.sh first $STORE0L year01 "$STORE_ROOT/year01" 1980
42    PREV=year01
43    for YEAR in $(years 2 $NB_YEARS) ; do
44        YEARDIR=$(printf 'year%02d' $YEAR)
45#       ANNEEREF=$((1979 + YEAR))
46        ANNEEREF=1980
47        $BASEDIR/prepare.sh next  $STORE0L "$STORE_ROOT/$PREV" $YEARDIR "$STORE_ROOT/$YEARDIR" $ANNEEREF
48        PREV=$YEARDIR
49    done
50}
51
52function submit_CCC()
53{
54    EXP=$1 ; shift
55    CMD="ccc_msub $* $EXP/job.sh"
56    MSG=$($CMD)
57    echo "$CMD : $MSG"
58    JOBID=$( echo "$MSG" | awk '{print $NF}' )
59    DEP="-a $JOBID"
60}
61
62function submit_X64_CURIE()
63{
64    submit_CCC $*
65}
66
67function submit_X64_IRENE()
68{
69    submit_CCC $*
70}   
71
72function cmd_submit()
73{
74    source ./config.sh
75    DEP=""
76    submit_$ARCH ce0l
77    for YEARDIR in $(yeardirs 1 $NB_YEARS) ; do
78        submit_$ARCH $YEARDIR $DEP
79    done
80}
81
82function init_all()
83{
84    cat >> config.sh <<EOF
85ARCH=X64_CURIE
86BASEDIR=$BASEDIR
87ESM_ROOT=$ESM_ROOT
88NB_YEARS=2
89NB_MPI_DYNAMICO=160
90NB_MPI_XIOS=16
91WALLTIME_JOB=7200
92WALLTIME_CE0L=120
93EOF
94    cp -fp $BASEDIR/*.sh $BASEDIR/*.xml $BASEDIR/*.def .
95    rm gcm.def # LMDZ-only, remove to avoid confusion
96    rm -rf orig
97    mkdir orig
98    cp -p *.sh *.xml *.def orig/ # keep original config files in orig
99    ls -lrh
100    echo
101    echo "$PWD/config.sh :"
102    cat config.sh
103    echo "If not done already, please create $PWD/storedir." 
104    echo 'You may edit config.sh, *.def, *.xml then run ./example.sh create'
105}
106
107function cmd_init_aqua()
108{
109    cat > config.sh <<EOF
110READ_CLIMOZ=-1
111VEGET=n
112SOLARLONG0=1000.
113ETAT0=held_suarez
114IFLAG_PHYS0=103
115EXPERIMENT=aqua
116EOF
117    init_all
118}
119
120function cmd_init_betaclim()
121{
122    cat > config.sh <<EOF
123READ_CLIMOZ=2
124VEGET=betaclim
125SOLARLONG0=-9999.999
126ETAT0=database
127IFLAG_PHYS0=1
128EXPERIMENT=betaclim
129EOF
130    init_all
131    echo "Decompressing FILES_LMDZ.tar.bz2"
132    tar xjf /ccc/store/cont003/gen7548/dubosth/Lluis/FILES_LMDZ.tar.bz2
133}
134
135function cmd_diff()
136{
137    for x in orig/*.sh orig/*.xml orig/*.def ; do
138        diff -u $x $(basename $x)
139    done
140}
141
142function cmd_patch()
143{
144    patch -p0 < $2
145}
146
147BASEDIR=$(dirname ${BASH_SOURCE[0]})
148BASEDIR=$( fullpath $BASEDIR )
149ESM_ROOT=$( fullpath $BASEDIR/../../ )
150echo "Your command : $0 $*"
151echo "Script base dir : $BASEDIR"
152echo "Run from : $(fullpath $PWD)"
153echo "Usage : $0 [init_aqua|init_betaclim|diff|patch|create|submit]"
154cmd_$1 $*
Note: See TracBrowser for help on using the repository browser.