source: TOOLS/CPLRESTART/CreateRestartOce4Oasis.bash @ 3707

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

O.M./ creates repository for creating initial state for OASIS

  • 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###
19### Documentation : https://forge.ipsl.jussieu.fr/igcmg/wiki/IPSLCM6/MOSAIX
20###
21## SVN information
22#  $Author$
23#  $Date$
24#  $Revision$
25#  $Id$
26#  $HeadURL$
27
28# Usage exemples :
29# 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
30## ===========================================================================
31##
32## You should not change anything below this line ....
33##
34## ===========================================================================
35
36##
37## Command line parameters
38## ===========================================================================
39# Default values
40Comment="Preliminary attempt - Do not trust !"
41IceVar=ice_pres # siconc #> Variable containing sea ice fraction [0-1]
42
43#
44# Defines computer
45# ================
46if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi
47if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi
48
49case ${arch} in
50    ( curie | irene )
51    set +vx
52    module unload cdo nco ferret
53    module unload netcdf hdf5
54    module load python # /2.7.12
55    module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS
56    module load nco
57    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
58    TMPDIR=${SCRATCHDIR}/TMP
59    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}}
60    ;;
61    ( * )
62    exit -1
63    ;;
64esac
65set -o verbose
66set -o xtrace
67set -e
68
69while [[ ${1} = -* ]] ; do
70    case ${1} in
71        ( -- ) shift ; break ;;
72        ( -c   | --comment  ) shift ; Comment=${1} ;;
73        ( -i   | --ice      ) shift ; IceVar=${1}  ;;
74        ( -a   | --alb      ) shift ; AlbVar=${1}  ;;
75        ( -v | --verbose    ) set -o verbose   ;;
76        ( -x | --xtrace     ) set -o xtrace    ;;
77        ( -xv | -vx         ) set -o xtrace verbose  ;;
78        ( -e                ) set -e           ;;
79        ( -V | --noverbose  ) set +o verbose   ;;
80        ( -X | --noxtrace   ) set +o xtrace    ;;
81        ( -XV | -VX         ) set +o xtrace verbose    ;;
82        ( -E                ) set +e           ;;
83        ( -* ) echo ${Bold}"Unknown option : ${1}"${Norm} ; return 1 ;;
84    esac
85    shift
86done
87
88OceFile=${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}
89
90#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}
91#
92
93#
94# Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits
95# ---------------------------------------------------------------------------
96FL_FMT=64bit
97
98##
99## Defines associated sea ice file
100## ===========================================================================
101IceFile=$(echo ${OceFile} | sed 's=/OCE/=/ICE/=' | sed 's=grid_T=icemod=')
102
103##
104## Extract variables
105## ===========================================================================
106ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable ${IceVar} ${IceFile} sstoce_fields.nc
107ncks --overwrite --fl_fmt=${FL_FMT} --history -d time_counter,0,0 --variable tos       ${OceFile} oce_fields.nc
108ncks --append --fl_fmt=${FL_FMT} --history oce_fields.nc   sstoce_fields.nc
109ncwa --overwrite --fl_fmt=${FL_FMT} --history --average time_counter sstoce_fields.nc sstoce_fields_notime.nc # Remove time dimension
110ncatted --history --attribute history,global,d,c,""  sstoce_fields_notime.nc           # Clean attributes
111
112##
113## Find ocean name
114## ===========================================================================
115dim_y=$(ncdump -h sstoce_fields_notime.nc | grep "y *=" | awk '{print $3}' )
116dim_x=$(ncdump -h sstoce_fields_notime.nc | grep "x *=" | awk '{print $3}' )
117echo ${dim_x} ${dim_y}
118
119[[ ${dim_x} = 182 && ${dim_y} = 149 ]] && OCE=ORCA2.3
120[[ ${dim_x} = 362 && ${dim_y} = 332 ]] && OCE=eORCA2.1
121
122
123##
124## Creates sstoce file
125## ===========================================================================
126
127cat <<EOF > create_sstoce.nco
128OIceFrc        = double ( ${IceVar}(:,:) ) ;
129//tos.simple_fill_miss(tos)               ;
130O_SSTSST[y,x]  = double ( (tos   (:,:) + 273.15d) * (1.0d-OIceFrc) ) ;
131//O_AlbIce[y,x]  = double ( ialb   (:,:)            * OIceFrc(:,:)   ) ;
132//O_TepIce[y,x]  = double ( (tsice (:,:) + 273.15d) * OIceFrc(:,:)   ) ;
133O_AlbIce[y,x]  = double (   0.65d            * OIceFrc(:,:)   ) ;
134O_TepIce[y,x]  = double ( (-20.0d + 273.15d) * OIceFrc(:,:)   ) ;
135O_OCurx1[y,x]  = 0.0d ;
136O_OCury1[y,x]  = 0.0d ;
137O_OCurz1[y,x]  = 0.0d ;
138EOF
139
140ncap2 --overwrite --fl_fmt=${FL_FMT} --history --script-file create_sstoce.nco sstoce_fields_notime.nc tmp_sstoc.nc
141
142ncks --fl_fmt=${FL_FMT} --overwrite --history --variable OIceFrc,O_SSTSST,O_AlbIce,O_TepIce,O_OCurx1,O_OCury1,O_OCurz1 tmp_sstoc.nc sstoc.nc
143
144ncatted --history --attribute comment,O_SSTSST,o,c,"SST weighted by fraction of open ocean"          sstoc.nc
145ncatted --history --attribute comment,O_SSTSST,o,c,"Albedo weighted by fraction of sea ice"          sstoc.nc
146ncatted --history --attribute comment,O_SSTSST,o,c,"Ice temperature weighted by fraction of sea ice" sstoc.nc
147
148##
149## Add some information in file headers
150## ===========================================================================
151
152UUID=$(uuid)
153NCO="$(ncks --version |& tail -1|sed 's/ncks //')"
154ncatted --history \
155        --attribute nco_openmp_thread_number,global,d,,                       \
156        --attribute source,global,o,c,"IPSL Earth system model"               \
157        --attribute group,global,o,c,"ICMC IPSL Climate Modelling Center"     \
158        --attribute Institution,global,o,c,"IPSL https://www.ipsl.fr"         \
159        --attribute Model,global,o,c,"${OCE} https://www.nemo-ocean.eu"       \
160        --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}')" \
161        --attribute originalFiles,global,o,c,"${OceFile} ${IceFile}"          \
162        --attribute directory,global,o,c,"$(pwd)"                             \
163        --attribute description,global,o,c,"Fields needed by OASIS-MCT"       \
164        --attribute timeStamp,global,o,c,"$(date)"                            \
165        --attribute uuid,global,o,c,"${UUID}"                                 \
166        --attribute Program,global,o,c,"Generated by ${0}"                    \
167        --attribute HOSTNAME,global,o,c,"$(hostname)"                         \
168        --attribute LOGNAME,global,o,c,"$(whoami)"                            \
169        --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \
170        --attribute OS,global,o,c,"$(uname -o)"                               \
171        --attribute release,global,o,c,"$(uname -r)"                          \
172        --attribute hardware,global,o,c,"$(uname -i)"                         \
173        --attribute directory,global,o,c,"$(pwd)"                             \
174        --attribute Comment,global,o,c,"${Comment}"                           \
175        --attribute SVN_Author,global,o,c,"$Author$"                 \
176        --attribute SVN_Date,global,o,c,"$Date$" \
177        --attribute SVN_Revision,global,o,c,"$Revision$"               \
178        --attribute SVN_Id,global,o,c,"$Id$" \
179        sstoc.nc
180
181##
182## Cleaning
183## ===========================================================================
184rm -f sstoce_fields.nc sstoce_fields_notime.nc tmp_flxat.nc oce_fields.nc
185
186mv sstoc.nc sstoc_${OCE}.nc
187
188## ===========================================================================
189##
190##                               That's all folk's !!!
191##
192## ===========================================================================
Note: See TracBrowser for help on using the repository browser.