Top Banner
MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014
30

MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Jan 03, 2016

Download

Documents

Colleen Maxwell
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

MS 698: 2014Implementing a Hydrodynamic Model

- Part 2

Julia Moriarty14 February 2014

Page 2: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Previously…• Governing Equations• Horizontal and Vertical Grid• Time-Stepping (Mode-splitting)• Compiling and Running 1D Test Case• Basic plots in MATLAB

This Week• Changing Inputs, Outputs • Practice Plotting

Page 3: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Types of Input

What types of input did we change last class?

Page 4: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Types of Input

1. Header file: sed_toy.h2. Analytical files: ana_smflux.h, etc. 3. NetCDF files: boundary_conditions.nc, etc.

Not in SED_TOY

4. ‘The’ input file: ocean_sed_toy.in

Page 5: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

The Header File:ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

Examples of header files for test cases

Header file for model run:sed_toy.h

Page 6: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

The Header File:sed_toy.h

ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

Page 7: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

What does the header file do?• Defines or undefines options, usually related

to the model setup and parameterizations Model Code:e.g. *.h, *.F

Page 8: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

What does the header file do?• Defines or undefines options, usually related

to the model setup and parameterizations Model Code:e.g. *.h, *.F

Model Code used for your model run:PROJECT/Build/*.f90

Compile

Page 9: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

What does the header file do?• Defines or undefines options, usually related

to the model setup and parameterizations Model Code:e.g. *.h, *.F

Model Code used for your model run:PROJECT/Build/*.f90

Compile

Page 10: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

What options are available for

header files?

ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

cppdefs.h lists all options for header files

-also see ROMS wiki: https://www.myroms.org/wiki/index.php/Documentation

_Portal

Page 11: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Model Forcing:Analytical files vs. NetCDF files

• Both analytical and NetCDF files provide ways to force your model (e.g. winds, model bathymetry, boundary information)– Only use one at a time for a particular forcing

• NetCDF files provide timeseries of data, more complicated model grids

• Analytical files are useful for simple forcing functions, e.g. constant or sinusoidal wind forcing, constant water depth, etc.

Page 12: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Analytical Files:e.g. ana_smflux.h

ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

Page 13: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Analytical Files:ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

… Original copies of analytical files:

ana_*.h

Edited copies of analytical files stored in one of these

directories

Page 14: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Analytical Files:ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

…Original copies of

analytical files:ana_*.h

Edited copies of analytical files stored in one of these

directories

Steps:1. Specify directory for edited

analytical files in build.bash (In this class, we used Include, not Functionals)

2. Copy original ana_*.h file to your PROJECT/Functionals or Include directory

3. Edit ana_*.h file(s)4. (Re)compile code

Page 15: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

NetCDF Files:ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

Page 16: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

NetCDF Files:ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

… Examples of NetCDF forcing files

(and *.in files)

NetCDF forcing files may be stored anywhere, but are

often stored here.

Page 17: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

‘The’ Input Files

• Main input file: ocean.in

• Ocean.in calls other input files– sediment.in, floats.in,

stations.in, …

Page 18: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

‘Input Files’: ocean.in,

sediment.in

ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

… Examples of input files (and NetCDF forcing

files)

Input files may be stored anywhere, but it are often

stored here.

Page 19: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

What’s in ocean.in?• Timesteps• Open boundary conditions• Basic horizontal and vertical grid information• Directions for output files• Paths for other input and output files (e.g.

NetCDF files, sediment_sed_toy.in, ocean_his.nc)

• … and much more …The second half of the ocean.in file is a glossary explaining all of the different parameters in ocean.in

Page 20: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Editing Code and Input Files

Page 21: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Useful Linux Tools for Editing Code:

• Be creative: *, .., ., ‘|more’, ‘> outfile.txt’ work with most commands

Command Description

diff file1.txt file2.txt Prints out a line-by-line comparison of file1.txt and file2.txt to the command line.

diff file1.txt file2.txt > file1_vs_file2.txt Creates file1_vs_file2.txt, which is a line-by-line comparison of file1.txt and file2.txt

grep SED_TOY ana_smflux.h Prints out line numbers of all occurrences of “SED_TOY” in ana_smflux.h to the command line

grep SED_TOY ana_*.h Prints out line numbers of all occurrences of “SED_TOY” in all files starting with “ana_” and ending in (“.h”) to the command line

grep SED_TOY * |more Prints out line numbers of all occurrences of “SED_TOY” in all files in this directory in the command line. The “|more” makes Linux print out only one page’s worth of text at a time. Press the spacebar or Enter to scroll through results.

From within Emacs: Ctrl-sWhen prompted (at the bottom of the window) enter a string to search for, e.g. ‘SED_TOY’

Searches for “SED_TOY” within the file you have open in Emacs. This is case sensitive. Emacs begins searching from wherever your cursor is, moving downward in the document. To search upwards, use ‘Ctrl-r’ instead of ‘Ctrl-s’.

Page 22: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Other Useful Linux Tools:

• Be creative: ‘*’, ‘..’, ‘|more’, ‘> outfile.txt’ work with most commands• Be careful with case-sensitive commands

Command Description

more file.txt Scroll through file.txt in the command line

ls */*/*.in List any file ending in “.in” that is located two directories below the current working directory.

ls ../../ana_* List all files starting with “ana_” that are located two directories above the current working directory

ls ../../trunk/ROMS/Functionals/ana_* List all files starting with “ana_” that are located two directories up, and then within the trunk/ROMS/Functionals directory

tail ocean_sed_toy.log Print out the last few lines of the file ocean_sed_toy.log

tail –f ocean_sed_toy.log Print out the lines of the file ocean_sed_toy.log as the file is written

From within ROMS model code:write(6,*) ‘text’ variable

Prints out “ text value_of_variable” to the log file in ROMS.

Page 23: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Is ROMS doing what you think its

doing?

ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

Check output files

*.f90 files are human-readable versions of the

compiled code

Page 24: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Is ROMS doing what you think its

doing?

ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

Check, then check again

- Is the model code correct?- Does the model produce

reasonable output?- Trouble shoot:

- Look at *.f90’s, log file- Use write statements

Page 25: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Overview of Output Files• History Files: ocean_his.nc

– Stores time-series of instantaneous output.

• Time-Averaged Results: ocean_avg.nc– Stores time-series of time averaged values.

• Restart File: ocean_rst.nc– Used to restart a model run from exactly where it ended.

• Log File: ocean_sed_toy.log– Text file with information on model configuration, error messages, and

much more. – Only created if specified in the oceanS command:

• oceanS < External/ocean_sed_toy.in > Results/ocean_sed_toy.log &

Page 26: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

ROMS OutputROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

Output files may be stored anywhere, but are often

stored here.

Page 27: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

ROMS Output:Location specified in

ocean.in

ROMS_OneD

trunk

PROJECT

Results

Build

External

ROMS

Include

Functionals

External

Include

Functionals

Page 28: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Manipulating Output Files• “Directions” for output

files in ocean_*.in:– NHIS – number of time-

steps between writing fields into history file

– NDEFHIS – number of time-steps between the creation of a new history file. NDEFHIS = 0 creates a single history file.

– HISNAME – name and path for history file

– Hout(*) – Tells model if it should prints out each variable to the history file

Page 29: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Questions?>> Start lab activity

Page 30: MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.

Manipulating Time Steps

• DT – Time-step (baroclinic) in seconds• NDTFAST – number of barotropic time-steps

between each baroclinic time step• NTIMES – Total number of baroclinic

timesteps. • DSTART – First Timestamp of model

“Δt in history file” = DT * NHIS“Total Model Time” = DT*NTIMES