From 3557d207b5a465fcea30cf38570078ff8c17b0b3 Mon Sep 17 00:00:00 2001 From: dudhia Date: Wed, 6 Dec 2023 09:27:02 -0700 Subject: [PATCH 01/14] fix loop ranges for polar projection (#1919) TYPE: bug fix KEYWORDS: lat/long projection only, polar boundary condition, loop ranges in advect_w SOURCE: internal and Forum, see Issue #1916 for link DESCRIPTION OF CHANGES: Problem: Loop ranges in polar boundary condition inconsistent with set variables and regular code. Not sure if any effect, since it only affects w at poles. Solution: Change ranges from kte,kte to kts+1,kte+1 in advect_w ISSUE: For use when this PR closes an issue. Fixes #1916 LIST OF MODIFIED FILES: M dyn_em/module_advect_em.F TESTS CONDUCTED: Compile only (needs confirmation test to check if any effects). Jenkins PASSed RELEASE NOTE: Fixed loop range in advect_w for lat-long map projection. --- dyn_em/module_advect_em.F | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dyn_em/module_advect_em.F b/dyn_em/module_advect_em.F index ff03d1a695..62f4fafaa6 100644 --- a/dyn_em/module_advect_em.F +++ b/dyn_em/module_advect_em.F @@ -4620,14 +4620,14 @@ SUBROUTINE advect_w ( w, w_old, tendency, & ! (latitudes are as for u grid, longitudes are displaced) ! Therefore: flow is only from one side for points next to poles IF ( config_flags%polar .AND. (j == jds+1) ) THEN - DO k=kts,ktf + DO k=kts+1,ktf+1 DO i = i_start, i_end mrdy=msftx(i,j-1)*rdy ! see ADT eqn 46 dividing by my, 2nd term RHS tendency(i,k,j-1) = tendency(i,k,j-1) - mrdy*fqy(i,k,jp1) END DO END DO ELSE IF( config_flags%polar .AND. (j == jde) ) THEN - DO k=kts,ktf + DO k=kts+1,ktf+1 DO i = i_start, i_end mrdy=msftx(i,j-1)*rdy ! see ADT eqn 46 dividing by my, 2nd term RHS tendency(i,k,j-1) = tendency(i,k,j-1) + mrdy*fqy(i,k,jp0) @@ -4934,14 +4934,14 @@ SUBROUTINE advect_w ( w, w_old, tendency, & ! (latitudes are as for u grid, longitudes are displaced) ! Therefore: flow is only from one side for points next to poles IF ( config_flags%polar .AND. (j == jds+1) ) THEN - DO k=kts,ktf + DO k=kts+1,ktf+1 DO i = i_start, i_end mrdy=msftx(i,j-1)*rdy ! see ADT eqn 46 dividing by my, 2nd term RHS tendency(i,k,j-1) = tendency(i,k,j-1) - mrdy*fqy(i,k,jp1) END DO END DO ELSE IF( config_flags%polar .AND. (j == jde) ) THEN - DO k=kts,ktf + DO k=kts+1,ktf+1 DO i = i_start, i_end mrdy=msftx(i,j-1)*rdy ! see ADT eqn 46 dividing by my, 2nd term RHS tendency(i,k,j-1) = tendency(i,k,j-1) + mrdy*fqy(i,k,jp0) @@ -5293,14 +5293,14 @@ SUBROUTINE advect_w ( w, w_old, tendency, & ! (latitudes are as for u grid, longitudes are displaced) ! Therefore: flow is only from one side for points next to poles IF ( config_flags%polar .AND. (j == jds+1) ) THEN - DO k=kts,ktf + DO k=kts+1,ktf+1 DO i = i_start, i_end mrdy=msftx(i,j-1)*rdy ! see ADT eqn 46 dividing by my, 2nd term RHS tendency(i,k,j-1) = tendency(i,k,j-1) - mrdy*fqy(i,k,jp1) END DO END DO ELSE IF( config_flags%polar .AND. (j == jde) ) THEN - DO k=kts,ktf + DO k=kts+1,ktf+1 DO i = i_start, i_end mrdy=msftx(i,j-1)*rdy ! see ADT eqn 46 dividing by my, 2nd term RHS tendency(i,k,j-1) = tendency(i,k,j-1) + mrdy*fqy(i,k,jp0) @@ -5525,14 +5525,14 @@ SUBROUTINE advect_w ( w, w_old, tendency, & ! (latitudes are as for u grid, longitudes are displaced) ! Therefore: flow is only from one side for points next to poles IF ( config_flags%polar .AND. (j == jds+1) ) THEN - DO k=kts,ktf + DO k=kts+1,ktf+1 DO i = i_start, i_end mrdy=msftx(i,j-1)*rdy ! see ADT eqn 46 dividing by my, 2nd term RHS tendency(i,k,j-1) = tendency(i,k,j-1) - mrdy*fqy(i,k,jp1) END DO END DO ELSE IF( config_flags%polar .AND. (j == jde) ) THEN - DO k=kts,ktf + DO k=kts+1,ktf+1 DO i = i_start, i_end mrdy=msftx(i,j-1)*rdy ! see ADT eqn 46 dividing by my, 2nd term RHS tendency(i,k,j-1) = tendency(i,k,j-1) + mrdy*fqy(i,k,jp0) @@ -12541,14 +12541,14 @@ SUBROUTINE advect_weno_w ( w, w_old, tendency, & ! (latitudes are as for u grid, longitudes are displaced) ! Therefore: flow is only from one side for points next to poles IF ( config_flags%polar .AND. (j == jds+1) ) THEN - DO k=kts,ktf + DO k=kts+1,ktf+1 DO i = i_start, i_end mrdy=msftx(i,j-1)*rdy ! see ADT eqn 46 dividing by my, 2nd term RHS tendency(i,k,j-1) = tendency(i,k,j-1) - mrdy*fqy(i,k,jp1) END DO END DO ELSE IF( config_flags%polar .AND. (j == jde) ) THEN - DO k=kts,ktf + DO k=kts+1,ktf+1 DO i = i_start, i_end mrdy=msftx(i,j-1)*rdy ! see ADT eqn 46 dividing by my, 2nd term RHS tendency(i,k,j-1) = tendency(i,k,j-1) + mrdy*fqy(i,k,jp0) From 531925eefb718c364d5425c22dbd54cc90629390 Mon Sep 17 00:00:00 2001 From: Dan Li <47722078+DanLi-BU@users.noreply.github.com> Date: Wed, 6 Dec 2023 20:33:04 -0500 Subject: [PATCH 02/14] Fixed a constant in module_sf_urban.F (#1928) TYPE: bug fix KEYWORDS: single-layer urban canopy model, saturated specific humidity for ground SOURCE: Dan Li (Boston University) DESCRIPTION OF CHANGES: Problem: When computing the derivative of the saturated specific humidity with respect to surface temperature for the ground in single-layer urban canopy model, the equation had a typo which involved a coefficient. It should be 0.622 (as in for example the same calculations for roof and wall) instead of 0.22. Solution: Change the coefficient from 0.22 to 0.622. LIST OF MODIFIED FILES: M phys/module_sf_urban.F TESTS CONDUCTED: 1. case study. 2. The Jenkins tests are all passing. RELEASE NOTE: Fix a typo in the constant used in computing the saturated specific humidity in the single-layer urban canopy model. The effect is likely small due to the calculation is relevant only in the case of rain and on impervious surfaces when using default evaporation scheme (which is set in URBPARM.TBL). --- phys/module_sf_urban.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys/module_sf_urban.F b/phys/module_sf_urban.F index f7c04091a4..cd1d097c77 100644 --- a/phys/module_sf_urban.F +++ b/phys/module_sf_urban.F @@ -1279,7 +1279,7 @@ SUBROUTINE urban(LSOLAR, & ! L ES=6.11*EXP( (2.5*10.**6./461.51)*(TGP-273.15)/(273.15*TGP) ) DESDT=(2.5*10.**6./461.51)*ES/(TGP**2.) QS0G=0.622*ES/(PS-0.378*ES) - DQS0GDTG=DESDT*0.22*PS/((PS-0.378*ES)**2.) + DQS0GDTG=DESDT*0.622*PS/((PS-0.378*ES)**2.) RG1=EPSG*( RX*VFGS & +EPSB*VFGW*SIG*TBP**4./60. & From af00d81b939b9a01474af9d79ad009212a646f91 Mon Sep 17 00:00:00 2001 From: weiwangncar Date: Wed, 6 Dec 2023 18:42:38 -0700 Subject: [PATCH 03/14] Fixes for WDM6 and WDM7 (#1933) TYPE: bug fixes KEYWORDS: WDM schemes, uninitialized value, wrong cloud autoconversion rate SOURCE: Songyou Hong, PSL/NOAA, internal DESCRIPTION OF CHANGES: Problem: 1. cloud autoconversion rate is off by a factor of 600 2. if cloud water is present, cloud number concentration needs to be set at initialization. Solution: Both problems are fixed in this PR. LIST OF MODIFIED FILES: M phys/module_mp_wdm6.F M phys/module_mp_wdm7.F TESTS CONDUCTED: 1. Tested in case studies. 2. The Jenkins tests are all passing. RELEASE NOTE: This PR fixes two errors in the WDM6 and WDM7 that have been in the code since V4.0: 1. uninitialized cloud number concentration when cloud is present at the start. 2. The cloud autoconversion rate was off by a factor of 600. The effect of the first error isn't large, but the effect of the wrong autoconversion rate has resulted in doubling the surface rainfall in some tests (warm rain processes). --- phys/module_mp_wdm6.F | 17 ++++++++++------- phys/module_mp_wdm7.F | 20 ++++++++++++++------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/phys/module_mp_wdm6.F b/phys/module_mp_wdm6.F index 4ff157910c..4509fff847 100644 --- a/phys/module_mp_wdm6.F +++ b/phys/module_mp_wdm6.F @@ -383,6 +383,12 @@ subroutine wdm62D(t, q, qci, qrs, ncr, den, p, delz & ! nccn > 100 cm-3, bae from kiaps, oct 2017 ! bug fix hydrometeros update before condensation process of rain, ! bae from kiaps, oct2017 +! bug fix in snow melting and autoconversion. +! ==> Revisions enchance melting and autoconverison. +! hong from noaa, july 2023 +! remedy for tiny nc in the presence of qc (nc = xncr, 300/cm**3) +! ==> prevents the crash in computing autoconversion +! hong from noaa, july 2023 ! ! history log : ! @@ -586,7 +592,6 @@ subroutine wdm62D(t, q, qci, qrs, ncr, den, p, delz & dend(i,k) = den(i,k) enddo enddo - ! ! latent heat for phase changes and heat capacity. neglect the ! changes during microphysical process calculation @@ -904,8 +909,7 @@ subroutine wdm62D(t, q, qci, qrs, ncr, den, p, delz & psmlt(i,k) = xka(t(i,k),den(i,k))/xlf*(t0c-t(i,k))*pi/2. & *n0sfac(i,k)*(precs1*rslope2(i,k,2) & +precs2*work2(i,k)*coeres)/den(i,k) - psmlt(i,k) = min(max(psmlt(i,k)*dtcld/mstep(i),-qrs(i,k,2) & - /mstep(i)),0.) + psmlt(i,k) = min(max(psmlt(i,k)*dtcld,-qrs(i,k,2)),0.) !------------------------------------------------------------------- ! nsmlt: melting of snow [LH A27] ! (T>T0: ->NR) @@ -928,8 +932,7 @@ subroutine wdm62D(t, q, qci, qrs, ncr, den, p, delz & pgmlt(i,k) = xka(t(i,k),den(i,k))/xlf*(t0c-t(i,k))*(precg1 & *rslope2(i,k,3) + precg2*work2(i,k)*coeres) & /den(i,k) - pgmlt(i,k) = min(max(pgmlt(i,k)*dtcld/mstep(i), & - -qrs(i,k,3)/mstep(i)),0.) + pgmlt(i,k) = min(max(pgmlt(i,k)*dtcld,-qrs(i,k,3)),0.) !------------------------------------------------------------------- ! ngmlt: melting of graupel [LH A28] ! (T>T0: ->NR) @@ -1165,7 +1168,7 @@ subroutine wdm62D(t, q, qci, qrs, ncr, den, p, delz & lencon = 2.7e-2*den(i,k)*qci(i,k,1)*(1.e20/16.*rslopec2(i,k) & *rslopec2(i,k)-0.4) lenconcr = max(1.2*lencon, qcrmin) - if(qci(i,k,1).gt.qcr(i,k)) then + if(qci(i,k,1).gt.qcr(i,k).and.ncr(i,k,2).gt.ncmin) then praut(i,k) = qck1*qci(i,k,1)**(7./3.)*ncr(i,k,2)**(-1./3.) praut(i,k) = min(praut(i,k),qci(i,k,1)/dtcld) !---------------------------------------------------------------------- @@ -2109,7 +2112,7 @@ SUBROUTINE wdm6init(den0,denr,dens,cl,cpv, ccn0, hail_opt, allowed_to_read) ! RA ! qc0 = 4./3.*pi*denr*r0**3.*xncr0/den0 qc1 = 4./3.*pi*denr*r0**3.*xncr1/den0 - qck1 = .104*9.8*peaut/(xncr*denr)**(1./3.)/xmyu*den0**(4./3.) ! 7.03 + qck1 = .104*9.8*peaut/(denr)**(1./3.)/xmyu*den0**(4./3.) ! 4706.08203 pidnc = pi*denr/6. ! bvtr1 = 1.+bvtr diff --git a/phys/module_mp_wdm7.F b/phys/module_mp_wdm7.F index e063038d78..d29374481c 100644 --- a/phys/module_mp_wdm7.F +++ b/phys/module_mp_wdm7.F @@ -380,6 +380,16 @@ SUBROUTINE wdm72D(t, q, qci, qrs, ncr, den, p, delz & ) !------------------------------------------------------------------- IMPLICIT NONE +! +! The code was first implemented in WRF in v4.1 +! Further Development: +! bug fix in snow melting and autoconversion. +! ==> Revisions enchance melting and autoconverison. +! hong from noaa, july2023 +! remedy for tiny nc in the presence of qc (nc = xncr, 300/cm**3) +! ==> prevents the crashed in computing autoconversion +! hong from noaa, july2023 +! !------------------------------------------------------------------- INTEGER, INTENT(IN ) :: ids,ide, jds,jde, kds,kde , & ims,ime, jms,jme, kms,kme , & @@ -916,8 +926,7 @@ SUBROUTINE wdm72D(t, q, qci, qrs, ncr, den, p, delz & psmlt(i,k) = xka(t(i,k),den(i,k))/xlf*(t0c-t(i,k))*pi/2. & *n0sfac(i,k)*(precs1*rslope2(i,k,2) & +precs2*work2(i,k)*coeres)/den(i,k) - psmlt(i,k) = min(max(psmlt(i,k)*dtcld/mstep(i),-qrs(i,k,2) & - /mstep(i)),0.) + psmlt(i,k) = min(max(psmlt(i,k)*dtcld,-qrs(i,k,2)),0.) ! ! nsmlt: melting of snow [LH A27] ! (T>T0: ->NR) @@ -939,8 +948,7 @@ SUBROUTINE wdm72D(t, q, qci, qrs, ncr, den, p, delz & pgmlt(i,k) = xka(t(i,k),den(i,k))/xlf*(t0c-t(i,k))*(precg1 & *rslope2(i,k,3) + precg2*work2(i,k)*coeres) & /den(i,k) - pgmlt(i,k) = min(max(pgmlt(i,k)*dtcld/mstep(i), & - -qrs(i,k,3)/mstep(i)),0.) + pgmlt(i,k) = min(max(pgmlt(i,k)*dtcld,-qrs(i,k,3)),0.) ! ! ngmlt: melting of graupel [LH A28] ! (T>T0: ->NR) @@ -1212,7 +1220,7 @@ SUBROUTINE wdm72D(t, q, qci, qrs, ncr, den, p, delz & lencon = 2.7e-2*den(i,k)*qci(i,k,1)*(1.e20/16.*rslopec2(i,k) & *rslopec2(i,k)-0.4) lenconcr = max(1.2*lencon, qcrmin) - if(qci(i,k,1).gt.qcr(i,k)) then + if(qci(i,k,1).gt.qcr(i,k).and.ncr(i,k,2).gt.ncmin) then praut(i,k) = qck1*qci(i,k,1)**(7./3.)*ncr(i,k,2)**(-1./3.) praut(i,k) = min(praut(i,k),qci(i,k,1)/dtcld) ! @@ -2381,7 +2389,7 @@ SUBROUTINE wdm7init(den0,denr,dens,cl,cpv, ccn0, allowed_to_read) ! RAS ! qc0 = 4./3.*pi*denr*r0**3.*xncr0/den0 qc1 = 4./3.*pi*denr*r0**3.*xncr1/den0 - qck1 = .104*9.8*peaut/(xncr*denr)**(1./3.)/xmyu*den0**(4./3.) ! 7.03 + qck1 = .104*9.8*peaut/(denr)**(1./3.)/xmyu*den0**(4./3.) ! 4706.08203 pidnc = pi*denr/6. ! bvtr1 = 1.+bvtr From eaaa8bdf24d1fa23af709640e85269da7d19b93b Mon Sep 17 00:00:00 2001 From: JS-WRF-SBM <48547778+JS-WRF-SBM@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:51:19 -0800 Subject: [PATCH 04/14] Bugfix in the calculations of immediate melting and supersaturation dynamical tendency (#1925) TYPE: bug fix KEYWORDS: Melting, Supersaturation SOURCE: Jacob Shpund (Pacific Northwest National Lab), Kangen Huang (Nanjing University) Alexander Khain (The Hebrew University of Jerusalem) DESCRIPTION OF CHANGES: Problem: This PR addresses the following problems: (1) The order of accumulating the melted mass was erroneous and based on the hydrometeor state after melting. (2) Changes in temperature and water vapor after advection were used via low-order approximation for calculating the supersaturation that caused relatively high values of total mass imbalance. (3) Corresponding code cleanup. Solution: (1) Changing the order in melting (2) Calculating the dynamical tendency directly from the perturbation of Temperature and water vapor LIST OF MODIFIED FILES: WRF/phys/module_mp_fast_sbm.F TESTS CONDUCTED: 1. The code compiles (Intel OneAPI 2021.1.1) 2. The melting correction has a very small affect on deep convective cloud state 3. The supersaturation dynamical tendency can cause evident changes in cloud depth of shallow clouds with local (transient) forcing. Otherwise, this fix improves the accuracy of the total mass balance. 4. The regression tests are all passing. RELEASE NOTE: Fixed the calculation order in the immediate melting, and the calculation method in the supersaturation dynamical tendency. --- phys/module_mp_fast_sbm.F | 169 +++++++------------------------------- 1 file changed, 29 insertions(+), 140 deletions(-) diff --git a/phys/module_mp_fast_sbm.F b/phys/module_mp_fast_sbm.F index 184a9220ea..f0600fea85 100644 --- a/phys/module_mp_fast_sbm.F +++ b/phys/module_mp_fast_sbm.F @@ -4096,7 +4096,7 @@ SUBROUTINE FAST_SBM (w,u,v,th_old, & REAL (KIND=R8SIZE) :: DEL1NR,DEL2NR,DEL12R,DEL12RD,ES1N,ES2N,EW1N,EW1PN REAL (KIND=R8SIZE) :: DELSUP1,DELSUP2,DELDIV1,DELDIV2 REAL (KIND=R8SIZE) :: TT,QQ,TTA,QQA,PP,DPSA,DELTATEMP,DELTAQ - REAL (KIND=R8SIZE) :: DIV1,DIV2,DIV3,DIV4,DEL1IN,DEL2IN,DEL1AD,DEL2AD + REAL (KIND=R8SIZE) :: DIV1,DIV2,DIV3,DIV4,DEL1IN,DEL2IN,DEL1AD,DEL2AD,DEL_T,DEL_Q REAL (KIND=R4SIZE) :: DEL_BB,DEL_BBN,DEL_BBR, TTA_r REAL (KIND=R4SIZE) :: FACTZ,CONCCCN_XZ,CONCDROP REAL (KIND=R4SIZE) :: SUPICE(KTE),AR1,AR2, & @@ -4594,26 +4594,12 @@ SUBROUTINE FAST_SBM (w,u,v,th_old, & SUP2_OLD=DEL2IN IF(del1ad > 0.0 .or. del2ad > 0.0 .or. (sum(FF1R)+sum(FF3R)+sum(FF4R)+sum(FF5R)) > 1.0e-20)THEN - ! JacobS: commented for this version - ! CALL Relaxation_Time(TT,QQ,PP,rhocgs(I,K,J),DEL1IN,DEL2IN, & - ! XL,VR1_Z(:,K),FF1R,RLEC,RO1BL, & - ! XI,VR2_Z,FF2R,RIEC,RO2BL, & - ! XS,VR3_Z(:,K),FF3R,RSEC,RO3BL, & - ! XG,VR4_Z(:,K),FF4R,RGEC,RO4BL, & - ! XH,VR5_Z(:,k),FF5R,RHEC,RO5BL, & - ! NKR,ICEMAX,COL,DT,NCOND,DTCOND) - DELSUP1=(DEL1AD-DEL1IN)/NCOND - DELSUP2=(DEL2AD-DEL2IN)/NCOND - DELDIV1=(DIV3-DIV1)/NCOND - DELDIV2=(DIV4-DIV2)/NCOND - DELTATEMP = 0 - DELTAQ = 0 - tt_old = TT - qq_old = qq - DIFFU=1 - - IF (DIV1.EQ.DIV3) DIFFU = 0 - IF (DIV2.EQ.DIV4) DIFFU = 0 + DEL_T = (TTA - TT) / NCOND + DEL_Q = (QQA - QQ) / NCOND + + DIFFU=1 + IF (DIV1.EQ.DIV3) DIFFU = 0 + IF (DIV2.EQ.DIV4) DIFFU = 0 DTNEW = 0.0 DO IKL=1,NCOND @@ -4622,27 +4608,20 @@ SUBROUTINE FAST_SBM (w,u,v,th_old, & IF (DIFFU.NE.0)THEN IF (DIFFU.NE.0)THEN - DEL1IN = DEL1IN+DELSUP1 - DEL2IN = DEL2IN+DELSUP2 - DIV1 = DIV1+DELDIV1 - DIV2 = DIV2+DELDIV2 + TT = TT + DEL_T + QQ = QQ + DEL_Q + ES1N = AA1_MY*DEXP(-BB1_MY/TT) + ES2N = AA2_MY*DEXP(-BB2_MY/TT) + EW1N = QQ*PP/(0.622+0.378*QQ) + DIV1 = EW1N/ES1N + DEL1IN = EW1N/ES1N-1.0 + DIV2 = EW1N/ES2N + DEL2IN = EW1N/ES2N-1.0 END IF IF (DIV1.GT.DIV2.AND.TT.LE.265)THEN DIFFU=0 END IF IF (DIFFU == 1)THEN - DEL1NR=A1_MYN*(100.*DIV1) - DEL2NR=A2_MYN*(100.*DIV2) - IF (DEL2NR.EQ.0)print*,'ikl = ',ikl - IF (DEL2NR.EQ.0)print*,'div1,div2 = ',div1,div2 - IF (DEL2NR.EQ.0)print*,'i,j,k = ',i,j,k - IF (DEL2NR.EQ.0)call wrf_error_fatal("fatal error in module_mp_fast_sbm (DEL2NR.EQ.0) , model stop ") - DEL12R=DEL1NR/DEL2NR - DEL12RD=DEL12R**DEL_BBR - EW1PN=AA1_MY*100.*DIV1*DEL12RD/100. - TT=-DEL_BB/DLOG(DEL12R) - QQ=0.622*EW1PN/(PP-0.378*EW1PN) - IF(DEL1IN > 0.0 .OR. DEL2IN > 0.0)THEN ! +------------------------------------------+ ! Droplet nucleation : @@ -6688,26 +6667,26 @@ SUBROUTINE J_W_MELT(FF1,XL,FF2,XI,FF3,XS,FF4,XG,FF5,XH & FF2(KR,ICE) = 0.0 ELSE IF (KR .gt. 10 .and. KR .lt. 18) THEN meltrate = 0.5/50. + ARG_M=ARG_M+FF2(KR,ICE)*(meltrate*dt) FF2(KR,ICE)=FF2(KR,ICE)-FF2(KR,ICE)*(meltrate*dt) - ARG_M=ARG_M+FF2(KR,ICE)*(meltrate*dt) ELSE meltrate = 0.683/120. + ARG_M=ARG_M+FF2(KR,ICE)*(meltrate*dt) FF2(KR,ICE)=FF2(KR,ICE)-FF2(KR,ICE)*(meltrate*dt) - ARG_M=ARG_M+FF2(KR,ICE)*(meltrate*dt) ENDIF ENDIF IF (ICE ==2 .or. ICE ==3) THEN IF (kr .le. 12) THEN + ARG_M = ARG_M+FF2(KR,ICE) FF2(KR,ICE)=0. - ARG_M = ARG_M+FF2(KR,ICE) ELSE IF (kr .gt. 12 .and. kr .lt. 20) THEN meltrate = 0.5/50. + ARG_M=ARG_M+FF2(KR,ICE)*(meltrate*dt) FF2(KR,ICE)=FF2(KR,ICE)-FF2(KR,ICE)*(meltrate*dt) - ARG_M=ARG_M+FF2(KR,ICE)*(meltrate*dt) ELSE - meltrate = 0.683/120. + meltrate = 0.683/120. + ARG_M=ARG_M+FF2(KR,ICE)*(meltrate*dt) FF2(KR,ICE)=FF2(KR,ICE)-FF2(KR,ICE)*(meltrate*dt) - ARG_M=ARG_M+FF2(KR,ICE)*(meltrate*dt) ENDIF ENDIF END DO ! Do ice @@ -6717,12 +6696,12 @@ SUBROUTINE J_W_MELT(FF1,XL,FF2,XI,FF3,XS,FF4,XG,FF5,XH & FF3(KR) = 0.0 ELSE IF (kr .gt. 14 .and. kr .lt. 22) THEN meltrate = 0.5/50. - FF3(KR)=FF3(KR)-FF3(KR)*(meltrate*dt) ARG_M=ARG_M+FF3(KR)*(meltrate*dt) + FF3(KR)=FF3(KR)-FF3(KR)*(meltrate*dt) ELSE meltrate = 0.683/120. - FF3(KR)=FF3(KR)-FF3(KR)*(meltrate*dt) ARG_M=ARG_M+FF3(KR)*(meltrate*dt) + FF3(KR)=FF3(KR)-FF3(KR)*(meltrate*dt) ENDIF ! ... Graupel/Hail IF (kr .le. 13) then @@ -6731,14 +6710,14 @@ SUBROUTINE J_W_MELT(FF1,XL,FF2,XI,FF3,XS,FF4,XG,FF5,XH & FF5(KR)=0. ELSE IF (kr .gt. 13 .and. kr .lt. 23) THEN meltrate = 0.5/50. + ARG_M=ARG_M+(FF4(KR)+FF5(KR))*(meltrate*dt) FF4(KR)=FF4(KR)-FF4(KR)*(meltrate*dt) FF5(KR)=FF5(KR)-FF5(KR)*(meltrate*dt) - ARG_M=ARG_M+(FF4(KR)+FF5(KR))*(meltrate*dt) ELSE meltrate = 0.683/120. - FF4(KR)=FF4(KR)-FF4(KR)*(meltrate*dt) - FF5(KR)=FF5(KR)-FF5(KR)*(meltrate*dt) - ARG_M=ARG_M+(FF4(KR)+FF5(KR))*(meltrate*dt) + ARG_M=ARG_M+(FF4(KR)+FF5(KR))*(meltrate*dt) + FF4(KR)=FF4(KR)-FF4(KR)*(meltrate*dt) + FF5(KR)=FF5(KR)-FF5(KR)*(meltrate*dt) ENDIF FF1(KR) = FF1(KR) + ARG_M @@ -7077,26 +7056,6 @@ SUBROUTINE ONECOND1 & call wrf_error_fatal("fatal error in ONECOND1-in (ABS(DAL1*DELMASSL1) > 3.0), model stop") ENDIF - ! ... SUPERSATURATION (ONLY WATER) - ARGEXP=-BB1_MY/TPN - ES1N=AA1_MY*DEXP(ARGEXP) - ARGEXP=-BB2_MY/TPN - ES2N=AA2_MY*DEXP(ARGEXP) - EW1N=OPER3(QPN,PP) - IF(ES1N == 0.0D0)THEN - DEL1N=0.5 - DIV1=1.5 - ELSE - DIV1 = EW1N/ES1N - DEL1N = EW1N/ES1N-1. - END IF - IF(ES2N == 0.0D0)THEN - DEL2N=0.5 - DIV2=1.5 - ELSE - DEL2N = EW1N/ES2N-1. - DIV2 = EW1N/ES2N - END IF IF(ISYM1 == 1) THEN DO KR=1,NKR SUPINTW(KR)=SUPINTW(KR)+B11_MY(KR)*D1N @@ -7160,29 +7119,6 @@ SUBROUTINE ONECOND1 & ENDIF ENDIF - ! ... SUPERSATURATION - ARGEXP=-BB1_MY/TPN - ES1N=AA1_MY*DEXP(ARGEXP) - ARGEXP=-BB2_MY/TPN - ES2N=AA2_MY*DEXP(ARGEXP) - EW1N=OPER3(QPN,PP) - IF(ES1N == 0.0D0)THEN - DEL1N=0.5 - DIV1=1.5 - call wrf_error_fatal("fatal error in ONECOND1 (ES1N.EQ.0), model stop") - ELSE - DIV1=EW1N/ES1N - DEL1N=EW1N/ES1N-1. - END IF - IF(ES2N.EQ.0)THEN - DEL2N=0.5 - DIV2=1.5 - call wrf_error_fatal("fatal error in ONECOND1 (ES2N.EQ.0), model stop") - ELSE - DEL2N=EW1N/ES2N-1. - DIV2=EW1N/ES2N - END IF - TT=TPN QQ=QPN DO KR=1,NKR @@ -7745,29 +7681,6 @@ SUBROUTINE ONECOND2 & ENDIF ENDIF - ! ... SUPERSATURATION - ARGEXP=-BB1_MY/TPN - ES1N=AA1_MY*DEXP(ARGEXP) - ARGEXP=-BB2_MY/TPN - ES2N=AA2_MY*DEXP(ARGEXP) - EW1N=OPER3(QPN,PP) - IF(ES1N == 0.0)THEN - DEL1N=0.5 - DIV1=1.5 - call wrf_error_fatal("fatal error in ONECOND2 (ES1N.EQ.0), model stop") - ELSE - DIV1=EW1N/ES1N - DEL1N=EW1N/ES1N-1. - END IF - IF(ES2N == 0.0)THEN - DEL2N=0.5 - DIV2=1.5 - call wrf_error_fatal("fatal error in ONECOND2 (ES2N.EQ.0), model stop") - ELSE - DEL2N=EW1N/ES2N-1. - DIV2=EW1N/ES2N - END IF - ! END OF TIME SPLITTING ! (ONLY ICE: CONDENSATION OR EVAPORATION) IF(TIMENEW.LT.DT) GOTO 46 @@ -8312,31 +8225,7 @@ SUBROUTINE ONECOND3 & call wrf_error_fatal("fatal error in ONECOND3-out (ABS(DAL1*DELMASSL1+DAL2*DELMASSI1) > 5.0), model stop") ENDIF ENDIF - - ! SUPERSATURATION - ARGEXP=-BB1_MY/TPN - ES1N=AA1_MY*DEXP(ARGEXP) - ARGEXP=-BB2_MY/TPN - ES2N=AA2_MY*DEXP(ARGEXP) - EW1N=OPER3(QPN,PP) - IF(ES1N == 0.0)THEN - DEL1N=0.5 - DIV1=1.5 - print*,'es1n onecond3 = 0' - call wrf_error_fatal("fatal error in ONECOND3 (ES1N.EQ.0), model stop") - ELSE - DIV1=EW1N/ES1N - DEL1N=EW1N/ES1N-1. - END IF - IF(ES2N == 0.0)THEN - DEL2N=0.5 - DIV2=1.5 - print*,'es2n onecond3 = 0' - call wrf_error_fatal("fatal error in ONECOND3 (ES2N.EQ.0), model stop") - ELSE - DEL2N=EW1N/ES2N-1. - DIV2=EW1N/ES2N - END IF + ! END OF TIME SPLITTING IF(TIMENEW < DT) GOTO 16 From 4c1b73240ccdbcc64ef9bf39169fc565c8c1aaf6 Mon Sep 17 00:00:00 2001 From: zhixiaozhang <72099269+zhixiaozhang@users.noreply.github.com> Date: Fri, 8 Dec 2023 07:21:30 +0000 Subject: [PATCH 05/14] Fix Code Bug on CAPE Triggering Condition (#1904) TYPE: bug fix KEYWORDS: CAPE, PLFC SOURCE: Zhixiao Zhang (University of Oxford) DESCRIPTION OF CHANGES: Problem: CAPE can't be updated Solution: Assign PLFC value before calculating CAPE because PLFC is the triggering condition for CAPE calculation. ISSUE: Fixes #1903 LIST OF MODIFIED FILES: M phys/module_diag_functions.F TESTS: The Jenkins tests are all passing. RELEASE NOTE: Fixed triggering condition code bug for CAPE calculation. --- phys/module_diag_functions.F | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/phys/module_diag_functions.F b/phys/module_diag_functions.F index ac920798ac..0466dff45f 100644 --- a/phys/module_diag_functions.F +++ b/phys/module_diag_functions.F @@ -760,9 +760,10 @@ FUNCTION Buoyancy ( nz, tk, rh, p, hgt, sfc, cape, cin, zlfc, plfc, lidx, & flag = .false. END IF END DO - IF (ellev >= 0) THEN !Modified by Zhixiao - pel = p(ellev) !Modified by Zhixiao - CIN=REAL ( 0 ) !Modified by Zhixiao + IF ((ellev >= 0) .and. (lfclev >= 0)) THEN !Modified by Zhixiao + plfc = p (lfclev) + pel = p (ellev) + CIN = REAL ( 0 ) DO k = sfc+1, nz ! Make CAPE and CIN consistent with AMS definition ! https://glossary.ametsoc.org/wiki/Convective_available_potential_energy From 414c1bf5ec8fd88d2d1f7d7d5dfed55f104b7f82 Mon Sep 17 00:00:00 2001 From: Wei-keng Liao Date: Fri, 8 Dec 2023 01:42:42 -0600 Subject: [PATCH 06/14] check if USENETCDFPAR is empty first (#1743) Env variable USENETCDFPAR may not be set when running make. TYPE: bug fix KEYWORDS: USENETCDFPAR SOURCE: Wei-keng Liao DESCRIPTION OF CHANGES: When env USENETCDFPAR is not set, running make spews the following error message. ``` /bin/sh: line 0: [: -eq: unary operator expected ``` Solution: Check if USENETCDFPAR is set first, and then its value if set. LIST OF MODIFIED FILES: M Makefile TESTS CONDUCTED: 1. It removes the error message 2. The Jenkins tests are passing. RELEASE NOTE: Fixed an error in Makefile to check if USENETCDFPAR is set first. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 775eb3c246..6391659ea7 100644 --- a/Makefile +++ b/Makefile @@ -1069,7 +1069,7 @@ fseek_test : # rule used by configure to test if this will compile with netcdf4 nc4_test: - if [ $(USENETCDFPAR) -eq 0 ] ; then \ + if [ -z "$(USENETCDFPAR)" ] || [ $(USENETCDFPAR) -eq 0 ] ; then \ ( cd tools ; /bin/rm -f nc4_test.{exe,nc,o} ; $(SCC) -o nc4_test.exe nc4_test.c -I$(NETCDF)/include -L$(NETCDF)/lib -lnetcdf $(NETCDF4_DEP_LIB) ; cd .. ) ; \ else \ ( cd tools ; /bin/rm -f nc4_test.{exe,nc,o} ; $(DM_CC) -o nc4_test.exe nc4_test.c -I$(NETCDF)/include -L$(NETCDF)/lib -lnetcdf $(NETCDF4_DEP_LIB) ; cd .. ) ; \ From ae0906eae9582c4d60cf85aec2bea90ec8598808 Mon Sep 17 00:00:00 2001 From: "Alexander (Alex) Knyazev" Date: Fri, 8 Dec 2023 07:54:16 +0000 Subject: [PATCH 07/14] Resolves building issues with Intel compilers (ifx/icx) (#1823) Adding/Replacing missing prototypes. Remove unsupported/bogus compiler switches. TYPE: Bug fix KEYWORDS: Missing prototypes, old unsupported compile options SOURCE: Alexander Knyazev DESCRIPTION OF CHANGES: Problem: Most C code written long ago. No prototypes were used. Solution: Add missing prototypes. LIST OF MODIFIED FILES: external/io_grib1/grib1_util/read_grib.c external/io_grib1/grib1_util/write_grib.c external/io_grib1/grib1_util/read_grib.h external/io_grib1/MEL_grib1/FTP_getfile.c external/io_grib1/MEL_grib1/gribfuncs.h external/io_grib1/MEL_grib1/gribgetbds.c external/io_grib1/MEL_grib1/upd_child_errmsg.c external/io_grib1/MEL_grib1/gribhdr2file.c external/io_grib1/MEL_grib1/init_enc_struct.c external/io_grib1/MEL_grib1/init_gribhdr.c external/io_grib1/MEL_grib1/init_struct.c external/io_grib1/MEL_grib1/ld_enc_input.c external/io_grib1/MEL_grib1/ld_enc_lookup.c external/io_grib1/MEL_grib1/map_lvl.c external/io_grib1/MEL_grib1/map_parm.c external/io_grib1/MEL_grib1/prt_inp_struct.c external/io_grib1/MEL_grib1/prt_badmsg.c external/io_grib1/MEL_grib1/set_bytes.c external/io_grib1/MEL_grib1/ld_grib_origctrs.c external/io_grib1/gribmap.c external/io_grib1/grib1_routines.c external/io_grib1/gribmap.h external/io_grib1/trim.c external/io_grib1/trim.h external/io_grib_share/get_region_center.c external/io_grib_share/open_file.c external/RSL_LITE/gen_comms.c external/RSL_LITE/c_code.c external/RSL_LITE/buf_for_proc.c external/RSL_LITE/rsl_malloc.c external/RSL_LITE/rsl_bcast.c external/RSL_LITE/task_for_point.c external/RSL_LITE/period.c external/RSL_LITE/swap.c external/RSL_LITE/cycle.c external/RSL_LITE/rsl_lite.h tools/protos.h tools/reg_parse.c tools/misc.c tools/symtab_gen.c tools/gen_config.c tools/sym.c tools/gen_streams.c tools/gen_irr_diag.c tools/sym.h frame/pack_utils.c arch/configure.defaults TESTS CONDUCTED: 1. Compilation with Intel oneAPI compiler works with these changes. 2. The Jenkins tests are all passing. RELEASE NOTE: This PR fixed some c code by adding and replacing missing prototypes. This also allows the new Intel oneAPI compiler to work. Remove unsupported/bogus compiler switches. --- arch/configure.defaults | 24 +-- external/RSL_LITE/buf_for_proc.c | 5 +- external/RSL_LITE/c_code.c | 12 ++ external/RSL_LITE/cycle.c | 6 +- external/RSL_LITE/gen_comms.c | 2 + external/RSL_LITE/period.c | 8 +- external/RSL_LITE/rsl_bcast.c | 165 +++++++++--------- external/RSL_LITE/rsl_lite.h | 17 ++ external/RSL_LITE/rsl_malloc.c | 3 +- external/RSL_LITE/swap.c | 7 +- external/RSL_LITE/task_for_point.c | 5 +- external/io_grib1/MEL_grib1/FTP_getfile.c | 7 + external/io_grib1/MEL_grib1/gribfuncs.h | 13 +- external/io_grib1/MEL_grib1/gribgetbds.c | 1 + external/io_grib1/MEL_grib1/gribhdr2file.c | 7 + external/io_grib1/MEL_grib1/init_enc_struct.c | 1 + external/io_grib1/MEL_grib1/init_gribhdr.c | 1 + external/io_grib1/MEL_grib1/init_struct.c | 1 + external/io_grib1/MEL_grib1/ld_enc_input.c | 1 + external/io_grib1/MEL_grib1/ld_enc_lookup.c | 2 +- .../io_grib1/MEL_grib1/ld_grib_origctrs.c | 9 +- external/io_grib1/MEL_grib1/map_lvl.c | 2 + external/io_grib1/MEL_grib1/map_parm.c | 1 + external/io_grib1/MEL_grib1/prt_badmsg.c | 1 + external/io_grib1/MEL_grib1/prt_inp_struct.c | 1 + external/io_grib1/MEL_grib1/set_bytes.c | 1 + .../io_grib1/MEL_grib1/upd_child_errmsg.c | 1 + external/io_grib1/grib1_routines.c | 10 +- external/io_grib1/grib1_util/read_grib.c | 9 +- external/io_grib1/grib1_util/read_grib.h | 1 + external/io_grib1/grib1_util/write_grib.c | 69 ++++---- external/io_grib1/gribmap.c | 2 + external/io_grib1/gribmap.h | 1 + external/io_grib1/trim.c | 1 + external/io_grib1/trim.h | 2 + external/io_grib_share/get_region_center.c | 1 + external/io_grib_share/open_file.c | 5 +- frame/pack_utils.c | 3 +- tools/gen_config.c | 1 + tools/gen_irr_diag.c | 1 + tools/gen_streams.c | 2 + tools/misc.c | 2 + tools/protos.h | 64 +++++++ tools/reg_parse.c | 1 + tools/sym.c | 76 ++++---- tools/sym.h | 4 +- tools/symtab_gen.c | 36 ++-- 47 files changed, 384 insertions(+), 211 deletions(-) create mode 100644 external/io_grib1/trim.h diff --git a/arch/configure.defaults b/arch/configure.defaults index aed98042a2..597963ffbf 100644 --- a/arch/configure.defaults +++ b/arch/configure.defaults @@ -304,7 +304,7 @@ DESCRIPTION = INTEL ($SFC/$SCC) DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -qopenmp -fpp -auto -OMPCC = # -qopenmp -fpp -auto +OMPCC = # -qopenmp SFC = ifort SCC = icc CCOMP = icc @@ -350,7 +350,7 @@ DESCRIPTION = INTEL ($SFC/$SCC): Xeon Phi (MIC architecture) DMPARALLEL = 1 OMPCPP = -D_OPENMP OMP = -qopenmp -fpp -auto -OMPCC = -qopenmp -fpp -auto +OMPCC = -qopenmp SFC = ifort -mmic SCC = icc -mmic CCOMP = icc -mmic @@ -398,7 +398,7 @@ DESCRIPTION = INTEL ($SFC/$SCC): Xeon (SNB with AVX mods) DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -qopenmp -fpp -auto -OMPCC = # -qopenmp -fpp -auto +OMPCC = # -qopenmp SFC = ifort SCC = icc CCOMP = icc @@ -472,7 +472,7 @@ DESCRIPTION = INTEL ($SFC/$SCC): SGI MPT DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -qopenmp -fpp -auto -OMPCC = # -qopenmp -fpp -auto +OMPCC = # -qopenmp SFC = ifort SCC = icc CCOMP = icc @@ -522,7 +522,7 @@ DESCRIPTION = INTEL ($SFC/$SCC): IBM POE DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -qopenmp -fpp -auto -OMPCC = # -qopenmp -fpp -auto +OMPCC = # -qopenmp SFC = ifort SCC = icc CCOMP = icc @@ -602,7 +602,7 @@ DESCRIPTION = INTEL ($SFC/$SCC): ia64 DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -qopenmp -fpp -auto -OMPCC = # -qopenmp -fpp -auto +OMPCC = # -qopenmp SFC = ifort SCC = icc CCOMP = icc @@ -686,7 +686,7 @@ DESCRIPTION = INTEL ($SFC/$SCC): SGI Altix DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -qopenmp -fpp -auto -OMPCC = # -qopenmp -fpp -auto +OMPCC = # -qopenmp SFC = ifort SCC = icc CCOMP = icc @@ -868,7 +868,7 @@ DESCRIPTION = INTEL ($SFC/$SCC) DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -qopenmp -fpp -auto -OMPCC = # -qopenmp -fpp -auto +OMPCC = # -qopenmp SFC = ifort SCC = icc CCOMP = icc @@ -1358,7 +1358,7 @@ DESCRIPTION = INTEL ($SFC/$SCC): Cray XC DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -qopenmp -fpp -auto -OMPCC = # -qopenmp -fpp -auto +OMPCC = # -qopenmp SFC = ftn SCC = icc CCOMP = icc @@ -1745,7 +1745,7 @@ DESCRIPTION = INTEL ($SFC/$SCC): Open MPI DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -qopenmp -fpp -auto -OMPCC = # -qopenmp -fpp -auto +OMPCC = # -qopenmp SFC = ifort SCC = icc CCOMP = icc @@ -1881,7 +1881,7 @@ DESCRIPTION = INTEL ($SFC/$SCC): HSW/BDW DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -qopenmp -fpp -auto -OMPCC = # -qopenmp -fpp -auto +OMPCC = # -qopenmp SFC = ifort SCC = icc CCOMP = icc @@ -1926,7 +1926,7 @@ DESCRIPTION = INTEL ($SFC/$SCC): KNL MIC DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -qopenmp -fpp -auto -OMPCC = # -qopenmp -fpp -auto +OMPCC = # -qopenmp SFC = ifort SCC = icc CCOMP = icc diff --git a/external/RSL_LITE/buf_for_proc.c b/external/RSL_LITE/buf_for_proc.c index 5d50cbf14a..e31703091a 100755 --- a/external/RSL_LITE/buf_for_proc.c +++ b/external/RSL_LITE/buf_for_proc.c @@ -148,6 +148,7 @@ fprintf(stderr,"buffer_for_proc %s %d : was %d, increasing to %d\n", return(ret) ; } +int show_tot_size() { int P ; @@ -164,9 +165,7 @@ show_tot_size() } int -buffer_size_for_proc( P, code ) - int P ; - int code ; +buffer_size_for_proc( int P, int code ) { return( buftab[code][P].size ) ; } diff --git a/external/RSL_LITE/c_code.c b/external/RSL_LITE/c_code.c index 27549bdf9c..8db9aba3ba 100755 --- a/external/RSL_LITE/c_code.c +++ b/external/RSL_LITE/c_code.c @@ -14,6 +14,8 @@ #ifdef _WIN32 #include +#else +#include #endif #ifdef NCEP_DEBUG_MULTIDIR // # include @@ -243,6 +245,7 @@ gethostid () } #endif +int RSL_LITE_GET_HOSTNAME ( char * hn, int * size, int *n, int *hostid ) { char temp[512] ; @@ -256,6 +259,7 @@ RSL_LITE_GET_HOSTNAME ( char * hn, int * size, int *n, int *hostid ) return(0) ; } +int BYTE_BCAST ( char * buf, int * size, int * Fcomm ) { #ifndef STUBMPI @@ -275,6 +279,7 @@ BYTE_BCAST ( char * buf, int * size, int * Fcomm ) #endif } +int BYTE_BCAST_FROM_ROOT ( char * buf, int * size, int *root , int * Fcomm ) { #ifndef STUBMPI @@ -297,6 +302,7 @@ BYTE_BCAST_FROM_ROOT ( char * buf, int * size, int *root , int * Fcomm ) static int yp_curs, ym_curs, xp_curs, xm_curs ; static int yp_curs_recv, ym_curs_recv, xp_curs_recv, xm_curs_recv ; +int RSL_LITE_INIT_EXCH ( int * Fcomm0, int * shw0, int * xy0 , @@ -395,6 +401,7 @@ RSL_LITE_INIT_EXCH ( xp_curs_recv = nbytes_x_recv ; xm_curs_recv = nbytes_x_recv ; } +int RSL_LITE_PACK ( int * Fcomm0, char * buf , int * shw0 , int * sendbegm0 , int * sendwm0 , int * sendbegp0 , int * sendwp0 , int * recvbegm0 , int * recvwm0 , int * recvbegp0 , int * recvwp0 , @@ -690,6 +697,7 @@ RSL_LITE_PACK ( int * Fcomm0, char * buf , int * shw0 , } #if ( WRFPLUS == 1 ) +int RSL_LITE_PACK_AD ( int * Fcomm0, char * buf , int * shw0 , int * sendbegm0 , int * sendwm0 , int * sendbegp0 , int * sendwp0 , int * recvbegm0 , int * recvwm0 , int * recvbegp0 , int * recvwp0 , @@ -989,6 +997,7 @@ static MPI_Request yp_recv, ym_recv, yp_send, ym_send ; static MPI_Request xp_recv, xm_recv, xp_send, xm_send ; #endif +int RSL_LITE_EXCH_Y ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 , int * sendw_m, int * sendw_p, int * recvw_m , int * recvw_p ) { @@ -1026,6 +1035,7 @@ RSL_LITE_EXCH_Y ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 #endif } +int RSL_LITE_EXCH_X ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 , int * sendw_m, int * sendw_p, int * recvw_m , int * recvw_p ) { @@ -1065,6 +1075,7 @@ RSL_LITE_EXCH_X ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 #if !defined( MS_SUA) && !defined(_WIN32) #include +int RSL_INTERNAL_MILLICLOCK () { struct timeval tb ; @@ -1078,6 +1089,7 @@ RSL_INTERNAL_MILLICLOCK () msecs = 1000 * isec + usec / 1000 ; return(msecs) ; } +int RSL_INTERNAL_MICROCLOCK () { struct timeval tb ; diff --git a/external/RSL_LITE/cycle.c b/external/RSL_LITE/cycle.c index e9b2738e2d..0acfd9e3a8 100644 --- a/external/RSL_LITE/cycle.c +++ b/external/RSL_LITE/cycle.c @@ -32,7 +32,7 @@ static int *nbytes_dst = NULL ; static MPI_Request *x_recv = NULL , *x_send = NULL ; #endif -RSL_LITE_INIT_CYCLE ( int * Fcomm , +void RSL_LITE_INIT_CYCLE ( int * Fcomm , int * xy0 , int * inout0 , int * n3dR0, int *n2dR0, int * typesizeR0 , int * n3dI0, int *n2dI0, int * typesizeI0 , @@ -142,7 +142,7 @@ RSL_LITE_INIT_CYCLE ( int * Fcomm , #endif } -RSL_LITE_PACK_CYCLE ( int * Fcomm, char * buf , int * inout0 , int * typesize0 , int * xy0 , int * pu0 , char * memord , int * xstag0 , +void RSL_LITE_PACK_CYCLE ( int * Fcomm, char * buf , int * inout0 , int * typesize0 , int * xy0 , int * pu0 , char * memord , int * xstag0 , int *me0, int * np0 , int * np_x0 , int * np_y0 , int * min_subdomain, int * ids0 , int * ide0 , int * jds0 , int * jde0 , int * kds0 , int * kde0 , @@ -343,7 +343,7 @@ RSL_LITE_PACK_CYCLE ( int * Fcomm, char * buf , int * inout0 , int * typesize0 , #endif } -RSL_LITE_CYCLE ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 ) +void RSL_LITE_CYCLE ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 ) { int me, np, np_x, np_y ; int yp, ym, xp, xm, nb ; diff --git a/external/RSL_LITE/gen_comms.c b/external/RSL_LITE/gen_comms.c index 2a6b2ef5bd..d62c5cb5af 100644 --- a/external/RSL_LITE/gen_comms.c +++ b/external/RSL_LITE/gen_comms.c @@ -1218,6 +1218,7 @@ fprintf(fp,"CALL wrf_debug(3,'calling RSL_LITE_INIT_EXCH %s for Y %s')\n",maxste } #endif +int #if ( WRFPLUS == 1 ) gen_packs_halo ( FILE *fp , node_t *p, char *shw, int xy /* 0=y,1=x */ , int pu /* 0=pack,1=unpack */, int nta /* 0=NLM,1=TLM,2=ADM*/, char * packname, char * commname, int always_interp_mp ) #else @@ -1454,6 +1455,7 @@ fprintf(fp,"(ips-1)*grid%%sr_x+1,ipe*grid%%sr_x,(jps-1)*grid%%sr_y+1,jpe*grid%%s } } +int gen_packs ( FILE *fp , node_t *p, int shw, int xy /* 0=y,1=x */ , int pu /* 0=pack,1=unpack */, char * packname, char * commname ) { node_t * q ; diff --git a/external/RSL_LITE/period.c b/external/RSL_LITE/period.c index 8e288b6ccf..b0401d03c5 100755 --- a/external/RSL_LITE/period.c +++ b/external/RSL_LITE/period.c @@ -14,7 +14,7 @@ static int yp_curs, ym_curs, xp_curs, xm_curs ; -RSL_LITE_INIT_PERIOD ( +void RSL_LITE_INIT_PERIOD ( int * Fcomm0, int * shw0, int * n3dR0, int *n2dR0, int * typesizeR0 , @@ -93,7 +93,7 @@ RSL_LITE_INIT_PERIOD ( } -RSL_LITE_PACK_PERIOD ( int* Fcomm0, char * buf , int * shw0 , int * typesize0 , int * xy0 , int * pu0 , int * imemord , int * stag0 , +void RSL_LITE_PACK_PERIOD ( int* Fcomm0, char * buf , int * shw0 , int * typesize0 , int * xy0 , int * pu0 , int * imemord , int * stag0 , int *me0, int * np0 , int * np_x0 , int * np_y0 , int * ids0 , int * ide0 , int * jds0 , int * jde0 , int * kds0 , int * kde0 , int * ims0 , int * ime0 , int * jms0 , int * jme0 , int * kms0 , int * kme0 , @@ -368,7 +368,7 @@ static MPI_Request yp_recv, ym_recv, yp_send, ym_send ; static MPI_Request xp_recv, xm_recv, xp_send, xm_send ; #endif -RSL_LITE_EXCH_PERIOD_X ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 ) +void RSL_LITE_EXCH_PERIOD_X ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 ) { #ifndef STUBMPI int me, np, np_x, np_y ; @@ -414,7 +414,7 @@ fprintf(stderr,"RSL_LITE_EXCH_PERIOD_X disabled\n") ; #endif } -RSL_LITE_EXCH_PERIOD_Y ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 ) +void RSL_LITE_EXCH_PERIOD_Y ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 ) { #ifndef STUBMPI int me, np, np_x, np_y ; diff --git a/external/RSL_LITE/rsl_bcast.c b/external/RSL_LITE/rsl_bcast.c index d3e7d10691..88c03c944b 100755 --- a/external/RSL_LITE/rsl_bcast.c +++ b/external/RSL_LITE/rsl_bcast.c @@ -74,13 +74,13 @@ typedef struct bcast_point_desc { } bcast_point_desc_t ; -static destroy_par_info ( p ) +static int destroy_par_info ( p ) char * p ; { if ( p != NULL ) RSL_FREE( p ) ; } -static destroy_list( list, dfcn ) +static int destroy_list( list, dfcn ) rsl_list_t ** list ; /* pointer to pointer to list */ int (*dfcn)() ; /* pointer to function for destroying the data field of the list */ @@ -161,7 +161,7 @@ static int s_putmsg = 0 ; // It needs the minor number of tasks on the nest's MPI mesh (just pass that in) // Otherwise it doesn't need a communicator -RSL_LITE_NESTING_RESET ( +void RSL_LITE_NESTING_RESET ( ) { int j ; @@ -452,7 +452,6 @@ void RSL_LITE_TO_PARENT_INFO ( msize_p, return ; } - /********************************************/ /*@ @@ -460,28 +459,9 @@ void RSL_LITE_TO_PARENT_INFO ( msize_p, @*/ -/* parent->nest */ -RSL_LITE_TO_CHILD_MSG ( nbuf_p, buf ) - int_p - nbuf_p ; /* (I) Number of bytes to be packed. */ - char * - buf ; /* (I) Buffer containing the data to be packed. */ -{ - rsl_lite_to_peerpoint_msg ( nbuf_p, buf ) ; -} - -/* nest->parent */ -RSL_LITE_TO_PARENT_MSG ( nbuf_p, buf ) - int_p - nbuf_p ; /* (I) Number of bytes to be packed. */ - char * - buf ; /* (I) Buffer containing the data to be packed. */ -{ - rsl_lite_to_peerpoint_msg ( nbuf_p, buf ) ; -} /* common code */ -rsl_lite_to_peerpoint_msg ( nbuf_p, buf ) +void rsl_lite_to_peerpoint_msg ( nbuf_p, buf ) int_p nbuf_p ; /* (I) Number of bytes to be packed. */ char * @@ -521,6 +501,28 @@ rsl_lite_to_peerpoint_msg ( nbuf_p, buf ) } + +/* parent->nest */ +void RSL_LITE_TO_CHILD_MSG ( nbuf_p, buf ) + int_p + nbuf_p ; /* (I) Number of bytes to be packed. */ + char * + buf ; /* (I) Buffer containing the data to be packed. */ +{ + rsl_lite_to_peerpoint_msg ( nbuf_p, buf ) ; +} + +/* nest->parent */ +void RSL_LITE_TO_PARENT_MSG ( nbuf_p, buf ) + int_p + nbuf_p ; /* (I) Number of bytes to be packed. */ + char * + buf ; /* (I) Buffer containing the data to be packed. */ +{ + rsl_lite_to_peerpoint_msg ( nbuf_p, buf ) ; +} + + /********************************************/ // PARALLELNESTING NOTES @@ -530,36 +532,9 @@ rsl_lite_to_peerpoint_msg ( nbuf_p, buf ) // // nest if it's parent->nest and the parent if it's nest->parent (we'll see) -/* parent->nest */ -RSL_LITE_BCAST_MSGS ( mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, Fcomm ) - int_p mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, Fcomm ; /* offset is the id of the first task in the nest set */ -{ -#ifndef STUBMPI - MPI_Comm comm ; - - comm = MPI_Comm_f2c( *Fcomm ) ; -#else - int comm ; -#endif - rsl_lite_allgather_msgs ( mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, comm, 0 ) ; -} - -/* nest->parent */ -RSL_LITE_MERGE_MSGS ( mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, Fcomm ) - int_p mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, Fcomm ; /* offset is the id of the first task in the nest set */ -{ -#ifndef STUBMPI - MPI_Comm comm ; - - comm = MPI_Comm_f2c( *Fcomm ) ; -#else - int comm ; -#endif - rsl_lite_allgather_msgs ( mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, comm, 1 ) ; -} /* common code */ -rsl_lite_allgather_msgs ( mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, comm, dir ) +void rsl_lite_allgather_msgs ( mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, comm, dir ) int_p mytask_p, ntasks_par_p, ntasks_nest_p, offset_p ; int dir ; /* 0 = parent to nest, otherwist nest to parent */ #ifndef STUBMPI @@ -651,30 +626,38 @@ rsl_lite_allgather_msgs ( mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, comm, } -/********************************************/ - /* parent->nest */ -RSL_LITE_FROM_PARENT_INFO ( ig_p, jg_p, retval_p ) - int_p - ig_p /* (O) Global index in M dimension of nest. */ - ,jg_p /* (O) Global index in N dimension of nest. */ - ,retval_p ; /* (O) Return value; =1 valid point, =0 done. */ +void RSL_LITE_BCAST_MSGS ( mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, Fcomm ) + int_p mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, Fcomm ; /* offset is the id of the first task in the nest set */ { - rsl_lite_from_peerpoint_info ( ig_p, jg_p, retval_p ) ; +#ifndef STUBMPI + MPI_Comm comm ; + + comm = MPI_Comm_f2c( *Fcomm ) ; +#else + int comm ; +#endif + rsl_lite_allgather_msgs ( mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, comm, 0 ) ; } /* nest->parent */ -RSL_LITE_FROM_CHILD_INFO ( ig_p, jg_p, retval_p ) - int_p - ig_p /* (O) Global index in M dimension of nest. */ - ,jg_p /* (O) Global index in N dimension of nest. */ - ,retval_p ; /* (O) Return value; =1 valid point, =0 done. */ +void RSL_LITE_MERGE_MSGS ( mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, Fcomm ) + int_p mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, Fcomm ; /* offset is the id of the first task in the nest set */ { - rsl_lite_from_peerpoint_info ( ig_p, jg_p, retval_p ) ; +#ifndef STUBMPI + MPI_Comm comm ; + + comm = MPI_Comm_f2c( *Fcomm ) ; +#else + int comm ; +#endif + rsl_lite_allgather_msgs ( mytask_p, ntasks_par_p, ntasks_nest_p, offset_p, comm, 1 ) ; } +/********************************************/ + /* common code */ -rsl_lite_from_peerpoint_info ( ig_p, jg_p, retval_p ) +void rsl_lite_from_peerpoint_info ( ig_p, jg_p, retval_p ) int_p ig_p /* (O) Global index in M dimension of nest. */ ,jg_p /* (O) Global index in N dimension of nest. */ @@ -696,30 +679,31 @@ rsl_lite_from_peerpoint_info ( ig_p, jg_p, retval_p ) } -/********************************************/ - /* parent->nest */ -RSL_LITE_FROM_PARENT_MSG ( len_p, buf ) +void RSL_LITE_FROM_PARENT_INFO ( ig_p, jg_p, retval_p ) int_p - len_p ; /* (I) Number of bytes to unpack. */ - int * - buf ; /* (O) Destination buffer. */ + ig_p /* (O) Global index in M dimension of nest. */ + ,jg_p /* (O) Global index in N dimension of nest. */ + ,retval_p ; /* (O) Return value; =1 valid point, =0 done. */ { - rsl_lite_from_peerpoint_msg ( len_p, buf ) ; + rsl_lite_from_peerpoint_info ( ig_p, jg_p, retval_p ) ; } /* nest->parent */ -RSL_LITE_FROM_CHILD_MSG ( len_p, buf ) +void RSL_LITE_FROM_CHILD_INFO ( ig_p, jg_p, retval_p ) int_p - len_p ; /* (I) Number of bytes to unpack. */ - int * - buf ; /* (O) Destination buffer. */ + ig_p /* (O) Global index in M dimension of nest. */ + ,jg_p /* (O) Global index in N dimension of nest. */ + ,retval_p ; /* (O) Return value; =1 valid point, =0 done. */ { - rsl_lite_from_peerpoint_msg ( len_p, buf ) ; + rsl_lite_from_peerpoint_info ( ig_p, jg_p, retval_p ) ; } + +/********************************************/ + /* common code */ -rsl_lite_from_peerpoint_msg ( len_p, buf ) +void rsl_lite_from_peerpoint_msg ( len_p, buf ) int_p len_p ; /* (I) Number of bytes to unpack. */ int * @@ -744,5 +728,26 @@ rsl_lite_from_peerpoint_msg ( len_p, buf ) Rpointcurs += *len_p ; } +/* parent->nest */ +void RSL_LITE_FROM_PARENT_MSG ( len_p, buf ) + int_p + len_p ; /* (I) Number of bytes to unpack. */ + int * + buf ; /* (O) Destination buffer. */ +{ + rsl_lite_from_peerpoint_msg ( len_p, buf ) ; +} + +/* nest->parent */ +void RSL_LITE_FROM_CHILD_MSG ( len_p, buf ) + int_p + len_p ; /* (I) Number of bytes to unpack. */ + int * + buf ; /* (O) Destination buffer. */ +{ + rsl_lite_from_peerpoint_msg ( len_p, buf ) ; +} + + /********************************************/ diff --git a/external/RSL_LITE/rsl_lite.h b/external/RSL_LITE/rsl_lite.h index da430be967..f3e291350f 100644 --- a/external/RSL_LITE/rsl_lite.h +++ b/external/RSL_LITE/rsl_lite.h @@ -164,6 +164,8 @@ #define RSL_FREE(P) rsl_free(&(P)) char * buffer_for_proc ( int P, int size, int code ) ; +int buffer_size_for_proc( int P, int code ); + void * rsl_malloc( char * f, int l, int s ) ; void rsl_free( char ** p ) ; typedef int * int_p ; @@ -194,3 +196,18 @@ typedef struct rsl_list { #endif } rsl_list_t ; + +void F_PACK_LINT (long *inbuf, long *outbuf, int* memorder, int* js, int* je, int* ks, int* ke, int* is, int* ie, int* jms, int* jme, int* kms, int* kme, int* ims, int* ime, int* curs); +void F_PACK_INT (int *inbuf, int *outbuf, int* memorder, int* js, int* je, int* ks, int* ke, int* is, int* ie, int* jms, int* jme, int* kms, int* kme, int* ims, int* ime, int* curs); +void F_UNPACK_LINT (long *inbuf, long *outbuf, int* memorder, int* js, int* je, int* ks, int* ke, int* is, int* ie, int* jms, int* jme, int* kms, int* kme, int* ims, int* ime, int* curs); +void F_UNPACK_INT (int *inbuf, int *outbuf, int* memorder, int* js, int* je, int* ks, int* ke, int* is, int* ie, int* jms, int* jme, int* kms, int* kme, int* ims, int* ime, int* curs); + +#if ( WRFPLUS == 1 ) +void F_PACK_LINT_AD (long *inbuf, long *outbuf, int* memorder, int* js, int* je, int* ks, int* ke, int* is, int* ie, int* jms, int* jme, int* kms, int* kme, int* ims, int* ime, int* curs); +void F_PACK_INT_AD (int *inbuf, int *outbuf, int* memorder, int* js, int* je, int* ks, int* ke, int* is, int* ie, int* jms, int* jme, int* kms, int* kme, int* ims, int* ime, int* curs); +void F_UNPACK_LINT_AD (long *inbuf, long *outbuf, int* memorder, int* js, int* je, int* ks, int* ke, int* is, int* ie, int* jms, int* jme, int* kms, int* kme, int* ims, int* ime, int* curs); +void F_UNPACK_INT_AD (int *inbuf, int *outbuf, int* memorder, int* js, int* je, int* ks, int* ke, int* is, int* ie, int* jms, int* jme, int* kms, int* kme, int* ims, int* ime, int* curs); +#endif + +int TASK_FOR_POINT ( int* i_p , int* j_p , int* ids_p, int* ide_p , int* jds_p, int* jde_p , int* npx_p , int* npy_p , int* Px_p, int* Py_p , int* minx_p, int* miny_p, int* ierr_p ); +void TASK_FOR_POINT_MESSAGE(); diff --git a/external/RSL_LITE/rsl_malloc.c b/external/RSL_LITE/rsl_malloc.c index 4a4cdd1001..689eed3401 100755 --- a/external/RSL_LITE/rsl_malloc.c +++ b/external/RSL_LITE/rsl_malloc.c @@ -85,7 +85,8 @@ # include "mpi.h" #endif #include "rsl_lite.h" - +#include +#include /* extern int EF_ALIGNMENT; extern int EF_PROTECT_BELOW; diff --git a/external/RSL_LITE/swap.c b/external/RSL_LITE/swap.c index 28ac424d04..5c32380da4 100644 --- a/external/RSL_LITE/swap.c +++ b/external/RSL_LITE/swap.c @@ -2,6 +2,7 @@ # include #endif #include +#include #define STANDARD_ERROR 2 @@ -27,7 +28,7 @@ static int *nbytes = NULL ; static MPI_Request *x_recv = NULL , *x_send = NULL ; #endif -RSL_LITE_INIT_SWAP ( +void RSL_LITE_INIT_SWAP ( int * Fcomm , int * xy0 , int * n3dR0, int *n2dR0, int * typesizeR0 , @@ -119,7 +120,7 @@ RSL_LITE_INIT_SWAP ( #endif } -RSL_LITE_PACK_SWAP ( int * Fcomm , char * buf , int * odd0 , int * typesize0 , int * xy0 , int * pu0 , char * memord , int * xstag0 , +void RSL_LITE_PACK_SWAP ( int * Fcomm , char * buf , int * odd0 , int * typesize0 , int * xy0 , int * pu0 , char * memord , int * xstag0 , int *me0, int * np0 , int * np_x0 , int * np_y0 , int * min_subdomain , int * ids0 , int * ide0 , int * jds0 , int * jde0 , int * kds0 , int * kde0 , @@ -304,7 +305,7 @@ RSL_LITE_PACK_SWAP ( int * Fcomm , char * buf , int * odd0 , int * typesize0 , i #endif } -RSL_LITE_SWAP ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 ) +void RSL_LITE_SWAP ( int * Fcomm0, int *me0, int * np0 , int * np_x0 , int * np_y0 ) { #ifndef STUBMPI int me, np, np_x, np_y ; diff --git a/external/RSL_LITE/task_for_point.c b/external/RSL_LITE/task_for_point.c index b33a03c452..6da4cd5aa5 100644 --- a/external/RSL_LITE/task_for_point.c +++ b/external/RSL_LITE/task_for_point.c @@ -20,8 +20,7 @@ static char tfpmess[1024] ; -TASK_FOR_POINT ( i_p , j_p , ids_p, ide_p , jds_p, jde_p , npx_p , npy_p , Px_p, Py_p , minx_p, miny_p, ierr_p ) - int_p i_p , j_p , Px_p , Py_p , ids_p, ide_p , jds_p, jde_p , npx_p , npy_p, minx_p, miny_p, ierr_p ; +int TASK_FOR_POINT ( int* i_p , int* j_p , int* ids_p, int* ide_p , int* jds_p, int* jde_p , int* npx_p , int* npy_p , int* Px_p, int* Py_p , int* minx_p, int* miny_p, int* ierr_p ) { int i , j , ids, ide, jds, jde, npx, npy, minx, miny ; /* inputs */ int Px, Py ; /* output */ @@ -124,7 +123,7 @@ TASK_FOR_POINT ( i_p , j_p , ids_p, ide_p , jds_p, jde_p , npx_p , npy_p , Px_p, *Py_p = Py ; } -TASK_FOR_POINT_MESSAGE() +void TASK_FOR_POINT_MESSAGE() { fprintf(stderr,"%s\n",tfpmess) ; } diff --git a/external/io_grib1/MEL_grib1/FTP_getfile.c b/external/io_grib1/MEL_grib1/FTP_getfile.c index 8fd4d5f675..08b0820955 100644 --- a/external/io_grib1/MEL_grib1/FTP_getfile.c +++ b/external/io_grib1/MEL_grib1/FTP_getfile.c @@ -1,5 +1,12 @@ #include #include +#include + +#if defined(_WIN32) +#include +#else +#include +#endif #include "dprints.h" /* Debug printing & function prototypes*/ #include "gribfuncs.h" /* function prototypes */ diff --git a/external/io_grib1/MEL_grib1/gribfuncs.h b/external/io_grib1/MEL_grib1/gribfuncs.h index a05f0fde97..42207e457d 100644 --- a/external/io_grib1/MEL_grib1/gribfuncs.h +++ b/external/io_grib1/MEL_grib1/gribfuncs.h @@ -29,12 +29,16 @@ int grib_dec (char *,PDS_INPUT *,grid_desc_sec *,BDS_HEAD_INPUT *, int grib_enc (DATA_INPUT,USER_INPUT,GEOM_IN,float *,GRIB_HDR *,char *); float grib_ibm_local(unsigned long ibm_float); int grib_seek (char *,long *,int,GRIB_HDR *,char *); +int grib_fseek (FILE *, long *, int, GRIB_HDR *, char *); + int gribgetbds (char *,short,BMS_INPUT *,grid_desc_sec *,float **, BDS_HEAD_INPUT *, char *); int gribgetbms (char *,BMS_INPUT *,int,unsigned long,char *); int gribgetgds (char *,grid_desc_sec *,char *); int gribgetpds (char *,PDS_INPUT *,char *); int gribhdr2file (GRIB_HDR *,FILE *,char *); +int gribhdr2filed (GRIB_HDR *, int , char *); + int gribputbds (USER_INPUT,long,short,float *,BDS_HEAD_INPUT *, GRIB_HDR **,char *); int gribputgds (GEOM_IN,GDS_HEAD_INPUT *,void **,GRIB_HDR **,char *); @@ -44,10 +48,12 @@ void init_dec_struct (PDS_INPUT *,grid_desc_sec *,BMS_INPUT *,BDS_HEAD_INPUT *); void init_enc_struct (DATA_INPUT *,GEOM_IN *,USER_INPUT *); int init_gribhdr (GRIB_HDR **,char *); void init_struct (void *, int); -int inp2Grib_Lambert (void **,LAMBERT *,long *,char *); +int inp2grib_Lambert (void **,LAMBERT *,long *,char *); int inp2grib_Latlon (void **,LATLON *,long *,char *); int inp2grib_PDS (PDS_INPUT *,PDS_GRIB **,char *); int inp2grib_PolarSt (void **,POLAR *,long *,char *); +int create_inpMercator (GEOM_IN , void **, char *); +int inp2grib_Mercator (void **, MERCATOR *,long *, char *); int ld_dec_lookup (char *,char *); int ld_enc_config (char *,USER_INPUT *,char *); int ld_enc_ffinfo (char *, DATA_INPUT *,char *); @@ -65,6 +71,11 @@ void prt_inp_struct (PDS_INPUT *,grid_desc_sec *, BMS_INPUT *, struct BDS_HEAD_INPUT *,float **); void upd_child_errmsg (char *,char *); void w3ft33_(float *ain,float **out, int *nsflag); + +void set_bytes(long in, int numbytes, char *out); +void set_bytes_u(unsigned long in, int numbytes, unsigned char *out); +int grib_unthin(float *in,float *out,int *rowsizes, int ysize, int *xsize); + #else #define PROTOTYPE_NEEDED 0 diff --git a/external/io_grib1/MEL_grib1/gribgetbds.c b/external/io_grib1/MEL_grib1/gribgetbds.c index abc3e5264a..f6958a9282 100644 --- a/external/io_grib1/MEL_grib1/gribgetbds.c +++ b/external/io_grib1/MEL_grib1/gribgetbds.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "dprints.h" /* for dprints */ #include "gribfuncs.h" /* prototypes */ diff --git a/external/io_grib1/MEL_grib1/gribhdr2file.c b/external/io_grib1/MEL_grib1/gribhdr2file.c index 41c248bce9..649c46dc0e 100644 --- a/external/io_grib1/MEL_grib1/gribhdr2file.c +++ b/external/io_grib1/MEL_grib1/gribhdr2file.c @@ -2,6 +2,13 @@ #include #include "dprints.h" /* for dprints */ #include "gribfuncs.h" /* prototypes */ + +#if defined(_WIN32) +#include +#else +#include +#endif + /* * ************************************************************************ diff --git a/external/io_grib1/MEL_grib1/init_enc_struct.c b/external/io_grib1/MEL_grib1/init_enc_struct.c index 9e5ce13fd6..dd2a79cdea 100644 --- a/external/io_grib1/MEL_grib1/init_enc_struct.c +++ b/external/io_grib1/MEL_grib1/init_enc_struct.c @@ -5,6 +5,7 @@ */ #include #include +#include #include "dprints.h" /* for dprints */ #include "gribfuncs.h" /* prototypes */ /* diff --git a/external/io_grib1/MEL_grib1/init_gribhdr.c b/external/io_grib1/MEL_grib1/init_gribhdr.c index ea0be9820f..b1580936e5 100644 --- a/external/io_grib1/MEL_grib1/init_gribhdr.c +++ b/external/io_grib1/MEL_grib1/init_gribhdr.c @@ -3,6 +3,7 @@ */ #include #include +#include #include "dprints.h" /* for dprints */ #include "gribfuncs.h" /* prototypes */ /* diff --git a/external/io_grib1/MEL_grib1/init_struct.c b/external/io_grib1/MEL_grib1/init_struct.c index bf81ed176c..5bc0e452ca 100644 --- a/external/io_grib1/MEL_grib1/init_struct.c +++ b/external/io_grib1/MEL_grib1/init_struct.c @@ -6,6 +6,7 @@ */ #include #include +#include #include "dprints.h" /* for dprints */ #include "gribfuncs.h" /* prototypes */ diff --git a/external/io_grib1/MEL_grib1/ld_enc_input.c b/external/io_grib1/MEL_grib1/ld_enc_input.c index b8a911925f..a4979aeb0c 100644 --- a/external/io_grib1/MEL_grib1/ld_enc_input.c +++ b/external/io_grib1/MEL_grib1/ld_enc_input.c @@ -10,6 +10,7 @@ Original version from previous Encoder Library; #include #include #include +#include #include "dprints.h" /* for dprints */ #include "gribfuncs.h" /* prototypes */ diff --git a/external/io_grib1/MEL_grib1/ld_enc_lookup.c b/external/io_grib1/MEL_grib1/ld_enc_lookup.c index 8605aac126..3330d478a2 100644 --- a/external/io_grib1/MEL_grib1/ld_enc_lookup.c +++ b/external/io_grib1/MEL_grib1/ld_enc_lookup.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include "grib_lookup.h" /* combined lookup structs */ #include "dprints.h" /* for dprints */ #include "gribfuncs.h" /* prototypes */ diff --git a/external/io_grib1/MEL_grib1/ld_grib_origctrs.c b/external/io_grib1/MEL_grib1/ld_grib_origctrs.c index 5429eca235..2db15c4b0d 100644 --- a/external/io_grib1/MEL_grib1/ld_grib_origctrs.c +++ b/external/io_grib1/MEL_grib1/ld_grib_origctrs.c @@ -1,6 +1,13 @@ #include #include #include + +#if defined(_WIN32) +#include +#else +#include +#endif + #include "grib_lookup.h" #include "dprints.h" /* for dprints */ #include "gribfuncs.h" /* prototypes */ @@ -153,7 +160,7 @@ FILE *fLook; * * A.7 RETURN with status */ - if (fLook) close(fLook); + if (fLook) fclose(fLook); DPRINT2 ("Exiting %s, Stat=%d\n", func, stat); return (stat); /* diff --git a/external/io_grib1/MEL_grib1/map_lvl.c b/external/io_grib1/MEL_grib1/map_lvl.c index bdbb7651e4..1458d033b9 100644 --- a/external/io_grib1/MEL_grib1/map_lvl.c +++ b/external/io_grib1/MEL_grib1/map_lvl.c @@ -1,5 +1,7 @@ #include #include +#include +#include #include "dprints.h" /* for debug printing */ #include "grib_lookup.h" /* LVL_DEFN */ #include "gribfuncs.h" /* prototypes */ diff --git a/external/io_grib1/MEL_grib1/map_parm.c b/external/io_grib1/MEL_grib1/map_parm.c index 18b2d049ed..83d7ce11b4 100644 --- a/external/io_grib1/MEL_grib1/map_parm.c +++ b/external/io_grib1/MEL_grib1/map_parm.c @@ -1,5 +1,6 @@ #include #include +#include #include "dprints.h" /* for debug printing */ #include "grib_lookup.h" /* PARM_DEFN */ #include "gribfuncs.h" /* prototypes */ diff --git a/external/io_grib1/MEL_grib1/prt_badmsg.c b/external/io_grib1/MEL_grib1/prt_badmsg.c index 2be1ed3383..015806b67b 100644 --- a/external/io_grib1/MEL_grib1/prt_badmsg.c +++ b/external/io_grib1/MEL_grib1/prt_badmsg.c @@ -1,5 +1,6 @@ #include #include +#include #include "gribfuncs.h" /* ************************************************************************** diff --git a/external/io_grib1/MEL_grib1/prt_inp_struct.c b/external/io_grib1/MEL_grib1/prt_inp_struct.c index 250ca780cb..23474ab1ce 100644 --- a/external/io_grib1/MEL_grib1/prt_inp_struct.c +++ b/external/io_grib1/MEL_grib1/prt_inp_struct.c @@ -6,6 +6,7 @@ */ #include #include +#include #include #include "grib_lookup.h" /* for Parm/Ctr/Levl/Mdl_defn */ #include "dprints.h" /* for dprints */ diff --git a/external/io_grib1/MEL_grib1/set_bytes.c b/external/io_grib1/MEL_grib1/set_bytes.c index b7b7aa34c1..6df01fca4b 100644 --- a/external/io_grib1/MEL_grib1/set_bytes.c +++ b/external/io_grib1/MEL_grib1/set_bytes.c @@ -1,4 +1,5 @@ #include +#include #include "isdb.h" void set_bytes(long in, int numbytes, char *out) diff --git a/external/io_grib1/MEL_grib1/upd_child_errmsg.c b/external/io_grib1/MEL_grib1/upd_child_errmsg.c index 500ce68162..d0a795e567 100644 --- a/external/io_grib1/MEL_grib1/upd_child_errmsg.c +++ b/external/io_grib1/MEL_grib1/upd_child_errmsg.c @@ -1,5 +1,6 @@ #include #include +#include #include "dprints.h" /* for dprints */ #include "gribfuncs.h" /* prototypes */ diff --git a/external/io_grib1/grib1_routines.c b/external/io_grib1/grib1_routines.c index 37dd19275f..0052cae0f8 100644 --- a/external/io_grib1/grib1_routines.c +++ b/external/io_grib1/grib1_routines.c @@ -16,17 +16,25 @@ #include "grib1_routines.h" #include "gridnav.h" #include "wrf_projection.h" +#include "trim.h" #include #include #include #include +#include +#include +#if defined(_WIN32) +#include +#else +#include +#endif -char *trim (char *str); int index_metadata(GribInfo *gribinfo, MetaData *metadata, int fid); int index_times(GribInfo *gribinfo, Times *times); int find_time(Times *times, char valid_time[15]); int get_gridnav_projection(int wrf_projection); int get_byte(int input_int, int bytenum); +int grib_time_format(char *DateStr, char *DateStrIn); /* * Allocate space for the fileindex structure diff --git a/external/io_grib1/grib1_util/read_grib.c b/external/io_grib1/grib1_util/read_grib.c index 79757d38d8..c1ebcdcb06 100644 --- a/external/io_grib1/grib1_util/read_grib.c +++ b/external/io_grib1/grib1_util/read_grib.c @@ -49,6 +49,13 @@ #include "gribfuncs.h" #include "gribsize.incl" #include "read_grib.h" +#include "alloc_2d.h" + +#if defined(_WIN32) +#include +#else +#include +#endif /* Function Declarations */ @@ -2267,7 +2274,7 @@ int rg_setup_gribmap(GribParameters *gribmap, char filename[]) gribmap->num_entries = idx; - close(fid); + fclose(fid); return 1; } diff --git a/external/io_grib1/grib1_util/read_grib.h b/external/io_grib1/grib1_util/read_grib.h index f2c628b64b..3a9d73c5cb 100644 --- a/external/io_grib1/grib1_util/read_grib.h +++ b/external/io_grib1/grib1_util/read_grib.h @@ -167,3 +167,4 @@ int rg_get_index_near_date(GribInfo *gribinfo,char targetdate[STRINGSIZE], int rg_get_date(GribInfo *gribinfo,int index); int rg_get_century(GribInfo *gribinfo,int index); int rg_get_forecast_time(GribInfo *gribinfo,int index); +int rg_get_parmtbl(GribInfo *gribinfo, int index); diff --git a/external/io_grib1/grib1_util/write_grib.c b/external/io_grib1/grib1_util/write_grib.c index 79dd956345..29646545cb 100644 --- a/external/io_grib1/grib1_util/write_grib.c +++ b/external/io_grib1/grib1_util/write_grib.c @@ -33,39 +33,14 @@ #include #include +#include #include "gribfuncs.h" -int rg_write_grib(PDS_INPUT *pds, grid_desc_sec *gds, char filename[], - float **data) -{ - char tmpfile[240]; - char tmpstring[240]; - FILE *fid; - int status; - - sprintf(tmpfile,"/tmp/tmpgribfile_%d",getpid()); - fid = fopen(tmpfile,"wb"); - if (fid == NULL) { - fprintf(stderr,"rg_write_grib: Could not open %s\n",tmpfile); - return -1; - } - - status = rg_fwrite_grib(pds,gds,data,fid); - if (status != 1) - { - fprintf(stderr,"rg_write_grib: rg_fwrite_grib failed\n"); - return -1; - } - - /* append tmpfile to filename */ - sprintf(tmpstring,"cat %s >> %s",tmpfile,filename); - system(tmpstring); - unlink(tmpfile); - - close(fid); - - return(1); -} +#if defined(_WIN32) +#include +#else +#include +#endif int rg_fwrite_grib(PDS_INPUT *pds, grid_desc_sec *gds, float **data, FILE *fid) { @@ -188,3 +163,35 @@ int rg_fwrite_grib(PDS_INPUT *pds, grid_desc_sec *gds, float **data, FILE *fid) return 1; } + +int rg_write_grib(PDS_INPUT *pds, grid_desc_sec *gds, char filename[], + float **data) +{ + char tmpfile[240]; + char tmpstring[240]; + FILE *fid; + int status; + + sprintf(tmpfile,"/tmp/tmpgribfile_%d",getpid()); + fid = fopen(tmpfile,"wb"); + if (fid == NULL) { + fprintf(stderr,"rg_write_grib: Could not open %s\n",tmpfile); + return -1; + } + + status = rg_fwrite_grib(pds,gds,data,fid); + if (status != 1) + { + fprintf(stderr,"rg_write_grib: rg_fwrite_grib failed\n"); + return -1; + } + + /* append tmpfile to filename */ + sprintf(tmpstring,"cat %s >> %s",tmpfile,filename); + system(tmpstring); + unlink(tmpfile); + + fclose(fid); + + return(1); +} diff --git a/external/io_grib1/gribmap.c b/external/io_grib1/gribmap.c index 0ad686c2fc..bfd0aa30df 100644 --- a/external/io_grib1/gribmap.c +++ b/external/io_grib1/gribmap.c @@ -1,6 +1,8 @@ #include #include +#include #include "gribmap.h" +#include "trim.h" /****************************************************************************** * diff --git a/external/io_grib1/gribmap.h b/external/io_grib1/gribmap.h index 24b56f1aca..3dd0cf32a3 100644 --- a/external/io_grib1/gribmap.h +++ b/external/io_grib1/gribmap.h @@ -52,5 +52,6 @@ int GET_GRIB1_TABLES_SIZE (int *size); int LOAD_GRIB1_TABLES (char filename[], Grib1_Tables *grib_tables, int *ret, int strlen1); +int FREE_GRIBMAP(Grib1_Tables *grib_tables); Grib1_Tables *copy_grib_tables(Grib1_Tables *); diff --git a/external/io_grib1/trim.c b/external/io_grib1/trim.c index cb219ad645..3f06fbe472 100644 --- a/external/io_grib1/trim.c +++ b/external/io_grib1/trim.c @@ -1,5 +1,6 @@ #include #include +#include char *trim (char *str) { diff --git a/external/io_grib1/trim.h b/external/io_grib1/trim.h new file mode 100644 index 0000000000..550f765a5f --- /dev/null +++ b/external/io_grib1/trim.h @@ -0,0 +1,2 @@ +char *trim (char *str); + diff --git a/external/io_grib_share/get_region_center.c b/external/io_grib_share/get_region_center.c index d708656c1e..68ad5f7bc5 100644 --- a/external/io_grib_share/get_region_center.c +++ b/external/io_grib_share/get_region_center.c @@ -2,6 +2,7 @@ #include "gridnav.h" #include #include +#include #include "wrf_projection.h" diff --git a/external/io_grib_share/open_file.c b/external/io_grib_share/open_file.c index 673b8ff544..b629bddfd8 100644 --- a/external/io_grib_share/open_file.c +++ b/external/io_grib_share/open_file.c @@ -1,9 +1,12 @@ #include #include #include - #ifdef _WIN32 #include +#include +#else +#include +#include #endif #ifndef CRAY diff --git a/frame/pack_utils.c b/frame/pack_utils.c index d7669ccfd5..bdd608d3e1 100644 --- a/frame/pack_utils.c +++ b/frame/pack_utils.c @@ -59,6 +59,7 @@ /* CALL int_pack_data ( hdrbuf , hdrbufsiz * inttypesize , int_local_output_buffer, int_local_output_cursor ) */ +void INT_PACK_DATA ( unsigned char *buf , int *ninbytes , unsigned char *obuf, int *cursor ) { int i, lcurs ; @@ -372,7 +373,7 @@ void *malloc(size_t size) # endif # if !defined(MS_SUA) && !defined(_WIN32) # include -RSL_INTERNAL_MICROCLOCK () +int RSL_INTERNAL_MICROCLOCK () { struct timeval tb ; struct timezone tzp ; diff --git a/tools/gen_config.c b/tools/gen_config.c index fc6573975f..c07be2e919 100644 --- a/tools/gen_config.c +++ b/tools/gen_config.c @@ -5,6 +5,7 @@ #include "registry.h" #include "data.h" #include +#include #ifndef _WIN32 # include #endif diff --git a/tools/gen_irr_diag.c b/tools/gen_irr_diag.c index 40c4219450..13071f239f 100644 --- a/tools/gen_irr_diag.c +++ b/tools/gen_irr_diag.c @@ -5,6 +5,7 @@ #include #include #include +#include int nChmOpts = 0; char rxt_tbl[5][1000][128]; diff --git a/tools/gen_streams.c b/tools/gen_streams.c index f93cf3989d..ad5251ff4d 100644 --- a/tools/gen_streams.c +++ b/tools/gen_streams.c @@ -539,6 +539,7 @@ gen_shutdown_closes ( FILE *fp ) } /* generate the calls that main/wrf_ESMFMod.F uses in wrf_state_populate() */ +int gen_med_open_esmf_calls ( FILE *fp ) { int i ; @@ -569,6 +570,7 @@ gen_med_open_esmf_calls ( FILE *fp ) } /* generate the calls that main/wrf_ESMFMod.F uses in wrf_state_populate() */ +int gen_med_find_esmf_coupling ( FILE *fp ) { int i ; diff --git a/tools/misc.c b/tools/misc.c index e0a00938dc..a794fd692a 100644 --- a/tools/misc.c +++ b/tools/misc.c @@ -6,6 +6,8 @@ # define index(X,Y) strchr(X,Y) #else # include +# include +# include #endif #include "protos.h" diff --git a/tools/protos.h b/tools/protos.h index 0191e8f4af..3d39c2dfa7 100644 --- a/tools/protos.h +++ b/tools/protos.h @@ -30,6 +30,9 @@ int print_warning( FILE * fp , char * fname ) ; int close_the_file( FILE * fp ) ; int make_entries_uniq ( char * fname ) ; int add_warning ( char * fname ) ; +int gen_dummy_decls ( char * dn ); +int gen_dummy_decls_new ( char * dn ); +int gen_i1_decls ( char * dn ); node_t * get_type_entry ( char * typename ) ; node_t * get_rconfig_entry( char * name ) ; @@ -157,6 +160,67 @@ void set_mask ( unsigned int * mask , int e ) ; int get_mask ( unsigned int * mask , int e ) ; int dims_ikj_inner(node_t *); int dims_ij_inner(node_t *); + +char *make_upper_case ( char * str ); +char *make_lower_case ( char * str ); +int sym_forget(); +int init_parser(); +int pre_parse( char * dir, FILE * infile, FILE * outfile ); +int check_dimspecs(); +int set_dim_order ( char * dimorder , node_t * dim_entry ); + +int gen_actual_args ( char * dirname ); +int gen_actual_args_new ( char * dirname ); +int gen_dummy_args ( char * dirname ); +int gen_dummy_args_new ( char * dirname ); +int gen_args ( char * dirname , int sw ); +int gen_args1 ( FILE * fp , char * outstr , char * structname , + node_t * node , int *linelen , int sw , int deep ); + + +int gen_namelist_defines ( char * dirname , int sw_dimension ); +int gen_namelist_defaults ( char * dirname ); +int gen_namelist_statements ( char * dirname ); +int gen_namelist_script ( char * dirname ); +int gen_get_nl_config ( char * dirname ); +int gen_config_assigns ( char * dirname ); +int gen_config_reads ( char * dirname ); + +int as_long(char *str,long *l); +int as_finite_double(char *str,double *d); +int contains_str( char *s1, char *s2 ); +int contains_tok( char *s1, char *s2, char *delims ); +int gen_nest_v_interp ( char * dirname ); +int gen_nest_interp ( char * dirname ); +int gen_nest_interp1 ( FILE * fp , node_t * node, char * fourdname, int down_path , int use_nest_time_level ); +int gen_nest_interp2 ( FILE * fp , node_t * node, char * fourdname, int down_path , int use_nest_time_level ); + + +int gen_streams( char * dirname ); +int gen_io_domain_defs ( FILE * fp ); +int gen_set_timekeeping_defs ( FILE *fp ); +int gen_io_form_for_dataset ( FILE *fp ); +int gen_io_form_for_stream ( FILE *fp ); +int gen_switches_and_alarms ( FILE *fp ); +int gen_check_auxstream_alarms ( FILE *fp ); +int gen_fine_stream_input ( FILE *fp ); +int gen_med_auxinput_in ( FILE *fp ); +int gen_med_hist_out_opens ( FILE *fp ); +int gen_med_hist_out_closes ( FILE *fp ); +int gen_med_auxinput_in_closes ( FILE *fp ); +int gen_med_last_solve_io ( FILE *fp ); +int gen_shutdown_closes ( FILE *fp ); +int gen_med_open_esmf_calls ( FILE *fp ); +int gen_med_find_esmf_coupling ( FILE *fp ); +int gen_io_boilerplate (); + +int gen_comms ( char * dirname ); + +int gen_set_timekeeping_alarms ( FILE * fp ); + +int create_ht(char *** p ); + + #define PROTOS_H #endif diff --git a/tools/reg_parse.c b/tools/reg_parse.c index 01176c0ea4..8e2e1a0fd1 100644 --- a/tools/reg_parse.c +++ b/tools/reg_parse.c @@ -6,6 +6,7 @@ # define index(X,Y) strchr(X,Y) #else # include +# include #endif #include "registry.h" diff --git a/tools/sym.c b/tools/sym.c index de41c2d965..d6977116f5 100644 --- a/tools/sym.c +++ b/tools/sym.c @@ -61,12 +61,43 @@ */ #include +#include +#include "protos.h" #include "sym.h" -extern sym_nodeptr symget() ; +extern sym_nodeptr symget(char *name, sym_nodeptr (*newnode)(), char **(*nodename)(sym_nodeptr), sym_nodeptr *(*nodenext)(sym_nodeptr), char ** symtab, int flag); static char ** symtab ; /* 2-19-90 */ + +sym_nodeptr +new_sym_node() +{ + sym_nodeptr p ; + p = (sym_nodeptr) malloc( sizeof( struct sym_node ) ) ; + p->name = NULL ; + p->next = NULL ; + + return( p ) ; +} + +char ** +node_name(sym_nodeptr p) +{ + char ** x ; + x = &(p->name) ; + return( x ) ; +} + +sym_nodeptr * +node_next(sym_nodeptr p) +{ + sym_nodeptr *x ; + x = &(p->next) ; + return( x ) ; +} + + int sym_init() /* 2-19-90, initialize symbol table package */ { @@ -80,58 +111,29 @@ sym_init() /* 2-19-90, initialize symbol table package */ } sym_nodeptr -sym_add( name ) -char * name ; +sym_add( char * name ) { +/* sym_nodeptr new_sym_node(); char **node_name() ; sym_nodeptr *node_next() ; +*/ return( symget( name, new_sym_node, node_name, node_next, symtab, 1 ) ) ; } sym_nodeptr -sym_get( name ) -char * name ; +sym_get( char * name ) { +/* sym_nodeptr new_sym_node(); char **node_name() ; sym_nodeptr *node_next() ; +*/ return( symget( name, new_sym_node, node_name, node_next, symtab, 0 ) ) ; } -sym_nodeptr -new_sym_node() -{ - void * malloc() ; - sym_nodeptr p ; - p = (sym_nodeptr) malloc( sizeof( struct sym_node ) ) ; - p->name = NULL ; - p->next = NULL ; - - return( p ) ; -} - -char ** -node_name(p) -sym_nodeptr p ; -{ - char ** x ; - x = &(p->name) ; - return( x ) ; -} - -sym_nodeptr * -node_next(p) -sym_nodeptr p ; -{ - sym_nodeptr *x ; - x = &(p->next) ; - return( x ) ; -} - int -show_entry(x) -sym_nodeptr x ; +show_entry(sym_nodeptr x) { int i ; if ( x == NULL ) return(0) ; diff --git a/tools/sym.h b/tools/sym.h index 9431f5d2b8..5480b9d908 100644 --- a/tools/sym.h +++ b/tools/sym.h @@ -89,7 +89,7 @@ struct sym_node int marked ; /* general purpose marker */ } ; -sym_nodeptr sym_add() ; -sym_nodeptr sym_get() ; +sym_nodeptr sym_add(char *) ; +sym_nodeptr sym_get(char *); #endif diff --git a/tools/symtab_gen.c b/tools/symtab_gen.c index 47870f6c88..a6ddcf9661 100644 --- a/tools/symtab_gen.c +++ b/tools/symtab_gen.c @@ -32,25 +32,24 @@ For a sample main or calling program see the end of this file. */ #include +#include #include #ifndef _WIN32 # include #endif +#include "protos.h" #define HASHSIZE 1024 /* commented out 2-29-90 static char * symtab[HASHSIZE] ; */ - +/* void * malloc() ; void * calloc() ; +*/ -char * symget(name,newnode,nodename,nodenext,symtab,flag) -char *name ; -char *(*newnode)(), **(*nodename)(), **(*nodenext)() ; -char *symtab[] ; -int flag ; /* 1 is create if not there, 0 return NULL if not there */ +char * symget(char *name,char *(*newnode)(),char **(*nodename)(char *),char **(*nodenext)(char *), char *symtab[], int flag) /* flag = 1 is create if not there, 0 return NULL if not there */ { int index ; int found ; @@ -94,9 +93,7 @@ int flag ; /* 1 is create if not there, 0 return NULL if not there */ return(p) ; } -int -hash(name) -char * name ; +int hash(char * name ) { register int result = 0 ; register char * p = name ; @@ -113,9 +110,7 @@ char * name ; /* added 2-19-90, attaches a new hash table to pointer */ -int -create_ht( p ) -char *** p ; +int create_ht(char *** p ) { *p = (char **) calloc( HASHSIZE , sizeof( char * ) ) ; return(0) ; @@ -130,11 +125,7 @@ function to each entry */ -int -sym_traverse( ht, nodenext, f ) -char *ht[] ; -char **(*nodenext)() ; -void (*f)() ; +int sym_traverse( char *ht[] , char **(*nodenext)(char *), void (*f)(char *) ) { char * p, **x ; int i ; @@ -173,25 +164,20 @@ struct symnode { extern struct symnode * symget() ; -struct symnode * -newnode() +struct symnode * newnode() { struct symnode * malloc() ; return( malloc( sizeof( struct symnode ) ) ) ; } -char ** -nodename(p) -struct symnode *p ; +char ** nodename(struct symnode *p) { char ** x ; x = &(p->name) ; return( x ) ; } -struct symnode ** -nodenext(p) -struct symnode *p ; +struct symnode ** nodenext(struct symnode *p) { struct symnode **x ; x = &(p->next) ; From 45215e0808eb5b234c36f92977d20f5cdf3bec1d Mon Sep 17 00:00:00 2001 From: weiwangncar Date: Fri, 8 Dec 2023 19:52:15 -0700 Subject: [PATCH 08/14] add compilation stanza for Intel oneAPI for 4.5.2 (#1946) TYPE: enhancement KEYWORDS: Intel, LLVM, oneAPI, compilation SOURCE: internal DESCRIPTION OF CHANGES: Problem: Addressing issue #1884 for Intel oneAPI ifx/icx builds Solution: Add configuration to configure.defaults mirroring original Intel ifort/icc build with minor tweaking. ISSUE: For use when this PR closes an issue. Fixes #1884 LIST OF MODIFIED FILES: M arch/configure.defaults TESTS CONDUCTED: 1. WRF core em_real compiles with ifx/icx in combination with PR-1823. 2. The Jenkins tests are all passing. Note that this is the same PR as in #1893, but committed to release-v4.5.2 branch (instead of develop) RELEASE NOTE: Added build configuration for new Intel oneAPI LLVM ifx/icx compilers, which will be available on NCAR's new computer, Derecho. --- arch/configure.defaults | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/arch/configure.defaults b/arch/configure.defaults index 597963ffbf..84b38a1132 100644 --- a/arch/configure.defaults +++ b/arch/configure.defaults @@ -2124,6 +2124,52 @@ NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD #insert new stanza here +########################################################### +#ARCH Linux x86_64 ppc64le i486 i586 i686, Intel oneAPI compiler with icx #serial smpar dmpar dm+sm +# This mirrors the above Intel build but changes ifort=>ifx icc=>icx + +DESCRIPTION = INTEL ($SFC/$SCC) : oneAPI LLVM +DMPARALLEL = # 1 +OMPCPP = # -D_OPENMP +OMP = # -qopenmp -fpp -auto +OMPCC = # -qopenmp -auto +SFC = ifx +SCC = icx +CCOMP = icx +DM_FC = mpif90 -f90=$(SFC) +DM_CC = mpicc -cc=$(SCC) +FC = CONFIGURE_FC +CC = CONFIGURE_CC +LD = $(FC) +RWORDSIZE = CONFIGURE_RWORDSIZE +PROMOTION = -real-size `expr 8 \* $(RWORDSIZE)` -i4 +ARCH_LOCAL = -DNONSTANDARD_SYSTEM_FUNC CONFIGURE_D_CTSM +CFLAGS_LOCAL = -w -O3 -ip #-xHost -fp-model fast=2 -no-prec-div -no-prec-sqrt -ftz -no-multibyte-chars # -DRSL0_ONLY +LDFLAGS_LOCAL = -ip #-xHost -fp-model fast=2 -no-prec-div -no-prec-sqrt -ftz -align all -fno-alias -fno-common +CPLUSPLUSLIB = +ESMF_LDFLAG = $(CPLUSPLUSLIB) +FCOPTIM = -O3 +FCREDUCEDOPT = $(FCOPTIM) +FCNOOPT = -O0 -fno-inline -no-ip +FCDEBUG = # -g $(FCNOOPT) -traceback # -fpe0 -check noarg_temp_created,bounds,format,output_conversion,pointers,uninit -ftrapuv -unroll0 -u +FORMAT_FIXED = -FI +FORMAT_FREE = -FR +FCSUFFIX = +BYTESWAPIO = -convert big_endian +RECORDLENGTH = -assume byterecl +FCBASEOPTS_NO_G = -ip -fp-model precise -w -ftz -align all -fno-alias $(FORMAT_FREE) $(BYTESWAPIO) #-xHost -fp-model fast=2 -no-heap-arrays -no-prec-div -no-prec-sqrt -fno-common +FCBASEOPTS = $(FCBASEOPTS_NO_G) $(FCDEBUG) +MODULE_SRCH_FLAG = +TRADFLAG = CONFIGURE_TRADFLAG +CPP = /lib/cpp CONFIGURE_CPPFLAGS +AR = ar +ARFLAGS = ru +M4 = m4 +RANLIB = ranlib +RLFLAGS = +CC_TOOLS = $(SCC) +NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD + ########################################################### #ARCH Linux aarch64, GCC compiler OpenMPI # serial smpar dmpar dm+sm # From eaff759af7f8961b8605bd3488449042b9140a14 Mon Sep 17 00:00:00 2001 From: juntangc <107206367+juntangc@users.noreply.github.com> Date: Sat, 9 Dec 2023 20:23:19 -0600 Subject: [PATCH 09/14] add default for Arm Compiler (#1888) Add compiler option for armclang/armflang. TYPE: enhancement KEYWORDS: Arm Compiler for Linux SOURCE: Jun Tang (Amazon) DESCRIPTION OF CHANGES: Add compile defaults for Arm Compiler for Linux. LIST OF MODIFIED FILES: M arch/configure.defaults TESTS CONDUCTED: - Tested the latest Arm compiler with this configuration. It shows 3% performance improvement on CONUS 12km benchmark. - The Jenkins tests are all passing. RELEASE NOTE: This PR adds compiler option for armclang/armflang. --- arch/configure.defaults | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/arch/configure.defaults b/arch/configure.defaults index 84b38a1132..36ca1b6e00 100644 --- a/arch/configure.defaults +++ b/arch/configure.defaults @@ -2170,6 +2170,46 @@ RLFLAGS = CC_TOOLS = $(SCC) NETCDFPAR_BUILD = CONFIGURE_NETCDFPAR_BUILD +########################################################### +#ARCH Linux aarch64, armclang compiler OpenMPI # serial smpar dmpar dm+sm +# +DESCRIPTION = armclang ($SFC/$SCC): Aarch64 +DMPARALLEL = +OMPCPP = -fopenmp +OMP = -fopenmp +OMPCC = -fopenmp +SFC = armflang +SCC = armclang +CCOMP = armclang +DM_FC = mpif90 +DM_CC = mpicc -DMPI2_SUPPORT +FC = CONFIGURE_FC +CC = CONFIGURE_CC +LD = $(FC) +RWORDSIZE = CONFIGURE_RWORDSIZE +PROMOTION = +ARCH_LOCAL = +CFLAGS_LOCAL = -w -O3 -c -Wno-implicit-function-declaration -Wno-int-conversion -Wno-implicit-int +LDFLAGS_LOCAL = -fopenmp +FCOPTIM = -Ofast -mcpu=native -funroll-loops +FCREDUCEDOPT = $(FCOPTIM) +FCNOOPT = -O0 -fopenmp -frecursive +FCDEBUG = -g $(FCNOOPT) +FORMAT_FIXED = -ffixed-form -ffixed-line-length-0 +FORMAT_FREE = -ffree-form -ffree-line-length-0 +FCSUFFIX = +BYTESWAPIO = -fconvert=big-endian -frecord-marker=4 +FCBASEOPTS = -w $(FORMAT_FREE) $(BYTESWAPIO) +MODULE_SRCH_FLAG= -I$(WRF_SRC_ROOT_DIR)/main +TRADFLAG = -traditional-cpp +CPP = /lib/cpp CONFIGURE_CPPFLAGS +AR = ar +ARFLAGS = ru +M4 = m4 -B 14000 +RANLIB = ranlib +RLFLAGS = +CC_TOOLS = $(SCC) -Wno-implicit-function-declaration -Wno-int-conversion -Wno-implicit-int + ########################################################### #ARCH Linux aarch64, GCC compiler OpenMPI # serial smpar dmpar dm+sm # From d69761a6bcd542c911c23bb6225cae416c479dc7 Mon Sep 17 00:00:00 2001 From: Timothy Brown Date: Sun, 10 Dec 2023 02:26:45 +0000 Subject: [PATCH 10/14] Changing how Config.pl looks for the HDF5 high-level fortran library. (#1934) Changing how Config.pl looks for the HDF5 high-level fortran library. TYPE: enhancement KEYWORDS: HDF5, high-level, fortran, library SOURCE: Timothy Brown (AWS) DESCRIPTION OF CHANGES: Problem: Depending on the installation type (autotools or cmake) of HDF5 the high-level fortran library can be either `hdf5_hl_fortran` or `hdf5hl_fortran`. Solution: In `Config.pl` we now check the HDF5 library directory for the high-level fortran library. ISSUE: Fixes [manual WRF build with Spack](https://github.com/aws-samples/aws-hpc-tutorials/issues/452) LIST OF MODIFIED FILES: M arch/Config.pl TESTS CONDUCTED: 1. Yes. I have configured and built WRF against installs of HDF5 where the high-level fortran library has been a. hdf5_hl_fortran b. hdf5hl_fortran c. hdf5_hl_fortran and hdf5hl_fortran 2. Passed the Jenkins tests. RELEASE NOTE: Config.pl now tests for the HDF5 high-level fortran library. --- arch/Config.pl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/Config.pl b/arch/Config.pl index 9585dfd3a1..385d9adeb2 100644 --- a/arch/Config.pl +++ b/arch/Config.pl @@ -49,6 +49,7 @@ $sw_time = "" ; # name of a timer to time fortran compiles, e.g. timex or time $sw_ifort_r8 = 0 ; $sw_hdf5 = "-lhdf5_hl -lhdf5"; +$sw_hdf5_hl_fortran="-lhdf5_hl_fortran"; $sw_zlib = "-lz"; $sw_dep_lib_path = ""; $sw_gpfs_path = ""; @@ -349,6 +350,15 @@ $sw_ctsm_mkfile_path = $ENV{WRF_CTSM_MKFILE}; } +if ( $sw_hdf5_path ) { + opendir(my $dh, "$sw_hdf5_path/lib"); + ($hl) = grep(/hdf5hl_fortran/i, readdir $dh); + closedir($dh); + if ($hl ne "") { + $sw_hdf5_hl_fortran="-lhdf5hl_fortran"; + } +} + # parse the configure.wrf file $validresponse = 0 ; @@ -453,6 +463,7 @@ } else { $sw_terrain_and_landuse =" -DLANDREAD_STUB=1" ; } + open CONFIGURE_DEFAULTS, "cat ./arch/configure.defaults |" ; $latchon = 0 ; while ( ) @@ -732,7 +743,7 @@ } if ( $sw_hdf5_path ) - { $_ =~ s:CONFIGURE_HDF5_LIB_PATH:-L$sw_hdf5_path/lib -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lm -lz: ; + { $_ =~ s:CONFIGURE_HDF5_LIB_PATH:-L$sw_hdf5_path/lib $sw_hdf5_hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lm -lz: ; $_ =~ s:CONFIGURE_HDF5_FLAG:-DHDF5: ; } else @@ -1120,7 +1131,7 @@ } if ( $sw_hdf5_path ) - { $_ =~ s:CONFIGURE_HDF5_LIB_PATH:-L$sw_hdf5_path/lib -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lm -lz: ; + { $_ =~ s:CONFIGURE_HDF5_LIB_PATH:-L$sw_hdf5_path/lib $sw_hdf5_hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lm -lz: ; $_ =~ s:CONFIGURE_HDF5_FLAG:-DHDF5: ; } else @@ -1200,4 +1211,3 @@ printf "Configuration successful! \n" ; printf "------------------------------------------------------------------------\n" ; - From bb406d2e65f5f3f0029bc27696f0b561caf96d20 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Fri, 15 Dec 2023 22:25:51 -0500 Subject: [PATCH 11/14] Improve NetCDF detection and linking (#1923) TYPE: enhancement KEYWORDS: NetCDF4, Spack-Stack, gfortran SOURCE: David Robertson, Rutgers University DESCRIPTION OF CHANGES: Problem: - NetCDF4 detection and linking is unreliable and impossible if NetCDF-C and NetCDF-Fortran reside in different directories - gfortran is intolerant of non-initialized variables in **`mediation_integrate.F`**. Solution: - Refactor the detection and configuration of NetCDF dependencies and add the capability to use NetCDF-C and NetCDF-Fortran libraries that don't reside in the same directory by introducing a new variable for the NetCDF-C path. - The **fname** and **n2** `intent(out)` variables are not assigned under certain circumstances so we should initialize them to empty strings. ``` ierr = 0 fname = "" n2 = "" ! Note that computation of fname and n2 are outside of the oid IF statement ``` LIST OF MODIFIED FILES: list of changed files (used `git diff --name-status release-v4.5.2` to get formatted list) ``` M Makefile M arch/Config.pl M arch/postamble M arch/preamble M configure M share/mediation_integrate.F ``` TESTS CONDUCTED: 1. Compiled and ran with several different configurations of NetCDF, including both shared and static versions of both split (NetCDF-C and NetCDF-Fortran in separate directories) and unified library locations. The shared library versions were from Spack-Stack; the static libraries were custom-built for my systems. 2. Ran the coupled WRF-ROMS standard test case for Hurricane Irene. 3. The Jenkins tests are all passing. RELEASE NOTE: This PR improve the detection and linking with shared and static configurations of the NetCDF-4 libraries (split or unified) inside and outside Spack-Stack. --- Makefile | 38 ++++---- arch/Config.pl | 12 +-- arch/postamble | 15 +-- arch/preamble | 3 +- configure | 176 ++++++++++++++---------------------- share/mediation_integrate.F | 2 + 6 files changed, 106 insertions(+), 140 deletions(-) diff --git a/Makefile b/Makefile index 6391659ea7..2bdff94d81 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ configcheck: echo "------------------------------------------------------------------------------" ; \ exit 21 ; \ fi - + framework_only : configcheck $(MAKE) MODULE_DIRS="$(ALL_MODULES)" ext @@ -154,7 +154,7 @@ wrfplus : configcheck @echo "build started: $(START_OF_COMPILE)" @echo "build completed:" `date` -all_wrfvar : +all_wrfvar : $(MAKE) MODULE_DIRS="$(DA_WRFVAR_MODULES)" ext $(MAKE) MODULE_DIRS="$(DA_WRFVAR_MODULES)" toolsdir if [ $(CRTM) -ne 0 ] ; then \ @@ -498,7 +498,7 @@ em_scm_xy : wrf ln -sf ../../run/LANDUSE.TBL . ; \ ln -sf ../../run/SOILPARM.TBL . ; \ ln -sf ../../run/VEGPARM.TBL . ; \ - ln -sf ../../run/RRTM_DATA . ) + ln -sf ../../run/RRTM_DATA . ) ( cd run ; /bin/rm -f ideal.exe ; ln -s ../main/ideal.exe . ) ( cd run ; if test -f namelist.input ; then \ /bin/cp -f namelist.input namelist.input.backup.`date +%Y-%m-%d_%H_%M_%S` ; fi ; \ @@ -529,11 +529,11 @@ convert_em : framework_only ( cd main ; $(MAKE) RLFLAGS="$(RLFLAGS)" MODULE_DIRS="$(ALL_MODULES)" convert_em ) ; \ fi -# Link wrf.exe and wrf_SST_ESMF.exe into -# test/em_esmf_exp when ESMF_COUPLING is set. wrf.exe -# can be used for stand-alone testing in this case. -# wrf_SST_ESMF.exe is a coupled application. Note that make -# target $(SOLVER)_wrf_SST_ESMF builds wrf_SST_ESMF.exe. +# Link wrf.exe and wrf_SST_ESMF.exe into +# test/em_esmf_exp when ESMF_COUPLING is set. wrf.exe +# can be used for stand-alone testing in this case. +# wrf_SST_ESMF.exe is a coupled application. Note that make +# target $(SOLVER)_wrf_SST_ESMF builds wrf_SST_ESMF.exe. em_real : wrf @/bin/rm -f real.exe > /dev/null 2>&1 @/bin/rm -f tc.exe > /dev/null 2>&1 @@ -923,31 +923,31 @@ framework : @ echo '--------------------------------------' ( cd frame ; $(MAKE) $(J) LLIST="$(LINKLIST)" framework ; \ cd ../external/io_netcdf ; \ - $(MAKE) NETCDFPATH="$(NETCDFPATH)" \ + $(MAKE) NETCDFPATH="$(NETCDFPATH)" NETCDF4_DEP_LIB="$(NETCDF4_DEP_LIB)" \ FC="$(FC) $(FCBASEOPTS) $(PROMOTION) $(FCDEBUG) $(OMP)" RANLIB="$(RANLIB)" \ CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" TRADFLAG="$(TRADFLAG)" ESMF_IO_LIB_EXT="$(ESMF_IO_LIB_EXT)" \ LIB_LOCAL="$(LIB_LOCAL)" \ ESMF_MOD_DEPENDENCE="$(ESMF_MOD_DEPENDENCE)" AR="INTERNAL_BUILD_ERROR_SHOULD_NOT_NEED_AR" diffwrf; \ cd ../io_netcdf ; \ - $(MAKE) NETCDFPATH="$(NETCDFPATH)" \ + $(MAKE) NETCDFPATH="$(NETCDFPATH)" NETCDF4_DEP_LIB="$(NETCDF4_DEP_LIB)" \ FC="$(SFC) $(FCBASEOPTS) $(PROMOTION) $(FCDEBUG) $(OMP)" RANLIB="$(RANLIB)" \ CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" TRADFLAG="$(TRADFLAG)" ESMF_IO_LIB_EXT="$(ESMF_IO_LIB_EXT)" \ LIB_LOCAL="$(LIB_LOCAL)" \ ESMF_MOD_DEPENDENCE="$(ESMF_MOD_DEPENDENCE)" AR="INTERNAL_BUILD_ERROR_SHOULD_NOT_NEED_AR"; \ cd ../io_netcdfpar ; \ - $(NETCDFPAR_BUILD) $(MAKE) NETCDFPARPATH="$(NETCDFPATH)" \ + $(NETCDFPAR_BUILD) $(MAKE) NETCDFPARPATH="$(NETCDFPATH)" NETCDF4_DEP_LIB="$(NETCDF4_DEP_LIB)" \ FC="$(FC) $(FCBASEOPTS) $(PROMOTION) $(FCDEBUG) $(OMP)" RANLIB="$(RANLIB)" \ CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" TRADFLAG="$(TRADFLAG)" ESMF_IO_LIB_EXT="$(ESMF_IO_LIB_EXT)" \ LIB_LOCAL="$(LIB_LOCAL)" \ ESMF_MOD_DEPENDENCE="$(ESMF_MOD_DEPENDENCE)" AR="INTERNAL_BUILD_ERROR_SHOULD_NOT_NEED_AR" diffwrf; \ cd ../io_netcdfpar ; \ - $(NETCDFPAR_BUILD) $(MAKE) NETCDFPARPATH="$(NETCDFPATH)" \ + $(NETCDFPAR_BUILD) $(MAKE) NETCDFPARPATH="$(NETCDFPATH)" NETCDF4_DEP_LIB="$(NETCDF4_DEP_LIB)" \ FC="$(SFC) $(FCBASEOPTS) $(PROMOTION) $(FCDEBUG) $(OMP)" RANLIB="$(RANLIB)" \ CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" TRADFLAG="$(TRADFLAG)" ESMF_IO_LIB_EXT="$(ESMF_IO_LIB_EXT)" \ LIB_LOCAL="$(LIB_LOCAL)" \ ESMF_MOD_DEPENDENCE="$(ESMF_MOD_DEPENDENCE)" AR="INTERNAL_BUILD_ERROR_SHOULD_NOT_NEED_AR"; \ cd ../io_pio ; \ - echo SKIPPING PIO BUILD $(MAKE) NETCDFPATH="$(PNETCDFPATH)" \ + echo SKIPPING PIO BUILD $(MAKE) NETCDFPATH="$(PNETCDFPATH)" NETCDF4_DEP_LIB="$(NETCDF4_DEP_LIB)" \ FC="$(SFC) $(FCBASEOPTS) $(PROMOTION) $(FCDEBUG) $(OMP)" RANLIB="$(RANLIB)" \ CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" TRADFLAG="$(TRADFLAG)" ESMF_IO_LIB_EXT="$(ESMF_IO_LIB_EXT)" \ LIB_LOCAL="$(LIB_LOCAL)" \ @@ -964,13 +964,13 @@ framework_plus : @ echo '--------------------------------------' ( cd frame ; $(MAKE) $(J) LLIST="$(MODLL)" framework ; \ cd ../external/io_netcdf ; \ - $(MAKE) NETCDFPATH="$(NETCDFPATH)" \ + $(MAKE) NETCDFPATH="$(NETCDFPATH)" NETCDF4_DEP_LIB="$(NETCDF4_DEP_LIB)" \ FC="$(FC) $(FCBASEOPTS) $(PROMOTION) $(FCDEBUG) $(OMP)" RANLIB="$(RANLIB)" \ CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" TRADFLAG="$(TRADFLAG)" ESMF_IO_LIB_EXT="$(ESMF_IO_LIB_EXT)" \ LIB_LOCAL="$(LIB_LOCAL)" \ ESMF_MOD_DEPENDENCE="$(ESMF_MOD_DEPENDENCE)" AR="INTERNAL_BUILD_ERROR_SHOULD_NOT_NEED_AR" diffwrf; \ cd ../io_netcdf ; \ - $(MAKE) NETCDFPATH="$(NETCDFPATH)" \ + $(MAKE) NETCDFPATH="$(NETCDFPATH)" NETCDF4_DEP_LIB="$(NETCDF4_DEP_LIB)" \ FC="$(SFC) $(FCBASEOPTS) $(PROMOTION) $(FCDEBUG) $(OMP)" RANLIB="$(RANLIB)" \ CPP="$(CPP)" LDFLAGS="$(LDFLAGS)" TRADFLAG="$(TRADFLAG)" ESMF_IO_LIB_EXT="$(ESMF_IO_LIB_EXT)" \ LIB_LOCAL="$(LIB_LOCAL)" \ @@ -1070,9 +1070,9 @@ fseek_test : # rule used by configure to test if this will compile with netcdf4 nc4_test: if [ -z "$(USENETCDFPAR)" ] || [ $(USENETCDFPAR) -eq 0 ] ; then \ - ( cd tools ; /bin/rm -f nc4_test.{exe,nc,o} ; $(SCC) -o nc4_test.exe nc4_test.c -I$(NETCDF)/include -L$(NETCDF)/lib -lnetcdf $(NETCDF4_DEP_LIB) ; cd .. ) ; \ + ( cd tools ; /bin/rm -f nc4_test.{exe,nc,o} ; $(SCC) -o nc4_test.exe nc4_test.c -I$(NETCDF_C)/include $(NETCDF4_DEP_LIB) ; cd .. ) ; \ else \ - ( cd tools ; /bin/rm -f nc4_test.{exe,nc,o} ; $(DM_CC) -o nc4_test.exe nc4_test.c -I$(NETCDF)/include -L$(NETCDF)/lib -lnetcdf $(NETCDF4_DEP_LIB) ; cd .. ) ; \ + ( cd tools ; /bin/rm -f nc4_test.{exe,nc,o} ; $(DM_CC) -o nc4_test.exe nc4_test.c -I$(NETCDF_C)/include $(NETCDF4_DEP_LIB) ; cd .. ) ; \ fi # rule used by configure to test if Fortran 2003 IEEE signaling is available @@ -1110,8 +1110,8 @@ toolsdir : # ( cd tools ; $(MAKE) CC_TOOLS="$(CC_TOOLS) -DIO_MASK_SIZE=$(IO_MASK_SIZE)" ) -# Use this target to build stand-alone tests of esmf_time_f90. -# Only touches external/esmf_time_f90/. +# Use this target to build stand-alone tests of esmf_time_f90. +# Only touches external/esmf_time_f90/. esmf_time_f90_only : @ echo '--------------------------------------' ( cd external/esmf_time_f90 ; $(MAKE) FC="$(FC) $(FCFLAGS)" CPP="$(CPP) -DTIME_F90_ONLY" tests ) diff --git a/arch/Config.pl b/arch/Config.pl index 385d9adeb2..761c540abe 100644 --- a/arch/Config.pl +++ b/arch/Config.pl @@ -51,7 +51,7 @@ $sw_hdf5 = "-lhdf5_hl -lhdf5"; $sw_hdf5_hl_fortran="-lhdf5_hl_fortran"; $sw_zlib = "-lz"; -$sw_dep_lib_path = ""; +$sw_netcdf4_dep_lib = ""; $sw_gpfs_path = ""; $sw_gpfs_lib = "-lgpfs"; $sw_curl_path = ""; @@ -70,10 +70,10 @@ { $sw_netcdf_path = substr( $ARGV[0], 8 ) ; } - if ( substr( $ARGV[0], 1, 13 ) eq "dep_lib_path=" ) + if ( substr( $ARGV[0], 1, 16 ) eq "netcdf4_dep_lib=" ) { - $sw_dep_lib_path = substr( $ARGV[0], 14 ) ; - $sw_dep_lib_path =~ s/\r|\n/ /g ; + $sw_netcdf4_dep_lib = substr( $ARGV[0], 17 ) ; + $sw_netcdf4_dep_lib =~ s/\r|\n/ /g ; } if ( substr( $ARGV[0], 1, 5 ) eq "gpfs=" ) { @@ -1050,7 +1050,7 @@ $_ =~ s/CONFIGURE_CONFIG_NUM/Compiler choice: $response_opt/g ; $_ =~ s/CONFIGURE_CONFIG_NEST/Nesting option: $response_nesting/g ; - $_ =~ s/CONFIGURE_DEP_LIB_PATH/$sw_dep_lib_path/g ; + $_ =~ s/CONFIGURE_NETCDF4_DEP_LIB/$sw_netcdf4_dep_lib/g ; $_ =~ s/CONFIGURE_COMMS_LIB/$sw_comms_lib/g ; if ( $sw_os ne "CYGWIN_NT" ) { @@ -1180,7 +1180,7 @@ $_ .= " " . $sw_curl_lib . "\n" ; } } - if ( $sw_dep_lib_path ne "" ) + if ( $sw_netcdf4_dep_lib ne "" ) { if (/^HDF5.*=/) { $_ =~ s/\r|\n//g; $_ .= " " . $sw_hdf5 . "\n" ; diff --git a/arch/postamble b/arch/postamble index 061fb4e0da..936f0405c8 100644 --- a/arch/postamble +++ b/arch/postamble @@ -94,15 +94,16 @@ module_dm_rsllite : ( if [ ! -e module_dm.F ] ; then /bin/cp module_dm_warning module_dm.F ; \ cat $(WRF_SRC_ROOT_DIR)/external/RSL_LITE/module_dm.F >> module_dm.F ; fi ) -wrfio_nf : +wrfio_nf : ( cd $(WRF_SRC_ROOT_DIR)/external/io_netcdf ; \ make $(J) NETCDFPATH="$(NETCDFPATH)" RANLIB="$(RANLIB)" CPP="$(CPP)" \ - CC="$(SCC)" CFLAGS="$(CFLAGS)" \ + CC="$(SCC)" CFLAGS="$(CFLAGS)" NETCDF4_DEP_LIB="$(NETCDF4_DEP_LIB)" \ FC="$(SFC) $(PROMOTION) $(OMP) $(FCFLAGS)" TRADFLAG="$(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" ) wrfio_nfpar : ( cd $(WRF_SRC_ROOT_DIR)/external/io_netcdfpar ; \ make $(J) NETCDFPARPATH="$(NETCDFPATH)" RANLIB="$(RANLIB)" CPP="$(CPP) $(ARCHFLAGS)" \ + NETCDF4_DEP_LIB="$(NETCDF4_DEP_LIB)" \ FC="$(FC) $(PROMOTION) $(OMP) $(FCFLAGS)" TRADFLAG="$(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" ) wrfio_pnf : @@ -118,7 +119,7 @@ wrfio_adios2 : wrfio_grib_share : ( cd $(WRF_SRC_ROOT_DIR)/external/io_grib_share ; \ make $(J) CC="$(SCC)" CFLAGS="$(CFLAGS)" RM="$(RM)" RANLIB="$(RANLIB)" CPP="$(CPP)" \ - FC="$(SFC) $(PROMOTION) -I. $(FCDEBUG) $(FCBASEOPTS) $(FCSUFFIX)" TRADFLAG="$(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" archive) + FC="$(SFC) $(PROMOTION) -I. $(FCDEBUG) $(FCBASEOPTS) $(FCSUFFIX)" TRADFLAG="$(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" archive) wrfio_grib1 : ( cd $(WRF_SRC_ROOT_DIR)/external/io_grib1 ; \ @@ -132,13 +133,13 @@ wrfio_grib2 : FC="$(SFC) $(PROMOTION) -I. $(FCDEBUG) $(FCBASEOPTS) $(FCSUFFIX)" TRADFLAG="-traditional" AR="$(AR)" ARFLAGS="$(ARFLAGS)" \ FIXED="$(FORMAT_FIXED)" archive) -wrfio_int : +wrfio_int : ( cd $(WRF_SRC_ROOT_DIR)/external/io_int ; \ make $(J) CC="$(CC)" CFLAGS_LOCAL="$(CFLAGS_LOCAL)" RM="$(RM)" RANLIB="$(RANLIB)" CPP="$(CPP)" \ FC="$(FC) $(PROMOTION) $(FCDEBUG) $(FCBASEOPTS) $(OMP)" FGREP="$(FGREP)" \ TRADFLAG="$(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" ARCHFLAGS="$(ARCHFLAGS)" all ) -esmf_time : +esmf_time : ( cd $(WRF_SRC_ROOT_DIR)/external/esmf_time_f90 ; \ make $(J) FC="$(SFC) $(PROMOTION) $(FCDEBUG) $(FCBASEOPTS)" RANLIB="$(RANLIB)" \ CPP="$(CPP) -I$(WRF_SRC_ROOT_DIR)/inc -I. $(ARCHFLAGS) $(TRADFLAG)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" ) @@ -201,12 +202,12 @@ wrfio_esmf : mv $*.f90.tmp $*.f90 ; \ fi $(FC) -o $@ -c $(FCFLAGS) $(OMP) $(MODULE_DIRS) $(PROMOTION) $(FCSUFFIX) $*.f90 - + .F.f90: $(RM) $@ sed -e "s/^\!.*'.*//" -e "s/^ *\!.*'.*//" $*.F > $*.G - $(SED_FTN) $*.G > $*.H + $(SED_FTN) $*.G > $*.H $(CPP) -I$(WRF_SRC_ROOT_DIR)/inc $(CPPFLAGS) $*.H > $@ $(RM) $*.G $*.H diff --git a/arch/preamble b/arch/preamble index ab97abbb4b..4543411e6f 100644 --- a/arch/preamble +++ b/arch/preamble @@ -94,8 +94,7 @@ GPFS = CURL = HDF5 = ZLIB = -DEP_LIB_PATH = CONFIGURE_DEP_LIB_PATH -NETCDF4_DEP_LIB = $(DEP_LIB_PATH) $(HDF5) $(ZLIB) $(GPFS) $(CURL) +NETCDF4_DEP_LIB = CONFIGURE_NETCDF4_DEP_LIB # NETCDF4INCLUDEGOESHERE diff --git a/configure b/configure index 27b01b19ce..41243e2813 100755 --- a/configure +++ b/configure @@ -50,7 +50,7 @@ if [ -n "$print_usage" ] ; then echo '-help print this message' echo '*****************************************************************************' echo ' ' - exit + exit fi if `pwd | grep ' ' > /dev/null ` ; then @@ -123,7 +123,7 @@ do else echo "$ac_t""found $ac_prog_where ($PERL)" 1>&1 fi - PERLFULLPATH=$ac_prog_where + PERLFULLPATH=$ac_prog_where else if test -z "$ac_echo_test" -a 1 = 1 ; then echo "$ac_t""no" @@ -135,16 +135,16 @@ do done if test -z "$PERL" ; then - # We have to set this outside of the loop lest the first failure in + # We have to set this outside of the loop lest the first failure in # PROGRAM_CHECK set the value (which then terminates the effect of the - # loop, since autoconf macros only set values that are null, they + # loop, since autoconf macros only set values that are null, they # don't override them PERL="" fi if test -n "$PERL" ; then PERL="$PERL" - + perlversion=`$PERL -v | grep 'This is perl' | \ sed -e 's/^.*v[a-z ]*\([0-9]\).*$/\1/'` @@ -159,8 +159,31 @@ if test -n "$PERL" ; then fi -if [ -e $NETCDF/bin/nc-config ] ; then - ncversion=`nc-config --version | awk '{print $2}'` +# We just need to find nc-config. First, check if NETCDF_C is set; if not, check +# $NETCDF/bin; otherwise, try `which nc-config`. If all that fails, warn user that WRF +# may fail to build beacuse of an incomplete NetCDF configuration. It could still be +# successfull if NetCDF was built statically because the results of `nf-config --flibs` +# should contain the necessary information for linking as long as NetCDF-Fortran is not +# version 4.5.3 (see https://github.com/Unidata/netcdf-fortran/issues/270) + +if [ -n "$NETCDF_C" ] ; then + if [ -f "$NETCDF_C/bin/nc-config" ] ; then + export NETCDF_C=$NETCDF_C + fi +elif [ -f "${NETCDF}/bin/nc-config" ] ; then + export NETCDF_C=$NETCDF +else + ans="`which nc-config`" + status="$?" + if [ "$ans" != "nc-config:" -a "$ans" != "" -a "$status" = "0" ] ; then + export NETCDF_C=`echo $ans | awk -F/ '{NF=NF-2;$NF=$NF}1' OFS=/` + else + export NETCDF_C="NOT_FOUND" + fi +fi + +if [ -e $NETCDF_C/bin/nc-config ] ; then + ncversion=`$NETCDF_C/bin/nc-config --version | awk '{print $2}'` else ncversion=OLD fi @@ -168,10 +191,10 @@ fi PROBS=FALSE if [ -n "$NETCDFPAR" ] ; then NETCDF="$NETCDFPAR" - if [ ! -e $NETCDF/bin/nc-config ] ; then + if [ ! -e $NETCDF_C/bin/nc-config ] ; then PROBS=TRUE else - ncversion=`nc-config --version | awk '{print $2}'` + ncversion=`$NETCDF_C/bin/nc-config --version | awk '{print $2}'` ncversiona=`echo $ncversion | cut -c 1` ncversionb=`echo $ncversion | cut -c 3` ncversionc=`echo $ncversion | cut -c 5` @@ -224,7 +247,7 @@ if [ -n "$NETCDF" ] ; then else USENETCDFF=" " fi - if [ -f "$NETCDF/lib/libnetcdf.a" -o -f "$NETCDF/lib/libnetcdf.so" -o -f "$NETCDF/lib/libnetcdf.dll.a" ] ; then + if [ -f "$NETCDF_C/lib/libnetcdf.a" -o -f "$NETCDF_C/lib/libnetcdf.so" -o -f "$NETCDF_C/lib/libnetcdf.dll.a" ] ; then USENETCDF="-lnetcdf" else USENETCDF=" " @@ -243,9 +266,7 @@ fi # If the user asked for classic netcdf, acquiesce to the request. -ans="`which nf-config`" -status="$?" -if [ "$ans" = "nf-config:" -o "$ans" = "" -o "$status" != "0" ] ; then +if [ ! -f "$NETCDF/bin/nf-config" ] ; then export NETCDF_classic=1 unset NETCDF4 else @@ -257,7 +278,7 @@ else export NETCDF4=1 fi else - if [ "`nf-config --has-nc4`" = "yes" ] ; then + if [ "`$NETCDF/bin/nf-config --has-nc4`" = "yes" ] ; then unset NETCDF_classic export NETCDF4=1 else @@ -274,76 +295,19 @@ if [ -z "$CURL_PATH" ] ; then CURL_PATH=''; fi if [ -n "$NETCDF4" ] ; then if [ $NETCDF4 -eq 1 ] ; then - DEP_LIB_PATH='' - if [ -f $NETCDF/bin/nf-config ] ; then - nx_config="$NETCDF/bin/nf-config --flibs" - DEP_LIB_PATH="`$nx_config | awk '{for(i=1;i<=NF;i++){if(match($i, /-L.*/)) {print $i} } }'`" - CURL="`$nx_config | awk '{for(i=1;i<=NF;i++){if($i == "-lcurl") {print $i} } }'`" - GPFS="`$nx_config | awk '{for(i=1;i<=NF;i++){if($i == "-lgpfs") {print $i} } }'`" - fi - if [ "$DEP_LIB_PATH" = '' ] ; then - if [ -f $NETCDF/bin/nc-config ] ; then - nx_config="$NETCDF/bin/nc-config --libs" - DEP_LIB_PATH="`$nx_config | awk '{for(i=1;i<=NF;i++){if(match($i, /-L.*/)) {print $i} } }'`" - CURL="`$nx_config | awk '{for(i=1;i<=NF;i++){if($i == "-lcurl") {print $i} } }'`" - GPFS="`$nx_config | awk '{for(i=1;i<=NF;i++){if($i == "-lgpfs") {print $i} } }'`" - if [ "$CURL" != '' -a "$CURL_PATH" = '' ] ; then - CURL_PATH="DEFAULT" - fi - if [ "$GPFS" != '' -a "$GPFS_PATH" = '' ] ; then - GPFS_PATH="DEFAULT" - fi - fi - fi - for P in "$HDF5_PATH" "$ZLIB_PATH" "$GPFS_PATH" "$CURL_PATH" - do - if [ "$P" != '' -a "$P" != "DEFAULT" ] ; then - if [ "${P#${P%?}}" = "/" ] ; then - P=`echo $P | sed 's/\/$//'` - fi - DEP_LIB_PATH="`echo $DEP_LIB_PATH | awk -v VAR=-L$P/lib '{for(i=1;i<=NF;i++){if ($i != VAR ) {print $i} } }'`" - DEP_LIB_PATH="$DEP_LIB_PATH -L$P/lib" - fi - done - if [ "${NETCDF#${NETCDF%?}}" = "/" ] ; then - NETCDF=`echo $NETCDF | sed 's/\/$//'` - fi - buff="`ls -l $NETCDF | sed 's/ */ /g'`" - while [ "`echo $buff | grep lib`" = "" -a "`echo $buff | grep '\->'`" != "" ] - do - buff="`echo $buff | sed -e 's/->//' -e 's/ */ /g'`" - n=`echo $buff | wc -w` - lastword=`echo "$buff" | cut -d' ' -f$n | sed 's/\/$//'` - c="`echo $lastword | cut -c1`" - if [ "$c" = "/" ] ; then - NETCDF=$lastword - else - c="`echo $lastword | cut -c1-2`" - if [ "$c" = "./" ] ; then - lastword="echo $lastword | cut -c3-" - fi - NETCDF=${NETCDF%/*}/$lastword - fi - buff="`ls -l $NETCDF | sed 's/ */ /g'`" - done - if [ "`echo $NETCDF | grep '..'`" != "" ] ; then - buff="`echo $NETCDF | sed -e 's/^\///' -e 's/\// /g'`" - n=`echo $buff | wc -w` - i=1 - while [ $i -le $n ] - do - if [ "`echo $buff | cut -d' ' -f$i`" = ".." ] ; then - m=$i - fi - i=$(( $i + 1 )) - done - m=$(( $m + 1 )) - NETCDF=/"`echo $buff | cut -d' ' -f${m}- | sed 's/ */\//g'`" - fi - if [ "${DEP_LIB_PATH#${DEP_LIB_PATH%?}}" = "/" ] ; then - DEP_LIB_PATH=`echo $DEP_LIB_PATH | sed 's/\/$//'` + NETCDF4_DEP_LIB='' + if [ "$NETCDF_C" != "NOT_FOUND" -a -f $NETCDF_C/bin/nc-config ] ; then + nx_config="`$NETCDF_C/bin/nc-config --libs`" + NETCDF4_DEP_LIB="$NETCDF4_DEP_LIB $nx_config" + else + echo ' ' + echo '*****************************************************************************' + echo 'WARNING! Unable to find nc-config. Linking with NetCDF may fail.' + echo '*****************************************************************************' + echo ' ' fi - DEP_LIB_PATH="`echo $DEP_LIB_PATH | awk -v VAR=-L$NETCDF/lib '{for(i=1;i<=NF;i++){if ($i != VAR ) {print $i} } }'`" + nx_config="`$NETCDF/bin/nf-config --flibs`" + NETCDF4_DEP_LIB="$NETCDF4_DEP_LIB $nx_config" fi fi @@ -398,12 +362,12 @@ else unset WRFPLUS_DIR fi fi -# Users who are cross-compiling can set environment variable -# $WRF_OS to override the value normally obtained from `uname`. -# If $WRF_OS is set, then $WRF_MACH can also be set to override -# the value normally obtained from `uname -m`. If $WRF_OS is -# set and $WRF_MACH is not set, then $WRF_MACH defaults to "ARCH". -# If $WRF_OS is not set then $WRF_MACH is ignored. +# Users who are cross-compiling can set environment variable +# $WRF_OS to override the value normally obtained from `uname`. +# If $WRF_OS is set, then $WRF_MACH can also be set to override +# the value normally obtained from `uname -m`. If $WRF_OS is +# set and $WRF_MACH is not set, then $WRF_MACH defaults to "ARCH". +# If $WRF_OS is not set then $WRF_MACH is ignored. if [ -n "$WRF_OS" ] ; then echo "${0}: WRF operating system set to \"${WRF_OS}\" via environment variable \$WRF_OS" os=$WRF_OS @@ -456,7 +420,7 @@ fi # the "!" is removed by Config.pl if [ -n "$WRF_HYDRO" ] ; then if [ $WRF_HYDRO = 1 ] ; then - echo building WRF-HYDRO + echo building WRF-HYDRO compileflags="${compileflags}!-DWRF_HYDRO" echo $compileflags fi @@ -517,11 +481,11 @@ if [ -n "$WRF_CHEM" ] ; then echo building WRF with chemistry option compileflags="${compileflags}!-DWRF_CHEM!-DBUILD_CHEM=1" if [ -n "$WRF_KPP" ] ; then - if [ $WRF_KPP = 1 ] ; then + if [ $WRF_KPP = 1 ] ; then echo building WRF with KPP chemistry option compileflags="${compileflags}!-DWRF_KPP" fi - fi + fi else compileflags="${compileflags} " fi @@ -575,7 +539,7 @@ if test -n "$PERL" ; then -netcdf=$NETCDF -pnetcdf=$PNETCDF -netcdfpar=$NETCDFPAR -adios2=$ADIOS2 -hdf5=$HDF5 -phdf5=$PHDF5 -os=$os -mach=$mach -ldflags=$ldflags \ -compileflags=$compileflags -opt_level=$opt_level -USENETCDFF=$USENETCDFF -USENETCDF=$USENETCDF \ -time=$FORTRAN_COMPILER_TIMER -tfl="$TFL" -cfl="$CFL" -config_line="$config_line" \ - -wrf_core=$wrf_core -gpfs=$GPFS_PATH -curl=$CURL_PATH -dep_lib_path="$DEP_LIB_PATH" + -wrf_core=$wrf_core -gpfs=$GPFS_PATH -curl=$CURL_PATH -netcdf4_dep_lib="$NETCDF4_DEP_LIB" if test ! -f configure.wrf ; then echo "configure.wrf not created! Exiting configure script..." exit 1 @@ -620,7 +584,7 @@ if test -f configure.wrf ; then if [ "$os" = "Darwin" ] ; then # fseeko64 does not exist under Darwin fseeko does. Remove the 0 length executable # file that might get generated anyway, even though the compiler complains about missing reference. - /bin/rm -f tools/fseeko64_test + /bin/rm -f tools/fseeko64_test fi if test -x tools/fseeko64_test ; then ( tools/fseeko64_test 2> /dev/null ) 1> /dev/null @@ -665,7 +629,7 @@ if test -n "$NETCDF" ; then configure_aaaa=$? ; export configure_aaaa if [ $configure_aaaa -a -z "$WRFIO_NCD_NO_LARGE_FILE_SUPPORT" ] ; then echo "NetCDF users note:" - echo " This installation of NetCDF supports large file support. To DISABLE large file" + echo " This installation of NetCDF supports large file support. To DISABLE large file" echo " support in NetCDF, set the environment variable WRFIO_NCD_NO_LARGE_FILE_SUPPORT" echo " to 1 and run configure again. Set to any other value to avoid this message." fi @@ -690,7 +654,7 @@ if [ -n "$WRFPLUS" ] ; then fi fi -#Checking cross-compiling capability for some particular environment +#Checking cross-compiling capability for some particular environment #on Linux and Mac box if [ $os = "Linux" -o $os = "Darwin" ]; then @@ -724,7 +688,7 @@ EOF rm ${foo} ${foo}.F 2> /dev/null fi -cat > ${foo}.c < ${foo}.c < ${foo}.o + ar p $NETCDF_C/lib/libnetcdf.a `ar t $NETCDF_C/lib/libnetcdf.a | grep -E '\.o' | head -n 1 | sed 's/://'` > ${foo}.o netcdf_arch="`file ${foo}.o | grep -o -E '[0-9]{2}-bit|i386'`" rm ${foo}.o - $SFC -o ${foo} ${foo}.f > /dev/null 2>&1 + $SFC -o ${foo} ${foo}.f > /dev/null 2>&1 SFC_arch="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`" rm ${foo} ${foo}.o 2> /dev/null @@ -790,7 +754,7 @@ EOF if [ "$SFC_arch" = "" -o "$SCC_arch" = "" -o "$CCOMP_arch" = "" ]; then echo " One of compilers testing failed!" echo " Please check your compiler" - echo + echo rm -f ${foo} ${foo}.[cfo] 2> /dev/null exit else @@ -901,14 +865,14 @@ EOF echo Please check your NetCDF lib and compiler else echo -m64 is appended to configure.wrf - echo It will be forced to build in 64-bit. + echo It will be forced to build in 64-bit. echo If you don\'t want 64-bit binaries, please use 32-bit NetCDF, and re-run the configure script. fi fi ;; esac - if [ -e configure.wrf.edit ]; then + if [ -e configure.wrf.edit ]; then mv configure.wrf.edit configure.wrf fi @@ -918,10 +882,10 @@ EOF echo " Fortran compiler is $SFC_arch" echo " It will build in $netcdf_arch" echo " " - if [ -e $NETCDF/bin/nc-config ] ; then + if [ -e $NETCDF_C/bin/nc-config ] ; then echo "NetCDF version: ${ncversion}" - echo "Enabled NetCDF-4/HDF-5: `nc-config --has-nc4`" - echo "NetCDF built with PnetCDF: `nc-config --has-pnetcdf`" + echo "Enabled NetCDF-4/HDF-5: `$NETCDF_C/bin/nc-config --has-nc4`" + echo "NetCDF built with PnetCDF: `$NETCDF_C/bin/nc-config --has-pnetcdf`" if [ "$USENETCDFPAR" = "1" ] ; then echo "Using parallel NetCDF via NETCDFPAR option" fi diff --git a/share/mediation_integrate.F b/share/mediation_integrate.F index 98bc99643a..fb12f2eaed 100644 --- a/share/mediation_integrate.F +++ b/share/mediation_integrate.F @@ -1701,6 +1701,8 @@ SUBROUTINE open_hist_w ( grid , config_flags, stream, alarm_id, & ENDIF ierr = 0 + fname = "" + n2 = "" ! Note that computation of fname and n2 are outside of the oid IF statement ! since they are OUT args and may be used by callers even if oid/=0. From 43a88c0d2e47cdf0eb3f9393ce4a5fc598047fa5 Mon Sep 17 00:00:00 2001 From: Marc Imberger <33318548+MarcImberger@users.noreply.github.com> Date: Thu, 21 Dec 2023 09:51:47 +0100 Subject: [PATCH 12/14] Add missing bcast for stc2 in module_wind_fitch.F (#1952) TYPE: bug fix KEYWORDS: wind, fitch, standing thrust coefficient, broadcast, mpi SOURCE: Marc Imberger, Technical University of Denmark, Denmark DESCRIPTION OF CHANGES: Problem: Curently, the standing thrust coefficient above cut-out wind speed ('stc2') is not broadcasted from the master node in the fitch wind farm parameterization scheme. This has the consequence that any wind turbine that (1) exceeds the cut-out wind speed at hub-height and that (2) is not located in a WRF tile associated with the MPI master process will have a non-deterministic standing thrust coefficient. Since stc2 is also not initialized within the code, this value could be in principle anything (I guess this also depends on how the compiler deals with uninitialialized arrays). This affects mostly 'thrcof' which modifies the horizontal velocity tendencies and can thus yield to unphysical feedback to the rest of the model or even model crash (CFL violations). Solution: Adding stc2 to the list of variables to broadcast (see l. 516 in WRF/phys/module_wind_fitch.F) using CALL wrf_dm_bcast_real(stc2,nt) addresses this issue. ISSUE: For use when this PR closes an issue. This PR fixes issue #1865 LIST OF MODIFIED FILES: - WRF/phys/module_wind_fitch.F TESTS CONDUCTED: - Flawed broadcasting could in principle be demonstrated by printing the values of 'stc2' by each MPI process. - Issue has been found by running a simulation with windfarm_opt=1 for a short episode where wind speeds at hub-height exceed cut-out wind speed and where the turbine is not located in the tile assocated with the master process. In my case, model crash due unreasonably high velocity tendencies (CFL violation) has been observed. - In less extreme cases (e.g. when stc2 contains 0 as described in issue #1865), 'thrcof' is set to 0 causing no turbine feedback to the velocity tendencies (while typical standing thrust coefficients are larger 0) - The code passed regression tests. RELEASE NOTE: Add missing wrf_dm_bcast_real for stc2 in fitch parameterization scheme affecting standing thrust coefficients for wind speeds at turbine hub-heights above cut-out. --- phys/module_wind_fitch.F | 1 + 1 file changed, 1 insertion(+) diff --git a/phys/module_wind_fitch.F b/phys/module_wind_fitch.F index e2b4bb3049..3adaa8274c 100644 --- a/phys/module_wind_fitch.F +++ b/phys/module_wind_fitch.F @@ -518,6 +518,7 @@ SUBROUTINE init_module_wind_fitch(id,config_flags,xlong,xlat,windfarm_initialize CALL wrf_dm_bcast_real(hubheight,nt) CALL wrf_dm_bcast_real(diameter,nt) CALL wrf_dm_bcast_real(stc,nt) + CALL wrf_dm_bcast_real(stc2,nt) CALL wrf_dm_bcast_real(npower,nt) CALL wrf_dm_bcast_real(cutin,nt) CALL wrf_dm_bcast_real(cutout,nt) From 4288d10215bc9aa18cdc89e0e54e97f4d3abea45 Mon Sep 17 00:00:00 2001 From: Michael Duda Date: Thu, 21 Dec 2023 01:56:08 -0700 Subject: [PATCH 13/14] Avoid re-initialization of time series for parent after child domain starts (#1953) This PR corrects an issue in which time series for a parent domain were re-initialized when a child domain started later than the initial time for a simulation. TYPE: bug fix KEYWORDS: time series, tslist, nest SOURCE: Mathieu Landreau (LHEEA, Centrale Nantes, France), Michael Duda (NSF NCAR) DESCRIPTION OF CHANGES: Problem: When running a simulation with a nest starting later than its parent and with the time series option activated, the parent domain time series is reinitialized when the nest starts. Solution: This issue is corrected by: 1) Initializing time series-specific members of the domain type, in particular, initializing `have_calculated_tslocs` to `.FALSE.` 2) Returning early from the wrf_tsin routine if `grid%have_calculated_tslocs` is `.TRUE.` (but avoiding changes to the value of `have_calculated_tslocs` otherwise). ISSUE: Fixes #1927 LIST OF MODIFIED FILES: M frame/module_domain_type.F M share/wrf_tsin.F TESTS CONDUCTED: - The problem was observed on a personal test case and the modifications fixed it. - It passes Jenkins tests. RELEASE NOTE: Fix an issue in which time series for a parent domain were re-initialized when a child domain started later than the initial time for a simulation. --- frame/module_domain_type.F | 16 ++++++++-------- share/wrf_tsin.F | 7 ++++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/frame/module_domain_type.F b/frame/module_domain_type.F index bafe99d4ed..e04b4f0231 100644 --- a/frame/module_domain_type.F +++ b/frame/module_domain_type.F @@ -224,14 +224,14 @@ MODULE module_domain_type Type(WRFU_TimeInterval) :: last_dtInterval ! Time series location information - INTEGER :: ntsloc, ntsloc_domain - INTEGER :: next_ts_time - INTEGER, POINTER, DIMENSION(:) :: itsloc, jtsloc, id_tsloc - REAL, POINTER, DIMENSION(:) :: lattsloc, lontsloc - CHARACTER (LEN=5), POINTER, DIMENSION(:) :: nametsloc - CHARACTER (LEN=25), POINTER, DIMENSION(:) :: desctsloc - CHARACTER (LEN=256), POINTER, DIMENSION(:) :: ts_filename - LOGICAL :: have_calculated_tslocs + INTEGER :: ntsloc = 0, ntsloc_domain = 0 + INTEGER :: next_ts_time = 0 + INTEGER, POINTER, DIMENSION(:) :: itsloc => NULL(), jtsloc => NULL(), id_tsloc => NULL() + REAL, POINTER, DIMENSION(:) :: lattsloc => NULL(), lontsloc => NULL() + CHARACTER (LEN=5), POINTER, DIMENSION(:) :: nametsloc => NULL() + CHARACTER (LEN=25), POINTER, DIMENSION(:) :: desctsloc => NULL() + CHARACTER (LEN=256), POINTER, DIMENSION(:) :: ts_filename => NULL() + LOGICAL :: have_calculated_tslocs = .FALSE. LOGICAL :: have_displayed_alloc_stats ! used in module_alloc_space to display alloc stats; only do it once. ! Track location information diff --git a/share/wrf_tsin.F b/share/wrf_tsin.F index 0ba9729763..694a05d77e 100644 --- a/share/wrf_tsin.F +++ b/share/wrf_tsin.F @@ -24,12 +24,17 @@ SUBROUTINE wrf_tsin ( grid , ierr ) ierr = 0 + ! + ! If time series locations have already been computed by calc_ts_locations, + ! assume that we have already read the 'tslist' file for this domain and return + ! + IF ( grid%have_calculated_tslocs ) RETURN + #if ((EM_CORE == 1) && (DA_CORE != 1)) IF ( grid%dfi_opt == DFI_NODFI .OR. (grid%dfi_opt /= DFI_NODFI .AND. grid%dfi_stage == DFI_SETUP) ) THEN #endif CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags ) grid%ntsloc = 0 - grid%have_calculated_tslocs = .FALSE. IF ( grid%max_ts_locs <= 0 ) RETURN From 027fb7bbcac55ab46cb158872f49c5b19171a35e Mon Sep 17 00:00:00 2001 From: Kelly Werner Date: Thu, 21 Dec 2023 19:13:06 -0700 Subject: [PATCH 14/14] updated top-level README and version_decl for V4.5.2 (#1955) TYPE: text only KEYWORDS: release, v4.5.2, version_decl, README SOURCE: internal DESCRIPTION OF CHANGES: Modified version in the top-level README and inc/version_decl files LIST OF MODIFIED FILES: M README M inc/version_decl TESTS CONDUCTED: No tests necessary - text only @kkeene44 --- README | 2 +- inc/version_decl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 18c13efec1..30879e360b 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -WRF Model Version 4.5.1 +WRF Model Version 4.5.2 https://www2.mmm.ucar.edu/wrf/users/ diff --git a/inc/version_decl b/inc/version_decl index 98f1ed2596..4ba1c7a84e 100644 --- a/inc/version_decl +++ b/inc/version_decl @@ -1 +1 @@ - CHARACTER (LEN=*), PARAMETER :: release_version = 'V4.5.1' + CHARACTER (LEN=*), PARAMETER :: release_version = 'V4.5.2'