source: modipsl/trunk/util/script_recup_model @ 1583

Last change on this file since 1583 was 1583, checked in by mmaipsl, 13 years ago

Correct usage in Documentation. Add tex and AA_ and BB_ files.

  • Property svn:executable set to *
  • Property svn:keywords set to Date,Author,Revision
File size: 5.9 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Martial Mancip
5# Contact: Martial.Mancip__at__ipsl.jussieu.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14# Documentation :
15# This script creates a tree of last configuration modipsl from a tar file previously produced by script_diff_model.
16#
17# After you have downloaded modipsl, you can copy a modipsl_name_of_the_save directory tree (from a saved tar file) in modipsl.
18# (Please, see script_diff_model documentation for information of how to get this file.)
19# You may use this script to download the same configuration with new files and modifications linked with this tarball.
20#
21# usage (in modipsl path) :
22# modipsl_path> util/script_recup_model modipsl_name_of_the_save
23#
24# After this whole configuration is backuped, you must use as usual ins_make and ins_job script
25# to installed all files depended on this new modipsl and the computer.
26#
27# Note :
28# It may not compile because of special post-installation (not versionning) for some component in model.
29# See "Actions related to the WORK directory for the OPA models" in model script to reproduce this post-installation.
30#-
31
32
33MODIPSL_SAVE_NAME=$1
34
35MODIPSL=${MODIPSL:=$(pwd)}
36
37DEBUG_mode=false
38
39function printDebugArray {
40    if ( ${DEBUG_mode} ); then
41        typeset nb_line i
42        eval nb_line=\${#$1[@]}
43        eval echo "$1 : " ${nb_line}
44        (( i = 0 ))
45        while [ $i -lt $nb_line ] ; do
46            eval echo \${$1[$i]}
47            (( i = i + 1 ))
48        done
49    fi
50}
51
52MODIPSL_SAVE=${MODIPSL}/${MODIPSL_SAVE_NAME}
53
54#typeset NbComponents ModelComponents ModelTags ModelSystems ModelServers ModelDirectories ModelLocalDirs ListPathComp ListPathFile ListPathRev ListPathBranch ListNewFiles ListModifFiles ListModifFilesDate Maxfiledate
55
56
57((i=1))
58while read line ; do
59    case $i in
60        1)
61            echo $line | sed -e 's&Last Model in log : *&&g'
62            ;;
63        2)
64            NbComponents=$( echo $line | sed -e"s/ *components ://" )
65            echo $NbComponents
66            ;;
67        3)
68            set +A ModelComponents -- $line
69            printDebugArray ModelComponents
70            ;;
71        4)
72            set +A ModelTags -- $line
73            printDebugArray ModelTags
74            ;;
75        5)
76            set +A ModelSystems -- $line
77            printDebugArray ModelSystems
78            ;;
79        6)
80            set +A ModelServers -- $line
81            printDebugArray ModelServers
82            ;;
83        7)
84            set +A ModelDirectories -- $line
85            printDebugArray ModelDirectories
86            ;;
87        8)
88            set +A ModelLocalDirs -- $line
89            printDebugArray ModelLocalDirs
90            ;;
91        9)
92            set +A ListPathComp -- $line
93            printDebugArray ListPathComp
94            ;;
95        10)
96            set +A ListPathFile -- $line
97            printDebugArray ListPathFile
98            ;;
99        11)
100            set +A ListPathRev -- $( echo $line | sed -e 's%\([0-9][0-9]/[0-9][0-9]/[0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\)%\1_\2%g' )
101            printDebugArray ListPathRev
102            ;;
103        12)
104            set +A ListPathBranch -- $line
105            printDebugArray ListPathBranch
106            ;;
107        13)
108            set +A ListNewFiles -- $line
109            printDebugArray ListNewFiles
110            ;;
111        14)
112            set +A ListModifFiles -- $line
113            printDebugArray ListModifFiles
114            ;;
115        15)
116            set +A ListModifFilesDate -- $line
117            printDebugArray ListModifFilesDate
118            ;;
119        16)
120            Maxfiledate=$line
121            printDebugArray Maxfiledate
122            ;;
123        *)
124            break
125            ;;
126    esac
127    ((i=i+1))
128done < ${MODIPSL_SAVE}/Last_log
129
130echo
131echo "read Last_log OK !"
132echo
133
134(( i = 0 ))
135for comp in ${ModelComponents[@]}; do
136    tag=${ModelTags[$i]}
137    echo $i $comp " : " $tag
138
139    pathComp=${ListPathComp[$i]}
140    filecomp=$( echo ${ListPathFile[$i]} | sed -e "s/_empty_//" )
141    SpathComp=${MODIPSL_SAVE}/${pathComp}
142    echo "Path/file :" ${pathComp}/${filecomp}
143
144    case ${ModelSystems[$i]} in
145        svn)
146            svn co -r ${ListPathRev[$i]} ${ModelServers[$i]}/${ListPathBranch[$i]}/${filecomp} ${pathComp}/${filecomp}
147            ;;
148        cvs)
149
150            cd ${ModelLocalDirs[i]}
151            if [ X${ModelDirectories[$i]} = X. ] ; then
152#               rev=$( echo ${ListPathRev[$i]} | sed -e 's%\([0-9][0-9]\)/\([0-9][0-9]\)/\([0-9][0-9]\)_\([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\)%\3/\1/\2 \4%g' )
153                rev=$( echo ${ListPathRev[$i]} | sed -e 's%:"[0-9][0-9]/[0-9][0-9]/[0-9][0-9]_[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"%%g' )
154                eval cvs -d :pserver:${ModelServers[$i]} co -r "${rev}" ${comp}
155            else
156                rev=$( echo ${ListPathRev[$i]} | sed -e 's%:"[0-9][0-9]/[0-9][0-9]/[0-9][0-9]_[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"%%g' )
157                echo cvs -d :pserver:${ModelServers[$i]} co -r ${rev} -d ${ModelDirectories[$i]} ${comp}
158                cvs -d :pserver:${ModelServers[$i]} co -r ${rev} -d ${ModelDirectories[$i]} ${comp}
159            fi
160            cd ${MODIPSL}
161
162            ;;
163        *)
164            echo "error ${ModelSystems[$i]} is not recognized as a valid control version system for ${MODIPSL_SAVE}/Last_log."
165            exit 1
166            ;;
167    esac
168    ((i=i+1))
169done
170
171set +A ListRep -- $( find ${MODIPSL_SAVE} -mindepth 1 -type d \
172    -exec bash -c " echo "'{}'" | sed -e 's&"${MODIPSL_SAVE}"/&&' | tee -a >( sed -e 's&\(.*\)&"${MODIPSL}"/\1&' | xargs mkdir -p >> out_mkdir 2>&1 ) " \; )
173printDebugArray ListRep
174rm out_mkdir
175
176(( i = 0 ))
177for comp in ${ModelComponents[@]}; do
178    tag=${ModelTags[$i]}
179    echo $i $comp " : " $tag
180
181    pathComp=${ListPathComp[$i]}
182    filecomp=$( echo ${ListPathFile[$i]} | sed -e "s/_empty_//" )
183    SpathComp=${MODIPSL_SAVE}/${pathComp}
184    echo "Patch :" $( ls ${SpathComp} )
185
186    # Patch this model
187    cd ${pathComp}
188    case ${ModelSystems[$i]} in
189        svn)
190            patch -p0 -i ${SpathComp}/svn_diff     
191            ;;
192        cvs)
193            patch -p0 -i ${SpathComp}/cvs_diff
194            ;;
195    esac
196    cd ${MODIPSL}
197    ((i=i+1))
198done
199
200# copy new files
201for file in ${ListNewFiles[@]} ; do
202    echo "copy New file : " ${MODIPSL_SAVE}/$file $file
203    cp -p ${MODIPSL_SAVE}/$file $file
204done 
Note: See TracBrowser for help on using the repository browser.