diff --git a/sewx_ne60/dates.txt b/forecast_clones/sewx_ne60/dates.txt similarity index 100% rename from sewx_ne60/dates.txt rename to forecast_clones/sewx_ne60/dates.txt diff --git a/sewx_ne60/notliveshell.csh b/forecast_clones/sewx_ne60/notliveshell.csh similarity index 100% rename from sewx_ne60/notliveshell.csh rename to forecast_clones/sewx_ne60/notliveshell.csh diff --git a/forecast_clones/dates3.txt b/forecast_clones/tcforecast_60_x4/dates3.txt similarity index 100% rename from forecast_clones/dates3.txt rename to forecast_clones/tcforecast_60_x4/dates3.txt diff --git a/forecast_clones/dates5.txt b/forecast_clones/tcforecast_60_x4/dates5.txt similarity index 100% rename from forecast_clones/dates5.txt rename to forecast_clones/tcforecast_60_x4/dates5.txt diff --git a/forecast_clones/newtcforecast2.csh b/forecast_clones/tcforecast_60_x4/newtcforecast2.csh similarity index 100% rename from forecast_clones/newtcforecast2.csh rename to forecast_clones/tcforecast_60_x4/newtcforecast2.csh diff --git a/forecast_clones/newtcforecast3.csh b/forecast_clones/tcforecast_60_x4/newtcforecast3.csh similarity index 100% rename from forecast_clones/newtcforecast3.csh rename to forecast_clones/tcforecast_60_x4/newtcforecast3.csh diff --git a/notliveshell.csh b/notliveshell.csh index 2dd2c9c..c8d1ae0 100755 --- a/notliveshell.csh +++ b/notliveshell.csh @@ -240,30 +240,6 @@ echo "We are using $yearstr $monthstr $daystr $cyclestr Z ($cyclestrsec seconds) echo "We are using $sstyearstr $sstmonthstr $sstdaystr $sstcyclestr Z for SST data" echo "SE initialization will occur at $se_yearstr $se_monthstr $se_daystr $se_cyclestr Z ($se_cyclestrsec seconds)" -if [ $machineid -eq 1 ] -then - echo "Using Yellowstone" -elif [ $machineid -eq 2 ] -then - echo "Using UMich Flux" - exit 1 -elif [ $machineid -eq 3 ] -then - echo "Using UCDavis Agri" - sewxscriptsdir=/home/$LOGNAME/sewx/ - gfs_files_path=/home/$LOGNAME/sewx/GFS - era_files_path=/home/$LOGNAME/getECMWFdata - gfs_to_cam_path=/home/$LOGNAME/sewx/gfs_to_cam - era_to_cam_path=/home/$LOGNAME/sewx/interim_to_cam - filter_path=/home/$LOGNAME/sewx/filter - path_to_case=/home/$LOGNAME - path_to_nc_files=$path_to_case/$gridname/run - outputdir=/home/$LOGNAME/${gridname}/run -else - echo "Machine not supported" - exit 1 -fi - if [ $debug -ne 1 ] then diff --git a/sample_user_nl/user_nl_cam_filter b/sample_user_nl/user_nl_cam_filter new file mode 100644 index 0000000..2fc1718 --- /dev/null +++ b/sample_user_nl/user_nl_cam_filter @@ -0,0 +1,37 @@ +! Users should add all user specific namelist changes below in the form of +! namelist_var = new_namelist_value +&cam_inparm + bnd_topo='/glade/scratch/zarzycki/unigridFiles/ecsnow_30_x4/topo/topo_ecsnow_30_x4_smooth.nc' + ncdata='/glade/p/work/zarzycki/sewx/INIC/ecsnow_30_x4_INIC.nc' + nhtfrq=1 + mfilt=200 + interpolate_analysis=.false. + fincl1='U:I','V:I','T:I','PS:I','Q:I','CLDICE:I','CLDLIQ:I','NUMICE:I','NUMLIQ:I','ICEFRAC:I' + empty_htapes=.TRUE. + inithist='ENDOFRUN' +/ +&ctl_nl + dtime=450 + se_nsplit=2 + rsplit=3 + hypervis_subcycle=4 + se_ne=0 + se_ftype=0 + nu=8e-8 + nu_div=20e-8 + nu_p =8e-8 + hypervis_scaling=3.2 + nu_q=8e-8 + nu_top=2.0e5 + tstep_type=5 + hypervis_power=0 +! nu=1.0000e13 +! nu_div=2.5000e13 +! nu_p = 1.00e13 +! nu_q = 1.00e13 +! nu_top = 2.0e5 +! fine_ne=120 +! hypervis_power=3.322 +! max_hypervis_courant=1.9 + mesh_file = "/glade/p/work/zarzycki/grids/exodus/ecsnow_30_x4.g" +/ diff --git a/sample_user_nl/user_nl_cam_run b/sample_user_nl/user_nl_cam_run new file mode 100644 index 0000000..768919d --- /dev/null +++ b/sample_user_nl/user_nl_cam_run @@ -0,0 +1,39 @@ +! Users should add all user specific namelist changes below in the form of +! namelist_var = new_namelist_value +&cam_inparm + bnd_topo='/glade/scratch/zarzycki/unigridFiles/ecsnow_30_x4/topo/topo_ecsnow_30_x4_smooth.nc' + ncdata='/glade/p/work/zarzycki/sewx/INIC/ecsnow_30_x4_INIC_filter.nc' + nhtfrq=0,-6 + mfilt=1,1 + interpolate_analysis=.false.,.true. + interp_nlat=361 + interp_nlon=720 + fincl2='PRECT:I','PRECSL:I','PRECSC:I','SST:I','U850:I','V850:I','PSL:I','ZBOT:I','UBOT:I','VBOT:I','T300:I','T200:I','FLUT:I','SST:I','U200:I','V200:I','OMEGA500:I','TMQ:I','Z500:I','PRECCav','PRECLav','SHFLX:I','LHFLX:I' +! empty_htapes=.TRUE. + inithist='ENDOFRUN' +/ +&ctl_nl + dtime=1800 + se_nsplit=8 + rsplit=3 + hypervis_subcycle=4 + se_ne=0 + se_ftype=0 + nu=8e-8 + nu_div=20e-8 + nu_p =8e-8 + hypervis_scaling=3.2 + nu_q=8e-8 + nu_top=2.0e5 + tstep_type=5 + hypervis_power=0 +! nu=1.0000e13 +! nu_div=2.5000e13 +! nu_p = 1.00e13 +! nu_q = 1.00e13 +! nu_top = 2.0e5 +! fine_ne=120 +! hypervis_power=3.322 +! max_hypervis_courant=1.9 + mesh_file = "/glade/p/work/zarzycki/grids/exodus/ecsnow_30_x4.g" +/ diff --git a/sample_user_nl/user_nl_clm b/sample_user_nl/user_nl_clm new file mode 100644 index 0000000..60e83f5 --- /dev/null +++ b/sample_user_nl/user_nl_clm @@ -0,0 +1,22 @@ +!---------------------------------------------------------------------------------- +! Users should add all user specific namelist changes below in the form of +! namelist_var = new_namelist_value +! +! Include namelist variables for drv_flds_in ONLY if -megan and/or -drydep options +! are set in the CLM_NAMELIST_OPTS env variable. +! +! EXCEPTIONS: +! Set co2_ppmv with CCSM_CO2_PPMV option +! Set co2_type with CLM_CO2_TYPE option +! Set dtime with L_NCPL option +! Set fatmlndfrc with LND_DOMAIN_PATH/LND_DOMAIN_FILE options +!finidat='' +! (includes $inst_string for multi-ensemble cases) +! Also use CLM_FORCE_COLDSTART='on' to startup +!finidat='' +! Set glc_grid with CISM_GRID option +! Set glc_smb with GLC_SMB option +! Set maxpatch_glcmec with GLC_NEC option +!---------------------------------------------------------------------------------- + flanduse_timeseries='' +!finidat='' diff --git a/scriptbackups/se_interp.BAK.20140807.1132 b/scriptbackups/se_interp.BAK.20140807.1132 deleted file mode 100644 index c6dd3fe..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1132 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2012" -monthstr="10" -daystr="01" -cyclestr="00" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/scratch/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/scratch/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1138 b/scriptbackups/se_interp.BAK.20140807.1138 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1138 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1142 b/scriptbackups/se_interp.BAK.20140807.1142 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1142 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1146 b/scriptbackups/se_interp.BAK.20140807.1146 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1146 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1147 b/scriptbackups/se_interp.BAK.20140807.1147 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1147 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1151 b/scriptbackups/se_interp.BAK.20140807.1151 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1151 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1153 b/scriptbackups/se_interp.BAK.20140807.1153 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1153 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1154 b/scriptbackups/se_interp.BAK.20140807.1154 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1154 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1155 b/scriptbackups/se_interp.BAK.20140807.1155 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1155 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1156 b/scriptbackups/se_interp.BAK.20140807.1156 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1156 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1158 b/scriptbackups/se_interp.BAK.20140807.1158 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1158 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1159 b/scriptbackups/se_interp.BAK.20140807.1159 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1159 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1200 b/scriptbackups/se_interp.BAK.20140807.1200 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1200 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1201 b/scriptbackups/se_interp.BAK.20140807.1201 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1201 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1204 b/scriptbackups/se_interp.BAK.20140807.1204 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1204 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1246 b/scriptbackups/se_interp.BAK.20140807.1246 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1246 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1248 b/scriptbackups/se_interp.BAK.20140807.1248 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1248 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1325 b/scriptbackups/se_interp.BAK.20140807.1325 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1325 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end - diff --git a/scriptbackups/se_interp.BAK.20140807.1543 b/scriptbackups/se_interp.BAK.20140807.1543 deleted file mode 100644 index 53f1714..0000000 --- a/scriptbackups/se_interp.BAK.20140807.1543 +++ /dev/null @@ -1,378 +0,0 @@ -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" -load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl" - -begin - -numlevels=30 -yearstr="2014" -monthstr="08" -daystr="07" -cyclestr="12" - -if (machineid .eq. 1) then - gfs_data_dir = "/glade/p/work/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" - wgt_file_dir = "/glade/p/work/zarzycki/maps/gfsmaps/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/glade/p/work/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else if (machineid .eq. 2) then - print("Flux not configured yet") - exit -else if (machineid .eq. 3) then - gfs_data_dir = "/home/zarzycki/sewx/GFS/" -; sst_filename = "gdas1.t00z.sstgrb.grib2" -; gfs_filename = "gfsanl_4_"+yearstr+monthstr+daystr+"_"+cyclestr+"00_000.grb2" -; gfs_filename = "gfs.t"+cyclestr+"z.pgrb2bf00.grb2" -; gfs_filename = "gfs.t12z.pgrb2f00.grb2" -wgt_file_dir = "/home/zarzycki/maps/wx_to_cam/" - wgt_filename = "map_gfs0.50_TO_"+gridname+"_patc.nc" - se_inic_dir = "/home/zarzycki/sewx/INIC/" - se_inic_filename = gridname+"_INIC.nc" -else - print("Invalid Machine ID specified") - exit -end if -end if -end if - -wgt_file = wgt_file_dir+wgt_filename -se_inic = se_inic_dir+se_inic_filename - -print("Using this file: "+gfs_filename) -print("Using this remap: "+wgt_filename) - -; Get strings -datestr = systemfunc("date +'%Y%m%d'") ; Get date string for parsing -rawhour = systemfunc("date -u +'%H'") - -in = addfile(se_inic,"w") - -; GFS ARCHIVE analysis files are -- http://nomads.ncdc.noaa.gov/data/gfsanl/ -;sst_file = addfile(gfs_data_dir+sst_filename,"r") -;grb_file = addfile(gfs_data_dir+gfs_filename,"r") -grb_file = addfile(gfs_filename,"r") - -;sstlat = sst_file->lat_0 -;sstlon = sst_file->lon_0 -;sst_gfs = sst_file->TMP_P0_L1_GLL0(:,:) - -grblat = grb_file->lat_0 -grblon = grb_file->lon_0 -grblev = grb_file->lv_ISBL0 -rhlev = grb_file->lv_ISBL6 -;rhlev = grb_file->lv_ISBL4 -cldlev = grb_file->lv_ISBL8 -;cldlev = grb_file->lv_ISBL4 - -ps = grb_file->PRES_P0_L1_GLL0(:,:) -p0 = 100000. - -pblh = grb_file->HPBL_P0_L1_GLL0(:,:) - -t_gfs = grb_file->TMP_P0_L100_GLL0(:,:,:) -u_gfs = grb_file->UGRD_P0_L100_GLL0(:,:,:) -v_gfs = grb_file->VGRD_P0_L100_GLL0(:,:,:) -rh_gfs = grb_file->RH_P0_L100_GLL0(:,:,:) -cldmix_gfs = grb_file->CLWMR_P0_L100_GLL0(:,:,:) - -print("Interpolating GRIB to uniform vertical levels") -rh_gfs_interp = int2p_n(rhlev,rh_gfs,grblev,2,0) -cld_gfs_interp = int2p_n(cldlev,cldmix_gfs,grblev,2,0) - -print("Calculating q from RH") -q_gfs = mixhum_ptrh(conform(t_gfs,grblev,0)*0.01, t_gfs , rh_gfs_interp, 2 ) ; specific humidity (g/kg) - -if (numlevels .eq. 30) -print("Loading 30 level data") -fC = addfile ("./L30template.nc", "r") -else -print("Loading 26 level data") -fC = addfile ("./L26template.nc", "r") -end if - -hya = fC->hyam ; levels to which the variable -hyb = fC->hybm ; will be interpolated - -print("Interpolating to CAM hybrid coordinates") -t_cam = pres2hybrid_Wrap(grblev,ps,p0,t_gfs,hya,hyb,4) -u_cam = pres2hybrid_Wrap(grblev,ps,p0,u_gfs,hya,hyb,4) -v_cam = pres2hybrid_Wrap(grblev,ps,p0,v_gfs,hya,hyb,4) -q_cam = pres2hybrid_Wrap(grblev,ps,p0,q_gfs,hya,hyb,4) -cldmix_cam = pres2hybrid_Wrap(grblev,ps,p0,cld_gfs_interp,hya,hyb,4) - -print("Sorting bad values") - do i = 0,dimsizes(grblat)-1 - do j = 0,dimsizes(grblon)-1 - do k = 0,25 - if (ismissing(cldmix_cam(k,i,j))) then - cldmix_cam(k,i,j) = 0 - else if (cldmix_cam(k,i,j) .gt. 0.01) then - cldmix_cam(k,i,j) = 0 - end if - end if - end do - end do - end do - -q_cam!0 = "lev" ; assign named dimensions -q_cam!1 = "lat" -q_cam!2 = "lon" - -q_cam&lev = t_cam&lv_ISBL0 -q_cam&lat = t_cam&lat_0 -q_cam&lon = t_cam&lon_0 - -cldmix_cam!0 = "lev" ; assign named dimensions -cldmix_cam!1 = "lat" -cldmix_cam!2 = "lon" - -cldmix_cam&lev = t_cam&lv_ISBL0 -cldmix_cam&lat = t_cam&lat_0 -cldmix_cam&lon = t_cam&lon_0 - -t_cam!0 = "lev" ; assign named dimensions -t_cam!1 = "lat" -t_cam!2 = "lon" -u_cam!0 = "lev" ; assign named dimensions -u_cam!1 = "lat" -u_cam!2 = "lon" -v_cam!0 = "lev" ; assign named dimensions -v_cam!1 = "lat" -v_cam!2 = "lon" -ps!0 = "lat" -ps!1 = "lon" -pblh!0 = "lat" -pblh!1 = "lon" - -; Create sst array for CAM -;sst_cam = sst_gfs -;sst_cam!0 = "lat" -;sst_cam!1 = "lon" - -fV = addfile ("./L26template.nc", "r") -fvlat = fV->lat -fvlon = fV->lon -fvslat = fV->slat -fvslon = fV->slon - -print("Interpolating horizontal to CAM") - - - -dstFileName = se_inic ; Destination grid -dfile = addfile(dstFileName,"r") -lonCell = dfile->lon -latCell = dfile->lat - -Opt = True -Opt@CopyVarCoords = False -ps_fv = ESMF_regrid_with_weights(ps,wgt_file,Opt) -pblh_fv = ESMF_regrid_with_weights(pblh,wgt_file,Opt) -t_fv = ESMF_regrid_with_weights(t_cam,wgt_file,Opt) -u_fv = ESMF_regrid_with_weights(u_cam,wgt_file,Opt) -v_fv = ESMF_regrid_with_weights(v_cam,wgt_file,Opt) -q_fv = ESMF_regrid_with_weights(q_cam,wgt_file,Opt) -cldmix_fv = ESMF_regrid_with_weights(cldmix_cam,wgt_file,Opt) - -;ncol = 333074 -sePS = in->PS -dim_sePS=dimsizes(sePS) -ncol=dim_sePS(1) - -printVarSummary(ps_fv) - - -; Interpolate from GFS grid to CAM FV grid -;ps_fv = linint2_Wrap (grblon,grblat(::-1),ps(::-1,:),True,fvlon,fvlat,0) -;pblh_fv = linint2_Wrap (grblon,grblat(::-1),pblh(::-1,:),True,fvlon,fvlat,0) -;t_fv = linint2_Wrap (grblon,grblat(::-1),t_cam(:,::-1,:),True,fvlon,fvlat,0) -;u_fv = linint2_Wrap (grblon,grblat(::-1),u_cam(:,::-1,:),True,fvlon,fvslat,0) -;v_fv = linint2_Wrap (grblon,grblat(::-1),v_cam(:,::-1,:),True,fvslon,fvlat,0) -;q_fv = linint2_Wrap (grblon,grblat(::-1),q_cam(:,::-1,:),True,fvlon,fvlat,0) -;cldmix_fv = linint2_Wrap (grblon,grblat(::-1),cldmix_cam(:,::-1,:),True,fvlon,fvlat,0) - -; sst_fv = linint2_Wrap (sstlon,sstlat(::-1),sst_cam(::-1,:),True,fvlon,fvlat,0) -; -; -; u_fv!0 = "lev" ; assign named dimensions -; u_fv!1 = "slat" -; u_fv!2 = "lon" -; v_fv!0 = "lev" ; assign named dimensions -; v_fv!1 = "lat" -; v_fv!2 = "slon" -; - print("Converting floats to doubles") - ; Convert floats to doubles - ps_fv_dbl = todouble(ps_fv) - pblh_fv_dbl = todouble(pblh_fv) - t_fv_dbl = todouble(t_fv) - u_fv_dbl = todouble(u_fv) - v_fv_dbl = todouble(v_fv) - q_fv_dbl = todouble(q_fv) - cldmix_fv_dbl = todouble(cldmix_fv) -; sst_fv_dbl = todouble(sst_fv) -; -; print("Copying metadata") -; ; Copy meta-deta over to newly created doubles - copy_VarMeta(ps_fv,ps_fv_dbl) - copy_VarMeta(pblh_fv,pblh_fv_dbl) - copy_VarMeta(t_fv,t_fv_dbl) - copy_VarMeta(u_fv,u_fv_dbl) - copy_VarMeta(v_fv,v_fv_dbl) - copy_VarMeta(q_fv,q_fv_dbl) - copy_VarMeta(cldmix_fv,cldmix_fv_dbl) -; copy_VarMeta(sst_fv,sst_fv_dbl) -; -; ; clean up some stuff - delete(ps_fv) - delete(pblh_fv) - delete(t_fv) - delete(u_fv) - delete(v_fv) - delete(q_fv) - delete(cldmix_fv) -; delete(sst_fv) -; -; numfvlat = dimsizes(fvlat) -; numfvlon = dimsizes(fvlon) -; numfvslat = dimsizes(fvslat) -; numfvslon = dimsizes(fvslon) -; - print("Correcting time records") -; ; Add time record - ps_fv_dbl_time = new((/1,ncol/),double) - ps_fv_dbl_time(0,:) = ps_fv_dbl -; - pblh_fv_dbl_time = new((/1,ncol/),double) - pblh_fv_dbl_time(0,:) = pblh_fv_dbl - -print("here1") -; -; u_fv_dbl_reord = u_fv_dbl(lev|:,slat|:,lon|:) - u_fv_dbl_time = new((/1,numlevels,ncol/),double) - u_fv_dbl_time(0,:,:) = u_fv_dbl - - print("here1") - -; v_fv_dbl_reord = v_fv_dbl(lev|:,lat|:,slon|:) - v_fv_dbl_time = new((/1,numlevels,ncol/),double) - v_fv_dbl_time(0,:,:) = v_fv_dbl - -print("here1") - -;t_fv_dbl_reord = t_fv_dbl(lev|:,lat|:,lon|:) -t_fv_dbl_time = new((/1,numlevels,ncol/),double) -t_fv_dbl_time(0,:,:) = t_fv_dbl - -print("here1") - -;q_fv_dbl_reord = q_fv_dbl(lev|:,lat|:,lon|:) -q_fv_dbl_time = new((/1,numlevels,ncol/),double) -q_fv_dbl_time(0,:,:) = q_fv_dbl - -print("here1") -;cldmix_fv_dbl_reord = cldmix_fv_dbl(lev|:,lat|:,lon|:) -cldmix_fv_dbl_time = new((/1,numlevels,ncol/),double) -cldmix_fv_dbl_time(0,:,:) = cldmix_fv_dbl - - - -; sst_fv_dbl_time = new((/1,numfvlat,numfvlon/),double) -; sst_fv_dbl_time(0,:,:) = sst_fv_dbl -; -; ; Create clone ice array - -print("here2") - cldice_fv_dbl_time = cldmix_fv_dbl_time -; -; -; - print("Seperate cloud ice and water") - ; If T > 0 C, water, if less than < 0, ice - do i = 0,ncol-1 - ;do j = 0,numfvlon-1 - do k = 0,numlevels-1 - if (t_fv_dbl_time(0,k,i) .gt. 273.15 ) then - cldice_fv_dbl_time(0,k,i) = 0 - else - cldmix_fv_dbl_time(0,k,i) = 0 - end if - end do - ;end do - end do -; -;delete(u_fv_dbl) -;delete(t_fv_dbl) -;delete(v_fv_dbl) -;delete(q_fv_dbl) -;delete(cldmix_fv_dbl) -; -; ; Write to NetCDF -; -; ; system("/bin/rm -f simple.nc") ; remove any pre-existing file -; ; sst_file = addfile("sst.nc" ,"c") ; open output netCDF file -; -; ; make time and UNLIMITED dimension ; recommended for most applications -; ; filedimdef(sst_file,"time",-1,True) -; -; ; sst_file->SST=(/sst_fv_dbl_time/) -; -; print("Writing file...") -; -; if (numlevels .eq. 30) - -; else -; in = addfile("/glade/scratch/zarzycki/gfs_to_cam/L26_clean.nc","w") -; end if -; - -;U_se = in->U - - -ps_fv_dbl_time!0 = "time" -ps_fv_dbl_time!1 = "ncol" -u_fv_dbl_time!0 = "time" -u_fv_dbl_time!1 = "lev" -u_fv_dbl_time!2 = "ncol" -v_fv_dbl_time!0 = "time" -v_fv_dbl_time!1 = "lev" -v_fv_dbl_time!2 = "ncol" -t_fv_dbl_time!0 = "time" -t_fv_dbl_time!1 = "lev" -t_fv_dbl_time!2 = "ncol" -q_fv_dbl_time!0 = "time" -q_fv_dbl_time!1 = "lev" -q_fv_dbl_time!2 = "ncol" -cldmix_fv_dbl_time!0 = "time" -cldmix_fv_dbl_time!1 = "lev" -cldmix_fv_dbl_time!2 = "ncol" -cldice_fv_dbl_time!0 = "time" -cldice_fv_dbl_time!1 = "lev" -cldice_fv_dbl_time!2 = "ncol" - -printVarSummary(ps_fv_dbl_time) - - in->PS=(ps_fv_dbl_time) - in->U=(u_fv_dbl_time) - in->V=(v_fv_dbl_time) - in->T=(t_fv_dbl_time) - in->Q=(q_fv_dbl_time) - in->CLDLIQ=(cldmix_fv_dbl_time) - in->CLDICE=(cldice_fv_dbl_time) -; ; in->PBLH=(/pblh_fv_dbl_time/) -; -; -; if (numlevels .eq. 30) -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; else -; ; system("ncks -O -x -v CLOUD,ICEFRAC,LCWAT,QCWAT,QPERT,TBOT,TCWAT,TPERT,TSICERAD,TSOCN fv.0.23x0.31_L26_input.nc fv.0.23x0.31_L26_input_clean.nc") -; end if - - print("done") - -end -