Skip to content

Commit

Permalink
Clean unused var (#579)
Browse files Browse the repository at this point in the history
* remove/avoid un-used variables

* remove/avoid un-used variables + clean-up

clean-up to keep all local variables declared in single place (and no longer in middle of src file)

* remove/avoid unused variables

also bring more consistent upper/lower case writing

* fix and clean-up

- add missing CTRL_OPTIONS.h (S/R was mostly empty without ALLOW_DEPTH_CONTROL
  being defined);
- comment out resetting of "writeBinaryPrec" (which is not safe);
- call PRINT_ERROR & PRINT_MESSAGE with myThid argument;
- avoid un-used variables.

* little cleaning in pkg/smooth:

- remove/avoid un-used variables
- separate S/R arg and local var
- fix/improve indentation
- more consistent upper/lower case writing

* remove/avoid unused variables

also simplify and clean a bit some src files (e.g., skip copy of tile loop
 range into local vars itlo,ithi & jtlo,jthi )

* same simplification as in cost_obcse.F

* avoid one more un-used var

* fix previous commit by commenting out 2 unused internal write

* document cleaning unused var from AD built
  • Loading branch information
jm-c committed Jan 5, 2022
1 parent 3b6c79e commit 9f5240b
Show file tree
Hide file tree
Showing 97 changed files with 2,306 additions and 3,022 deletions.
3 changes: 3 additions & 0 deletions doc/tag-index
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Notes on tags used in MITgcmUV
==============================

o pkgs:
- remove/avoid unused variables from AD verification exp. built except from
halfpipe_streamice (pkg/streamice); also clean-up a bit pkg/smooth.
o pkg/autodiff:
- introduce separate tapes for integer arrays: the corresponding routines
just convert between integer and double precision arrays and call the
Expand Down
6 changes: 4 additions & 2 deletions model/src/cg2d_nsa.F
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ SUBROUTINE CG2D_NSA(
C Out: the actual number of iterations used
C nIterMin :: Inp: decide to store (if >=0) or not (if <0) lowest res. sol.
C Out: iteration number corresponding to lowest residual
C myThid :: Thread on which I am working.
C myThid :: my Thread Id number
_RL cg2d_b(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RL cg2d_x(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RL firstResidual
Expand Down Expand Up @@ -95,6 +95,8 @@ SUBROUTINE CG2D_NSA(
INTEGER act1, act2
INTEGER max1
INTEGER icg2dkey, ikey
#else
_RL rhsNorm
#endif
_RL cg2dTolerance_sq
_RL err_sq, errTile(nSx,nSy)
Expand All @@ -103,7 +105,7 @@ SUBROUTINE CG2D_NSA(
_RL cgBeta, alpha
_RL alphaSum,alphaTile(nSx,nSy)
_RL sumRHS, sumRHStile(nSx,nSy)
_RL rhsMax, rhsNorm
_RL rhsMax
CHARACTER*(MAX_LEN_MBUF) msgBuf
LOGICAL printResidual
_RL cg2d_z(1:sNx,1:sNy,nSx,nSy)
Expand Down
4 changes: 2 additions & 2 deletions model/src/ini_linear_phisurf.F
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SUBROUTINE INI_LINEAR_PHISURF( myThid )
#include "SURFACE.h"

C !INPUT/OUTPUT PARAMETERS:
C === Routine arguments ===
C myThid :: my Thread Id number
INTEGER myThid

Expand All @@ -37,11 +36,12 @@ SUBROUTINE INI_LINEAR_PHISURF( myThid )
C needed since MDSIO now allows (2009/06/07) to write local arrays

C !LOCAL VARIABLES:
C === Local variables ===
C topoHloc :: Temporary array used to write surface topography
C bi,bj :: tile indices
C i,j,k :: Loop counters
#ifndef ALLOW_AUTODIFF
_RS topoHloc(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
#endif
INTEGER bi, bj
INTEGER i, j, k
_RL pLoc, rhoLoc
Expand Down
15 changes: 8 additions & 7 deletions model/src/ini_pressure.F
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@ SUBROUTINE INI_PRESSURE( myThid )
#include "DYNVARS.h"

C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C myThid - Number of this instance of INI_PRESSURE
C myThid :: my Thread Id number
INTEGER myThid

C !LOCAL VARIABLES:
C == Local variables ==
C dPhiHydX,Y :: Gradient (X & Y directions) of Hyd. Potential
C bi,bj :: tile indices
C i,j,k :: Loop counters
INTEGER bi, bj
INTEGER i, j, k
#ifndef ALLOW_AUTODIFF
INTEGER iMin, iMax, jMin, jMax, npiter
_RL PhiHydF (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL PhiHydC (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
Expand All @@ -48,13 +47,10 @@ SUBROUTINE INI_PRESSURE( myThid )
_RL oldPhi (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL count, rmspp, rmsppold
_RL sumTile, rmsTile
#endif

CHARACTER*(MAX_LEN_MBUF) msgBuf
CEOP
iMin = 1-OLx
iMax = sNx+OLx
jMin = 1-OLy
jMax = sNy+OLy

_BEGIN_MASTER( myThid )
WRITE(msgBuf,'(a)')
Expand Down Expand Up @@ -82,6 +78,11 @@ SUBROUTINE INI_PRESSURE( myThid )
cph-- really be needed;
cph-- would need storing of totPhiHyd for each npiter

iMin = 1-OLx
iMax = sNx+OLx
jMin = 1-OLy
jMax = sNy+OLy

rmspp = 1. _d 0
rmsppold = 0. _d 0
npiter = 0
Expand Down
4 changes: 2 additions & 2 deletions model/src/initialise_varia.F
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ SUBROUTINE INITIALISE_VARIA( myThid )
#endif

C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
INTEGER myThid

C !LOCAL VARIABLES:
C == Local variables ==
#ifndef ALLOW_AUTODIFF_WHTAPEIO
INTEGER bi,bj
#endif
CEOP

#ifdef ALLOW_DEBUG
Expand Down
11 changes: 5 additions & 6 deletions model/src/reset_nlfs_vars.F
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ SUBROUTINE RESET_NLFS_VARS( myTime, myIter, myThid )
#include "SURFACE.h"

C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C myTime :: Current time in simulation
C myIter :: Current iteration number in simulation
C myThid :: my Thread Id number
Expand All @@ -34,17 +33,17 @@ SUBROUTINE RESET_NLFS_VARS( myTime, myIter, myThid )

C !LOCAL VARIABLES:
#ifdef NONLIN_FRSURF
C Local variables
C i,j,k,bi,bj :: loop counter
INTEGER i,j,bi,bj
#ifndef DISABLE_RSTAR_CODE
C i, j, :: loop counter
C bi, bj :: tile indices
INTEGER i, j, bi, bj
CEOP

C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|

DO bj=myByLo(myThid), myByHi(myThid)
DO bi=myBxLo(myThid), myBxHi(myThid)

#ifndef DISABLE_RSTAR_CODE
IF ( fluidIsAir .AND. select_rStar.GE.1 ) THEN
DO j=1-OLy,sNy+OLy
DO i=1-OLx,sNx+OLx
Expand All @@ -58,12 +57,12 @@ SUBROUTINE RESET_NLFS_VARS( myTime, myIter, myThid )
ENDDO
ENDDO
ENDIF
#endif /* DISABLE_RSTAR_CODE */

C- end bi,bj loop
ENDDO
ENDDO

#endif /* DISABLE_RSTAR_CODE */
#endif /* NONLIN_FRSURF */

RETURN
Expand Down
3 changes: 3 additions & 0 deletions pkg/autodiff/autodiff_init_varia.F
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ SUBROUTINE AUTODIFF_INIT_VARIA( myThid )
C bi,bj :: tile indices
C i,j,k :: Loop counters
INTEGER bi, bj
#if ( ( defined ALLOW_AUTODIFF_INIT_OLD && defined ECCO_CTRL_DEPRECATED ) \
|| defined ALLOW_EP_FLUX )
INTEGER i, j, k
#endif
CEOP

C-- Scalar fields
Expand Down
7 changes: 1 addition & 6 deletions pkg/autodiff/myactivefunction.F
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

CBOP
C !INTERFACE:
_RL FUNCTION myActiveFunction ( mytmp3d, mythid )
_RL FUNCTION myActiveFunction ( mytmp3d, myThid )
C !DESCRIPTION: \bv
C *==========================================================*
C *==========================================================*
Expand All @@ -17,18 +17,13 @@ _RL FUNCTION myActiveFunction ( mytmp3d, mythid )
#include "PARAMS.h"

C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C myThid - Thread number for this instance of the routine.
C myIter - Iteration number
C myTime - Current time of simulation ( s )
_RL mytmp3d(sNx,sNy,Nr,nSx,nSy)
INTEGER myThid
INTEGER myIter

C !LOCAL VARIABLES:

c == external ==

CEOP

myActiveFunction = 1.0
Expand Down
9 changes: 2 additions & 7 deletions pkg/autodiff/myactivefunction_ad.F
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

CBOP
C !INTERFACE:
SUBROUTINE admyActiveFunction (
& mytmp3d, mythid, admytmp3d,admyactivetmp )
SUBROUTINE admyActiveFunction(
& mytmp3d, myThid, admytmp3d, admyactivetmp )
C !DESCRIPTION: \bv
C *==========================================================*
C *==========================================================*
Expand All @@ -18,20 +18,15 @@ SUBROUTINE admyActiveFunction (
#include "PARAMS.h"

C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C myThid - Thread number for this instance of the routine.
C myIter - Iteration number
C myTime - Current time of simulation ( s )
_RL mytmp3d(sNx,sNy,Nr,nSx,nSy)
_RL admytmp3d(sNx,sNy,Nr,nSx,nSy)
_RL admyactivetmp
INTEGER myThid
INTEGER myIter

C !LOCAL VARIABLES:

c == external ==

CEOP

cph Do nothing and nothing will be done
Expand Down
10 changes: 5 additions & 5 deletions pkg/bling/bling_light.F
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ SUBROUTINE BLING_LIGHT(
_RL irr_eff (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)

C === Local variables ===
_RL solar, albedo
_RL dayfrac, yday, delta
_RL lat, sun1, dayhrs
_RL cosz, frac, fluxi
_RL atten
_RL irr_surf (1-OLx:sNx+OLx,1-OLy:sNy+OLy)
#ifdef ML_MEAN_LIGHT
Expand All @@ -84,6 +80,10 @@ SUBROUTINE BLING_LIGHT(
_RL tmp_ML
#endif
#ifndef USE_QSW
_RL solar, albedo
_RL dayfrac, yday, delta
_RL lat, sun1, dayhrs
_RL cosz, frac, fluxi
_RL sfac (1-OLy:sNy+OLy)
#endif
#ifdef PHYTO_SELF_SHADING
Expand Down Expand Up @@ -170,7 +170,7 @@ SUBROUTINE BLING_LIGHT(
sfac(j) = MAX(1. _d -5,fluxi)
ENDDO !j

#endif
#endif /* ndef USE_QSW */

c ---------------------------------------------------------------------
c instantaneous light, mixed layer averaged light
Expand Down
42 changes: 15 additions & 27 deletions pkg/cost/cost_accumulate_mean.F
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#include "COST_OPTIONS.h"

subroutine cost_accumulate_mean( myThid )
SUBROUTINE cost_accumulate_mean( myThid )
C *==========================================================*
C | subroutine cost_accumulate_mean |
C | SUBROUTINE cost_accumulate_mean |
C | o accumulate mean state for cost evalualtion |
C *==========================================================*
C | |
C *==========================================================*
IMPLICIT NONE

Expand All @@ -20,29 +18,19 @@ subroutine cost_accumulate_mean( myThid )

C == Routine arguments ==
C myThid - Thread number for this instance of the routine.
integer bi, bj
integer myThid
INTEGER bi, bj
INTEGER myThid

#ifdef ALLOW_COST
C == Local variables
_RL thetaRef

integer i, j, k
integer ig, jg
integer itlo,ithi
integer jtlo,jthi

jtlo = mybylo(mythid)
jthi = mybyhi(mythid)
itlo = mybxlo(mythid)
ithi = mybxhi(mythid)
INTEGER i, j, k

C-- Calculate cost function on tile of this instance
do bj = jtlo,jthi
do bi = itlo,ithi
do k = 1, Nr
do j=1,sNy
do i=1,sNx
DO bj = myByLo(myThid), myByHi(myThid)
DO bi = myBxLo(myThid), myBxHi(myThid)
DO k = 1, Nr
DO j=1,sNy
DO i=1,sNx
cMeanTheta(i,j,k,bi,bj) = cMeanTheta(i,j,k,bi,bj)
& + theta(i,j,k,bi,bj)
& /lastinterval*deltaTClock
Expand All @@ -65,11 +53,11 @@ subroutine cost_accumulate_mean( myThid )
& /2.*vvel(i,j,k,bi,bj)
& *maskS(i,j,k,bi,bj)*maskC(i,j,k,bi,bj)
& /lastinterval*deltaTClock
end do
end do
end do
end do
end do
ENDDO
ENDDO
ENDDO
ENDDO
ENDDO

#endif

Expand Down
19 changes: 8 additions & 11 deletions pkg/cost/cost_dependent_init.F
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@ subroutine cost_dependent_init( mythid )

c == local variables ==

integer i,j,k
#if ( defined ALLOW_COST_VECTOR || defined ALLOW_COST_STATE_FINAL )
integer i
#endif
#ifdef ALLOW_COST_STATE_FINAL
integer j, k
#endif
integer bi,bj
integer itlo,ithi
integer jtlo,jthi

c == external functions ==

c == end of interface ==
jtlo = mybylo(mythid)
jthi = mybyhi(mythid)
itlo = mybxlo(mythid)
ithi = mybxhi(mythid)

#ifdef ALLOW_OPENAD
fc%v = 0.0
Expand All @@ -59,8 +56,8 @@ subroutine cost_dependent_init( mythid )
endif
#endif

do bj = jtlo,jthi
do bi = itlo,ithi
do bj = myByLo(mythid), myByHi(mythid)
do bi = myBxLo(mythid), myBxHi(mythid)
#ifdef ALLOW_COST_VECTOR
do i=1,sNx
objf_vector(i,bi,bj) = 0. _d 0
Expand Down
Loading

0 comments on commit 9f5240b

Please sign in to comment.