Skip to content
Snippets Groups Projects
Commit dfabb37c authored by Stefano Serafin's avatar Stefano Serafin
Browse files

WRF.md, updated conditional compilation

parent 0cf3bffa
No related branches found
No related tags found
No related merge requests found
...@@ -355,7 +355,7 @@ then you have a problem, and there is no unique solution. Take a closer look at ...@@ -355,7 +355,7 @@ then you have a problem, and there is no unique solution. Take a closer look at
## Conditional compilation ## Conditional compilation
Most Fortran compilers allow passing the source code through a C preprocessor (CPP; sometimes also called the Fortran preprocessor, FPP) to allow for conditional compilation. In the C programming language, there are some directives that make it possible to compile selectively portions of the source code. Most Fortran compilers allow passing the source code through a C preprocessor (CPP; sometimes also called the Fortran preprocessor, FPP) to allow for conditional compilation. In the C programming language, there are some directives that make it possible to compile portions of the source code selectively.
In the WRF source code, Fortran files have an .F extension. cpp will parse these files and create corresponding .f90 files. The .f90 files will then be compiled by the Fortran compiler. In the WRF source code, Fortran files have an .F extension. cpp will parse these files and create corresponding .f90 files. The .f90 files will then be compiled by the Fortran compiler.
...@@ -363,7 +363,7 @@ This means: ...@@ -363,7 +363,7 @@ This means:
1. When editing the source code, always work on the .F files, otherwise changes will be lost on the next compilation. 1. When editing the source code, always work on the .F files, otherwise changes will be lost on the next compilation.
2. In the .F files, it is possible to include `#ifdef` and `#ifndef` directives for conditional compilation. 2. In the .F files, it is possible to include `#ifdef` and `#ifndef` directives for conditional compilation.
For instance, in `dyn_em/module_initialize_ideal.F`: For instance, in `dyn_em/module_initialize_ideal.F`, the following bits of code define the model orography for idealized large-eddy simulation runs. Four possibilities are given: `MTN`, `EW_RIDGE`, `NS_RIDGE`, and `NS_VALLEY`. If none is selected at compile time, none of these code lines is compiled and `grid%ht(i,j)` (the model orography) is set to 0:
``` ```
#ifdef MTN #ifdef MTN
...@@ -410,7 +410,7 @@ For instance, in `dyn_em/module_initialize_ideal.F`: ...@@ -410,7 +410,7 @@ For instance, in `dyn_em/module_initialize_ideal.F`:
To control conditional compilation: To control conditional compilation:
1. Search for the variable `ARCHFLAGS` in `configure.wrf` 1. Search for the variable `ARCHFLAGS` in `configure.wrf`
2. Add the desired define statement at the bottom 2. Add the desired define statement at the bottom. For instance, to selectively compile the `NS_VALLEY` block above, do the following:
``` ```
ARCHFLAGS = $(COREDEFS) -DIWORDSIZE=$(IWORDSIZE) -DDWORDSIZE=$(DWORDSIZE) -DRWORDSIZE=$(RWORDSIZE) -DLWORDSIZE=$(LWORDSIZE) \ ARCHFLAGS = $(COREDEFS) -DIWORDSIZE=$(IWORDSIZE) -DDWORDSIZE=$(DWORDSIZE) -DRWORDSIZE=$(RWORDSIZE) -DLWORDSIZE=$(LWORDSIZE) \
$(ARCH_LOCAL) \ $(ARCH_LOCAL) \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment