source: branches/libIGCM_MPI_OpenMP/libIGCM_post/IGCM_Patch_20091118_mask.ksh @ 494

Last change on this file since 494 was 373, checked in by sdipsl, 14 years ago

Remove libIGCM_sys_claude.ksh and libIGCM_sys_calculo.ksh
Update/homogenize all headers usgin the new fixed-length keyword syntax regarding properties keywords
$Rev:: 13 i $: Revision of last commit
$Author:: harry $: Author of last commit
$Date:: 2006-03-15 02:33:03 -0500 (Wed, 15 Mar 2006) $: Date of last commit
Add / update original author and contact when missing

  • Property svn:executable set to *
  • Property svn:keywords set to Revision Author Date
File size: 4.2 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    [ -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'*}
31    chaineTrc=${filename%%'ptrc_T'*}
32    chaineDia=${filename%%'diad_T'*}
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'
44    elif [ ${filename} != ${chaineTrc} ]; then
45        mask='tmask' ; depth='deptht'
46    elif [ ${filename} != ${chaineDia} ]; then
47        mask='tmask' ; depth='deptht'
48    fi
49
50    #============================================
51    # Remove nav_lon, nav_lat file
52    IGCM_sys_ncks -Oh -x -v nav_lon,nav_lat ${filename} file1.nc
53
54    #============================================
55    # Extract mask variable
56    IGCM_sys_ncks -Oh -v ${mask} ${config_UserChoices_JobName}_mesh_mask.nc mask3D.nc
57
58    #============================================
59    # Rename deptht dimension
60    IGCM_sys_ncrename -Oh -d z,${depth} mask3D.nc
61
62    #============================================
63    # Remove single dimension t
64    IGCM_sys_ncwa -Oh -a t mask3D.nc mask3D.nc
65
66    #============================================
67    # Create mask2D
68    IGCM_sys_ncks -Oh -d ${depth},0,0 mask3D.nc mask2D.nc
69    IGCM_sys_ncwa -Oh -a ${depth} mask2D.nc mask2D.nc
70    IGCM_sys_ncrename -h -v ${mask},mask2D mask2D.nc
71
72    #============================================
73    # Append mask (2D) to file1.nc
74    IGCM_sys_ncks -Ah -c -v mask2D mask2D.nc file1.nc
75
76    if [ ${filename} = ${chaineIce} ]; then
77
78        #============================================
79        # Append mask (3D) only for oceanic files
80        IGCM_sys_ncks -Ah -v ${mask} mask3D.nc file1.nc
81        IGCM_sys_ncrename -h -v ${mask},mask3D file1.nc
82
83        #============================================
84        # Add record dimension only for oceanic files
85        IGCM_sys_ncecat -Oh file1.nc file1.nc
86
87        #============================================
88        # Apply mask 3D only for oceanic files
89        IGCM_sys_ncwa -Oh -a record -B 'mask3D==1' file1.nc file2.nc
90        IGCM_sys_Rm file1.nc
91        IGCM_sys_Mv file2.nc file1.nc
92
93
94    fi
95
96    #============================================
97    # Add record dimension
98    IGCM_sys_ncecat -Oh file1.nc file1.nc
99
100    #============================================
101    # Apply mask 2D
102    IGCM_sys_ncwa -Oh -b -a record -B 'mask2D==1' file1.nc file1.nc
103
104    #============================================
105    # Permute record dimension in time_counter dimension
106    IGCM_sys_ncpdq -Oh -a time_counter,record file1.nc file1.nc
107    IGCM_sys_ncwa -Oh -a record file1.nc file1.nc
108
109    #============================================
110    # Remove mask
111    IGCM_sys_ncks -Oh -x -v mask2D,mask3D file1.nc file_mask.nc
112
113    #============================================
114    # Add nav_lon nav_lat
115    IGCM_sys_ncks -Ah -v nav_lon,nav_lat ${filename} file_mask.nc
116
117    #============================================
118    # Cleaning
119    IGCM_debug_Verif_Exit_Post
120    IGCM_sys_Mv file_mask.nc ${filename}
121    IGCM_sys_Rm mask3D.nc mask2D.nc file1.nc
122   
123    IGCM_debug_PopStack "IGCM_Patch_mask"
124}
Note: See TracBrowser for help on using the repository browser.