source: trunk/libIGCM/libIGCM_post/IGCM_Patch_20091030_histcom_time_axis.ksh @ 1059

Last change on this file since 1059 was 1059, checked in by sdipsl, 10 years ago
  • Attach the licence when it is not the case
  • 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.8 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_20091030_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-9a-zA-Z]*\).*/\1/')
25    # liste => tous les axes de temps vont s'appeler time_counter !!
26    if [ $? -eq 0 ] ; then
27      if [ ${#AXISt[*]} -ge 1 ] ; then
28
29        file=t_$1
30        IGCM_sys_Mv ${1} ${file}
31        IGCM_sys_Chmod 644 ${file}
32
33        if [ ${#AXISt[*]} -gt 1 ] ; then
34            echo "WARNING : for file ${1} we have more than one time axis !"
35            echo "We choose first one ! = t_ave_${AXISt[0]}."
36        fi
37        #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
38        # We keep only first time axis as time_counter !!!!
39        #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
40
41        AXISt_i=${AXISt[0]}
42        # Rename time_counter variable
43        IGCM_sys_ncrename -O --hst -v t_ave_${AXISt_i},time_counter ${file}
44        ncdump -h ${file} > ${file}_ncdump-h
45
46        # We have also to rename variables indexed by this time value
47        # liste => pb avec deux variables indéxées par deux valeurs de temps différentes => même nom au final!
48        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/" )
49        for VAR_AXISt_i in ${VAR_AXISt[*]} ; do
50            IGCM_sys_ncrename -O --hst -v ${VAR_AXISt_i}_${AXISt_i},${VAR_AXISt_i} ${file}
51        done
52
53        # A-t-on besoin de renommer les attributs des autres variables ??
54        # Rename relative associate string in other variables
55
56        set +A VARName $( cat ${file}_ncdump-h | grep "[0-9a-zA-Z_]*.*:associate.*" | grep "t_ave_${AXISt_i}" | sed -e "s/[[:space:]]*\(.*\):associate.*/\1/" )
57        for var in ${VARName[*]} ; do 
58            # Old attribute value
59            ATTN=$( cat ${file}_ncdump-h | grep "${var}:associate.*" | grep "t_ave_${AXISt_i}" | sed -e "s/.*:associate = \"\(.*\)\" ;/\1/" )
60            # New attribute value
61            ATTNV=$( echo ${ATTN} | sed -e "s/t_ave_${AXISt_i}/time_counter/" ) #| sed -e 's/[[:space:]]/\\ /g')
62            # change it !
63            IGCM_sys_ncatted -O --hst -a associate,${var},m,c,"${ATTNV}" ${file}
64        done
65
66        # Rename coordinates attribut from t_ave_xxxx to time_counter
67
68        set +A VARName $( cat ${file}_ncdump-h | grep "[0-9a-zA-Z_]*.*:coordinates.*" | grep "t_ave_${AXISt_i}" | sed -e "s/[[:space:]]*\(.*\):coordinates.*/\1/" )
69        for var in ${VARName[*]} ; do
70            # Old attribute value
71            ATTN=$( cat ${file}_ncdump-h | grep "${var}:coordinates.*" | grep "t_ave_${AXISt_i}" | sed -e "s/.*:coordinates = \"\(.*\)\" ;/\1/" )
72            # New attribute value
73            ATTNV=$( echo ${ATTN} | sed -e "s/t_ave_${AXISt_i}/time_counter/" ) #| sed -e 's/[[:space:]]/\\ /g')
74            # change it !
75            IGCM_sys_ncatted -O --hst -a coordinates,${var},m,c,"${ATTNV}" ${file}
76        done
77
78
79        IGCM_debug_Verif_Exit_Post
80        IGCM_sys_Mv ${file} ${1}
81        IGCM_sys_Rm ${file}_ncdump-h
82      fi
83    fi
84    IGCM_sys_Rm ${1}_ncdump-h
85   
86    IGCM_debug_PopStack "IGCM_Patch_histcom_time_axis"
87}
Note: See TracBrowser for help on using the repository browser.