source: trunk/libIGCM/libIGCM_post/IGCM_Patch_20091118_mask.ksh @ 271

Last change on this file since 271 was 257, checked in by sdipsl, 14 years ago
  • Add mercure-new : libIGCM_sys_mercure.ksh
  • SX9 use mercure-new for post-processing
  • Few feature missing on mercure-new dmget not yet install for example
  • Properly reset all svn:keywords feature
  • Bugfix in libIGCM_post.ksh when RebuildFromArchive? was false
  • Bugfix in IGCM_Patch_20090317_histcomFillvalue.ksh when renaming _Fillvalue we now just add missing_value to be retro-compatible
  • Some more comments
  • Property svn:executable set to *
  • Property svn:keywords set to Date Author Revision
File size: 4.0 KB
RevLine 
[201]1#!/bin/ksh
2
[257]3#**************************************************************
4# Author: Arnaud Caubel
5# Contact: Arnaud.Caubel_lsce.ipsl.fr
6# $Date$
7# $Author$
8# $Revision$
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
22    [ -f ${config_UserChoices_JobName}_mesh_mask.nc ] || IGCM_sys_Get ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc .
23
24    filename=${1}
25
26    chaineT=${filename%%'grid_T'*}
27    chaineU=${filename%%'grid_U'*}
28    chaineV=${filename%%'grid_V'*}
29    chaineW=${filename%%'grid_W'*}
30    chaineIce=${filename%%'icemod'*}
[242]31    chaineTrc=${filename%%'ptrc_T'*}
32    chaineDia=${filename%%'diad_T'*}
[201]33
34    if [ ${filename} != ${chaineT} ]; then
35        mask='tmask' ; depth='deptht'
36    elif [ ${filename} != ${chaineU} ]; then
37        mask='umask' ; depth='depthu'
38    elif [ ${filename} != ${chaineV} ]; then
39        mask='vmask' ; depth='depthv'
40    elif [ ${filename} != ${chaineW} ]; then
41        mask='tmask' ; depth='depthw'
42    elif [ ${filename} != ${chaineIce} ]; then
43        mask='tmask' ; depth='deptht'
[242]44    elif [ ${filename} != ${chaineTrc} ]; then
45        mask='tmask' ; depth='deptht'
46    elif [ ${filename} != ${chaineDia} ]; then
47        mask='tmask' ; depth='deptht'
[201]48    fi
49
[257]50    #============================================
51    # Remove nav_lon, nav_lat file
[201]52    IGCM_sys_ncks -Oh -x -v nav_lon,nav_lat ${filename} file1.nc
53
[257]54    #============================================
55    # Extract mask variable
[201]56    IGCM_sys_ncks -Oh -v ${mask} ${config_UserChoices_JobName}_mesh_mask.nc mask3D.nc
57
[257]58    #============================================
59    # Rename deptht dimension
[201]60    IGCM_sys_ncrename -Oh -d z,${depth} mask3D.nc
61
[257]62    #============================================
63    # Remove single dimension t
[201]64    IGCM_sys_ncwa -Oh -a t mask3D.nc mask3D.nc
65
[257]66    #============================================
67    # Create mask2D
[201]68    IGCM_sys_ncks -Oh -d ${depth},0,0 mask3D.nc mask2D.nc
69    IGCM_sys_ncwa -Oh -a ${depth} mask2D.nc mask2D.nc
[207]70    IGCM_sys_ncrename -h -v ${mask},mask2D mask2D.nc
[201]71
[257]72    #============================================
73    # Append mask (2D) to file1.nc
[201]74    IGCM_sys_ncks -Ah -c -v mask2D mask2D.nc file1.nc
75
76    if [ ${filename} = ${chaineIce} ]; then
77
[257]78        #============================================
79        # Append mask (3D) only for oceanic files
[201]80        IGCM_sys_ncks -Ah -v ${mask} mask3D.nc file1.nc
[207]81        IGCM_sys_ncrename -h -v ${mask},mask3D file1.nc
[201]82
[257]83        #============================================
84        # Add record dimension only for oceanic files
[201]85        IGCM_sys_ncecat -Oh file1.nc file1.nc
86
[257]87        #============================================
88        # Apply mask 3D only for oceanic files
[201]89        IGCM_sys_ncwa -Oh -a record -B 'mask3D==1' file1.nc file1.nc
90
91    fi
92
[257]93    #============================================
94    # Add record dimension
[201]95    IGCM_sys_ncecat -Oh file1.nc file1.nc
96
[257]97    #============================================
98    # Apply mask 2D
[207]99    IGCM_sys_ncwa -Oh -b -a record -B 'mask2D==1' file1.nc file1.nc
[201]100
[257]101    #============================================
102    # Permute record dimension in time_counter dimension
[207]103    IGCM_sys_ncpdq -Oh -a time_counter,record file1.nc file1.nc
104    IGCM_sys_ncwa -Oh -a record file1.nc file1.nc
105
[257]106    #============================================
107    # Remove mask
[201]108    IGCM_sys_ncks -Oh -x -v mask2D,mask3D file1.nc file_mask.nc
109
[257]110    #============================================
111    # Add nav_lon nav_lat
[201]112    IGCM_sys_ncks -Ah -v nav_lon,nav_lat ${filename} file_mask.nc
113
[257]114    #============================================
115    # Cleaning
[201]116    IGCM_debug_Verif_Exit_Post
117    IGCM_sys_Mv file_mask.nc ${filename}
118    IGCM_sys_Rm mask3D.nc mask2D.nc file1.nc
119   
120    IGCM_debug_PopStack "IGCM_Patch_mask"
121}
Note: See TracBrowser for help on using the repository browser.