#!/bin/bash
# delete first line
export CUPY_GPU_MEMORY_LIMIT="90%"
sed  '/setup_case()/d' setup_case.py > temp_file
sed   's/def vist_smag/def vist_smag_old/' ~/pythons-rans-code/pyCALC-LES-GPU.py  > temp_file0
# add new first line plus global declarations
cat  ~/pythons-rans-code/global-GPU temp_file vist_smag_menter-mixing_length.py modify_case.py ~/pythons-rans-code/synt_fluct-GPU.py temp_file0 >  temp_file1;
# find setting of 'gpu' 
'grep' gpu setup_case.py > gpu_value;
# remove leading white space
sed -i 's/^[ \t]*//' gpu_value;
# add value of 'gpu' at first line
cat  gpu_value temp_file1  > exec-pyCALC-LES-GPU.py;
/usr/bin/time -a  -o out ~/anaconda3/bin/python -u  exec-pyCALC-LES-GPU.py > out
