forked from zerothi/fdict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.sh
128 lines (122 loc) · 2.31 KB
/
settings.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# Define here the number of dimensions for the different types
# Variables
function var_N {
local var=$1 ; shift
case $var in
VAR) _ps 0 ;;
V) _ps 0 ;;
a) _ps 0 ;;
*) _ps 3 ;;
esac
}
#declare -A N
#N[VAR]=0 # variable
#N[V]=0 # variable-string
#N[a]=0 # character
#N[s]=3 # single
#N[d]=3 # double
#N[c]=3 # single complex
#N[z]=3 # double complex
#N[b]=3 # logical
#N[h]=3 # short
#N[i]=3 # integer
#N[l]=3 # long integer
# Names of the different short-hands
# DONT change these
function var_name {
local var=$1 ; shift
case $var in
VAR) _ps "type(var)" ;;
V) _ps "type(var_str)" ;;
a) _ps "character(len=*)" ;;
s) _ps "real(sp)" ;;
d) _ps "real(dp)" ;;
c) _ps "complex(sp)" ;;
z) _ps "complex(dp)" ;;
b) _ps "logical" ;;
h) _ps "integer(ih)" ;;
i) _ps "integer(is)" ;;
l) _ps "integer(il)" ;;
esac
}
#declare -A name
#name[VAR]="type(var)"
#name[V]="type(var_str)"
#name[a]="character(len=*)"
#name[s]="real(sp)"
#name[d]="real(dp)"
#name[c]="complex(sp)"
#name[z]="complex(dp)"
#name[b]="logical"
#name[h]="integer(ih)"
#name[i]="integer(is)"
#name[l]="integer(il)"
function _ps { printf "%b" "$@" ; }
function _psnl { printf "%b\n" "$@" ; }
function modproc {
local sub=$1 ; shift
local sn=$1 ; shift
local dim=$1 ; shift
if [ $# -eq 0 ]; then
_psnl "module procedure ${sub}_$sn$dim"
else
while [ $# -gt 0 ]; do
_psnl "module procedure ${sub}_${1}_$sn$dim"
shift
done
fi
}
function dim_to_size {
case $1 in
1)
_ps "(:)" ;;
2)
_ps "(:,:)" ;;
3)
_ps "(:,:,:)" ;;
4)
_ps "(:,:,:,:)" ;;
5)
_ps "(:,:,:,:,:)" ;;
6)
_ps "(:,:,:,:,:,:)" ;;
7)
_ps "(:,:,:,:,:,:,:)" ;;
0)
;;
*)
echo "You are requesting a too large array size."
return 1
;;
esac
}
function ptr_declarations {
local v
local count=1
if [ $1 == "-count" ]; then
shift
count=$1
shift
fi
while [ $# -gt 0 ]; do
v=$1 ; shift
for d in `seq 0 $(var_N $v)` ; do
_psnl "type :: pt$v$d"
_psnl " $(var_name $v), pointer :: p$(dim_to_size $d)"
_psnl "end type pt$v$d"
_ps "type(pt$v$d) :: "
if [ $count -eq 1 ]; then
_psnl "p$v${d}"
else
for i in `seq 1 $count` ; do
_ps "p$v${d}_$i"
if [ $i -lt $count ]; then
_ps ", "
fi
done
_psnl ""
fi
done
done
}