Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

Compiling in MacOS

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.


New member
Dear WRF-help,

I have been trying to install WRF on my Mac laptop running OS 10.14.6.

I am discovering that contrary to what is on the “Compile WRF” web site, it is necessary to do a 2 step installation of netcdf. First a netcdf-c. Then a netcdf-fortran. If seems that netcdf-c does not supply necessary elements ( and a .mod file) necessary for the fortran compile of WRF.

Not only for installation on MacOS laptops, but also for the CENTOS-LINUX/bash running on group’s cluster.

If this is well-known, then send me the link that explains this. And under the Compiling/Installation web page, list this MacOS/Linux problem as a topic.

I got to this point by first switching a window to /bin/tcsh.

Then largely following the steps in Compile WRF: wrf/OnlineTutorial/compilation_tutorial.php#STEP2.

Plus advice from my PhD student who attended the WRF teaching workshop in Boulder in 2017 and has WRF running on his MacOS laptop. His advice was to use netcdf-c- instead of netcdf-4.1.3.tar.gz . He just sent me links to the latest netcdf-c-4.4 and netcdf-fortran-4.4 downloads, with instructions to do them in that order. Our cluster guru says he found a blog telling him to do the equivalent.

Otherwise I get this:

“Error : Not found /Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES/netcdf/include/
Please check this installation of NetCDF and re-run this configure script”

In other words, WRF wants this file and netcdf-c-, does not produce it. netcdf-4.1.3 does produce it, but has other problems.

It would be better if netcdf-c-, had a new option that would allow this in one step

Robert M. Kerr email:
Professorship for Computational Fluid Dynamics, F-APS, F-IMA
School of Engineering, Dept of Mathematics and Centre for Scientific Computing
University of Warwick
Coventry CV4 7AL, United Kingdom
+44 (0)24 76 5 74840 Fax: 524182 Mes: 28312
Zeeman Building (Mathematics Institute): C2.15
Yes, the compiling web page assumes the installation of the complete package of NetCDF-C and NetCDF-Fortran as a combined unit, although it's acceptable to compile them separately as you and your student have done. I have tested the web page instructions very recently (a week or so ago) and they seem to work okay on my Mac laptop. Out of curiosity, what types of errors were you seeing when trying to use the combined NetCDF tar file?

Just to be certain, after your adjustments, were you able to successfully complete the installation of WRF?
I have successfully compiled WRFV3 for the em_b_wave case. I am using netcdf-4.1.3.tar.gz on your advice.

My NEW problem now is to get WPS, maps and analysis, to run.

My WRF problems were probably due to the faulty setenv with and extra “/“ I got from an error on their “Compile WRF” page, which is now corrected.

I finally generated the ideal.exe and wrf.exe for em_b_wave and they both ran.

I have also gotten em_real to compile.

However, its real.exe would not run. It needs some met_em files and it seems I need WPS to get these.

So I have tried to install WPS.

It won’t build geogrid.exe or metgrid.exe. Only ungrib.exe. It says I haven’t compiled WRF in WRFV3 (I have set WRF_DIR to ../WRFV3)

The "Compile WRF" page says:
The metgrid.exe and geogrid.exe programs rely on the WRF model's I/O libraries. There is a line in the configure.wps file that directs the WPS build system to the location of the I/O libraries from the WRF model:

I have compiled WRFV3 in 3 ways. Either just ./compile, ./compile em_b_wave, ./compile em_real. Same results in each case.

All the files requested below in $WRF_DIR/external are there.

I append my current env and configure.wps at the bottom.

Robert M. Kerr email:
Professorship for Computational Fluid Dynamics, F-APS, F-IMA
School of Engineering, Dept of Mathematics and Centre for Scientific Computing
University of Warwick
Coventry CV4 7AL, United Kingdom
+44 (0)24 76 5 74840 Fax: 524182 Mes: 28312


What my generated configure.wps says about WRF I/O is:
WRF_INCLUDE = -I$(WRF_DIR)/external/io_netcdf \
-I$(WRF_DIR)/external/io_grib_share \
-I$(WRF_DIR)/external/io_grib1 \
-I$(WRF_DIR)/external/io_int \
-I$(WRF_DIR)/inc \

WRF_LIB = -L$(WRF_DIR)/external/io_grib1 -lio_grib1 \
-L$(WRF_DIR)/external/io_grib_share -lio_grib_share \
-L$(WRF_DIR)/external/io_int -lwrfio_int \
-L$(WRF_DIR)/external/io_netcdf -lwrfio_nf \
-L$(NETCDF)/lib -lnetcdff -lnetcdf

PERHAPS the short-cut to getting this in Tim Sit's env is these two lines:

LDFLAGS=-L/Users/timothysit/WRF/LIBRARIES/grib2/lib -L/Users/timothysit/WRF/LIBRARIES/netcdf/lib
CPPFLAGS=-I/Users/timothysit/WRF/LIBRARIES/grib2/include -I/Users/timothysit/WRF/LIBRARIES/netcdf/include

He also includes: NETCDFF=/Users/timothysit/WRF/LIBRARIES/netcdf

I do not know how to set this up. I have only the first link in each line.

env (14:00 GMT 16 August 2019)

# configure.wps
# This file was automatically generated by the configure script in the
# top level directory. You may make changes to the settings in this
# file but be aware they will be overwritten each time you run configure.
# Ordinarily, it is necessary to run configure once, when the code is
# first installed.
# To permanently change options, change the settings for your platform
# in the file arch/configure.defaults, the preamble, and the postamble -
# then rerun configure.

.SUFFIXES: .F .f .c .o

SHELL = /bin/sh

NCARG_LIBS = -L$(NCARG_ROOT)/lib -lncarg -lncarg_gks -lncarg_c \
-L/usr/X11R6/lib -lX11

NCARG_LIBS2 = # May be overridden by architecture specific value below


# Listing of options that are usually independent of machine type.
# When necessary, these are over-ridden by each architecture.


PERL = perl

RANLIB = echo


WRF_INCLUDE = -I$(WRF_DIR)/external/io_netcdf \
-I$(WRF_DIR)/external/io_grib_share \
-I$(WRF_DIR)/external/io_grib1 \
-I$(WRF_DIR)/external/io_int \
-I$(WRF_DIR)/inc \

WRF_LIB = -L$(WRF_DIR)/external/io_grib1 -lio_grib1 \
-L$(WRF_DIR)/external/io_grib_share -lio_grib_share \
-L$(WRF_DIR)/external/io_int -lwrfio_int \
-L$(WRF_DIR)/external/io_netcdf -lwrfio_nf \
-L$(NETCDF)/lib -lnetcdff -lnetcdf

#### Architecture specific settings ####

COMPRESSION_LIBS = # intentionally left blank, fill in COMPRESSION_LIBS below

COMPRESSION_INC = # intentionally left blank, fill in COMPRESSION_INC below

# Settings for Darwin Intel gfortran/gcc (serial)
COMPRESSION_LIBS = -L/Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES/grib2/lib -ljasper -lpng -lz
COMPRESSION_INC = -I/Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES/grib2/include
SFC = gfortran
SCC = gcc
DM_FC = mpif90
DM_CC = mpicc
FC = $(SFC)
CC = $(SCC)
LD = $(FC)
FFLAGS = -ffree-form -O -fconvert=big-endian -frecord-marker=4
F77FLAGS = -ffixed-form -O -fconvert=big-endian -frecord-marker=4
CPP = /usr/bin/cpp -P -traditional
RANLIB = ranlib

# Macros, these should be generic for all machines

LN = ln -sf
MAKE = make -i -r
RM = /bin/rm -f
CP = /bin/cp
AR = ar ru

.SUFFIXES: .c .f .F .o

# There is probably no reason to modify these rules

$(RM) $@
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<

$(RM) $@ $*.mod
$(FC) $(F77FLAGS) -c $< $(WRF_INCLUDE)

$(RM) $@ $*.mod
$(CPP) $(CPPFLAGS) $(FDEFS) $(WRF_INCLUDE) $< > $*.f90
$(FC) $(FFLAGS) -c $*.f90 $(WRF_INCLUDE)
# $(RM) $*.f90
WPS is now installed on my MacOS system.

First I found that by doing ./compile for WRF (in WRFV3) and with setenv WRF_DIR /Users/../WRFV3, I did not generate metgrid.exe and geogrid.exe, only ungrib.exe

However, by doing this WRF command: ./compile em_real (etc), leaving that in the WRFV3 directory that I untamed and using setenv WRF_DIR /Users/../WRFV3 I get metgrid.exe and geogrid.exe.

My guess is that one must compile a real WRF case to generate the I/O libraries in WRF_DIR that WPS needs. It would be useful if this was documented.
I'm glad to hear that you were able to overcome the problem. I'm not sure what source you are using to follow for the process of installation, or learning to run WRF, but there is a lot of useful documentation out there that actually does mention that you need to use "./compile em_case" (e.g., ./compile em_real) in order to compile WRF. Take a look at some of these:

WRF Users' Guide (see chapter 2 for WRF Installation):

Online Tutorial:

Compilation Tutorial:

Presentations from our WRF tutorial:

Technical Note:

Best Practice for Namelists (helps you to make good decisions when setting up your domain and namelist settings:

(and for other information on downloading, etc. you can see) WRF Users’ Home Page:
Dear WRF,

I have reached a point in installing WPS and WRF (V3 for both) on my Mac laptop where everything seems to be working.

Setting up the environment under tcsh on a Mac has been a bit of a nightmare. What is given at:

is nothing more than crude guide. Particularly correctly getting LDFLAGS and CPPFLAGS and there is no mention of defining NETCDFF

What I need now is a test case for which I can get all the maps and other material off the internet. I have downloaded geog_high_res_mandatory.tar.gz

And I am now looking at the JAN00 test and downloaded JAN00_GFS_FNL.tar.gz

This is what I have gotten.

Parsed 25 entries in GEOGRID.TBL
Processing domain 1 of 1
ERROR: Could not open ../WPS_GEOG/soiltype_top_2m/index

There is no such directory in the WPS_GEOG I downloaded. Only: soiltype_top_30s

I can go no further without being given a namelist file that can accommodate soiltype_top_30s. Or told where I can download soiltype_top_2m.

I cannot find anything like this in the links you provided in your August 19 reply.

Thanks for your help.

Robert Kerr
University of Warwick, UK
Yes, the installation process for libraries can differ between different computing platforms, operating systems, versions, etc. While we support the WRF model (and WPS), we do not develop the specific libraries that must also be installed, and therefore we do not have the resources to support them, nor to troubleshoot problems encountered regarding those libraries. We attempt being helpful by going out of our area of responsibility to provide generic instructions that typically will help users to install the libraries and set the environment variables, via the website we created. Unfortunately there are outlier cases in which the instructions we provide may not be sufficient.

As for the problem you are seeing: I assume that you must be using a version of WRF older than V3.8. Beginning with V3.8, in the namelist.wps file, we changed the line:
geog_data_res = '10m', '2m'
geog_data_res = 'default', 'default'

This new option ensures that the user is using the highest available resolution of static data for each domain. With this change, the GEOGRID.TBL was also modified to be able to interpret this. Your options are:
1) modify that line to:
geog_data_res = '30s', '30s'

2) If you want to use lower-resolution data, specific to V3, from the 'Static Data Downloads' page, near the top (above the first table), you should see: "*To access the old (Version 3) downloads page, click here."
Click there to access the older data. You can click on each individual type of data to download, and unpack and place them in your WPS_GEOG/ directory.