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