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 | |
---|
31 | # 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 |
---|
32 | |
---|
33 | # CreateRestartAtm4Oasis.bash --oce ORCA2.3 /ccc/work/cont003/gencmip6/bedidil/SAVE8_ORCA2/STORE1/dynamico_grid.nc |
---|
34 | |
---|
35 | # CreateRestartAtm4Oasis.bash --oce ORCA2.3 /ccc/work/cont003/gencmip6/bedidil/SAVE9_ORCA2_DYN30_1MO/STORE1/histmth.nc |
---|
36 | |
---|
37 | # CreateRestartAtm4Oasis.bash --oce eORCA1.4.2 /ccc/store/cont003/gencmip6/p86caub/IGCM_OUT/ICOLMDZOR/DEVT/test/ICOLOR-SROUT.11.NBP60.HISTMTH/ATM/Output/DA/ICOLOR-SROUT.11.NBP60.HISTMTH_19950101_19950105_1D_histday.nc |
---|
38 | |
---|
39 | ## =========================================================================== |
---|
40 | ## |
---|
41 | ## You should not change anything below this line .... |
---|
42 | ## |
---|
43 | ## =========================================================================== |
---|
44 | set +vx |
---|
45 | ## |
---|
46 | ## Command line parameters |
---|
47 | ## =========================================================================== |
---|
48 | # Default values |
---|
49 | Comment="Preliminary attempt - Do not trust !" |
---|
50 | OCE="Unknown" |
---|
51 | |
---|
52 | # |
---|
53 | # Defines computer |
---|
54 | # ================ |
---|
55 | if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi |
---|
56 | if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi |
---|
57 | if [[ $(hostname) = lsce* ]] ; then arch=spip ; center=spip ; fi |
---|
58 | |
---|
59 | case ${arch} in |
---|
60 | ( irene ) |
---|
61 | set +e |
---|
62 | R_IN=$(ccc_home -u igcmg --cccwork)/IGCM |
---|
63 | TMPDIR=$(ccc_home --cccwork)/TMP/CPLRESTART |
---|
64 | SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR:-$(pwd)}} |
---|
65 | MpiRun="time ccc_mprun" |
---|
66 | PyRun="time ccc_mprun -n 1" # Needed to force python to run on one process only |
---|
67 | source $(ccc_home -u igcmg)/MachineEnvironment/irene/env_atlas_irene |
---|
68 | set -e |
---|
69 | ;; |
---|
70 | ( spip ) |
---|
71 | R_IN=${HOME}/Scratch/IGCM |
---|
72 | TMPDIR=${HOME}/Scratch/TMP |
---|
73 | SUBMIT_DIR=$(pwd) |
---|
74 | MpiRun="/opt/local/bin/mpirun -n 1" |
---|
75 | PyRun="time" |
---|
76 | ;; |
---|
77 | ( * ) |
---|
78 | exit -1 |
---|
79 | ;; |
---|
80 | esac |
---|
81 | |
---|
82 | mkdir -p ${TMPDIR} |
---|
83 | cd ${TMPDIR} |
---|
84 | |
---|
85 | bVerbose='Yes' |
---|
86 | bXtrace='Yes' |
---|
87 | bError='Yes' |
---|
88 | |
---|
89 | while [[ ${1} = -* || ${1} = +* ]] ; do |
---|
90 | #echo ${Red}"${1}"${Norm} |
---|
91 | case ${1} in |
---|
92 | ( -- ) shift ; break ;; |
---|
93 | ( -o | --oce ) shift ; OCE=${1} ;; # Just needed to add information in the file and file name |
---|
94 | ( -c | --comment ) shift ; Comment=${1} ;; # Just needed to add information in the file |
---|
95 | ( -v | --verbose ) bVerbose='Yes' ;; |
---|
96 | ( -x | --xtrace ) bXtrace='Yes' ;; |
---|
97 | ( -xv | -vx ) bVerbose='Yes' ; bXtrace='Yes' ;; |
---|
98 | ( -e ) bError='Yes' ;; |
---|
99 | ( -V | +v | --noverbose ) bVerbose='No' ;; |
---|
100 | ( -X | +x | --noxtrace ) bXtrace='No' ;; |
---|
101 | ( -XV | -VX | +vx | +xv ) bVerbose='No'; bXtrace='No' ;; |
---|
102 | ( -E | +e ) bError='No' ;; |
---|
103 | ( -* ) echo ${Bold}"Unknown option : ${1}"${Norm} ; return 1 ;; |
---|
104 | esac |
---|
105 | shift |
---|
106 | done |
---|
107 | |
---|
108 | [[ "X${bVerbose}" = "XYes" ]] && set -o verbose |
---|
109 | [[ "X${bVerbose}" = "XNo" ]] && set +o verbose |
---|
110 | [[ "X${bXtrace}" = "XYes" ]] && set -o xtrace |
---|
111 | [[ "X${bXtrace}" = "XNo" ]] && set +o xtrace |
---|
112 | [[ "X${bError}" = "XYes" ]] && set -o errexit |
---|
113 | [[ "X${bError}" = "XNo" ]] && set +o errexit |
---|
114 | |
---|
115 | #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} |
---|
116 | #AtmFile=${1:-/ccc/work/cont003/gencmip6/bedidil/SAVE8_ORCA2/STORE1/dynamico_grid.nc} |
---|
117 | AtmFile=${1:-/ccc/scratch/cont003/gencmip6/p86caub/RUN_DIR/9114048_89294/ICOLOR-SROUT.11.NBP80.HISTMTH.89294/histday.nc} |
---|
118 | |
---|
119 | # |
---|
120 | # Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits |
---|
121 | # --------------------------------------------------------------------------- |
---|
122 | FL_FMT=64bit |
---|
123 | |
---|
124 | Count=$(ncdump -h ${AtmFile} | grep nvertex | wc -l) |
---|
125 | if [[ ${Count} -gt 0 ]] ; then |
---|
126 | IsUnstructured=True |
---|
127 | dim_cell=$(ncdump -h ${AtmFile} |& grep "cell *=" | awk '{print $3}' ) # Get nominal DYNAMICO resolution (nbp parameter) |
---|
128 | ico_nbp=$( echo "sqrt(($dim_cell-2)/10)" | bc -l | sed 's/\..*//' ) |
---|
129 | ATM=ICO${ico_nbp} |
---|
130 | else |
---|
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 )) |
---|
140 | fi |
---|
141 | |
---|
142 | echo ${Blue}"Version atmosphere : ${ATM}"${Norm} |
---|
143 | |
---|
144 | ## |
---|
145 | ## Creates flxat file |
---|
146 | ## =========================================================================== |
---|
147 | |
---|
148 | python3 ${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 | |
---|
156 | UUID=$(uuid) |
---|
157 | NCO="$(ncks --version |& tail -1 | sed 's/ncks //')" |
---|
158 | ncatted --history \ |
---|
159 | --attribute nco_openmp_thread_number,global,d,, \ |
---|
160 | --attribute Program,global,o,c,"Generated by ${0}" \ |
---|
161 | --attribute originalFiles,global,o,c,"${AtmFile}" \ |
---|
162 | --attribute uuid,global,o,c,"${UUID}" \ |
---|
163 | --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \ |
---|
164 | --attribute Comment,global,o,c,"${Comment}" \ |
---|
165 | flxat.nc |
---|
166 | |
---|
167 | ## |
---|
168 | ## Creates other files |
---|
169 | ## =========================================================================== |
---|
170 | mv flxat.nc flxat_${ATM}_maskFrom_${OCE}.nc |
---|
171 | ncks --overwrite --history --variable COCALVIN flxat_${ATM}_maskFrom_${OCE}.nc icbrg_${ATM}_maskFrom_${OCE}.nc |
---|
172 | ncks --overwrite --history --variable COCALVIN flxat_${ATM}_maskFrom_${OCE}.nc icshf_${ATM}_maskFrom_${OCE}.nc |
---|
173 | |
---|
174 | ## |
---|
175 | echo ${Blue}"TMPDIR : ${TMPDIR}"${Norm} |
---|
176 | |
---|
177 | ## =========================================================================== |
---|
178 | ## |
---|
179 | ## That's all folk's !!! |
---|
180 | ## |
---|
181 | ## =========================================================================== |
---|