source: tags/libIGCM_v2.0_beta4/libIGCM_post/IGCM_Patch_20091118_mask.ksh

Last change on this file was 590, checked in by sdipsl, 12 years ago
  • can extract needed restart from a tar (up to 20 minutes on titane)
    • still to do : introduce a lag when cleaning the restart buffer so that we don't look into the tar too often
    • still to do : work on the clean_month procedure
  • rebuild process submit pack_output process if needed
    • still to do : a pack_output able to submit create_ts/create_se if needed
  • bugfixes/cosmetics/cleaning
  • SX9 and titane OK.
  • Property svn:executable set to *
  • Property svn:keywords set to Revision Author Date
File size: 4.8 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    if [ ! -f ${config_UserChoices_JobName}_mesh_mask.nc ] ; then
23      if [ -f ${R_BUFR}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc ] ; then
24        IGCM_sys_GetBuffer ${R_BUFR}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc .
25      elif [ -f ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc ] ; then
26        IGCM_sys_Get ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc .
27      else
28        IGCM_debug_Exit "mesh_mask can not be found. Stop."
29        IGCM_debug_Exit "neither here ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc"
30        IGCM_debug_Exit "nor here ${R_BUFR}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc"
31        IGCM_debug_Verif_Exit_Post
32      fi
33    fi
34
35    filename=${1}
36
37    chaineT=${filename%%'grid_T'*}
38    chaineU=${filename%%'grid_U'*}
39    chaineV=${filename%%'grid_V'*}
40    chaineW=${filename%%'grid_W'*}
41    chaineIce=${filename%%'icemod'*}
42    chaineTrc=${filename%%'ptrc_T'*}
43    chaineDia=${filename%%'diad_T'*}
44
45    if [ ${filename} != ${chaineT} ]; then
46        mask='tmask' ; depth='deptht'
47    elif [ ${filename} != ${chaineU} ]; then
48        mask='umask' ; depth='depthu'
49    elif [ ${filename} != ${chaineV} ]; then
50        mask='vmask' ; depth='depthv'
51    elif [ ${filename} != ${chaineW} ]; then
52        mask='tmask' ; depth='depthw'
53    elif [ ${filename} != ${chaineIce} ]; then
54        mask='tmask' ; depth='deptht'
55    elif [ ${filename} != ${chaineTrc} ]; then
56        mask='tmask' ; depth='deptht'
57    elif [ ${filename} != ${chaineDia} ]; then
58        mask='tmask' ; depth='deptht'
59    fi
60
61    #============================================
62    # Remove nav_lon, nav_lat file
63    IGCM_sys_ncks -Oh -x -v nav_lon,nav_lat ${filename} file1.nc
64
65    #============================================
66    # Extract mask variable
67    IGCM_sys_ncks -Oh -v ${mask} ${config_UserChoices_JobName}_mesh_mask.nc mask3D.nc
68
69    #============================================
70    # Rename deptht dimension
71    IGCM_sys_ncrename -Oh -d z,${depth} mask3D.nc
72
73    #============================================
74    # Remove single dimension t
75    IGCM_sys_ncwa -Oh -a t mask3D.nc mask3D.nc
76
77    #============================================
78    # Create mask2D
79    IGCM_sys_ncks -Oh -d ${depth},0,0 mask3D.nc mask2D.nc
80    IGCM_sys_ncwa -Oh -a ${depth} mask2D.nc mask2D.nc
81    IGCM_sys_ncrename -h -v ${mask},mask2D mask2D.nc
82
83    #============================================
84    # Append mask (2D) to file1.nc
85    IGCM_sys_ncks -Ah -c -v mask2D mask2D.nc file1.nc
86
87    if [ ${filename} = ${chaineIce} ]; then
88
89        #============================================
90        # Append mask (3D) only for oceanic files
91        IGCM_sys_ncks -Ah -v ${mask} mask3D.nc file1.nc
92        IGCM_sys_ncrename -h -v ${mask},mask3D file1.nc
93
94        #============================================
95        # Add record dimension only for oceanic files
96        IGCM_sys_ncecat -Oh file1.nc file1.nc
97
98        #============================================
99        # Apply mask 3D only for oceanic files
100        IGCM_sys_ncwa -Oh -a record -B 'mask3D==1' file1.nc file2.nc
101        IGCM_sys_Rm file1.nc
102        IGCM_sys_Mv file2.nc file1.nc
103
104
105    fi
106
107    #============================================
108    # Add record dimension
109    IGCM_sys_ncecat -Oh file1.nc file1.nc
110
111    #============================================
112    # Apply mask 2D
113    IGCM_sys_ncwa -Oh -b -a record -B 'mask2D==1' file1.nc file1.nc
114
115    #============================================
116    # Permute record dimension in time_counter dimension
117    IGCM_sys_ncpdq -Oh -a time_counter,record file1.nc file1.nc
118    IGCM_sys_ncwa -Oh -a record file1.nc file1.nc
119
120    #============================================
121    # Remove mask
122    IGCM_sys_ncks -Oh -x -v mask2D,mask3D file1.nc file_mask.nc
123
124    #============================================
125    # Add nav_lon nav_lat
126    IGCM_sys_ncks -Ah -v nav_lon,nav_lat ${filename} file_mask.nc
127
128    #============================================
129    # Cleaning
130    IGCM_debug_Verif_Exit_Post
131    IGCM_sys_Mv file_mask.nc ${filename}
132    IGCM_sys_Rm mask3D.nc mask2D.nc file1.nc
133   
134    IGCM_debug_PopStack "IGCM_Patch_mask"
135}
Note: See TracBrowser for help on using the repository browser.