An Overview of ROMS Code Kate Hedstrom, ARSC April 2007.

Slides:



Advertisements
Similar presentations
Building CCSM2.0 Brian Kauffman CCSM Software Engineering Group
Advertisements

Compiling. Your C, C++ or Fortran program won’t work unless you compile it The compiler will build your program as an executable file (typically in the.
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 17 - The Preprocessor Outline 17.1Introduction 17.2The #include Preprocessor Directive 17.3The.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction.
More about the C Preprocessor CS-2303, C-Term More about the C Preprocessor CS-2303 System Programming Concepts (Slides include materials from The.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction 13.2The #include Preprocessor Directive 13.3The.
The Unix Environment and Compiling. Getting Set Up Your programs will be compiled and tested on the Departmental server ‘linprog’ The linprog servers.
 2007 Pearson Education, Inc. All rights reserved C Preprocessor.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 19 - The Preprocessor Outline 19.1 Introduction 19.2 The #include Preprocessor Directive 19.3.
The Pre-processor A unique feature of c language is the pre-processor. A program can use the tools provided by pre-processor to make his program easy to.
The preprocessor and the compilation process COP3275 – PROGRAMMING USING C DIEGO J. RIVERA-GUTIERREZ.
1 CSC103: Introduction to Computer and Programming Lecture No 26.
Programming In C++ Spring Semester 2013 Programming In C++, Lecture 1.
Configuring ROMS for South of Java Kate Hedstrom, ARSC/UAF October, 2007.
Windows Programming Lecture 05. Preprocessor Preprocessor Directives Preprocessor directives are instructions for compiler.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Macros. There are three basic phases for C programming. preprocessing, compiling, and linking. C input file is first passed to a preprocessing program.
The Structure of a C++ Program. Outline 1. Separate Compilation 2. The # Preprocessor 3. Declarations and Definitions 4. Organizing Decls & Defs into.
Old Chapter 10: Programming Tools A Developer’s Candy Store.
Introduction to C Programming CE Lecture 7 Compiler options and makefiles.
Introduction to Programming Using C Modularity. 2 Contents Modularity Functions Preprocessor Comments Global variables.
MS 698: 2014 Implementing a Hydrodynamic Model - Part 2 Julia Moriarty 14 February 2014.
C Hints and Tips The preprocessor and other fun toys.
240-Current Research Easily Extensible Systems, Octave, Input Formats, SOA.
ROMS as a Component of the Community Climate System Model (CCSM) Enrique Curchitser, IMCS/Rutgers Kate Hedstrom, ARSC/UAF Bill Large, Mariana Vertenstein,
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessing Lecture 12 April 7, 2005.
Week 2-3 Control flow (review) Conditional statements If, else, else if, switch-case, break Loop constructs for, while, do-while, break, continue, label--go;
ROMS/TOMS European Workshop Alcala de Henares, Spain, November 7, 2006 ROMS Framework and Algorithms Andrew M. Moore UCSC Emanuele Di Lorenzo Georgia Tech.
Beginning Fortran Fortran (77) Advanced 29 October 2009 *Black text on white background provided for easy printing.
Dr. Mark L. HornickCS-1030 Dr. Mark Hornick 1 C++ Global functions Declarations & Definitions Preprocessor Directives.
Copyright © 2015 Curt Hill Make An Indispensable Developer’s Tool.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
GUIs Basic Concepts. GUI GUI : Graphical User Interface Window/Frame : a window on the screen Controls/Widgets : GUI components.
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
Compiler Directives. The C Preprocessor u The C preprocessor (cpp) changes your source code based on instructions, or preprocessor directives, embedded.
Report on POP & CICE of RACM components Jaromir Jakacki, IO PAS Boulder, CO, 2010.
The Preprocessor Directives Introduction Preprocessing – Occurs before program compiled Inclusion of external files Definition of symbolic constants.
Slide 1 NEMOVAR-LEFE Workshop 22/ Slide 1 Current status of NEMOVAR Kristian Mogensen.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction 13.2The #include Preprocessor Directive 13.3The.
© Oxford University Press All rights reserved. CHAPTER 10 THE PREPROCESSOR DIRECTIVE.
1 Object-Oriented Programming -- Using C++ Andres, Wen-Yuan Liao Department of Computer Science and Engineering De Lin Institute of Technology
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Pre-Compiler Directives for TTCN-3 Ina Schieferdecker in response to CR5089 and 5090.
Hank Childs, University of Oregon April 13 th, 2016 CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / /
Lecture 3 Translation.
COM S 326X Deep C Programming for the 21st Century Prof. Rozier
13 C Preprocessor.
ROMS Framework: Kernel
Separate Compilation and Namespaces
Shell Scripting March 1st, 2004 Class Meeting 7.
Chapter 13 - The Preprocessor
Pre-processor Directives
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
What is Bash Shell Scripting?
Compiler Construction
Preprocessor C program → Modified C program → Object Code
Register Variables Declaring a variable as a "register" variable is an advisory to the compiler to keep the normal location of the variable in a register,
C Preprocessor(CPP).
Preprocessor.
Defining and Calling a Macro
Coding Concepts (Basics)
C Preprocessor Seema Chandak.
Lab 4: Introduction to Scripting
CPL7/CCSM4 (J.Jakacki/G.Jost)
Conditional Compilation
SPL – PS1 Introduction to C++.
Week 2 - Friday CS222.
Preprocessor Directives and Macros Chapter 21
Presentation transcript:

An Overview of ROMS Code Kate Hedstrom, ARSC April 2007

Outline Outline of the code cpp cppdefs.h Modules ocean.in Note: understanding gnu make is important, but not covered in this talk

ls roms Atmosphere/ Lib/ User/ Build/ makefile Waves/ Compilers/ Master/ Data/ ROMS/ I also have an Apps directory here for my applications.

ls ROMS Adjoint/ License_ROMS.txt Bin/ Modules/ SeaIce/ Drivers/ Nonlinear/ Tangent/ External/ Obsolete/ Utility/ Functionals/ Programs/ Version Include/ Representer/

Most Important Drivers –Various model main programs Nonlinear –The regular ocean physics (forward model) Modules –Ocean model data types, with allocation and initialization routines Utility –File reading and writing routines and other files common to the various models

Support Include –Include files, including cppdefs.h Bin –Perl and shell scripts Compilers –System-dependent parts of the makefile Lib –ARPACK and MCT libraries (optional) External –ASCII input files

Other Data Assimilation –Adjoint –Representer –Tangent SeaIce Functionals –Analytic expressions for initial conditions, etc. Obsolete Programs

Master/master.F #include “cppdefs.h” #if defined AIR_OCEAN # include “air_ocean.h” #elif defined WAVES_OCEAN # include “waves_ocean.h” #else # include “ocean.h” #endif

Master/ocean.h #include “cppdefs.h” PROGRAM ocean USE … #ifdef MPI CALL mpi_init CALL mpi_comm_rank(…) #endif CALL initialize CALL run CALL finalize #ifdef MPI CALL mpi_finalize #endif END PROGRAM ocean

ROMS/Drivers/nl_ocean.h Included by ocean_control.F Contains initialize, run, finalize for the nonlinear ocean model Run calls main3d or main2d inside the timestepping loop Calls get_data which reads files now or handles the coupling in CCSM Many, many other include files for the other models

ROMS/TOMS: MODULAR DESIGN

cpp The C preprocessor, cpp, comes with some C compilers, or the functionality can be built into a C compiler Very simple macro processor Used in ROMS primarily for conditional compilation We probably won’t switch to coco when it becomes widely available

cpp Versions People started using the C preprocessor before there was a C standard - the Standard cpp isn’t quite the version we want Gnu “cpp -traditional” does the right thing for Fortran

File Inclusion In Fortran, you can include files with: include ‘file.h’ In cpp, the equivalent is: #include “file.h” We use the cpp version to make sure the #defines in the include files are seen

Macro Substitution A macro definition has the form: #define text replacement text This is done in ROMS: #define WESTERN_EDGE Istr.eq.1 and used in: if (WESTERN_EDGE) then …. Safe as long as the replacement text is not much longer than the original

More on Macros Another type of macro substitution is like statement functions in Fortran Statement functions and the more modern inlined functions are better because the compiler can do type checking

Logical Macros A third kind of macro is something like: #define MASKING or #define MASKING 1 These can be tested like: #ifdef MASKING (first case) #if MASKING (second case) We use the first style for historical reasons, gnu has officially gone to the second

Conditional Compilation ROMS uses conditional code everywhere. #ifdef ICE ! Stuff having to do with sea ice #endif If you want to find out about (say) sediment code, do a search on SEDIMENT

More on Conditionals When setting up a problem of your own, it’s best to surround code you add with a unique cpp flag: #define LOMBOK_STRAIT : #ifdef LOMBOK_STRAIT ! My code #endif

Still More The ROMS Makefile will take our.F files and run them through cpp for us before passing them to the compiler The intermediate files have a.f90 extension The compiler errors will refer to line numbers in the.f90 file, not the original source file Fix the.F file, but feel free to look at the.f90 files to see what happened

cppdefs.h Every ROMS source file starts with: #include “cppdefs.h” This file has been changed to contain #if defined ROMS_HEADER # include ROMS_HEADER #endif The ROMS_HEADER variable comes from the makefile now

Modules The model variables are stored in Fortran 90 modules defining specific types You no longer have to modify mod_param.F for your domain Let’s look at a few…

Input file ROMS has an ascii input file which it reads during initialization The file is not a namelist, but similar in intent It specifies things like: –Number of timesteps –Number of gridpoints (Lm, Mm, N) –Parallel grid partitioning –Other input filenames, output options –Many others