~nickpapior/siesta/tddft-work

« back to all changes in this revision

Viewing changes to Src/fdict/src/variable.sh

  • Committer: Rafi Ullah
  • Date: 2017-08-30 14:09:10 UTC
  • mfrom: (611.1.19 trunk)
  • Revision ID: rraffiu@gmail.com-20170830140910-bhu0osuh4d59wn8e
Merged with trunk-630

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
[ -e $_vpath/settings.bash ] && source $_vpath/settings.bash
14
14
 
15
15
# The different settings used in this
16
 
vars=(V s d c z b h i l)
 
16
vars=(a s d c z b h i l)
17
17
 
18
18
ptr_declarations ${vars[@]} > var_declarations.inc
 
19
{
 
20
    _psnl "type :: pta_"
 
21
    _psnl " type(pta__), pointer :: p(:) => null()"
 
22
    _psnl "end type pta_"
 
23
    _psnl "type :: pta__"
 
24
    _psnl " character(len=1), pointer :: p => null()"
 
25
    _psnl "end type pta__"
 
26
    _psnl "type(pta_) :: pa_"
 
27
} >> var_declarations.inc
19
28
ptr_declarations -count 2 ${vars[@]} > var_declarations2.inc
 
29
{
 
30
    _psnl "type :: pta_"
 
31
    _psnl " type(pta__), pointer :: p(:) => null()"
 
32
    _psnl "end type pta_"
 
33
    _psnl "type :: pta__"
 
34
    _psnl " character(len=1), pointer :: p => null()"
 
35
    _psnl "end type pta__"
 
36
    _psnl "type(pta_) :: pa__1, pa__2"
 
37
} >> var_declarations2.inc
20
38
 
21
39
# Print out to the mod file
22
40
{
25
43
[ "$sub" == "associatd" ] && args="l r"
26
44
_psnl "interface $sub"
27
45
# Add the character(len=*)
28
 
[ "$sub" == "assign" ] && modproc $sub char 0 $args
29
 
# Add the variable
30
 
[ "$sub" != "associatd" ] && modproc $sub var ""
 
46
case "$sub" in
 
47
    assign)
 
48
        # Add the character(len=*)
 
49
        modproc $sub a "0_0" get set
 
50
        # Add the variable
 
51
        modproc $sub var ""
 
52
        ;;
 
53
    associate)
 
54
        # Add the variable
 
55
        modproc $sub var ""
 
56
        ;;
 
57
esac
31
58
for v in ${vars[@]} ; do
32
 
    for d in `seq 0 $(var_N $v)` ; do
 
59
    md=0
 
60
    [ $v == 'a' ] && md=1
 
61
    for d in `seq $md $(var_N $v)` ; do
33
62
        modproc $sub $v $d $args
34
63
    done
35
64
done
36
 
_psnl "end interface $sub"
 
65
_psnl "end interface"
37
66
_psnl "public :: $sub"
38
67
done
39
68
if [ 1 -eq 0 ]; then
40
69
for sub in eq ne lt gt ge le ; do
41
70
_psnl "interface operator(.$sub.)"
42
71
for v in ${vars[@]} ; do
43
 
    for d in `seq 0 $(var_N $v)` ; do
 
72
    md=0
 
73
    [ $v == 'a' ] && md=1
 
74
    for d in `seq $md $(var_N $v)` ; do
44
75
        modproc $sub $v $d l r
45
76
    done
46
77
done
47
78
modproc $sub v 0
48
 
_psnl "end interface operator(.$sub.)"
 
79
_psnl "end interface"
49
80
_psnl "public :: operator(.$sub.)"
50
81
done
51
82
fi
54
85
 
55
86
{
56
87
for v in ${vars[@]} ; do
57
 
    for d in `seq 0 $(var_N $v)` ; do
 
88
    md=0
 
89
    [ $v == 'a' ] && md=1
 
90
    for d in `seq $md $(var_N $v)` ; do
58
91
        _psnl "if (this%t == '$v$d') then"
59
92
        _psnl "  p$v$d = transfer(this%enc,p$v$d)"
60
93
        if [[ $v == "V" ]]; then
64
97
        _psnl "end if"
65
98
    done
66
99
done
67
 
# We define the type 'USER' as a "user-type"
68
 
_psnl "if (this%t == 'USER') then"
69
 
_psnl "print '(a)','var: Cannot deallocate UT, proceed:'"
70
 
_psnl "print '(a)','     1) retrieve type, 2) deallocate, 3) call nullify(var)'"
71
 
_psnl "end if"
72
100
} > var_delete.inc
73
101
 
74
102
 
75
103
{
76
104
for v in ${vars[@]} ; do
77
 
    for d in `seq 0 $(var_N $v)` ; do
 
105
    md=0
 
106
    [ $v == 'a' ] && md=1
 
107
    for d in `seq $md $(var_N $v)` ; do
78
108
        _psnl "if ( this%t == '$v$d' ) then"
79
109
        _psnl "#define DIM $d"
80
110
        _psnl '#include "settings.inc"'
90
120
 
91
121
{
92
122
for v in ${vars[@]} ; do
93
 
    for d in `seq 0 $(var_N $v)` ; do
 
123
    md=0
 
124
    [ $v == 'a' ] && md=1
 
125
    for d in `seq $md $(var_N $v)` ; do
94
126
        _psnl "if ( this%t == '$v$d' ) then"
95
127
        _psnl "p$v${d}_1%p = p$v${d}_2%p"
96
128
        _psnl "allocate(this%enc(size(transfer(p$v${d}_1, local_enc_type))))"
102
134
# In case the variable is a user-type, then we
103
135
# copy the encoding, probably this is a bit wearing, but
104
136
_psnl "if ( this%t == 'USER' ) then"
105
 
_psnl "print '(a)','var: Cannot assign a UT, USE call associate(..)'"
 
137
_psnl "write(*,'(a)') 'var: Cannot assign a UT, USE call associate(..)'"
106
138
_psnl "end if"
107
139
} > var_var_set.inc
108
140
 
109
141
 
110
142
{
111
143
for v in ${vars[@]} ; do
112
 
    for d in `seq 0 $(var_N $v)` ; do
 
144
    md=0
 
145
    [ $v == 'a' ] && md=1
 
146
    for d in `seq $md $(var_N $v)` ; do
113
147
        _psnl "if ( this%t == '$v$d' ) then"
114
148
        _psnl "p$v${d}_1 = transfer(this%enc,p$v${d}_1)"
115
149
        _psnl "p$v${d}_2 = transfer(rhs%enc,p$v${d}_2)"
129
163
_psnl "#undef VAR_PREC"
130
164
for v in ${vars[@]} ; do
131
165
    _psnl "#define VAR_TYPE $(var_name $v)"
132
 
    for d in `seq 0 $(var_N $v)` ; do
 
166
    md=0
 
167
    [ $v == 'a' ] && md=1
 
168
    for d in `seq $md $(var_N $v)` ; do
133
169
        if [ $d -eq 0 ]; then
134
170
            _psnl "#define DIMS"
135
171
        else