Skip to content

Commit

Permalink
dOxyGenized MOM_string_functions.F90
Browse files Browse the repository at this point in the history
  Added dOxyGen comments for all routines and arguments in
MOM_string_functions.F90.  All answers are bitwise identical.
  • Loading branch information
Hallberg-NOAA committed May 8, 2018
1 parent 397d258 commit 434f77c
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions src/framework/MOM_string_functions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ module MOM_string_functions

contains

!> Return a string in which all uppercase letters have been replaced by
!! their lowercase counterparts.
function lowercase(input_string)
character(len=*), intent(in) :: input_string !< The string to modify
character(len=len(input_string)) :: lowercase !< The modified output string
! This function returns a string in which all uppercase letters have been
! replaced by their lowercase counterparts. It is loosely based on the
! lowercase function in mpp_util.F90.
! Arguments
character(len=*), intent(in) :: input_string
character(len=len(input_string)) :: lowercase
! Local variables
integer, parameter :: co=iachar('a')-iachar('A') ! case offset
integer :: k

Expand All @@ -45,13 +45,14 @@ function lowercase(input_string)
enddo
end function lowercase

!> Return a string in which all uppercase letters have been replaced by
!! their lowercase counterparts.
function uppercase(input_string)
character(len=*), intent(in) :: input_string
character(len=len(input_string)) :: uppercase
character(len=*), intent(in) :: input_string !< The string to modify
character(len=len(input_string)) :: uppercase !< The modified output string
! This function returns a string in which all lowercase letters have been
! replaced by their uppercase counterparts. It is loosely based on the
! uppercase function in mpp_util.F90.
! Arguments
integer, parameter :: co=iachar('A')-iachar('a') ! case offset
integer :: k

Expand All @@ -62,25 +63,23 @@ function uppercase(input_string)
enddo
end function uppercase

!> Returns a character string of a left-formatted integer
!! e.g. "123 " (assumes 19 digit maximum)
function left_int(i)
! Returns a character string of a left-formatted integer
! e.g. "123 " (assumes 19 digit maximum)
! Arguments
character(len=19) :: left_int
integer, intent(in) :: i
! Local variables
integer, intent(in) :: i !< The integer to convert to a string
character(len=19) :: left_int !< The output string

character(len=19) :: tmp
write(tmp(1:19),'(I19)') i
write(left_int(1:19),'(A)') adjustl(tmp)
end function left_int

!> Returns a character string of a comma-separated, compact formatted,
!! integers e.g. "1, 2, 3, 4"
function left_ints(i)
! Returns a character string of a comma-separated, compact formatted,
! integers e.g. "1, 2, 3, 4"
! Arguments
character(len=1320) :: left_ints
integer, intent(in) :: i(:)
! Local variables
integer, intent(in) :: i(:) !< The array of integers to convert to a string
character(len=1320) :: left_ints !< The output string

character(len=1320) :: tmp
integer :: j
write(left_ints(1:1320),'(A)') trim(left_int(i(1)))
Expand All @@ -92,10 +91,11 @@ function left_ints(i)
endif
end function left_ints

!> Returns a left-justified string with a real formatted like '(G)'
function left_real(val)
real, intent(in) :: val
character(len=32) :: left_real
! Returns a left-justified string with a real formatted like '(G)'
real, intent(in) :: val !< The real variable to convert to a string
character(len=32) :: left_real !< The output string

integer :: l, ind

if ((abs(val) < 1.0e4) .and. (abs(val) >= 1.0e-3)) then
Expand Down Expand Up @@ -143,19 +143,18 @@ function left_real(val)
left_real = adjustl(left_real)
end function left_real

!> Returns a character string of a comma-separated, compact formatted, reals
!! e.g. "1., 2., 5*3., 5.E2"
function left_reals(r,sep)
! Returns a character string of a comma-separated, compact formatted, reals
! e.g. "1., 2., 5*3., 5.E2"
! Arguments
character(len=1320) :: left_reals
real, intent(in) :: r(:)
real, intent(in) :: r(:) !< The array of real variables to convert to a string
character(len=*), optional, intent(in) :: sep !< The separator between
!! successive values, by default it is ', '.
character(len=1320) :: left_reals !< The output string

! Local variables
integer :: j, n, b, ns
logical :: doWrite
character(len=10) :: separator

n=1 ; doWrite=.true. ; left_reals='' ; b=1
if (present(sep)) then
separator=sep ; ns=len(sep)
Expand Down Expand Up @@ -185,11 +184,10 @@ function left_reals(r,sep)
enddo
end function left_reals

!> Returns True if the string can be read/parsed to give the exact value of "val"
function isFormattedFloatEqualTo(str, val)
! Returns True if the string can be read/parsed to give the exact
! value of "val"
character(len=*), intent(in) :: str
real, intent(in) :: val
character(len=*), intent(in) :: str !< The string to parse
real, intent(in) :: val !< The real value to compare with
logical :: isFormattedFloatEqualTo
! Local variables
real :: scannedVal
Expand All @@ -204,8 +202,8 @@ end function isFormattedFloatEqualTo
!! or "" if the string is not long enough. Both spaces and commas
!! are interpreted as separators.
character(len=120) function extractWord(string, n)
character(len=*), intent(in) :: string
integer, intent(in) :: n
character(len=*), intent(in) :: string !< The string to scan
integer, intent(in) :: n !< Number of word to extract

extractWord = extract_word(string, ' ,', n)

Expand Down

0 comments on commit 434f77c

Please sign in to comment.