CloudResolvingClimateModeling / dales

Dutch Atmospheric Large-Eddy Simulation model
GNU General Public License v3.0
1 stars 0 forks source link

netCDFstitching scripts are outdated #5

Closed fjansson closed 6 years ago

fjansson commented 7 years ago

The scripts for merging netCDF result files written by different MPI tasks seem broken. Each task writes a separate file for the data it has, these are supposed to be merged afterwards. There are scripts to do this, in dales/utils/{catfields catxy catyz}, but they expect a different file naming format and seem to merge only in one direction. Presumably they work with an older Dales that only parallellized in slabs.

File name examples

crossxy.0002.x003y002.001.nc
crossxz.x000y000.001.nc
crossyz.x003y003.001.nc
surf_xy.x000y000.001.nc (experimental addition for surface fields - no height level)

File name format:
crossxy.HHHH.xXXXyYYY.EXP.nc
H    - height level
X, Y - coordinates of the task
EXP - experiment number

Probably the same applies for the 3D fields.

We can update the scripts to stitch in 2D, rewrite in Python, or change Dales itself to write a single output file using the parallel netCDF API.

fjansson commented 7 years ago

Here is a hacked catyz. It currently concatenates all crossyz fields it finds. If dales is run with MPI paralellization in the X direction, this results in slices side by side, which is actually useful for quick viewing.

#!/bin/csh -f
# new name: crossyz.x000y000.001.nc
# old name: crossyz.000.???.nc
foreach j (crossyz.x000y000.???.nc)

rm temp*.nc
set exp=$j:r:e   
echo exp $exp

#:r is the root of a file name - removes '.extension' from the end
#:e is extension of a file name - everything after the last '.'

rm crossyz.$exp.nc
foreach i (crossyz.*.$exp.nc)
set idy=$i:r:r:e
ncks -O -v wyz crossyz.$idy.$exp.nc tempw.$idy.nc
ncks -O -v vyz crossyz.$idy.$exp.nc tempv.$idy.nc
ncks -O -v uyz,thlyz,thvyz,qtyz,qlyz,qryz,buoyyz crossyz.$idy.$exp.nc temp.$idy.nc
ncpdq -O -a yt,time,zm tempw.$idy.nc tempw.$idy.nc # Make y record dimension
ncpdq -O -a ym,time,zt tempv.$idy.nc tempv.$idy.nc # Make y record dimension
ncpdq -O -a yt,time,zt temp.$idy.nc temp.$idy.nc # Make y record dimension
end
ncrcat -O tempw.*.nc tempwyz.nc       # Concatenate along y
ncrcat -O tempv.*.nc tempvyz.nc       # Concatenate along y
ncrcat -O temp.*.nc tempyz.nc         # Concatenate along y
ncpdq -O -a time,zm,yt tempwyz.nc tempwyz.nc # Revert to time as record dimension
ncpdq -O -a time,zt,ym tempvyz.nc tempvyz.nc # Revert to time as record dimension
ncpdq -O -a time,zt,yt tempyz.nc crossyz.$exp.nc # Revert to time as record dimension
ncks -A tempwyz.nc crossyz.$exp.nc
ncks -A tempvyz.nc crossyz.$exp.nc
end
rm temp*.nc
goord commented 6 years ago

Fixed in dalesview merge_grids.py