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

Last change on this file since 592 was 592, checked in by mafoipsl, 12 years ago

Second merge of libIGCM_MPI_OpenMP branch with libIGCM trunk, revision 591.

  • Property svn:executable set to *
  • Property svn:keywords set to Revision Author Date
File size: 4.8 KB
RevLine 
[201]1#!/bin/ksh
2
[257]3#**************************************************************
4# Author: Arnaud Caubel
[373]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
[257]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
[592]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
[201]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'*}
[242]42    chaineTrc=${filename%%'ptrc_T'*}
43    chaineDia=${filename%%'diad_T'*}
[201]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'
[242]55    elif [ ${filename} != ${chaineTrc} ]; then
56        mask='tmask' ; depth='deptht'
57    elif [ ${filename} != ${chaineDia} ]; then
58        mask='tmask' ; depth='deptht'
[201]59    fi
60
[257]61    #============================================
62    # Remove nav_lon, nav_lat file
[201]63    IGCM_sys_ncks -Oh -x -v nav_lon,nav_lat ${filename} file1.nc
64
[257]65    #============================================
66    # Extract mask variable
[201]67    IGCM_sys_ncks -Oh -v ${mask} ${config_UserChoices_JobName}_mesh_mask.nc mask3D.nc
68
[257]69    #============================================
70    # Rename deptht dimension
[201]71    IGCM_sys_ncrename -Oh -d z,${depth} mask3D.nc
72
[257]73    #============================================
74    # Remove single dimension t
[201]75    IGCM_sys_ncwa -Oh -a t mask3D.nc mask3D.nc
76
[257]77    #============================================
78    # Create mask2D
[201]79    IGCM_sys_ncks -Oh -d ${depth},0,0 mask3D.nc mask2D.nc
80    IGCM_sys_ncwa -Oh -a ${depth} mask2D.nc mask2D.nc
[207]81    IGCM_sys_ncrename -h -v ${mask},mask2D mask2D.nc
[201]82
[257]83    #============================================
84    # Append mask (2D) to file1.nc
[201]85    IGCM_sys_ncks -Ah -c -v mask2D mask2D.nc file1.nc
86
87    if [ ${filename} = ${chaineIce} ]; then
88
[257]89        #============================================
90        # Append mask (3D) only for oceanic files
[201]91        IGCM_sys_ncks -Ah -v ${mask} mask3D.nc file1.nc
[207]92        IGCM_sys_ncrename -h -v ${mask},mask3D file1.nc
[201]93
[257]94        #============================================
95        # Add record dimension only for oceanic files
[201]96        IGCM_sys_ncecat -Oh file1.nc file1.nc
97
[257]98        #============================================
99        # Apply mask 3D only for oceanic files
[311]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
[201]103
[311]104
[201]105    fi
106
[257]107    #============================================
108    # Add record dimension
[201]109    IGCM_sys_ncecat -Oh file1.nc file1.nc
110
[257]111    #============================================
112    # Apply mask 2D
[207]113    IGCM_sys_ncwa -Oh -b -a record -B 'mask2D==1' file1.nc file1.nc
[201]114
[257]115    #============================================
116    # Permute record dimension in time_counter dimension
[207]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
[257]120    #============================================
121    # Remove mask
[201]122    IGCM_sys_ncks -Oh -x -v mask2D,mask3D file1.nc file_mask.nc
123
[257]124    #============================================
125    # Add nav_lon nav_lat
[201]126    IGCM_sys_ncks -Ah -v nav_lon,nav_lat ${filename} file_mask.nc
127
[257]128    #============================================
129    # Cleaning
[201]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.