You are on page 1of 8


Useful websites for Python scripts:

Powerpoints on ROMS and RegCM4-ROMS:

Install PYROMS, netcdf, parallel netcdf 1.2, EMSF 5.2.0rp2, EPD PYTHON, XML XERCES, MPI,

Create file similar to /home/graziano/ and source the file.


Download ETOP01 netcdf file (“ice surface”) from

Extract a smaller ETOP01 grid, surrounding the region of study, using either NCO or CDO:

ncks –d lon,-94.,-72. –d lat,38.,50.


cdo sellonlatbox,-94,-72,38,50

vi the python script for creating your ROMS grid,

Specify center lat,lon of your grid, which affects the projection.

lat_0 = 43.
lon_0 = -85.6

Specify lower left and upper right corners, which surround the entire lake region.
In this case, this box includes all 5 lakes with a little buffer around it. Don’t make it too big
or it will slow the model down.
llcrnrlon= -92.0
Plot map in python.

Type ipython

At first, you need to cut and paste the python script commands into command-line python
to get a satisfactory grid. Later, you can run the entire script as is.

Copy 1st part of into python to make a map of x,y points.

To draw a map:
run map.drawcoastlines

Find upper-left point 1st and then go counterclockwise, identifying the values of x and y.
This box should surround the entire lakes.
For the Great Lakes, these are the values:
UL: x=19617 y=915744
LL: x=19617 y=30170
LR: x=1356380 y=30170
UR: x=1356380 y=901730

In, specify these coordinates into Xp and Yp.


In python, copy and paste 2nd section from to generate grid map.

Need to specify # points in N-S direction (Mm) and # points in E-W direction (Lm).
Try these initial values:


Run python commands again.

To check the current x-direction and y-direction resolution of your grid in meters, type:

Check to see that both are close to 10-km, which was our goal resolution.
If either is not close to 10-km, change Mm and Lm until they are closer to 10-km.

Now, cut and paste next part of We are checking for the correct segment,
which represents the Great Lakes. Unfortunately, there are 126 segments total and we
don’t know which represents the Great Lakes. In fact, 3 of them in total represent the lakes,
not one.

These commands will help you figure out which segments are largest and the likely ones
that represent the Great Lakes.
print(nseg, size(verts))

Try different segments to see which captures the lakes. Segment 2 gave the 3 western lakes.
Segment 5 gave Erie. Segment 6 gave Ontario. We need to change the line below so it
includes all 3 segments to get all of the lakes.

In, change
“if nsseg==4” line and lines below TO:

nseg = 0
hgrd.mask_rho[:] = 0.0
for verts in map.coastsegs:
if (nseg == 2 or nseg == 5 or nseg == 6):
hgrd.mask_polygon(verts, mask_value=1.0)

(Be careful to get the spacing right in the above commands or it won’t work.)

Cut and paste command:

pyroms.hgrid.edit_mask_mesh(hgrd, proj=map)

Brings up grid map that we can manually edit to remove land points.

To edit map, press “e” and click points to change to specify land points.
Click 5th icon on lower left (with magnifying glass) for zooming.
Close connections between lakes.

Edit further

Specify subset ETOP01 file name.‘’)

Run full python script now:

LL x=998812 y=260816
LR x=1341660 y=285946
UR x=1332690 y=472628
UL x=993427 y=427752

Superior=180m Huron=176m Ontario=75m Michigan=176m

So, can use 176m for 4 lakes and 75m for Ontario.

topo_org = topo.copy()
topo = topo_orig-176.0

ix = np.asarray(where ((lats > 43) & (lats < 44.5)))

jx = np.asarray(where ((lons > -80) & (lons < -76.0)))
for i in range(0,ix,shape[-1]):
for j in range(0,jx,shape[-1]):
topo[ix[0,i]][jx[0,j]] = topo_org[ix[0,i]][jx[0,j]]-75.0

Run python script, again.

It creates Rename the file as version 2.


mkdir cpl2
cd cpl2
mkdir input
mkdir output

mv into cpl2/input/

cd input

Copy the following files into this input directory:

roms_glue_forc.ncl -> Combines the individual months into one file
roms_split_fld.ncl -> Splits the input files into individual months

Need to merge all of the SRF output files into a single file,

ncrcat ../../cpl/output/
../../cpl/output/ ../../cpl/output/

vi roms_forc.ncl

prefix = “GLAKE”


cycle_length = 365

Change the epoc if-then loop to the following:

epoc = “days since 2000-04-01 00:00:00”

durl = ”.”

Edit the “if (dname….) loop” twice, regarding SRF, in script to:
url = durl+”/”
Don’t worry about the RAD files because the model won’t use them.

Comment out “varz =” lines.

vi (interpolates 9 forcing variables and creates GLAKE_forcing*nc monthly

First we prepare for year 2000.

for yy in `seq 2000 2000`

for mm in 04 05 06 07 08 09 10 11 12
(since we want to run April 2000 – December 2000)

Specify GLAKE_forcing_${str}.nc

Run script
(This script will run roms_forc.ncl)

Then we’ll prepare for year 2001.

Then vi again

for yy in `seq 2001 2001`

for mm in 01 02 03
(Since we want to run Jan 2001-Mar 2001)

Run script again



Change file to “GLAKE_forcing_*

(Runs roms_split_fld.ncl)

This will create one nc file per variable per month.




List of variables should begin with lwrad, etc (remove two variables for clouds and
radiation before it).

(Runs roms_glue_forc.ncl)

Merges all forcing files into one file


In cpl2 directory,

cp ../cpl/regcm.in_LAKESUP20km_16-05-12-09:57 regcm.in_LAKESUP20km

cp ../cpl/ .
cp ../cpl/ .
cp ../cpl/varinfo.dat .
cp ../cpl/regcm.job .
cp ../cpl/regcm.rc .

We’ll use the same executable as a previous run, so link to those binaries.
ln –s ../cpl/src/RegCM-4.3-rc7/Bin .

Link the ICBCs, domain, and SSTs from the previous run so we can use them again.
cd input
ln –s ../../cpl/input/GLAKE_ICBC.200* .
ln –s ../../cpl/input/ .
ln –s ../../cpl/input/ .

cd ..
(in cpl2 dir)

vi regcm.in_LAKESUP20km

lakemod = 0


ncdump –h
xi_rho=129, eta_rho=83

Mm == 81 (2 less than in ncdump of forcing file)

Lm == 127 (2 less than in ncdump of forcing file)

NNREC == 0 (spinup, not a restart)

LcycleRST == F (write restart each day and file continues to grow)
LDEFOUT == T (daily history files)

GRDNAME == input/
ININAME == /dev/null (we provided the initial conditions)

vi regcm.job

Submit job:
qsub regcm.job

Check regcmout.txt to check the progress of the run.