#!/bin/ksh # MKEXE 2003/12/30 # reMaKe the EXEcutable modules for a Model run # OMDIR=$HOME ; OUTPAR=$HOME # Rundeck (runID.R) is assumed to reside in Present Working Directory # Compiled object modules are assumed to reside in Present Working # Directory or else in the directory OMDIR . # The executable module will be saved in the directory OUTPAR/RUNID . if [[ $# -eq 0 ]] then echo " Usage: MKEXE runID 2003/12/30" echo " ReMaKe EXEcutable module of Fortran-90 Model run" echo " Default directory of compiled object modules: $OMDIR" echo " Output parent directory of run directory: $OUTPAR" exit ; fi RUNID=$1 ; RFILE=$RUNID.R ; OUTPUT=$OUTPAR/$RUNID if [[ ! -s $RFILE ]] then echo "File does not exist: $RFILE" ; exit 2 ; fi if [[ ! -d $OUTPUT ]] then echo "Run directory does not exist: $OUTPUT" echo "Consider executing: SETUP $RUNID" ; exit 3 ; fi # Make RFILE the standard input exec < $RFILE # Read RFILE until "Object modules:" is encountered until [[ $VAR1 = 'Object' && $VAR2 = 'modules:' ]] ; do read VAR1 VAR2 if [[ $? -ne 0 ]] then echo "'"Object modules:"' not found in $RFILE" ; exit 4 ; fi done # Set beginning of link command that creates executable module # LINK="xlf90 -o $OUTPUT/$RUNID.exe -O2" ## xlf LINK=" f90 -o $OUTPUT/$RUNID.exe -O3 -64 -mips4" ## SGI # LINK=" f90 -o $OUTPUT/$RUNID.exe -O4 -convert big_endian" ## Compaq # Add the names of all object modules to LINK command while true ; do read VAR1 VAR2 VAR3 if [[ $? -ne 0 ]] then echo "'"Data input files:"' not found in $RFILE" ; exit 5 ; fi if [[ $VAR1 = 'Data' && $VAR2 = 'input' && $VAR3 = 'files:' ]] then break ; fi if [[ $VAR1 != '' ]] then for VAR in $VAR1 $VAR2 $VAR3 ; do if [[ $VAR = '!' ]] then break ; fi OM=$VAR.o if [[ ! -r $OM ]] then OM=$OMDIR/$VAR.o ; fi if [[ ! -r $OM ]] then echo "Neither $VAR.o nor $OM exists." ; exit 6 ; fi LINK="$LINK $OM" ; done ; fi ; done # Recreate the executable module OUTPUT/RUNID.exe rm -f $OUTPUT/$RUNID.exe WARN.f90 $LINK 2> WARN.f90 if [[ -s WARN.f90 ]] then echo "Compiler warnings saved in: WARN.f90 . Inspect them." ; fi if [[ ! -s $OUTPUT/$RUNID.exe ]] then echo "Link errors. MKEXE terminated." ; exit 7 ; fi echo "$RUNID.exe recreated."