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.

kerrrobt

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 (netcdf.inc 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-4.4.1.1.tar.gz 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/netcdf.inc
Please check this installation of NetCDF and re-run this configure script”

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

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

Robert M. Kerr email: Robert.Kerr@warwick.ac.uk
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
 
Hi,
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: Robert.Kerr@warwick.ac.uk
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 MIGHT BE THE PROBLEM

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 \
-I$(NETCDF)/include

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)
TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/9l/82bvpll95kl365_jsccc4yr40000gn/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.Mv0QF1KzcQ/Render
TERM_PROGRAM_VERSION=421.2
OLDPWD=/Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES/netcdf-4.1.3
TERM_SESSION_ID=0997886F-D0C0-44A3-8EB2-1502DD6E376B
USER=kerrrobt
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.20KlW16oqZ/Listeners
PATH=/Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES/netcdf/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
PWD=/Users/kerrrobt/Build_WRFV4tcsh
EDITOR=vi
LANG=en_GB.UTF-8
XPC_FLAGS=0x0
PS1=\u\w:
XPC_SERVICE_NAME=0
SHLVL=2
HOME=/Users/kerrrobt
LOGNAME=kerrrobt
DISPLAY=/private/tmp/com.apple.launchd.JucyFQ02N4/org.macosforge.xquartz:0
SECURITYSESSIONID=186a7
_=/bin/tcsh
HOSTTYPE=unknown
VENDOR=apple
OSTYPE=darwin
MACHTYPE=x86_64
GROUP=staff
HOST=Roberts-Macintosh.local
DIR=/Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES
CC=gcc
CXX=g++
FC=gfortran
FCFLAGS=-m64
F77=gfortran
FFLAGS=-m64
JASPERLIB=/Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES/grib2/lib
JASPERINC=/Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES/grib2/include
LDFLAGS=-L/Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES/grib2/lib
CPPFLAGS=-I/Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES/grib2/include
NCARG_ROOT=/Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES/ncl_ncarg-6.6.2-MacOS_10.14_64bit_gnu730
NETCDF=/Users/kerrrobt/Build_WRFV4tcsh/LIBRARIES/netcdf
WRF_DIR=/Users/kerrrobt/Build_WRFV4tcsh/WRFV3real

configure.wps
# 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

FDEFS = -DUSE_JPEG2000 -DUSE_PNG

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

ARFLAGS =

PERL = perl

RANLIB = echo

WRF_DIR = ../WRFV3

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 \
-I$(NETCDF)/include

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
FDEFS = -DUSE_JPEG2000 -DUSE_PNG
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
FCSUFFIX =
FNGFLAGS = $(FFLAGS)
LDFLAGS =
CFLAGS =
CPP = /usr/bin/cpp -P -traditional
CPPFLAGS = -D_UNDERSCORE -DBYTESWAP -DIO_NETCDF -DBIT32 -DMACOS -DNO_SIGNAL
ARFLAGS =
RANLIB = ranlib
CC_TOOLS =

########################################################################################################################
#
# 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

.IGNORE:
.SUFFIXES: .c .f .F .o

# There is probably no reason to modify these rules

.c.o:
$(RM) $@
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<

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

.F.o:
$(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.
 
Hi,
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):
http://www2.mmm.ucar.edu/wrf/users/docs/user_guide_v4/v4.1/contents.html

Online Tutorial: http://www2.mmm.ucar.edu/wrf/OnLineTutorial/index.php

Compilation Tutorial: http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php

Presentations from our WRF tutorial: http://www2.mmm.ucar.edu/wrf/users/tutorial/tutorial_presentation_summer_2019.htm

Technical Note: http://www2.mmm.ucar.edu/wrf/users/docs/technote/contents.html

Best Practice for Namelists (helps you to make good decisions when setting up your domain and namelist settings:
WPS: http://www2.mmm.ucar.edu/wrf/users/namelist_best_prac_wps.html
WRFV3: http://www2.mmm.ucar.edu/wrf/users/namelist_best_prac_wrf.html

(and for other information on downloading, etc. you can see) WRF Users’ Home Page: http://www.mmm.ucar.edu/wrf/users/
 
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: http://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php#STEP1

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.

./geogrid.exe
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:
Code:
geog_data_res = '10m', '2m'
to
Code:
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:
Code:
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.
 
Top