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

An Overview of ROMS Code Kate Hedstrom, ARSC April 2007

Embed Size (px)

Citation preview

  • An Overview of ROMS CodeKate Hedstrom, ARSCApril 2007

  • OutlineOutline of the codecppcppdefs.hModulesocean.inNote: understanding gnu make is important, but not covered in this talk

  • ls romsAtmosphere/ Lib/ User/Build/ makefile Waves/Compilers/ Master/Data/ ROMS/

    I also have an Apps directory here for my applications.

  • ls ROMSAdjoint/ License_ROMS.txtBin/ Modules/ SeaIce/Drivers/ Nonlinear/ Tangent/External/ Obsolete/ Utility/Functionals/ Programs/ VersionInclude/ Representer/

  • Most ImportantDriversVarious model main programsNonlinearThe regular ocean physics (forward model)ModulesOcean model data types, with allocation and initialization routinesUtilityFile reading and writing routines and other files common to the various models

  • SupportIncludeInclude files, including cppdefs.hBinPerl and shell scriptsCompilersSystem-dependent parts of the makefileLibARPACK and MCT libraries (optional)ExternalASCII input files

  • OtherData AssimilationAdjointRepresenterTangentSeaIceFunctionalsAnalytic expressions for initial conditions, etc.ObsoletePrograms

  • 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.hIncluded by ocean_control.FContains initialize, run, finalize for the nonlinear ocean modelRun calls main3d or main2d inside the timestepping loopCalls get_data which reads files now or handles the coupling in CCSMMany, many other include files for the other models

  • ROMS/TOMS:MODULAR DESIGN

  • cppThe C preprocessor, cpp, comes with some C compilers, or the functionality can be built into a C compilerVery simple macro processorUsed in ROMS primarily for conditional compilationWe probably wont switch to coco when it becomes widely available

  • cpp VersionsPeople started using the C preprocessor before there was a C standard - the Standard cpp isnt quite the version we wantGnu cpp -traditional does the right thing for Fortran

  • File InclusionIn Fortran, you can include files with: include file.hIn cpp, the equivalent is: #include file.hWe use the cpp version to make sure the #defines in the include files are seen

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

  • More on MacrosAnother type of macro substitution is like statement functions in FortranStatement functions and the more modern inlined functions are better because the compiler can do type checking

  • Logical MacrosA third kind of macro is something like: #define MASKINGor #define MASKING 1These 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 CompilationROMS uses conditional code everywhere. #ifdef ICE ! Stuff having to do with sea ice #endifIf you want to find out about (say) sediment code, do a search on SEDIMENT

  • More on ConditionalsWhen setting up a problem of your own, its best to surround code you add with a unique cpp flag: #define LOMBOK_STRAIT : #ifdef LOMBOK_STRAIT ! My code #endif

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

  • cppdefs.hEvery ROMS source file starts with: #include cppdefs.hThis file has been changed to contain#if defined ROMS_HEADER# include ROMS_HEADER#endifThe ROMS_HEADER variable comes from the makefile now

  • ModulesThe model variables are stored in Fortran 90 modules defining specific typesYou no longer have to modify mod_param.F for your domainLets look at a few

  • Input fileROMS has an ascii input file which it reads during initializationThe file is not a namelist, but similar in intentIt specifies things like:Number of timestepsNumber of gridpoints (Lm, Mm, N)Parallel grid partitioningOther input filenames, output optionsMany others

    4