[91] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Martial Mancip |
---|
[373] | 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 |
---|
[91] | 9 | # IPSL (2006) |
---|
| 10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 11 | # |
---|
| 12 | #************************************************************** |
---|
| 13 | |
---|
| 14 | #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 15 | # We keep only first time axis as time_counter !!!! |
---|
| 16 | #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 17 | |
---|
| 18 | function IGCM_Patch_20090407_histcom_time_axis { |
---|
| 19 | IGCM_debug_PushStack "IGCM_Patch_histcom_time_axis" $@ |
---|
| 20 | |
---|
| 21 | typeset file AXISt AXISt_i VARName var ATTN ATTNV VAR_AXISt VAR_AXISt_i |
---|
| 22 | |
---|
| 23 | ncdump -h ${1} > ${1}_ncdump-h |
---|
[169] | 24 | set +A AXISt $(cat ${1}_ncdump-h | grep 't_ave_.*(time_counter)' | sed -e 's/[[:space:]][fd][lo][ou][ab][tl][ e] *t_ave_\([0-9]*\).*/\1/') |
---|
[91] | 25 | # liste => tous les axes de temps vont s'appeler time_counter !! |
---|
| 26 | if [ $? -eq 0 ] ; then |
---|
| 27 | |
---|
| 28 | file=t_$1 |
---|
| 29 | IGCM_sys_Mv ${1} ${file} |
---|
| 30 | IGCM_sys_Chmod 644 ${file} |
---|
| 31 | |
---|
| 32 | if [ ${#AXISt[*]} -gt 1 ] ; then |
---|
| 33 | echo "WARNING : for file ${1} we have more than one time axis !" |
---|
| 34 | echo "We choose first one ! = t_ave_${AXISt[0]}." |
---|
| 35 | fi |
---|
| 36 | #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 37 | # We keep only first time axis as time_counter !!!! |
---|
| 38 | #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 39 | |
---|
| 40 | AXISt_i=${AXISt[0]} |
---|
| 41 | # Rename time_counter variable |
---|
| 42 | IGCM_sys_ncrename -O --hst -v t_ave_${AXISt_i},time_counter ${file} |
---|
| 43 | ncdump -h ${file} > ${file}_ncdump-h |
---|
| 44 | |
---|
| 45 | # We have also to rename variables indexed by this time value |
---|
| 46 | # liste => pb avec deux variables indéxées par deux valeurs de temps différentes => même nom au final! |
---|
| 47 | set +A VAR_AXISt $( cat ${file}_ncdump-h | grep "[[:space:]]*[a-z]* [a-zA-Z_]*${AXISt_i}(.*) ;" | sed -e "s/[[:space:]]*[a-z]* \([a-zA-Z_]*\)_${AXISt_i}(.*) ;/\1/" ) |
---|
| 48 | for VAR_AXISt_i in ${VAR_AXISt[*]} ; do |
---|
| 49 | IGCM_sys_ncrename -O --hst -v ${VAR_AXISt_i}_${AXISt_i},${VAR_AXISt_i} ${file} |
---|
| 50 | done |
---|
| 51 | |
---|
| 52 | # A-t-on besoin de renommer les attributs des autres variables ?? |
---|
| 53 | # Rename relative associate string in other variables |
---|
| 54 | |
---|
| 55 | set +A VARName $( cat ${file}_ncdump-h | grep "[0-9a-zA-Z_]*.*:associate.*" | grep "t_ave_${AXISt_i}" | sed -e "s/[[:space:]]*\(.*\):associate.*/\1/" ) |
---|
| 56 | for var in ${VARName[*]} ; do |
---|
| 57 | # Old attribute value |
---|
| 58 | ATTN=$( cat ${file}_ncdump-h | grep "${var}:associate.*" | grep "t_ave_${AXISt_i}" | sed -e "s/.*:associate = \"\(.*\)\" ;/\1/" ) |
---|
| 59 | # New attribute value |
---|
| 60 | ATTNV=$( echo ${ATTN} | sed -e "s/t_ave_${AXISt_i}/time_counter/" ) #| sed -e 's/[[:space:]]/\\ /g') |
---|
| 61 | # change it ! |
---|
[375] | 62 | IGCM_sys_ncatted -O --hst -a associate,${var},m,c,"${ATTNV}" ${file} |
---|
[91] | 63 | done |
---|
| 64 | IGCM_debug_Verif_Exit_Post |
---|
| 65 | IGCM_sys_Mv ${file} ${1} |
---|
| 66 | IGCM_sys_Rm ${file}_ncdump-h |
---|
| 67 | fi |
---|
| 68 | IGCM_sys_Rm ${1}_ncdump-h |
---|
| 69 | |
---|
| 70 | IGCM_debug_PopStack "IGCM_Patch_histcom_time_axis" |
---|
| 71 | } |
---|