source: trunk/LMDZ.COMMON/libf/evolution/deftank/modify_startfi_orbit.sh @ 3209

Last change on this file since 3209 was 3145, checked in by jbclement, 2 years ago

PEM:

  • Addition of a script in LMDZ.MARS/deftank/pem/ to launch a chained simulation of 1D PCM runs which follow, year by year, the orbital parameters (obliquity, eccentricity, Ls perihelion) given in a specified file.
  • Small changes to other files of the deftank directory (check and cosmetic).

JBC

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/bin/bash
2######################################################################
3### Script to modify the orbital parameters of a file "startfi.nc" ###
4######################################################################
5
6# Name of the file to be modified
7name_file="startfi.nc"
8
9# New values for the orbital parameters
10new_obl=25.18941689
11new_ecc=0.09340902
12new_Lsp=251.06881714
13new_iniLs=0.
14
15
16# Calculate modified values
17if [ ! -f "$name_file" ]; then
18    echo "Error: file \"$name_file\" not found!"
19    exit 1
20fi
21year_day=669.
22halfaxe=227.94
23pi=$(echo "4.*a(1.)" | bc -l)
24degrad=$(echo "180./$pi" | bc -l)
25
26periheli=$(echo "$halfaxe*(1. - $new_ecc)" | bc -l)
27aphelie=$(echo "$halfaxe*(1. + $new_ecc)" | bc -l)
28
29tan=$(echo "s(0.5*$new_Lsp/$degrad)/c(0.5*$new_Lsp/$degrad)" | bc -l)
30zx0=$(echo "-2.*a($tan*sqrt((1. - $new_ecc)/(1. + $new_ecc)))" | bc -l)
31if [ $(echo "$zx0 <= 0." | bc -l) -eq 1 ]; then
32    zx0=$(echo "$zx0 + 2.*$pi" | bc -l)
33fi
34peri_day=$(echo "$year_day*(1. - ($zx0 - $new_ecc*s($zx0))/(2.*$pi))" | bc -l)
35
36ztheta=$(echo "($new_iniLs - $new_Lsp)/$degrad" | bc -l)
37tan=$(echo "s(0.5*$ztheta)/c(0.5*$ztheta)" | bc -l)
38zx0=$(echo "2.*a($tan*sqrt((1. - $new_ecc)/(1. + $new_ecc)))" | bc -l)
39xref=$(echo "$zx0 - $new_ecc*s($zx0)" | bc -l)
40new_inisol=$(echo "$peri_day + $xref*$year_day/(2.*$pi)" | bc -l)
41if [ $(echo "$new_inisol < 0." | bc -l) -eq 1 ]; then
42    new_inisol=$(echo "$new_inisol + $year_day" | bc -l)
43fi
44if [ $(echo "$new_inisol >= $year_day" | bc -l) -eq 1 ]; then
45    new_inisol=$(echo "$new_inisol - $year_day" | bc -l)
46fi
47
48# Update the netCDF file
49# controle(15) = periheli ! min. Sun-Mars distance (Mkm)  ̃206.66
50# controle(16) = aphelie  ! max. SUn-Mars distance (Mkm)  ̃249.22
51# controle(17) = peri_day ! date of perihelion (sols since N. spring)
52# controle(18) = obliquit ! Obliquity of the planet (deg)  ̃23.98
53# controle(3)  = day_ini + int(time) ! initial day
54ncap2 -O -s "controle(17)=$new_obl" \
55         -s "controle(14)=$periheli" \
56         -s "controle(15)=$aphelie" \
57         -s "controle(16)=$peri_day" \
58         -s "controle(2)=$new_inisol" \
59         $name_file $name_file
60
61echo "In \"$name_file\":"
62echo "New obliquit     = $new_obl"
63echo "New eccentricity = $new_ecc -> new periheli = $periheli"
64echo "                              -> new aphelie  = $aphelie"
65echo "New Lsp          = $new_Lsp -> new peri_day = $peri_day"
66echo "New initial Ls   = $new_iniLs -> New initial sol = $new_inisol"
67echo "Done!"
Note: See TracBrowser for help on using the repository browser.