Version control is a necessary element in a large software project. It allows an institution to freeze stages in the development of code, in order to recreate prior states when required or desired, and to allow the easy coexistence of project components at varying levels of maturity. This document describes a version-controlled repository of the source code for FMS, the Flexible Modeling System.
CVS is the Concurrent Versions System, a set of tools for management of source codes with multiple users and developers distributed across a wide-area network. It is a central pillar of the open source community and is maintained by GNU. It is locally available at GFDL at /usr/local/bin/cvs.
I don't propose a detailed write-up of CVS here, but point you to a CVS reference manual by Per Cederqvist et al, and to the CVS support page, that describes CVS at various levels of detail. There is also a newsgroup of the CVS community at gnu.cvs.help, where I've found people to be generous with their time and expertise. There is also a manpage (type man cvs).
Useful features of CVS include:
The FMS repository has been set up at /home/fms/cvs. A document describing the design of the FMS repository is available at /net/vb/tex/reports/cvs.ps.
If this is the primary repository you will be using, you can make all cvs commands use it by setting the environment variable CVSROOT in your .cshrc:
% setenv CVSROOT /home/fms/cvs
External users need to use the client-server mechanism of cvs, called pserver:
% setenv CVSROOT :pserver:cvs@cvs.gfdl.gov:/home/fms/cvs % cvs login
This is password-protected, you will need to send mail to fms@gfdl.gov to get a password.
You can override the value of CVSROOT with When you check files out of the repository, you get a private copy
of the source tree. You will need to refer back to the repository only
when you need to update your working copy with updates that were
subsequently made to the repository.
Any user can point to the CVS repository and check out files. This
will check out the latest version of the files in the
mpp module into your directory
~/src/mpp. The dates on your checked out files will be
the dates they were checked in (so you can use Makefiles, etc).
If you've been working in the directory ~/src/mpp
and want to know if I've modified the repository, you use the cvs
status command. You can then decide if you actually want to
update any files, and issue cvs update on those.
The output of cvs status is rather verbose, so be
sure to pipe it to your pager (e.g more).
This updates your working directory with any updates to the
repository. If there are files that have been changed in the
repository, as well as by you to your working copy,
cvs will automatically attempt to merge the
changes. If unable to merge, it will report a conflict, and create a
merged file with highlighted conflicts for you to edit. Your working
copy is preserved with the string '.#' prepended to
the name.
By default cvs update updates from the latest
versions in the repository. Other files in the repository may be
identified by tag information, or by date, or by
revision number (all retrievable by cvs status). To
retrieve a non-default version with the tag tag, use:
This will check in a new version of mpp.F90 into
the repository. You will be prompted for information to be placed in
the version log. If you do not have write access to the repository
$CVSROOT/mpp the commit will fail.
The current FMS policy calls for write
access to be restricted to user fms. When you are
ready to commit changes, fms will temporarily assign
you write permission to certain relevant directories, and revoke the
permissions when you are done.
This will create an empty directory for you under CVS control.
Copy your source into this directory, and then inform CVS of your
additions.
Finally, commit your source back to the repository following the
normal commit instructions.
CVS modules (not be confused with f90 modules) are a convenient
way of creating sets of source that are to be used together. Modules
have been set up for each component of FMS, as well as for
experiments. An experiment is a source module that can be used
to run a particular FMS configuration, either a solo component model,
or a particular ensemble of component models coupled. For example:
When a module is checked out, you will see a message near the end:
(External users using the pserver mechanism will
not get the path_names file, since CVS does not permit
the server to run scripts on the client. They will need to checkout
bin/list_paths from $CVSROOT and run
it themselves in the current working directory).
The file path_names contains a list of the source
files that have been checked out. A Makefile to compile this FMS
configuration can be created using mkmf, a script for
analyzing source file dependencies, particularly for
f90, simply by typing:
You will probably need to set some additional mkmf flags, though.
The file path_names can also be useful if you want
to perform other actions (e.g grep) on the source.
The Makefile generated by mkmf can also be used to
create "tags" files that allow you easily to navigate the source
tree. (These editing tags are not to be confused with CVS tags).
The first form produces a file TAGS (used by
emacs) and the second form produces a file
tags (used by vi). Please consult your
editor's documentation for instructions on the use of editing tags.
Full FMS documentation is available from the FMS home
page. Documentation is also stored in the FMS repository and
will be checked out along with the source. If lines similar to the
following appear at the end of a checkout:
you can use this URL in your browser to get links to the
documentation specific to your experiment.
CVS commands
% mkdir -p ~/src # where your working copy sits.
% cd ~/src
% cvs checkout mpp
% cd ~/src/mpp
% ls -l
% cvs status mpp
% cvs diff mpp
% cvs update mpp
% cvs update -r tag mpp
See the documentation for more details, for checkout by date,
etc. Your original checkout could also have been controlled the same
way.
% emacs mpp.F90 #and hack away
% cvs commit mpp.F90
# these can only be executed by fms
% mkdir -p FMS/shared/mpp
% chmod 775 FMS/shared/mpp
Checkout the new directory.
% cvs checkout FMS/shared/mpp
% cd FMS/shared/mpp
% cp /net/vb/src/mpp/mpp*.F90 .
% cvs add *.F90
CVS modules
% cvs checkout fms_spectral_amip
will checkout an experiment coupling a spectral atmosphere to AMIP
datasets for ocean, ice and land. A list of the available modules can
be obtained by:
% cvs checkout -c
Compiling FMS
A list of the files you checked out is in the file path_names ...
% mkmf path_names
% make TAGS
% make tags
FMS documentation
Documentation on the files you checked out is accessible on the web at
file://localhost/tmp/FMS/path_names.html ...