Ignore:
Timestamp:
Nov 22, 2018 4:01:22 PM (4 years ago)
Author:
eckhard
Message:

inifor: Updated documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/UTIL/inifor/src/inifor_util.f90

    r3447 r3557  
    2626! -----------------
    2727! $Id$
     28! Updated documentation
     29!
     30!
     31! 3447 2018-10-29 15:52:54Z eckhard
    2832! Renamed source files for compatibilty with PALM build system
    2933!
     
    4448! Authors:
    4549! --------
    46 ! @author Eckhard Kadasch
     50!> @author Eckhard Kadasch (Deutscher Wetterdienst, Offenbach)
    4751!
    4852! Description:
     
    6165    IMPLICIT NONE
    6266
     67!------------------------------------------------------------------------------!
     68! Description:
     69! ------------
     70!> Fortran implementation of C's struct tm for representing points in time
     71!------------------------------------------------------------------------------!
    6372    TYPE, BIND(c) :: tm_struct
    6473       INTEGER(C_INT) :: tm_sec     !< seconds after the minute [0, 61]
     
    7584    INTERFACE
    7685
     86!------------------------------------------------------------------------------!
     87! Description:
     88! ------------
     89!> Interface to C's strptime function, which converts a string to a tm
     90!> structure.
     91!------------------------------------------------------------------------------!
    7792       FUNCTION strptime(string, format, timeinfo) BIND(c, NAME='strptime')
    7893          IMPORT :: C_CHAR, C_SIZE_T, tm_struct
     
    87102
    88103
     104!------------------------------------------------------------------------------!
     105! Description:
     106! ------------
     107!> Interface to C's strftime function, which converts the given 'timeinfo'
     108!> structure to a string in the given 'format'.
     109!------------------------------------------------------------------------------!
    89110       FUNCTION strftime(string, string_len, format, timeinfo) BIND(c, NAME='strftime')
    90111          IMPORT :: C_CHAR, C_SIZE_T, tm_struct
     
    101122
    102123
     124!------------------------------------------------------------------------------!
     125! Description:
     126! ------------
     127!> Interface to C's mktime function, which converts the given tm structure to
     128!> Unix time (number of seconds since 0 UTC, 1st January 1970). INIFOR uses the
     129!> side effect that a call to mktime noramlizes the given 'timeinfo' structure,
     130!> e.g. increments the date if hours overfow 24.
     131!------------------------------------------------------------------------------!
    103132       FUNCTION mktime(timeinfo) BIND(c, NAME='mktime')
    104133          IMPORT :: C_PTR, tm_struct
     
    115144 CONTAINS
    116145
     146!------------------------------------------------------------------------------!
     147! Description:
     148! ------------
     149!> Takes a string of the form YYYYMMDDHH, adds the given number of hours to its
     150!> tm structure representation, and returns the corresponding string in the same
     151!> format
     152!------------------------------------------------------------------------------!
    117153    CHARACTER(LEN=DATE) FUNCTION add_hours_to(date_string, hours)
    118154       CHARACTER(LEN=DATE), INTENT(IN)          ::  date_string
     
    143179
    144180
     181!------------------------------------------------------------------------------!
     182! Description:
     183! ------------
     184!> Print all members of the given tm structure
     185!------------------------------------------------------------------------------!
    145186    SUBROUTINE print_tm(timeinfo)
    146187       TYPE(tm_struct), INTENT(IN) :: timeinfo
     
    158199
    159200   
     201!------------------------------------------------------------------------------!
     202! Description:
     203! ------------
     204!> Initialize the given tm structure with zero values
     205!------------------------------------------------------------------------------!
    160206    SUBROUTINE init_tm(timeinfo)
    161207       TYPE(tm_struct), INTENT(INOUT) :: timeinfo
     
    177223
    178224
    179     SUBROUTINE fake_output_3d(a)
    180 
    181        REAL(dp), INTENT(INOUT)       ::  a(:,:,:)
    182        REAL(dp)                      ::  lxi, lyi
    183        INTEGER ::  i,j,k
    184 
    185        lyi = 2.0_dp * PI / (SIZE(a, 2) - 1.0_dp)
    186        lxi = 2.0_dp * PI / (SIZE(a, 1) - 1.0_dp)
    187 
    188        DO k = 1, SIZE(a, 3)
    189        DO j = 1, SIZE(a, 2)
    190        DO i = 1, SIZE(a, 1)
    191            a(i,j,k) = SIN(lxi * i) * COS(lyi * j) + k
    192        END DO
    193        END DO
    194        END DO
    195 
    196     END SUBROUTINE fake_output_3d
    197 
    198 
    199     SUBROUTINE fake_output_2d(a, offset)
    200 
    201        REAL(dp), INTENT(INOUT) ::  a(:,:)
    202        INTEGER, INTENT(IN)     ::  offset
    203        REAL(dp)                ::  lxi, lyi
    204        INTEGER                 ::  i,j
    205 
    206        lyi = 2.0_dp*PI / (SIZE(a, 2) - 1.0_dp)
    207        lxi = 2.0_dp*PI / (SIZE(a, 1) - 1.0_dp)
    208 
    209        a(:,:) = 1.0_dp
    210        DO j = 1, SIZE(a, 2)
    211        DO i = 1, SIZE(a, 1)
    212           a(i,j) = SIN(lxi * i) * COS(lyi * j) + offset
    213        END DO
    214        END DO
    215 
    216     END SUBROUTINE fake_output_2d
    217 
    218 
     225!------------------------------------------------------------------------------!
     226! Description:
     227! ------------
     228!> Fill the given array with values equally spaced between and including start
     229!> and stop
     230!------------------------------------------------------------------------------!
    219231    SUBROUTINE linspace(start, stop, array)
    220232
     
    255267
    256268
     269!------------------------------------------------------------------------------!
     270! Description:
     271! ------------
     272!>
     273!------------------------------------------------------------------------------!
    257274    SUBROUTINE deaverage(avg_1, t1, avg_2, t2, avg_3, t3)
    258275
     
    270287
    271288
     289!------------------------------------------------------------------------------!
     290! Description:
     291! ------------
     292!> Compute the COSMO-DE/-D2 basic state pressure profile
     293!------------------------------------------------------------------------------!
    272294    SUBROUTINE get_basic_state(z, beta, p_sl, t_sl, rd, g, p0)
    273295
     
    278300       REAL(dp), INTENT(IN)  ::  rd     !< ideal gas constant of dry air [J/kg/K]
    279301       REAL(dp), INTENT(IN)  ::  g      !< acceleration of Earth's gravity [m/s^2]
    280        REAL(dp), INTENT(OUT) ::  p0(1:) !< COSMO-DE basic state pressure [Pa]
     302       REAL(dp), INTENT(OUT) ::  p0(1:) !< COSMO basic state pressure [Pa]
    281303       REAL(dp) ::  root_frac, factor   !< precomputed factors
    282304
     
    285307
    286308       p0(:) = p_sl * EXP(                                                     &
    287                   factor * ( 1.0_dp - SQRT( 1.0_dp - root_frac * z(:) ) )  &
    288                )
     309                  factor * ( 1.0_dp - SQRT( 1.0_dp - root_frac * z(:) ) )      &
     310       )
    289311
    290312    END SUBROUTINE get_basic_state
     
    345367
    346368
     369!------------------------------------------------------------------------------!
     370! Description:
     371! ------------
     372!> Converts the given real value to a string
     373!------------------------------------------------------------------------------!
    347374    CHARACTER(LEN=16) FUNCTION real_to_str_f(val)
    348375
     
    355382
    356383
     384!------------------------------------------------------------------------------!
     385! Description:
     386! ------------
     387!> Converts the given integer value to a string
     388!------------------------------------------------------------------------------!
    357389    CHARACTER(LEN=10) FUNCTION str(val)
    358390
     
    365397
    366398
    367     CHARACTER(LEN=30) FUNCTION strs(vals)
    368 
    369         INTEGER, INTENT(IN) ::  vals(:)
    370         INTEGER ::  i
    371 
    372         strs = ''
    373         DO i = 1, SIZE(vals)
    374            strs = TRIM(strs) // TRIM(str(vals(i)))
    375         END DO
    376 
    377     END FUNCTION strs
    378 
    379 
     399!------------------------------------------------------------------------------!
     400! Description:
     401! ------------
     402!> If the given path is not conlcuded by a slash, add one.
     403!------------------------------------------------------------------------------!
    380404    SUBROUTINE normalize_path(path)
    381405       
Note: See TracChangeset for help on using the changeset viewer.