carbon_sink/02.write_tseries_casa.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
forrest@0
     1
;************************************************
forrest@0
     2
;    read from mss
forrest@0
     3
;    output fire(COL_FIRE_CLOSS), NPP, NEE                        
forrest@0
     4
;************************************************
forrest@0
     5
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
forrest@0
     6
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
forrest@0
     7
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  
forrest@0
     8
;************************************************
forrest@0
     9
begin
forrest@0
    10
forrest@0
    11
; input data
forrest@0
    12
forrest@0
    13
  model_name = "i01.10casa"
forrest@0
    14
forrest@0
    15
  nlat = 64
forrest@0
    16
  nlon = 128
forrest@0
    17
forrest@0
    18
  year_start = 1979
forrest@0
    19
  year_end   = 2004
forrest@0
    20
forrest@0
    21
  diri  = "/ptmp/jeff/"+model_name+"/"
forrest@0
    22
forrest@0
    23
  system("mkdir "+diri)
forrest@0
    24
forrest@0
    25
; output
forrest@0
    26
  
forrest@0
    27
  diro  = "/ptmp/jeff/"
forrest@0
    28
  filo  = model_name + "_Fire_C_"+year_start+"-"+year_end+"_monthly.nc"
forrest@0
    29
  c = addfile(diro+filo,"c")
forrest@0
    30
  filedimdef(c,"year",-1,True) 
forrest@0
    31
forrest@0
    32
forrest@0
    33
  nyear  = year_end - year_start + 1
forrest@0
    34
  nmonth = 12
forrest@0
    35
  
forrest@0
    36
; data1  = new((/nyear,nmonth,nlat,nlon/),float)
forrest@0
    37
  data2  = new((/nyear,nmonth,nlat,nlon/),float)
forrest@0
    38
  data3  = new((/nyear,nmonth,nlat,nlon/),float)
forrest@0
    39
  date   = new((/nyear,nmonth/),integer)
forrest@0
    40
forrest@0
    41
; input from mss
forrest@0
    42
forrest@0
    43
  do m = 0,nyear-1
forrest@0
    44
     year = year_start + m
forrest@0
    45
forrest@0
    46
     text = "mss:/FORREST/CCSM/results/"+model_name+"/lnd/hist/*"+year+"* "
forrest@0
    47
     print (text)
forrest@0
    48
forrest@0
    49
     system("msrcp "+text+diri)
forrest@0
    50
     system("dcswait")
forrest@0
    51
     print (year)   
forrest@0
    52
forrest@0
    53
  do n = 0,nmonth-1
forrest@0
    54
     nn = n+1
forrest@0
    55
     date(m,n) = year*100 +nn 
forrest@0
    56
     
forrest@0
    57
;    input file
forrest@0
    58
     if (nn .ge. 10) then
forrest@0
    59
        fili = model_name+".clm2.h0."+year+"-"+nn+".nc"
forrest@0
    60
     else
forrest@0
    61
        fili = model_name+".clm2.h0."+year+"-0"+nn+".nc"
forrest@0
    62
     end if
forrest@0
    63
forrest@0
    64
;    print (fili)
forrest@0
    65
forrest@0
    66
     g  = addfile (diri+fili,"r")
forrest@0
    67
forrest@0
    68
;    b1 = g->COL_FIRE_CLOSS
forrest@0
    69
;    data1(m,n,:,:) = (/b1(0,:,:)/)
forrest@0
    70
forrest@0
    71
     b2 = g->NPP
forrest@0
    72
     data2(m,n,:,:) = (/b2(0,:,:)/)
forrest@0
    73
forrest@0
    74
     b3 = g->NEE
forrest@0
    75
     data3(m,n,:,:) = (/b3(0,:,:)/)
forrest@0
    76
    
forrest@0
    77
  end do
forrest@0
    78
forrest@0
    79
;    system("rm "+diri+"*")     
forrest@0
    80
forrest@0
    81
  end do
forrest@0
    82
forrest@0
    83
;  name dimensions and assign coordinate variables
forrest@0
    84
forrest@0
    85
; data1!0    ="year"
forrest@0
    86
; data1!1    ="month"
forrest@0
    87
; data1!2    = "lat"
forrest@0
    88
; data1!3    = "lon"
forrest@0
    89
; data1@long_name  = b1@long_name
forrest@0
    90
; data1@units      = b1@units
forrest@0
    91
; data1@_FillValue = b1@_FillValue
forrest@0
    92
forrest@0
    93
  data2!0    ="year"
forrest@0
    94
  data2!1    ="month"
forrest@0
    95
  data2!2    = "lat"
forrest@0
    96
  data2!3    = "lon"
forrest@0
    97
  data2@long_name  = b2@long_name
forrest@0
    98
  data2@units      = b2@units
forrest@0
    99
  data2@_FillValue = b2@_FillValue
forrest@0
   100
forrest@0
   101
  data3!0    ="year"
forrest@0
   102
  data3!1    ="month"
forrest@0
   103
  data3!2    = "lat"
forrest@0
   104
  data3!3    = "lon"
forrest@0
   105
  data3@long_name  = b3@long_name
forrest@0
   106
  data3@units      = b3@units
forrest@0
   107
  data3@_FillValue = b3@_FillValue
forrest@0
   108
forrest@0
   109
  date!0    ="year"
forrest@0
   110
  date!1    ="month"
forrest@0
   111
  date@long_name  = "date: yyyymm"
forrest@0
   112
         
forrest@0
   113
; c->COL_FIRE_CLOSS = data1
forrest@0
   114
  c->NPP            = data2
forrest@0
   115
  c->NEE            = data3
forrest@0
   116
  c->date           = date
forrest@0
   117
  c->area           = g->area
forrest@0
   118
forrest@0
   119
  print (date)
forrest@0
   120
forrest@0
   121
end