Skip to content

Commit 329fbaf

Browse files
added fpp option to intel and gfortran cmake flag files, added if block comments to temporarily bypass OMP directives that cause some crashes with newer compilers.
1 parent a52c5c9 commit 329fbaf

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

cmake/compiler_flags_GNU_Fortran.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
####################################################################
1212

1313
if( HAVE_AUTOPROFILE )
14-
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -finstrument-functions")
14+
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -finstrument-functions -fpp")
1515
endif( )
1616

1717
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -D_REAL8_ -ffree-line-length-none")

cmake/compiler_flags_IntelLLVM_Fortran.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# FLAGS COMMON TO ALL BUILD TYPES
33
####################################################################
44

5-
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl" )
5+
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl -fpp" )
66

77
if( HAVE_AUTOPROFILE )
88
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -finstrument-functions" )

cmake/compiler_flags_Intel_Fortran.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# FLAGS COMMON TO ALL BUILD TYPES
1111
####################################################################
1212

13-
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl")
13+
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl -fpp")
1414

1515
if( HAVE_AUTOPROFILE )
1616
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -finstrument-functions")

src/CRTM_K_Matrix_Module.f90

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,12 @@ FUNCTION CRTM_K_Matrix( &
425425
CALL OMP_SET_MAX_ACTIVE_LEVELS(1)
426426
ELSE
427427

428-
n_profile_threads = n_Profiles !** e.g, NOMP = 8, n_profiles = 2 -> n_profile_threads = 2
428+
n_profile_threads = n_Profiles !** e.g, NOMP = 8, n_profiles = 2 -> n_profile_threads = 2
429+
!** BTJ: temporary preprocessor directive for openMP over channels bypass, permitting modern ifort / ifx versions to run properly
430+
!** https://github.com/JCSDA/CRTMv3/issues/231
431+
#if 1
432+
n_channel_threads=1
433+
#else
429434
!** if n_channels < (n_omp_threads-n_profile_threads), no need to use additional threads
430435
n_channel_threads = MIN(n_channels, MAX(1,n_omp_threads-n_profile_threads))
431436
IF (n_profile_threads + n_channel_threads > n_omp_threads) THEN
@@ -434,6 +439,7 @@ FUNCTION CRTM_K_Matrix( &
434439
n_profile_threads, n_channel_threads, n_omp_threads
435440
CALL Display_Message( ROUTINE_NAME, Message, Error_Status )
436441
END IF
442+
#endif
437443
if(n_channel_threads > 1) THEN
438444
CALL OMP_SET_MAX_ACTIVE_LEVELS(2)
439445
ELSE
@@ -923,12 +929,23 @@ FUNCTION profile_solution (m, Opt, AncillaryInput) RESULT( Error_Status )
923929
! ------------
924930
! THREAD LOOP
925931
! ------------
932+
!** BTJ preprocessor directive bypass of OMP directives causing issues when compiling with modern ifort/ifx
933+
!** https://github.com/JCSDA/CRTMv3/issues/231
934+
#if 1
935+
IF (n_channel_threads > 1) THEN
936+
WRITE( Message,'("ERROR: n_channel_threads > 1, this should not happen with the current preprocessor directives")')
937+
938+
Error_status = FAILURE
939+
CALL Display_Message( ROUTINE_NAME, Message, Error_Status )
940+
END IF
941+
#else
926942
!$OMP PARALLEL DO NUM_THREADS(n_channel_threads) &
927943
!$OMP FIRSTPRIVATE(ln, r_cloudy) &
928944
!$OMP PRIVATE(Message, ChannelIndex, n_Full_Streams, PVar, AAvar, &
929945
!$OMP start_ch, end_ch, Wavenumber, Status_FWD, Status_K, &
930946
!$OMP transmittance, transmittance_K, transmittance_clear, &
931947
!$OMP transmittance_clear_K, l, mth_Azi)
948+
#endif
932949
Thread_Loop: DO nt = 1, n_channel_threads
933950
start_ch = (nt - 1) * chunk_ch + 1
934951
IF ( nt == n_channel_threads) THEN
@@ -1681,8 +1698,12 @@ FUNCTION profile_solution (m, Opt, AncillaryInput) RESULT( Error_Status )
16811698
END IF
16821699

16831700
END DO Channel_Loop
1684-
END DO Thread_Loop
1701+
END DO Thread_Loop
1702+
!** BTJ preprocessor directive bypass of OMP directives causing issues when compiling with modern ifort/ifx
1703+
!** https://github.com/JCSDA/CRTMv3/issues/231
1704+
#if 0
16851705
!$OMP END PARALLEL DO
1706+
#endif
16861707
IF ( Error_Status == FAILURE ) RETURN
16871708
ln = ln + n_sensor_channels - n_inactive_channels(n_channel_threads)
16881709

0 commit comments

Comments
 (0)