Skip to content

Commit b8e61d6

Browse files
committed
Initial import (fingers crossed)
git-svn-id: https://cvmix.googlecode.com/svn/trunk@2 ec264166-b127-864d-6cb2-e100125a5c76
1 parent 12cba08 commit b8e61d6

16 files changed

+1474
-0
lines changed

README

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Right now, the stand-alone driver isn't very powerful. It is set up to run
2+
Bryan-Lewis mixing on a single column, and output the diffusivity coefficients
3+
at each level. Obviously this program will grow as we develop CVMix, but it
4+
seems like a good starting point.
5+
6+
Directory structure:
7+
8+
bld/ -- Contains the Makefile, is also where the build process will store .o
9+
and .mod files.
10+
11+
doc/ -- Contains documentation. At this point, it only has a PDF of the latest
12+
protex in-code notes.
13+
14+
exe/ -- Where the Makefile will put the vmix executable, also contains two
15+
namelists that can be used to recreate Fig. 3.1 in Steve's notes.
16+
17+
src/ -- Contains the source code. Right now it just contains the driver and
18+
the subdirectory shared/, which is all the modules that are needed
19+
to use CVMix with an outside model. (At some point, src/shared/ will
20+
be picked up as an svn:external for POP and, I assume, MPAS and MOM.
21+
22+
ncl/ -- Will eventually contain NCL scripts for making various plots depending
23+
on the namelist settings. At this point, it contains one script for
24+
generating the comparison of two Bryan-Lewis parameter sets. To use
25+
right now, you need to run
26+
27+
exe/] $ vmix < low_lat.ncl > diff1.txt
28+
exe/] $ vmix < high_lat.ncl > diff2.txt
29+
ncl/] $ ncl make_diff_plot-BryanLewis.ncl
30+
31+
reg_tests/ -- This is a place-holder, but at some point we will want to create
32+
a suite of regression tests to ensure everything in CVMix is
33+
functioning correctly.
34+
35+
INSTALLATION NOTES:
36+
37+
The bld directory contains a Makefile and a 'setup' utility. bld/setup is a
38+
python script that asks for compiler / netcdf information (it only needs to
39+
be run once, info is saved in bld/.CVMix_env). If you just run 'make' without
40+
.CVMix_env, then setup will run automatically.
41+
42+
To build with netcdf, run 'make netcdf' instead of just 'make'.

bld/Makefile

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
.SUFFIXES: .F90 .o
2+
3+
extension = .F90
4+
5+
# Name of executable
6+
EXE = ../exe/cvmix
7+
# File containing information about compiler and netCDF (generated by ./setup)
8+
ENV_FILE = .CVMix_env
9+
# File containing information about whether or not the last build linked to
10+
# netCDF (see below for more details)
11+
INFO_FILE = .netcdf_info
12+
13+
COMPILE_FLAGS = -cpp -O2
14+
LINKING_FLAGS =
15+
16+
# The variables FC, NETCDF_INC, NETCDF_LIB, and NETCDF_LINK are read in from
17+
# CVMix_env. If the file doesn't exist, then the python script "setup" is run
18+
# to generate the file.
19+
ifeq ($(wildcard $(ENV_FILE)),)
20+
tmp := $(shell ./setup >&2)
21+
endif
22+
include $(ENV_FILE)
23+
24+
# If you build without netCDF and then decide you want to build with netCDF (or
25+
# vice versa), you need to clean the old object files. The way this is handled
26+
# is by storing whether the last compilation used netCDF or not in the hidden
27+
# file .netcdf_info; whether the current built is using netCDF or not is stored
28+
# in the variable NEW_NETCDF while the contents of .netcdf_info is stored in the
29+
# variable OLD_NETCDF. The target "check" compares these two variables and runs
30+
# make clean if they differ. If the file doesn't exist, the two variables are
31+
# equal.
32+
ifdef USE_NETCDF
33+
COMPILE_FLAGS += -D_NETCDF -I$(NETCDF_INC)
34+
LINKING_FLAGS += -L$(NETCDF_LIB) -lnetcdf
35+
# Check for netcdf4 library
36+
ifneq ($(wildcard $(NETCDF_LIB)/libnetcdff.a),)
37+
LINKING_FLAGS += -lnetcdff
38+
endif
39+
NEW_NETCDF = YES
40+
else
41+
NEW_NETCDF = NO
42+
endif
43+
44+
ifneq ($(wildcard $(INFO_FILE)),)
45+
OLD_NETCDF = $(shell cat $(INFO_FILE))
46+
else
47+
OLD_NETCDF = $(NEW_NETCDF)
48+
endif
49+
50+
ifneq ($(OLD_NETCDF), $(NEW_NETCDF))
51+
REBUILD = TRUE
52+
endif
53+
54+
55+
# ORDER MATTERS UNTIL I SET UP DEPENDENCIES
56+
# Also, directories will change once we get a new repository
57+
F_FILES = ../src/shared/vmix_kinds_and_types.F90 \
58+
../src/shared/vmix_background.F90 \
59+
../src/shared/vmix_convection.F90 \
60+
../src/shared/vmix_put_get.F90 \
61+
../src/vmix_output.F90 \
62+
../src/vmix_driver.F90
63+
64+
O_FILES = $(subst shared/,,$(subst ../src/,,$(F_FILES:$(extension)=.o)))
65+
66+
### TARGETS ###
67+
68+
.PHONY: check
69+
70+
all: vmix
71+
72+
# Possible executables: with and without netCDF
73+
netcdf:
74+
$(MAKE) USE_NETCDF=TRUE
75+
76+
vmix: check $(O_FILES)
77+
$(FC) -o $(EXE) $(O_FILES) $(LINKING_FLAGS)
78+
$(shell echo $(NEW_NETCDF) > $(INFO_FILE))
79+
80+
# .o files -- until I can handle dependencies automatically, have to be specific
81+
vmix_kinds_and_types.o: ../src/shared/vmix_kinds_and_types.F90
82+
$(FC) $(COMPILE_FLAGS) -c $< -o $@
83+
84+
vmix_background.o: ../src/shared/vmix_background.F90 \
85+
../src/shared/vmix_kinds_and_types.F90
86+
$(FC) $(COMPILE_FLAGS) -c $< -o $@
87+
88+
vmix_convection.o: ../src/shared/vmix_convection.F90 \
89+
../src/shared/vmix_kinds_and_types.F90
90+
$(FC) $(COMPILE_FLAGS) -c $< -o $@
91+
92+
vmix_put_get.o: ../src/shared/vmix_put_get.F90 \
93+
../src/shared/vmix_kinds_and_types.F90
94+
$(FC) $(COMPILE_FLAGS) -c $< -o $@
95+
96+
vmix_output.o: ../src/vmix_output.F90 \
97+
../src/shared/vmix_kinds_and_types.F90
98+
$(FC) $(COMPILE_FLAGS) -c $< -o $@
99+
100+
vmix_driver.o: ../src/vmix_driver.F90 \
101+
../src/shared/vmix_kinds_and_types.F90 \
102+
../src/shared/vmix_background.F90 \
103+
../src/shared/vmix_convection.F90 \
104+
../src/shared/vmix_put_get.F90 \
105+
../src/vmix_output.F90
106+
$(FC) $(COMPILE_FLAGS) -c $< -o $@
107+
108+
# Utilities: check sees if we need to rebuild stand-alone components using
109+
# -D_NETCDF, clean is standard, distclean removes $ENV_FILE so you
110+
# will need to re-run setup
111+
check:
112+
$(if $(REBUILD), rm -f vmix_output.o vmix_driver.o)
113+
114+
clean:
115+
/bin/rm -rf $(EXE) $(INFO_FILE) *.mod *.o
116+
117+
distclean: clean
118+
/bin/rm -rf $(ENV_FILE)

bld/README

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
To build, run
2+
3+
$ make
4+
5+
If this is your first time building, you will be prompted for some basic setup (compiler, location of netcdf). These values are saved in the file CVMix_env if they need to be editted later, or you can run
6+
7+
$ ./setup
8+
9+
To run with netCDF support, use
10+
11+
$ make netcdf
12+
13+
or
14+
15+
$ make USE_NETCDF=[any non-empty string]

bld/setup

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python
2+
3+
# Allow tab completion
4+
try:
5+
import readline,glob
6+
except ImportError:
7+
print "Can not find readline or glob package, so tab-complete will not work"
8+
else:
9+
def complete(text, state):
10+
return(glob.glob(text+'*')+[None])[state]
11+
readline.set_completer_delims(' \t\n;')
12+
readline.parse_and_bind("tab: complete")
13+
readline.set_completer(complete)
14+
15+
# Print standard information about this tool
16+
print "This utility needs to be run before the included Makefile will"
17+
print "successfully compile CVMix. It collects information about your compiler"
18+
print "and associated libraries, and saves it in the .CVMix_env file. Note that"
19+
print "it only needs to be run once, though you should run it again if anything"
20+
print "changes.\n"
21+
22+
# For now, just need fortran compiler and netCDF location / flags
23+
compiler = raw_input('Fortran compiler (mpi not necessary): ')
24+
netcdf_dir = raw_input('Directory containing netcdf (enter "need_both" to enter netcdf include directory and netcdf lib directory separately): ')
25+
if netcdf_dir == "need_both":
26+
netcdf_inc = raw_input('netCDF/include location: ')
27+
netcdf_lib = raw_input('netCDF/include location: ')
28+
else:
29+
netcdf_inc = netcdf_dir+"/include"
30+
netcdf_lib = netcdf_dir+"/lib"
31+
32+
fid = open(".CVMix_env", 'w')
33+
fid.write("FC = " + compiler+"\n")
34+
fid.write("NETCDF_INC = " + netcdf_inc+"\n")
35+
fid.write("NETCDF_LIB = " + netcdf_lib+"\n")

doc/protex_documentation.pdf

199 KB
Binary file not shown.

exe/high_lat.nl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
&cvmix_nml
2+
mixing ='BryanLewis'
3+
nlev = 30
4+
ocn_depth = 5250
5+
/
6+
&BryanLewis_nml
7+
! Low latitude: 6.50e-5, 1.15e-4, 4.5e-3, 2500
8+
! High latitude: 7.50e-5, 0.95e-4, 4.5e-3, 2500
9+
! Orig BL paper: 8.00e-5, 1.05e-4, 4.5e-3, 2500
10+
!
11+
vdc1 = 7.50d-5
12+
vdc2 = 0.95d-4
13+
linv = 4.5d-3
14+
dpth = 2500.0d0
15+
/

exe/low_lat.nl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
&cvmix_nml
2+
mixing ='BryanLewis'
3+
nlev = 30
4+
ocn_depth = 5250
5+
/
6+
&BryanLewis_nml
7+
! Low latitude: 6.50e-5, 1.15e-4, 4.5e-3, 2500
8+
! High latitude: 7.50e-5, 0.95e-4, 4.5e-3, 2500
9+
! Orig BL paper: 8.00e-5, 1.05e-4, 4.5e-3, 2500
10+
!
11+
vdc1 = 6.50d-5
12+
vdc2 = 1.15d-4
13+
linv = 4.5d-3
14+
dpth = 2500.0d0
15+
/

ncl/make_diff_plot-BryanLewis.ncl

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
2+
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
3+
4+
begin
5+
6+
; Create Color Table
7+
my_color_map = (/"White", "Black"/)
8+
9+
nml = asciiread("../exe/low_lat.nl", -1, "integer")
10+
nlev = nml(0)
11+
datal = asciiread("../exe/diff1.txt", (/nlev+1,2/), "double")
12+
datah = asciiread("../exe/diff2.txt", (/nlev+1,2/), "double")
13+
14+
x = new((/2, nlev+1/), "double")
15+
x(0,:) = datal(:,1)
16+
x(1,:) = datah(:,1)
17+
18+
y = new(nlev+1, "double")
19+
y = datal(:,0)
20+
21+
; out_type = "ps"
22+
out_type = "X11"
23+
wks = gsn_open_wks(out_type, "Bryan-Lewis_CVMix")
24+
gsn_define_colormap(wks, my_color_map)
25+
26+
; Basic Graphics set up (don't draw / advance frame to add legend!)
27+
res = True
28+
res@gsnDraw = False
29+
res@gsnFrame = False
30+
31+
; line & marker styles / axes ranges (y decreases to bottom)
32+
res@xyMonoMarkLineMode = True
33+
res@xyMarkLineMode = "MarkLines"
34+
res@xyMarkers = (/0,4/)
35+
res@xyDashPatterns = (/0,0/)
36+
res@trXMinF = 0
37+
res@trXMaxF = 1.4
38+
res@trYMinF = 0
39+
res@trYMaxF = 5500
40+
res@trYReverse = True
41+
42+
; Plot / font size, tick marks
43+
res@vpHeightF = 0.55
44+
res@vpWidthF = 0.77
45+
res@tiMainFontHeightF = 0.02
46+
res@tiXAxisFontHeightF = 0.015
47+
res@tiYAxisFontHeightF = 0.015
48+
res@tmXBLabelFontHeightF = 0.015
49+
res@tmYLLabelFontHeightF = 0.015
50+
res@tmXBMinorOn = False
51+
res@tmYLMinorOn = False
52+
res@tmXBMajorOutwardLengthF = 0
53+
res@tmYLMajorOutwardLengthF = 0
54+
55+
; Title / axes labels
56+
res@tiMainString = "Background vertical tracer diffusivity"
57+
res@tiXAxisString = "Diffusivity (1e-4 m:S:2:N:/sec)"
58+
res@tiYAxisString = "Depth (m)"
59+
60+
plot = gsn_csm_xy(wks, 1e4*x, y, res)
61+
62+
; Legend
63+
lres = True
64+
lres@vpWidthF = 0.30
65+
lres@vpHeightF = 0.14
66+
lres@lgMonoItemType = True
67+
lres@lgItemType = "Markers"
68+
lres@lgAutoManage = False
69+
lres@lgLabelFontHeightF = 0.035
70+
lres@lgMonoMarkerIndex = False
71+
lres@lgMarkerIndexes = (/0, 4/)
72+
lres@lgLineLabelsOn = False
73+
74+
leg_text = (/"Low", "High"/)+" latitudes"
75+
legend = gsn_create_legend(wks, 2, leg_text, lres)
76+
77+
ares = True
78+
ares@amParallelPosF = 0.27
79+
ares@amOrthogonalPosF = -0.33
80+
annotate = gsn_add_annotation(plot, legend, ares)
81+
draw(plot)
82+
frame(wks)
83+
84+
end

old.tmp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Initial import (fingers crossed)
2+
3+
--This line, and those below, will be ignored--
4+
5+
A .

reg_tests/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
I think all the regression testing can be done via various namelist settings. I
2+
still need to figure out what, exactly, to test, and the best way to automate
3+
the process. This file will grow as more decisions are made.

0 commit comments

Comments
 (0)