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