source: CONFIG/IPSLCM/IPSLCM5A/CpiControl/COMP/lmdz_analyse_pisces_out.awk @ 1234

Last change on this file since 1234 was 1234, checked in by mmaipsl, 12 years ago

Add awk scripts to get CO2 values from text outputs of PISCES and STOMATE components.

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1#!/usr/bin/awk -f
2# lmdz_analyse_opa_out - filter NEMO/PISCES output :
3# command :
4# lmdz_analyse_opa_out.awk [-d] ocean.output
5
6#**************************************************************
7# Author: Martial.Mancip
8# Contact: Martial.Mancip__at__ipsl.jussieu.fr
9# $Revision:: 373                                      $ Revision of last commit
10# $Author:: sdipsl                                     $ Author of last commit
11# $Date:: 2010-10-29 12:37:36 +0200 (Fri, 29 Oct 2010) $ Date of last commit
12# IPSL (2006)
13#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
14#
15#**************************************************************
16
17#==========================
18function myprint(str) {
19  if (debug) {
20     print str
21  }
22}
23
24
25#==========================
26BEGIN {
27#  print "traitement de " ARGV[1]
28
29  nbarg=ARGC
30
31  if (ARGV[1] == "-d") {
32    debug=1
33    file=ARGV[2]
34    delete ARGV[1] 
35    nbarg--
36  } else {
37    debug=0
38    file=ARGV[1]
39  }
40
41  exit_value=0
42  if (nbarg != 2) {
43        print "Usage: lmdz_analyse_opa_out.awk [-d] file"
44        exit_value=-1
45        exit
46  }
47
48  line=0
49
50  fluxCarbon_found=0
51  counter=0
52
53  CO2file[1]=""
54  errcounter=0
55}
56
57#==========================
58{
59
60#  myprint($0)
61
62  line=line+1
63 
64  if (match($0, ".*Cumulative total Flux of Carbon out of the ocean.*")) {
65    fluxCarbon_found=1
66    myprint("fluxCarbon_found=1")
67
68    nb=split($0,felts, ":")
69    myprint("nb  :" nb)
70    for (elt in felts) {
71        myprint(elt "- elt  :" felts[elt])
72    }
73    myprint("elts_co2  :" felts[2])
74
75    counter=counter+1
76    CO2file[counter]=felts[2]
77  }
78}
79
80#==========================
81END {
82  if ( exit_value != -1 ) {
83
84    if ( fluxCarbon_found == 1 ) {
85        myprint("CO2 value for " file)
86        myprint("counter  :" counter)
87        for (i=1; i<=counter; i++) { 
88            print CO2file[i]
89            myprint("value  :" CO2file[i])
90        }
91       
92        exit_value=0
93        exit 0
94    }
95    else {
96        myprint("ERROR : NO CO2 value for " file)
97        print "0001"
98    }
99   
100  }
101  else {
102      print "0000"
103  }
104}
Note: See TracBrowser for help on using the repository browser.