source: CONFIG/IPSLCM/IPSLCM5A/Chistorical/COMP/lmdz_analyse_stomate_out.awk @ 1237

Last change on this file since 1237 was 1237, checked in by mmaipsl, 14 years ago

First CO2 interactive historical scripts.
Please, see https://forge.ipsl.jussieu.fr/igcmg/wiki/IPSLCM5ACo2 for informations.
And follow links in https://forge.ipsl.jussieu.fr/igcmg/wiki/IPSLCM5ACo2#Testsetruns
for example of use.

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1#!/usr/bin/awk -f
2# lmdz_analyse_stomate_out - filter ORCHIDEE node output :
3# command :
4# lmdz_analyse_stomate_out.awk [-d] out_orchidee[_0000]
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_stomate_out.awk [-d] file"
44        exit_value=-1
45        exit
46  }
47
48  line=0
49
50  fluxCarbon_found=0
51  counterCO2=0
52
53  fluxLU_found=0
54  counterLU=0
55
56  CO2file[1]=""
57  LUfile[1]=""
58}
59
60#==========================
61{
62
63#  myprint($0)
64
65  line=line+1
66
67  if (match($0, ".*GLOBAL net_co2_flux_monthly.*")) {
68    myprint("fluxCarbon_found = 1")
69    fluxCarbon_found=1
70    counterCO2=counterCO2+1
71
72    nb=split($0,felts, "=")
73    myprint("nb  :" nb)
74    for (elt in felts) {
75        myprint(elt "- elt  :" felts[elt])
76    }
77    myprint("elts_co2  :" felts[2])
78
79    CO2file[counterCO2]=felts[2]
80  }
81  else if (match($0, ".*GLOBAL net cflux_prod_total_sum.*")) {
82    myprint("fluxLU_found = 1")
83    fluxLU_found=1
84    counterLU=counterLU+1
85
86    nb=split($0,felts, "=")
87    myprint("nb  :" nb)
88    for (elt in felts) {
89        myprint(elt "- elt  :" felts[elt])
90    }
91    myprint("elts_lu  :" felts[2])
92
93    LUfile[counterLU]=felts[2]
94  }
95}
96
97#==========================
98END {
99  if ( exit_value != -1 ) {
100
101    if ( fluxCarbon_found == 1 ) {
102        myprint("CO2 value for " file)
103        myprint("counterCO2  :" counterCO2)
104        for (i=1; i<=counterCO2; i++) { 
105            print CO2file[i]
106            myprint("value  :" CO2file[i])
107        }
108       
109        if ( fluxLU_found == 1 ) {
110            myprint("LU value for " file)
111            myprint("counterLU  :" counterLU)
112            for (i=1; i<=counterLU; i++) { 
113                print LUfile[i]
114                myprint("value  :" LUfile[i])
115            }
116           
117            exit_value=0
118            exit 0
119        }
120        else {
121            myprint("ERROR : NO LU value for " file)
122            print "0002"
123            exit 1
124        }
125
126        exit_value=0
127        exit 0
128    }
129    else {
130        myprint("ERROR : NO CO2 value for " file)
131        print "0001"
132        print "0002"
133        exit 1
134    }
135   
136  }
137  else {
138      print "0000"
139      exit 1
140  }
141}
Note: See TracBrowser for help on using the repository browser.