source: trunk/libIGCM/libIGCM_post/IGCM_Patch_20090407_histcom_time_axis.ksh @ 1206

Last change on this file since 1206 was 1206, checked in by sdipsl, 9 years ago
  • Remove IGCM_debug_Verif_Exit_Post. Only IGCM_debug_Verif_Exit will manage exit cases.
  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Revision Author Date
File size: 3.2 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#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15# We keep only first time axis as time_counter !!!!
16#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
17
18function 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
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/')
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 !
62            IGCM_sys_ncatted -O --hst -a associate,${var},m,c,"${ATTNV}" ${file}
63        done
64        # ------------------------------------------------------------------
65        # Test if all was right before proceeding further
66        # ------------------------------------------------------------------
67        IGCM_debug_Verif_Exit
68
69        IGCM_sys_Mv ${file} ${1}
70        IGCM_sys_Rm ${file}_ncdump-h
71    fi
72    IGCM_sys_Rm ${1}_ncdump-h
73   
74    IGCM_debug_PopStack "IGCM_Patch_histcom_time_axis"
75}
Note: See TracBrowser for help on using the repository browser.