| forrest@1 |      1 | ;************************************************
 | 
| forrest@1 |      2 | ;    Read ascii, Write nc
 | 
| forrest@1 |      3 | ;    output: lat: N->S     lon: -180W->180E                         
 | 
| forrest@1 |      4 | ;************************************************
 | 
| forrest@1 |      5 | load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
 | 
| forrest@1 |      6 | load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
 | 
| forrest@1 |      7 | load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  
 | 
| forrest@1 |      8 | ;************************************************
 | 
| forrest@1 |      9 | begin
 | 
| forrest@1 |     10 | 
 | 
| forrest@1 |     11 | ; output
 | 
| forrest@1 |     12 | 
 | 
| forrest@1 |     13 |   model_name = "i01.39cn"
 | 
| forrest@1 |     14 |   
 | 
| forrest@1 |     15 |   ;diro  = "/ptmp/jeff/"
 | 
| forrest@1 |     16 |   diro  = "/lustre/wolf-ddn/scratch/hof/cases1/i01.39cn_out/"
 | 
| forrest@1 |     17 |   filo  = model_name + "_ameriflux_2101-2125_monthly.nc"
 | 
| forrest@1 |     18 |   c = addfile(diro+filo,"c")
 | 
| forrest@1 |     19 |   filedimdef(c,"year",-1,True) 
 | 
| forrest@1 |     20 | 
 | 
| forrest@1 |     21 | ; input data
 | 
| forrest@1 |     22 | 
 | 
| forrest@1 |     23 |   nlat = 96
 | 
| forrest@1 |     24 |   nlon = 144
 | 
| forrest@1 |     25 | 
 | 
| forrest@1 |     26 |   year_start = 2101
 | 
| forrest@1 |     27 |   year_end   = 2125
 | 
| forrest@1 |     28 | 
 | 
| forrest@1 |     29 |   nyear  = year_end - year_start + 1
 | 
| forrest@1 |     30 |   nmonth = 12
 | 
| forrest@1 |     31 |   
 | 
| forrest@1 |     32 |   data1  = new((/nyear,nmonth,nlat,nlon/),float)
 | 
| forrest@1 |     33 |   data2  = new((/nyear,nmonth,nlat,nlon/),float)
 | 
| forrest@1 |     34 |   data3  = new((/nyear,nmonth,nlat,nlon/),float)
 | 
| forrest@1 |     35 |   ;data4  = new((/nyear,nmonth,nlat,nlon/),float)
 | 
| forrest@1 |     36 |   ;data5  = new((/nyear,nmonth,nlat,nlon/),float)
 | 
| forrest@1 |     37 |   data6  = new((/nyear,nmonth,nlat,nlon/),float)
 | 
| forrest@1 |     38 |   data7  = new((/nyear,nmonth,nlat,nlon/),float)
 | 
| forrest@1 |     39 |   data8  = new((/nyear,nmonth,nlat,nlon/),float)
 | 
| forrest@1 |     40 |   data9  = new((/nyear,nmonth,nlat,nlon/),float)
 | 
| forrest@1 |     41 |   data10 = new((/nyear,nmonth,nlat,nlon/),float)
 | 
| forrest@1 |     42 |   date   = new((/nyear,nmonth/),integer)
 | 
| forrest@1 |     43 | 
 | 
| forrest@1 |     44 | ;  name dimensions and assign coordinate variables
 | 
| forrest@1 |     45 | 
 | 
| forrest@1 |     46 |   data1!0    ="year"
 | 
| forrest@1 |     47 |   data1!1    ="month"
 | 
| forrest@1 |     48 |   data1!2    = "lat"
 | 
| forrest@1 |     49 |   data1!3    = "lon"
 | 
| forrest@1 |     50 | 
 | 
| forrest@1 |     51 |   data2!0    ="year"
 | 
| forrest@1 |     52 |   data2!1    ="month"
 | 
| forrest@1 |     53 |   data2!2    = "lat"
 | 
| forrest@1 |     54 |   data2!3    = "lon"
 | 
| forrest@1 |     55 | 
 | 
| forrest@1 |     56 |   data3!0    ="year"
 | 
| forrest@1 |     57 |   data3!1    ="month"
 | 
| forrest@1 |     58 |   data3!2    = "lat"
 | 
| forrest@1 |     59 |   data3!3    = "lon"
 | 
| forrest@1 |     60 | 
 | 
| forrest@1 |     61 |   ;data4!0    ="year"
 | 
| forrest@1 |     62 |   ;data4!1    ="month"
 | 
| forrest@1 |     63 |   ;data4!2    = "lat"
 | 
| forrest@1 |     64 |   ;data4!3    = "lon"
 | 
| forrest@1 |     65 | 
 | 
| forrest@1 |     66 |   ;data5!0    ="year"
 | 
| forrest@1 |     67 |   ;data5!1    ="month"
 | 
| forrest@1 |     68 |   ;data5!2    = "lat"
 | 
| forrest@1 |     69 |   ;data5!3    = "lon"
 | 
| forrest@1 |     70 | 
 | 
| forrest@1 |     71 |   data6!0    ="year"
 | 
| forrest@1 |     72 |   data6!1    ="month"
 | 
| forrest@1 |     73 |   data6!2    = "lat"
 | 
| forrest@1 |     74 |   data6!3    = "lon"
 | 
| forrest@1 |     75 | 
 | 
| forrest@1 |     76 |   data7!0    ="year"
 | 
| forrest@1 |     77 |   data7!1    ="month"
 | 
| forrest@1 |     78 |   data7!2    = "lat"
 | 
| forrest@1 |     79 |   data7!3    = "lon"
 | 
| forrest@1 |     80 | 
 | 
| forrest@1 |     81 |   data8!0    ="year"
 | 
| forrest@1 |     82 |   data8!1    ="month"
 | 
| forrest@1 |     83 |   data8!2    = "lat"
 | 
| forrest@1 |     84 |   data8!3    = "lon"
 | 
| forrest@1 |     85 | 
 | 
| forrest@1 |     86 |   data9!0    ="year"
 | 
| forrest@1 |     87 |   data9!1    ="month"
 | 
| forrest@1 |     88 |   data9!2    = "lat"
 | 
| forrest@1 |     89 |   data9!3    = "lon"
 | 
| forrest@1 |     90 | 
 | 
| forrest@1 |     91 |   data10!0    ="year"
 | 
| forrest@1 |     92 |   data10!1    ="month"
 | 
| forrest@1 |     93 |   data10!2    = "lat"
 | 
| forrest@1 |     94 |   data10!3    = "lon"
 | 
| forrest@1 |     95 | 
 | 
| forrest@1 |     96 |   date!0    ="year"
 | 
| forrest@1 |     97 |   date!1    ="month"
 | 
| forrest@1 |     98 |   date@long_name  = "date: yyyymm"
 | 
| forrest@1 |     99 | 
 | 
| forrest@1 |    100 | ; input dir
 | 
| forrest@1 |    101 |   diri  = "/lustre/wolf-ddn/scratch/hof/cases1/"+model_name+"/"
 | 
| forrest@1 |    102 | 
 | 
| forrest@1 |    103 |   do m = 0,nyear-1
 | 
| forrest@1 |    104 |      year = year_start + m
 | 
| forrest@1 |    105 |   do n = 0,nmonth-1
 | 
| forrest@1 |    106 |      nn = n+1
 | 
| forrest@1 |    107 |      date(m,n) = year*100 +nn 
 | 
| forrest@1 |    108 |      
 | 
| forrest@1 |    109 | ;    input file
 | 
| forrest@1 |    110 |      if (nn .ge. 10) then
 | 
| forrest@1 |    111 |         fili = model_name+".clm2.h0."+year+"-"+nn+".nc"
 | 
| forrest@1 |    112 |      else
 | 
| forrest@1 |    113 |         fili = model_name+".clm2.h0."+year+"-0"+nn+".nc"
 | 
| forrest@1 |    114 |      end if
 | 
| forrest@1 |    115 | 
 | 
| forrest@1 |    116 |      print (fili)
 | 
| forrest@1 |    117 | 
 | 
| forrest@1 |    118 |      g = addfile (diri+fili,"r")
 | 
| forrest@1 |    119 | 
 | 
| forrest@1 |    120 |      b = g->NEE
 | 
| forrest@1 |    121 |      data1(m,n,:,:) = (/b(0,:,:)/)
 | 
| forrest@1 |    122 |      data1@long_name  = b@long_name
 | 
| forrest@1 |    123 |      data1@units      = b@units
 | 
| forrest@1 |    124 |      data1@_FillValue = b@_FillValue
 | 
| forrest@1 |    125 |      delete (b)
 | 
| forrest@1 |    126 | 
 | 
| forrest@1 |    127 |      b = g->GPP
 | 
| forrest@1 |    128 |      data2(m,n,:,:) = (/b(0,:,:)/)
 | 
| forrest@1 |    129 |      data2@long_name  = b@long_name
 | 
| forrest@1 |    130 |      data2@units      = b@units
 | 
| forrest@1 |    131 |      data2@_FillValue = b@_FillValue
 | 
| forrest@1 |    132 |      delete (b)
 | 
| forrest@1 |    133 | 
 | 
| forrest@1 |    134 |      b = g->ER
 | 
| forrest@1 |    135 |      data3(m,n,:,:) = (/b(0,:,:)/)
 | 
| forrest@1 |    136 |      data3@long_name  = b@long_name
 | 
| forrest@1 |    137 |      data3@units      = b@units
 | 
| forrest@1 |    138 |      data3@_FillValue = b@_FillValue
 | 
| forrest@1 |    139 |      delete (b)
 | 
| forrest@1 |    140 | 
 | 
| forrest@1 |    141 |      ;b = g->NETRAD
 | 
| forrest@1 |    142 |      ;data4(m,n,:,:) = (/b(0,:,:)/)
 | 
| forrest@1 |    143 |      ;data4@long_name  = b@long_name
 | 
| forrest@1 |    144 |      ;data4@units      = b@units
 | 
| forrest@1 |    145 |      ;data4@_FillValue = b@_FillValue
 | 
| forrest@1 |    146 |      ;delete (b)
 | 
| forrest@1 |    147 | 
 | 
| forrest@1 |    148 |      ;b = g->LATENT
 | 
| forrest@1 |    149 |      ;data5(m,n,:,:) = (/b(0,:,:)/)
 | 
| forrest@1 |    150 |      ;data5@long_name  = b@long_name
 | 
| forrest@1 |    151 |      ;data5@units      = b@units
 | 
| forrest@1 |    152 |      ;data5@_FillValue = b@_FillValue
 | 
| forrest@1 |    153 |      ;delete (b)
 | 
| forrest@1 |    154 | 
 | 
| forrest@1 |    155 |      b = g->FSH
 | 
| forrest@1 |    156 |      data6(m,n,:,:) = (/b(0,:,:)/)
 | 
| forrest@1 |    157 |      data6@long_name  = b@long_name
 | 
| forrest@1 |    158 |      data6@units      = b@units
 | 
| forrest@1 |    159 |      data6@_FillValue = b@_FillValue
 | 
| forrest@1 |    160 |      delete (b)
 | 
| forrest@1 |    161 | 
 | 
| forrest@1 |    162 |      b = g->FSDS
 | 
| forrest@1 |    163 |      data7(m,n,:,:) = (/b(0,:,:)/)
 | 
| forrest@1 |    164 |      data7@long_name  = b@long_name
 | 
| forrest@1 |    165 |      data7@units      = b@units
 | 
| forrest@1 |    166 |      data7@_FillValue = b@_FillValue
 | 
| forrest@1 |    167 |      delete (b)
 | 
| forrest@1 |    168 | 
 | 
| forrest@1 |    169 |      b = g->FCEV
 | 
| forrest@1 |    170 |      data8(m,n,:,:) = (/b(0,:,:)/)
 | 
| forrest@1 |    171 |      data8@long_name  = b@long_name
 | 
| forrest@1 |    172 |      data8@units      = b@units
 | 
| forrest@1 |    173 |      data8@_FillValue = b@_FillValue
 | 
| forrest@1 |    174 |      delete (b)
 | 
| forrest@1 |    175 | 
 | 
| forrest@1 |    176 |      b = g->FCTR
 | 
| forrest@1 |    177 |      data9(m,n,:,:) = (/b(0,:,:)/)
 | 
| forrest@1 |    178 |      data9@long_name  = b@long_name
 | 
| forrest@1 |    179 |      data9@units      = b@units
 | 
| forrest@1 |    180 |      data9@_FillValue = b@_FillValue
 | 
| forrest@1 |    181 |      delete (b)
 | 
| forrest@1 |    182 | 
 | 
| forrest@1 |    183 |      b = g->FGEV
 | 
| forrest@1 |    184 |      data10(m,n,:,:) = (/b(0,:,:)/)
 | 
| forrest@1 |    185 |      data10@long_name  = b@long_name
 | 
| forrest@1 |    186 |      data10@units      = b@units
 | 
| forrest@1 |    187 |      data10@_FillValue = b@_FillValue
 | 
| forrest@1 |    188 |      delete (b)
 | 
| forrest@1 |    189 | 
 | 
| forrest@1 |    190 |   end do
 | 
| forrest@1 |    191 |   end do
 | 
| forrest@1 |    192 |          
 | 
| forrest@1 |    193 |   c->NEE = data1
 | 
| forrest@1 |    194 |   c->GPP = data2
 | 
| forrest@1 |    195 |   c->ER  = data3
 | 
| forrest@1 |    196 |   ;c->NETRAD = data4
 | 
| forrest@1 |    197 |   ;c->LATENT = data5
 | 
| forrest@1 |    198 |   c->FSH    = data6
 | 
| forrest@1 |    199 |   c->FSDS   = data7
 | 
| forrest@1 |    200 |   c->FCEV   = data8
 | 
| forrest@1 |    201 |   c->FCTR   = data9
 | 
| forrest@1 |    202 |   c->FGEV   = data10
 | 
| forrest@1 |    203 |   c->date   = date
 | 
| forrest@1 |    204 |   c->area   = g->area
 | 
| forrest@1 |    205 | 
 | 
| forrest@1 |    206 |   print (date)
 | 
| forrest@1 |    207 | 
 | 
| forrest@1 |    208 | end
 |