tpreprocess.sh - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
 (HTM) git clone git://src.adamsgaard.dk/pism
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
       tpreprocess.sh (3693B)
       ---
            1 #!/bin/bash
            2 
            3 # Copyright (C) 2011-2014, 2017, 2019 the PISM authors
            4 
            5 # downloads SeaRISE "1km Greenland data set" NetCDF file,
            6 # adjusts metadata, saves under new name with fields needed
            7 # for pism_regional.py
            8 
            9 # depends on wget and NCO (ncrename, ncap, ncwa, ncks)
           10 
           11 set -e  # exit on error
           12 
           13 # get file; see page http://websrv.cs.umt.edu/isis/index.php/1km_Greenland_data_set
           14 
           15 DATAURL=http://websrv.cs.umt.edu/isis/images/a/ab/
           16 DATANAME=Greenland1km.nc
           17 DATASIZE=80Mb
           18 echo "fetching $DATASIZE master file $DATANAME ... "
           19 wget -nc ${DATAURL}${DATANAME}
           20 
           21 WORKING=gr1km.nc
           22 echo "creating PISM-readable file $WORKING from master ..."
           23 
           24 # copies over preserving history and global attrs; drops climate data:
           25 ncks -O -v x,y,mapping,bheatflx,topg,thk $DATANAME $WORKING
           26 
           27 # remove time dimension
           28 ncwa -O -a t $WORKING $WORKING
           29 
           30 echo "adding lat and lon fields by using nc2cdo.py (which is in pism/util/)"
           31 nc2cdo.py $WORKING
           32 
           33 # create usurf, needed by regional-tools not pism
           34 ncap2 -O -s 'usurf=thk+topg' $WORKING $WORKING
           35 ncap2 -O -s 'where(usurf<0.0) usurf=0.0' $WORKING $WORKING
           36 ncatted -a standard_name,usurf,d,, $WORKING # remove it
           37 ncatted -O -a units,usurf,o,c,"m" $WORKING
           38 ncatted -O -a long_name,usurf,o,c,"ice surface elevation" $WORKING
           39 
           40 echo "copying geometry fields for boundary conditions in no_model area..."
           41 # create fields thkstore and usrfstore so that pism is able to appropriately
           42 # assign Dirichlet b.c. for surface gradient & driving stress
           43 ncap2 -O -s "usurfstore=1.0*usurf" $WORKING $WORKING
           44 ncatted -a standard_name,usurfstore,d,, $WORKING # remove it
           45 ncatted -O -a units,usurfstore,a,c,"m" $WORKING
           46 ncatted -O -a long_name,usurfstore,a,c,"stored ice surface elevation (for regional b.c.)" $WORKING
           47 ncap2 -O -s "thkstore=1.0*thk" $WORKING $WORKING
           48 ncatted -a standard_name,thkstore,d,, $WORKING # remove it
           49 ncatted -O -a units,thkstore,a,c,"m" $WORKING
           50 ncatted -O -a long_name,thkstore,a,c,"stored ice thickness (for regional b.c.)" $WORKING
           51 
           52 echo "... done with cleaning file $WORKING"
           53 echo
           54 
           55 
           56 # get file containing surface mass balance and other data on 5km grid
           57 # see page http://websrv.cs.umt.edu/isis/index.php/Present_Day_Greenland
           58 DATAVERSION=1.1
           59 DATAURL=http://websrv.cs.umt.edu/isis/images/a/a5/
           60 DATANAME=Greenland_5km_v$DATAVERSION.nc
           61 echo "fetching 5km SeaRISE data file which contains surface mass balance ... "
           62 wget -nc ${DATAURL}${DATANAME}
           63 CLIMATEFILE=g5km_climate.nc
           64 echo "creating PISM-readable climate file $CLIMATEFILE from airtemp2m and smb in data file ..."
           65 ncks -O -v mapping,smb,airtemp2m $DATANAME $CLIMATEFILE
           66 ncrename -O -v airtemp2m,ice_surface_temp $CLIMATEFILE
           67 ncatted -O -a units,ice_surface_temp,a,c,"Celsius" $CLIMATEFILE
           68 # convert SMB from liquid water equivalent thickness per year to [kg m-2 year-1];
           69 # assume water density of 1000.0 [kg m-3]
           70 ncap2 -O -s "climatic_mass_balance=1000.0*smb" \
           71       -s 'climatic_mass_balance@standard_name="land_ice_surface_specific_mass_balance_flux"' \
           72       -s 'climatic_mass_balance@units="kg m-2 year-1"' \
           73       $CLIMATEFILE $CLIMATEFILE
           74 ncks -O -x -v smb $CLIMATEFILE $CLIMATEFILE
           75 echo "... done"
           76 echo
           77 
           78 
           79 # get locally-generated or pre-computed PISM result
           80 echo "checking for locally-generated, or fetching, pre-computed PISM whole ice-sheet result on 5km grid"
           81 URL=https://www.pism-docs.org/download
           82 WHOLE=g5km_gridseq.nc
           83 wget -nc ${URL}/$WHOLE
           84 BCFILE=g5km_bc.nc
           85 echo "creating PISM-readable boundary conditions file $BCFILE from whole ice sheet result ..."
           86 ncks -O -v u_ssa,v_ssa,bmelt,tillwat,enthalpy,litho_temp $WHOLE $BCFILE
           87 # rename bmelt and u_ssa and v_ssa so that they are used as b.c.
           88 ncrename -O -v bmelt,basal_melt_rate_grounded -v u_ssa,u_ssa_bc -v v_ssa,v_ssa_bc $BCFILE
           89 echo "... done"
           90 echo