Skip to content

Commit

Permalink
Move makdep compilation to Makefile (#307)
Browse files Browse the repository at this point in the history
* Move makdep compilation to Makefile

* makdep compiled from a makdep rule in the Makefile
* Add CFLAG_HOST macro
* makdep is only compiled if needed
* This addresses #306

* Use $(DEPGEN) instead of makdep as target (Makefile)

* Update documentation
  • Loading branch information
phil-blain authored and apcraig committed Apr 30, 2019
1 parent f5da487 commit b0063cb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
12 changes: 12 additions & 0 deletions configuration/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ db_flags:
@echo "* .F.o := $(FC) -c $(FFLAGS) $(FIXEDFLAGS) $(INCS) $(INCLDIR)"
@echo "* .F90.o := $(FC) -c $(FFLAGS) $(FREEFLAGS) $(INCS) $(INCLDIR)"

#-------------------------------------------------------------------------------
# build rule for makdep: MACFILE, cmd-line, or env vars must provide
# the needed macros
#-------------------------------------------------------------------------------

ifndef $(CFLAGS_HOST)
CFLAGS_HOST :=
endif

$(DEPGEN): $(ICE_CASEDIR)/makdep.c
$(SCC) -o $@ $(CFLAGS_HOST) $<

#-------------------------------------------------------------------------------
# build rules: MACFILE, cmd-line, or env vars must provide the needed macros
#-------------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion configuration/scripts/cice.build
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ cat ${ICE_OBJDIR}/Filepath
echo " "

echo "building makdep"
cc -o makdep ${ICE_CASEDIR}/makdep.c || exit 2
${ICE_MACHINE_MAKE} \
-f ${ICE_CASEDIR}/Makefile MACFILE=${ICE_CASEDIR}/Macros.${ICE_MACHCOMP} makdep || exit 2

echo "building cice > ${ICE_OBJDIR}/${ICE_BLDLOG_FILE}"

Expand Down
14 changes: 13 additions & 1 deletion doc/source/user_guide/ug_running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ The CICE scripts are written to allow quick setup of cases and tests. Once a ca
generated, users can manually modify the namelist and other files to custom configure
the case. Several settings are available via scripts as well.

.. _overview:

Overview
~~~~~~~~

Expand Down Expand Up @@ -201,7 +203,7 @@ Once the cases are created, users are free to modify the cice.settings and ice_i
Porting
-------

To port, an **env.[machine]_[environment]** and **Macros.[machine]_[environment}** file have to be added to the
To port, an **env.[machine]_[environment]** and **Macros.[machine]_[environment]** file have to be added to the
**configuration/scripts/machines/** directory and the
**configuration/scripts/cice.batch.csh** file needs to be modified.
In general, the machine is specified in ``cice.setup`` with ``--mach``
Expand Down Expand Up @@ -229,6 +231,16 @@ directory back to **configuration/scripts/machines/** and update
the **configuration/scripts/cice.batch.csh** file, retest,
and then add and commit the updated machine files to the repository.

.. _cross_compiling:

Cross-compiling
~~~~~~~~~~~~~~~
It can happen that the model must be built on a platform and run on another, for example when the run environment is only available in a batch queue. The program **makdep** (see :ref:`overview`), however, is both compiled and run as part of the build process.

In order to support this, the Makefile uses a variable ``CFLAGS_HOST`` that can hold compiler flags specfic to the build machine for the compilation of makdep. If this feature is needed, add the variable ``CFLAGS_HOST`` to the **Macros.[machine]_[environment]** file. For example : ::

CFLAGS_HOST = -xHost

.. _account:

Machine Account Settings
Expand Down

0 comments on commit b0063cb

Please sign in to comment.