Skip to content

Clean up compiler warnings#78

Merged
pjpegion merged 5 commits into
NOAA-PSL:masterfrom
DusanJovic-NOAA:no_warn
Apr 17, 2024
Merged

Clean up compiler warnings#78
pjpegion merged 5 commits into
NOAA-PSL:masterfrom
DusanJovic-NOAA:no_warn

Conversation

@DusanJovic-NOAA
Copy link
Copy Markdown
Contributor

This PR cleans up compiler warnings when Intel compiler is used without a compiler flag that suppresses all warnings.

fixes: #73

/work/noaa/fv3-cam/djovic/ufs/ufs-weather-model/stochastic_physics/stochy_patterngenerator.F90(162): warning #8221: This integer constant is outside the default integer range - using INTEGER(8) instead.   [2147483648]
           count4 = mod(iseed(np) + 2147483648, 4294967296) - 2147483648
------------------------------------^
/work/noaa/fv3-cam/djovic/ufs/ufs-weather-model/stochastic_physics/stochy_data_mod.F90(488): remark #7713: This statement function has not been used.   [INDLSOD]
   integer :: indev,indod,indlsod,indlsev,varid1,varid2,varid3,varid4,ierr
--------------------------^
/work/noaa/fv3-cam/djovic/ufs/ufs-weather-model/stochastic_physics/stochy_data_mod.F90(488): remark #7713: This statement function has not been used.   [INDLSEV]
   integer :: indev,indod,indlsod,indlsev,varid1,varid2,varid3,varid4,ierr
----------------------------------^
@DusanJovic-NOAA
Copy link
Copy Markdown
Contributor Author

When code is compiled with debug flags (-DDEBUG=ON) I see additional warnings:

[ 33%] Building Fortran object stochastic_physics/CMakeFiles/stochastic_physics.dir/update_ca.F90.o
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/update_ca.F90(623): warning #8889: Explicit interface or EXTERNAL declaration is required.   [PLUMES]
        call plumes(V,L,AG,onegrid,ncells,ncells,kend)
-------------^

Simplest way to fix this warning is to define plumes subroutine inside a module, for example plume_mod, and use that module in update_cells_sgs subroutine in update_ca.F90

@DusanJovic-NOAA
Copy link
Copy Markdown
Contributor Author

There are also bunch or undeclared variables in spectral_transforms.F90:

[100%] Building Fortran object stochastic_physics/CMakeFiles/stochastic_physics.dir/spectral_transforms.F90.o
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(728): warning #6717: This name has not been given an explicit type.   [IDO]
      REAL(kind_dbl_prec) :: CH(IDO,L1,IP), CC(IDO,IP,L1), C1(IDO,L1,IP), C2(IDL1,IP), &
--------------------------------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(728): warning #6717: This name has not been given an explicit type.   [L1]
      REAL(kind_dbl_prec) :: CH(IDO,L1,IP), CC(IDO,IP,L1), C1(IDO,L1,IP), C2(IDL1,IP), &
------------------------------------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(728): warning #6717: This name has not been given an explicit type.   [IP]
      REAL(kind_dbl_prec) :: CH(IDO,L1,IP), CC(IDO,IP,L1), C1(IDO,L1,IP), C2(IDL1,IP), &
---------------------------------------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(728): warning #6717: This name has not been given an explicit type.   [IDL1]
      REAL(kind_dbl_prec) :: CH(IDO,L1,IP), CC(IDO,IP,L1), C1(IDO,L1,IP), C2(IDL1,IP), &
-----------------------------------------------------------------------------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(731): warning #6717: This name has not been given an explicit type.   [ARG]
      ARG = TPI/FLOAT(IP)
------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(732): warning #6717: This name has not been given an explicit type.   [DCP]
      DCP = COS(ARG)
------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(733): warning #6717: This name has not been given an explicit type.   [DSP]
      DSP = SIN(ARG)
------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(734): warning #6717: This name has not been given an explicit type.   [IDP2]
      IDP2 = IDO+2
------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(735): warning #6717: This name has not been given an explicit type.   [NBD]
      NBD = (IDO-1)/2
------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(736): warning #6717: This name has not been given an explicit type.   [IPP2]
      IPP2 = IP+2
------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(737): warning #6717: This name has not been given an explicit type.   [IPPH]
      IPPH = (IP+1)/2
------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(739): warning #6717: This name has not been given an explicit type.   [K]
      DO K=1,L1
---------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(740): warning #6717: This name has not been given an explicit type.   [I]
         DO I=1,IDO
------------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(751): warning #6717: This name has not been given an explicit type.   [J]
  106 DO 108 J=2,IPPH
-------------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(752): warning #6717: This name has not been given an explicit type.   [JC]
         JC = IPP2-J
---------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(753): warning #6717: This name has not been given an explicit type.   [J2]
         J2 = J+J
---------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(766): warning #6717: This name has not been given an explicit type.   [IC]
               IC = IDP2-I
---------------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(787): warning #6717: This name has not been given an explicit type.   [AR1]
  116 AR1 = 1.
------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(788): warning #6717: This name has not been given an explicit type.   [AI1]
      AI1 = 0.
------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(790): warning #6717: This name has not been given an explicit type.   [L]
      DO 120 L=2,IPPH
-------------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(791): warning #6717: This name has not been given an explicit type.   [LC]
         LC = IPP2-L
---------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(792): warning #6717: This name has not been given an explicit type.   [AR1H]
         AR1H = DCP*AR1-DSP*AI1
---------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(795): warning #6717: This name has not been given an explicit type.   [IK]
         DO 117 IK=1,IDL1
----------------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(799): warning #6717: This name has not been given an explicit type.   [DC2]
         DC2 = AR1
---------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(800): warning #6717: This name has not been given an explicit type.   [DS2]
         DS2 = AI1
---------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(801): warning #6717: This name has not been given an explicit type.   [AR2]
         AR2 = AR1
---------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(802): warning #6717: This name has not been given an explicit type.   [AI2]
         AI2 = AI1
---------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(806): warning #6717: This name has not been given an explicit type.   [AR2H]
            AR2H = DC2*AR2-DS2*AI2
------------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(866): warning #6717: This name has not been given an explicit type.   [IS]
      IS = -IDO
------^
/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(869): warning #6717: This name has not been given an explicit type.   [IDIJ]
         IDIJ = IS
---------^

All these warnings are from RADBG_STOCHY subroutine, which uses two implicit real statements to declare real variables, like:

      SUBROUTINE RADBG_STOCHY (IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA)                                      
      implicit real(kind=kind_dbl_prec) (A-H)
      implicit real(kind=kind_dbl_prec) (O-Z)

I suggest we add implicit none instead and explicitly declare all variables.

@DusanJovic-NOAA
Copy link
Copy Markdown
Contributor Author

One more warning about missing explicit interface:

/work/noaa/fv3-cam/djovic/ufs/remove_nowarn/ufs-weather-model/stochastic_physics/spectral_transforms.F90(1477): warning #8889: Explicit interface or EXTERNAL declaration is required.   [SLEEP]
            call sleep(2)
-----------------^

This sleep subroutine is called just before the stop statement, here:

          if(wrk(i) .eq. 0.0) then
            write(6,*) ' la2ga: error'
            call sleep(2)                                                                              
            stop
          endif
        enddo
      return
!
   end subroutine stochy_la2ga

I think this call can just be removed. I do not see the need to sleep for 2 seconds before stopping the program.

@BrianCurtis-NOAA
Copy link
Copy Markdown
Contributor

BrianCurtis-NOAA commented Apr 17, 2024

UFS PR #2225 is ready for merging. Please merge.

@zach1221
Copy link
Copy Markdown
Collaborator

UFS PR #2225 is ready for merging. Please merge.

copying @pjpegion as well.

@pjpegion pjpegion merged commit 31e4e3e into NOAA-PSL:master Apr 17, 2024
@DusanJovic-NOAA DusanJovic-NOAA deleted the no_warn branch April 17, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiler warnings

4 participants