1 | #!/bin/ksh |
---|
2 | |
---|
3 | ######################################################################## |
---|
4 | |
---|
5 | #D- Flag to determine if this job in a standalone mode |
---|
6 | #D- Default : value from AA_job if any |
---|
7 | StandAlone=${StandAlone:=true} |
---|
8 | |
---|
9 | #D- Increased verbosity (1, 2, 3) |
---|
10 | #D- Default : value from AA_job if any |
---|
11 | Verbosity=${Verbosity:=3} |
---|
12 | |
---|
13 | #D- Low level debug : to bypass lib test checks and stack construction |
---|
14 | #D- Default : value from AA_job if any |
---|
15 | DEBUG_debug=${DEBUG_debug:=false} |
---|
16 | |
---|
17 | |
---|
18 | ######################################################################## |
---|
19 | |
---|
20 | MODIPSL=$1 |
---|
21 | libIGCM=${libIGCM:=${MODIPSL}/libIGCM} |
---|
22 | |
---|
23 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
24 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
25 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
26 | #------- |
---|
27 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
28 | . ${libIGCM}/libIGCM_config/libIGCM_config.ksh |
---|
29 | . ${libIGCM}/libIGCM_comp/libIGCM_comp.ksh |
---|
30 | . ${libIGCM}/libIGCM_post/libIGCM_post.ksh |
---|
31 | #------- |
---|
32 | ( ${DEBUG_debug} ) && IGCM_debug_Check |
---|
33 | ( ${DEBUG_debug} ) && IGCM_card_Check |
---|
34 | ( ${DEBUG_debug} ) && IGCM_date_Check |
---|
35 | |
---|
36 | #D--------------------------------------------------------------------== |
---|
37 | #D- 0.1 COMMON ENVIRONMENT |
---|
38 | #D- - Read libIGCM compatibility version in config.card |
---|
39 | #D- - Read UserChoices section |
---|
40 | #D- - Read Ensemble section |
---|
41 | #D- - Read Post section |
---|
42 | #D- - Define all netcdf output directories |
---|
43 | #D--------------------------------------------------------------------== |
---|
44 | IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card |
---|
45 | |
---|
46 | |
---|
47 | #D--------------------------------------------------------------------== |
---|
48 | #D- 1. INITIALIZE CONFIGURATION |
---|
49 | #D- - Simulation configuration |
---|
50 | #D- - Simulation parameters |
---|
51 | #D- - Execution parameter |
---|
52 | #D- - Define input files directory |
---|
53 | #D- - Read or initialize CumulPeriod |
---|
54 | #D- - run.card |
---|
55 | #D---------------------------------------------------------------------== |
---|
56 | IGCM_config_Initialize |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | ######################################################################## |
---|
61 | #set -vx |
---|
62 | ######################################################################## |
---|
63 | # Script input parameters |
---|
64 | |
---|
65 | Group=$2 |
---|
66 | # Site name |
---|
67 | SiteArg=$3 |
---|
68 | Site=${SiteArg:=Gu} |
---|
69 | export Site |
---|
70 | ## Time in years in file for this site : |
---|
71 | #DureeArg=$4 |
---|
72 | #DUREE=${DureeArg:=1} |
---|
73 | #export DUREE |
---|
74 | # |
---|
75 | ## First year in file for this site : |
---|
76 | #FirstArg=$5 |
---|
77 | #FYEAR=${FirstArg:=1} |
---|
78 | #export FYEAR |
---|
79 | # |
---|
80 | #(( LYEAR=FYEAR+DUREE-1 )) |
---|
81 | #export LYEAR |
---|
82 | |
---|
83 | |
---|
84 | # Atlas Name : |
---|
85 | AtlasCfgArg=$4 |
---|
86 | AtlasCfg=${AtlasCfgArg:=atlas_FLUXNET.cfg} |
---|
87 | |
---|
88 | # observation_file |
---|
89 | eval observation_file_pathArg=$5 |
---|
90 | observation_file=${observation_file_pathArg} |
---|
91 | echo observation_file=${observation_file} |
---|
92 | |
---|
93 | # Modulo for SpinUp years |
---|
94 | ModuloArg=${8} |
---|
95 | echo "ModuloArg:" $ModuloArg |
---|
96 | |
---|
97 | IGCM_sys_MkdirWork ${RUN_DIR_PATH} |
---|
98 | echo "RUN_DIR_PATH ${RUN_DIR_PATH} ok." |
---|
99 | IGCM_sys_Cd ${RUN_DIR_PATH} |
---|
100 | |
---|
101 | if [ ${StandAlone} = true ] ; then |
---|
102 | CARD_DIR=${SUBMIT_DIR} |
---|
103 | else |
---|
104 | CARD_DIR=${RUN_DIR_PATH}/$( basename ${SUBMIT_DIR} ) |
---|
105 | IGCM_sys_Get_Master ${SUBMIT_DIR} ${RUN_DIR_PATH} |
---|
106 | fi |
---|
107 | |
---|
108 | # |
---|
109 | # First of all |
---|
110 | # |
---|
111 | IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card UserChoices |
---|
112 | typeset option |
---|
113 | for option in ${config_UserChoices[*]} ; do |
---|
114 | IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card UserChoices ${option} |
---|
115 | done |
---|
116 | # |
---|
117 | echo |
---|
118 | IGCM_debug_Print 1 "DefineArrayFromOption : config_UserChoices" |
---|
119 | IGCM_debug_PrintVariables 3 config_UserChoices_JobName |
---|
120 | if [ 3 -le ${Verbosity} ] ; then |
---|
121 | echo "--------------Debug3-->" "config_UserChoices_LongName=" |
---|
122 | echo "--------------Debug3-->" \"${config_UserChoices_LongName}\" |
---|
123 | fi |
---|
124 | IGCM_debug_PrintVariables 3 config_UserChoices_TagName |
---|
125 | IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType |
---|
126 | IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin |
---|
127 | IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd |
---|
128 | IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength |
---|
129 | echo |
---|
130 | |
---|
131 | |
---|
132 | # FLAG = SECHIBA, OK_STOMATE |
---|
133 | IGCM_card_DefineVariableFromOption ${CARD_DIR}/ensemble.card UserChoices ok_stomate |
---|
134 | if [ X${ensemble_UserChoices_ok_stomate} = Xn ] ; then |
---|
135 | export FLAG=SECHIBA |
---|
136 | else |
---|
137 | export FLAG=OK_STOMATE |
---|
138 | fi |
---|
139 | |
---|
140 | |
---|
141 | #================================== |
---|
142 | |
---|
143 | SpinUpJob=${Site}${config_UserChoices_JobName} |
---|
144 | set -A liste_fichiers_with_path -- $( \ls -rt ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_UserChoices_JobName}/${SpinUpJob}HIST/SRF/Output/MO/*_sechiba_history.nc ) |
---|
145 | echo liste_fichiers_with_path=${liste_fichiers_with_path} |
---|
146 | ii=0 |
---|
147 | for filetmp in ${liste_fichiers_with_path[@]} ; do |
---|
148 | (( ii = ii + 1 )) |
---|
149 | file=$( echo ${filetmp} | xargs basename ) |
---|
150 | done |
---|
151 | if [ $ii -ne 1 ] ; then |
---|
152 | echo "Error. More than one file found. ii=$ii" |
---|
153 | exit |
---|
154 | fi |
---|
155 | echo file=$file |
---|
156 | |
---|
157 | # Get and sed atlas |
---|
158 | IGCM_sys_Cp ${CARD_DIR}/${AtlasCfg} ./atlas.cfg |
---|
159 | IGCM_sys_Cp ${CARD_DIR}/ORCHIDEE_3dif.jnl ./ORCHIDEE_3dif.jnl |
---|
160 | |
---|
161 | IGCM_sys_Cp -Rp ${liste_fichiers_with_path[0]} . |
---|
162 | |
---|
163 | # old history file |
---|
164 | reference_file_pathArg=$6 |
---|
165 | if [ X${reference_file_pathArg} == XNONE ] ; then |
---|
166 | reference_file_path=${liste_fichiers_with_path} |
---|
167 | else |
---|
168 | reference_file_path=${reference_file_pathArg} |
---|
169 | fi |
---|
170 | |
---|
171 | eval reference_file=${reference_file_path} |
---|
172 | sed -e "s,RRRRRRR,${reference_file},g" -e "s,VVVVVVV,${observation_file},g" atlas.cfg > atlas_.cfg |
---|
173 | |
---|
174 | echo "REFERENCE ATLAS for file : " ${file} ${reference_file} ${observation_file} |
---|
175 | reference_config=$7 |
---|
176 | atlas -o ${SpinUpJob}_${reference_config} atlas_.cfg ${file} |
---|
177 | |
---|
178 | # Remove small files before saving |
---|
179 | if [ X$CleanSmallFiles = Xyes ] ; then |
---|
180 | tmpdir=${SpinUpJob}_${reference_config} |
---|
181 | # Remove .info .tex .jnl .stdout .jpg .pdf (deuxieme niveau ) |
---|
182 | echo "Remove small files before saving : " |
---|
183 | sumfilestoremove=$(( $( find ${tmpdir} -name "*.info" | wc -l ) + $( find ${tmpdir} -name "*.tex" | wc -l ) + $( find ${tmpdir} -name "*.jnl" | wc -l ) + $( find ${tmpdir} -name "*.stdout" | wc -l ) + $( find ${tmpdir} -name "*.pdf" | wc -l ) )) |
---|
184 | echo "Following $sumfilestoremove files listed below will be removed: " |
---|
185 | |
---|
186 | find ${tmpdir} -name "*.info" |
---|
187 | find ${tmpdir} -name "*.tex" |
---|
188 | find ${tmpdir} -name "*.jnl" |
---|
189 | find ${tmpdir} -name "*.stdout" |
---|
190 | find ${tmpdir} -name "*.pdf" |
---|
191 | |
---|
192 | # Now remove them |
---|
193 | find ${tmpdir} -name "*.info" -print -exec rm -f '{}' \; |
---|
194 | find ${tmpdir} -name "*.tex" -print -exec rm -f '{}' \; |
---|
195 | find ${tmpdir} -name "*.jnl" -print -exec rm -f '{}' \; |
---|
196 | find ${tmpdir} -name "*.stdout" -print -exec rm -f '{}' \; |
---|
197 | find ${tmpdir} -name "*.pdf" -print -exec rm -f '{}' \; |
---|
198 | |
---|
199 | else |
---|
200 | echo "No clean of small files will be done." |
---|
201 | fi |
---|
202 | |
---|
203 | |
---|
204 | # Save files |
---|
205 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_UserChoices_JobName}/fluxnet_taylor_diff_${config_UserChoices_JobName}_${reference_config}_${Group} |
---|
206 | |
---|
207 | echo "Before IGCM_sys_Put_Dir : destination= ${R_SAVE}" |
---|
208 | IGCM_sys_Put_Dir ${SpinUpJob}_${reference_config} ${R_SAVE} |
---|
209 | |
---|
210 | IGCM_sys_Rm -Rf ${SpinUpJob}_${reference_config} |
---|
211 | |
---|
212 | |
---|
213 | |
---|
214 | # # Get and Apply Patch |
---|
215 | # . ${MODIPSL}/libIGCM/libIGCM_post/IGCM_Patch_20070220_histcom_time_axis.ksh |
---|
216 | # for file in ${liste_fichiers[*]} ; do |
---|
217 | # IGCM_Patch_20070220_histcom_time_axis ${file} |
---|
218 | # done |
---|
219 | |
---|
220 | # # look at files |
---|
221 | # echo "after Patch" IGCM_Patch_20070220_histcom_time_axis |
---|
222 | # \ls -lrt *_sechiba_history.nc |
---|
223 | |
---|
224 | # Concat files |
---|
225 | #IGCM_sys_ncrcat -o ${SpinUpJob}_1M_sechiba_history.nc ${liste_fichiers[*]} |
---|
226 | |
---|
227 | IGCM_sys_Rm -Rf ${liste_fichiers[*]} |
---|
228 | |
---|
229 | IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH} |
---|