File: FreeFem++-CoCoa.in

package info (click to toggle)
freefem++ 3.61.1+dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 17,108 kB
  • sloc: cpp: 141,214; ansic: 28,664; sh: 4,925; makefile: 3,142; fortran: 1,171; perl: 844; awk: 290; php: 199; pascal: 41; f90: 32
file content (61 lines) | stat: -rwxr-xr-x 1,392 bytes parent folder | download | duplicates (2)
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
60
61
#!/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;