Skip to content

Commit

Permalink
add some comments to docn gen code from ALCC runs
Browse files Browse the repository at this point in the history
  • Loading branch information
zarzycki committed Mar 6, 2023
1 parent 9cc32e6 commit d3b0228
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions slab-ocn/external-to-docn.ncl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
begin

; this script takes in some sort of external file (infile) with different vars
; for SST and ice (ex: sst and icec) and converts it to monthly means at the midpoint
; of each month in proper format to be used for CIME DOCN streams.

f=addfile(infile,"r")

Expand All @@ -14,9 +17,10 @@ lon_out = r->lon
var_in = f->sst(:,::-1,:)
ice_in = f->icec(:,::-1,:)

; get rid of missing data (usually over land areas)
; first go east/west, then north/south for SST and set to 0 for ICEFRAC
var_in = linmsg(var_in,-1)
var_in = linmsg_n(var_in,-1,1)

ice_in = linmsg(ice_in,-1)
ice_in = where(ismissing(ice_in),0.0,ice_in)

Expand All @@ -27,36 +31,41 @@ dd = toint(alldates(:,2))
sssss = toint(alldates(:,5))

do ii = 0,dimsizes(time_in)-1
; all months of 30 + 31 have midpoint on 16th day, but feb is on 15th
if (mm(ii) .eq. 2) then
dd(ii) = 15
else
dd(ii) = 16
end if


; if month has even number of day, midpoint is at 0, if not at 43200
if (mm(ii) .eq. 2 .or. mm(ii) .eq. 4 .or. mm(ii) .eq. 6 .or. mm(ii) .eq. 9 .or. mm(ii) .eq. 11) then
sssss(ii) = 0
else
sssss(ii) = 43200
end if

end do

; get YYYYMMDD
date = yyyy*10000 + mm*100 + dd
date!0 = "time"

; get SSSSS
datesec = sssss
datesec!0 = "time"

print(date+" "+datesec)

;----- write ouput file with correct format

SST_write_file=infile+"_CIMEified.nc"
system("/bin/rm -f -v "+SST_write_file)
out = addfile(SST_write_file,"c")

fAtt = True
fAtt@creation_date = systemfunc ("date")
fileattdef(out, fAtt)
filedimdef(out,"time",-1,True)
filedimdef(out,"time",-1,True)

; copy over some vars. Not sure top 2 are needed.
;out->date = in->date
Expand All @@ -69,7 +78,6 @@ out->time = time_in
out->date = (/date/)
out->datesec = (/datesec/)


; output SST and ice fields
out->SST = var_in
out->ICEFRAC = ice_in
Expand Down

0 comments on commit d3b0228

Please sign in to comment.