snowtools 2.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. cenutils/put +278 -0
  2. snowtools/DATA/EMOS_HN.Rdata +0 -0
  3. snowtools/DATA/FORCING_test_base.nc +0 -0
  4. snowtools/DATA/METADATA.xml +18793 -0
  5. snowtools/DATA/OPER/cron_belenos +49 -0
  6. snowtools/DATA/OPER/cron_sxcen +4 -0
  7. snowtools/DATA/OPTIONS_V8.1_NEW_OUTPUTS_NC.nam +290 -0
  8. snowtools/DATA/OPTIONS_V8.1_NEW_OUTPUTS_NC_OPER.nam +291 -0
  9. snowtools/DATA/OPTIONS_V8.1_NEW_OUTPUTS_NC_SYTRON.nam +293 -0
  10. snowtools/DATA/OPTIONS_V8.1_NEW_OUTPUTS_NC_reanalysis.nam +289 -0
  11. snowtools/DATA/OPTIONS_V8.1_NEW_OUTPUTS_NC_reanalysis_avalanches.nam +287 -0
  12. snowtools/DATA/OPTIONS_V8.1_NEW_OUTPUTS_NC_reanalysis_forprep.nam +282 -0
  13. snowtools/DATA/OPTIONS_V8.1_NEW_OUTPUTS_NC_reforecast.nam +287 -0
  14. snowtools/DATA/OPTIONS_V8_NEW_OUTPUTS_NC.nam +223 -0
  15. snowtools/DATA/OPTIONS_test_2d.nam +149 -0
  16. snowtools/DATA/OPTIONS_test_2d_pappus.nam +150 -0
  17. snowtools/DATA/PGD_test_2d.nc +0 -0
  18. snowtools/DATA/__init__.py +39 -0
  19. snowtools/DATA/images.json +14 -0
  20. snowtools/DATA/interpolate_safran.nam +37 -0
  21. snowtools/DATA/liste_malgeolocalises.txt +92 -0
  22. snowtools/DATA/massifs.cpg +1 -0
  23. snowtools/DATA/massifs.dbf +0 -0
  24. snowtools/DATA/massifs.prj +1 -0
  25. snowtools/DATA/massifs.shp +0 -0
  26. snowtools/DATA/massifs.shx +0 -0
  27. snowtools/DATA/perturbations_param.txt +10 -0
  28. snowtools/DATA/reanalyse.ini +10 -0
  29. snowtools/DATA/sta_skylines.csv +47808 -0
  30. snowtools/__init__.py +0 -0
  31. snowtools/conf/S2M_Standard_Metadata.ini +62 -0
  32. snowtools/conf/extraction_guess_safran.ini +46 -0
  33. snowtools/conf/extraction_guess_safran_reforecast.ini +23 -0
  34. snowtools/conf/s2m_alp.ini +162 -0
  35. snowtools/conf/s2m_alp_allslopes.ini +33 -0
  36. snowtools/conf/s2m_alp_pp.ini +8 -0
  37. snowtools/conf/s2m_cor.ini +151 -0
  38. snowtools/conf/s2m_cor_allslopes.ini +33 -0
  39. snowtools/conf/s2m_jur.ini +162 -0
  40. snowtools/conf/s2m_mac.ini +162 -0
  41. snowtools/conf/s2m_postes.ini +73 -0
  42. snowtools/conf/s2m_prosnow.ini +23 -0
  43. snowtools/conf/s2m_pyr.ini +151 -0
  44. snowtools/conf/s2m_pyr_allslopes.ini +33 -0
  45. snowtools/conf/s2m_vog.ini +162 -0
  46. snowtools/conf/s2mdevnew_alp.ini +162 -0
  47. snowtools/conf/s2mdevnew_cor.ini +151 -0
  48. snowtools/conf/s2mdevnew_jur.ini +162 -0
  49. snowtools/conf/s2mdevnew_mac.ini +162 -0
  50. snowtools/conf/s2mdevnew_postes.ini +73 -0
  51. snowtools/conf/s2mdevnew_pyr.ini +151 -0
  52. snowtools/conf/s2mdevnew_vog.ini +162 -0
  53. snowtools/conf/safran.ini +81 -0
  54. snowtools/conf/safran_reanalysis.ini +58 -0
  55. snowtools/conf/safran_reforecast.ini +63 -0
  56. snowtools/interpolation/DEM.nc +0 -0
  57. snowtools/interpolation/Makefile +57 -0
  58. snowtools/interpolation/Makefile_belenos +61 -0
  59. snowtools/interpolation/Makefile_pc +57 -0
  60. snowtools/interpolation/Makefile_pc_mag6 +56 -0
  61. snowtools/interpolation/Netcdf_add_massif_info.py +155 -0
  62. snowtools/interpolation/ReadMe +33 -0
  63. snowtools/interpolation/__init__.py +0 -0
  64. snowtools/interpolation/interpolate_safran.f90 +2341 -0
  65. snowtools/interpolation/modd_interpol_safran.f90 +28 -0
  66. snowtools/interpolation/modn_interpol_safran.f90 +68 -0
  67. snowtools/interpolation/shapefile2NetCDF.py +804 -0
  68. snowtools/interpolation/shapefile2NetCDF_2D.py +460 -0
  69. snowtools/plots/__init__.py +0 -0
  70. snowtools/plots/abstracts/__init__.py +0 -0
  71. snowtools/plots/abstracts/figures.py +86 -0
  72. snowtools/plots/boxplots/__init__.py +0 -0
  73. snowtools/plots/boxplots/boxplots.py +181 -0
  74. snowtools/plots/compare.py +279 -0
  75. snowtools/plots/logos/logoMF15.jpg +0 -0
  76. snowtools/plots/maps/__init__.py +0 -0
  77. snowtools/plots/maps/cartopy.py +2051 -0
  78. snowtools/plots/pearps2m/__init__.py +0 -0
  79. snowtools/plots/pearps2m/postprocess.py +1259 -0
  80. snowtools/plots/pearps2m/secure_graph_prod.py +21 -0
  81. snowtools/plots/stratiprofile/Dictionnaries.py +66 -0
  82. snowtools/plots/stratiprofile/__init__.py +0 -0
  83. snowtools/plots/stratiprofile/gen_GUI_selfcontain.sh +219 -0
  84. snowtools/plots/stratiprofile/gui_elements.py +576 -0
  85. snowtools/plots/stratiprofile/procompare.py +96 -0
  86. snowtools/plots/stratiprofile/procompare_gui.py +435 -0
  87. snowtools/plots/stratiprofile/profilPlot.py +539 -0
  88. snowtools/plots/stratiprofile/proplotter.png +0 -0
  89. snowtools/plots/stratiprofile/proplotter.py +134 -0
  90. snowtools/plots/stratiprofile/proplotter_functions.py +402 -0
  91. snowtools/plots/stratiprofile/proplotter_gui.py +939 -0
  92. snowtools/plots/stratiprofile/proplotter_test_procedure.md +73 -0
  93. snowtools/plots/stratiprofile/proreader.py +984 -0
  94. snowtools/plots/stratiprofile/test_proreader.py +29 -0
  95. snowtools/plots/temporal/__init__.py +0 -0
  96. snowtools/plots/temporal/chrono.py +338 -0
  97. snowtools/plots/temporal/compare_sims.py +112 -0
  98. snowtools/plots/temporal/demo.py +146 -0
  99. snowtools/plots/temporal/energybudget.py +275 -0
  100. snowtools/plots/temporal/escroc_plot.py +245 -0
  101. snowtools/plots/temporal/impact_comod.py +116 -0
  102. snowtools/scores/CompareSimuPosteObsCsv.py +640 -0
  103. snowtools/scores/__init__.py +0 -0
  104. snowtools/scores/deterministic.py +292 -0
  105. snowtools/scores/ensemble.py +260 -0
  106. snowtools/scores/generic.py +70 -0
  107. snowtools/scores/list_scores.py +128 -0
  108. snowtools/scripts/ESMSnowMIP/ESM_snowmip.py +163 -0
  109. snowtools/scripts/ESMSnowMIP/__init__.py +0 -0
  110. snowtools/scripts/ESMSnowMIP/post_snowmip.py +129 -0
  111. snowtools/scripts/__init__.py +0 -0
  112. snowtools/scripts/create_forcing/Template_creation_FORCING.py +213 -0
  113. snowtools/scripts/create_forcing/__init__.py +0 -0
  114. snowtools/scripts/create_forcing/forcing_assembly_line.py +166 -0
  115. snowtools/scripts/extract/__init__.py +0 -0
  116. snowtools/scripts/extract/bdap/Extraction_BDAP.py +296 -0
  117. snowtools/scripts/extract/get_pearome4edelweiss.py +65 -0
  118. snowtools/scripts/extract/obs/__init__.py +0 -0
  119. snowtools/scripts/extract/obs/bdquery.py +217 -0
  120. snowtools/scripts/extract/obs/extract_htn_vosges.py +82 -0
  121. snowtools/scripts/extract/obs/extract_obs.py +99 -0
  122. snowtools/scripts/extract/obs/extract_obs_allhtn.py +80 -0
  123. snowtools/scripts/extract/obs/extract_obs_ange.py +80 -0
  124. snowtools/scripts/extract/obs/extract_obs_chasseneige.py +52 -0
  125. snowtools/scripts/extract/obs/extract_obs_meteo.py +157 -0
  126. snowtools/scripts/extract/obs/extract_obs_meteo_mb.py +38 -0
  127. snowtools/scripts/extract/obs/extract_obs_neigefraiche.py +42 -0
  128. snowtools/scripts/extract/obs/extract_obs_nivometeo.py +156 -0
  129. snowtools/scripts/extract/obs/extract_pluvios.py +55 -0
  130. snowtools/scripts/extract/obs/extract_pluvios_antilope.py +47 -0
  131. snowtools/scripts/extract/obs/extract_pluvios_clim_antilopeJP1.py +54 -0
  132. snowtools/scripts/extract/vortex/get_archive_reforecast.py +142 -0
  133. snowtools/scripts/extract/vortex/get_escroc.py +139 -0
  134. snowtools/scripts/extract/vortex/get_reanalysis.py +222 -0
  135. snowtools/scripts/extract/vortex/get_reforecast.py +149 -0
  136. snowtools/scripts/extract/vortex/vortexIO.py +378 -0
  137. snowtools/scripts/metadata/__init__.py +0 -0
  138. snowtools/scripts/metadata/add_newmask.py +54 -0
  139. snowtools/scripts/metadata/creeMETADATA_postes.py +160 -0
  140. snowtools/scripts/metadata/extract_mask.py +109 -0
  141. snowtools/scripts/metadata/extract_metadata.py +68 -0
  142. snowtools/scripts/metadata/gen_metadata_massif_file.py +84 -0
  143. snowtools/scripts/post_processing/compute_sentinel2_diagnostics.py +169 -0
  144. snowtools/tasks/__init__.py +0 -0
  145. snowtools/tasks/crocO_vortex_kitchen.py +63 -0
  146. snowtools/tasks/lance_safran.py +87 -0
  147. snowtools/tasks/oper/__init__.py +0 -0
  148. snowtools/tasks/oper/ensemble_surfex_tasks_analysis.py +20 -0
  149. snowtools/tasks/oper/ensemble_surfex_tasks_common.py +536 -0
  150. snowtools/tasks/oper/ensemble_surfex_tasks_forecast.py +105 -0
  151. snowtools/tasks/oper/get_monthly_reanalysis.py +173 -0
  152. snowtools/tasks/oper/get_oper_files.py +394 -0
  153. snowtools/tasks/oper/iga/__init__.py +0 -0
  154. snowtools/tasks/oper/iga/conf/dble/s2m_alp.ini +161 -0
  155. snowtools/tasks/oper/iga/conf/dble/s2m_cor.ini +150 -0
  156. snowtools/tasks/oper/iga/conf/dble/s2m_jur.ini +161 -0
  157. snowtools/tasks/oper/iga/conf/dble/s2m_mac.ini +161 -0
  158. snowtools/tasks/oper/iga/conf/dble/s2m_postes.ini +72 -0
  159. snowtools/tasks/oper/iga/conf/dble/s2m_pyr.ini +150 -0
  160. snowtools/tasks/oper/iga/conf/dble/s2m_vog.ini +161 -0
  161. snowtools/tasks/oper/iga/conf/s2m_alp.ini +168 -0
  162. snowtools/tasks/oper/iga/conf/s2m_cor.ini +157 -0
  163. snowtools/tasks/oper/iga/conf/s2m_jur.ini +167 -0
  164. snowtools/tasks/oper/iga/conf/s2m_mac.ini +167 -0
  165. snowtools/tasks/oper/iga/conf/s2m_postes.ini +84 -0
  166. snowtools/tasks/oper/iga/conf/s2m_pyr.ini +156 -0
  167. snowtools/tasks/oper/iga/conf/s2m_vog.ini +167 -0
  168. snowtools/tasks/oper/iga/ensemble_surfex_tasks_analysis.py +26 -0
  169. snowtools/tasks/oper/iga/ensemble_surfex_tasks_bdpe.py +231 -0
  170. snowtools/tasks/oper/iga/ensemble_surfex_tasks_common.py +524 -0
  171. snowtools/tasks/oper/iga/ensemble_surfex_tasks_forecast.py +110 -0
  172. snowtools/tasks/oper/iga/monthly_surfex_reanalysis.py +398 -0
  173. snowtools/tasks/oper/iga/prepsafran_analyse.py +369 -0
  174. snowtools/tasks/oper/iga/prepsafran_prevision.py +240 -0
  175. snowtools/tasks/oper/iga/rapatrie.py +180 -0
  176. snowtools/tasks/oper/iga/recextfiles.py +23 -0
  177. snowtools/tasks/oper/iga/recextfiles_monthly.py +21 -0
  178. snowtools/tasks/oper/iga/safran_analyse_ensemble.py +824 -0
  179. snowtools/tasks/oper/iga/safran_prevision_ensemble.py +551 -0
  180. snowtools/tasks/oper/iga_now/conf/s2m_alp.ini +150 -0
  181. snowtools/tasks/oper/iga_now/conf/s2m_cor.ini +138 -0
  182. snowtools/tasks/oper/iga_now/conf/s2m_postes.ini +85 -0
  183. snowtools/tasks/oper/iga_now/conf/s2m_pyr.ini +139 -0
  184. snowtools/tasks/oper/monthly_surfex_reanalysis.py +413 -0
  185. snowtools/tasks/oper/monthly_surfex_reanalysis_sytron.py +330 -0
  186. snowtools/tasks/oper/prepsaf_prosnow.py +147 -0
  187. snowtools/tasks/oper/prepsafran_analyse.py +358 -0
  188. snowtools/tasks/oper/prepsafran_prevision.py +254 -0
  189. snowtools/tasks/oper/prepsafran_reanalyse.py +180 -0
  190. snowtools/tasks/oper/refill_guess_safran.py +340 -0
  191. snowtools/tasks/oper/safran_analyse_ensemble.py +881 -0
  192. snowtools/tasks/oper/safran_prevision_ensemble.py +641 -0
  193. snowtools/tasks/oper/safran_prosnow.py +383 -0
  194. snowtools/tasks/research/__init__.py +0 -0
  195. snowtools/tasks/research/crocO/__init__.py +0 -0
  196. snowtools/tasks/research/crocO/crocO_common.py +481 -0
  197. snowtools/tasks/research/crocO/crocO_driver.py +53 -0
  198. snowtools/tasks/research/crocO/crocO_offline.py +326 -0
  199. snowtools/tasks/research/crocO/crocO_perturb.py +149 -0
  200. snowtools/tasks/research/crocO/crocO_soda.py +168 -0
  201. snowtools/tasks/research/edelweiss/__init__.py +0 -0
  202. snowtools/tasks/research/edelweiss/make_forcing.py +154 -0
  203. snowtools/tasks/research/prosnow/__init__.py +0 -0
  204. snowtools/tasks/research/prosnow/prosnow_LT_forecast.py +493 -0
  205. snowtools/tasks/research/prosnow/prosnow_LT_hindcast.py +322 -0
  206. snowtools/tasks/research/prosnow/prosnow_ST_forecast.py +479 -0
  207. snowtools/tasks/research/prosnow/prosnow_analysis.py +505 -0
  208. snowtools/tasks/research/prosnow/prosnow_init.py +396 -0
  209. snowtools/tasks/research/safran/__init__.py +0 -0
  210. snowtools/tasks/research/safran/prepsaf_reana.py +292 -0
  211. snowtools/tasks/research/safran/prepsafran_analyse.py +166 -0
  212. snowtools/tasks/research/safran/prepsafran_reanalysis.py +381 -0
  213. snowtools/tasks/research/safran/prepsafran_reforecast.py +407 -0
  214. snowtools/tasks/research/safran/refill_reforecast.py +113 -0
  215. snowtools/tasks/research/safran/safran_analysis.py +881 -0
  216. snowtools/tasks/research/safran/safran_reanalysis.py +776 -0
  217. snowtools/tasks/research/safran/safran_reanalysis_era5.py +654 -0
  218. snowtools/tasks/research/safran/safran_reforecast.py +568 -0
  219. snowtools/tasks/research/surfex/__init__.py +0 -0
  220. snowtools/tasks/research/surfex/crps_task.py +110 -0
  221. snowtools/tasks/research/surfex/diag_sentinel2.py +119 -0
  222. snowtools/tasks/research/surfex/ensemble_surfex_reforecast.py +429 -0
  223. snowtools/tasks/research/surfex/escroc_tasks.py +476 -0
  224. snowtools/tasks/research/surfex/interpol_task.py +285 -0
  225. snowtools/tasks/research/surfex/refill_surfex_output.py +619 -0
  226. snowtools/tasks/research/surfex/scores_task.py +109 -0
  227. snowtools/tasks/research/surfex/surfex_task.py +985 -0
  228. snowtools/tasks/runs.py +429 -0
  229. snowtools/tasks/s2m_command.py +559 -0
  230. snowtools/tasks/s2m_launcher.py +70 -0
  231. snowtools/tasks/vortex_kitchen.py +1046 -0
  232. snowtools/tests/__init__.py +0 -0
  233. snowtools/tests/export_output.py +18 -0
  234. snowtools/tests/namelists/namelist_axel_aaron.nam +358 -0
  235. snowtools/tests/namelists/namelist_base.nam +289 -0
  236. snowtools/tests/namelists/namelist_impur1.nam +305 -0
  237. snowtools/tests/namelists/namelist_impur2.nam +305 -0
  238. snowtools/tests/namelists/namelist_multiphy1.nam +294 -0
  239. snowtools/tests/namelists/namelist_multiphy2.nam +294 -0
  240. snowtools/tests/namelists/namelist_multiphy3.nam +294 -0
  241. snowtools/tests/namelists/namelist_pappus_1.nam +291 -0
  242. snowtools/tests/namelists/namelist_prep_impur.nam +317 -0
  243. snowtools/tests/namelists/namelist_resort1.nam +300 -0
  244. snowtools/tests/namelists/namelist_snowdrift1.nam +295 -0
  245. snowtools/tests/namelists/namelist_snowdrift2.nam +295 -0
  246. snowtools/tests/namelists/namelist_snowdrift3.nam +295 -0
  247. snowtools/tests/s2m_instance.py +31 -0
  248. snowtools/tests/tempfolder.py +90 -0
  249. snowtools/tests/test_Netcdf_add_massif_info.py +30 -0
  250. snowtools/tests/test_cartopy_plots.py +417 -0
  251. snowtools/tests/test_cartopy_plots_index_template.html +204 -0
  252. snowtools/tests/test_comp_surfex.py +78 -0
  253. snowtools/tests/test_dev_surfex.py +178 -0
  254. snowtools/tests/test_postprocess.py +42 -0
  255. snowtools/tests/test_prosimu.py +253 -0
  256. snowtools/tests/test_s2m.py +60 -0
  257. snowtools/tests/test_script_create_forcing.py +74 -0
  258. snowtools/tests/test_soda/OBSERVATIONS_140225H06.nc +0 -0
  259. snowtools/tests/test_soda/OPTIONS.nam +341 -0
  260. snowtools/tests/test_soda/PGD.nc +0 -0
  261. snowtools/tests/test_soda/PREP.nc +0 -0
  262. snowtools/tests/test_soda/__init__.py +0 -0
  263. snowtools/tests/test_soda/test_soda.sh +34 -0
  264. snowtools/tools/VizForEnsemble.py +111 -0
  265. snowtools/tools/__init__.py +0 -0
  266. snowtools/tools/change_forcing.py +1157 -0
  267. snowtools/tools/change_prep.py +248 -0
  268. snowtools/tools/combine_memberfiles.py +139 -0
  269. snowtools/tools/emosCSG.py +268 -0
  270. snowtools/tools/execute.py +70 -0
  271. snowtools/tools/get_requirements.sh +26 -0
  272. snowtools/tools/initTG.py +150 -0
  273. snowtools/tools/massif_diags.py +107 -0
  274. snowtools/tools/param_baseline.txt +11 -0
  275. snowtools/tools/perturb_forcing.py +322 -0
  276. snowtools/tools/read_conf.py +154 -0
  277. snowtools/tools/special_diags.py +55 -0
  278. snowtools/tools/update_namelist.py +362 -0
  279. snowtools/utils/ESCROCsubensembles.py +657 -0
  280. snowtools/utils/FileException.py +338 -0
  281. snowtools/utils/Met2Netcdf.py +665 -0
  282. snowtools/utils/S2M_standard_file.py +464 -0
  283. snowtools/utils/__init__.py +0 -0
  284. snowtools/utils/dates.py +264 -0
  285. snowtools/utils/git.py +421 -0
  286. snowtools/utils/infomassifs.py +519 -0
  287. snowtools/utils/obscsv.py +157 -0
  288. snowtools/utils/operational_reproductibility/__init__.py +0 -0
  289. snowtools/utils/operational_reproductibility/compare2versions.py +626 -0
  290. snowtools/utils/operational_reproductibility/extractallproducts.py +121 -0
  291. snowtools/utils/prosimu.py +1029 -0
  292. snowtools/utils/read_snowpack.py +361 -0
  293. snowtools/utils/resources.py +317 -0
  294. snowtools/utils/shapefile.py +1168 -0
  295. snowtools/utils/skyline/__init__.py +0 -0
  296. snowtools/utils/skyline/skyline_bdclim.py +220 -0
  297. snowtools/utils/sun.py +440 -0
  298. snowtools-2.0.1.dist-info/LICENCE-en.txt +517 -0
  299. snowtools-2.0.1.dist-info/LICENCE.txt +521 -0
  300. snowtools-2.0.1.dist-info/METADATA +623 -0
  301. snowtools-2.0.1.dist-info/RECORD +304 -0
  302. snowtools-2.0.1.dist-info/WHEEL +5 -0
  303. snowtools-2.0.1.dist-info/entry_points.txt +4 -0
  304. snowtools-2.0.1.dist-info/top_level.txt +2 -0
cenutils/put ADDED
@@ -0,0 +1,278 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+
6
+ #######################################################################
7
+ # Help #
8
+ #######################################################################
9
+
10
+ function usage()
11
+ {
12
+ echo "Script to synchronize the codes between your computer"
13
+ echo "and servers (vortex, snowtools, other codes)"
14
+ echo ""
15
+ echo "$0 [options] folder server"
16
+ echo ""
17
+ echo -e "options:"
18
+ echo -e "\t-h --help : help"
19
+ # echo -e "\t--no-delete : Do not delete files on destination (not implemented)"
20
+ echo -e "\t-f --force : Do not ask for confirmation"
21
+ echo -e "\t--ftp : Use lftp/mirror to transfer files instead of rsync"
22
+ echo -e ""
23
+ echo -e "folder:"
24
+ echo -e "\tThe code folder to synchronize"
25
+ echo -e "\tAlso accept 'snowtools', 'surfex' and 'vortex' if"
26
+ echo -e "\tenvironment variables SNOWTOOLS_CEN, EXESURFEX and"
27
+ echo -e "\tVORTEX are defined"
28
+ echo -e ""
29
+ echo -e "server:"
30
+ echo -e "\tThe server on which the code should be sent"
31
+ echo -e ""
32
+ }
33
+
34
+ #######################################################################
35
+ # Colored terms #
36
+ #######################################################################
37
+
38
+ if [[ -t 1 ]]
39
+ then
40
+ GREEN="\033[32m"
41
+ ORANGE="\033[1;33m"
42
+ RED="\033[1;31m"
43
+ STOPC="\033[0m"
44
+ else
45
+ GREEN=""
46
+ ORANGE=""
47
+ RED=""
48
+ STOPC=""
49
+ fi
50
+
51
+ #######################################################################
52
+ # Parsing arguments #
53
+ #######################################################################
54
+ FOLDER='x'
55
+ SERVER='x'
56
+ FORCE=0
57
+ METHOD='Rsync'
58
+ while [[ $# -gt 0 ]]
59
+ do
60
+ key="$1"
61
+
62
+ case $key in
63
+ -h|--help)
64
+ usage
65
+ exit 0
66
+ ;;
67
+ -f|--force)
68
+ FORCE=1
69
+ shift
70
+ ;;
71
+ --ftp)
72
+ METHOD='LFTP'
73
+ shift
74
+ ;;
75
+ -*)
76
+ echo -e "${RED}ERROR${STOPC}: Unknown argument $1"
77
+ echo ""
78
+ usage
79
+ exit 3
80
+ ;;
81
+ *) # Folder or server
82
+ if [ "$FOLDER" = "x" ]
83
+ then
84
+ FOLDER="$1"
85
+ else
86
+ SERVER="$1"
87
+ fi
88
+ shift # shift to next argument
89
+ ;;
90
+ esac
91
+ done
92
+
93
+ #######################################################################
94
+ # Check arguments #
95
+ #######################################################################
96
+ # We need at least folder and server
97
+
98
+
99
+ if [ "$SERVER" = "x" ]
100
+ then
101
+ echo -e "${RED}ERROR${STOPC}: Argument server not provided"
102
+ echo ""
103
+ usage
104
+ exit 3
105
+ fi
106
+
107
+ # Check FOLDER : is it a known repository ? Or a valid folder ?
108
+
109
+ case $FOLDER in
110
+ x)
111
+ echo -e "${RED}ERROR${STOPC}: Argument folder not provided"
112
+ echo ""
113
+ usage
114
+ exit 3
115
+ ;;
116
+ vortex)
117
+ if [ ! -d "$FOLDER" ]
118
+ then
119
+ FOLDER="$VORTEX"
120
+ fi
121
+ ;;
122
+ snowtools)
123
+ if [ ! -d "$FOLDER" ]
124
+ then
125
+ FOLDER="$SNOWTOOLS_CEN"
126
+ fi
127
+ ;;
128
+ surfex)
129
+ if [ ! -d "$FOLDER" ]
130
+ then
131
+ FOLDER=`dirname $EXESURFEX`
132
+ fi
133
+ ;;
134
+ esac
135
+
136
+ if [ ! -d "$FOLDER" ]
137
+ then
138
+ echo -e "${RED}ERROR${STOPC}: Folder $FOLDER is incorrect"
139
+ echo ""
140
+ usage
141
+ exit 3
142
+ fi
143
+
144
+ # Pre-processing of FOLDER variable : remove $HOME at begining
145
+ FOLDER=`realpath "$FOLDER"`
146
+ if $(echo `realpath SURFEX` | grep -q "^$HOME")
147
+ then # The folder to treat is a subfolder of $HOME : OK
148
+ FOLDER_FROM_HOME=`echo "$FOLDER" | sed -e "s#^$HOME/##"`
149
+ else
150
+ echo -e "${RED}ERROR${STOPC}: This script is not designed to deal with folders that are not in your home !"
151
+ echo "Provided folder $FOLDER is not in your home."
152
+ echo ""
153
+ exit 3
154
+ fi
155
+
156
+ #######################################################################
157
+ # File transfer #
158
+ #######################################################################
159
+
160
+ folder_dest=$FOLDER_FROM_HOME
161
+ folder_orig=$HOME/$FOLDER_FROM_HOME/
162
+
163
+ # Confirmation
164
+ if [ $FORCE -eq 0 ]
165
+ then
166
+ echo "> $METHOD transfer folder ~/$FOLDER_FROM_HOME on $SERVER (~/$folder_dest)"
167
+ read -p "Is this correct [Y/n] ? " -n 1 -r CHOICE
168
+ echo ""
169
+ if [[ $CHOICE =~ ^[nN]$ ]]
170
+ then
171
+ echo -e "Aborting."
172
+ exit 0
173
+ fi
174
+ fi
175
+
176
+ # Git management : transfer a minimal information on git status
177
+ # on the destination in the ofr of a simple .git_info file.
178
+ GIT_INFO_ADDED=1
179
+ pushd $folder_orig > /dev/null
180
+ if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]
181
+ then
182
+ GIT_PRETTYLOG=`git log -1 --date=format:'%Y-%m-%d' --format='%h (%cd)'`
183
+ GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
184
+ if git status --porcelain --untracked-files=no | grep -q 'M'
185
+ then
186
+ GIT_MODIFIED=' +'
187
+ else
188
+ GIT_MODIFIED=''
189
+ fi
190
+ GIT_STR="$GIT_PRETTYLOG $GIT_BRANCH$GIT_MODIFIED"
191
+ echo "$GIT_STR" > "${folder_orig}/.git_info"
192
+ GIT_INFO_ADDED=0
193
+ fi
194
+ popd > /dev/null
195
+
196
+ # Actual transfer
197
+ if [ "$METHOD" = "Rsync" ]
198
+ then
199
+ set +e
200
+ # --delete-excluded --force (force deletion of dirs even if not empty)
201
+ rsync -av --links --delete \
202
+ --exclude .git \
203
+ --exclude .idea \
204
+ --exclude .settings \
205
+ --exclude "venv*" \
206
+ --exclude "*.pyc" --exclude "*.bak" --exclude "*.sav" --exclude "*.backup" \
207
+ --exclude ".*.swp" --exclude "*~" \
208
+ --exclude "*.egg-info" --exclude "*.o" --exclude "*.bin" --exclude "*.exe" \
209
+ --exclude fail_test --exclude Manual_tests --exclude "interpolation/*.mod" \
210
+ --exclude "interpolation/interpol_*" \
211
+ --exclude /exe --exclude "src/dir_obj*" --exclude "exe_*" \
212
+ --exclude 'profile_surfex' --exclude 'profile_surfex-LX*' \
213
+ --exclude "src/LIB/grib_api-*-Source" --exclude "src/LIB/eccodes*" --exclude STRATO \
214
+ $folder_orig $SERVER:$folder_dest
215
+ retcode=$?
216
+ set -e
217
+ elif [ "$METHOD" = "LFTP" ]
218
+ then
219
+ user=`id -u -n`
220
+ set +e
221
+ lftp -c "set ftp:list-options -a;
222
+ open -u $user@$SERVER -p 8021 ftp://137.129.13.180;
223
+ set ftp:passive-mode false;
224
+ set cmd:fail-exit true;
225
+ set ftp:use-utf8 false;
226
+ # Par defaut les logs sont dans ~/.local/share/lftp/transfer_log
227
+ set log:show-pid true;
228
+ set mirror:sort-by name;
229
+ set mirror:overwrite true;
230
+ lcd ./ ;
231
+ cd $HOME;
232
+ mirror --reverse \
233
+ --delete --use-cache --verbose \
234
+ --allow-chown --allow-suid --no-umask --parallel=2 \
235
+ --exclude .git/ \
236
+ --exclude .idea/ \
237
+ --exclude .settings/ \
238
+ --exclude fail_test \
239
+ --exclude Manual_tests \
240
+ --exclude interpolation/interpol_MPIAUTO \
241
+ --exclude exe/ \
242
+ --exclude-glob exe_*/ \
243
+ --exclude 'profile_surfex' \
244
+ --exclude-glob interpolation/*.mod \
245
+ --exclude-glob venv* \
246
+ --exclude-glob *.pyc \
247
+ --exclude-glob *.bak \
248
+ --exclude-glob *.sav \
249
+ --exclude-glob *.backup \
250
+ --exclude-glob .*.swp \
251
+ --exclude-glob *~ \
252
+ --exclude-glob *.egg-info \
253
+ --exclude-glob *.o \
254
+ --exclude-glob *.bin \
255
+ --exclude-glob *.exe \
256
+ --exclude-glob src/dir_obj*/ \
257
+ --exclude-glob 'profile_surfex-LX*' \
258
+ --exclude-glob src/LIB/grib_api-*-Source/ \
259
+ --exclude-glob src/LIB/eccodes*/ \
260
+ --exclude-glob src/LIB/eccodes* \
261
+ --exclude STRATO \
262
+ $folder_orig $folder_dest"
263
+ retcode=$?
264
+ set -e
265
+ fi
266
+
267
+ # Cleaning eventual git file added
268
+ if [ $GIT_INFO_ADDED -eq 0 ]
269
+ then
270
+ rm "${folder_orig}/.git_info"
271
+ fi
272
+
273
+ if [ $retcode -eq 0 ]
274
+ then
275
+ echo -e "${GREEN}OK${STOPC}: Transfer successful."
276
+ else
277
+ echo -e "${RED}ERROR${STOPC}: An error occured during code synchronization. Please refer to output log above. (Return code $retcode)"
278
+ fi
Binary file
Binary file