Skip to content

Commit

Permalink
Nov 2019 (#10)
Browse files Browse the repository at this point in the history
* First update for November 2019 training course

* Update links and re-do adding a new task to a suite section

* Further updates

* Update fcm tutorial to add an new module file. #4

* Fix typos and update cf-python exercises for python3

* Update cfa section

* Remove reference to cfdump
  • Loading branch information
RosalynHatcher authored Dec 3, 2019
1 parent 69ee20f commit 9a817e3
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 78 deletions.
Binary file modified practicals.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions practicals/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

# General information about the project.
project = u'NCAS Unified Model Introduction'
copyright = u'2017, NCAS-CMS'
copyright = u'2017-2019, NCAS-CMS'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -61,7 +61,7 @@

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
today = '03 April 2019'
today = '06 November 2019'
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'

Expand Down
14 changes: 8 additions & 6 deletions practicals/source/fcm-tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,20 @@ Now make some code changes! Use the following scenario to take you through the b

**Adding a new file**

* Still in the ``src/control/top_level`` directory, add a new file with a subroutine in, called ``um_shell_sub.F90``. (An example file is available on PUMA: ``~um/um-training/um_shell_sub.F90``. The routine ``umPrint`` should be used for writing out messages rather than standard FORTRAN ``WRITE`` statements.)
* Still in the ``src/control/top_level`` directory, add a new FORTRAN module file (``um_shell_mod.F90``) containing a subroutine called ``um_shell_sub()``. (An example file is available on PUMA: ``~um/um-training/um_shell_mod.F90``. The routine ``umPrint`` should be used for writing out messages rather than standard FORTRAN ``WRITE`` statements.)
* Run **fcm add** on the command line, to let the repository know you're adding a new file at the next commit. Make sure you are still in ``src/control/top_level`` and then type: ::

fcm add um_shell_sub.F90
fcm add um_shell_mod.F90

at the command prompt.

* Amend ``um_shell.F90`` to call this new subroutine: ::
* Modify ``um_shell.F90`` to use this new module. You'll see lots of ``USE`` statements near the top of the file. Add the following to use our new one. ::

CALL um_shell_sub()
USE um_shell_mod

* Then add a line to call the ``um_shell_sub`` subroutine (suggest around line 375): ::

* Ensure you put a comment line **! DEPENDS ON: um_shell_sub** above the CALL statement to ensure the dependency on your new file is registered.
CALL um_shell_sub()

**Deleting a file**

Expand Down Expand Up @@ -351,7 +353,7 @@ Version Control of Suites

Just like the model code, your UM suites are also under version control in a subversion repository, usually *roses-u* which is on the MOSRS. Once you have a working copy of your suite under ``~/roses`` you can use FCM commands in the same way as for your source code branches; i.e. commit changes, diff changes, etc.

* Look in the roses-u repository via MOSRS Trac (https://code.metoffice.gov.uk/trac/roses-u) and find the suite you created in the previous section. (Hint: Go to *"Browse Source"* then drill down to find you suite. e.g. u-ag263 would be under a/g/2/6/3). When was the suite last modified?
* Look in the roses-u repository via MOSRS Trac (https://code.metoffice.gov.uk/trac/roses-u) and find the suite you created in the previous section. (Hint: Go to *"Browse Source"* then drill down to find your suite. e.g. u-ag263 would be under a/g/2/6/3). When was the suite last modified?

* Go to your suite working directory and type **fcm status** to see the changes you have made since you copied the suite.

Expand Down
2 changes: 1 addition & 1 deletion practicals/source/further-exercises-2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Navigate to *um -> namelist -> Model Input and Output -> NetCDF Output Options*

Expand the *NetCDF Output Streams* section. A single stream - **nc0** - already exists; select it to display its content. As a useful comaprison, expand the *Model Output Streams* section and with the middle mouse button select **pp0**. Observe that the only significant differences between **pp0** and **nc0** are the values of ``file_id`` and ``filename_base``. Data compression options for **nc0** are revealed if ``l_compress`` is set to true. NetCDF deflation is a computationally expensive process best handled asynchronously to computation and as yet not fully implemented through the UM IO Server scheme (but under active development.) For many low- to medium-resolution models and, depending precisely on output profiles, high-resolution models also, use of UM-NetCDF without IO servers still provides significant benefits over fields-file output since using it avoids the need for subsequent file format conversion.

Right-click on **nc0** and select *Clone this section*. Edit the settings of the newly cloned section to make the new stream similar to **pp1**. It is sensible to change the name of the new stream from "1" to something more meaningful, nc1 for example (right click on "1", select *Rename a section*, and change ...nc(1) to ...nc (nc1)).
Right-click on **nc0** and select *Clone this section*. Edit the settings of the newly cloned section appropriately to make the new stream similar to **pp1** (ie. edit ``filename_base`` and all the reinitialisation variables). It is sensible to change the name of the new stream from "1" to something more meaningful, nc1 for example (right click on "1", select *Rename a section*, and change ...nc(1) to ...nc (nc1)).

**iii. Direct output to the nc streams**

Expand Down
6 changes: 3 additions & 3 deletions practicals/source/getting-setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Unfortunately we can no longer pre-install MobaXterm for you due to licencing re
* | From Chrome, go to page: https://mobaxterm.mobatek.net/download.html
| Google “mobaxterm download” and this should be the first entry (check the URL).
* Under “Home Edition” select “Download now”
* | On next page select **“MobaXterm Home Edition v11.1 (Portable edition)”**.
* | On next page select **“MobaXterm Home Edition v12.2 (Portable edition)”**.
| This should download the package.
* Click the download icon in the bottom left hand corner.
* | Double-click on the **MobaXterm_Personal_11.1** application file, and select “Extract all”.
* | Double-click on the **MobaXterm_Personal_12.2** application file, and select “Extract all”.
| A new directory window will open up.
* Double-click **MobaXterm_Personal_11.1** to launch the application.
* Double-click **MobaXterm_Personal_12.2** to launch the application.

Next time, navigate to “Downloads” to open the application.

Expand Down
Binary file removed practicals/source/images/ba799-1.jpg
Binary file not shown.
Binary file added practicals/source/images/ba799-new-app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion practicals/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
NCAS Unified Model Introduction: Practical sessions
===================================================

Practical exercises for the UM training course in Reading, 3-5 April 2019.
Practical exercises for the UM training course in Reading, 6-8 November 2019.

NCAS Computational Modelling Services: http://cms.ncas.ac.uk/

Expand Down
29 changes: 14 additions & 15 deletions practicals/source/post-processing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ Run ``um-convpp`` on a fieldsfile (E.g ba799a.pc19880901_00) ::

Note the reduction in file size. Now use xconv to examine the contents of the PP file.

cfa and cfdump
--------------
cfa
---

There is an increasing use of python in the community and we have, and
continue to develop, python tools to do much of the data processing
Expand All @@ -105,19 +105,18 @@ features - we'll use it to convert UM fields file or PP data to
CF-compliant data in NetCDF format. You first need to set the
environment to run ``cfa``: ::

esPP001$ module load anaconda/2.2.0-python2 cf udunits
esPP001$ module swap PrgEnv-cray PrgEnv-intel
esPP001$ export PATH=/home/n02/n02/ajh/anaconda3/bin:$PATH
esPP001$ cfa -i -o ba799a.pc19880901_00.nc ba799a.pc19880901_00.pp
Try viewing the NetCDF file with xconv.


``cfdump`` is a tool to view CF fields. It can be run on PP or NetCDF
``cfa`` can also view CF fields. It can be run on PP or NetCDF
files, to provide a text representation of the CF fields contained in
the input files. Try it on a PP file and its NetCDF equivalent,
e.g. ::

archer$ cfdump ba799a.pc19880901_00.pp | less
archer$ cfa -vm ba799a.pc19880901_00.pp | less
Field: long_name:HEAVYSIDE FN ON P LEV/UV GRID (ncvar%UM_m01s30i301_vn1100)
---------------------------------------------------------------------------
Data : long_name:HEAVYSIDE FN ON P LEV/UV GRID(time(5), air_pressure(17), latitude(145), longitude(192))
Expand All @@ -143,21 +142,21 @@ Many tools exist for analysing data from NWP and climate models and there are ma

* Set up the environment and start python. ::

archer$ module load anaconda/2.2.0-python2 cf udunits
archer$ module swap PrgEnv-cray PrgEnv-intel
archer$ export PATH=/home/n02/n02/ajh/anaconda3/bin:$PATH
archer$ python
>>> import cf

We'll be looking at CRU observed precipitation data

* Read in data files ::

>>> f = cf.read_field('~charles/UM_Training/cru/*.nc')
>>> f = cf.read('~charles/UM_Training/cru/*.nc')[0]

* Inspect the file contents with different amounts of detail ::

>>> f
>>> print f
>>> print(f)
>>> f.dump()
Note that the three files in the cru directory are aggregated into one
Expand All @@ -166,24 +165,24 @@ field.
* Average the field with respect to time ::

>>> f = f.collapse('T: mean')
>>> print f
>>> print(f)

Note that the time coordinate is now of length 1.

* Read in another field produced by a GCM, this has a different latitude/longitude grid to regrid the CRU data to ::

>>> g = cf.read_field('~charles/UM_Training/N96_DJF_precip_means.nc')
>>> print g
>>> g = cf.read('~charles/UM_Training/N96_DJF_precip_means.nc')[0]
>>> print(g)

* Regrid the field of observed data (f) to the grid of the model field (g) ::

>>> f = f.regrids(g, method='bilinear')
>>> print f
>>> print(f)

* Subspace the regridded field, f, to a European region ::

>>> f = f.subspace(X=cf.wi(-10, 40), Y=cf.wi(35, 70))
>>> print f
>>> print(f)

Note that the latitude and longitude coordinates are now shorter in length.

Expand Down
Loading

0 comments on commit 9a817e3

Please sign in to comment.