#! /bin/sh -x # # esm-ssp585-ocn-alk_EXP1.plot - generate all standard plots for the different models # # $Id DEFAULT.plot.tmpl 0 2013-09-06 05:46:36Z m221078 $ # # $Id: DEFAULT.config 1 2021-02-03 20:53:47Z m221078 $ # $Id$ # $Id$ # $Id: CDRSYNTRA_OUTPUT.config 9899 2019-07-01 09:57:06Z m221078 $ # $Id: levante.config $ # EXP_ID=esm-ssp585-ocn-alk_EXP1 MODEL_DIR=${MODEL_DIR:-/home/m/m300966/CDRSynTra-mpiesm-1.2.01p7} WORK_DIR=${WORK_DIR:-/scratch/m/m300966/CDRSynTra-mpiesm-1.2.01p7/experiments} DATA_DIR=${DATA_DIR:-/work/bm1241/m300966/CDRSynTra-mpiesm-1.2.01p7/experiments} MODEL_RES=T63GR15 INTERVAL_MONTHS=12 export MODEL_DIR WORK_DIR DATA_DIR MODEL_RES INTERVAL_MONTHS BIN_DIR=${MODEL_DIR}/contrib/plots MON_DIR=${MON_DIR:-/work/bm1241/m300966/CDRSynTra-mpiesm-1.2.01p7/experiments/monitoring} ECHAM_RES=T63 ECHAM_LEVELS=L47 ECHAM=$ECHAM_RES$ECHAM_LEVELS MPIOM_RES=GR15 MPIOM_LEVELS=L40 MPIOM=$MPIOM_RES$MPIOM_LEVELS ALL_PLOTS='monitoring cosmos-asob mpiom/OQs hamocc cvdp' PLOTS=${PLOTS:-$ALL_PLOTS} type grads > /dev/null 2>&1 || { echo 'Sorry: cannot run grads, check environment' >&2; exit 1; } type cdo > /dev/null 2>&1 || { echo 'Sorry: cannot run cdo, check environment' >&2; exit 1; } update_index () ( # Update index files [ "x$1" = x ] && set . cd "$1" $BIN_DIR/mk_index_html ) for EXP_NAME in "${@:-$EXP_ID}" do YEAR_START=${YEAR_START:-2020} YEAR_END=${YEAR_END:-2100} INTERVAL=${INTERVAL:-100} PLOT_DIR=${PLOT_DIR:-$MON_DIR}/$EXP_NAME/plots mkdir -p $PLOT_DIR export EXP_NAME YEAR_START YEAR_END INTERVAL PLOT_DIR case "$PLOTS" in *monitoring*) # Create ECHAM plots YEAR=$YEAR_START while [ $YEAR -le $(( YEAR_END - INTERVAL + 1)) ] do $BIN_DIR/monitoring/run.sh $DATA_DIR $EXP_NAME $ECHAM $MPIOM $YEAR $(( YEAR + INTERVAL - 1 )) '/work/bm1241/m300966/CDRSynTra-mpiesm-1.2.01p7/experiments' '' update_index $PLOT_DIR YEAR=$(( YEAR + INTERVAL )) done ;; esac case "$PLOTS" in *cosmos-asob*) # Create C inventory plots REMOTE_HOST= VISALL_TAG=$EXP_NAME VISALL_CLEAN=yes VISALL_SLF=no VISALL_CMOR=yes VISALL_ECHAM=no REBUILD=no VISALL_ECHAM_SURF=/pool/data/ECHAM6/input/r0008/T63/T63GR15_jan_surf.nc VISALL_JSBACH_INI=/pool/data/JSBACH/input/r0010/T63/jsbach_T63GR15_11tiles_5layers_1850_dynveg.nc export REMOTE_HOST VISALL_TAG VISALL_CLEAN VISALL_SLF VISALL_CMOR \ VISALL_ECHAM REBUILD VISALL_ECHAM_SURF VISALL_JSBACH_INI $BIN_DIR/cosmos-asob/visualize_all.ksh update_index $PLOT_DIR # Create 2d forest-fraction plots YEAR=$YEAR_START while [ $YEAR -le $(( YEAR_END - INTERVAL + 1)) ] do YEAR_LAST=$(( YEAR + INTERVAL - 1 )) YEAR_FILE=$( printf '%04.0f-%04.0f' $YEAR $YEAR_LAST ) cdo timavg -selyear,$YEAR/$YEAR_LAST \ outdata_land/${EXP_NAME}_treeFrac.nc \ treeFrac_${EXP_NAME}_$YEAR_FILE.nc grads -cbp "run $BIN_DIR/cosmos-asob/forest.gs $EXP_NAME $YEAR_FILE" mv treeFrac_${EXP_NAME}_$YEAR_FILE.pdf $PLOT_DIR update_index $PLOT_DIR YEAR=$(( YEAR + INTERVAL )) done ;; esac case "$PLOTS" in *mpiom/OQs*) # Create MPIOM plots YEAR=$YEAR_START while [ $YEAR -le $(( YEAR_END - INTERVAL + 1)) ] do YEAR2=$(( YEAR + INTERVAL - 1 )) Y1=$YEAR Y2=$YEAR2 \ GRID=$MPIOM_RES LEV=$MPIOM_LEVELS \ DATADIR=/work/bm1241/m300966/CDRSynTra-mpiesm-1.2.01p7/experiments/esm-ssp585-ocn-alk_EXP1/outdata/mpiom \ EXPID=$EXP_ID CHUNK=$((INTERVAL_MONTHS / 12)) \ POOL=/pool/data/MPIOM/input/r0010 \ $BIN_DIR/ocean_quickplots/OQs/plot_mpiom.sh mv -v *mpiom*$YEAR*$YEAR2*.pdf $PLOT_DIR update_index $PLOT_DIR YEAR=$(( YEAR + INTERVAL )) done ;; esac case "$PLOTS" in *hamocc*) # Create MPIOM plots exp=$EXP_NAME YEAR_START=$YEAR_START YEAR_END=$YEAR_END $BIN_DIR/hamocc/plot_hamocc.sh update_index $PLOT_DIR ;; esac case "$PLOTS" in *cvdp*) CVDP_PLOT_DIR=${MON_DIR}/${EXP_NAME}/cvdp mkdir -p ${CVDP_PLOT_DIR} mkdir cvdp cd cvdp SURFACE_DIR=../outdata/$EXP_NAME rm -f namelist YEAR=$YEAR_START while [ $YEAR -le $(( YEAR_END - INTERVAL + 1)) ] do YEAR_LAST=$(( YEAR + INTERVAL - 1 )) SURFACE_FILE=$SURFACE_DIR/BOT_${EXP_NAME}_${YEAR}-${YEAR_LAST} [[ -r $SURFACE_FILE ]] || { echo "Sorry: cannot run 'cvdp' plots for ${YEAR}-${YEAR_LAST}" \ "w/o running 'monitoring' before" >&2 continue } cdo -r -t echam6 -f nc2 \ -splitname,swap \ -chname,temp2,tas,precip,pr,tsurf,ts,sn,snd \ -selcode,167,4,151,169,141 $SURFACE_FILE \ _${EXP_NAME}_echam6_BOT_mm_${YEAR}01_${YEAR_LAST}12 cat >> namelist << EOF ${EXP_NAME} | ./ | ${YEAR} | ${YEAR_LAST} EOF # IF Observation data also present , then # a. Update the namelist_obs # b. update the flag in the driver.ncl YEAR=$(( YEAR + INTERVAL )) done # while YEAR cat > driver.ncl << EOF ; ; CVDP driver script. To run the CVDP at the command line type: ncl driver.ncl ; To run the CVDP at the command line, put it in background mode, and write the terminal output ; to a file named file.out, type: ncl driver.ncl >&! file.out & ; ;============================================================================================ outdir = "/work/bm1241/m300966/CDRSynTra-mpiesm-1.2.01p7/experiments/monitoring/esm-ssp585-ocn-alk_EXP1/cvdp/" ; location of output files (must end in a "/") ; It is recommended that a new or empty directory be pointed to here ; as existing files in outdir can get removed. namelists_only = "False" ; Set to True to only create the variable namelists. Useful ; upon running the package for the first time to verify that the correct ; files are being selected by the package. (See files in namelist_byvar/ directory) ; Set to False to run the entire package. obs = "False" ; True = plot OBS (specified in namelist_obs), False = do not scale_timeseries = "True" ; True = scale timeseries so that x-axis length is comparable across timeseries, False = do not output_data = "True" ; True = output selected calculated data to a netCDF file. Make sure .nc files from previous CVDP ; runs are in outdir or they will get added to/modified. compute_modes_mon = "True" ; True = compute DJF, MAM, JJA, SON, Annual and Monthly Atmospheric Modes of Variability ; False = do not compute the Monthly Atmospheric Modes of Variability (saves computation time) ;- - - - - - - - - - - - - - - - - - opt_climo = "Full" ; "Full" = remove climatology based on full record of each simulation, ; "Custom" = use start and end year of climatological period specified by climo_syear and climo_eyear if (opt_climo.eq."Custom") then climo_syear = 700 ; remove the climatology/annual cycle based on these years when opt_climo = "Custom" climo_eyear = 719 ; note: climo_syear and climo_eyear should be within the range of years of all analyzed model runs end if ; and specified observational datasets. ;- - - - - - - - - - - - - - - - - - colormap = 0 ; 0 = default colormaps, 1 = colormaps better for color blindness output_type = "png" ; "ps" or "png". Note that for output_type = "ps", png's are created from the .ps files for web use. png_scale = 1.5 ; Value between .1->5. Any value > 1 (< 1) increases (decreases) png page size. ; When output_type = "png" a value of 1 will result in a png sized 1500 (H) x 1500 (W) before automatic cropping of white space ; When output_type = "ps" a value of 1 will result in a png density setting of 144 before automatic cropping of white space webpage_title = "esm-ssp585-ocn-alk_EXP1" ; Webpage title tar_output = "False" ; tar up all output in outdir and remove individual files? ; Note: ALL files in outdir will be tarred up and then removed fromthe outdir directory. zp = "/home/m/m300966/CDRSynTra-mpiesm-1.2.01p7/contrib/plots/cvdp/ncl_scripts/" ; directory path of CVDP NCL scripts. (must end in a "/") ; Examples: "ncl_scripts/" if all code is local, or on CGD or CISL systems: "~asphilli/CESM-diagnostics/CVDP/ncl_scripts/" ; Regardless of this setting the following files should be in one directory: namelist, driver.ncl, and namelist_obs. ; If pointing to code in ~asphilli make sure the driver script version #s match between the local version of driver.ncl and the ; version # in ~asphilli/CESM-diagnostics/CVDP/driver.ncl ncl_exec = "ncl" ; this can be changed to a different path if a different version of NCL needs to be used, ; such as "/different/path/to/bin/ncl" ;========END USER MODIFICATIONS=========================================================== version = "3.7.0" loadscript(zp+"functions.ncl") variables = (/"ts","trefht","psl","prect","snowdp"/) do gg = 0,dimsizes(variables)-1 if (isfilepresent2("obs_"+variables(gg))) then system("rm obs_"+variables(gg)) end if end do if (isfilepresent2(outdir+"metrics_orig.txt")) then ; remove metrics_orig.txt file if present system("rm "+outdir+"metrics_orig.txt") end if if (isfilepresent2(outdir+"metrics.txt")) then ; remove metrics.txt file if present system("rm "+outdir+"metrics.txt") end if if (.not.isfilepresent2(outdir)) then system("mkdir "+outdir) end if if (opt_climo.ne."Custom") then climo_syear = -999 climo_eyear = -999 end if webpage_title = str_sub_str(webpage_title," ","%") if (namelists_only.eq."True") then system(" export OUTDIR="+outdir+"; export OBS="+obs+"; export SCALE_TIMESERIES="+scale_timeseries+"; "+\ "export OUTPUT_DATA="+output_data+"; export VERSION="+version+"; export PNG_SCALE="+png_scale+"; "+\ "export OPT_CLIMO="+opt_climo+"; export CLIMO_SYEAR="+climo_syear+"; export CLIMO_EYEAR="+climo_eyear+"; "+\ "export COMPUTE_MODES_MON="+compute_modes_mon+"; export CVDP_SCRIPTS="+zp+"; export OUTPUT_TYPE="+output_type+";"+\ " "+ncl_exec+" "+zp+"namelist.ncl") print("Variable namelists have been created. Examine files in namelist_byvar/ directory to verify CVDP file selection.") print("Finished: Climate Variability Diagnostics Package") exit end if ; If one alters the order that scripts are called in the following system calls one will have to modify the metrics.ncl ; script to account for this. (metrics.ncl assumes that the metric rows are created in the same order every time.) ; Adding scripts to the end of this system call is completely fine as that will not alter the order of the ; calculated metrics. ncl_exec = ncl_exec+" -Q" system(" export OUTDIR="+outdir+"; export OBS="+obs+"; export SCALE_TIMESERIES="+scale_timeseries+"; "+\ "export OUTPUT_DATA="+output_data+"; export VERSION="+version+"; export PNG_SCALE="+png_scale+"; "+\ "export OPT_CLIMO="+opt_climo+"; export CLIMO_SYEAR="+climo_syear+"; export CLIMO_EYEAR="+climo_eyear+"; "+\ "export COMPUTE_MODES_MON="+compute_modes_mon+"; export OUTPUT_TYPE="+output_type+"; "+\ "export COLORMAP="+colormap+"; export CVDP_SCRIPTS="+zp+";"+\ " "+str_sub_str(ncl_exec," -Q","")+" "+zp+"namelist.ncl; "+ncl_exec+" "+zp+"sst.indices.ncl; "+ncl_exec+" "+zp+"amo.ncl;"+\ " "+ncl_exec+" "+zp+"pdo.ncl; "+ncl_exec+" "+zp+"psl.modes_indices.ncl; "+ncl_exec+" "+zp+"tas.trends_timeseries.ncl;"+\ " "+ncl_exec+" "+zp+"psl.trends.ncl; "+ncl_exec+" "+zp+"pr.trends_timeseries.ncl; "+ncl_exec+" "+zp+"sst.mean_stddev.ncl;"+\ " "+ncl_exec+" "+zp+"snd.trends.ncl; "+ncl_exec+" "+zp+"psl.mean_stddev.ncl; "+ncl_exec+" "+zp+"tas.mean_stddev.ncl;"+\ " "+ncl_exec+" "+zp+"pr.mean_stddev.ncl; "+ncl_exec+" "+zp+"sst.trends_timeseries.ncl; "+ncl_exec+" "+zp+"amoc.ncl") if (output_type.eq."png") then ofiles = systemfunc("ls "+outdir+"*.png") do gg = 0,dimsizes(ofiles)-1 system("convert -trim +repage -border 8 -bordercolor white "+ofiles(gg)+" "+ofiles(gg)) end do else ofilesS = systemfunc("ls "+outdir+"*."+output_type) ofilesT = systemfunc("ls -l "+outdir+"*."+output_type) do gg = 0,dimsizes(ofilesT)-1 ; check for empty .ps files, remove filesize = tofloat(str_get_field(ofilesT(gg),5," ")) if (filesize.lt.10000) then print("Removing: "+ofilesT(gg)) system("rm "+ofilesS(gg)) end if end do delete([/filesize,ofilesS,ofilesT/]) ofiles = systemfunc("ls "+outdir+"*."+output_type) ofiles_png = str_sub_str(ofiles,"."+output_type,".png") d_opt = 144*png_scale print("Converting "+output_type+" files to .png") do gg = 0,dimsizes(ofiles)-1 system("convert -density "+d_opt+" -trim +repage -border 8 -bordercolor white -background white -flatten "+ofiles(gg)+" "+ofiles_png(gg)) end do print("Done with "+output_type+"->png conversion") end if system("cp "+zp+"cas-cvdp.png "+outdir) system("cp namelist_byvar/* "+outdir) system("cp namelist "+outdir) if (obs.eq."True") then system("cp namelist_obs "+outdir) end if if (isfilepresent2(outdir+"metrics_orig.txt")) then system(" export OUTDIR="+outdir+"; "+ncl_exec+" "+zp+"metrics.ncl") end if system(" export OUTDIR="+outdir+"; export VERSION="+version+"; export OUTPUT_DATA="+output_data+"; "+\ "export OPT_CLIMO="+opt_climo+"; export CLIMO_SYEAR="+climo_syear+"; export CLIMO_EYEAR="+climo_eyear+"; "+\ "export WEBTITLE="+webpage_title+"; export OBS="+obs+"; export CVDP_SCRIPTS="+zp+"; "+ncl_exec+" "+zp+"webpage.ncl") ;------------------------------- if (tar_output.eq."True") then if (isfilepresent2(outdir+"cvdp.tar")) then system("rm "+outdir+"cvdp.tar") end if ; print("cd "+outdir+"; tar -cf cvdp.tar *") system("cd "+outdir+"; tar -cf cvdp.tar *") system("cd "+outdir+"; rm *.png *.ps *.txt *.html *.nc namelist*") end if ;------------------------------- ; Cleanup do gg = 0,dimsizes(variables)-1 if (isfilepresent2("obs_"+variables(gg))) then system("rm obs_"+variables(gg)) end if end do delete([/ofiles,variables,outdir,obs,scale_timeseries,output_data,opt_climo,climo_syear,climo_eyear,png_scale,webpage_title,compute_modes_mon/]) print("Finished: Climate Variability Diagnostics Package") EOF #Execute the ncl script ncl driver.ncl #Update the HTML with the CVDP_PLOT_DIR cd .. ;; esac # case *cvdp* done # for EXP_NAME