From d3b022867c8405c7188c978bc5213b08c90cd012 Mon Sep 17 00:00:00 2001 From: zarzycki Date: Mon, 6 Mar 2023 11:35:23 -0500 Subject: [PATCH] add some comments to docn gen code from ALCC runs --- slab-ocn/external-to-docn.ncl | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/slab-ocn/external-to-docn.ncl b/slab-ocn/external-to-docn.ncl index 7fa32e4..320a1cb 100644 --- a/slab-ocn/external-to-docn.ncl +++ b/slab-ocn/external-to-docn.ncl @@ -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") @@ -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) @@ -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 @@ -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