Main menu



5 posts / 0 new
Last post

Dear CESM developers: Is there a guideline for how to compile runoff_to_ocn under cesm1_1_1/mapping/gen_mapping_files? The default set up is done for bluefire. I was wondering if I could use some helps. Any comments would be very much appreciated.


Hi there,

Before you can build, you need to do two things:

  1. Define a Macros file in the gen_mapping_files/runoff_to_ocn/src/ directory (see example below). The easiest way is to run $CCSMROOT/scripts/ccsm_utils/Machines /configure -mach [machine name] and then make a few changes
    1. Change the variables SCC, SCXX, and SFC to CC, CXX, and FC, respectively
    2. Add the variables CPP:= [your preprocessor... for intel, use fpp] and CPPFLAGS:= [preprocessor flags... for intel, use -p]
    3. Add -c argument to variables CFLAGS and FFLAGS
    4. Add the lines

      INCLDIR := -I$(NETCDF_PATH)/include
      SLIBS := -L$(NETCDF_PATH)/lib -lnetcdf -lblas -llapack

      to the bottom of the file (anywhere after where $NETCDF_PATH is defined)

  2. Make a file similar to runoff_to_ocn/build.bluefire.csh that uses your new Macros file instead of Macros.bluefire in line 23 (the gmake line)

Here is the text of the Macros file used on yellowstone in the upcoming CESM 1.2. Note that $(NETCDF) is already an environment variable so we skip setting $(NETCDF_PATH):

CC := mpicc
#CPP := /usr/bin/cpp
CPP := fpp
CFLAGS:= -c -O2
FC := ifort
FFLAGS := -c -O2 -assume byterecl -ftz -traceback
LD := $(FC)
AR := ar
INCLDIR := -I. -I$(NETCDF)/include
SLIBS := -L$(NETCDF)/lib -lnetcdf -L/glade/apps/opt/lib

ifeq ($(THREAD), TRUE) 
   LDFLAGS += -openmp 
   CFLAGS += -openmp 
   FFLAGS += -openmp 

ifeq ($(DEBUG), TRUE) 
   FFLAGS += -g -CU -check pointers -fpe0 -ftz 
   # SLIBS    += -lmass -lmassv -llapack -lblas
   SLIBS    += -llapack -lblas

edit (May 15, 2013): I forgot to add the -llapack and -lblas to SLIB in my example above. You may also need -L$(PATH_TO_BLAS) and -L$(PATH_TO_LAPACK)

Michael Levy

CESM Software Engineering Group (CSEG)

ML-417, x1748


Dear mlevy,

I appreciate your guidance, but I am still having trouble compiling the code. It appears the code has some errors, if I am not doing something wrong. Here are the errors that I have encountered.

1) map_mod.f90(2736): error #6222: This IMPLICIT statement is not positioned correctly within the scoping unit.

   implicit none

---> This was remedied by moving the "implicit none" to a proper position.

2) mapsort_mod.f90(352): error #6633: The type of the actual argument differs from the type of the dummy argument.   [S]

   call mapsort_qsortRC(map%s(n:m),map%row(n:m),map%col(n:m))


mapsort_mod.f90(566): error #6633: The type of the actual argument differs from the type of the dummy argument.   [S]

         call mapsort_QsortC(map%s(n:m),map%row(n:m),map%col(n:m))


mapsort_mod.f90(1012): error #6795: The target must be of the same type and kind type parameters as the pointer.   [S]

   S   => map%s

---> I do not know how to fix this error. I'd appreciate your input again.


Hi cyoo,


The version of the runoff_to_ocn executable distributed with CESM 1.1 and CESM 1.1.1 was tailored to a specific computer, and a lot of shortcuts were taken with regards to compiler flags and such. The version that will be released with CESM 1.2 is much more flexible - I've made it available on the web at

If you download the above tarball and replace the entire runoff_to_ocn/ directory with the version above, I believe the steps listed in my previous response will be sufficient for you. I tested this version on a machine here, and the only difference I found was that I needed to add "-lnetcdff" to the SLIBS as well:

SLIBS:= -L$(NETCDF_PATH)/lib -lnetcdf -lnetcdff

Michael Levy

CESM Software Engineering Group (CSEG)

ML-417, x1748


Thank you very much.

Log in or register to post comments

Who's new

  • ezhu@...
  • 1260680980@...
  • 675881908@...
  • liruichao@...
  • krc139@...