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 | #RUN_DIR_PATH=${RUN_DIR_PATH:=/tmp/tmp$$} |
---|
18 | |
---|
19 | ######################################################################## |
---|
20 | |
---|
21 | MODIPSL=$1 |
---|
22 | libIGCM=${libIGCM:=${MODIPSL}/libIGCM} |
---|
23 | |
---|
24 | . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh |
---|
25 | . ${libIGCM}/libIGCM_card/libIGCM_card.ksh |
---|
26 | . ${libIGCM}/libIGCM_date/libIGCM_date.ksh |
---|
27 | . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh |
---|
28 | |
---|
29 | ######################################################################## |
---|
30 | #set -vx |
---|
31 | ######################################################################## |
---|
32 | # Script input parameters |
---|
33 | |
---|
34 | # Site name |
---|
35 | SiteArg=$2 |
---|
36 | Site=${SiteArg:=Gu} |
---|
37 | # Time in years in file for this site : |
---|
38 | DureeArg=$3 |
---|
39 | export DUREE=${DureeArg:=1} |
---|
40 | |
---|
41 | # First year in file for this site : |
---|
42 | FirstArg=$4 |
---|
43 | export FYEAR=${FirstArg:=1} |
---|
44 | |
---|
45 | |
---|
46 | # Atlas Name : |
---|
47 | AtlasCfgArg=$5 |
---|
48 | AtlasCfg=${AtlasCfgArg:=atlas_FLUXNET.cfg} |
---|
49 | |
---|
50 | # observation_file |
---|
51 | observation_file_pathArg=$6 |
---|
52 | observation_file_path=${observation_file_pathArg:='${R_IN}/BC/OOL/${config_UserChoices_TagName}/FLUXNET/OLD/${Site}.nc'} |
---|
53 | #/home/mancip/IGCM/BC/OOL/OL2/FLUXNET/OBS/${Site}_obs_gapfilled.nc |
---|
54 | |
---|
55 | # old history file |
---|
56 | reference_file_pathArg=$7 |
---|
57 | reference_file_path=${reference_file_pathArg:='/home/mancip/PROG/IPSL/VALID_OL/SECHIBA/${Site}_sechiba_hist.nc'} |
---|
58 | |
---|
59 | # Modulo for SpinUp years |
---|
60 | ModuloArg=$8 |
---|
61 | |
---|
62 | #if [ ${DEBUG_debug} = true ] ; then |
---|
63 | IGCM_sys_MkdirWork ${RUN_DIR_PATH} |
---|
64 | echo "RUN_DIR_PATH ${RUN_DIR_PATH} ok." |
---|
65 | #fi |
---|
66 | IGCM_sys_Cd ${RUN_DIR_PATH} |
---|
67 | |
---|
68 | if [ ${StandAlone} = true ] ; then |
---|
69 | CARD_DIR=${SUBMIT_DIR} |
---|
70 | else |
---|
71 | CARD_DIR=${RUN_DIR_PATH}/$( basename ${SUBMIT_DIR} ) |
---|
72 | IGCM_sys_Get_Master ${SUBMIT_DIR} ${RUN_DIR_PATH} |
---|
73 | fi |
---|
74 | |
---|
75 | # |
---|
76 | # First of all |
---|
77 | # |
---|
78 | IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card UserChoices |
---|
79 | typeset option |
---|
80 | for option in ${config_UserChoices[*]} ; do |
---|
81 | IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card UserChoices ${option} |
---|
82 | done |
---|
83 | # |
---|
84 | echo |
---|
85 | IGCM_debug_Print 1 "DefineArrayFromOption : config_UserChoices" |
---|
86 | IGCM_debug_PrintVariables 3 config_UserChoices_JobName |
---|
87 | if [ 3 -le ${Verbosity} ] ; then |
---|
88 | echo "--------------Debug3-->" "config_UserChoices_LongName=" |
---|
89 | echo "--------------Debug3-->" \"${config_UserChoices_LongName}\" |
---|
90 | fi |
---|
91 | IGCM_debug_PrintVariables 3 config_UserChoices_TagName |
---|
92 | IGCM_debug_PrintVariables 3 config_UserChoices_CalendarType |
---|
93 | IGCM_debug_PrintVariables 3 config_UserChoices_DateBegin |
---|
94 | IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd |
---|
95 | IGCM_debug_PrintVariables 3 config_UserChoices_PeriodLength |
---|
96 | echo |
---|
97 | |
---|
98 | |
---|
99 | # FLAG = SECHIBA, OK_STOMATE |
---|
100 | IGCM_card_DefineVariableFromOption ${CARD_DIR}/fluxnet.card UserChoices ok_stomate |
---|
101 | if [ X${fluxnet_UserChoices_ok_stomate} = Xn ] ; then |
---|
102 | export FLAG=SECHIBA |
---|
103 | else |
---|
104 | export FLAG=OK_STOMATE |
---|
105 | fi |
---|
106 | |
---|
107 | #================================== |
---|
108 | |
---|
109 | SpinUpJob=${Site}${config_UserChoices_JobName} |
---|
110 | |
---|
111 | R_BC=${R_IN}/BC |
---|
112 | R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${SpinUpJob}/SPIN |
---|
113 | |
---|
114 | # look at files |
---|
115 | IGCM_card_DefineVariableFromOption ${CARD_DIR}/fluxnet.card UserChoices DEBUG_SPIN |
---|
116 | if [ X${fluxnet_UserChoices_DEBUG_SPIN} = Xn ] ; then |
---|
117 | set -A liste_fichiers_with_path -- $( \ls -rt ${R_SAVE}/Output/${SpinUpJob}*/SRF/Output/MO/*_sechiba_history.nc ${R_OUT}/${config_UserChoices_TagName}/${SpinUpJob}HIST/SRF/Output/MO/*_sechiba_history.nc ) |
---|
118 | else |
---|
119 | set -A liste_fichiers_with_path -- $( \ls -rt ${R_OUT}/${config_UserChoices_TagName}/${SpinUpJob}*/SRF/Output/MO/*_sechiba_history.nc ) |
---|
120 | fi |
---|
121 | |
---|
122 | ii=0 |
---|
123 | for file in ${liste_fichiers_with_path[@]} ; do |
---|
124 | liste_fichiers[$ii]=$( echo ${file} | xargs basename ) |
---|
125 | (( ii = ii + 1 )) |
---|
126 | done |
---|
127 | echo ${liste_fichiers[*]} |
---|
128 | |
---|
129 | # Get and sed atlas |
---|
130 | IGCM_sys_Cp ${CARD_DIR}/${AtlasCfg} ./atlas.cfg |
---|
131 | |
---|
132 | # Set default Modulo parameter to the last file |
---|
133 | eval NbFiles=${#liste_fichiers[@]} |
---|
134 | echo "NbFiles=" $NbFiles |
---|
135 | Modulo=${ModuloArg:=$(( NbFiles - 1 ))} |
---|
136 | |
---|
137 | # Get last time_axis patch |
---|
138 | Last_Patch_File=$( ls -t ${libIGCM}/libIGCM_post/IGCM_Patch_*_histcom_time_axis.ksh | tail -1 ) |
---|
139 | #echo "source patch file : ${Last_Patch_File}" |
---|
140 | # . ${Last_Patch_File} |
---|
141 | # Last_Patch=$( echo ${Last_Patch_File} | sed -e "s&${libIGCM}/libIGCM_post/\(.*\)\.ksh&\1&" ) |
---|
142 | #echo "We will apply the patch on all sechiba files : " ${Last_Patch} |
---|
143 | |
---|
144 | # Apply atlas |
---|
145 | ii=0 |
---|
146 | for file in ${liste_fichiers[*]} ; do |
---|
147 | |
---|
148 | DirFile=$( dirname ${liste_fichiers_with_path[$ii]} ) |
---|
149 | echo ${DirFile} |
---|
150 | |
---|
151 | # First apply the last time_axis patch |
---|
152 | # IGCM_sys_Cd ${DirFile} |
---|
153 | # ${Last_Patch} ${file} |
---|
154 | # # clean dir |
---|
155 | # rm out_rsync |
---|
156 | # # Then return to RUN_DIR_PATH |
---|
157 | # IGCM_sys_Cd ${RUN_DIR_PATH} |
---|
158 | |
---|
159 | if [ $ii -eq 0 ] ; then |
---|
160 | file_=${file} |
---|
161 | # copy files we need for ATLAS |
---|
162 | IGCM_sys_Cp -p ${liste_fichiers_with_path[$ii]} . |
---|
163 | fi |
---|
164 | echo "!!!!!!!!!!!!!!!!!" |
---|
165 | echo ${file} |
---|
166 | export F_FILE=${Site} |
---|
167 | echo $ii "Modulo : " $( expr $ii \% $Modulo ) |
---|
168 | if [ $ii -gt 0 ] && [ X$( expr $ii \% $Modulo ) = X0 ] ; then |
---|
169 | |
---|
170 | # copy files we need for ATLAS |
---|
171 | IGCM_sys_Cp -Rp ${liste_fichiers_with_path[$ii]} . |
---|
172 | |
---|
173 | reference_file=${file_} |
---|
174 | eval observation_file=${observation_file_path} |
---|
175 | echo "ATLAS DIFF for files : " ${file} ${reference_file} ${observation_file} |
---|
176 | |
---|
177 | #cat atlas.cfg |
---|
178 | sed -e "s,RRRRRRR,${reference_file},g" -e "s,VVVVVVV,${observation_file},g" atlas.cfg > atlas_.cfg |
---|
179 | #cat atlas_.cfg |
---|
180 | AtlasPath=$( echo ${file} | sed -e 's/_1M_sechiba_history.nc//' ) |
---|
181 | atlas -o ATLAS_DIFF_${AtlasPath} atlas_.cfg ${file} |
---|
182 | |
---|
183 | # Save files |
---|
184 | IGCM_sys_Put_Dir ATLAS_DIFF_${AtlasPath} ${R_SAVE} |
---|
185 | # IGCM_sys_Rm -Rf ATLAS_DIFF_${AtlasPath} |
---|
186 | echo "&&&&&&&&&&&&&&&&!" |
---|
187 | |
---|
188 | file_=${file} |
---|
189 | fi |
---|
190 | (( ii=ii+1 )) |
---|
191 | done |
---|
192 | eval reference_file=${reference_file_path} |
---|
193 | sed -e "s,RRRRRRR,${reference_file},g" -e "s,VVVVVVV,${observation_file},g" atlas.cfg > atlas_.cfg |
---|
194 | |
---|
195 | echo "REFERENCE ATLAS for file : " ${file} ${reference_file} ${observation_file} |
---|
196 | atlas -o ATLAS_FIN_${AtlasPath}_ref atlas_.cfg ${file} |
---|
197 | |
---|
198 | # Save files |
---|
199 | IGCM_sys_Put_Dir ATLAS_FIN_${AtlasPath}_ref ${R_SAVE} |
---|
200 | |
---|
201 | IGCM_sys_Rm -Rf ATLAS_FIN_${AtlasPath}_ref |
---|
202 | |
---|
203 | |
---|
204 | |
---|
205 | # # Get and Apply Patch |
---|
206 | # . ${MODIPSL}/libIGCM/libIGCM_post/IGCM_Patch_20070220_histcom_time_axis.ksh |
---|
207 | # for file in ${liste_fichiers[*]} ; do |
---|
208 | # IGCM_Patch_20070220_histcom_time_axis ${file} |
---|
209 | # done |
---|
210 | |
---|
211 | # # look at files |
---|
212 | # echo "after Patch" IGCM_Patch_20070220_histcom_time_axis |
---|
213 | # \ls -lrt *_sechiba_history.nc |
---|
214 | |
---|
215 | # Concat files |
---|
216 | #IGCM_sys_ncrcat -o ${SpinUpJob}_1M_sechiba_history.nc ${liste_fichiers[*]} |
---|
217 | |
---|
218 | IGCM_sys_Rm -Rf ${liste_fichiers[*]} |
---|
219 | |
---|
220 | IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH} |
---|