Ignore:
Timestamp:
Sep 21, 2023, 11:56:12 AM (21 months ago)
Author:
jbclement
Message:

Mars PEM:
Correction of a case where maximum admissible change of orbital parameters could not be found, in particular for Lsp because of modulo + some improvements.
JBC

Location:
trunk/LMDZ.COMMON/libf/evolution
Files:
2 edited

Legend:

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

    r3040 r3047  
    5252  integer :: max_obl_iter, max_ecc_iter, max_lsp_iter       ! Maximum year iteration before reaching an inadmissible value of orbit param
    5353  integer :: ilask, iylask                                  ! Loop variables
    54   real    :: xa, xb, ya, yb, yc_obl, yc_ecc, yc_lsp         ! Variables for interpolation
     54  real    :: xa, xb, ya, yb                                 ! Variables for interpolation
     55  logical :: found_obl, found_ecc, found_lsp                ! Flag variables for orbital parameters
     56  logical :: crossed_modulo_d, crossed_modulo_i             ! Flag variables for modulo of Lsp
    5557
    5658! **********************************************************************
     
    6971! We read the file
    7072open(73,file = 'obl_ecc_lsp.asc')
     73last_ilask = 0
    7174do ilask = 1,size(yearlask,1)
    7275    read(73,*) yearlask(ilask), obllask(ilask), ecclask(ilask), lsplask(ilask)
     
    7578enddo
    7679close(73)
    77 write(*,*) 'Corresponding line in the obl_ecc_lsp.asc file =', last_ilask
     80if (last_ilask == 0 .or. last_ilask == size(yearlask,1) + 1) then
     81    write(*,*) 'The current year could not be find in the file "obl_ecc_lsp.asc".'
     82    stop
     83else
     84    write(*,*) 'The current year in the "obl_ecc_lsp.asc" file is at line:', last_ilask
     85endif
    7886
    7987! Constant max change case
     
    8290max_change_lsp = 18.
    8391
    84 call getin('max_change_obl', max_change_obl)
     92call getin('max_change_obl',max_change_obl)
    8593max_obl = obliquit + max_change_obl
    8694min_obl = obliquit - max_change_obl
     
    8896write(*,*) 'Minimum obliquity accepted =', min_obl
    8997
    90 call getin('max_change_ecc', max_change_ecc)
     98call getin('max_change_ecc',max_change_ecc)
    9199max_ecc = min(e_elips + max_change_ecc,1. - 1.e-10) ! ex < 1.
    92100min_ecc = max(e_elips - max_change_ecc,0.) ! ex >= 0.
     
    94102write(*,*) 'Minimum eccentricity accepted =', min_ecc
    95103
    96 call getin('max_change_lsp', max_change_lsp)
     104call getin('max_change_lsp',max_change_lsp)
    97105max_lsp = Lsp + max_change_lsp
    98106min_lsp = Lsp - max_change_lsp
     
    107115max_lsp_iter = 1000000
    108116
    109         ! Tendency of the orbital parameter for the considered year gives the limitation between min and max
     117! The maximum reachable year is found by interpolation according to the maximum admissible change of orbital parameters
     118found_obl = .false.
     119found_ecc = .false.
     120found_lsp = .false.
     121if (.not. var_obl) found_obl = .true.
     122if (.not. var_ecc) found_ecc = .true.
     123if (.not. var_lsp) found_lsp = .true.
     124crossed_modulo_d = .false.
     125crossed_modulo_i = .false.
     126
    110127do ilask = last_ilask,2,-1
    111128    xa = yearlask(ilask)
    112129    xb = yearlask(ilask - 1)
    113     if (xa <= Year .and. Year < xb) then
    114         ! Obliquity
    115         if (var_obl) then
    116             ya = obllask(ilask)
    117             yb = obllask(ilask - 1)
    118             if (ya < yb) then ! Increasing -> max is the limitation
    119                 yc_obl = max_obl
    120             else ! Decreasing -> min is the limitation
    121                 yc_obl = min_obl
    122             endif
    123         endif
    124 
    125         ! Eccentricity
    126         if (var_ecc) then
    127             ya = ecclask(ilask)
    128             yb = ecclask(ilask - 1)
    129             if (ya < yb) then ! Increasing -> max is the limitation
    130                 yc_ecc = max_ecc
    131             else ! Decreasing -> min is the limitation
    132                 yc_ecc = min_ecc
    133             endif
    134         endif
    135 
    136         ! Lsp
    137         if (var_lsp) then
    138             ya = lsplask(ilask)
    139             yb = lsplask(ilask - 1)
    140              if (ya < yb) then ! Increasing -> max is the limitation
    141                 if (yb - ya > 300.) then ! If modulo is "crossed" then it is the other way around
    142                     yc_lsp = min_lsp
     130
     131    ! Obliquity
     132    if (var_obl .and. .not. found_obl) then
     133        ya = obllask(ilask)
     134        yb = obllask(ilask - 1)
     135        if (yb < min_obl) then ! The minimum accepted is overtaken
     136            max_obl_iter = floor((min_obl - ya)*(xb - xa)/(yb - ya) + xa) - Year
     137            found_obl = .true.
     138        else if (max_obl < yb) then ! The maximum accepted is overtaken
     139            max_obl_iter = floor((max_obl - ya)*(xb - xa)/(yb - ya) + xa) - Year
     140            found_obl = .true.
     141        endif
     142    endif
     143
     144    ! Eccentricity
     145    if (var_ecc .and. .not. found_ecc) then
     146        ya = ecclask(ilask)
     147        yb = ecclask(ilask - 1)
     148        if (yb < min_ecc) then ! The minimum accepted is overtaken
     149            max_ecc_iter = floor((min_ecc - ya)*(xb - xa)/(yb - ya) + xa) - Year
     150            found_ecc = .true.
     151        else if (max_ecc < yb) then ! The maximum accepted is overtaken
     152            max_ecc_iter = floor((max_ecc - ya)*(xb - xa)/(yb - ya) + xa) - Year
     153            found_ecc = .true.
     154        endif
     155    endif
     156
     157    ! Lsp
     158    if (var_lsp .and. .not. found_lsp) then
     159        ya = lsplask(ilask)
     160        yb = lsplask(ilask - 1)
     161        if (abs(yb - ya) > 300.) then ! If modulo is "crossed" through the interval
     162            if (ya < yb) then ! Lsp should be decreasing
     163                if (.not. crossed_modulo_i) then
     164                    yb = yb - 360.
     165                    if (min_lsp < 0.) crossed_modulo_d = .true.
    143166                else
    144                     yc_lsp = max_lsp
     167                    crossed_modulo_i = .false.
    145168                endif
    146             else ! Decreasing -> min is the limitation
    147                 if (ya - yb > 300.) then ! If modulo is "crossed" then it is the other way around
    148                     yc_lsp = max_lsp
     169            else ! Lsp should be increasing
     170                if (.not. crossed_modulo_d) then
     171                    yb = yb + 360.
     172                    if (max_lsp > 360.) crossed_modulo_i = .true.
    149173                else
    150                     yc_lsp = min_lsp
     174                    crossed_modulo_d = .false.
    151175                endif
    152176            endif
    153         endif
    154         iylask = ilask
    155         exit ! The loop is left as soon as the right interval is found
     177        else
     178            if (crossed_modulo_d) then ! If decreasing Lsp "crossed" the modulo but min_lsp has not been met yet
     179                ya = ya - 360.
     180                yb = yb - 360.
     181            else if (crossed_modulo_i) then ! If increasing Lsp "crossed" the modulo but max_lsp has not been met yet
     182                ya = ya + 360.
     183                yb = yb + 360.
     184            endif
     185        endif
     186        if (yb < min_lsp) then ! The minimum accepted is overtaken
     187            max_lsp_iter = floor((min_lsp - ya)*(xb - xa)/(yb - ya) + xa) - Year
     188            found_lsp = .true.
     189        else if (max_lsp < yb) then ! The maximum accepted is overtaken
     190            max_lsp_iter = floor((max_lsp - ya)*(xb - xa)/(yb - ya) + xa) - Year
     191            found_lsp = .true.
     192        endif
    156193    endif
     194
     195    if (found_obl .and. found_ecc .and. found_lsp) exit ! The loop is left as soon as everything is found
    157196enddo
    158197
    159 if (ilask == 1) then
    160     write(*,*) 'The year does not match with Laskar data in the file obl_ecc_lsp.asc.'
    161     stop
    162 endif
    163 
    164 ! Linear interpolation gives the maximum reachable year according to the limitation
    165 ! Obliquity
    166 if (var_obl) then
    167     do ilask = iylask,2,-1
    168         ya = obllask(ilask)
    169         yb = obllask(ilask - 1)
    170         if (min(ya,yb) <= yc_obl .and. yc_obl < max(ya,yb)) then
    171             xa = yearlask(ilask)
    172             xb = yearlask(ilask - 1)
    173             max_obl_iter = floor((yc_obl - ya)*(xb - xa)/(yb - ya) + xa) - Year
    174             exit ! The loop is left as soon as the right interval is found
    175         endif
    176     enddo
    177 endif
    178 ! Eccentricity
    179 if (var_ecc) then
    180     do ilask = iylask,2,-1
    181         ya = ecclask(ilask)
    182         yb = ecclask(ilask - 1)
    183         if (min(ya,yb) <= yc_ecc .and. yc_ecc < max(ya,yb)) then
    184             xa = yearlask(ilask)
    185             xb = yearlask(ilask - 1)
    186             max_ecc_iter = floor((yc_ecc - ya)*(xb - xa)/(yb - ya) + xa) - Year
    187             exit ! The loop is left as soon as the right interval is found
    188         endif
    189     enddo
    190 endif
    191 ! Lsp
    192 if (var_lsp) then
    193     do ilask = iylask,2,-1
    194         ya = lsplask(ilask)
    195         yb = lsplask(ilask - 1)
    196         if (min(ya,yb) <= yc_lsp .and. yc_lsp < max(ya,yb)) then
    197             xa = yearlask(ilask)
    198             xb = yearlask(ilask - 1)
    199             max_lsp_iter = floor((yc_lsp - ya)*(xb - xa)/(yb - ya) + xa) - Year
    200             exit ! The loop is left as soon as the right interval is found
    201         endif
    202     enddo
    203 endif
     198if (.not. found_obl) write(*,*) 'The maximum reachable year for obl. could not be find in the file "obl_ecc_lsp.asc".'
     199if (.not. found_ecc) write(*,*) 'The maximum reachable year for ecc. could not be find in the file "obl_ecc_lsp.asc".'
     200if (.not. found_lsp) write(*,*) 'The maximum reachable year for Lsp could not be find in the file "obl_ecc_lsp.asc".'
    204201
    205202write(*,*) 'Max. number of iterations for the obl. parameter =', max_obl_iter
     
    208205
    209206year_iter_max = min(max_obl_iter,max_ecc_iter,max_lsp_iter)
    210 if (year_iter_max > 0) then
    211     write(*,*) 'So the max. number of iterations for the orbital criteria =', year_iter_max
    212 else
    213     write(*,*) 'The max. number of iterations is not compatible with Laskar data in the file obl_ecc_lsp.asc.'
    214     stop
    215 endif
     207write(*,*) 'So the max. number of iterations for the orbital criteria =', year_iter_max
    216208
    217209END SUBROUTINE orbit_param_criterion
  • TabularUnified trunk/LMDZ.COMMON/libf/evolution/recomp_orb_param_mod.F90

    r3040 r3047  
    4444  real    :: unitastr
    4545  real    :: xa, xb, ya, yb ! Variables for interpolation
     46  logical :: found_year     ! Flag variable
    4647
    4748! **********************************************************************
     
    6465write(*,*) 'recomp_orb_param, Old Lsp  =', Lsp
    6566
     67found_year = .false.
    6668do ilask = last_ilask,2,-1
    6769    xa = yearlask(ilask)
     
    8688            ya = lsplask(ilask)
    8789            yb = lsplask(ilask - 1)
    88             if (yb - ya > 300.) then ! If modulo is "crossed"
    89                 if (ya < yb) then ! Increasing
    90                     yb = yb - 360.
    91                 else ! Decreasing
     90            if (abs(yb - ya) > 300.) then ! If modulo is "crossed" through the interval
     91                if (ya < yb) then ! Lsp should be decreasing
     92                    ya = ya + 360.
     93                else ! Lsp should be increasing
    9294                    yb = yb + 360.
    9395                endif
    9496            endif
    95             Lsp = (Year - xa)*(yb - ya)/(xb - xa) + ya
    96             Lsp = modulo(Lsp,360.)
     97            Lsp = modulo((Year - xa)*(yb - ya)/(xb - xa) + ya,360.)
    9798        endif
     99        found_year = .true.
    98100        exit ! The loop is left as soon as the right interval is found
    99101    endif
    100102enddo
     103
     104if (.not. found_year) then
     105    write(*,*) 'The new year could not be found in the file "obl_ecc_lsp.asc".'
     106    stop
     107endif
     108
    101109halfaxe = 227.94
    102110Lsp = Lsp*pi/180.
Note: See TracChangeset for help on using the changeset viewer.