Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust #defines to accommodate future CMake build #1910

Merged
merged 5 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions dyn_em/module_advect_em.F
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

!WRF:MODEL_LAYER:DYNAMICS
!
#if ( defined(ADVECT_KERNEL) )
#ifdef ADVECT_KERNEL
! cpp -traditional-cpp -P -DADVECT_KERNEL module_advect_em.F > advection_kernel.f90
! gfortran -ffree-form -ffree-line-length-none advection_kernel.f90
! ./a.out
Expand Down Expand Up @@ -111,7 +111,7 @@ SUBROUTINE column (loop , data_list, its,ite)

END SUBROUTINE column
!----------------------------------------------------------------
#elif ( ! defined(ADVECT_KERNEL) )
#else

MODULE module_advect_em

Expand Down Expand Up @@ -4357,7 +4357,7 @@ SUBROUTINE advect_scalar ( field, field_old, tendency, &
ENDIF vert_order_test

END SUBROUTINE advect_scalar
#if ( ! defined(ADVECT_KERNEL) )
#ifndef ADVECT_KERNEL

!---------------------------------------------------------------------------------

Expand Down Expand Up @@ -10543,7 +10543,7 @@ END SUBROUTINE advect_scalar_mono

!-----------------------------------------------------------

#if ( defined(ADVECT_KERNEL) )
#ifdef ADVECT_KERNEL

END MODULE advection_kernel
!================================================================
Expand Down Expand Up @@ -10851,7 +10851,7 @@ PROGRAM feeder

END PROGRAM feeder
#endif
#if ( !defined(ADVECT_KERNEL) )
#ifndef ADVECT_KERNEL

!---------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion external/atm_ocn/cmpcomm.F
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if defined( DM_PARALLEL )
#ifdef DM_PARALLEL
MODULE CMP_COMM

implicit none
Expand Down
6 changes: 3 additions & 3 deletions external/io_adios2/wrf_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,9 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 &

call LowerCase(MemoryOrder,MemOrd)
select case (MemOrd)

!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1))
! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1))))
! Cannot use following define due to gfortran cpp traditional mode concatenation limitations
!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1))
! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1))))
case ('xzy')
#undef DFIELD
#define DFIELD XField(1:di,XDEX(i,k,j))
Expand Down
4 changes: 2 additions & 2 deletions external/io_netcdf/wrf_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 &

call LowerCase(MemoryOrder,MemOrd)
select case (MemOrd)

! Cannot use following define due to gfortran cpp traditional mode concatenation limitations
!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1))
! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1))))

Expand Down Expand Up @@ -940,7 +940,7 @@ subroutine TransposeToR4(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 &

call LowerCase(MemoryOrder,MemOrd)
select case (MemOrd)

! Cannot use following define due to gfortran cpp traditional mode concatenation limitations
!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1))
! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1))))

Expand Down
4 changes: 2 additions & 2 deletions external/io_netcdfpar/wrf_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 &

call LowerCase(MemoryOrder,MemOrd)
select case (MemOrd)

! Cannot use following define due to gfortran cpp traditional mode concatenation limitations
!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1))
! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1))))

Expand Down Expand Up @@ -953,7 +953,7 @@ subroutine TransposeToR4a(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 &

call LowerCase(MemoryOrder,MemOrd)
select case (MemOrd)

! Cannot use following define due to gfortran cpp traditional mode concatenation limitations
!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1))
! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1))))

Expand Down
2 changes: 1 addition & 1 deletion external/io_pnetcdf/wrf_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ subroutine Transpose(IO,MemoryOrder,di, Field,l1,l2,m1,m2,n1,n2 &

call LowerCase(MemoryOrder,MemOrd)
select case (MemOrd)

! Cannot use following define due to gfortran cpp traditional mode concatenation limitations
!#define XDEX(A,B,C) A-A ## 1+1+(A ## 2-A ## 1+1)*((B-B ## 1)+(C-C ## 1)*(B ## 2-B ## 1+1))
! define(`XDEX',($1-``$1''1+1+(``$1''2-``$1''1+1)*(($2-``$2''1)+($3-``$3''1)*(``$2''2-``$2''1+1))))

Expand Down
4 changes: 3 additions & 1 deletion frame/module_configure.F
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ SUBROUTINE init_module_scalar_tables
END SUBROUTINE init_module_scalar_tables
END MODULE module_scalar_tables

#if( WRF_CHEM == 1 && WRF_KPP == 1 )
#ifdef WRF_CHEM
#ifdef WRF_KPP

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps hypothetically, but without duplicating the enclosed code, how would one transform the original directive here if it involved an or instead of and relationship? Inability to process logical expressions in #if directives might be an issue to raise with the CMake developers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be impossible, and the current guidance (from CMake developers) is to (1) switch to Ninja or (2) rewrite the code - both of which at times are nonstarters.

This is a huge annoyance that has been noted to the CMake developers in https://gitlab.kitware.com/cmake/cmake/-/issues/17398 (which coincidentally happens to be a derivative issue spawned from https://github.com/WRF-CMake/wrf that helped me find out this limitation).

There are a few instances in WRF already that run into this scenario, and the solution there is to do neither (1) or (2) but instead do traditional C preprocessing and generate an intermediate file. The makefile system already does this for everything; moving away from this to do native Fortran preprocessing through the respective compiler would be ideal.

As a middle ground compromise limiting two-step intermediate file C preprocessing to only those files which absolutely need it has been an okay solution.

MODULE module_irr_diag

INTEGER, parameter :: max_eqn = 1200
Expand Down Expand Up @@ -45,6 +46,7 @@ END SUBROUTINE init_module_irr_diag

END MODULE module_irr_diag
#endif
#endif

MODULE module_configure

Expand Down
5 changes: 5 additions & 0 deletions phys/module_mp_SBM_polar_radar.F
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ SUBROUTINE SBM_polar_radar
dummy = 1
END SUBROUTINE SBM_polar_radar
END MODULE module_mp_SBM_polar_radar

! Stub module
module scatt_tables
end module scatt_tables

#else
!******************
module scatt_tables
Expand Down
14 changes: 14 additions & 0 deletions phys/module_mp_fast_sbm.F
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ SUBROUTINE SBM_fast
dummy = 1
END SUBROUTINE SBM_fast
END MODULE module_mp_fast_sbm

! Stub modules
module module_mp_SBM_BreakUp
end module module_mp_SBM_BreakUp

module module_mp_SBM_Collision
end module module_mp_SBM_Collision

module module_mp_SBM_Auxiliary
end module module_mp_SBM_Auxiliary

module module_mp_SBM_Nucleation
end module module_mp_SBM_Nucleation

#else
! +-----------------------------------------------------------------------------+
! +-----------------------------------------------------------------------------+
Expand Down