Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Fabien Rozar
script_factory
Commits
94b1f0ec
Commit
94b1f0ec
authored
Feb 16, 2016
by
frozar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DEV] Add basic scripts.
parent
09b9b23b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
0 deletions
+114
-0
common_subroutine.sh
common_subroutine.sh
+52
-0
get_subroutine.sh
get_subroutine.sh
+31
-0
get_type.sh
get_type.sh
+31
-0
No files found.
common_subroutine.sh
0 → 100755
View file @
94b1f0ec
#!/bin/bash
files
=(
$(
ls
mod_[A-Z][A-Z][A-Z][A-Z][a-z0-9].f90
)
)
first_file
=
${
files
[0]
}
# echo $first_file
subroutines
=
$(
to_del
=
$(
echo
$first_file
|
sed
"s/mod//g;s/.f90//g"
)
;
grep
-i
"subroutine"
mod
${
to_del
}
.f90 |
grep
-vi
-e
"end subroutine"
-e
"
\!\!
"
-e
" *!"
|
grep
-i
subroutine |
sed
"s/ *subroutine //g;s/ *SUBROUTINE //g;s/(.*//g"
|
sort
|
sed
"s/
${
to_del
}
//g"
)
# grep -i "subroutine *CLALp2ENT" mod_CLJCx.f90
# grep -i "subroutine *clean_memory" mod_CLJCx.f90
i
=
0
# for s in CLALp2ENT clean_memory
for
s
in
${
subroutines
[*]
}
do
# echo " s:" $s
in_all
=
"true"
# for f in mod_CLALp.f90 mod_CLJCx.f90
for
f
in
${
files
[*]
}
do
# echo " the test"
# echo $(grep -i "subroutine *${s}" ${f})
if
[
"
`
grep
-i
"subroutine *
${
s
}
"
${
f
}
`
"
==
""
]
then
# echo " f:" $f
# grep -i "subroutine *${s}" ${f}
in_all
=
"false"
fi
done
# echo " in_all:" $in_all
# echo ""
if
[
$in_all
==
"true"
]
then
elected_subroutines[
${
i
}
]=
$s
i
=
$((${
i
}
+
1
))
fi
done
# echo ${elected_subroutines[*]}
for
i
in
${
elected_subroutines
[*]
}
do
echo
$i
done
echo
"Array length:"
${#
elected_subroutines
[*]
}
get_subroutine.sh
0 → 100755
View file @
94b1f0ec
#!/bin/bash
usage
(){
# display the number of argument given
# echo $#
echo
" Usage:"
$0
"<subroutine_name>"
}
files
=(
$(
ls
mod_[A-Z][A-Z][A-Z][A-Z][a-z0-9].f90
)
)
if
[
$#
-ne
1
]
then
usage
exit
-1
fi
sub
=
$1
outfile
=
l_s_
${
sub
}
>
$outfile
(
for
f
in
${
files
[*]
}
do
echo
" ======
$f
"
beg
=
`
grep
-ni
-e
"^ *subroutine *
${
sub
}
_"
-e
"^ *end *subroutine"
$f
|
grep
-i
-e
"^[0-9]*: *subroutine *
$sub
"
-A1
|
head
-n1
|
cut
-d
":"
-f1
`
end
=
`
grep
-ni
-e
"^ *subroutine *
${
sub
}
_"
-e
"^ *end *subroutine"
$f
|
grep
-i
-e
"^[0-9]*: *subroutine *
$sub
"
-A1
|
tail
-n1
|
cut
-d
":"
-f1
`
head
-n
$end
$f
|
tail
-n
$((${
end
}
-
${
beg
}
+
1
))
echo
" ====== END
$f
"
echo
""
done
)
>
$outfile
get_type.sh
0 → 100755
View file @
94b1f0ec
#!/bin/bash
usage
(){
# display the number of argument given
# echo $#
echo
" Usage:"
$0
"<subroutine_name>"
}
files
=(
$(
ls
mod_[A-Z][A-Z][A-Z][A-Z][a-z0-9].f90
)
)
if
[
$#
-ne
1
]
then
usage
exit
-1
fi
typ
=
$1
outfile
=
l_t_
${
typ
}
>
$outfile
(
for
f
in
${
files
[*]
}
do
echo
" ======
$f
"
beg
=
`
grep
-ni
-e
"^ *type *
${
typ
}
_"
-e
"^ *end *type"
$f
|
grep
-i
-e
"^[0-9]*: *type *
$typ
"
-A1
|
head
-n1
|
cut
-d
":"
-f1
`
end
=
`
grep
-ni
-e
"^ *type *
${
typ
}
_"
-e
"^ *end *type"
$f
|
grep
-i
-e
"^[0-9]*: *type *
$typ
"
-A1
|
tail
-n1
|
cut
-d
":"
-f1
`
head
-n
$end
$f
|
tail
-n
$((${
end
}
-
${
beg
}
+
1
))
echo
" ====== END
$f
"
echo
""
done
)
>
$outfile
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment