source: modipsl/trunk/util/script_recup_model @ 1582

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

This script creates a tree of last configuration modipsl from a tar file previously produced by script_diff_model.

After you have downloaded modipsl, you can copy a modipsl_name_of_the_save.tar file in modipsl.
(Please, see script_diff_model documentation for information of how to get this file.)
You may use this script to download the same configuration with new files and modifications linked with this tarball.

usage (in modipsl path) :

modipsl_path> util/script_recup_model modipsl_name_of_the_save

(without tar extension.)

After this whole configuration is backuped, you must use as usual ins_make and ins_job script
to installed all files depended on this new modipsl and the computer.

Note :

It may not compile because of special post-installation (not versionning) for some component in model.
See "Actions related to the WORK directory for the OPA models" in model script to reproduce this post-installation.

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