#!/usr/bin/awk -f # lmdz_analyse_opa_out - filter NEMO/PISCES output : # command : # lmdz_analyse_opa_out.awk [-d] ocean.output #************************************************************** # Author: Martial.Mancip # Contact: Martial.Mancip__at__ipsl.jussieu.fr # $Revision:: 373 $ Revision of last commit # $Author:: sdipsl $ Author of last commit # $Date:: 2010-10-29 12:37:36 +0200 (Fri, 29 Oct 2010) $ Date of last commit # IPSL (2006) # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC # #************************************************************** #========================== function myprint(str) { if (debug) { print str } } #========================== BEGIN { # print "traitement de " ARGV[1] nbarg=ARGC if (ARGV[1] == "-d") { debug=1 file=ARGV[2] delete ARGV[1] nbarg-- } else { debug=0 file=ARGV[1] } exit_value=0 if (nbarg != 2) { print "Usage: lmdz_analyse_opa_out.awk [-d] file" exit_value=-1 exit } line=0 fluxCarbon_found=0 counter=0 CO2file[1]="" errcounter=0 } #========================== { # myprint($0) line=line+1 if (match($0, ".*Cumulative total Flux of Carbon out of the ocean.*")) { fluxCarbon_found=1 myprint("fluxCarbon_found=1") nb=split($0,felts, ":") myprint("nb :" nb) for (elt in felts) { myprint(elt "- elt :" felts[elt]) } myprint("elts_co2 :" felts[2]) counter=counter+1 CO2file[counter]=felts[2] } } #========================== END { if ( exit_value != -1 ) { if ( fluxCarbon_found == 1 ) { myprint("CO2 value for " file) myprint("counter :" counter) for (i=1; i<=counter; i++) { print CO2file[i] myprint("value :" CO2file[i]) } exit_value=0 exit 0 } else { myprint("ERROR : NO CO2 value for " file) print "0001" } } else { print "0000" } }