Git Product home page Git Product logo

ecrad's Introduction

ECRAD - ECMWF atmospheric radiation scheme

This document last updated 9 June 2022

Robin Hogan [email protected]

For more complete information about compilation and usage of ecRad, please see the documentation on the ecRad web site.

INTRODUCTION

This package contains the offline version of a radiation scheme suitable for use in atmospheric weather and climate models. The code is designed to be extensible and flexible. For example, the gas optics, cloud optics and solver are completely separated (see radiation/radiation_interface.F90 where they are called in sequence), thereby facilitating future changes where different gas models or solvers may be switched in and out independently. The offline code is parallelized using OpenMP.

Five solvers are currently available:

  1. The Monte Carlo Independent Column Approximation (McICA) of Pincus et al. (2003). This is is a now widely used method for treating cloud structure efficiently. The implementation in this package is more efficient than the one currently operational in the ECMWF model, and produces less noise in partially cloudy situations. Note that since McICA is stocastic, individual flux profiles using McICA may differ simply due to random variations in the sampling of the cloud field.

  2. The Tripleclouds scheme of Shonk and Hogan (2008). This represents cloud structure by dividing each layer into three regions, one clear and two cloudy with different optical depth. It is somewhat slower than McICA but does not generate noise.

  3. The Speedy Algorithm for Radiative Transfer through Cloud Sides (SPARTACUS) of Hogan et al. (JGR 2016). This is a method for efficiently treating 3D radiative effects associated with clouds. It uses the same differential equations proposed by Hogan and Shonk (JAS 2013), but solves them using a matrix exponential method that is much more elegant than their method, and is also here extended to the longwave (see Schaefer et al., JGR 2016). It also incorporates the Tripleclouds methodology of Shonk and Hogan (2008) to represent cloud inhomogeneity.

  4. A homogeneous (plane parallel) solver in which clouds are assumed to fill the gridbox horizontally. This is useful for computing Independent Column Approximation benchmarks.

  5. A "cloudless" solver if your focus is on clear skies.

Two gas optics models are available:

  1. The Rapid Radiative Transfer Model for GCMs (RRTMG), the implementation being that from the ECMWF Integrated Forecasting System (IFS).

  2. The ECMWF Correlated k-Distribution (ecCKD) scheme (since ecRad 1.5), which uses a flexible discretization of the spectrum that is read from a file at run-time.

PACKAGE OVERVIEW

The subdirectories are as follows:

  • radiation - the ecRad souce code

  • ifsaux - source code providing a (sometimes dummy) IFS environment

  • ifsrrtm - the IFS implementation of the RRTMG gas optics scheme

  • utilities - source code for useful utilities, such as reading netCDF files

  • drhook - dummy version of the Dr Hook profiling system

  • driver - the source code for the offline driver program

  • ifs - slightly modified source files from the IFS that are used to provide inputs to ecRad, but not used in this offline version except if you compile the ecrad_ifs_driver executable

  • mod - where Fortran module files are written

  • lib - where the static libraries are written

  • bin - where the executable ecrad is written

  • data - contains configuration data read at run-time

  • test - test cases including Matlab code to plot the outputs

  • include - automatically generated interface blocks for non-module routines

  • practical - exercises to get started with ecRad

TO COMPILE

  1. Ensure you have a reasonably recent Fortran compiler - it needs to support modules with contains and procedure statements for example. Ensure you have the Fortran netCDF library installed (versions 3 or 4) and that the module file is compatible with your Fortran compiler.

  2. You can compile the code using

    make PROFILE=<prof>
    

    where <prof> is one of gfortran, pgi, cray or intel. This will read the system-specific configurations from the file Makefile_include.<prof>. If you omit the PROFILE= option then gfortran will be assumed. If you have a compiler other than these then create such a file for your compiler following the example in Makefile_include.gfortran. Two additional profiles are provided, ecmwf which builds on the gfortran profile and uor (University of Reading) which is built on the pgi profile.

    If the compile is successful then static libraries should appear in the lib directory, and then the executable bin/ecrad.

  3. To clean-up, type make clean. To build an unoptimized version for debugging, you can do

    make PROFILE=<prof> DEBUG=1
    

    or you can specifically override the variables in Makefile_include.<prof> using, for example

    make PROFILE=<prof> OPTFLAGS=-O0 DEBUGFLAGS="-g -pg"
    

    To compile in single precision add SINGLE_PRECISION=1 to the make command line. To compile with the Dr Hook profiling system, first install ECMWF's [fiat library](ecRad web site, then add FIATDIR=/path/to/fiat to the make command line, such that the files $FIATDIR/lib/libfiat.so and $FIATDIR/module/fiat/yomhook.mod can be found at build time.

TO TEST

The offline driver is run via

ecrad <namelist.nam> <input_file.nc> <output_file.nc>

where the radiation scheme is configured using the Fortran namelist file <namelist.nam>, and the inputs and outputs are in netCDF format.

The practical directory contains a set of practical exercises to help new users become familiar with the capabilities of ecRad. Start by reading the instructions in practical/ecrad_practical.pdf.

The test/ifs directory contains a pole-to-pole slice of low-resolution IFS model data in a form to use as input to the offline version of ecRad. It includes aerosols extracted from the CAMS climatology used operationally since IFS Cycle 43R3. Typing make test in this directory runs a number of configurations of ecRad described in the Makefile. The Matlab script plot_ifs.m can be used to visualize the results. The file ecrad_meridian_default_out_REFERENCE.nc contains a reference version of the output file ecrad_meridian_default_out.nc (case "a"), which you can compare to be sure your compilation is working as expected. This case has essentially been superceded by the slice in the practical directory.

The test/i3rc directory contains the 1D profile of the I3RC cumulus test case used by Hogan et al. (2016). Typing make test in this directory runs the various 1D and 3D configurations of ecRad. The Matlab script plot_i3rc.m can then be used to visualize the results, reproducing three of the figures from Hogan et al. (2016). Note that you will need to ensure that a reasonably up-to-date version of the nco tools are available and in your path. This test involves running the duplicate_profiles.sh script, which duplicates the single profile in i3rc_mls_cumulus.nc, each with a different solar zenith angle.

The test/surface directory contains tests of the surface tile types, although this is under development and so nothing here is guaranteed to work.

Alternatively, type make test in the top-level directory to run all cases.

In addition to writing the output file, a file containing the intermediate radiative properties of the atmosphere for each g-point can be stored in radiative_properties.nc (edit the config namelist to enable this), but note that the g-points have been reordered in approximate order of optical depth if the SPARTACUS solver is chosen.

LICENCE

(C) Copyright 2014- ECMWF.

This software is licensed under the terms of the Apache Licence Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.

In applying this licence, ECMWF does not waive the privileges and immunities granted to it by virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. Copyright statements are given in the file NOTICE.

The ifsrrtm directory of this package includes a modified version of the gas optics part of the Rapid Radiative Transfer Model for GCMS (RRTMG). RRTMG was developed at Atmospheric & Environmental Research (AER), Inc., Lexington, Massachusetts and is available under the "3-clause BSD" license; for details, see ifsrrtm/AER-BSD3-LICENSE.

PUBLICATIONS

The ecRad radiation scheme itself is described here:

  • Hogan, R. J., and A. Bozzo, 2018: A flexible and efficient radiation scheme for the ECMWF model. J. Adv. Modeling Earth Syst., 10, 1990-2008, doi:10.1029/2018MS001364.

  • Hogan, R. J., and A. Bozzo, 2016: ECRAD: A new radiation scheme for the IFS. ECMWF Technical Memorandum number 787, 35pp: http://www.ecmwf.int/en/elibrary/16901-ecrad-new-radiation-scheme-ifs

A two-part paper is published in Journal of Geophysics Research describing the SPARTACUS technique:

More recent developments on the shortwave SPARTACUS solver, available since ecRad 1.1.10, are described here:

  • Hogan, R. J., M. D. Fielding, H. W. Barker, N. Villefranque and S. A. K. Schäfer, 2019: Entrapment: An important mechanism to explain the shortwave 3D radiative effect of clouds. J. Atmos. Sci., 76, 2123–2141.

The ecCKD gas optics scheme is described here:

  • Hogan, R. J., and M. Matricardi, 2022: a tool for generating fast k-distribution gas-optics models for weather and climate applications. J. Adv. Modeling Earth Sys., in review.

CONTACT

Please email Robin Hogan [email protected] with any queries or bug fixes, but note that ECMWF does not commit to providing support to users of this software.

ecrad's People

Contributors

drieg avatar huppd avatar ioanhadade avatar lguez avatar reuterbal avatar rjhogan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ecrad's Issues

Crash using netcdf-fortran >=4.6

I recently recompiled ecrad using the latest netcdf fortran library (4.6.1), and noticed a new crash in a config that worked fine before:

*** Error defining variable pressure_hl: NetCDF: Name contains illegal characters
Error writing NetCDF file
Note: The following floating-point exceptions are signalling: IEEE_UNDERFLOW_FLAG IEEE_DENORMAL
ERROR STOP 1

Error termination. Backtrace:
#0  0x7f9c74223960 in ???
#1  0x7f9c742244d9 in ???
#2  0x7f9c74225bb2 in ???
#3  0x55cc96b506ed in __radiation_io_MOD_radiation_abort
        at ecrad/utilities/radiation_io.F90:52
#4  0x55cc96b4434e in __easy_netcdf_MOD_define_variable
        at ecrad/utilities/easy_netcdf.F90:2072
#5  0x55cc96a8a4a2 in __radiation_save_MOD_save_fluxes
        at ecrad/radiation/radiation_save.F90:156
#6  0x55cc96a4c368 in ecrad_driver
        at ecrad/driver/ecrad_driver.F90:376
#7  0x55cc96a4a738 in main
        at ecrad/driver/ecrad_driver.F90:33

After some investigation, I can confirm that the command used to obtain this error ../bin/ecrad conf.nam nc1.nc nc_out.nc works fine with version 4.5.4, but doesn't work with 4.6.0 and 4.6.1.

Crash in setup_general_cloud_optics

Hello. We have a crash when we run ECRad, at line 183 of file radiation_general_cloud_optics_data.F90:

this%ssa       = matmul(mapping, mass_ext*ssa) / this%mass_ext

with message:

0: forrtl: severe (408): fort: (8):
  Attempt to fetch from allocatable variable MASS_EXT when it is not allocated

The code was compiled with ifort 19.0.4. There is no problem when we compile with gfortran 11. I looked at the crash with a debugger and I suspect this is a compiler bug. Could you please tell us which compilers and versions you have successfully used with ECRad?

Infinite loop in radiation_aerosol_optics_data::get_line

In radiation_aerosol_optics_data::get_line, if str contains only blanks then the do while loop is endless: i_start_new == 0 and cycle repeats the same situation. I guess you meant exit instead of cycle. Note that str contains blanks for an empty description of aerosol types in the NetCDF file with optical properties.

Usage of PFRAC in rrtm_gas_optical_depth

Hi Robin,

PFRAC is used as intent(out) in all rrtm_taumol*.F90 routines. Following the Fortran standard that means that a compiler is free to delete all prior content on entry of this subroutine. I stumbled now upon the fact that a compiler was setting to NaN on entry in each rrtm_taumol* routine again overwriting the previous calculated values. From my understanding the intent must be inout in the rrtm_taumol* routines. This can, depending on the compiler and/or compiler options create hard to detect errors.

Cheerio,
Luis

Compilation errors in parallel builds

When compiling ecrad with multiple jobs (i.e. make -j 16), the compilation fails sometimes.

Test setup

The tests were conducted with gfortran v11.2.0 and multiple Intel compilers (ifort v2021.5.0, ifort v2021.10.0, ifx v2023.2.0). All tests used a version of NetCDF-Fortran v4.5.3 built with the respective compilers.
The following script was run:

for i in `seq 1 22`; do  
make [PROFILE=intel] -j $i |& tee make_${i}.log
make clean
done

Errors

Some compilation processes failed, usually for job counts >= 8. The error message was the following with gfortran:

radiation_spectral_definition.F90:972:9:

  972 |     use radiation_constants, only : SpeedOfLight, BoltzmannConstant, PlanckConstant
      |         1   
Fatal Error: Cannot open module file 'radiation_constants.mod' for reading at (1): No such file or directory
compilation terminated.

For the intel compilers, the error is similar:

radiation_spectral_definition.F90(972): error #7005: Error in reading the compiled module file.   [RADIATION_CONSTANTS]
    use radiation_constants, only : SpeedOfLight, BoltzmannConstant, PlanckConstant
--------^
radiation_spectral_definition.F90(982): error #6406: Conflicting attributes or multiple declaration of name.   [SPEEDOFLIGHT]
      freq = 100.0_jprd * real(SpeedOfLight,jprd) * real(wavenumber,jprd)
-------------------------------^
radiation_spectral_definition.F90(982): warning #7319: This argument's data type is incompatible with this intrinsic procedure; procedure assumed EXTERNAL.   [REAL]  
      freq = 100.0_jprd * real(SpeedOfLight,jprd) * real(wavenumber,jprd)
-------------------------------^
radiation_spectral_definition.F90(982): error #6404: This name does not have a type, and must have an explicit type.   [REAL]  
      freq = 100.0_jprd * real(SpeedOfLight,jprd) * real(wavenumber,jprd)
--------------------------^
radiation_spectral_definition.F90(982): warning #8889: Explicit interface or EXTERNAL declaration is required.   [REAL]
      freq = 100.0_jprd * real(SpeedOfLight,jprd) * real(wavenumber,jprd)
----------------------------------------------------^
radiation_spectral_definition.F90(982): error #7137: Any procedure referenced in a PURE procedure, including one referenced via a defined operation or assignment, must have an explicit interface and be declared PURE.   [REAL]  
      freq = 100.0_jprd * real(SpeedOfLight,jprd) * real(wavenumber,jprd)
[...]

Likely causes/solutions

Since this error only occurs in parallel builds, it seems that some prerequisites in the radiation Makefile were not set properly. A visualization of the dependencies with makefile2graph corroborates that assumption.
The compilation errors presented above were resolved by adding radiation_spectral_definition.o: radiation_constants.o.

That led to another missing prerequisite showing itself, namely for the radiation_aerosol_optics.o:

radiation_aerosol_optics.F90:497:9:

  497 |     use radiation_aerosol,             only : aerosol_type
      |         1
Fatal Error: Cannot open module file 'radiation_aerosol.mod' for reading at (1): No such file or directory
compilation terminated.

Adding the prerequisite radiation_aerosol_optics.o: radiation_aerosol.o to the Makefile solves that as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.