Back to home page

MITgcm

 
 

    


Warning, /utils/scripts/xplodemnc is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
79ad2ffb0a Jean*0001 #! /usr/bin/env bash
                0002 #
c9520951e9 Bayl*0003 # This is a shell script to separate an MITgcm mnc output file into
                0004 # one file per multi-dimensional variable. 
                0005 # The file should be in one directory, where this script is run.
                0006 # The resulting files will be in the same directory.
                0007 
26aa721ce9 Bayl*0008 DEBUG="--dbg_lvl=0"
015eade80b Bayl*0009 
c9520951e9 Bayl*0010 inone=$1
                0011 inone=${1:?"You must input an mnc filename to be xploded"}
                0012 
                0013 for somefile in $@
                0014 do
                0015   echo Extracting from file $somefile...
                0016   if [ ! -s $somefile ]; then
                0017     echo "Error: $somefile is missing or empty"
                0018     exit 1
                0019   fi
                0020 
015eade80b Bayl*0021 # Finding all the multidimensional variables
525eaadd5e Mart*0022   varls=$(ncdump -h $somefile | egrep "double|float" | egrep , )
c9520951e9 Bayl*0023   IFS=';'
                0024   vars=
                0025   for somevar in ${varls}
                0026   do
                0027    somevar1=${somevar%(*}
                0028    somevar1=${somevar1#*double }
015eade80b Bayl*0029    somevar1=${somevar1#*float }
26aa721ce9 Bayl*0030 #   echo $somevar1
c9520951e9 Bayl*0031    vars=${vars}$somevar1' '
                0032   done
                0033   IFS=' '
79ad2ffb0a Jean*0034   withIter=$(ncdump -h $somefile | grep -c 'int iter(' )
                0035   if [ $withIter -gt 0 ]; then vars=${vars}iter ; fi
                0036   echo Variables to extract: $vars
c9520951e9 Bayl*0037   for somevar in $vars
                0038   do
015eade80b Bayl*0039     ncks $DEBUG -v $somevar $somefile $somevar.$somefile
c9520951e9 Bayl*0040   done
                0041 done