Setting up Environment for AGCM Sandbox: Difference between revisions
Created page with "Given the large number of directories in the GEOS5 model it can be useful to set up your environment to make navigating your sandbox easier. This page will document one way of do..." |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Given the large number of directories in the GEOS5 model it can be useful to set up your environment to make navigating your sandbox easier. This page will document one way of doing this | Given the large number of directories in the GEOS5 agcm model it can be useful to set up your environment to make navigating your sandbox easier. This page will document one way of doing this. This is especially useful if you have multiple copies of the GEOS5 model that you might have checked out (a stable release and your development sandbox for example). This method assumes you have checked out a copy of the model previously and you are running c shell. This method also assumes that all of your models are kept in the same parent directory and that the | ||
GEOSagcm directory is itself inside another folder. For example you if you have 2 models on discover at NCCS they would need to be organized as: | |||
/discover/nobackup/username/models/model1/GEOSagcm | |||
/discover/nobackup/username/models/model2/GEOSagcm | |||
You will need two files in your home directory or somewhere else in your path. | |||
First is geostagx, shown below. You will need to set the MODELDIR variable in this script to where ever you have chosen to keep your models. | |||
<nowiki> | <nowiki> | ||
#!/bin/tcsh -f | |||
set BLACK = "\033[30m" | |||
set RED = "\033[31m" | |||
set GREEN = "\033[32m" | |||
set YELLOW = "\033[33m" | |||
set BLUE = "\033[34m" | |||
set MAGENTA = "\033[35m" | |||
set CYAN = "\033[36m" | |||
set WHITE = "\033[37m" | |||
set RESET = "\033[0m" | |||
set BOLD = "\033[1m" | |||
set COLORS = `echo $BLACK $RED $GREEN $YELLOW $BLUE $MAGENTA $CYAN $WHITE $RESET` | |||
set C1 = $RED | |||
set C2 = $BLUE | |||
set CN = $RESET | |||
set MODELDIR = /discover/swdev/username/models | |||
# Create ~/.geostag for modules and aliases | |||
# Note: Variable GEOSTAG will point to the directory from CVS containing: src | |||
# ---------------------------------------------------------------------------- | |||
if( .$1 == . ) then | |||
if( -e ~/.geostag ) then | |||
set dummy = `grep ESMADIR ~/.geostag | cut -d" " -f3` | |||
# echo " " | |||
# echo "Enter GEOSTAG: $dummy (Default)" | |||
# set tag = $< | |||
# if( .$tag == . ) set tag = $dummy | |||
# echo " " | |||
set items = `/bin/ls -1 $MODELDIR` | |||
set tags = '' | |||
foreach item ($items) | |||
if( -d $MODELDIR/$item ) then | |||
if( -e $MODELDIR/$item/GEOSagcm ) set tags = `echo $tags $MODELDIR/$item/GEOSagcm` | |||
endif | |||
end | |||
if( $#tags != 0 ) then | |||
echo " " | |||
echo "Enter GEOSTAG Index to use:" | |||
echo "---------------------------" | |||
@ n = 0 | |||
foreach tag ($tags) | |||
@ n = $n + 1 | |||
if( $tag == $dummy ) then | |||
@ ndum = $n | |||
echo ${C1}" $n $tag (Current)"${CN} | |||
else | |||
echo " $n $tag" | |||
endif | |||
end | |||
set tag_index = $< | |||
if( .$tag_index == . ) then | |||
set tag_index = $ndum | |||
endif | |||
set tag = $tags[$tag_index] | |||
else | |||
echo " " | |||
echo "Enter GEOSTAG: " | |||
set tag = $< | |||
endif | |||
else | |||
set items = `/bin/ls -1 $MODELDIR` | |||
set tags = '' | |||
foreach item ($items) | |||
if( -d $MODELDIR/$item ) then | |||
if( -e $MODELDIR/$item/GEOSagcm ) set tags = `echo $tags $MODELDIR/$item/GEOSagcm` | |||
endif | |||
end | |||
if( $#tags != 0 ) then | |||
HERE: | |||
echo " " | |||
echo "Enter GEOSTAG Index to use:" | |||
echo "---------------------------" | |||
@ n = 0 | |||
foreach tag ($tags) | |||
@ n = $n + 1 | |||
echo " $n $tag" | |||
end | |||
set tag_index = $< | |||
if( .$tag_index == . ) GOTO HERE | |||
set tag = $tags[$tag_index] | |||
set tag = $tags[$tag_index] | |||
else | |||
echo " " | |||
echo "Enter GEOSTAG: " | |||
set tag = $< | |||
endif | |||
endif | |||
else | |||
set tag = $1 | |||
endif | |||
if( -e $tag/src ) then | |||
set dummy = $tag | |||
else if( -e $tag/GEOSagcm/src ) then | |||
set dummy = $tag/GEOSagcm | |||
else | |||
echo " " | |||
echo \!\!\! Note: geostag not executed. | |||
echo \!\!\! Note: GEOSTAG should point to the model directory which contains: src | |||
echo " " | |||
exit | |||
endif | |||
if( -e ~/.geostag ) /bin/rm ~/.geostag | |||
echo \#\!/bin/csh -f > ~/.geostag | |||
echo setenv ESMADIR $dummy >> ~/.geostag | |||
chmod 755 ~/.geostag | |||
</nowiki> | |||
Next is g5env | |||
<nowiki> | |||
#!/bin/csh -f | #!/bin/csh -f | ||
Line 93: | Line 217: | ||
</nowiki> | </nowiki> | ||
Finally you will need an alias in your run script to souce these files. | |||
Here I have chosen to call the alias geostag | |||
alias geostag 'geostagx \!* ; source ~/.geostag ; source ~/g5env' | |||
When you execute the alias geostag it will source geostagx and g5env. | |||
Geostagx will search the model directory for all the occurences of $MODELDIR/*/GEOSagcm, | |||
list these directories in a numbered list and ask the user to select one. Once the user has make their choice the geostagx sets the $ESMADIR enviroment variable for that particular sandbox. | |||
It will also write the value of the $ESMADIR variable to a .geostag file in the users home directory. If the .geostag file already exists that model will be shown in a different color when running geostagx. | |||
Next the g5env file will be sourced. Sourcing this will source the g5_modules file on for the sandbox you have chosen and set aliases to various directories within the model. For example now to get to the MAPL_Base directory you simply have to type mapl. |