UKCA Chemistry and Aerosol vn10.9 Tutorial 11

From UKCA
Revision as of 16:32, 13 December 2017 by Nla27 (talk | contribs) (→‎Make a branch)

UKCA Chemistry and Aerosol Tutorials at vn10.9

What you will learn in this Tutorial

In this tutorial you will go through a worked example showing you how to commit code to the UM trunk.

You should also open the working practices for the UM page on MOSRS and read through that as well.

This can only be completed on the Virtual Machine, as rose-stem does not currently work on ARCHER.

Before you start this Tutorial

Before you start this tutorial you will need to have a working Virtual Machine where known good output (or KGO) has been installed for the vm_n48_ukca_eg_noomp. You can do this by running the command

rose stem --group=vm_n48_ukca_eg_noomp -S GENERATE_KGO=true

within a vanilla copy of the vn10.9 trunk. When this runs for the first time the two KGO tasks will fail, but when this happens the KGO is installed. You just need to re-trigger these two tasks to run again, and they will succeed and the suite will stop.

For more information on the VM you should read-through umdp_X10.

Create a ticket

You will need to fill-in several headings. These can all be changed later if needed.

  • Summary: Give a short description of what the change is for.
  • Description: Give a longer and more detailed description.
  • Type: Putting enhancement is usually fine here.
  • Milestone: This should be the UM (or Mule) version that you are targeting. If you don't know a particular version leave this as Hopefully, and if you aren't targeting a version then you can put this as Not for Builds. In this example please use Not for Builds.
  • Severity: Usually changes will be minor or significant, depending on if results are changed. Usually wholesale and trivial aren't used very often. This doesn't matter too much, as the Code Reviewer will often change this during their review.
  • Keywords: When working on UKCA, please include UKCA and SC0138 (this is to make it easy to search for UKCA tickets)

Once you have created it, you should Modify it and start work and then click submit. This will change the ownership to you and change the ticket statue to in_progress. You will now be able to find your ticket on your view tickets page.

You can find an example of this here: um:#3639.

Make a branch

Please make a branch as covered in Tutorial 4, e.g.

fcm branch-create --type dev -k ticket_number your_branch_name fcm:um.x_tr@vn10.9

and then check-out your branch by

fcm checkout fcm:um.x_br/dev/userid/vn10.9_your_branch_name

Merge in Initial Changes

You should merge-in branch dev/lukeabraham/vn10.9_UKCA_Worked_Example by changing into the top-level directory of your branch and doing

fcm merge fcm:um.x_br/dev/lukeabraham/vn10.9_UKCA_Worked_Example@47427

(Note: the revision number 47427 is important here) and then fcm commit your branch.

The code that you are checking in can be found here: https://code.metoffice.gov.uk/trac/um/changeset/47427

Index: src/atmosphere/UKCA/ukca_light.F90
===================================================================
--- src/atmosphere/UKCA/ukca_light.F90	(revision 47420)
+++ src/atmosphere/UKCA/ukca_light.F90	(revision 47427)
@@ -241,27 +241,60 @@
   !         3 from cloud base to 2 above top
   !         KLT is the level above cloud top
 
-  dpcg = ppress(1) - ppress(jniv)
-  dpcc = ppress(jniv) - ppress(klt)
+  IF (l_ukca_linox_logp) THEN
+    !  DO EVERYTHING LINEARLY IN LOG(PRESSURE)
+    ! sanity check to prevent dpcg==0
+    IF (jniv <= 1) jniv=2
+    
+    dpcg = LOG(ppress(1)) - LOG(ppress(jniv))
+    dpcc = LOG(ppress(jniv)) - LOG(ppress(klt))   
+    !         ...construct L-NOx profile in kg(N)/gridcell/s
+    !         ...first cloud-to-ground L-NOx profiles (kg(N)/gridcell/s)
+    IF ((jniv-1) == 1) THEN
+       anox(1) = acgnox
+    ELSE
+      DO k = 1,jniv-1
+         anox(k) = acgnox * ((LOG(ppress(k))-LOG(ppress(k+1)))/dpcg) 
+      END DO
+    END IF
+    
+    !         ...then cloud-to-cloud L-NOx profiles (kg(N)/gridcell/s)
+    IF (LOG(ppress(jniv)) <= LOG(ppress(klt))) THEN
+      ! jniv (level of the 500hPa level) is above the
+      ! cloud-top-height. In this case, put all C2C N
+      ! into the cloud-top level.
+      anox(klt-1) = anox(klt-1) + accnox
+    ELSE
+      ! jniv is greater than the cloud-top-height
+      ! Note: anox(k) is also on the RHS of this equation
+      DO k = jniv,klt-1
+         anox(k) = anox(k) + accnox * ( (LOG(ppress(k)) - LOG(ppress(k+1))) / dpcc ) 
+      END DO
+    END IF
+  ELSE ! .not. l_ukca_linox_logp
+    !  DO EVERYTHING LINEARLY IN PRESSURE
+    dpcg = ppress(1) - ppress(jniv)
+    dpcc = ppress(jniv) - ppress(klt)
+    !         ...construct L-NOx profile in kg(N)/gridcell/s
+    !         ...first cloud-to-ground L-NOx profiles (kg(N)/gridcell/s)
+    IF ((jniv-1) == 1) THEN
+      anox(1) = acgnox
+    ELSE
+      DO k = 1,jniv-1
+         anox(k) = acgnox * ((ppress(k)-ppress(k+1))/dpcg)
+      END DO
+    END IF
+    
+    !         ...then cloud-to-cloud L-NOx profiles (kg(N)/gridcell/s)
+    IF (ppress(jniv) <= ppress(klt)) THEN
+      anox(klt-1) = anox(klt-1) + accnox
+    ELSE
+      DO k = jniv,klt-1
+         anox(k) = accnox * ((ppress(k)-ppress(k+1))/dpcc)
+      END DO
+    END IF
+  END IF ! l_ukca_linox_logp
 
-  !         ...construct L-NOx profile in kg(N)/gridcell/s
-  !         ...first cloud-to-ground L-NOx profiles (kg(N)/gridcell/s)
-  IF ((jniv-1) == 1) THEN
-    anox(1) = acgnox
-  ELSE
-    DO k = 1,jniv-1
-      anox(k) = acgnox * ((ppress(k)-ppress(k+1))/dpcg)
-    END DO
-  END IF
-
-  !         ...then cloud-to-cloud L-NOx profiles (kg(N)/gridcell/s)
-  IF (ppress(jniv) <= ppress(klt)) THEN
-    anox(klt-1) = anox(klt-1) + accnox
-  ELSE
-    DO k = jniv,klt-1
-      anox(k) = accnox * ((ppress(k)-ppress(k+1))/dpcc)
-    END DO
-  END IF
 END IF
 
 IF (lhook) CALL dr_hook(ModuleName//':'//RoutineName,zhook_out,zhook_handle)

You should now run this through rose-stem by running the command

rose stem --group=vm_n48_ukca_eg_noomp,umdp3_check

The vm_n48_ukca_eg_noomp will run the code through one of the UKCA jobs, and the umdp3_check will test for coding standard compliance.

UKCA Chemistry and Aerosol Tutorials at vn10.9


Written by Luke Abraham 2017