create_tarball.sh 7.95 KB
Newer Older
1
#!/bin/bash
2
# Ignacio Pisso, May 2017 
Ignacio Pisso's avatar
Ignacio Pisso committed
3
# Changes 2018-2019
4

Ignacio Pisso's avatar
Ignacio Pisso committed
5
echo CREATE A NEW FLEXPART DISTRIBUTION
Ignacio Pisso's avatar
Ignacio Pisso committed
6

7
# get current commit hash
Ignacio Pisso's avatar
Ignacio Pisso committed
8
githash=$(git rev-parse --short --verify HEAD)
Ignacio Pisso's avatar
Ignacio Pisso committed
9
echo githash $githash 
10
11
#define version number with hash
version=10.4_$githash
Ignacio Pisso's avatar
Ignacio Pisso committed
12
echo version $version  
13

14
# define tarball name
Ignacio Pisso's avatar
Ignacio Pisso committed
15
targetdir=../flexpart_distribution/
Ignacio Pisso's avatar
Ignacio Pisso committed
16
17
echo targetdir $targetdir

18
# name distribution version
Ignacio Pisso's avatar
Ignacio Pisso committed
19
20
distribution_name=flexpart_v$version

21
# name distribution temporary dir
Ignacio Pisso's avatar
Ignacio Pisso committed
22
23
24
tarball_tmp=${targetdir}flexpart_v$version
echo tarball_tmp $tarball_tmp

25
# name distribution tarball file
Ignacio Pisso's avatar
Ignacio Pisso committed
26
27
#tarball=${targetdir}flexpart_v$version.tar 
tarball=${tarball_tmp}.tar 
Ignacio Pisso's avatar
Ignacio Pisso committed
28
echo tarball $tarball
29

30
# if needed clean old package
Ignacio Pisso's avatar
Ignacio Pisso committed
31
if [ -d $tarball_tmp ]; then
Ignacio Pisso's avatar
Ignacio Pisso committed
32
33
34
35
36
37
38
39
40
41
42
  echo
  echo clean old tarball
  hora=$(date +"%Y-%m-%d_%H%M%S")
  tarball_tmp_bk=$tarball_tmp$tarball_tmp_$hora
  echo tarball_tmp=$tarball_tmp exists: move to tarball_tmp_bk=$tarball_tmp_bk #and exit  
  mkdir $tarball_tmp_bk 
  mv $tarball_tmp $tarball_tmp_bk/ 
  mv $tarball $tarball_tmp_bk/ 
  #exit 
  echo old files moved to tarball_tmp_bk=$tarball_tmp_bk 
  echo
Ignacio Pisso's avatar
Ignacio Pisso committed
43
44
fi

45
46
47
48
49
50
51
# start packing
## needs in addition to the git repo ANCILLARY git repos
# VERIFY THESE RESOURCES EXIST BEFORE PACKING DISTRIBUTION
#1 OH file OH_variables.bin || OH_variables=../flexin/OH_FIELDS/OH_variables.bin
#2 flex_extract || flex_extract=../flex_extract_v7.0.4/
#3 flex_read_fortran from ../flex_read_matlab/export_basic  TODO: add functions to ../flex_read_matlab/export/ 
#  flex_read_matlab_src=../flex_read_matlab/export_basic
Ignacio Pisso's avatar
Ignacio Pisso committed
52
#4 tests/examples ../flex_tests_examples/examples/*
53
54
55
56
57




# mkdir container
Ignacio Pisso's avatar
Ignacio Pisso committed
58
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
59
echo ')' create basis dir $tarball_tmp
60
mkdir $tarball_tmp
Ignacio Pisso's avatar
Ignacio Pisso committed
61
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
62
63
64

echo

65
# patnames
Ignacio Pisso's avatar
Ignacio Pisso committed
66
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
67
echo ')' copy pathnames 
Ignacio Pisso's avatar
Ignacio Pisso committed
68
69
cp pathnames $tarball_tmp/pathnames
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
70
71
72

echo 

73
# fortran source files
Ignacio Pisso's avatar
Ignacio Pisso committed
74
75
echo ---------------------------------------------------------
echo ')' copy src/
76
77
mkdir $tarball_tmp/src
cp src/*.f90 $tarball_tmp/src
78
cp -r src/gributils $tarball_tmp/src 
79
cp src/makefile $tarball_tmp/src
Ignacio Pisso's avatar
Ignacio Pisso committed
80
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
81
82
83

echo

84
# options dir
Ignacio Pisso's avatar
Ignacio Pisso committed
85
86
echo ---------------------------------------------------------
echo ')' copy options/ 
87
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
88
89
90
91
92
93
94
95
96
97
mkdir $tarball_tmp/options
user_input_files="AGECLASSES     COMMAND        IGBP_int1.dat  OUTGRID        OUTGRID_NEST   RECEPTORS      RELEASES       surfdata.t     surfdepo.t"
for i in $user_input_files
do
  echo $i
  cp -r options/$i $tarball_tmp/options
done
mkdir $tarball_tmp/options/SPECIES
cp options/SPECIES/SPECIES* $tarball_tmp/options/SPECIES/
cp options/SPECIES/specoverview.f90 $tarball_tmp/options/SPECIES/
Ignacio Pisso's avatar
Ignacio Pisso committed
98
echo copy options/SPECIES/ to $tarball_tmp/options/SPECIES/
99
100
101
echo ---------------------------------------------------------

echo
Ignacio Pisso's avatar
Ignacio Pisso committed
102

103
104
105
106
107
108
# OH file 
echo ---------------------------------------------------------
echo ')' copy OH_variables.bin to flexin 
mkdir $tarball_tmp/flexin
OH_variables=../flexin/OH_FIELDS/OH_variables.bin
cp $OH_variables $tarball_tmp/flexin/
Ignacio Pisso's avatar
Ignacio Pisso committed
109
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
110
111
112

echo

113
# AVAILABLE
Ignacio Pisso's avatar
Ignacio Pisso committed
114
115
echo ---------------------------------------------------------
echo ')' copy AVAILABLE
Ignacio Pisso's avatar
Ignacio Pisso committed
116
cp AVAILABLE $tarball_tmp/AVAILABLE
Ignacio Pisso's avatar
Ignacio Pisso committed
117
118
119
echo ---------------------------------------------------------

echo 
Ignacio Pisso's avatar
Ignacio Pisso committed
120

121
# output
Ignacio Pisso's avatar
Ignacio Pisso committed
122
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
123
echo  ')' create output/ #  mkdir $tarball_tmp/output
Ignacio Pisso's avatar
Ignacio Pisso committed
124
125
mkdir $tarball_tmp/output
echo ---------------------------------------------------------
126
127
echo output reference?
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
128

129
echo
Ignacio Pisso's avatar
Ignacio Pisso committed
130

131
# preprocess
Ignacio Pisso's avatar
Ignacio Pisso committed
132
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
133
echo ')' preprocess/
134
mkdir $tarball_tmp/preprocess
Ignacio Pisso's avatar
Ignacio Pisso committed
135
echo -----------------flex_extract-------------------
136
mkdir $tarball_tmp/preprocess/flex_extract
137
flex_extract=../flex_extract_v7.0.4/
Ignacio Pisso's avatar
Ignacio Pisso committed
138
139
echo include flex_extract v7.0.4 b7c1c04a204c91e53759ef590504bf52dfaece64
echo from $flex_extract [use git modules?] IP 3/2018 
140
141
142
143
144
cp $flex_extract/README.md $tarball_tmp/preprocess/flex_extract
cp -r $flex_extract/docs $tarball_tmp/preprocess/flex_extract
cp -r $flex_extract/grib_templates $tarball_tmp/preprocess/flex_extract
cp -r $flex_extract/python $tarball_tmp/preprocess/flex_extract
cp -r $flex_extract/src $tarball_tmp/preprocess/flex_extract
Ignacio Pisso's avatar
Ignacio Pisso committed
145
146
echo flex_extract copied
echo ---------------------------------------------------------
147
148
echo AVAILABLE generation scripts?
echo ---------------------------------------------------------
149

Ignacio Pisso's avatar
Ignacio Pisso committed
150
151
echo 

152
# postprocess
Ignacio Pisso's avatar
Ignacio Pisso committed
153
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
154
echo ')' postprocess/
Ignacio Pisso's avatar
Ignacio Pisso committed
155
156
157
158

postprocess=postprocess
mkdir $tarball_tmp/$postprocess
echo -----------------flex_read_fortran-------------------
159
flex_read_fortran_src=$postprocess/flex_read_fortran/
Ignacio Pisso's avatar
Ignacio Pisso committed
160
161
162
163
mkdir $tarball_tmp/$postprocess/flex_read_fortran
cp $postprocess/flex_read_fortran/*.f $tarball_tmp/$postprocess/flex_read_fortran
cp $postprocess/flex_read_fortran/*.f90 $tarball_tmp/$postprocess/flex_read_fortran
cp $postprocess/flex_read_fortran/makefile $tarball_tmp/$postprocess/flex_read_fortran
164
echo flex_read_fortran copied from $flex_read_fortran_src
Ignacio Pisso's avatar
Ignacio Pisso committed
165
166

echo -----------------flex_read_matlab-------------------
167
168
169
170
flex_read_matlab_src=../flex_read_matlab/export_basic
mkdir $tarball_tmp/$postprocess/flex_read_matlab
cp -r $flex_read_matlab_src/* $tarball_tmp/$postprocess/flex_read_matlab
echo flex_read_fortran from $flex_read_matlab_src  # NOT copied
Ignacio Pisso's avatar
Ignacio Pisso committed
171
echo ---------------------------------------------------------
172

Ignacio Pisso's avatar
Ignacio Pisso committed
173
echo
174

Ignacio Pisso's avatar
Ignacio Pisso committed
175
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
176
echo ')' tests/
Ignacio Pisso's avatar
Ignacio Pisso committed
177
#echo '13) tests' 
178
mkdir $tarball_tmp/tests
179
echo ----------------- examples -------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
180
181

mkdir $tarball_tmp/tests/examples
182
183
184
185
186
187
cp -r ../flex_tests_examples/examples3/* $tarball_tmp/tests/examples/

echo ----------------- examples_reference -------------------
cp -r ./tests/examples_reference $tarball_tmp/tests/

echo -----------------read examples-------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
188
189

mkdir $tarball_tmp/tests/read_examples
190
191
192
193
194

cp tests/read_examples/declare_examples $tarball_tmp/tests/read_examples/
cp tests/read_examples/display_examples.sh $tarball_tmp/tests/read_examples/
cp tests/read_examples/examples_output.txt $tarball_tmp/tests/read_examples/
cp tests/read_examples/read_examples.sh $tarball_tmp/tests/read_examples/
Ignacio Pisso's avatar
Ignacio Pisso committed
195
cp tests/read_examples/read_grids.sh $tarball_tmp/tests/read_examples/
196
197
198
cp tests/read_examples/read_parts.sh $tarball_tmp/tests/read_examples/
cp tests/read_examples/set_examples_all $tarball_tmp/tests/read_examples/
cp tests/read_examples/set_examples_3.sh $tarball_tmp/tests/read_examples/
Ignacio Pisso's avatar
Ignacio Pisso committed
199
cp tests/read_examples/read_headers.sh $tarball_tmp/tests/read_examples/
200
cp tests/read_examples/read_examples_output.txt $tarball_tmp/tests/ #read_examples/
Ignacio Pisso's avatar
Ignacio Pisso committed
201

202
203
204
echo ------------compare examples-------------------
mkdir $tarball_tmp/tests/compare_examples

Ignacio Pisso's avatar
Ignacio Pisso committed
205

206
207
cp tests/compare_examples/*.sh $tarball_tmp/tests/compare_examples
cp tests/compare_examples/compare_grids_output.txt $tarball_tmp/tests/ #compare_examples
Ignacio Pisso's avatar
Ignacio Pisso committed
208

Ignacio Pisso's avatar
Ignacio Pisso committed
209
echo 
Ignacio Pisso's avatar
Ignacio Pisso committed
210

Ignacio Pisso's avatar
Ignacio Pisso committed
211
212
213
214
215
216
217
echo ---------------------------------------------------------
echo create tarball

cd $targetdir
tar cf $distribution_name.tar $distribution_name 

pwd
Ignacio Pisso's avatar
Ignacio Pisso committed
218

Ignacio Pisso's avatar
Ignacio Pisso committed
219
echo  tarball $tarball complete
Ignacio Pisso's avatar
Ignacio Pisso committed
220
echo exported untarred files in $tarball_tmp 
221

Ignacio Pisso's avatar
Ignacio Pisso committed
222
echo verify:
223
224
225
226
227
228
echo cp -r preprocess/flex_extract/work $tarball_tmp/preprocess/flex_extract/ 
echo cd $tarball_tmp/src
echo $HOME/repos/flexpart/src/make_in_laptop.sh
echo cd .. ';' ./src/FLEXPART 
echo cd postprocess/flex_read_fortran
echo make test
Ignacio Pisso's avatar
Ignacio Pisso committed
229
echo e.g.: max:  0.115784094     mean:   4.70877676E-05
230
231
232
233
234
235
236
237
238
239
echo cd ../../tests/examples ';'   make run
echo cd ../read_examples
echo ./read_examples.sh
echo ./read_examples.sh '>' ../read_examples_output.txt
echo cd ../compare_examples
echo ./compare_grids.sh
echo ./compare_grids.sh '>' ../compare_grids_output.txt

echo e.g. tar --append --file=$tarball_tmp/ ../compare_grids_output.txt ../read_examples_output.txt