Three tutorials of the Utrecht University course NS-MO447M Waves in Geophysical Fluids will be devoted to recovering and extending the result published in the paper
Drijfhout, S., & Maas, L. R. M. (2007). Impact of Channel Geometry and Rotation on the Trapping of Internal Tides. Journal of Physical Oceanography, 37(11), 2740–2763. https://doi.org/10.1175/2007JPO3586.1
You will do so using the simple ocean circulation model named “MICOM” (Miami Isopycnic Coordinate Ocean Model Output), written in Fortran, which is the main computer language for nearly all ocean, atmosphere, and climate models.
This repository holds the model code and files that you can use for analysis. This README also contains the instructions for a small report that forms the fifth assignment of the course.
The model is configured as a channel with an open boundary at one, oceanward side, and a continental slope at the opposite side. The length of the channel is 1200 km, the width 191.25 km. There are 43 layers of 100-m depth, so that total depth in the middle of the channel is 4300 m.
A barotropic tidal wave, having a typical period of 12 h, enters the channel from the open boundary. Over the continental slope its mainly horizontally-moving barotropic tidal current aquires a vertical component, as the flow is forced to follow the bottom. This vertical velocity displaces isopycnals up and downward out-of-equilibrium. The gravitational restoring force subsequently generates outward-propagating internal tides.
The paper discusses 4 experiments. In two experiments the earth’s rotation is neglected and the Coriolis frequency is set to 0. In the other two experiments we use an
The model files in this repository are configured for the case
Try to find/remember what the nondimensional parameter tau must be for trapping. Is tau the same for the two combinations of
You are used to working with Python, which is an interpreted programming language. This means that your instructions are not immediately understood by your computer, but are interpreted and translated to machine code on-the-fly as you execute a script. In contrast, Fortran is a compiled programming language. Before you run a program, your entire code needs to be translated to machine code first. This extra step allows your code to run incredibly efficiently whenever it is executed.
To run the model, you will first need to compile it. This is also called building the model. For this assingment, we recommend to run the model on Gemini, the Science department's computer cluster. It is also possible to run the model on your local machine. In any case, make sure to read the specific instructions below.
⚠️ **Instructions for using the Gemini cluster [Click me]**
- Open a Terminal.
- Connect to the Gemini cluster by typing
ssh 1234567@gemini.science.uu.nlusing your Solis-ID in place of 1234567. - Type your Solis-ID password.
- You're in! Your home directory is
/nethome/1234567. It has a quotum of 2GB. If you need to temporarily store large amounts of data, create a personal scratch folder on the scratch disk:mkdir /scratch/1234567. Please do not store data on scratch folders for longer than 2 weeks.
- You can download the files in this repository by first navigating to the directory where you want to store them (
cd /destination/path) and runninggit clone https://github.com/FrankaJes/trapping_internal_tides.git - Navigate to the
modeldirectory:cd trapping_internal_tides/model/ - Use the
make cleancommand, and after that use themakecommand to build the model.
You can use Jupyter Lab on the cluster. This allows you to easily analyze the model output.
- To do so, you must first load Conda:
module load miniconda/3. Initialize Conda by typingconda init bash. You may need to open another bash-shell: typebash. You can tell that Conda is loaded when(base)is being shown in front of the interpreter. - Navigate to the
trapping_internal_tidesdirectory:cd trapping_internal_tides/, and start Jupyter:jupyter lab --no-browser. - Take note of the Jupyter port number that has been assigned (the four digits in the X's in http://127.0.0.1:XXXX) and the token (the long string after
token=). - Open a new terminal window or tab on your local computer. In this terminal we set up an SSH tunnel.
- Pick a random number YYYY between 8000 and 9000. This will be our SSH port number for the tunnel. Try another number if something fails.
- On your local machine, type
ssh -A -L YYYY:localhost:XXXX 1234567@gemini.science.uu.nl - Open a browser on your local computer and go to
localhost:YYYY, whereYYYYis your chosen portnumber. When asked for a password/token, use the one that you noted in step 2.
Instead of analysing the data on the cluster, you can also download the data to your local machine and analyse it using your favourite programme. To download data to your local, you can follow these steps:
- Open a Terminal.
- Copy data from your Gemini directory to your local directory using:
scp 1234567@gemini.science.uu.nl:/path_to_output_data /path_to_local_analysis_directoryusing your Solis-ID in place of 1234567.
More info can be found here: https://github.com/OceanParcels/UtrechtTeam/wiki/How-to-run-parcels-on-lorenz,-gemini-and-cartesius#gemini
⚠️ **Instructions for using your local machine [Click me]**
The model should be able to build on **MacOS** and **Linux** with the Fortran compiler *gfortran* (part of the *GCC* compiler collection) installed. If you are using MacOS, you may first need to install the Command Line Tools using `xcode-select --install`. Then, you can install _gfortran_ as part of _GCC_ using the package manager _[Homebrew](https://brew.sh)_ (after installing Homebrew, use `brew install gcc`). If you use **Windows**, you may install **Linux within Windows** (see [these instructions] (https://docs.microsoft.com/en-us/windows/wsl/about)).
- You can download the files in this repository by first navigating to the directory where you want to store them (
cd /destination/path) and runninggit clone https://github.com/FrankaJes/trapping_internal_tides.git - Navigate to the
modeldirectory:cd trapping_internal_tides/model/ - Use the
make cleancommand, and after that use themakecommand to build the model.
You will find the following files in the model directory:
*.ffiles. These are the source codes for the model. The main code ismicom-ssd.f, and the other files serve as subroutines.makefilethat contains instructions for the compiler*.ofiles that are created after compiling the code with the makefilemicom1.xfile created after compiling the code with the makefile. This is the executable for running the model*.h(3x) files where some variables are defined common to various subroutines and the main partmicom.infile setting a few free parameters.thetasfile describing the densities of the 43 layers.
With the command ./micom1.x, the model starts running.
Three types of output files will be created;
- 16
analyse_****files - 2
average_****files - 1
restart_****file
The MICOM model is a so-called isopycnic model. It consists of layers with constant density but the depth of the interface between the layers is variable (in contrast to so-called constant z-models, where the density of layers is variable, but their interfaces are fixed in time).
- The
analyse-files output the time varying depth of the 43 interfaces at 16 moments in time during the last day (1.5 hour output). This is enough to resolve the dominant frequency of internal waves forced by an external wave with fixed frequency of 12 hrs. - The
average-files describe the 1-day average of the model-state. You only need the last day. - The
restart-file is needed when you want to prolong your run
In the analysis folder, you will find a micom_tools.py file, that contains a simple Python class with a couple of methods to read in the data and to compute the amplitude and phase of the dominant internal wave. Amplitudes are already divided by 980.6 to convert them to centimeters (tutorial_micom_tools.ipynb notebook will guide you through the functionality of the tool. Make sure to have Numpy, Matplotlib and Xarray installed.
In tutorial 1 you will try to recover some of the figures in Drijfhout and Maas (2007). Start by setting up the model on Gemini or your local machine and run the model as it is (so you do not need to change the set-up). Analyse the output data using the provided scripts or create your own scripts to do so.
In tutorial 2 you will have to change parameters to obtain one of the other configurations discussed in Drijfhout and Maas (2007). Below are the places you will have to make changes in the code (although the code is in Fortran, the required changes are so simple that you can make them without detailed understanding of the code). Note that you need to recompile the program using make.
- To change the bottom profile, in
cyclo.fyou must editpmer(line 57) andpoos(line 49) to define the bottom profile in respectively length and width. - To change
$f$ you must editgeopar.f(line 22-23) - To change
$N$ you must editthetas. The values in thetas represent the potential densities (assuming a linear equation of state, where density solely depends on potential temperature), and are determined as ($\sigma_0-1000)/1000$ . That means that$1000*\sigma_0$ runs from 26.0 till 28.071$\rm{kg}/{m}^3$ . - To change the length of the run you must edit
micom.in. The 5 values are explained inmicom_ssd.fwheremicom.inis read on line 27. You can search for their names to understand what they steer. The first 2 values refer today1andday2and the model runs fromday1today2.
In tutorial 3 we ask you to configure at least 1 configuration that was NOT discussed in Drijfhout and Maas (2007). You may think of the following options:
- What happens when you change the forcing frequency? Are the results invariant for this parameter? And what happens if you add the new and old frequency in the forcing? How linear is the response?
You can change the forcing frequency in
boundpb.fandboundvb.fon line 30 (sin(tsec*2.*pi/(12.*3600.))). - What happens if you choose steeper or less steep bottom profiles in the cross-channel direction? What happens if you add random small-scale perturbations to the bottom?
- What happens if you turn the channel (from an east-west alignment to a north-south alignment), or to make it easy, make
$f$ a variable function of x? - What happens if you make
$N$ stronger or weaker or no longer a constant but a function of z? - Maybe you want to change another parameter. Which one would you choose (try to argue, even if you have no time to do this)?
- In our examples
$N$ >$f$ . What happens if$f$ > 10 *$N$ ? Can you design such a combination that keeps tau unchanged? What happens if you apply this combination of$f$ and$N$ ? Note that changing$N$ implies changing theta.
For the assignment, we ask you to hand in a report in which you
- Motivate your choice of figures for three different simulations (choose 2-4 per simulation)
- Write a clear interpretation of the figures
- Explain why you must adapt
$N$ and total runtime when$f$ changes - Explain why you see trapping of internal waves in the initial set-up (tutorial 1) and not in other set-ups (different
$f$ values and bottom profiles) - Think about the story you want to tell (see the first bullet) and highlight the main conclusions
The report can be written in your usual groups and the deadline for this assignment is May 28th, 2024.