Skip to content

Commit

Permalink
Push MARBL infrastructure from svn to git
Browse files Browse the repository at this point in the history
Source code coming in a later commit, hoping to maintain SVN revision history.
  • Loading branch information
mnlevy1981 committed Mar 18, 2016
1 parent 72264c9 commit 17f65fd
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.svn
**/.svn
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
===============================================================================
Tag Creator: mlevy
Developers: mlevy
Tag Date: 17 Mar 2016
Tag Name: MARBL/trunk_tags/MARBL0.0.0
Tag Summary: Initial commit of MARBL code that compiles on its own
===============================================================================
20 changes: 20 additions & 0 deletions bld-test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
SRC_DIR=../src
OBJ_DIR=../obj
LIB_DIR=../lib
INC_DIR=../include

COMP_ARGS=OBJ_DIR=$(OBJ_DIR) LIB_DIR=$(LIB_DIR) INC_DIR=$(INC_DIR) CPPDEFS="-DECOSYS_NT=27 -DZOOPLANKTON_CNT=1 -DAUTOTROPH_CNT=3 -DGRAZER_PREY_CNT=3"

all: intel

intel:
cd $(SRC_DIR) ; make FC=ifort FCFLAGS="-O2 -free -module $(OBJ_DIR) -cpp -nogen-interface -fp-model source" $(COMP_ARGS) LIB_NAME=$(LIB_DIR)/libmarbl-intel.a

pgi:
cd $(SRC_DIR) ; make FC=pgf90 FCFLAGS="-O2 -Mfree -module $(OBJ_DIR)" $(COMP_ARGS) LIB_NAME=$(LIB_DIR)/libmarbl-pgi.a

gnu:
cd $(SRC_DIR) ; make FC=gfortran FCFLAGS="-O2 -ffree-form -J $(OBJ_DIR) -cpp" $(COMP_ARGS) LIB_NAME=$(LIB_DIR)/libmarbl-gnu.a

clean:
rm -f $(OBJ_DIR)/* $(LIB_DIR)/* $(INC_DIR)/*
13 changes: 13 additions & 0 deletions bld-test/hobart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

build() {
compiler=$1
rm -f ../obj/* ../include/*
module purge
module load compiler/$compiler
make $compiler
}

build intel
build nag
build gnu
12 changes: 12 additions & 0 deletions bld-test/yellowstone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

build() {
compiler=$1
rm -f ../obj/* ../include/*
module purge
module load $compiler
make $compiler
}

build intel
build gnu
1 change: 1 addition & 0 deletions include/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.mod
1 change: 1 addition & 0 deletions lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.a
3 changes: 3 additions & 0 deletions obj/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.o
*.mod
*.d
82 changes: 82 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.SUFFIXES: .F90 .o
extension = .F90

SRC_DIR = .
OBJ_DIR = .
LIB_DIR = .
INC_DIR = .
FC = NONE

LIB_NAME = $(LIB_DIR)/libmarbl.a

# Dependency Generation
MAKE_DEP = $(SRC_DIR)/makedep.py
DEP_FILE = $(OBJ_DIR)/shared_deps.d

ifeq ($(FC),NONE)
NOFC = TRUE
endif

MODULES = $(shell ls *.F90)

# Some compilers produce ALL_UPPER_CASE.mod files
ifeq ($(UCASE),TRUE)
MODS_TMP = $(shell echo $(MODULES) | tr '[a-z]' '[A-Z]')
else
MODS_TMP = $(MODULES)
endif
ifneq ($(OBJ_DIR),$(INC_DIR))
INCS = $(addprefix $(INC_DIR)/,${MODS_TMP:.F90=.mod})
endif
MODS = $(addprefix $(OBJ_DIR)/,${MODS_TMP:.F90=.mod}) \
$(INCS)
OBJS = $(addprefix $(OBJ_DIR)/,${MODULES:.F90=.o})

ifeq ($(USE_DEPS),TRUE)
include $(DEP_FILE)
endif

### TARGETS ###

all: lib

# Create all object and module files
# Note that .mod files need to be copied to INC_DIR if OBJ_DIR != INC_DIR

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.F90
$(FC) $(FCFLAGS) $(CPPDEFS) -c $< -o $@

$(INC_DIR)/%.mod: $(OBJ_DIR)/%.mod
ifneq ($(INC_DIR),$(OBJ_DIR))
cp $< $@
endif

### Combine into library
$(LIB_NAME): $(OBJS)
ar -ru $(LIB_NAME) $(OBJS)

$(DEP_FILE): $(MAKE_DEP) $(SRC_DIR)/*.F90
$(MAKE_DEP) $(DEP_FILE) $(OBJ_DIR) $(SRC_DIR)
@echo "Generated dependencies!"

.PHONY: depends recurse check clean

# Shorthand for making dependency file
depends: $(DEP_FILE)

# Shorthand for making the library (and all .mod files)
lib: check depends
$(MAKE) -e -f $(SRC_DIR)/Makefile $(LIB_NAME) $(INCS) USE_DEPS=TRUE

# Make sure a Fortran compiler was specified (the Makefile for the stand-alone
# driver passes FC along with FCFLAGS, SRC_DIR, OBJ_DIR, LIB_DIR, and INC_DIR)
check:
@$(if $(NOFC), echo "ERROR: you must specify FC (and it is recommended that \
you specify FCFLAGS as"; echo "well)."; echo "NOTE: if you have checked \
out the stand-alone CVMix driver set then you should"; echo "run \"make \
lib\" from the src/ directory to use CVMix compile options."; exit 1)

# Remove library, object files, module files, and dependency file
clean:
/bin/rm -f $(LIB_NAME) $(OBJS) $(MODS) $(DEP_FILE)

69 changes: 69 additions & 0 deletions src/makedep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python

# usage: makedep.py $(DEP_FILE) $(OBJ_DIR) $(SRC_DIR) [$(SRC_DIR2)]

# Generate $DEP_FILE in $OBJ_DIR (arguments 1 and 2, respectively)
# Read in every file in $SRC_DIR and $SRC_DIR2 (arguments 3 and 4)
# Only depend on modules located in $SRC_DIR or $SRC_DIR2

import os, sys, re

try:
dep_file = sys.argv[1]
except:
dep_file = "depends.d"

try:
obj_dir = sys.argv[2]
except:
obj_dir = '.'

try:
src_dir = sys.argv[3]
except:
src_dir = '.'

try:
src_dir2 = sys.argv[4]
except:
src_dir2 = src_dir

try:
inc_dir = sys.argv[5]
files_in_inc_dir = os.listdir(inc_dir)
except:
inc_dir = 'NONE'

fout = open(dep_file, 'w')
files_in_src_dir = os.listdir(src_dir)
if src_dir != src_dir2:
files_in_src_dir.extend(os.listdir(src_dir2))

for src_file in files_in_src_dir:
file_name, file_ext = os.path.splitext(src_file)
if file_ext == '.F90':
try:
fin = open(src_dir+'/'+src_file,"r")
except:
fin = open(src_dir2+'/'+src_file,"r")
for line in fin:
if re.match('^ *[Uu][Ss][Ee]',line):
line_array = line.split()
# statements are usually "use module, only : subroutine"
# so we need to strip away the , to get the module name
file_used = line_array[1].split(',')[0]
if file_used+'.F90' in files_in_src_dir:
print file_name+'.o depends on '+file_used+'.o'
fout.write(obj_dir+'/'+file_name+'.o: '+obj_dir+'/'+file_used+'.o\n')
else:
if inc_dir != 'NONE':
if file_used+'.mod' in files_in_inc_dir:
print file_name+'.o depends on '+file_used+'.mod'
fout.write(obj_dir+'/'+file_name+'.o: '+inc_dir+'/'+file_used+'.mod\n')
else:
# Check for upper case
file_used = file_used.upper()
if file_used+'.mod' in files_in_inc_dir:
print file_name+'.o depends on '+file_used+'.mod'
fout.write(obj_dir+'/'+file_name+'.o: '+inc_dir+'/'+file_used+'.mod\n')
fin.close

0 comments on commit 17f65fd

Please sign in to comment.