source: TOOLS/CPLRESTART/CreateRestartAtm4Oasis.bash @ 6446

Last change on this file since 6446 was 6366, checked in by omamce, 14 months ago

O.M.

CPLRESTART

Remove most nco commands : all is handled by the python script
Adapt to be more tolerant when inout variables are missing

  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision HeadURL Author Id
File size: 6.9 KB
Line 
1#!/usr/bin/env bash
2### ===========================================================================
3###
4### Creates initial state for coupler, atmosphere side
5### Takes state from atmospheric hist file
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# CreateRestartAtm4Oasis.bash --oce ORCA2.3    /ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/ATM/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_histmth.nc
30# CreateRestartAtm4Oasis.bash --oce eORCA1.2   /ccc/store/cont003/gencmip6/p86maf/IGCM_OUT/IPSLCM6/PROD/piControl/CM61-LR-pi-03/ATM/Output/MO/CM61-LR-pi-03_23400101_23491231_1M_histmth.nc
31# CreateRestartAtm4Oasis.bash --oce ORCA2.3    /ccc/work/cont003/gencmip6/bedidil/SAVE8_ORCA2/STORE1/dynamico_grid.nc
32# CreateRestartAtm4Oasis.bash --oce ORCA2.3    /ccc/work/cont003/gencmip6/bedidil/SAVE9_ORCA2_DYN30_1MO/STORE1/histmth.nc
33# CreateRestartAtm4Oasis.bash --oce eORCA1.4.2 /ccc/scratch/cont003/gencmip6/p86caub/RUN_DIR/9114048_89294/ICOLOR-SROUT.11.NBP80.HISTMTH.89294/histday.nc
34
35## ===========================================================================
36##
37## You should not change anything below this line ....
38##
39## ===========================================================================
40
41##
42## Command line parameters
43## ===========================================================================
44# Default values
45Comment="Preliminary attempt - Do not trust !"
46OCE="Unknown"
47
48#
49# Defines computer
50# ================
51if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi
52if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi
53if [[ $(hostname) = lsce*  ]] ; then arch=spip  ; center=spip ; fi
54
55case ${arch} in
56    ( irene )
57    set +e
58    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM
59    TMPDIR=${CCCSCRATCHDIR}/TMP/CPLRESTART
60    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR:-$(pwd)}}
61    MpiRun="time ccc_mprun"
62    PyRun="time ccc_mprun -n 1" # Needed to force python to run on one process only
63    module purge
64    module load hdf5
65    module load netcdf-c
66    module load nco # /4.9.1
67    module load cdo # /1.9.5
68    module load python3 # /3.7.2
69    module load datadir/igcmg
70    module list
71    set -e
72    ;;
73    ( spip )
74    R_IN=${HOME}/Scratch/IGCM
75    TMPDIR=${HOME}/Scratch/TMP
76    SUBMIT_DIR=$(pwd)
77    MpiRun="/opt/local/bin/mpirun -n 1"
78    PyRun="time"
79    ;;
80    ( * )
81    exit -1
82    ;;
83esac
84set -o verbose
85set -o xtrace
86set -e
87
88mkdir -p ${TMPDIR} 
89
90cd ${TMPDIR}
91
92while [[ ${1} = -* ]] ; do
93    case ${1} in
94        ( -- ) shift ; break ;;
95        ( -o   | --oce      ) shift ; OCE=${1}     ;; # Just needed to add information in the file and file name
96        ( -c   | --comment  ) shift ; Comment=${1} ;; # Just needed to add information in the file
97        ( -v | --verbose    ) set -o verbose         ;;
98        ( -x | --xtrace     ) set -o xtrace          ;;
99        ( -xv | -vx         ) set -o xtrace verbose  ;;
100        ( -e                ) set -e                 ;;
101        ( -V | --noverbose  ) set +o verbose         ;;
102        ( -X | --noxtrace   ) set +o xtrace          ;;
103        ( -XV | -VX         ) set +o xtrace verbose  ;;
104        ( -E                ) set +e                 ;;
105        ( -* ) echo ${Bold}"Unknown option : ${1}"${Norm} ; return 1 ;;
106    esac
107    shift
108done
109
110
111set -e
112
113#AtmFile=${1:-/ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/ATM/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_histmth.nc}
114#AtmFile=${1:-/ccc/work/cont003/gencmip6/bedidil/SAVE8_ORCA2/STORE1/dynamico_grid.nc}
115AtmFile=${1:-/ccc/scratch/cont003/gencmip6/p86caub/RUN_DIR/9114048_89294/ICOLOR-SROUT.11.NBP80.HISTMTH.89294/histday.nc}
116
117#
118# Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits
119# ---------------------------------------------------------------------------
120FL_FMT=64bit
121
122
123Count=$(ncdump -h  ${AtmFile} | grep nvertex | wc -l)
124if [[ ${Count} -gt 0 ]] ; then
125    IsUnstructured=True
126    dim_cell=$(ncdump -h  ${AtmFile} |& grep "cell *=" | awk '{print $3}' ) # Get nominal DYNAMICO resolution (nbp parameter)
127    ico_nbp=$( echo "sqrt(($dim_cell-2)/10)" | bc -l | sed 's/\..*//' )
128    ATM=ICO${ico_nbp}
129   
130else
131    # lat/lon
132    IsUnstructured=False
133    dim_lat=$(ncdump -h ${AtmFile} | grep "lat *=" | awk '{print $3}' )
134    dim_lon=$(ncdump -h ${AtmFile} | grep "lon *=" | awk '{print $3}' )
135    #ncrename --history --dimension lon,x flxat_fields_notime.nc
136    #ncrename --history --dimension lat,y flxat_fields_notime.nc
137    (( dim_lat = dim_lat - 1 ))
138    ATM=LMD${dim_lon}${dim_lat}
139    (( n_lat = dim_lat - 1 ))
140fi
141
142echo "Version atmosphere : " ${ATM}
143
144##
145## Creates flxat file
146## ===========================================================================
147
148python3 ${SUBMIT_DIR}/create_flxat.py --IsUnstructured=${IsUnstructured} --input ${AtmFile} --output flxat.nc
149
150#ncks --fl_fmt=${FL_FMT} --append --history --variable COTAUXXU,COTAUYYU,COTAUZZU,COTAUXXV,COTAUYYV,COTAUZZV,COTOTRAI,COTOTSNO,COTOTEVA,COICEVAP,COQSRMIX,COQNSMIX,COSHFICE,CONSFICE,CODFLXDT,COCALVIN,COLIQRUN,COWINDSP,COTAUMOD tmp_flxat.nc flxat.nc
151
152##
153## Add some information in file headers
154## ===========================================================================
155
156UUID=$(uuid)
157NCO="$(ncks --version |& tail -1 | sed 's/ncks //')"
158ncatted --history \
159        --attribute nco_openmp_thread_number,global,d,,                       \
160        --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}')" \
161        --attribute Program,global,o,c,"Generated by ${0}"      \
162        --attribute originalFiles,global,o,c,"${AtmFile}"       \
163        --attribute uuid,global,o,c,"${UUID}"                                 \
164        --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \
165        --attribute Comment,global,o,c,"${Comment}"                           \
166        flxat.nc
167
168##
169## Creates other files
170## ===========================================================================
171mv flxat.nc flxat_${ATM}_maskFrom_${OCE}.nc
172ncks --history --variable COCALVIN flxat_${ATM}_maskFrom_${OCE}.nc icbrg_${ATM}_maskFrom_${OCE}.nc
173ncks --history --variable COCALVIN flxat_${ATM}_maskFrom_${OCE}.nc icshf_${ATM}_maskFrom_${OCE}.nc
174
175## ===========================================================================
176##
177##                               That's all folk's !!!
178##
179## ===========================================================================
Note: See TracBrowser for help on using the repository browser.