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 | |
---|
18 | function 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 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 |
---|
26 | IGCM_sys_GetBuffer ${R_BUFR}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc . |
---|
27 | elif [ -f ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc ] ; then |
---|
28 | IGCM_sys_Get ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc . |
---|
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" |
---|
33 | IGCM_debug_Verif_Exit_Post |
---|
34 | fi |
---|
35 | fi |
---|
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'*} |
---|
44 | chaineTrc=${filename%%'ptrc_T'*} |
---|
45 | chaineDia=${filename%%'diad_T'*} |
---|
46 | chaineBio=${filename%%'dbio_T'*} |
---|
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' |
---|
58 | elif [ ${filename} != ${chaineTrc} ]; then |
---|
59 | mask='tmask' ; depth='deptht' |
---|
60 | elif [ ${filename} != ${chaineDia} ]; then |
---|
61 | mask='tmask' ; depth='deptht' |
---|
62 | elif [ ${filename} != ${chaineBio} ]; then |
---|
63 | mask='tmask' ; depth='deptht' |
---|
64 | fi |
---|
65 | |
---|
66 | #============================================ |
---|
67 | # Remove nav_lon, nav_lat file |
---|
68 | IGCM_sys_ncks -Oh -x -v nav_lon,nav_lat ${filename} file1.nc |
---|
69 | |
---|
70 | #============================================ |
---|
71 | # Extract mask variable |
---|
72 | IGCM_sys_ncks -Oh -v ${mask} ${config_UserChoices_JobName}_mesh_mask.nc mask3D.nc |
---|
73 | |
---|
74 | #============================================ |
---|
75 | # Rename deptht dimension |
---|
76 | IGCM_sys_ncrename -Oh -d z,${depth} mask3D.nc |
---|
77 | |
---|
78 | #============================================ |
---|
79 | # Remove single dimension t |
---|
80 | IGCM_sys_ncwa -Oh -a t mask3D.nc mask3D.nc |
---|
81 | |
---|
82 | #============================================ |
---|
83 | # Create mask2D |
---|
84 | IGCM_sys_ncks -Oh -d ${depth},0,0 mask3D.nc mask2D.nc |
---|
85 | IGCM_sys_ncwa -Oh -a ${depth} mask2D.nc mask2D.nc |
---|
86 | IGCM_sys_ncrename -h -v ${mask},mask2D mask2D.nc |
---|
87 | |
---|
88 | #============================================ |
---|
89 | # Append mask (2D) to file1.nc |
---|
90 | IGCM_sys_ncks -Ah -c -v mask2D mask2D.nc file1.nc |
---|
91 | |
---|
92 | if [ ${filename} = ${chaineIce} ]; then |
---|
93 | |
---|
94 | #============================================ |
---|
95 | # Append mask (3D) only for oceanic files |
---|
96 | IGCM_sys_ncks -Ah -v ${mask} mask3D.nc file1.nc |
---|
97 | IGCM_sys_ncrename -h -v ${mask},mask3D file1.nc |
---|
98 | |
---|
99 | #============================================ |
---|
100 | # Add record dimension only for oceanic files |
---|
101 | IGCM_sys_ncecat -Oh file1.nc file1.nc |
---|
102 | |
---|
103 | #============================================ |
---|
104 | # Apply mask 3D only for oceanic files |
---|
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 |
---|
108 | |
---|
109 | |
---|
110 | fi |
---|
111 | |
---|
112 | #============================================ |
---|
113 | # Add record dimension |
---|
114 | IGCM_sys_ncecat -Oh file1.nc file1.nc |
---|
115 | |
---|
116 | #============================================ |
---|
117 | # Apply mask 2D |
---|
118 | IGCM_sys_ncwa -Oh -b -a record -B 'mask2D==1' file1.nc file1.nc |
---|
119 | |
---|
120 | #============================================ |
---|
121 | # Permute record dimension in time_counter dimension |
---|
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 | |
---|
125 | #============================================ |
---|
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 |
---|
137 | |
---|
138 | #============================================ |
---|
139 | # Add nav_lon nav_lat |
---|
140 | IGCM_sys_ncks -Ah -v nav_lon,nav_lat ${filename} file_mask.nc |
---|
141 | |
---|
142 | #============================================ |
---|
143 | # Cleaning |
---|
144 | IGCM_debug_Verif_Exit_Post |
---|
145 | IGCM_sys_Mv file_mask.nc ${filename} |
---|
146 | IGCM_sys_Rm mask3D.nc mask2D.nc file1.nc |
---|
147 | |
---|
148 | IGCM_debug_PopStack "IGCM_Patch_mask" |
---|
149 | } |
---|