How to organize custom bio code

Discussion on computers, ROMS installation and compiling

Moderators: arango, robertson

Post Reply
Message
Author
pmaccc
Posts: 74
Joined: Wed Oct 22, 2003 6:59 pm
Location: U. Wash., USA

How to organize custom bio code

#1 Unread post by pmaccc »

Dear ROMS-ulans,

I have some custom bio code based on fennel. In the past I have kept it all in ROMS/Nonlinear/Biology next to all the other bio code. However, I am updating everything to the latest ROMS revision, and would like to keep my edits out of the svn repo as much as possible. I have found this easy to do by making a separate git repo with my edited build_roms.sh and compiler files, but am not sure how to do this with the bio code.

I see in Modules/mod_biology.F the note:

Code: Select all

** Note that all the *.h files are located in ROMS/Nonlinear/Biology  **
** and included within  <...>  to allow the user to customize any of  **
** them in the project directory  while keeping the distributed code  **
** intact (check the build script for details).                       **
So my question is, how do I modify a statement like:

Code: Select all

# if defined BIO_FENNEL
#  include <fennel_mod.h>
to point to code that is not in Nonlinear/Biology?

Thanks,

Parker

User avatar
arango
Site Admin
Posts: 1368
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: How to organize custom bio code

#2 Unread post by arango »

Very easily, such capability has been available in ROMS since ever. See the test repository directory test/upwelling. Notice that there is a copy of fennel.h that overwrites the one in the distributed master code. Also, notice the following variable in build_roms.sh:

Code: Select all

export MY_ANALYTICAL_DIR=${MY_PROJECT_DIR}
which is used to overwrite the master version of the analytical and ecosystem include files. The C-preprocessing will take care of your customized version, which needs to be located in the project directory when compiling.

User avatar
wilkin
Posts: 922
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: How to organize custom bio code

#3 Unread post by wilkin »

The trick here is the angle bracket syntax for the #include in biology.F:

Code: Select all

# if defined BIO_FENNEL
#  include <fennel.h>
# elif defined ECOSIM
#  include <ecosim.h>
# elif defined HYPOXIA_SRM
#  include <hypoxia_srm.h>
which you also see in analytical.F:

Code: Select all

analytical.F:
#include "cppdefs.h"
..
#   include <ana_biology.h>
#   include <ana_btflux.h>
The angle brackets, e.g. #include <fennel.h> cause ROMS to a search a path for that file, starting with the directory defined by MY_ANALYTICAL_DIR and if it not found use the trunk version. The double quotes #include "cppdefs.h" always use the trunk.

One trick I use when updates to the trunk occur for these files I have modified locally, is to copy my customized file into the trunk, do an svn update on just that file, (resolve any conflicts), and then copy back to my project directory. The file now shows the updated svn version in the header. With svn it is hard to do any lasting damage, because you can always delete a file and run svn update to get back a clean version from the trunk.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

pmaccc
Posts: 74
Joined: Wed Oct 22, 2003 6:59 pm
Location: U. Wash., USA

Re: How to organize custom bio code

#4 Unread post by pmaccc »

Hernan and John, thanks so much for your answers - very helpful!

Post Reply