#!/bin/csh -f # (4/5/2005) Work for Saravanan # Interpolate the curvilinear grids of POP output onto regular lat/lon grids # for eight variables: # 1. rhopoto - sea water potential density # 2. so - sea water salinity # 3. thetao - sea water potential temperature # 4. tos - sea surface temperature # 5. uo - eastward sea water velocity # 6. vo - northward sea water velocity # 7. wo - upward sea water velocity # 8. zos - sea surface height above geoid # # Received this basic script from Scott Weese on 4 April 2005 # AWM made too many modifications to make note of # NOTES # ----- # 1. This script loads 80 map files comprising 2.3 GB to /ptmp/${USER}/maps. # If any of the map files are scrubbed while the script is executing, it # may fail. (At the current time /ptmp is at 67% capacity, so this seems # unlikely.) # 2. During the course of execution of this script, intermediate files require # ~5 GB of disk space for three years per file in the final output. So a # decade per final output file would require more than 15 GB disk space. # This is in addition to the 2.3 GB needed by the maps noted in (1). # ..Check number of arguments if ($#argv < 3) then echo echo ' Usage: Process_CCSM_OcnM cases start_yr num_yrs [num_yrs_per_outfile]' echo echo ' The default number of years in each output file is 10. The MSS' echo ' output files are in /`upcase ${USER}`/IPCC_AR4/${case}/' echo exit(1) endif # ..Get arguments set cases = $1 set start_yr = $2 set num_yr = $3 if ($#argv == 4) then set num_yr_outf = $4 else set num_yr_outf = 10 endif # ..Compute number of output files @ noutf = ($num_yr - 1) / $num_yr_outf + 1 # ..Get maps (2.3 GB in 80 files) cd /ptmp/${USER} msrcp -n -R mss:/MAI/IPCC_Processing/maps . # ..Loop on cases foreach c ( ${cases} ) set based = ~mai/IPCC_Processing set regrd = ~mai/IPCC_Processing/regridding set ocnd = /ptmp/${USER}/${c}/ocn/mon set msd = /CCSM/csm/${c}/ocn/hist set mso = /`/home/tempest/mai/bin/upcase ${USER}`/IPCC_AR4/${c} if !(-d ${ocnd}) mkdir -p ${ocnd} if !(-d ${ocnd}/IPCC) mkdir -p ${ocnd}/IPCC if !(-d ${ocnd}/maps) mkdir -p ${ocnd}/maps cd ${ocnd} ln -s -f ${based}/do_cmor_create_ccsm . ln -s -f ${based}/CCSM_ocnm_2cf.ncl . ln -s -f ${based}/mss_* . ln -s -f ${based}/Send* . ln -s -f ${based}/set_attributes_ccsm.ncl . ln -s -f ${regrd}/ccsm_ocn_rgd . ln -s -f ${regrd}/levitus_levels.dat . ln -s -f ${regrd}/NML_tgrid_ocn . ln -s -f ${regrd}/NML_ugrid_ocn . ln -s -f ${regrd}/NML_ssh_ocn . cd ${ocnd}/maps ln -s -f /ptmp/${USER}/maps/*.nc . cd ${ocnd}/IPCC ln -s -f ${based}/cf_*var*concat . cd ${ocnd} # ..Loop on output files @ jyr = $start_yr - 1 @ nyrl = $num_yr @ ioutf = 0 while ( $ioutf < $noutf ) @ ioutf++ echo "MSSG output file "$ioutf" "`date` if ($num_yr_outf < $nyrl) then @ nyrtd = $num_yr_outf else @ nyrtd = $nyrl endif # ..Loop on years in this output file @ iyr = 0 while ( $iyr < $nyrtd ) @ iyr++ @ jyr++ switch ($jyr) case ?: set y = 000$jyr breaksw case ??: set y = 00$jyr breaksw case ???: set y = 0$jyr breaksw default: set y = $jyr endsw # ..Loop on months in this year set msf = "${c}.pop.h.${y}-{01,02,03,04,05,06,07,08,09,10,11,12}.nc" echo "MSS read "$y" "`date` ./mss_read "${msd}" "${msf}" echo "MSS done "$y" "`date` foreach i ( ${msf} ) set m = `echo $i | cut -d"-" -f2 | cut -c1-2` rm -f coords_t.nc ; ncks -h -O -v time,time_bound,z_w,z_t $i coords_t.nc ###################### rm -f ssh_nml cat NML_ssh_ocn | sed -e "s/CASE/${c}/g" | \ sed -e "s/YYYY/${y}/g" | \ sed -e "s/MM/${m}/g" > ssh_nml ./ccsm_ocn_rgd < ssh_nml ###################### rm -f tgrid_nml cat NML_tgrid_ocn | sed -e "s/CASE/${c}/g" | \ sed -e "s/YYYY/${y}/g" | \ sed -e "s/MM/${m}/g" > tgrid_nml ./ccsm_ocn_rgd < tgrid_nml ###################### rm -f ugrid_nml cat NML_ugrid_ocn | sed -e "s/CASE/${c}/g" | \ sed -e "s/YYYY/${y}/g" | \ sed -e "s/MM/${m}/g" > ugrid_nml ./ccsm_ocn_rgd < ugrid_nml ###################### echo "FINISHED CCSM OCEAN REGRID" if ($status == 0) then rm -f ${i} echo "DELETED" ${i} foreach j (${c}.pop.h.*.${y}-${m}.nc ) ncks -A coords_t.nc ${j} ./do_cmor_create_ccsm $j if ($status == 0) rm -f ${j} end else echo "REGRID FAILED" exit 1 endif end # loop on months echo "REGRID and NCL done "${y}" "`date` # ..Concatenate 12 months into one year cd ${ocnd}/IPCC ./cf_var_ann_concat cd ${ocnd} touch /ptmp/${USER}/maps/* # keep maps files from being scrubbed end # loop on years # ..Concatenate years into final output file and write to MSS cd ${ocnd}/IPCC ./cf_var_yrs_concat if ($status == 0) then set PCMDI_ext = PDcntrl_1 ### look in set_attributes_ccsm.ncl echo ${y} foreach i (`ls *_*.${PCMDI_ext}.CCSM.ocnm.????-??_cat_????-??.nc`) ../mss_write ${i} ${mso} echo ${i} ${mso} end endif cd ${ocnd} @ nyrl = $nyrl - $nyrtd end # loop on output files end # loop on cases # exit