source: branches/publications/ORCHIDEE_CAMEO_gmd_2022/src_parameters/script_livestockparametersconfig.awk

Last change on this file was 6929, checked in by maureen.beaudor, 4 years ago

adding the scripts for livestock parameters files generation

File size: 3.9 KB
Line 
1BEGIN{
2FS="::"
3toanalyse=0
4firstvar=1
5
6print "!! ================================================================================================================================"
7print "!! SUBROUTINE   : config_livestock_parameters                                                                                              "
8print "!!                                                                                                                                 "
9print "!>\BRIEF          This subroutine will read the imposed values for the global livestock                                            "
10print "!! parameters                                              "
11print "!!                                                                                                                                 "
12print "!! DESCRIPTION  : None                                                                                                             "
13print "!!                                                                                                                                 "
14print "!! RECENT CHANGE(S): None                                                                                                          "
15print "!!                                                                                                                                 "
16print "!! MAIN OUTPUT VARIABLE(S): None                                                                                                   "
17print "!!                                                                                                                                 "
18print "!! REFERENCE(S) : None                                                                                                             "
19print "!!                                                                                                                                 "
20print "!! FLOWCHART    : None                                                                                                             "
21print "!! \n                                                                                                                              "
22print "!_ ================================================================================================================================"
23print "                                                                                                                                   "
24print "  SUBROUTINE config_livestock_parameters                                                                                           "
25print "                                                                                                                                   "
26print "    IMPLICIT NONE                                                                                                                  "
27print "                                                                                                                                   "
28print "    !! 0. Variables and parameters declaration                                                                                     "
29print "                                                                                                                                   "
30print "    !! 0.4 Local variable                                                                                                          "
31print "                                                                                                                                   "
32print "    INTEGER(i_std) :: jv                   !! Index (untiless)                                                                     "
33print "                                                                                                                                   "
34print "    !_ ============================================================================================================================"
35
36
37}
38{
39    if($2!="")
40    {
41        if(toanalyse) 
42        {
43            if(!firstvar)
44            {
45                print "!Config Def ="valuestoprint
46                print "!Config Help ="helptoprint
47                print "!Config Units = "myunit
48                print "CALL getin_p('"toupper(myvar)"',"myvar")"
49            }
50        }
51        var="echo \""$2"\"|sed -e 's/\=\.\*//'"
52        var | getline myvar
53        close(var)
54
55        var="echo \""myvar"\"|sed -e 's/_mtc//'"
56        var | getline myvar
57        close(var)
58
59        var="echo \""myvar"\"|sed -e 's/\ //g'"
60        var | getline myvar
61        close(var)
62
63        if(myvar=="LMTC_name") toanalyse=1
64
65        if(myvar=="nvmc") myvar="nvm"
66        if(myvar=="LMTC_name") myvar="LIVESTOCK_name"
67
68        if(myvar=="nvm")
69        {
70            declar="echo \""$1"\"|sed -e 's/PARAMETER/SAVE/'"
71            declar | getline mydeclar
72            close(declar)
73        }
74        else
75        {
76            declar="echo \""$1"\"|sed -e 's/PARAMETER/ALLOCATABLE, SAVE/'"
77            declar | getline mydeclar
78            close(declar)
79        }
80        declar="echo \""mydeclar"\"|sed -e 's/nvmc/:/'"
81        declar | getline mydeclar
82        close(declar)
83
84
85        comment="echo \""$2"\"|sed -e 's/\\(.*\\)\!!\\(.*\\)/\\2/'"
86        comment | getline mycomment
87        close(comment)
88
89        unit="echo \""mycomment"\"|grep -o '(.*)' | sed -e 's/(/[/' | sed -e 's/)/]/' "
90        unit | getline myunit
91        close(unit)
92
93       
94        if(toanalyse) 
95        {
96            valuestoprint=""
97            helptoprint=""
98            myvalues=""
99            firstvar=0
100            printf("\n")
101            print "!Config Key   = "toupper(myvar)
102            print "!Config Desc = "mycomment
103            print "!Config if ="
104
105
106        }
107    }
108    else
109    {
110        comment="echo \""$1"\"|sed -e 's/\ //g'"
111        comment | getline mycomment
112        close(comment)
113        if(substr(mycomment,1,1)=="&")
114        {
115            values=substr(mycomment,2)
116            values="echo \""values"\"|sed -e 's/&.*//g'|sed -e 's/!!.*//g'"
117            values | getline myvalues
118            close(values)
119            valuestoprint=sprintf("%s%s",valuestoprint,myvalues)
120
121#comment="echo \""$1"\"|sed -e 's/\\([^!]*\\)\\(.*\\)/\\2/'"
122        }
123        help="echo \""$1"\"|grep -o '!!.*'|sed -e 's/!//g'"
124        help | getline myhelp
125        close(help)
126        if(myhelp!="") 
127        {
128            helptoprint=sprintf("%s%s",helptoprint,myhelp)
129            myhelp=""
130        }
131           
132#       else
133#       {
134#           comment="echo \""$1"\"|sed -e 's/\\([^!]*\\)\\(.*\\)/\\2/'"
135#           comment | getline mycomment
136#           close(comment)
137#       }
138    }
139}
140END{
141    print "!Config Def ="valuestoprint
142    print "!Config Help ="helptoprint
143    print "!Config Units = "myunit
144    print "CALL getin_p('"toupper(myvar)"',"myvar")"
145    print "SUBROUTINE config_livestock_parameters"
146}
Note: See TracBrowser for help on using the repository browser.