#!/bin/csh -f # +-======-+ # Copyright (c) 2003-2007 United States Government as represented by # the Admistrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE, # REPRODUCTION, DISTRIBUTION, MODIFICATION AND REDISTRIBUTION OF CERTAIN # COMPUTER SOFTWARE ORIGINALLY RELEASED BY THE UNITED STATES GOVERNMENT AS # REPRESENTED BY THE GOVERNMENT AGENCY LISTED BELOW ("GOVERNMENT AGENCY"). # THE UNITED STATES GOVERNMENT, AS REPRESENTED BY GOVERNMENT AGENCY, IS AN # INTENDED THIRD-PARTY BENEFICIARY OF ALL SUBSEQUENT DISTRIBUTIONS OR # REDISTRIBUTIONS OF THE SUBJECT SOFTWARE. ANYONE WHO USES, REPRODUCES, # DISTRIBUTES, MODIFIES OR REDISTRIBUTES THE SUBJECT SOFTWARE, AS DEFINED # HEREIN, OR ANY PART THEREOF, IS, BY THAT ACTION, ACCEPTING IN FULL THE # RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN THIS AGREEMENT. # # Government Agency: National Aeronautics and Space Administration # Government Agency Original Software Designation: GSC-15354-1 # Government Agency Original Software Title: GEOS-5 GCM Modeling Software # User Registration Requested. Please Visit http://opensource.gsfc.nasa.gov # Government Agency Point of Contact for Original Software: # Dale Hithon, SRA Assistant, (301) 286-2691 # # +-======-+ if( .$3 == . ) then set filetype = checkpoint else set filetype = $3 endif # Create List of Comparison Files # ------------------------------- set dir = `pwd` cd $1 set chk_files = `/bin/ls -1 *${filetype}*` set restarts = '' foreach file ($chk_files) # Compute number of "Dot" delimiters # ---------------------------------- @ n = 0 @ b = 1 set bit = `echo $file | cut -b $b` while( "${bit}" != '' ) if( "${bit}" == '.' ) then @ n = $n + 1 endif @ b = $b + 1 set bit = `echo ${file} | cut -b $b` end #echo Number of Dots for ${file}: $n # Find node matching "internal" or "import" # ----------------------------------------- if( $n != 0 ) then @ m = 1 set node = `echo $file | cut -d. -f$m` while( $node != '' ) set check_internal = `echo $node | grep internal` set check_import = `echo $node | grep import` if( $check_internal == $node | \ $check_import == $node ) then set rstname = $node set node = '' else @ m = $m + 1 set node = `echo $file | cut -d. -f$m` endif end else set rstname = $file endif # Add name to list of restarts # ---------------------------- set found = FALSE foreach rst ($restarts) if( $rst == $rstname ) set found = TRUE end #echo RESTART Name: $rstname FOUND: $found if( $found == FALSE ) then set restarts = `echo $restarts $rstname` endif end echo "" echo "Comparing Files ..." foreach rst ($restarts) echo " $rst" end echo "" cd $dir # Compare Files # ------------- foreach restart ( $restarts ) echo "Comparing $restart ..." echo "---------------------------------" set rsts1 = `/bin/ls -1 $1/*${restart}*` set rsts2 = `/bin/ls -1 $2/*${restart}*` if( $#rsts1 != 0 & $#rsts2 != 0 ) then foreach rst1 ($rsts1) foreach rst2 ($rsts2) set frmt1 = `file -ib $rst1 | cut -d/ -f2` set frmt2 = `file -ib $rst2 | cut -d/ -f2` if( "$frmt1" != "$frmt2" ) then echo "File Formats do not agree!" echo "$rst1 Format: $frmt1" echo "$rst2 Format: $frmt2" else if( "$frmt1" == "x-hdf" ) then set cmd = "cdo -s -diffn" else set cmd = cmp endif if( -e diffs ) /bin/rm -rf diffs echo " $cmd $rst1 $rst2" $cmd $rst1 $rst2 | tee diffs set RC = $status if( "$cmd" == "cdo -s -diffn" & $RC[1] == 0 ) set RC = `cat diffs | cut -do -f1` if( -e diffs ) /bin/rm -rf diffs if( $RC[1] == 0 ) then echo " Success!" echo " " else echo " Failed!" echo " " set size1 = `/bin/ls -l $rst1 | cut -d' ' -f5` set size2 = `/bin/ls -l $rst2 | cut -d' ' -f5` if( $size1 != $size2 ) then set size = $size1 if( $size1 > $size2 ) set size = $size2 echo " Comparing first $size bytes ..." if( "$cmd" == "cdo -s -diffn" ) then cdo -n $size -s -diffn $rst1 $rst2 else cmp -n $size $rst1 $rst2 endif if( $status == 0 ) then echo " Success!" echo " " else echo " Failed Again!" echo " " endif endif endif endif end end endif end