# #---------------------------------------------------------------------- # Get model source and object tar files from mss: # # This script is included in job script which defined the following: # tgcm_version = model version (used to make src and obj mss paths) # # Also optionally defined: # CF = compiler (f90) (f77 no longer supported) # COMPILE_ALL = if set, compile all source code (do not acquire object) # ARCH = machine type (if not set, use uname -n to determine target) # tmpdir = temporary dir in which to link src and obj tar files # msread_src = mss path to source code tar file # (default msread_src is /FOSTER/tgcm/${tgcm_version}_src.tar) # mswrite_src = mss path to write source code tar file # msread_obj = mss path to object code tar file # (default msread_obj is # /FOSTER/tgcm/${tgcm_version}_${ARCH}_obj.tar) # mswrite_obj = mss path to write object code tar file # msread_bin = mss path to binary executable (no compile/load) # mswrite_bin = mss path to write binary executable # # If msread_src not set, then mss path to source code will be: # $mssdir/${tgcm_version}_src.tar): # # If msread_obj not set, then mss path to object code will be: # $mssdir/${tgcm_version}_${ARCH}_obj.tar # Object code is not acquired if COMPILE_ALL is set) #---------------------------------------------------------------------- if ($?EXEC_FILE) then echo getsrcobj returning because EXEC_FILE is set = $EXEC_FILE goto gotsrcobj endif # # tgcm_version must be set: # if (! $?tgcm_version) then echo " " echo "Please specify the tgcm_version shell variable in your run script" echo "The following are valid values for tgcm_version:" echo " tgcm22 (latest time-gcm)" echo " tgcm22mt (multi-tasked tgcm22)" echo " tgcm21 (time-gcm)" echo " tgcm21_nmc (nmc time-gcm)" echo " tgcm20 (old time-gcm)" echo " tgcm13 (latest tiegcm)" echo " tgcm12 (tiegcm)" echo " tgcm8 (tigcm)" echo " mtgcm (mars tgcm)" echo " vtgcm (venus tgcm)" echo " " echo "For example:" echo " set tgcm_version = tgcm22" exit 1 endif # # Mss directory which contains tgcm source, object, and binaries: set mssdir = /FOSTER/tgcm # # Make tmpdir if necessary (default is ./tmpdir): if (! $?tmpdir) set tmpdir = ./tmpdir # default if (! -d $tmpdir) then mkdir -p -m 777 $tmpdir echo Made directory $tmpdir endif # # Set default CF if necessary, and validate: # 9/28/98: f77 no longer available. # if (! $?CF) set CF = f90 if ($CF != 'f90') then echo ' ' echo '>>>' Bad value for CF: compiler must be '"f90"' echo ' (f77 compilation of tgcm no longer available)' echo ' ' exit 1 endif # # Get available hosts, archs, etc from hosts.dat: # INCLUDE -h $TGCMROOT/bin/hosts.dat # hosts data file #INCLUDE -h hosts.dat # hosts data file INCLUDE -h $TGCMROOT/bin/rdhosts # perl script that reads hosts.dat INCLUDE $TGCMROOT/bin/rdhosts.csh # calls rdhosts to get # $hosts,$vendors,$archs,$ncpus,$mems,$ssds # # Validate current host and set ARCH: # #set host = `hostname` set host = `uname -n` if (! $?ARCH) then @ i = 1 foreach availhost ($hosts) if ($host == $availhost) then set ARCH = $archs[$i] set ihost = $i endif @ i++ end if (! $?ARCH) then echo " " echo ">>> WARNING getsrcobj: unknown host: $host" echo " (tgcm object code is not available for this host)" echo " Known hosts are: $hosts" echo " " if (! $?COMPILE_ALL) then echo " " echo "If you want to compile tgcm on this unknown host," echo " resubmit with COMPILE_ALL set in your run script." echo " " exit 1 endif echo " " endif endif echo host=$host ARCH=$ARCH # # Skip rest of this part of script if a binary executable is specified: # if ($?msread_bin) goto gotsrcobj # # Get source from mss and extract: # (check $tmpdir first. If in cwd, msread will not go to mss) # if (! $?msread_src) set msread_src = $mssdir/${tgcm_version}_src.tar # # Disk file name is same as mss path, but with "/"s replaced by "."s: set srctar = `echo $msread_src | perl -pe 's/\///' | perl -pe 's/\//./g'` if (! -e $tmpdir/$srctar) then echo msread $srctar from $msread_src... # msread $srctar $msread_src || goto fail_getsrc msread $srctar $msread_src || set err if ($?err) then echo "WARNING: could not find mss file $srctar" else ln $srctar $tmpdir/$srctar endif else ln $tmpdir/$srctar . echo Linked $srctar from $tmpdir/$srctar endif if (! $?err) then tar xf $srctar echo Extracted source from $srctar endif chmod 644 *.h *.f *.F # # If $COMPILE_ALL is set, do not get object tar file. # (this will force make to compile all source code) # echo ' ' if ($?COMPILE_ALL) then echo "COMPILE_ALL is set:" echo " Will compile all source code, making new object code." goto gotsrcobj endif # # Get object tar file from mss and extract. # (check $tmpdir first. If in cwd, msread will not go to mss) # # If user specified mss obj file $msrobj, acquire it from mss, otherwise # get object code from mss appropriate to requested tgcm version # (tgcm_version) and machine type (ARCH). # if (! $?msread_obj) then set msread_obj = $mssdir/${tgcm_version}_${ARCH}_obj.tar # set exist = `msls $msread_obj` # if ($exist == "") then # echo ">>> WARNING getsrcobj: could not find mss object tar file" # echo " for tgcm_version $tgcm_version." # goto fail_msls_msread_obj # endif endif # # Disk file name is same as mss path, but with "/"s replaced by "."s: echo msread_obj = $msread_obj set objtar = `echo $msread_obj | perl -pe 's/\///' | perl -pe 's/\//./g'` echo objtar = $objtar if (! -e $tmpdir/$objtar) then echo msread $objtar from $msread_obj... msread $objtar $msread_obj || goto fail_getobj ln $objtar $tmpdir/$objtar else ln $tmpdir/$objtar . echo Linked $objtar from $tmpdir/$objtar endif tar xf $objtar echo Extracted object from $objtar chmod 644 *.o goto gotsrcobj # all ok, continue parent script # # Error traps: # # Failure to find source tar file on mss is fatal: # fail_getsrc: echo getsrcobj: msread of $msread_src to disk file $srctar failed exit 1 # fail_msls_msread_obj: echo getsrcobj WARNING: mss file $msread_obj apparently does not exist. exit 1 # # Failure to find object tar file on mss is fatal: # (note if COMPILE_ALL was set, object file was not acquired) # fail_getobj: echo getsrcobj WARNING: msread of $msread_obj to disk file $objtar failed exit 1 # # Continue execution of parent script: # gotsrcobj: