source: tags/libIGCM_v2.4/libIGCM_post/IGCM_Patch_20091118_mask.ksh @ 1331

Last change on this file since 1331 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: 5.3 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Arnaud Caubel
5# Contact: Arnaud.Caubel__at__lsce.ipsl.fr
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ Date of last commit
9# IPSL (2009)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14#------------------------------------------------------------
15# Add mask from meshmask file to oceanic variables
16#------------------------------------------------------------
17
18function IGCM_Patch_20091118_mask {
19
20    IGCM_debug_PushStack "IGCM_Patch_mask" $@
21
22    if [ ! -f ${config_UserChoices_JobName}_mesh_mask.nc ] ; then
23      if [ -f ${R_BUFR}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc ] ; then
24        IGCM_sys_GetBuffer ${R_BUFR}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc .
25      elif [ -f ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc ] ; then
26        IGCM_sys_Get ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc .
27      else
28        IGCM_debug_Exit "mesh_mask can not be found. Stop."
29        IGCM_debug_Exit "neither here ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc"
30        IGCM_debug_Exit "nor here ${R_BUFR}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc"
31        IGCM_debug_Verif_Exit_Post
32      fi
33    fi
34
35    filename=${1}
36
37    chaineT=${filename%%'grid_T'*}
38    chaineU=${filename%%'grid_U'*}
39    chaineV=${filename%%'grid_V'*}
40    chaineW=${filename%%'grid_W'*}
41    chaineIce=${filename%%'icemod'*}
42    chaineTrc=${filename%%'ptrc_T'*}
43    chaineDia=${filename%%'diad_T'*}
44    chaineBio=${filename%%'dbio_T'*}
45
46    if [ ${filename} != ${chaineT} ]; then
47        mask='tmask' ; depth='deptht'
48    elif [ ${filename} != ${chaineU} ]; then
49        mask='umask' ; depth='depthu'
50    elif [ ${filename} != ${chaineV} ]; then
51        mask='vmask' ; depth='depthv'
52    elif [ ${filename} != ${chaineW} ]; then
53        mask='tmask' ; depth='depthw'
54    elif [ ${filename} != ${chaineIce} ]; then
55        mask='tmask' ; depth='deptht'
56    elif [ ${filename} != ${chaineTrc} ]; then
57        mask='tmask' ; depth='deptht'
58    elif [ ${filename} != ${chaineDia} ]; then
59        mask='tmask' ; depth='deptht'
60    elif [ ${filename} != ${chaineBio} ]; then
61        mask='tmask' ; depth='deptht'
62    fi
63
64    #============================================
65    # Remove nav_lon, nav_lat file
66    IGCM_sys_ncks -Oh -x -v nav_lon,nav_lat ${filename} file1.nc
67
68    #============================================
69    # Extract mask variable
70    IGCM_sys_ncks -Oh -v ${mask} ${config_UserChoices_JobName}_mesh_mask.nc mask3D.nc
71
72    #============================================
73    # Rename deptht dimension
74    IGCM_sys_ncrename -Oh -d z,${depth} mask3D.nc
75
76    #============================================
77    # Remove single dimension t
78    IGCM_sys_ncwa -Oh -a t mask3D.nc mask3D.nc
79
80    #============================================
81    # Create mask2D
82    IGCM_sys_ncks -Oh -d ${depth},0,0 mask3D.nc mask2D.nc
83    IGCM_sys_ncwa -Oh -a ${depth} mask2D.nc mask2D.nc
84    IGCM_sys_ncrename -h -v ${mask},mask2D mask2D.nc
85
86    #============================================
87    # Append mask (2D) to file1.nc
88    IGCM_sys_ncks -Ah -c -v mask2D mask2D.nc file1.nc
89
90    if [ ${filename} = ${chaineIce} ]; then
91
92        #============================================
93        # Append mask (3D) only for oceanic files
94        IGCM_sys_ncks -Ah -v ${mask} mask3D.nc file1.nc
95        IGCM_sys_ncrename -h -v ${mask},mask3D file1.nc
96
97        #============================================
98        # Add record dimension only for oceanic files
99        IGCM_sys_ncecat -Oh file1.nc file1.nc
100
101        #============================================
102        # Apply mask 3D only for oceanic files
103        IGCM_sys_ncwa -Oh -a record -B 'mask3D==1' file1.nc file2.nc
104        IGCM_sys_Rm file1.nc
105        IGCM_sys_Mv file2.nc file1.nc
106
107
108    fi
109
110    #============================================
111    # Add record dimension
112    IGCM_sys_ncecat -Oh file1.nc file1.nc
113
114    #============================================
115    # Apply mask 2D
116    IGCM_sys_ncwa -Oh -b -a record -B 'mask2D==1' file1.nc file1.nc
117
118    #============================================
119    # Permute record dimension in time_counter dimension
120    IGCM_sys_ncpdq -Oh -a time_counter,record file1.nc file1.nc
121    IGCM_sys_ncwa -Oh -a record file1.nc file1.nc
122
123    #============================================
124    # Remove mask 2D and 3D for oceanic files, and mask 2D only for ice files
125   
126    if [ ${filename} = ${chaineIce} ]; then
127        #============================================
128        # Remove mask 2D and mask 3D for oceanic files
129        IGCM_sys_ncks -Oh -x -v mask2D,mask3D file1.nc file_mask.nc
130    else
131        #============================================
132        # Remove mask 2D for ice files
133        IGCM_sys_ncks -Oh -x -v mask2D file1.nc file_mask.nc
134    fi
135
136    #============================================
137    # Add nav_lon nav_lat
138    IGCM_sys_ncks -Ah -v nav_lon,nav_lat ${filename} file_mask.nc
139
140    #============================================
141    # Cleaning
142    IGCM_debug_Verif_Exit_Post
143    IGCM_sys_Mv file_mask.nc ${filename}
144    IGCM_sys_Rm mask3D.nc mask2D.nc file1.nc
145   
146    IGCM_debug_PopStack "IGCM_Patch_mask"
147}
Note: See TracBrowser for help on using the repository browser.