# # Run make and execute model (if EXEC not set, do not execute): # (if msread_bin is set, just get it and execute, no make necessary) # Assume source and fixed object files are already in cwd (see getsrcobj) # This script requires that $inp be the model input file. # $CF and $ARCH were verified in getsrcobj. # $FFLAGS and $LDFLAGS are optional (passed to mkmake). # # If user specified a binary executable, acquire it and execute: # if ($?msread_bin) then set exec = `echo $msread_bin | perl -pe 's/\///' | perl -pe 's/\//./g'` if (! -e $tmpdir/$exec) then echo msread $exec from $msread_bin... msread $exec $msread_bin || goto fail_getbin ln $exec $tmpdir/$exec else ln $tmpdir/$exec . echo Linked $exec from $tmpdir/$exec endif chmod u+x $exec goto execute endif # # Make Makefile suitable for CF, ARCH, FFLAGS, and LDFLAGS. # If FFLAGS or LDFLAGS were not set by user, they are set to # "(default)" for mkmake. # If Makefile already exists use it instead (it was provided by user). # INCLUDE -h $TGCMROOT/bin/mkmake if (-e Makefile) then echo "Using existing Makefile -- mkmake not used." else if (! $?FFLAGS) set FFLAGS = "(default)" if (! $?LDFLAGS) set LDFLAGS = "(default)" echo ' ' echo Executing mkmake to make Makefile... perl mkmake $CF $ARCH FFLAGS=$FFLAGS LDFLAGS=$LDFLAGS || goto fail_mkmake endif # # Make object list and dependencies for makefile: # INCLUDE -h $TGCMROOT/bin/mkdep echo Executing mkdep ... perl mkdep || goto fail_mkdep # # TARGET env var saves time on segldr by avoiding scalar cache safe checks. # TARGET is CRAY-YMP for scd Cray machines, except antero, which is CRAY-C90 # 6/30/97: Do not use TARGET env var -- may cause problems. # if ($ARCH == 'c90') then setenv TARGET CRAY-C90 else setenv TARGET CRAY-YMP endif # # Compile new/modified code and load executable: # (note executable is always tgcm*x, see mkmake) # (get separate ja report for make) # echo Making executable ... ja make NPROC=5 || goto fail_make ja -st set exec = tgcm*.x # # Write source tar file to mss if requested: # if ($?mswrite_src) then tar cf src.tar *.h *.f set msserr = 0 mswrite -t 367 src.tar $mswrite_src || set msserr = 1 if ($msserr) then echo WARNING: ERROR writing src.tar to mss $mswrite_src else echo Wrote source tar file to mss $mswrite_src endif endif # # Write object tar file to mss if requested: # if ($?mswrite_obj) then tar cf obj.tar *.o set msserr = 0 mswrite -t 367 obj.tar $mswrite_obj || set msserr = 1 if ($msserr) then echo WARNING: ERROR writing obj.tar to mss $mswrite_obj else echo Wrote object tar file to mss $mswrite_obj endif endif # # Write binary executable to mss if requested: # if ($?mswrite_bin) then set msserr = 0 mswrite -t 367 $exec $mswrite_bin || set msserr = 1 if ($msserr) then echo WARNING: ERROR writing $exec to mss $mswrite_bin else echo Wrote binary executable $exec to mss $mswrite_bin endif endif # if (! $?EXEC) then echo Exit because EXEC not set \(see set EXEC in job script\) exit 0 endif # # Use only 1 processor (allowed multi-proc for compilation above): # if ($?ncpus) then setenv NCPUS $ncpus else setenv NCPUS 1 endif echo Set env var NCPUS to $NCPUS # # Execute (Makefile's 1st target must be $exec = tgcm_${CF}${ARCH}.x) # execute: if (-e HISTCPY) rm HISTCPY ja $exec < $inp || goto fail_exec ja -cdst #ja -st # # Return metacode: # if ($?rmeta) then rcp gmeta $rmeta endif # # Return to parent (user) job script if requested: # if ($?RETURN) then goto $RETURN endif exit 0 #----------------------------------------------- # # Error traps: # fail_getbin: echo Msread of executable $msread_bin failed exit 1 # fail_modify: echo Modify failed exit 2 # fail_mkmake: echo $job\: mkmake failed. exit 3 # fail_mkdep: echo $job\: mkdep failed. exit 4 # fail_make: echo $job\: make failed. exit 5 # fail_exec: echo Model execution failed # 1/27/98: change debug to debugview #debug -B -s $exec debugview -c core $exec -B if ($?rmeta) then rcp gmeta $rmeta/$job.cgm endif ja -cslst exit 6