source: TOOLS/MOSAIX/CreateRestartOce4Oasis.bash @ 3623

Last change on this file since 3623 was 3623, checked in by omamce, 6 years ago

O.M.: add SVN properties

  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision HeadURL Author Id
File size: 8.2 KB
Line 
1#!/bin/bash
2### ===========================================================================
3###
4### Creates initial state for coupler, ocean side
5### Take data from NEMO grid_T and icemod files
6###
7### ===========================================================================
8##
9##  Warning, to install, configure, run, use any of Olivier Marti's
10##  software or to read the associated documentation you'll need at least
11##  one (1) brain in a reasonably working order. Lack of this implement
12##  will void any warranties (either express or implied).
13##  O. Marti assumes no responsability for errors, omissions,
14##  data loss, or any other consequences caused directly or indirectly by
15##  the usage of his software by incorrectly or partially configured
16##  personal.
17##
18## SVN information
19#  $Author$
20#  $Date$
21#  $Revision$
22#  $Id$
23#  $Log: $
24
25# Usage exemples :
26# CreateRestartOce4Oasis.bash /ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/OCE/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_grid_T.nc/ccc/store/c# CreateRestartOce4Oasis.bash /ccc/store/cont003/gencmip6/p86mart/IGCM_OUT/IPSLCM6/DEVT/pdControl/CM6010.2.rivgeo-LR-pdCtrl/OCE/Output/MO/CM6010.2.rivgeo-LR-pdCtrl_22400101_22491231_1M_grid_T.nc
27## ===========================================================================
28##
29## You should not change anything below this line ....
30##
31## ===========================================================================
32
33##
34## Command line parameters
35## ===========================================================================
36# Default values
37Comment="Preliminary attempt - Do not trust !"
38IceVar=ice_pres # siconc #> Variable containing sea ice fraction [0-1]
39
40#
41# Defines computer
42# ================
43if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi
44if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi
45
46case ${arch} in
47    ( curie | irene )
48    set +vx
49    module unload cdo nco ferret
50    module unload netcdf hdf5
51    module load python # /2.7.12
52    module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS
53    module load nco
54    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
55    TMPDIR=${SCRATCHDIR}/TMP
56    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}}
57    ;;
58    ( * )
59    exit -1
60    ;;
61esac
62set -o verbose
63set -o xtrace
64set -e
65
66while [[ ${1} = -* ]] ; do
67    case ${1} in
68        ( -- ) shift ; break ;;
69        ( -c   | --comment  ) shift ; Comment=${1} ;;
70        ( -i   | --ice      ) shift ; IceVar=${1}  ;;
71        ( -a   | --alb      ) shift ; AlbVar=${1}  ;;
72        ( -v | --verbose    ) set -o verbose   ;;
73        ( -x | --xtrace     ) set -o xtrace    ;;
74        ( -xv | -vx         ) set -o xtrace verbose  ;;
75        ( -e                ) set -e           ;;
76        ( -V | --noverbose  ) set +o verbose   ;;
77        ( -X | --noxtrace   ) set +o xtrace    ;;
78        ( -XV | -VX         ) set +o xtrace verbose    ;;
79        ( -E                ) set +e           ;;
80        ( -* ) echo ${Bold}"Unknown option : ${1}"${Norm} ; return 1 ;;
81    esac
82    shift
83done
84
85OceFile=${1:-/ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/OCE/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_grid_T.nc}
86
87#OceFile=${1:-/ccc/store/cont003/gencmip6/p86mart/IGCM_OUT/IPSLCM6/DEVT/pdControl/CM6010.2.rivgeo-LR-pdCtrl/OCE/Output/MO/CM6010.2.rivgeo-LR-pdCtrl_22400101_22491231_1M_grid_T.nc}
88#
89
90#
91# Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits
92# ---------------------------------------------------------------------------
93FL_FMT=64bit
94
95##
96## Defines associated sea ice file
97## ===========================================================================
98IceFile=$(echo ${OceFile} | sed 's=/OCE/=/ICE/=' | sed 's=grid_T=icemod=')
99
100##
101## Extract variables
102## ===========================================================================
103ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 -v ${IceVar} ${IceFile} sstoce_fields.nc
104ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 -v tos       ${OceFile} oce_fields.nc
105ncks --append --fl_fmt=${FL_FMT} --history oce_fields.nc   sstoce_fields.nc
106ncwa --overwrite --fl_fmt=${FL_FMT} --history -a time_counter sstoce_fields.nc sstoce_fields_notime.nc # Remove time dimension
107ncatted --history --attribute history,global,d,c,""  sstoce_fields_notime.nc           # Clean attributes
108
109##
110## Find ocean name
111## ===========================================================================
112dim_y=$(ncdump -h sstoce_fields_notime.nc | grep "y *=" | awk '{print $3}' )
113dim_x=$(ncdump -h sstoce_fields_notime.nc | grep "x *=" | awk '{print $3}' )
114echo ${dim_x} ${dim_y}
115
116[[ ${dim_x} = 182 && ${dim_y} = 149 ]] && OCE=ORCA2.3
117[[ ${dim_x} = 362 && ${dim_y} = 332 ]] && OCE=eORCA2.1
118
119
120##
121## Creates sstoce file
122## ===========================================================================
123
124cat <<EOF > create_sstoce.nco
125OIceFrac       = double ( ${IceVar}(:,:) ) ;
126//tos.simple_fill_miss(tos)               ;
127O_SSTSST[y,x]  = double ( (tos   (:,:) + 273.15d) * (1.0d-OIceFrac) ) ;
128//O_AlbIce[y,x]  = double ( ialb   (:,:)            * OIceFrac(:,:)   ) ;
129//O_TepIce[y,x]  = double ( (tsice (:,:) + 273.15d) * OIceFrac(:,:)   ) ;
130O_AlbIce[y,x]  = double (   0.65d            * OIceFrac(:,:)   ) ;
131O_TepIce[y,x]  = double ( (-20.0d + 273.15d) * OIceFrac(:,:)   ) ;
132O_OCurx1[y,x]  = 0.0d ;
133O_OCury1[y,x]  = 0.0d ;
134O_OCurz1[y,x]  = 0.0d ;
135EOF
136
137ncap2 --overwrite --fl_fmt=${FL_FMT} --history -S create_sstoce.nco sstoce_fields_notime.nc tmp_sstoc.nc
138
139ncks --fl_fmt=${FL_FMT} --overwrite --history -v OIceFrac,O_SSTSST,O_AlbIce,O_TepIce,O_OCurx1,O_OCury1,O_OCurz1 tmp_sstoc.nc sstoc.nc
140
141ncatted --history --attribute comment,O_SSTSST,o,c,"SST weighted by fraction of open ocean"          sstoc.nc
142ncatted --history --attribute comment,O_SSTSST,o,c,"Albedo weighted by fraction of sea ice"          sstoc.nc
143ncatted --history --attribute comment,O_SSTSST,o,c,"Ice temperature weighted by fraction of sea ice" sstoc.nc
144
145##
146## Add some information in file headers
147## ===========================================================================
148
149UUID=$(uuid)
150NCO="$(ncks --version |& tail -1|sed 's/ncks //')"
151ncatted --history \
152        --attribute nco_openmp_thread_number,global,d,,                       \
153        --attribute source,global,o,c,"IPSL Earth system model"               \
154        --attribute group,global,o,c,"ICMC IPSL Climate Modelling Center"     \
155        --attribute Institution,global,o,c,"IPSL https://www.ipsl.fr"         \
156        --attribute Model,global,o,c,"${OCE} https://www.nemo-ocean.eu"       \
157        --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}')" \
158        --attribute originalFiles,global,o,c,"${OceFile} ${IceFile}"          \
159        --attribute directory,global,o,c,"$(pwd)"                             \
160        --attribute description,global,o,c,"Fields needed by OASIS-MCT"       \
161        --attribute timeStamp,global,o,c,"$(date)"                            \
162        --attribute uuid,global,o,c,"${UUID}"                                 \
163        --attribute Program,global,o,c,"Generated by ${0}"                    \
164        --attribute HOSTNAME,global,o,c,"$(hostname)"                         \
165        --attribute LOGNAME,global,o,c,"$(whoami)"                            \
166        --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \
167        --attribute OS,global,o,c,"$(uname -o)"                               \
168        --attribute release,global,o,c,"$(uname -r)"                          \
169        --attribute hardware,global,o,c,"$(uname -i)"                         \
170        --attribute directory,global,o,c,"$(pwd)"                             \
171        --attribute Comment,global,o,c,"${Comment}"                           \
172        --attribute     SVN_Author,global,o,c,"$Author"                       \
173        --attribute SVN_Date,global,o,c,"$Date$"                            \
174        --attribute SVN_Revision,global,o,c,"$Revision$"                    \
175        --attribute SVN_Id,global,o,c,"$Id$"                                \
176        --attribute SVN_Lo,global,o,c,"$Log: $"                               \
177        sstoc.nc
178
179##
180## Cleaning
181## ===========================================================================
182rm -f sstoce_fields.nc sstoce_fields_notime.nc tmp_flxat.nc oce_fields.nc
183
184mv sstoc.nc sstoc_${OCE}.nc
185
186## ===========================================================================
187##
188##                               That's all folk's !!!
189##
190## ===========================================================================
Note: See TracBrowser for help on using the repository browser.