create_tarball.sh 12.6 KB
Newer Older
1
#!/bin/bash
2
# Ignacio Pisso, May 2017 
3

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

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

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

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

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

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

29
# if needed clean old package
30
if [ -d $tarball_tmp ]; then
Ignacio Pisso's avatar
Ignacio Pisso committed
31 32 33 34 35 36 37 38 39 40 41
  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
42 43
fi

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
# 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
#4 tests/examples ../flex_tests_examples/examples3/*
#5  
#6




# mkdir container
61
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
62
echo ')' create basis dir $tarball_tmp
63
mkdir $tarball_tmp
64
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
65 66 67

echo

68
# patnames
69
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
70
echo ')' copy pathnames 
71 72 73
#cp pathnames_distribution $tarball_tmp/pathnames
cp pathnames $tarball_tmp/pathnames
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
74 75 76

echo 

77
# fortran source files
Ignacio Pisso's avatar
Ignacio Pisso committed
78 79
echo ---------------------------------------------------------
echo ')' copy src/
80 81
mkdir $tarball_tmp/src
cp src/*.f90 $tarball_tmp/src
82
cp -r src/gributils $tarball_tmp/src 
83
# echo '3)' copy makefile
84
cp src/makefile $tarball_tmp/src
85
#cp src/makefile.gfs $tarball_tmp/src
86
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
87 88 89

echo

90
# options dir
Ignacio Pisso's avatar
Ignacio Pisso committed
91 92
echo ---------------------------------------------------------
echo ')' copy options/ 
93
echo ---------------------------------------------------------
94 95 96 97 98 99 100 101
# (for the distribution they work with the defult flex_ecmwf test winds)
#cp -r options_flex_ecmwf_EA $tarball_tmp/options
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
Ignacio Pisso's avatar
Ignacio Pisso committed
102
  #echo copy $i to $tarball_tmp/options
103 104 105 106
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
107
echo copy options/SPECIES/ to $tarball_tmp/options/SPECIES/
108 109 110
echo ---------------------------------------------------------

echo
Ignacio Pisso's avatar
Ignacio Pisso committed
111

112 113 114 115 116 117
# 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/
118
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
119 120 121

echo

122
# AVAILABLE
Ignacio Pisso's avatar
Ignacio Pisso committed
123 124
echo ---------------------------------------------------------
echo ')' copy AVAILABLE
125 126
#cp AVAILABLE_flex_ecmwf_EA $tarball_tmp/AVAILABLE
cp AVAILABLE $tarball_tmp/AVAILABLE
Ignacio Pisso's avatar
Ignacio Pisso committed
127 128 129
echo ---------------------------------------------------------

echo 
130

131
# output
132
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
133
echo  ')' create output/ #  mkdir $tarball_tmp/output
134 135
mkdir $tarball_tmp/output
echo ---------------------------------------------------------
136 137
echo output reference?
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
138

139
echo
Ignacio Pisso's avatar
Ignacio Pisso committed
140

141
# preprocess
Ignacio Pisso's avatar
Ignacio Pisso committed
142
echo ---------------------------------------------------------
143
echo ')' preprocess/
144
mkdir $tarball_tmp/preprocess
145 146 147
echo -----------------flex_extract-------------------
#echo '6)'  mkdir $tarball_tmp/flex_extract [a separate repository]
#mkdir $tarball_tmp/preprocess
148 149
#mkdir $tarball_tmp/preprocess/flex_ecmwf
mkdir $tarball_tmp/preprocess/flex_extract
150 151 152
#echo '7)  add ECMWF retrieve routines (change EA wind files for latest source code)'
#mkdir $tarball_tmp/preprocess/flex_extract
#mkdir $tarball_tmp/preprocess/flex_extract/work
153
#cp -r flex_ecmwf_src/* $tarball_tmp/preprocess/flex_ecmwf/
154 155
#cp -r flex_ecmwf_src/* $tarball_tmp/preprocess/flex_extract/
## cp -r flex_extract/work/EA* $tarball_tmp/preprocess/flex_extract/work   
156
flex_extract=../flex_extract_v7.0.4/
Ignacio Pisso's avatar
Ignacio Pisso committed
157 158
echo include flex_extract v7.0.4 b7c1c04a204c91e53759ef590504bf52dfaece64
echo from $flex_extract [use git modules?] IP 3/2018 
159 160 161 162 163
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
164 165
echo flex_extract copied
echo ---------------------------------------------------------
166 167
echo AVAILABLE generation scripts?
echo ---------------------------------------------------------
168

169 170 171 172 173
#echo '10)' cp example generating scripts [a separate repository]
#echo moved below
#mkdir $tarball_tmp/examples
#cp -r examples/*.sh $tarball_tmp/examples/ 
#cp -r examples/Makefile $tarball_tmp/examples/ 
Ignacio Pisso's avatar
Ignacio Pisso committed
174 175 176

echo 

177
# postprocess
178
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
179
echo ')' postprocess/
180 181 182 183

postprocess=postprocess
mkdir $tarball_tmp/$postprocess
echo -----------------flex_read_fortran-------------------
184
flex_read_fortran_src=$postprocess/flex_read_fortran/
185 186 187 188 189 190
#echo ')'  directory for reading routines
#echo '12)'  add fortran reading routines [a separate repository]
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
191
echo flex_read_fortran copied from $flex_read_fortran_src
192 193

echo -----------------flex_read_matlab-------------------
194 195 196 197
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
198
# add matlab reading routines
199 200
#mkdir $tarball_tmp/postprocess/flex_read_matlab
#cp postprocess/flex_read_matlab/*.m $tarball_tmp/postprocess/flex_read_matlab
Ignacio Pisso's avatar
Ignacio Pisso committed
201
echo ---------------------------------------------------------
202

Ignacio Pisso's avatar
Ignacio Pisso committed
203
echo
204

205
echo ---------------------------------------------------------
Ignacio Pisso's avatar
Ignacio Pisso committed
206 207
echo ')' tests/
###############################################################
208
#echo '13) tests' 
209
mkdir $tarball_tmp/tests
210
#echo -----------------flex_read_fortran-------------------
211
#echo 'b) ./tests/flex_read_fortran/' 
212
#echo fixme
213 214 215
#mkdir $tarball_tmp/tests/flex_read_fortran
#cp tests/flex_read_fortran/test_read_default.sh  $tarball_tmp/tests/flex_read_fortran

Ignacio Pisso's avatar
Ignacio Pisso committed
216

217
###############################################################
218
echo ----------------- examples -------------------
219 220 221

#echo ') ./tests/examples/' 
mkdir $tarball_tmp/tests/examples
222 223 224 225
#echo ') scripts' 
#cp -r ./tests/examples/*.sh $tarball_tmp/tests/examples/ 
#echo ') makefile' 
#cp -r ./tests/examples/Makefile $tarball_tmp/tests/examples/ 
226
# echo USAGE: ~/repos/flexpart/tests/examples'$' make run
227 228 229 230 231
cp -r ../flex_tests_examples/examples3/* $tarball_tmp/tests/examples/

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

232 233


234
###############################################################
235 236
# echo -----------------postprocess examples-------------------
echo -----------------read examples-------------------
237 238 239

#echo '13 c) ./tests/read_examples/' 
mkdir $tarball_tmp/tests/read_examples
240 241 242 243 244

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/
245
cp tests/read_examples/read_grids.sh $tarball_tmp/tests/read_examples/
246 247 248
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/
249
cp tests/read_examples/read_headers.sh $tarball_tmp/tests/read_examples/
250
cp tests/read_examples/read_examples_output.txt $tarball_tmp/tests/ #read_examples/
251 252 253
# echo USAGE ~/repos/flexpart/tests/read_examples'$'./read_grids.sh

###############################################################
254
echo ------------compare examples-------------------
255
#echo tests/compare_examples.sh
256 257
mkdir $tarball_tmp/tests/compare_examples

258 259 260

#mkdir $tarball_tmp/tests/compare_examples
#cp tests/compare_examples/compare_grids.sh $tarball_tmp/tests/compare_examples
261 262 263
#cp tests/compare_grids.sh $tarball_tmp/tests/
cp tests/compare_examples/*.sh $tarball_tmp/tests/compare_examples
cp tests/compare_examples/compare_grids_output.txt $tarball_tmp/tests/ #compare_examples
264
# list of examples with units
265
#cp tests/declare_examples $tarball_tmp/tests/
266

Ignacio Pisso's avatar
Ignacio Pisso committed
267
echo 
268 269 270 271 272

# ~/repos/flexpart/tests$./compare_grids.sh 

#echo mkdir $tarball_tmp/tests/examples2/
#echo cp tests/examples2/setup.sh $tarball_tmp/tests/examples2/
Ignacio Pisso's avatar
Ignacio Pisso committed
273 274
# echo --repeat examples-------------------
# echo FIXME 
275 276

###############################################################
Ignacio Pisso's avatar
Ignacio Pisso committed
277 278
#echo -----------------ctbto-------------------
# mkdir $tarball_tmp/tests/ctbto
279 280 281 282

# cp -r tests/NILU/test_1 $tarball_tmp/tests/
# cp -r tests/default_cases $tarball_tmp/tests/

Ignacio Pisso's avatar
Ignacio Pisso committed
283 284 285 286 287 288 289 290 291 292
echo ---------------------------------------------------------
echo create tarball
#tar cvf $tarball  $tarball_tmp  
#tar cf $tarball  $tarball_tmp  
#cd 

cd $targetdir
tar cf $distribution_name.tar $distribution_name 

pwd
293

Ignacio Pisso's avatar
Ignacio Pisso committed
294 295

echo  tarball $tarball complete
296
echo exported untarred files in $tarball_tmp 
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319

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
echo  max:  0.115784094     mean:   4.70877676E-05
#echo cd $tarball_tmp/tests/examples ';'   make run
echo cd ../../tests/examples ';'   make run
#echo cd $tarball_tmp/tests/read_examples
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
 
 


320
exit
321
#return
322 323
###############################################################

Ignacio Pisso's avatar
Ignacio Pisso committed
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
# obtain $FLEXHOME (and set)
#1 cd $FLEXHOME/src 

#2 compile
#
#[laptop] source /Users/ignacio/repos/flexpart/src/make_in_laptop.sh 
# [njord] make
# ->created executable (FLEXPART)

#3 execute in src (absolute paths)
#
#[laptop] cp  /Users/ignacio/repos/flexpart/src/pathnames .
#[njord] FIXME
#
# mkdir output
# ./FLEXPART
# ->created output in output/

#4 read output
# cd  $FLEXHOME/postprocess/flex_read_fortran/
# make
# -> printheader* printgrid* flex_read_compare2*
#/postprocess/flex_read_fortran$./printheader ../../src/output/
#/postprocess/flex_read_fortran$./printgrid ../../src/output/ conc
# -> output in stdout (max:   11122924.0     sum:   90330784.0)

#5 execute in $FLEXHOME
# cd $FLEXHOME
# get winds
#[laptop] cp -r ~/repos/flex_winds/work/ ./preprocess/flex_extract/ 
#[njord] curl https://folk.nilu.no/~ignacio/FLEXPART/EA120101.tar --output EA120101.tar ; tar -xvf EA120101.tar ; mv flex_extract/work preprocess/flex_extract/ ; rmdir flex_extract

# src/FLEXPART
# -> output in $FLEXHOME/output/

#6 read output
# postprocess/flex_read_fortran/printheader output/
# postprocess/flex_read_fortran/printgrid output/ conc
# -> output in stdout ( max:   11578738.0     sum:   104058720.)

#7 gnererate examples
# cd $FLEXHOME/tests/examples

#make run

#make examples
#make batch
#./run_batch_cl.sh

#make (set_default_example.sh)
#tests/examples$../../src/FLEXPART
#output

#8 read examples:
#cd $FLEXHOME/tests/read_examples  
# ./read_headers.sh
# ./read_grids.sh 

#9 compare examples with reference