# TRACK storm tracking
## Install (scalc01.geomar.de)
Get the code to your home directory
```
cd /home/$USER/
cp /data/user/jkjellsson/TRACK-1.5.2_latest.tar .
tar -xvf TRACK-1.5.2_latest.tar
mv TRACK-1.5.2_latest TRACK-1.5.2
cd TRACK-1.5.2
```
Add current dir to your PATH
```
export PATH=${PATH}:.
```
Set variables for compilers etc
```
export CC=gcc
export FC=gfortran
export ARFLAGS=
export NETCDF=/usr/
```
Compile TRACK
```
master -build -i=linux -f=linux
```
Change line 11 in utils/Makefile from
```
makelinks.csh
```
to
```
./makelinks.csh
```
Compile the utils
```
make utils
```
That's it!
## Spectral filtering of data
The input files for TRACK are in
```
/data/user/jkjellsson/track_files/
```
Put the adapt.dat0, zone.dat0, initial.T63_NH and initial.T63_SH in the TRACK-1.5.2/data directory.
Put the RUNDATIN files and the RSPLICE.in file in the TRACK-1.5.2/indat directory and the specfilt.in file in the main TRACK-1.5.2 directory.
Put your MSLP netcdf file in the indat directory or a symbolic link to it. For example
```
ln -sfv /data/proj/foci/foci-openifs1.0/foci_JJK001_pmpi/outdata/oifs/foci_JJK001_pmpi_19500101_19991231_MSL.nc indat/foci_JJK001_pmpi_MSL.nc
```
First run the spectral filtering using
```
bin/track.linux -i foci_JJK001_pmpi_MSL.nc -f filt < specfilt.in
```
TRACK needs only to be the filename as the code knows to look in the indat directory.
You will get a file in the outdat directory called specfil.filt_band001 which should be renamed to the indat directory, e.g.
```
mv outdat/specfil.filt_band001 indat/foci_JJK001_pmpi_19500101_19991231_MSL_T63filt.bin
```
The outdat/specfil.filt_band000 can be deleted.
The new filtered data file will be in an other format, if you want to view it it will need converting to netcdf using the converters/bin2nc program which first needs to be compiled in the converters directory.
```
gcc -I[netcdfpath]/include -I../include -o bin2nc bin2nc.c ../src/new_time.o -L[netcdfpath]/lib -lnetcdf -lm
```
On the GEOMAR scalc machines, netcdfpath is /usr/
To run use:
```
./converters/bin2nc indat/foci_JJK001_pmpi_19500101_19991231_MSL_T63filt.bin indat/foci_JJK001_pmpi_19500101_19991231_MSL_T63filt
```
This will create a file foci_JJK001_pmpi_19500101_19991231_MSL_T63filt.nc that you can open with ncview and make sure its ok.
## Run
To run the tracking first edit the RUNDATIN files and change the path /users/kih to your installation path.
Make sure TRACK directory is in your PATH environment variable.
You can actually add this to your .bashrc
```
export PATH=${PATH}:/home/$USER/TRACK-1.5.2/
```
To run the tracking use for the NH
```
master -c=[OUTDIR] -e=track.linux -d=now -i=foci_JJK001_pmpi_19500101_19991231_MSL_T63filt.bin -f=y1950 -j=RUN_AT.in -k=initial.T63_NH -n=1,62,3 -o=[OUTPATH]/NH -r=RUN_AT_ -s=RUNDATIN.JOAKIM_MSLP
```
and for the SH
```
master -c=[OUTDIR] -e=track.linux -d=now -i=foci_JJK001_pmpi_19500101_19991231_MSL_T63filt.bin -f=y1950 -j=RUN_AT.in -k=initial.T63_SH -n=1,62,3 -o=[OUTPATH]/SH -r=RUN_AT_ -s=RUNDATIN.JOAKIM_MSLP
```
You need to provide the [OUTPATH] where you want the output to be written and the output directory [OUTDIR] which should be unique for each run. Note the -n setting is suitable for the length of data you sent but this would need to be changed for a longer time period.
If the runs are successful you should get the ff_trs_pos.gz, ff_trs_neg.gz, tr_trs_pos.gz and tr_trs_neg.gz files.
These are compressed text files so uncompress to view. The tr files contain all tracks and the ff files the filtered tracks to retain those that last longer than 2 days and travel more than 1000km.
The pos files are for positive anomalies, i.e. anticyclones and the neg files are the cyclones.
## Using screen for long runs
Analysis of large and/or long data sets can take some time, and the connection between your computer and scalc might break so that you lose all progress.
The best way is to start a screen session.
First, type screen
```
screen
```
Then type the command you wish to run
```
<some stuff that will take a long time>
```
Now you can "detach" the screen by pressing Ctrl+A+D.
If you log out or the connection breaks, the screen session will still run on the scalc machine.
To get back to the session, type
```
screen -r
```
which will re-attach the screen to your terminal window.