Skip to content

Commit 4548324

Browse files
committed
add shmesa extras
1 parent 9e0c9c8 commit 4548324

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

scripts/shmesa/shmesa

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ shmesa_help () {
4444
|___/_| |_|_| |_|_____|____/_/ \_\
4545
4646
EOF
47-
echo "Usage: shmesa [work|change|defaults|cp|grep|zip|help] [arguments]"
47+
echo "Usage: shmesa [work|change|defaults|cp|grep|extras|zip|help] [arguments]"
4848
echo
4949
echo "Subcommands:"
5050
echo " work copy the work directory to the current location"
5151
echo " change change a parameter in the given inlist"
5252
echo " defaults copy the history/profile defaults to the current location"
5353
echo " cp copy a MESA directory without copying LOGS, photos, etc."
5454
echo " grep search the MESA source code for a given string"
55+
echo " extras fill in the full run_star_extras.f90 template"
5556
echo " zip prepare a MESA directory for sharing"
5657
echo " help display this helpful message"
5758
echo " -h flag for getting additional details about any of the above"
@@ -258,12 +259,36 @@ shmesa_zip () {
258259
}
259260

260261

262+
shmesa_extras () {
263+
if shmesa_check_h_flag "$@"; then
264+
echo "Usage: shmesa extras [src/run_star_extras.f90]"
265+
echo "replaces run_star_extras.f90 with the full template"
266+
return 0
267+
fi
268+
269+
local rse='src/run_star_extras.f90'
270+
if [[ ! -z $1 ]]; then
271+
rse=$1
272+
fi
273+
274+
local contents=$(cat "$MESA_DIR/include/standard_run_star_extras.inc")
275+
if [[ -z $contents ]]; then
276+
echo "Cannot find $MESA_DIR/include/standard_run_star_extras.inc"
277+
return 1
278+
fi
279+
contents=$(sed 's:|:\\|:g' "$MESA_DIR/include/standard_run_star_extras.inc" | sed -z 's:\n:\\n:g')
280+
281+
backup_copy "$rse" "$rse".bak
282+
sed -i "s| include 'standard_run_star_extras.inc'|$contents|" $rse
283+
}
284+
285+
261286
### DEVELOPMENT USE
262287
shmesa_template () {
263288
### TEMPLATE FOR NEW SHMESA FUNCTIONS
264289
if shmesa_check_h_flag "$@"; then
265290
echo "Usage: shmesa funcname arg [optional arg]"
266-
echo "put discription here"
291+
echo "put description here"
267292
return 0
268293
fi
269294

@@ -335,6 +360,10 @@ shmesa_test () {
335360
# shmesa cp
336361
run_shmesa_test "cp" \
337362
"(shmesa cp '$MESA_SHMESA_TEST' '$MESA_SHMESA_TEST'_cp)"
363+
364+
# shmesa extras
365+
run_shmesa_test "extras" \
366+
"(cd $MESA_SHMESA_TEST && shmesa extras)"
338367

339368
# shmesa zip
340369
run_shmesa_test "zip" \
@@ -435,6 +464,9 @@ case "$subcommand" in
435464
grep)
436465
shmesa_grep "$@"
437466
;;
467+
extras)
468+
shmesa_extras "$@"
469+
;;
438470
zip)
439471
shmesa_zip "$@"
440472
;;

0 commit comments

Comments
 (0)