| 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 |
|---|
| 9 | LMDZ=${LMDZ:-../trunk/} #You have to adapt to your own path, can be in your bashrc |
|---|
| 10 | source $LMDZ/XIOS/arch.env |
|---|
| 11 | #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 |
|---|
| 12 | module load nco |
|---|
| 13 | |
|---|
| 14 | #conversion to netcdf 3 in order to rename and add variables, not properly done with netcdf4 files |
|---|
| 15 | nccopy -k 'classic' startfi_prefinalize.nc startphy_icosa_nc3.nc |
|---|
| 16 | |
|---|
| 17 | # rename lat and lon variables as latitude and longitude and put result in |
|---|
| 18 | # file startphy.nc |
|---|
| 19 | ncrename -v lon,longitude -v lat,latitude -d cell,physical_points\ |
|---|
| 20 | startphy_icosa_nc3.nc startphy_nc3.nc |
|---|
| 21 | #Temporay soildepth array from Dynamico restartfi |
|---|
| 22 | ncks -A -v soildepth restartfi.nc startphy_nc3.nc #You have to adapt to your own path |
|---|
| 23 | # ncks -A -v subslope_dist restartfi.nc startphy_nc3.nc |
|---|
| 24 | # ncks -A -v def_slope restartfi.nc startphy_nc3.nc |
|---|
| 25 | |
|---|
| 26 | nccopy -k 4 startphy_nc3.nc startfi.nc |
|---|
| 27 | |
|---|
| 28 | #Temporary Time variable from start2archive; should be added with xios |
|---|
| 29 | ncks -O -x -v time_counter startfi.nc startfi.nc_tmp |
|---|
| 30 | ncks -A -v Time start.nc startfi.nc_tmp |
|---|
| 31 | # ncks -A -v flux_geo restartfi.nc startfi.nc_tmp |
|---|
| 32 | # ncks -A -v wstar restartfi.nc startfi.nc_tmp |
|---|
| 33 | # ncks -A -v hmons restartfi.nc startfi.nc_tmp |
|---|
| 34 | # ncks -A -v summit restartfi.nc startfi.nc_tmp |
|---|
| 35 | # ncks -A -v base restartfi.nc startfi.nc_tmp |
|---|
| 36 | cp startfi.nc_tmp startfi.nc |
|---|
| 37 | |
|---|
| 38 | ./rearrange_startphy.e > rearrange_startphy.out 2>&1 |
|---|
| 39 | |
|---|
| 40 | # make a proper start.nc file based on start_icosa.nc |
|---|
| 41 | cp start_icosa_prefinalize.nc start_icosa.nc |
|---|
| 42 | |
|---|
| 43 | # add u,u_lat,u_lon,bounds_lat_u and bound_lon_u from start_icosa_ref.nc |
|---|
| 44 | ncks -A -v u,lon_u,lat_u,bounds_lon_u,bounds_lat_u \ |
|---|
| 45 | start_icosa_ref.nc start_icosa.nc |
|---|
| 46 | ncrename -d cell,cell_mesh \ |
|---|
| 47 | start_icosa.nc |
|---|
| 48 | ncrename -d nvertex,nvertex_mesh \ |
|---|
| 49 | start_icosa.nc |
|---|
| 50 | ncks -A -v xcell,ycell,zcell \ |
|---|
| 51 | start_icosa_ref.nc start_icosa.nc |
|---|
| 52 | |
|---|
| 53 | ncks -A -v W,geopot,q,nq start_icosa_ref.nc start_icosa.nc |
|---|
| 54 | |
|---|
| 55 | # In the current version of Dynamico, the variable q for tracer is needed but unused. |
|---|
| 56 | # To create this unused variable simply run this short python code |
|---|
| 57 | |
|---|
| 58 | # cleanup |
|---|
| 59 | rm -rf startphy_icosa_nc3.nc startphy_nc3.nc |
|---|