forked from FreeFem/FreeFem-sources
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFreeFem++-CoCoa.in
executable file
·61 lines (56 loc) · 1.36 KB
/
FreeFem++-CoCoa.in
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
#!/bin/sh
#
# EXTENSIONS : ".edp" # Accepted file extentions
# OSTYPES : "****" # Accepted file types
# ROLE : None # Role (Editor, Viewer, None)
# SERVICEMENU : FreeFem++ # Name of Service menu item
#
dir=`dirname $0`;
ff="@bindir@/FreeFem++"
fa="-glut ffglut "
q="'"
end="exit;"
begin="cd $PWD;"
# begin the cmd generation ----------
cmd=""
# -----------------
for i in "$@"; do
d=`dirname "$i"`;
f=`basename "$i"`;
if [ -f "$i" ] ; then
np=`awk -v npo=$np '$1=="//" && $2=="NBPROC" { if( vv == ""){ print $3;}; vv=1}' "$i"`
npa=`awk -v npo=$np '$1=="//" && $2=="PARAM" { if( vv == ""){ for(i=3;i<=NF;++i)print $i;}; vv=1}' "$i"`
# echo --- $np -- $npa --------
if [ "0$np" -gt 0 ] ; then
test -n "@TEST_FFPPMPI@" && ff="@bindir@/ff-mpirun -np $np"
fi
if [ -n "$npa" ] ; then fa="$fa $npa"; fi
cmd="$cmd cd $q$d$q; $ff $q$f$q $fa ;"
fi
done
# ------------------
if [ -z "$cmd" ]; then
cmd="$ff;"
fi
# ------------------
cmd="$cmd"
# ---- end of cmd generation ----
echo 'do script "'$cmd'"'
#
#
# send the command $cmd to the apple terminal via osascript
#
# (echo $0;echo $*;echo "--$TERM--";printenv;set) >/tmp/tutu
if [ -z "$TERM_PROGRAM" ] ; then
echo '
tell application "Terminal"
activate
try
do script "'$begin$cmd$end'"
end try
end tell
' | osascript
else
set -e
eval $cmd
fi;