-
Notifications
You must be signed in to change notification settings - Fork 0
/
barakuda.sh
executable file
·997 lines (797 loc) · 35.8 KB
/
barakuda.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
#!/usr/bin/env bash
#==============================================================
#
# B A R A K U D A
#
# An OCEAN MONITORING python environment for NEMO
#
# L. Brodeau, 2009-2017
#
#===============================================================
date
export script=barakuda
[ -z ${BARAKUDA_ROOT+x} ] && export BARAKUDA_ROOT=${PWD}
[ -z ${CDFTOOLS_ROOT+x} ] && export CDFTOOLS_ROOT=${PWD}
# Display available configs:
list_conf="`\ls ${BARAKUDA_ROOT}/configs/config_*.sh | sed -e "s|${BARAKUDA_ROOT}/configs\/config_||g" -e s/'.sh'/''/g`"
# User configs, potentially in the directory from which barakuda.sh is called:
list_conf+=" `\ls ./config_*.sh 2>/dev/null | sed -e "s|.\/config_||g" -e s/'.sh'/''/g`"
# Important bash functions:
. ${BARAKUDA_ROOT}/src/bash/bash_functions.bash
barakuda_init
while getopts C:R:f:y:z:c:FeEh option ; do
case $option in
C) export CONFIG=${OPTARG} ;;
R) export EXP=${OPTARG} ;;
f) export IFREQ_SAV_YEARS=${OPTARG} ;;
y) export YEAR0=${OPTARG} ; export LFORCE_YINI=true ;;
z) export YEARN=${OPTARG} ; export LFORCE_YEND=true ;;
c) export EXPREF=${OPTARG} ;;
F) export LFORCEDIAG=true ;;
e) export ISTAGE=2 ;;
E) export ISTAGE=2 ; export l_clim_diag=true ;;
h) barakuda_usage; exit ;;
\?) barakuda_usage; exit ;;
esac
done
barakuda_check
# Time to source the config file:
if [ -f ./config_${CONFIG}.sh ]; then
# sourcing local configuration file if present:
fconfig=./config_${CONFIG}.sh
else
# sourcing barakuda-distribution configuration file:
fconfig=${BARAKUDA_ROOT}/configs/config_${CONFIG}.sh
fi
if [ -f ${fconfig} ]; then
echo "Sourcing configuration file: ${fconfig} !"
. ${fconfig}
else
echo "ERROR: cannot find file ${fconfig} !"; exit
fi
echo
# If auto-submit experiment (ece_exp=10) then overides a few functions with:
if [ ${ece_exp} -ge 10 ]; then
echo "Sourcing ${BARAKUDA_ROOT}/src/bash/bash_functions_autosub.bash"
. ${BARAKUDA_ROOT}/src/bash/bash_functions_autosub.bash
fi
# If CMOR files, then overides a few functions with
if [ ${CMOR} -eq 1 ]; then
echo "Sourcing ${BARAKUDA_ROOT}/src/bash/bash_functions_cmor.bash"
. ${BARAKUDA_ROOT}/src/bash/bash_functions_cmor.bash
fi
#
# If 3D fieds are annual averaged then overides a few functions with:
if [ ! "${ANNUAL_3D}" = "" ]; then
. ${BARAKUDA_ROOT}/src/bash/bash_functions_1y.bash
fi
# List of CDFTOOLS executables needed for the diagnostics:
export L_EXEC="cdfmaxmoc.x cdfmoc.x cdfvT.x cdftransportiz.x cdficeflux.x cdficediags.x cdfmhst.x cdfsigtrp.x"
barakuda_setup
echo
echo " SETTINGS: "
echo " *** CONFIG = ${CONFIG} "
echo " *** NEMO_OUT_D = ${NEMO_OUT_D} "
echo " *** CLIM_DIR = ${CLIM_DIR} "
echo " *** TMP_DIR = ${TMP_DIR} "
echo " *** GRID = ${ORCA} "
echo " *** EXP = ${EXP} "
echo " *** CPREF = ${CPREF} "
echo " *** IFREQ_SAV_YEARS = ${IFREQ_SAV_YEARS} "
echo " *** NCDF_DIR = ${NCDF_DIR} "
echo
if [ ${ISTAGE} -eq 1 ]; then
barakuda_first_last_years ; # look at NEMO files to know what are first and last years available...
echo ${IFREQ_SAV_YEARS} > ${DIAG_D}/numb_year_per_file.info
echo ${YEAR_INI} > ${DIAG_D}/first_year.info
else
# -> this is stage 2 (plot generation) ISTAGE=2 !
barakuda_init_plot
fi
cyear_ini=`printf "%04d" ${YEAR_INI}`
cyear_end=`printf "%04d" ${YEAR_END}`
# For proper python executables and scripts to be found:
export PATH=${PYBRKD_EXEC_PATH}:${BARAKUDA_ROOT}/src/bash:${PYTHON_HOME}/bin:${PATH}
# setup over
######################################################################################
jyear=${YEAR_INI}
fcompletion=${DIAG_D}/last_year_done.info
if [ -f ${fcompletion} ]; then jyear=`cat ${fcompletion}`; ((jyear++)); fi
cd ${TMP_DIR}/
barakuda_import_mesh_mask ; # Importing mesh_mask (+basin) files...
if [ ${ISTAGE} -eq 1 ]; then
# Importing cdftools executables:
for ex in ${L_EXEC}; do rsync -v ${BARAKUDA_ROOT}/cdftools_light/bin/${ex} . ; done
fi
# L O O P A L O N G Y E A R S
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lcontinue=true
if ${LFORCEDIAG}; then lcontinue=false; fi
if ${LFORCE_YEND}; then
if [ ${jyear} -gt ${YEARN} ]; then lcontinue=false; fi
fi
while ${lcontinue}; do
export cyear=`printf "%04d" ${jyear}`
if [ ${CMOR} -eq 0 ]; then
cpf=""
if [ ${ISTAGE} -eq 1 ] && [ ${ece_exp} -gt 0 ]; then
iy=$((${jyear}-${YEAR_INI}+1+${YEAR_INI}-${YEAR_INI_F}))
dir_ece=`printf "%03d" ${iy}`
echo " *** ${cyear} => dir_ece = ${dir_ece}"
cpf="${dir_ece}/"
fi
fi
i_get_file=0
if [ $((${jyear}%${IFREQ_SAV_YEARS})) -eq 0 ]; then
barakuda_check_year_is_complete ; # lcontinue might be updated to false!
fi
echo; echo
export CRT1M=${CPREF}${cyear}${cmmdd1}_${cyear}${cmmdd2}
if ${l_y2_j}; then export CRT1M=${CPREF}${cyear}${cmmdd1}_`printf "%04d" $((${jyear}+1))`${cmmdd2} ; fi
if ${lcontinue}; then
echo "Yeah! Year ${jyear} is saved..."; echo
if [ ${ISTAGE} -eq 2 ]; then
echo; echo "You cannot create figures and HTML pages yet!"
echo " => finish treating the results first by launching barakuda.sh without the '-e' switch."
exit
fi
echo; echo
echo "*********************************************************************"
echo " Experiment ${EXP}: Will generate diagnostics and data for year ${cyear}..."
echo "*********************************************************************"
echo; echo
barakuda_import_files
# Monthly files to work with for current year:
ft1m=${CRT1M}_grid_T.nc
fu1m=${CRT1M}_grid_U.nc
fv1m=${CRT1M}_grid_V.nc
fj1m=${CRT1M}_${FILE_ICE_SUFFIX}.nc ; # can be icemod or grid_T ....
ff1m=${CRT1M}_${FILE_FLX_SUFFIX}.nc ; # file with surface fluxes
#
# Annual files to work with for current year:
CRT1Y=`echo ${CRT1M} | sed -e s/"_${TSTAMP}_"/"_${ANNUAL_3D}_"/g`
ft1y=${CRT1Y}_grid_T.nc
fu1y=${CRT1Y}_grid_U.nc
fv1y=${CRT1Y}_grid_V.nc
fj1y=${CRT1Y}_${FILE_ICE_SUFFIX}.nc
ff1y=${CRT1Y}_${FILE_FLX_SUFFIX}.nc
CFG3D=${CRT1M}
#
# Files that contain the 3D fields (might be monthly or annaual sometimes (when "${ANNUAL_3D}" = "1y")
ft3d=${ft1m}
fu3d=${fu1m}
fv3d=${fv1m}
if [ "${ANNUAL_3D}" = "1y" ]; then
[[ ${NEMO_SAVED_FILES_3D} =~ (^|[[:space:]])"grid_U"($|[[:space:]]) ]] \
&& CFG3D=${CRT1Y}; ft3d=${ft1y}; fu3d=${fu1y}; fv3d=${fv1y} \
|| echo "...default"
echo ""
fi
fvt=${CFG3D}_VT.nc
# -- time to compute diagnostics --
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# If coupled EC-Earth simu, attempting to compute ocean-averaged fluxes from IFS too (E, P, E-P)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${ece_exp} -eq 2 ] && [ ${NBL} -eq 75 ] && [ ${i_do_ifs_flx} -eq 1 ]; then
echo; echo; echo "Fluxes of freshwater at the surface from IFS..."
echo " *** CALLING: extract_ifs_surf_fluxes.sh &"
extract_ifs_surf_fluxes.sh &
pid_flxl=$! ; echo
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Computing time-series of spatially-averaged variables
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_mean} -eq 1 ]; then
#
echo; echo "3D-averaging for time series"
echo " *** CALLING: mean_3d.py ${ft1m} ${jyear} T &"
mean_3d.py ${ft1m} ${jyear} T &
pid_mn3dt=$! ; echo
#
echo " *** CALLING: mean_3d.py ${ft1m} ${jyear} S &"
mean_3d.py ${ft1m} ${jyear} S &
pid_mn3ds=$! ; echo
#
echo; echo "2D-averaging for time series"
echo " *** CALLING: mean_2d.py ${ft1m} ${jyear} &"
mean_2d.py ${ft1m} ${jyear} &
pid_mn2d=$! ; echo
#
echo; echo "2D-integration of some surface fluxes over basins"
echo " *** CALLING: flux_int_basins.py ${ff1m} ${jyear} &"
flux_int_basins.py ${ff1m} ${jyear} &
pid_ssf=$! ; echo
#
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
# Creating VT file if needed
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_trsp} -gt 0 ] || [ ${i_do_mht} -eq 1 ]; then
if [ ! -f ${fvt} ]; then
echo; echo; echo " *** CALLING: ./cdfvT.x ${CFG3D} ${NN_T} ${NN_S} ${NN_U} ${NN_V} ${NN_U_EIV} ${NN_V_EIV} &"
./cdfvT.x ${CFG3D} ${NN_T} ${NN_S} ${NN_U} ${NN_V} ${NN_U_EIV} ${NN_V_EIV} &
pid_vtvt=$! ; echo
fi
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 2D maps of NEMO - OBS for SST and SSS (for movies)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_movi} -eq 1 ]; then
echo; echo; echo "2D maps of NEMO - OBS for SST and SSS (for movies)"
echo " *** CALLING: prepare_movies.py ${ft1m} ${jyear} sst &"
prepare_movies.py ${ft1m} ${jyear} sst &
pid_movt=$! ; echo
echo " *** CALLING: prepare_movies.py ${ft1m} ${jyear} sss &"
prepare_movies.py ${ft1m} ${jyear} sss &
pid_movs=$! ; echo
echo " *** CALLING: prepare_movies.py ${ft1m} ${jyear} mld &"
prepare_movies.py ${ft1m} ${jyear} mld &
pid_movm=$! ; echo
echo " *** CALLING: prepare_movies.py ${fj1m} ${jyear} ice &"
prepare_movies.py ${fj1m} ${jyear} ice &
pid_movi=$! ; echo
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Computing time-series of spatially-averaged variables
# on boxes (saving the variable on 2D box too...
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_ssx_box} -eq 1 ]; then
echo; echo; echo "Box monthly values"
echo " *** CALLING: ssx_boxes ${ft1m} ${jyear} ${NN_SST} ${NN_SSS} &"
ssx_boxes.py ${ft1m} ${jyear} ${NN_SST} ${NN_SSS} &
pid_boxa=$! ; echo
fi
#~~~~~~~
# MOC
#~~~~~~~
if [ ${i_do_amoc} -eq 1 ]; then
echo; echo; echo "MOC"
rm -f moc.nc *.tmp
echo " *** CALLING: ./cdfmoc.x ${fv3d} ${NN_V} ${NN_V_EIV} &"
./cdfmoc.x ${fv3d} ${NN_V} ${NN_V_EIV} &
pid_amoc=$! ; echo
fi
#~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Transport by sigma-class
#~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_sigt} -eq 1 ]; then
echo; echo
if [ ! -f ./dens_section.dat ]; then
if [ -f ${DENSITY_SECTION_FILE} ]; then
echo "Copying ${DENSITY_SECTION_FILE} to here: `pwd` !"; cp ${DENSITY_SECTION_FILE} ./dens_section.dat
else
echo; echo "WARNING: Can't do Transport by sigma-class: ${DENSITY_SECTION_FILE} is missing!!!"
fi
fi
echo " *** CALLING: ./cdfsigtrp.x ${ft3d} ${fu3d} ${fv3d} 24.8 28.6 19 ${jyear} ${DIAG_D} ${NN_T} ${NN_S} ${NN_U} ${NN_V} &"; echo
./cdfsigtrp.x ${ft3d} ${fu3d} ${fv3d} 24.8 28.6 19 ${jyear} ${DIAG_D} ${NN_T} ${NN_S} ${NN_U} ${NN_V} &
pid_sigt=$! ; echo
fi
echo
echo " Gonna wait for level #1 to be done !"
wait ${pid_vtvt}
#wait
echo " .... diag level #1 done...." ; echo
echo
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Meridional heat and salt transport
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_mht} -eq 1 ]; then
echo; echo; echo "Meridional transport of heat and salt"
fo=${DIAG_D}/merid_transport_T_S_${CONFEXP}.nc
if [ ! -f ${fvt} ]; then
echo "WARNING: file ${fvt} is not here, skipping meridional transports section"
else
rm -f merid_heat_trp.dat merid_salt_trp.dat
echo " *** CALLING: ./cdfmhst.x ${fvt} ${fo} ${jyear} &"
./cdfmhst.x ${fvt} ${fo} ${jyear} &
pid_mhst=$! ; echo
fi
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# VOLUME, HEAT and SALT transports through specified section
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_trsp} -gt 0 ]; then
echo; echo; echo "Transports of volume, heat and salt through different sections"
if [ -z ${TRANSPORT_SECTION_FILE} ]; then
echo "Please specify which TRANSPORT_SECTION_FILE to use into the config file!" ; exit
fi
if [ ! -f ./transportiz.dat ]; then
check_if_file ${TRANSPORT_SECTION_FILE}
cp ${TRANSPORT_SECTION_FILE} ./transportiz.dat
fi
if [ ${i_do_trsp} -eq 1 ]; then z1_trsp="" ; z2_trsp=""; fi
if [ ! -f ${fvt} ]; then
echo "WARNING: file ${fvt} is not here, skipping transport section!"
else
# Breaking transportiz file in several files so we can go parallel!
rm -f transportiz_*.dat
break_downn_section_file.py ./transportiz.dat 2 ; # => Max. 2 sections per file
list=`\ls transportiz_*.dat`
for fs in ${list}; do
echo " *** CALLING: ./cdftransportiz.x ${fs} ${CFG3D} ${NN_U} ${NN_V} ${NN_U_EIV} ${NN_V_EIV} ${jyear} ${DIAG_D} ${z1_trsp} ${z2_trsp} &"
./cdftransportiz.x ${fs} ${CFG3D} ${NN_U} ${NN_V} ${NN_U_EIV} ${NN_V_EIV} ${jyear} ${DIAG_D} ${z1_trsp} ${z2_trsp} &
echo
done
fi
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Solid freshwater transport through sections due to sea-ice drift
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_ice} -gt 0 ] && [ ${i_do_trsp_ice} -eq 1 ]; then
echo; echo; echo "Solid freshwater transport through sections due to sea-ice drift"
if [ -z ${TRANSPORT_SECTION_FILE_ICE} ]; then
echo "Please specify which TRANSPORT_SECTION_FILE_ICE to use into the config file!" ; exit
fi
if [ ! -f ./transport_ice.dat ]; then
check_if_file ${TRANSPORT_SECTION_FILE_ICE}
cp ${TRANSPORT_SECTION_FILE_ICE} ./transport_ice.dat
fi
#
# Breaking transportiz file in several files so we can go parallel!
rm -f transport_ice_*.dat
break_downn_section_file.py ./transport_ice.dat 2 ; # => Max. 2 sections per file
list=`\ls transport_ice_*.dat`
for fs in ${list}; do
echo " *** CALLING: ./cdficeflux.x ${fs} ${fj1m} ${NN_ICEF} ${NN_ICEU} ${NN_ICEV} ${NN_ICET} ${jyear} ${DIAG_D} &"
./cdficeflux.x ${fs} ${fj1m} ${NN_ICEF} ${NN_ICEU} ${NN_ICEV} ${NN_ICET} ${jyear} ${DIAG_D} &
echo
done
fi
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Deep Mixed Volume (DMV) on a given box
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ! -z ${i_do_dmv} ] && [ ${i_do_dmv} -gt 0 ]; then
if [ -z ${FILE_DEF_BOXES} ]; then
echo "Please specify a FILE_DEF_BOXES to use into the config file!" ; exit
fi
echo " *** CALLING: dmv.py ${ft1m} ${cyear} &"
dmv.py ${ft1m} ${cyear} &
pid_dmvl=$! ; echo
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Budget and other stuffs on a given rectangular box!
# It provides time-series depending only on time (not depth)
# budget_rectangle_box.py
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_bb} -gt 0 ]; then
echo; echo; echo "Budget and other stuffs on rectangular boxes!"
if [ -z ${FILE_DEF_BOXES} ]; then
echo "Please specify a FILE_DEF_BOXES to use into the config file!" ; exit
fi
echo " *** CALLING: budget_rectangle_box.py ${cyear} 100 uv &"
budget_rectangle_box.py ${cyear} 100 uv &
pid_bbbb=$! ; echo
fi
echo " Gonna wait for level #2 to be done !"
wait ${pid_amoc} ; # moc needs to be done to call cdfmaxmoc.x ...
echo
echo " .... diag level #2 done...." ; echo ; echo
#~~~~~~~~~~~
# Max AMOC
#~~~~~~~~~~~
if [ ${i_do_amoc} -eq 1 ]; then
if [ -z "${LMOCLAT}" ]; then
echo "AMOC => specify latitude bands with variable LMOCLAT into the config file!!!"; exit
fi
for clat in ${LMOCLAT}; do
cslat=`echo ${clat} | sed -e s/'-'/' '/g`
echo " *** ./cdfmaxmoc.x moc.nc atl ${cslat} 500 1500 ${jyear} ${DIAG_D}"
./cdfmaxmoc.x moc.nc atl ${cslat} 500 1500 ${jyear} ${DIAG_D}
done
fi
#~~~~~~~~~
# SEA-ICE
#~~~~~~~~~
if [ ${i_do_ice} -eq 1 ]; then
echo; echo; echo "Sea-ice extent and volume..." ; rm -f tmp_ice.nc
echo "ncks -A -v ${NN_ICEF} ${fj1m} -o tmp_ice.nc"
ncks -A -v ${NN_ICEF} ${fj1m} -o tmp_ice.nc
ncrename -v ${NN_ICEF},ice_frac tmp_ice.nc
coic=""
if [ -z ${NN_ICET} ]; then
coic="oic" ; # means only ice concentration available!
else
echo "ncks -A -v ${NN_ICET} ${fj1m} -o tmp_ice.nc"
ncks -A -v ${NN_ICET} ${fj1m} -o tmp_ice.nc
ncrename -v ${NN_ICET},ice_thic tmp_ice.nc
fi
echo " *** CALLING: ./cdficediags.x tmp_ice.nc ${jyear} ${DIAG_D} ${coic} &"
./cdficediags.x tmp_ice.nc ${jyear} ${DIAG_D} ${coic} &
fi
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Temperature and Salinity on cross meridional/zonal sections
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_sect} -eq 1 ]; then
check_if_file ${TS_SECTION_FILE}
lst_sec=`cat ${TS_SECTION_FILE} | grep -v -E '(^#|EOF)' | awk -F ' ' '{print $1}'`
echo; echo; echo "Cross-sections on specified transects:"
echo "${lst_sec}"; echo
echo " *** CALLING: cross_sections.py ${ft3d} ${jyear} &"
cross_sections.py ${ft3d} ${jyear} &
echo
fi
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Vertical profiles of T,S and density horizontally averaged
# on rectangular boxes defined into FILE_DEF_BOXES
# => creates time-series function of time and depth
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_box_TS_z} -gt 0 ]; then
if [ -z ${FILE_DEF_BOXES} ]; then
echo "Please specify a FILE_DEF_BOXES to use into the config file!" ; exit
fi
echo " *** CALLING: prof_TS_z_box.py ${cyear} &"
prof_TS_z_box.py ${cyear} &
echo;echo
fi
# --- end of stuffs that can be launched in bg ---
echo
echo " Waiting for backround jobs for current year (${jyear}) !"
wait ${pid_mn3dt} ${pid_mn3ds} ${pid_movt} ${pid_movs} ${pid_movm} ${pid_movi} ${pid_mn2d} ${pid_ssf} ${pid_flxl}
wait
echo " Done waiting for year ${cyear} !"
if [ ${i_do_movi} -eq 1 ]; then rsync -rv movies ${DIAG_D}/ ; fi
rm -f *.tmp broken_line_* tmp_ice.nc
rm -f ${CRT1M}_*.nc ${CRT1Y}_*.nc ; #debug
echo
echo " ---- DIAGS ARE DONE FOR YEAR ${cyear} ! ---"
echo "${cyear}" > ${fcompletion}
echo; echo
fi ; # if ${lcontinue}; then
#if ${LFORCE_YEND}; then
# if [ ${jyear} -eq ${YEARN} ]; then lcontinue=false; fi
#fi
wait
((jyear++))
if ${LFORCE_YEND}; then
if [ ${jyear} -gt ${YEARN} ]; then lcontinue=false; fi
fi
# end loop years...
done ; # while ${lcontinue}; do
# PREPARING HTML PAGE
# ~~~~~~~~~~~~~~~~~~~
l_pclim=false
if [ ${ISTAGE} -eq 2 ]; then
rm -rf ${DIAG_D}/${EXP}
y1=`cat ${DIAG_D}/first_year.info`
y2=`cat ${DIAG_D}/last_year_done.info`
nby=$((${y2}-${y1}+1))
# Agreement between last year from output files and 'fcompletion' file:
ydum=`cat ${fcompletion}`
if [ -z ${YEARN} ]; then
# (if YEARN is not set...)
if [ ! ${ydum} -eq ${YEAR_END} ]; then
echo;
echo "###################################################################"
echo "ERROR: in ${fcompletion} last_year = ${ydum}"
echo " and from stored files files last_year = ${YEAR_END} !"
echo "###################################################################"
echo
exit
fi
fi
echo; echo; echo "EXP ${EXP}: creating plots"; echo
#cd ${BARAKUDA_ROOT}/
cd ${DIAG_D}/
echo
if [ ${i_do_movi} -eq 1 ]; then
if [ "${iffmpeg_x264}" = "1" ]; then
# FFMPEG compiled with x264 mp4 support is available on host:
cd movies/
for cc in dsst dsss mld icen ices; do
hh=520 ; # height of image in pixels
if [ "${cc}" = "icen" ]; then hh=576; fi
if [ "${cc}" = "ices" ]; then hh=456; fi
echo " *** CALLING: images2mp4.sh ${cc} ${FIG_FORM} ${hh} 8 &"
images2mp4.sh ${cc} ${FIG_FORM} ${hh} 8 &
echo
done
cd ${DIAG_D}/
else
# Faling back on GIF, with 'convert' of imageMagick:
idelay=$((120-${nby}*8))
if [ ${idelay} -lt 10 ]; then idelay=10; fi
rm -f *_${CONFEXP}.gif
for cc in dsst dsss mld icen ices; do
echo " *** CALLING: convert -delay ${idelay} -loop 0 movies/${cc}_*.png ${cc}_${CONFEXP}.gif &"
convert -delay ${idelay} -loop 0 movies/${cc}_*.png ${cc}_${CONFEXP}.gif &
echo
done
fi
fi
# 1D plots to perform
# ~~~~~~~~~~~~~~~~~~~
DIAG_1D_LIST=""
if [ ${i_do_mean} -eq 1 ]; then
DIAG_1D_LIST="${DIAG_1D_LIST} 3d_so mean_sos 3d_thetao mean_tos mean_zos"
if [ ! "${NN_MLD}" = "X" ]; then DIAG_1D_LIST="${DIAG_1D_LIST} mean_mld"; fi
if [ ! "${NN_QNET}" = "X" ]; then DIAG_1D_LIST="${DIAG_1D_LIST} mean_htf"; fi
if [ ! "${NN_FWF}" = "X" ]; then DIAG_1D_LIST="${DIAG_1D_LIST} mean_fwf"; fi
fi
if [ ${i_do_amoc} -eq 1 ]; then DIAG_1D_LIST="${DIAG_1D_LIST} amoc"; fi
if [ ${i_do_ice} -eq 1 ]; then DIAG_1D_LIST="${DIAG_1D_LIST} seaice"; fi
if [ ${i_do_trsp} -gt 0 ] || [ ${i_do_trsp_ice} -eq 1 ]; then DIAG_1D_LIST="${DIAG_1D_LIST} transport_sections" ; fi
dy=$((${YEAR_END}-${YEAR_INI}+1)) ; export YF2=$((${YEAR_END}+1))
# Doing 1D plots
# ~~~~~~~~~~~~~~
echo ; echo; echo "Going to perform the following 1D plots:"
echo " => ${DIAG_1D_LIST}"; echo
for fd in ${DIAG_1D_LIST}; do
echo " *** CALLING: plot_time_series.py ${fd}"
plot_time_series.py ${fd} ; echo
echo
done
echo ; echo ; echo
if [ ${i_do_mean} -eq 1 ]; then
# 5-month-running mean SST anomaly over Nino region 3.4 graph:
echo " *** CALLING: plot_enso.py Nino34_${CONFEXP}.nc ${NN_SST}"
plot_enso.py Nino34_${CONFEXP}.nc ${NN_SST}
echo; echo
# Hovmuller of temperature and salinity
echo " *** CALLING: plot_hovm_tz.py"
plot_hovm_tz.py
echo; echo
if [ ${nby} -ge 70 ]; then
# AMO aka 11-year-running mean SST anomaly over North Atlantic (0-70N)
echo " *** CALLING: plot_amo.py mean_SST_NAtl_${CONFEXP}.nc ${NN_SST}"
plot_amo.py mean_SST_NAtl_${CONFEXP}.nc ${NN_SST}
echo; echo
fi
fi
if [ ${i_do_sigt} -eq 1 ]; then
# Transport by sigma-class
echo " *** CALLING: plot_trsp_sigma.py"
plot_trsp_sigma.py
echo; echo; echo
fi
if [ ${i_do_mht} -eq 1 ]; then
#
# Hovmullers of advective meridional heat/salt transport
echo; echo
echo " *** CALLING: plot_hovm_merid_trsp.py"
plot_hovm_merid_trsp.py
echo; echo; echo
#
fi
echo; echo; echo
if ${l_clim_diag} ; then
###########################################################################
# Climatology over X years (12-month file average of X consecutive years)
# => has to be built with the 'build_clim.sh' script
###########################################################################
echo; echo; echo "Checking for presence of ${DIAG_D}/clim/last_clim..."
if [ -f ${DIAG_D}/clim/last_clim ]; then
cat ${DIAG_D}/clim/last_clim
export CLIM_PER=`cat ${DIAG_D}/clim/last_clim`
ftcli=${DIAG_D}/clim/mclim_${CONFEXP}_${CLIM_PER}_grid_T.nc4
ficli=${DIAG_D}/clim/mclim_${CONFEXP}_${CLIM_PER}_${FILE_ICE_SUFFIX}.nc4
fcsbc=${DIAG_D}/clim/mclim_${CONFEXP}_${CLIM_PER}_${FILE_FLX_SUFFIX}.nc4
fclvt=${DIAG_D}/clim/aclim_${CONFEXP}_${CLIM_PER}_VT.nc4
fcmoc=${DIAG_D}/clim/aclim_${CONFEXP}_${CLIM_PER}_MOC.nc4
fcpsi=${DIAG_D}/clim/aclim_${CONFEXP}_${CLIM_PER}_PSI.nc4
fccrl=${DIAG_D}/clim/aclim_${CONFEXP}_${CLIM_PER}_TCURL.nc4
iclyear=`echo ${CLIM_PER} | sed -e s/'-'/' '/g`
else
echo; echo "ERROR => you set l_clim_diag to true (probably by using '-E') but no file 'last_clim' was found in:"
echo " ${DIAG_D}/clim/"
echo " => then use '-e' instead!"; echo
exit
fi
echo; echo; echo "Checking for presence of ${ftcli}..."
if [ -f ${ftcli} ]; then
echo; echo;
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "* Climatologies found !!!"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo
echo " => for years ${CLIM_PER}" ; echo " => using ${ftcli}"
list_comp_2d="OBS"
l_pclim=true
lcomp_to_exp=false
if [ ! -z ${EXPREF} ]; then
lcomp_to_exp=true
list_comp_2d="OBS ${EXPREF}"
# Must check if climatology for exp ${EXPREF} is there:
fclim_ref=`echo "${ftcli}" | sed -e "s|${EXP}|${EXPREF}|g"`
check_if_file ${fclim_ref}
echo "Going to compare also against exp ${fclim_ref}!"
echo
fi
echo; echo
for ff in ${F_T_OBS_3D_12} ${F_S_OBS_3D_12} ${F_SST_OBS_12}; do check_if_file ${ff} "name:${ff}"; done
if [ ${i_do_ice} -gt 0 ]; then check_if_file ${F_ICE_OBS_12} "name:${F_ICE_OBS_12}" ; fi
echo; echo
#######################################
# Diags that don't imply a comparison #
#######################################
export COMP2D="OBS"
# Lat-Depth AMOC
# ~~~~~~~~~~~~~~
if [ -f ${fcmoc} ]; then
echo; echo
echo " Ploting lat-depth MOC !"
cd ${DIAG_D}/
export DIRS_2_EXP="${DIRS_2_EXP} moc"
rm -rf moc; mkdir moc; cd moc/
echo; echo; echo " *** CALLING: moc.py ${iclyear}"
moc.py ${iclyear} &
cd ../
echo
fi
# March Mixed layer depth in Nordic Seas
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ `ipresent_var_in_ncf ${ftcli} ${NN_MLD}` -eq 1 ]; then
echo; echo
echo " Performing 2D mapping of March Mixed layer depth in Nordic Seas"
cd ${DIAG_D}/
export DIRS_2_EXP="${DIRS_2_EXP} mld"
rm -rf mld; mkdir mld; cd mld/
echo; echo; echo " *** CALLING: mld.py ${iclyear}"; echo
mld.py ${iclyear} &
cd ../
echo
fi
# Sea-ice extent stereographic polar projection South and North
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ ${i_do_ice} -gt 0 ] && [ `ipresent_var_in_ncf ${ficli} ${NN_ICEF}` -eq 1 ]; then
echo; echo
echo " Performing 2D Sea-ice extent stereographic polar projection South and North"
cd ${DIAG_D}/
export DIRS_2_EXP="${DIRS_2_EXP} sea_ice"
rm -rf sea_ice; mkdir sea_ice; cd sea_ice/
echo; echo; echo " *** CALLING: ice.py ${iclyear}"; echo
ice.py ${iclyear} &
cd ../
echo
fi
# Sea-surface height
# ~~~~~~~~~~~~~~~~~~
if [ `ipresent_var_in_ncf ${ftcli} ${NN_SSH}` -eq 1 ]; then
echo; echo; echo " SSH map"
export DIRS_2_EXP="${DIRS_2_EXP} ssh"
cd ${DIAG_D}/
rm -rf ssh; mkdir ssh; cd ssh/
echo " *** CALLING: ssh.py ${iclyear}"; echo
ssh.py ${iclyear} &
cd ../ ; echo
else
echo; echo "WARNING: did not find ${NN_SSH} into ${ftcli} !!!!"; echo
fi
# Wind-stress module and curl
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ -f ${fccrl} ]; then
echo; echo; echo " Wind-stress module and curl maps"
if [ -x ${NN_TAUM} ]; then echo "ERROR: define variable NN_TAUM in ${fconfig}! ('X' if not present in NEMO output)"; exit; fi
export DIRS_2_EXP="${DIRS_2_EXP} wind"
cd ${DIAG_D}/
rm -rf wind; mkdir wind; cd wind/
echo " *** CALLING: wind.py ${iclyear}"; echo
wind.py ${iclyear} &
cd ../ ; echo
else
echo
echo "WARNING: did not find file ${fccrl} !!!"
echo " or did not find ${NN_TAUM} into ${fcsbc} !!!!"
echo
fi
# Zonally-averaged surface heat fluxes
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lolo
if [ -f ${fcsbc} ]; then
echo; echo; echo " Zonally-averaged surface heat fluxes"
if [ -x ${NN_QSOL} ]; then echo "ERROR: define variable NN_QSOL in ${fconfig}! ('X' if not present in NEMO output)"; exit; fi
export DIRS_2_EXP="${DIRS_2_EXP} sfluxes"
cd ${DIAG_D}/
rm -rf sfluxes; mkdir sfluxes; cd sfluxes/
echo " *** CALLING: sfluxes.py ${iclyear}"; echo
sfluxes.py ${iclyear} &
cd ../ ; echo
else
echo
echo "WARNING: did not find file ${fcsbc} !!!"
echo " or did not find ${NN_QSOL} into ${fcsbc} !!!!"
echo
fi
##################################################
# Diags that imply a comparison against "COMP2D" #
##################################################
cd ${DIAG_D}/
rm -rf temp_sal
for COMP2D in ${list_comp_2d}; do
export COMP2D=${COMP2D}
echo; echo; echo "Clim. comparisons against ${COMP2D}"
if [ "${COMP2D}" = "${EXPREF}" ]; then
export F_T_OBS_3D_12=${fclim_ref}; check_if_file ${F_T_OBS_3D_12} "name:F_T_OBS_3D_12"
export F_S_OBS_3D_12=${fclim_ref}; check_if_file ${F_S_OBS_3D_12} "name:F_S_OBS_3D_12"
export F_SST_OBS_12=${fclim_ref} ; check_if_file ${F_SST_OBS_12} "name:F_SST_OBS_12"
if [ ${i_do_ice} -gt 0 ]; then export F_ICE_OBS_12=${fclim_ref} ; check_if_file ${F_ICE_OBS_12} "name:F_ICE_OBS_12"; fi
fi
# Temperature and Salinity
# ~~~~~~~~~~~~~~~~~~~~~~~~
echo; echo
echo " Creating maps and cross-sections (i_do_sect) of Temperature and Salinity"
cd ${DIAG_D}/
export DIRS_2_EXP="${DIRS_2_EXP} temp_sal"
DIRS_2_EXP_RREF="${DIRS_2_EXP_RREF} temp_sal"
mkdir -p temp_sal; cd temp_sal/
echo; echo; echo " *** CALLING: temp_sal.py ${iclyear} &"; echo
temp_sal.py ${iclyear} &
cd ../
echo
done ; # for COMP2D in ${list_comp_2d}; do
wait
else
echo; echo
echo " No Climatologies found ...";
echo " => you can use 'build_clim.sh' to build a climato of your experiment"
echo; echo
fi
fi ; # if ${l_clim_diag}
wait
# Time for HTML stuff!
export HTML_DIR=${DIAG_D}/${EXP}
mkdir -p ${HTML_DIR}
cd ${DIAG_D}/
# Moving all figures to HTML_DIR:
for fp in ${FIG_FORM} svg mp4 gif; do mv -f *.${fp} ${HTML_DIR}/ >/dev/null 2>/dev/null ; done
mv -f ./merid_transport/*.${FIG_FORM} ${HTML_DIR}/ >/dev/null 2>/dev/null
mv -f ${DIAG_D}/movies/movie_*.mp4 ${HTML_DIR}/ >/dev/null 2>/dev/null
# Sign with logo?
#cd ${HTML_DIR}/
#list=`\ls *.png`
#for ff in ${list}; do
# sign_image ${ff} n_${ff}
# mv -f n_${ff} ${ff}
#done
cd ${DIAG_D}/
. ${BARAKUDA_ROOT}/src/bash/build_html.bash
wait
# Building main index.html
build_index_html
# If climatology built, sub 2D html pages
if ${l_pclim}; then
build_sub_html
fi
#==================================================================
wait ; # likely waiting for the creation of the GIFs....
echo; echo
cp ${BARAKUDA_ROOT}/src/html/conf_*.html ${HTML_DIR}/
if [ ${ece_exp} -eq 0 ]; then
cp -L ${BARAKUDA_ROOT}/src/html/logo.*g ${HTML_DIR}/
else
cp -L ${BARAKUDA_ROOT}/src/html/logo_ece.svg ${HTML_DIR}/logo.svg
cp -L ${BARAKUDA_ROOT}/src/html/logo_ece.png ${HTML_DIR}/logo.png
fi
mv -f index.html namelist*.html ${HTML_DIR}/
cp -r ${DIRS_2_EXP} ${HTML_DIR}/ >/dev/null 2>/dev/null
echo; echo; echo
if [ ${ihttp} -eq 1 ]; then
echo "Preparing to export to remote host!"; echo
send_dir=`basename ${HTML_DIR}`
tar cvf ${send_dir}.tar ${send_dir}
ssh ${RUSER}@${RHOST} "mkdir -p ${RWWWD}"
scp ${send_dir}.tar ${RUSER}@${RHOST}:${RWWWD}/
ssh ${RUSER}@${RHOST} "cd ${RWWWD}/; rm -rf ${send_dir}; tar xf ${send_dir}.tar 2>/dev/null; rm -f ${send_dir}.tar; \
chmod -R a+r ${send_dir}; cd ${send_dir}/"
echo; echo
echo "Diagnostic page installed on http://${RHOST}${RWWWD}/${send_dir}/ !"
echo "( Also browsable on local host in ${DIAG_D}/${send_dir} )"
rm -f ${send_dir}.tar
else
if [ ${ihttp} -eq 0 ]; then
echo "Diagnostic page installed in ${HTML_DIR}/"
echo " => you can view it with a web browser..."
else
echo "Error: \"ihttp\" must be either 0 or 1 !"
fi
fi
echo; echo
rm -rf *.eps
else
echo
echo "Diagnostics built and saved! (${DIAG_D})"
echo "Re-Run \"${script}.sh\" adding the \"-e\" or \"-E\" switch to create figure and HTML page..."
echo
fi
##!!TA rm -rf ${TMP_DIR} 2>/dev/null ; #debug
date
echo