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

Last change on this file since 3554 was 3210, checked in by jbclement, 11 months ago

PEM:

  • Addition in the deftank of a bash script "modify_startfi_var.sh" to modify the value of a variable in a "startfi.nc".
  • Small corrections due to r3206.

JBC

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