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

Last change on this file since 201 was 201, checked in by aclsce, 15 years ago

Added patch to mask oceanic variables.
Modified libIGCM_post.ksh to use the variables
config_UserChoices_JobName and R_SAVE in IGCM_Patch_20091118_mask.

  • Property svn:executable set to *
File size: 3.1 KB
Line 
1#!/bin/ksh
2
3#------------------------------------------------------------
4# Add mask from meshmask file to oceanic variables
5#------------------------------------------------------------
6
7function IGCM_Patch_20091118_mask {
8
9    set -vx
10    IGCM_debug_PushStack "IGCM_Patch_mask" $@
11
12    [ -f ${config_UserChoices_JobName}_mesh_mask.nc ] || IGCM_sys_Get ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc .
13
14    filename=${1}
15
16    chaineT=${filename%%'grid_T'*}
17    chaineU=${filename%%'grid_U'*}
18    chaineV=${filename%%'grid_V'*}
19    chaineW=${filename%%'grid_W'*}
20    chaineIce=${filename%%'icemod'*}
21
22    if [ ${filename} != ${chaineT} ]; then
23        mask='tmask' ; depth='deptht'
24    elif [ ${filename} != ${chaineU} ]; then
25        mask='umask' ; depth='depthu'
26    elif [ ${filename} != ${chaineV} ]; then
27        mask='vmask' ; depth='depthv'
28    elif [ ${filename} != ${chaineW} ]; then
29        mask='tmask' ; depth='depthw'
30    elif [ ${filename} != ${chaineIce} ]; then
31        mask='tmask' ; depth='deptht'
32    fi
33
34#============================================
35# Remove nav_lon, nav_lat file
36    IGCM_sys_ncks -Oh -x -v nav_lon,nav_lat ${filename} file1.nc
37
38#============================================
39# Extract mask variable
40    IGCM_sys_ncks -Oh -v ${mask} ${config_UserChoices_JobName}_mesh_mask.nc mask3D.nc
41
42#============================================
43# Rename deptht dimension
44    IGCM_sys_ncrename -Oh -d z,${depth} mask3D.nc
45
46#============================================
47# Remove single dimension t
48    IGCM_sys_ncwa -Oh -a t mask3D.nc mask3D.nc
49
50#============================================
51# Create mask2D
52    IGCM_sys_ncks -Oh -d ${depth},0,0 mask3D.nc mask2D.nc
53    IGCM_sys_ncwa -Oh -a ${depth} mask2D.nc mask2D.nc
54    IGCM_sys_ncrename -v ${mask},mask2D mask2D.nc
55
56#============================================
57# Append mask (2D) to file1.nc
58    IGCM_sys_ncks -Ah -c -v mask2D mask2D.nc file1.nc
59
60    if [ ${filename} = ${chaineIce} ]; then
61
62#============================================
63# Append mask (3D) only for oceanic files
64        IGCM_sys_ncks -Ah -v ${mask} mask3D.nc file1.nc
65        IGCM_sys_ncrename -v ${mask},mask3D file1.nc
66
67#============================================
68# Add record dimension only for oceanic files
69        IGCM_sys_ncecat -Oh file1.nc file1.nc
70
71#============================================
72# Apply mask 3D only for oceanic files
73        IGCM_sys_ncwa -Oh -a record -B 'mask3D==1' file1.nc file1.nc
74
75    fi
76
77#============================================
78# Add record dimension
79    IGCM_sys_ncecat -Oh file1.nc file1.nc
80
81#============================================
82# Apply mask 2D
83    IGCM_sys_ncwa -Oh -a record -B 'mask2D==1' file1.nc file1.nc
84
85#============================================
86# Remove mask
87    IGCM_sys_ncks -Oh -x -v mask2D,mask3D file1.nc file_mask.nc
88
89#============================================
90# Add nav_lon nav_lat
91    IGCM_sys_ncks -Ah -v nav_lon,nav_lat ${filename} file_mask.nc
92
93#============================================
94# Cleaning
95    IGCM_debug_Verif_Exit_Post
96    IGCM_sys_Mv file_mask.nc ${filename}
97    IGCM_sys_Rm mask3D.nc mask2D.nc file1.nc
98   
99    IGCM_debug_PopStack "IGCM_Patch_mask"
100}
Note: See TracBrowser for help on using the repository browser.