#! /usr/bin/env bash # # $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/calc_diagnostics_dims,v 1.1 2004/02/13 06:05:49 edhill Exp $ # $Name: checkpoint64v $ # The purpose of this script is to calculate the exact number of "z" # dimensions needed within a FORTRAN storage array for the MITgcm # diagnostics package. usage() { cat < ./tmp_diagnostic_names DNAMES= vcode=0 cat $DATA_FILE | while read line ; do r0=t r1=t echo $line | grep '^[ ]*#' > /dev/null 2>&1 && r0=f echo $line | grep "$SEPARATOR" > /dev/null 2>&1 && r1=f if test "x$vcode" = x1 ; then echo $line | grep '=' > /dev/null 2>&1 && vcode=0 fi echo $line | grep "$VAR_NAME"'[ ]*=' > /dev/null 2>&1 && vcode=1 if test $r0 = t -a $r1 = t -a ! "x$vcode" = x0 ; then t1=`echo $line | sed -e "s|$VAR_NAME| |g" | sed -e 's|=| |g'` t2=`echo $t1 | sed -e "s|'| |g" | sed -e 's|,| |g'` echo "$t2" >> ./tmp_diagnostic_names fi done DNAMES=`cat ./tmp_diagnostic_names` rm -rf ./tmp_diagnostic_names # Get the size of $NRPHYS t1=`cat $fizhi_SIZE | grep -i Nrphys | grep -i "^[ ]*parameter"` t2=`echo $t1 | sed -e 's|(| |g' | sed -e 's|)| |g' | sed -e 's|=| |g'` NRPHYS=`echo $t2 | awk '{print $3}'` # Get the number of "z" dimensions numz=0 for dnam in $DNAMES ; do t1=`grep -i "n"$dnam $pack_h | grep -i '^[ ]*EQUIVALENCE'` t2=`echo $t1 | sed -e 's|(| |g' | sed -e 's|)| |g'` t3=`echo $t2 | awk '{print $3}'` if test ! "x$t3" = x ; then t1=`cat $init_vals | grep -i '^[ ]*KDIAG' | grep $t3` t2=`echo $t1 | sed -e 's|(| |g' | sed -e 's|)| |g'` t3=`echo $t2 | sed -e 's|=| |g' | awk '{print $3}'` t1=`echo $t3 | sed -e "s|nrphys|$NRPHYS|g"` numz=$(( $numz + $t1 )) fi done echo "$numz"