Ignore:
Timestamp:
Dec 16, 2025, 4:39:24 PM (4 weeks ago)
Author:
jbclement
Message:

PEM:
Apply documentation template everywhere: standardized headers format with short description, separators between functions/subroutines, normalized code sections, aligned dependencies/arguments/variables declaration.
JBC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/orbit.F90

    r3989 r3991  
    11MODULE orbit
    2 
    3 !=======================================================================
    4 !
    5 ! Purpose: Compute the maximum number of iteration for PEM based on the
    6 ! stopping criterion given by the orbital parameters
    7 !
    8 ! Author: RV, JBC
    9 !=======================================================================
    10 
     2!-----------------------------------------------------------------------
     3! NAME
     4!     orbit
     5! DESCRIPTION
     6!     Compute orbital-parameter-based stopping criteria and update
     7!     planetary orbit parameters.
     8! AUTHORS & DATE
     9!     R. Vandemeulebrouck
     10!     JB Clement, 2023-2025
     11! NOTES
     12!
     13!-----------------------------------------------------------------------
     14
     15! DECLARATION
     16! -----------
    1117implicit none
    1218
     19! MODULE VARIABLES
     20! ----------------
    1321real, dimension(:), allocatable :: year_lask  ! year before present from Laskar et al.
    14 real, dimension(:), allocatable :: obl_lask   ! obliquity    [deg]
     22real, dimension(:), allocatable :: obl_lask   ! obliquity [deg]
    1523real, dimension(:), allocatable :: ecc_lask   ! eccentricity
    1624real, dimension(:), allocatable :: lsp_lask   ! ls perihelie [deg]
    1725integer                         :: iyear_lask ! Index of the line in the file year_obl_lask.asc corresponding to the closest lower year to the current year
    1826
    19 !=======================================================================
    2027contains
    21 !=======================================================================
    22 
     28!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     29
     30!=======================================================================
    2331SUBROUTINE read_orbitpm(Year)
    24 
     32!-----------------------------------------------------------------------
     33! NAME
     34!     read_orbitpm
     35!
     36! DESCRIPTION
     37!     Read Laskar orbital file and prepare arrays; locate index for
     38!     closest lower year relative to current simulation year.
     39!
     40! AUTHORS & DATE
     41!     R. Vandemeulebrouck
     42!     JB Clement, 2023-2025
     43!
     44! NOTES
     45!     Converts kilo Earth years to Martian years using 'convert_years'.
     46!-----------------------------------------------------------------------
     47
     48! DEPENDENCIES
     49! ------------
    2550use evolution, only: convert_years
    2651
     52! DECLARATION
     53! -----------
    2754implicit none
    2855
     56! ARGUMENTS
     57! ---------
    2958real, intent(in) :: Year ! Martian year of the simulation
    3059
    31 integer :: n ! number of lines in Laskar files
     60! LOCAL VARIABLES
     61! ---------------
     62integer :: n ! Number of lines in Laskar files
    3263integer :: ierr, i
    3364
     65! CODE
     66! ----
    3467n = 0
    3568open(1,file = 'obl_ecc_lsp.asc',status = 'old',action = 'read')
     
    5689
    5790END SUBROUTINE read_orbitpm
    58 
    59 !=======================================================================
    60 
     91!=======================================================================
     92
     93!=======================================================================
    6194SUBROUTINE end_orbit
    62 
     95!-----------------------------------------------------------------------
     96! NAME
     97!     end_orbit
     98!
     99! DESCRIPTION
     100!     Deallocate orbital data arrays.
     101!
     102! AUTHORS & DATE
     103!     R. Vandemeulebrouck
     104!     JB Clement, 2023-2025
     105!
     106! NOTES
     107!
     108!-----------------------------------------------------------------------
     109
     110! DECLARATION
     111! -----------
    63112implicit none
    64113
     114! CODE
     115! ----
    65116if (allocated(year_lask)) deallocate(year_lask)
    66 if (allocated(obl_lask)) deallocate(obl_lask)
    67 if (allocated(ecc_lask)) deallocate(ecc_lask)
    68 if (allocated(lsp_lask)) deallocate(lsp_lask)
     117if (allocated(obl_lask))  deallocate(obl_lask)
     118if (allocated(ecc_lask))  deallocate(ecc_lask)
     119if (allocated(lsp_lask))  deallocate(lsp_lask)
    69120
    70121END SUBROUTINE end_orbit
    71122!=======================================================================
    72123
     124!=======================================================================
    73125SUBROUTINE orbit_param_criterion(i_myear,nyears_maxorb)
    74 
     126!-----------------------------------------------------------------------
     127! NAME
     128!     orbit_param_criterion
     129!
     130! DESCRIPTION
     131!     Determine maximum PEM iterations before orbital params change
     132!     beyond admissible thresholds.
     133!
     134! AUTHORS & DATE
     135!     R. Vandemeulebrouck
     136!     JB Clement, 2023-2025
     137!
     138! NOTES
     139!
     140!-----------------------------------------------------------------------
    75141#ifdef CPP_IOIPSL
    76142    use IOIPSL,          only: getin
     
    83149use evolution,      only: year_bp_ini, var_obl, var_ecc, var_lsp, convert_years
    84150
     151! DECLARATION
     152! -----------
    85153implicit none
    86154
    87 !--------------------------------------------------------
    88 ! Input Variables
    89 !--------------------------------------------------------
    90 real, intent(in) :: i_myear ! Martian year of the simulation
    91 
    92 !--------------------------------------------------------
    93 ! Output Variables
    94 !--------------------------------------------------------
     155! ARGUMENTS
     156! ---------
     157real, intent(in)  :: i_myear       ! Martian year of the simulation
    95158real, intent(out) :: nyears_maxorb ! Maximum number of iteration of the PEM before orb changes too much
    96159
    97 !--------------------------------------------------------
    98 ! Local variables
    99 !--------------------------------------------------------
     160! LOCAL VARIABLES
     161! ---------------
    100162real                            :: Year                                           ! Year of the simulation
    101163real                            :: Lsp                                            ! Ls perihelion
     
    103165real                            :: max_obl, max_ecc, max_lsp                      ! Maximum value of orbit param given the admissible change
    104166real                            :: min_obl, min_ecc, min_lsp                      ! Minimum value of orbit param given the admissible change
    105 real                            :: nyears_maxobl, nyears_maxecc, nyears_maxlsp       ! Maximum year iteration before reaching an inadmissible value of orbit param
    106 integer                         :: i                                          ! Loop variable
    107 real                            :: xa, xb, ya, yb                                 ! Variables for interpolation
    108 logical                         :: found_obl, found_ecc, found_lsp                ! Flag variables for orbital parameters
    109 real                            :: lsp_corr                                       ! Lsp corrected if the "modulo is crossed"
    110 real                            :: delta                                          ! Intermediate variable
    111 real, dimension(:), allocatable :: lsplask_unwrap                                 ! Unwrapped sequence of Lsp from Laskar's file
    112 
     167real                            :: nyears_maxobl, nyears_maxecc, nyears_maxlsp    ! Maximum year iteration before reaching an inadmissible value of orbit param
     168real                            :: xa, xb, ya, yb                  ! Variables for interpolation
     169logical                         :: found_obl, found_ecc, found_lsp ! Flag variables for orbital parameters
     170real                            :: lsp_corr                        ! Lsp corrected if the "modulo is crossed"
     171real                            :: delta                           ! Intermediate variable
     172real, dimension(:), allocatable :: lsplask_unwrap                  ! Unwrapped sequence of Lsp from Laskar's file
     173integer                         :: i
     174
     175! CODE
     176! ----
    113177! **********************************************************************
    114178! 0. Initializations
     
    246310
    247311END SUBROUTINE orbit_param_criterion
    248 
    249 !***********************************************************************
    250 ! Purpose: Recompute orbit parameters based on values by Laskar et al.
     312!=======================================================================
     313
     314!=======================================================================
    251315SUBROUTINE set_new_orbitpm(i_myear,i_myear_leg)
     316!-----------------------------------------------------------------------
     317! NAME
     318!     set_new_orbitpm
     319!
     320! DESCRIPTION
     321!     Recompute orbit parameters from Laskar values at a new year and
     322!     update planetary constants; handles Lsp modulo crossings.
     323!
     324! AUTHORS & DATE
     325!     R. Vandemeulebrouck
     326!     JB Clement, 2023-2025
     327!
     328! NOTES
     329!
     330!-----------------------------------------------------------------------
    252331
    253332use evolution,        only: year_bp_ini, var_obl, var_ecc, var_lsp
     
    256335use call_dayperi_mod, only: call_dayperi
    257336
     337! DECLARATION
     338! -----------
    258339implicit none
    259340
    260 !--------------------------------------------------------
    261 ! Input Variables
    262 !--------------------------------------------------------
     341! ARGUMENTS
     342! ---------
    263343real, intent(in) :: i_myear     ! Number of simulated Martian years
    264344real, intent(in) :: i_myear_leg ! Number of iterations of the PEM
    265345
    266 !--------------------------------------------------------
    267 ! Output Variables
    268 !--------------------------------------------------------
    269 
    270 !--------------------------------------------------------
    271 ! Local variables
    272 !--------------------------------------------------------
     346! LOCAL VARIABLES
     347! ---------------
    273348real    :: Year           ! Year of the simulation
    274349real    :: Lsp            ! Ls perihelion
    275 integer :: i          ! Loop variable
    276350real    :: halfaxe        ! Million of km
     351integer :: i
    277352real    :: unitastr
    278353real    :: xa, xb, ya, yb ! Variables for interpolation
    279354logical :: found_year     ! Flag variable
    280355
     356! CODE
     357! ----
    281358! **********************************************************************
    282359! 0. Initializations
     
    353430
    354431END SUBROUTINE set_new_orbitpm
     432!=======================================================================
    355433
    356434END MODULE orbit
Note: See TracChangeset for help on using the changeset viewer.