# Hurricane Model Launching Script (GFDL Model) 4/23/95 -- Stephen Lord # Modified 4/14/99 by Tim Marchok; added function convy4y2 to convert a # 4-digit year to a 2-digit year, since NHC & FNMOC will begin sending # vitals to us in 4-digit year format starting 4/21/99. # Modified 5/24/11 by Luke Lin; ignored the storm.dev? convy4y2 () { # This function is called in order to modify a TC vitals record. # If the record contains a 2-digit year, the record is left alone # and merely written back out as is. If the record contains a # 4-digit year, then the "20" or "19" is cut off and the year is # written back out as a 2-digit year. awk ' { yycheck = substr($0,20,2) if ((yycheck == 20 || yycheck == 19) && (length($4) == 8)) { printf ("%s%s\n",substr($0,1,19),substr($0,22)) } else { printf ("%s\n",$0) } } ' $1 } # IBM/SP operational directories export ROTPRE=${ROTPRE:-/nwprod} export execdir=$ROTPRE/exec export fixdir=$ROTPRE/fix export nhcdir=${NHCDIR:-/tpc/save/guidance/storm-data/ncep} export mesagdir=${MESAGDIR:-/com/hur/prod/inpdata} echo "ROTPRE= $ROTPRE" echo "NHCDIR= $NHCDIR" echo "mesagdir= $mesagdir" cd $mesagdir echo "Messages are stored in directory mesagdir="$mesagdir # Copy in fixed file: fildef.sdm rm -rf fildef.sdm rm -rf core cp $fixdir/gfdl_fildef.sdm fildef.sdm chmod 775 fildef.sdm 2>/dev/null chgrp g02 fildef.sdm 2>/dev/null echo "Hurricane Model Launching Script (GFDL Model) 4/23/95 -- Stephen Lord 763-8005" echo " Your options are the following:" echo " Initialize the model run (i)" echo " Revise the previous initialization (r)" echo " Quit (q)" echo "Please enter i, r, or q now" read reply if test $reply = "i" -o $reply = "I" -o $reply = "r" -o $reply = "R" then if test $reply = "i" -o $reply = "I" then rm -rf storms.nhc echo "You have chosen to initialize for the GFDL model runs." n=1 num=`ls -l ${nhcdir} | grep storm | grep -v dev | wc -l` echo "ls of nhcdir ($nhcdir) follows...." ls -la $nhcdir if test $num -eq 0 then echo "!!! No storms found" else echo "There are $num storms to be initialized." while test $n -le $num do cat < ${nhcdir}/storm${n} | convy4y2 >> storms.nhc chmod 775 storms.nhc 2>/dev/null chgrp g02 storms.nhc 2>/dev/null n=`expr $n + 1` done fi fi if test $reply = "r" -o $reply = "R" then echo "You have chosen to revise the previous submisson." cat storms.checked | convy4y2 >storms.nhc cat storms.checked | convy4y2 >storms.prev chmod 775 storms.prev 2>/dev/null chgrp g02 storms.prev 2>/dev/null chmod 775 storms.nhc 2>/dev/null chgrp g02 storms.nhc 2>/dev/null fi # Execute storm card checking program $execdir/gfdl_gogfdl < /dev/tty errchk=$? echo "gogfdl completion code=$errchk" chmod 775 storms.checked gog.out 2>/dev/null chgrp g02 storms.checked gog.out 2>/dev/null convy4y2 storms.checked >tmpstorms chmod 775 tmpstorms 2>/dev/null chgrp g02 tmpstorms 2>/dev/null mv tmpstorms storms.checked chmod 775 storms.checked 2>/dev/null chgrp prod storms.checked 2>/dev/null if test $errchk -eq 0 then echo "Input storm cards have been constructed, ready to submit storm initialization scripts." numstm=` awk ' {line = $0} ; END {print NR} ' storms.checked ` if test $numstm -eq 0 then echo "Exiting normally with 0 storms to submit" exit fi # echo "Number of storms to be forecast=$numstm" echo "Input storm file has been constructed" chkdate=`sed -n "1,1 p" storms.checked` ymd=`echo $chkdate | awk ' {print $4} ' ` cyc=`echo $chkdate | awk ' {print $5} ' | cut -c1-2` echo $ymd$cyc > stormdate chmod 775 stormdate 2>/dev/null chgrp g02 stormdate 2>/dev/null if test $reply = "i" -o $reply = "I" then cat << eof1 > nstorms $numstm eof1 fi chmod 775 nstorms 2>/dev/null chgrp g02 nstorms 2>/dev/null ### For the 2002 gfdl nestno will be hardwired to =3 # echo "Enter the number of nests (2 or 3) for the forecast:" # read nestno # echo "Number of nests=$nestno" nestno=3 cat << eof3 > nestnum $nestno eof3 chmod 775 nestnum 2>/dev/null chgrp g02 nestnum 2>/dev/null nst=1 while test $nst -le $numstm do record=`sed -n "$nst,$nst p" storms.checked` if test $reply = "i" -o $reply = "I" then nstm=$nst fi if test $reply = "r" -o $reply = "R" then testid=`echo $record | awk ' {print $2} ' ` echo "record=$record" split -1 storms.prev zzz fnames=` ls zzz* ` nstz=0 for fname in $fnames do nstz=` expr $nstz + 1 ` stmid=` awk ' {print $2} ' $fname ` if test $stmid = $testid then nstm=$nstz echo "Storm id $stmid found as previously submitted storm number $nstm" fi done rm zzz* fi echo "Writing record=$record to initialization input file message$nstm" cat << eof2 > message$nstm $record eof2 chmod 775 message$nstm 2>/dev/null chgrp g02 message$nstm 2>/dev/null nst=`expr $nst + 1 ` done else echo "ERROR IN CONSTRUCTING INPUT STORM FILE. ABORT." exit 20 fi NUMBER=`cat < nstorms` export NUMBER echo "Number of storms to be forecast=$NUMBER" fi chmod 775 * 2>/dev/null chgrp prod * 2>/dev/null