[3545] | 1 | #!/usr/bin/bash |
---|
| 2 | # |
---|
| 3 | # Bash script to post-process files startphy_icosa.nc and start_icosa.nc |
---|
| 4 | # generated by start_archive2icosa and create files |
---|
| 5 | # start.nc and startphy.nc (usable as inputs for icosa_lmdz.exe) |
---|
| 6 | |
---|
| 7 | # load nco module |
---|
| 8 | module purge |
---|
[3567] | 9 | # change to your LMDZ install dir or set "export LMDZ=/path/lmdz" in your .bashrc |
---|
| 10 | LMDZ=${LMDZ:-../../..} |
---|
[3545] | 11 | source $LMDZ/XIOS/arch.env |
---|
| 12 | #module load nco/4.7.9-gcc-4.8.5-hdf5-1.8.18-openmpi-2.0.4 #Example of version of the module needed |
---|
| 13 | module load nco |
---|
| 14 | |
---|
[3567] | 15 | # save start*nc from lmdz grid |
---|
| 16 | mkdir -p lmdz_starts |
---|
| 17 | cp start.nc startfi.nc lmdz_starts |
---|
| 18 | |
---|
[3545] | 19 | #conversion to netcdf 3 in order to rename and add variables, not properly done with netcdf4 files |
---|
| 20 | nccopy -k 'classic' startfi_prefinalize.nc startphy_icosa_nc3.nc |
---|
| 21 | |
---|
| 22 | # rename lat and lon variables as latitude and longitude and put result in |
---|
| 23 | # file startphy.nc |
---|
| 24 | ncrename -v lon,longitude -v lat,latitude -d cell,physical_points\ |
---|
| 25 | startphy_icosa_nc3.nc startphy_nc3.nc |
---|
| 26 | #Temporay soildepth array from Dynamico restartfi |
---|
| 27 | ncks -A -v soildepth restartfi.nc startphy_nc3.nc #You have to adapt to your own path |
---|
| 28 | # ncks -A -v subslope_dist restartfi.nc startphy_nc3.nc |
---|
| 29 | # ncks -A -v def_slope restartfi.nc startphy_nc3.nc |
---|
| 30 | |
---|
| 31 | nccopy -k 4 startphy_nc3.nc startfi.nc |
---|
| 32 | |
---|
| 33 | #Temporary Time variable from start2archive; should be added with xios |
---|
| 34 | ncks -O -x -v time_counter startfi.nc startfi.nc_tmp |
---|
| 35 | ncks -A -v Time start.nc startfi.nc_tmp |
---|
| 36 | # ncks -A -v flux_geo restartfi.nc startfi.nc_tmp |
---|
| 37 | # ncks -A -v wstar restartfi.nc startfi.nc_tmp |
---|
| 38 | # ncks -A -v hmons restartfi.nc startfi.nc_tmp |
---|
| 39 | # ncks -A -v summit restartfi.nc startfi.nc_tmp |
---|
| 40 | # ncks -A -v base restartfi.nc startfi.nc_tmp |
---|
| 41 | cp startfi.nc_tmp startfi.nc |
---|
| 42 | |
---|
| 43 | ./rearrange_startphy.e > rearrange_startphy.out 2>&1 |
---|
| 44 | |
---|
| 45 | # make a proper start.nc file based on start_icosa.nc |
---|
| 46 | cp start_icosa_prefinalize.nc start_icosa.nc |
---|
| 47 | |
---|
| 48 | # add u,u_lat,u_lon,bounds_lat_u and bound_lon_u from start_icosa_ref.nc |
---|
| 49 | ncks -A -v u,lon_u,lat_u,bounds_lon_u,bounds_lat_u \ |
---|
| 50 | start_icosa_ref.nc start_icosa.nc |
---|
| 51 | ncrename -d cell,cell_mesh \ |
---|
| 52 | start_icosa.nc |
---|
| 53 | ncrename -d nvertex,nvertex_mesh \ |
---|
| 54 | start_icosa.nc |
---|
| 55 | ncks -A -v xcell,ycell,zcell \ |
---|
| 56 | start_icosa_ref.nc start_icosa.nc |
---|
| 57 | |
---|
| 58 | ncks -A -v W,geopot,q,nq start_icosa_ref.nc start_icosa.nc |
---|
| 59 | |
---|
| 60 | # In the current version of Dynamico, the variable q for tracer is needed but unused. |
---|
| 61 | # To create this unused variable simply run this short python code |
---|
| 62 | |
---|
| 63 | # cleanup |
---|
| 64 | rm -rf startphy_icosa_nc3.nc startphy_nc3.nc |
---|
[3567] | 65 | |
---|
| 66 | # copy icosa start files in icosa_starts folder |
---|
| 67 | mkdir -p icosa_starts |
---|
| 68 | mv start_icosa.nc icosa_starts/start.nc |
---|
| 69 | mv startfi.nc icosa_starts/startfi.nc |
---|
| 70 | |
---|
| 71 | # get back start files from lmdz grid |
---|
| 72 | cp lmdz_starts/* . |
---|