Skip to content

Replace "derf()" with standard "erf()" in SBM MP scheme#1183

Merged
kkeene44 merged 6 commits intowrf-model:release-v4.2.1from
kkeene44:pgi_compile_fix
Jul 10, 2020
Merged

Replace "derf()" with standard "erf()" in SBM MP scheme#1183
kkeene44 merged 6 commits intowrf-model:release-v4.2.1from
kkeene44:pgi_compile_fix

Conversation

@kkeene44
Copy link
Collaborator

@kkeene44 kkeene44 commented Apr 27, 2020

TYPE: bug fix

KEYWORDS: PGI, compile, mp_SBM_polar_radar, phys, erf, derf

SOURCE: Bart Brashers (Ramboll)

DESCRIPTION OF CHANGES: A fortran function (DErF) was being used in the module_mp_SBM_polar_radar file. This was causing a compiling fail for PGI (tested with versions
19.10.0 on user's machine and 19.3 on Cheyenne). According to this article:
https://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/DErF-Intrinsic.html
the DErF function is archaic. Modifying this function to ErF corrects the problem and allows the
PGI compiler to build the WRF executable from source.

LIST OF MODIFIED FILES:
M phys/module_mp_SBM_polar_radar.F

TESTS CONDUCTED:

  1. Verified that code does not compile in original state, but does with the modified code when
    using the PGI compiler.
  2. Reggie should be OK.

RELEASE NOTE: A minor modification has been introduced into the SBM Polar Radar microphysics code to allow the WRF code to build with PGI compilers. The nonstandard derf() intrinsic has been replaced by the 2008 standard compliant erf() intrinsic.

@kkeene44 kkeene44 removed request for a team, brankokosovic, domingom and pedro-jm April 27, 2020 21:53
@kkeene44 kkeene44 closed this Apr 27, 2020
@kkeene44
Copy link
Collaborator Author

I clearly did something wrong with my fork - 532 changed files. Will correct and submit a new PR.

@kkeene44 kkeene44 reopened this Apr 27, 2020
@kkeene44 kkeene44 closed this Apr 27, 2020
@davegill
Copy link
Contributor

Kelly,
Version dyslexia: v4.1.2 vs v4.2.1!

@kkeene44 kkeene44 reopened this Apr 27, 2020
@kkeene44 kkeene44 changed the base branch from release-v4.1.2 to release-v4.2.1 April 27, 2020 22:02
@kkeene44
Copy link
Collaborator Author

@davegill Good eye - thanks!!

@davegill
Copy link
Contributor

davegill commented Apr 27, 2020

@kkeene44 @weiwangncar @dudhia
Folks,
There are a few places where we have this "derf" used:

> find . -name \*.F -exec grep -iw derf {} \; -print
         t=derf((1.0d0-fract_volume_water)/fract_volume_water-0.2d0)
./phys/module_mp_SBM_polar_radar.F

!      real derf,derfc, erf_alt
./phys/module_mp_morr_two_moment_aero.F

      function derf(x)
      derf = y
      end function derf
#define ERF derf
      real(r8) derf,derfc, erf_alt
!++ag replace sg erf with hm derf pre 1.68
!               nact=nact+0.5*(1.-derf(x))*na(m)
!               nact=nact+0.5*(1.-derf(x))*na(m)  
!       write(*,*)'nact',nact,derf(x),na(m),m
./phys/module_cu_mskf.F

             dum1  = nanew1*0.5*(1.-derf(uu1)) ! activated number in kg-1 mode 1
             dum2  = nanew2*0.5*(1.-derf(uu2)) ! activated number in kg-1 mode 2
 real function DERF(X)
      DERF = Y
 end function DERF
./phys/module_mp_p3.F

   module procedure derf
!   subprograms: ERF, ERFC, and ERFCX (or DERF, DERFC, and DERFCX),
!                   Y=ERF(X)     (or   Y=DERF(X)),
FUNCTION DERF(X)
   real(rk) :: DERF
   CALL CALERF_r8(X, DERF, JINT)
END FUNCTION DERF
./phys/module_cam_error_function.F

   real(r8) derf
#define ERF derf
      real(r8) derf,derfc
      real(r8) function derf(x)
      derf = y
      end function derf
./phys/module_cam_mp_microp_aero.F

Clearly, every other place has been patched up with various local definitions of this gaussian.

The erf is an intrinsic from Fortran 2008 and on.
GNU ERF doc
There is no need to ever say derf (which is an extension). However, there is no need to put the letter d in front of a zillion functions in the physics directory: dsin, dcos, dexp, dlog, etc.

Due to precedent, I am OK with this being the only change made to the WRF source.

@dudhia
Copy link
Collaborator

dudhia commented Apr 28, 2020 via email

@davegill
Copy link
Contributor

@dudhia @kkeene44 @weiwangncar

Why has this only shown up now when it was also in some older schemes?

Jimy,
All of the other instances inside of WRF of the use of the "derf()" intrinsic function were essentially user-defined. The only raw "derf()" function is the single one that Kelly is modifying.

@dudhia
Copy link
Collaborator

dudhia commented Apr 28, 2020 via email

Copy link
Contributor

@davegill davegill left a comment

Choose a reason for hiding this comment

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

Approved

@davegill davegill changed the title PGI compiling bug fix for SBM Polar Radar Replace "derf()" with standard "erf()" in SBM MP scheme Jul 9, 2020
@davegill
Copy link
Contributor

davegill commented Jul 9, 2020

@nbald
Thanks for spotting the double PR.
I am closing #1246, but stealing the best parts of its commit message.

@kkeene44 kkeene44 merged commit 28b84b7 into wrf-model:release-v4.2.1 Jul 10, 2020
joshbenz1 pushed a commit to SJSU-CS-systems-group/WRF-SFIRE that referenced this pull request Mar 19, 2021
TYPE: bug fix

KEYWORDS: PGI, compile, mp_SBM_polar_radar, phys, erf, derf

SOURCE: Bart Brashers (Ramboll)

DESCRIPTION OF CHANGES: A fortran function (DErF) was being used in the module_mp_SBM_polar_radar file. This was causing a compiling fail for PGI (tested with versions
19.10.0 on user's machine and 19.3 on Cheyenne). According to this article:
https://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/DErF-Intrinsic.html
the DErF function is archaic. Modifying this function to ErF corrects the problem and allows the
PGI compiler to build the WRF executable from source.

LIST OF MODIFIED FILES:
M phys/module_mp_SBM_polar_radar.F

TESTS CONDUCTED:

Verified that code does not compile in original state, but does with the modified code when
using the PGI compiler.
Reggie should be OK.
RELEASE NOTE: A minor modification has been introduced into the SBM Polar Radar microphysics code to allow the WRF code to build with PGI compilers. The nonstandard derf() intrinsic has been replaced by the 2008 standard compliant erf() intrinsic.
joshbenz1 added a commit to SJSU-CS-systems-group/WRF-SFIRE that referenced this pull request Mar 19, 2021
Replace "derf()" with standard "erf()" in SBM MP scheme (wrf-model#1183)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants