diff --git a/WRF.md b/WRF.md index deedb45739053cb2bf184312ccc4bad1126e95d6..0daebf6e644b9db353735e22f84e99fa73b735f5 100644 --- a/WRF.md +++ b/WRF.md @@ -333,9 +333,64 @@ This means: 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. +For instance, in `dyn_em/module_initialize_ideal.F`: + +``` +#ifdef MTN + DO j=max(ys,jds),min(ye,jde-1) + DO i=max(xs,ids),min(xe,ide-1) + grid%ht(i,j) = mtn_ht * 0.25 * & + ( 1. + COS ( 2*pi/(xe-xs) * ( i-xs ) + pi ) ) * & + ( 1. + COS ( 2*pi/(ye-ys) * ( j-ys ) + pi ) ) + ENDDO + ENDDO +#endif +#ifdef EW_RIDGE + DO j=max(ys,jds),min(ye,jde-1) + DO i=ids,ide + grid%ht(i,j) = mtn_ht * 0.50 * & + ( 1. + COS ( 2*pi/(ye-ys) * ( j-ys ) + pi ) ) + ENDDO + ENDDO +#endif +#ifdef NS_RIDGE + DO j=jds,jde + DO i=max(xs,ids),min(xe,ide-1) + grid%ht(i,j) = mtn_ht * 0.50 * & + ( 1. + COS ( 2*pi/(xe-xs) * ( i-xs ) + pi ) ) + ENDDO + ENDDO +#endif +#ifdef NS_VALLEY + DO i=ids,ide + DO j=jds,jde + grid%ht(i,j) = mtn_ht + ENDDO + ENDDO + xs=ids !-1 + xe=xs + 20000./config_flags%dx + DO j=jds,jde + DO i=max(xs,ids),min(xe,ide-1) + grid%ht(i,j) = mtn_ht - mtn_ht * 0.50 * & + ( 1. + COS ( 2*pi/(xe-xs) * ( i-xs ) + pi ) ) + ENDDO + ENDDO +#endif +``` + To control conditional compilation: 1. Search for the variable `ARCHFLAGS` in `configure.wrf` 2. Add the desired define statement at the bottom +``` +ARCHFLAGS = $(COREDEFS) -DIWORDSIZE=$(IWORDSIZE) -DDWORDSIZE=$(DWORDSIZE) -DRWORDSIZE=$(RWORDSIZE) -DLWORDSIZE=$(LWORDSIZE) \ + $(ARCH_LOCAL) \ + $(DA_ARCHFLAGS) \ + -DDM_PARALLEL \ +... + -DNMM_NEST=$(WRF_NMM_NEST) \ + -DNS_VALLEY + +``` ## Customizing model output