source: tags/ORCHIDEE_1_9_6/ORCHIDEE_OL/FLUXNET/post_FLUXNET @ 4234

Last change on this file since 4234 was 602, checked in by nicolas.vuichard, 13 years ago

New Taylor diagrams for post-treatment

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