all/99.final.ncl
author Forrest Hoffman <forrest@climatemodeling.org>
Mon, 26 Jan 2009 22:08:20 -0500
changeset 0 0c6405ab2ff4
permissions -rw-r--r--
Initial commit of C-LAMP Diagnostics from Jeff Lee
     1 ;********************************************************
     2 ; landfrac applied to area only.
     3 ; using model biome class
     4 ;
     5 ; required command line input parameters:
     6 ;  ncl 'model_name="10cn" model_grid="T42" dirm="/.../ film="..."' 01.npp.ncl
     7 ;
     8 ; histogram normalized by rain and compute correleration
     9 ;**************************************************************
    10 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
    11 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
    12 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
    13 ;**************************************************************
    14 procedure set_line(lines:string,nline:integer,newlines:string) 
    15 begin
    16 ; add line to ascci/html file
    17     
    18   nnewlines = dimsizes(newlines)
    19   if(nline+nnewlines-1.ge.dimsizes(lines))
    20     print("set_line: bad index, not setting anything.") 
    21     return
    22   end if 
    23   lines(nline:nline+nnewlines-1) = newlines
    24 ;  print ("lines = " + lines(nline:nline+nnewlines-1))
    25   nline = nline + nnewlines
    26   return 
    27 end
    28 ;**************************************************************
    29 ; Main code.
    30 begin
    31 ;--------------------------------------------------
    32 ; edit table.html of current model for movel1_vs_model2
    33 
    34  if (isvar("compare")) then
    35     html_name2 = compare+"/table.html"  
    36     html_new2  = html_name2 +".new"
    37  end if
    38 
    39 ;-------------------------------------
    40 ; edit table.html for current model
    41 
    42  html_name = model_name+"/table.html"  
    43  html_new  = html_name +".new"
    44 
    45 ;---------------------------------------------------
    46 ; add total score and update metric table
    47 
    48   M_save = 0.
    49 
    50   if (isfilepresent("M_save.npp")) then
    51      M_save = M_save + asciiread("M_save.npp",(/1/),"float")
    52   end if
    53 
    54   if (isfilepresent("M_save.lai")) then
    55      M_save = M_save + asciiread("M_save.lai",(/1/),"float")
    56   end if 
    57 
    58   if (film3 .ne. "") then
    59   if (isfilepresent("M_save.co2")) then
    60      M_save = M_save + asciiread("M_save.co2",(/1/),"float")
    61   end if
    62   end if
    63 
    64   if (isfilepresent("M_save.biomass")) then
    65      M_save = M_save + asciiread("M_save.biomass",(/1/),"float")
    66   end if
    67 
    68   if (isfilepresent("M_save.fluxnet")) then
    69      M_save = M_save + asciiread("M_save.fluxnet",(/1/),"float")
    70   end if
    71 
    72   if (isfilepresent("M_save.beta")) then
    73      M_save = M_save + asciiread("M_save.beta",(/1/),"float")
    74   end if
    75 
    76   if (isfilepresent("M_save.fire")) then
    77      M_save = M_save + asciiread("M_save.fire",(/1/),"float")
    78   end if
    79 
    80   if (isfilepresent("M_save.ameriflux")) then
    81      M_save = M_save + asciiread("M_save.ameriflux",(/1/),"float")
    82   end if
    83 
    84   M_total = sprintf("%.2f", M_save)
    85 
    86   if (isvar("compare")) then
    87      system("sed -e '1,/M_total/s/M_total/"+M_total+"/' "+html_name2+" > "+html_new2+";"+ \
    88             "mv -f "+html_new2+" "+html_name2)
    89   end if
    90 
    91   system("sed s#M_total#"+M_total+"# "+html_name+" > "+html_new+";"+ \
    92          "mv -f "+html_new+" "+html_name+";"+ \
    93          "rm M_save.*")
    94 end
    95