source: trunk/LMDZ.MARS/deftank/launch_1Dchained.sh @ 3493

Last change on this file since 3493 was 3465, checked in by jbclement, 2 months ago

Mars PCM:

  • Small update in "analyse_netcdf.py".
  • Putting the 1D launching scripts back to the "deftank" folder.

JBC

  • Property svn:executable set to *
File size: 3.1 KB
RevLine 
[3209]1#!/bin/bash
2################################################################
3### Launching script for a chained simulation of 1D PCM runs ###
4################################################################
5
6echo "The launching script is starting!"
7echo "The output file is \"loglaunch.txt\"."
8if [ "$1" = "bg" ]; then
9    date
10else
11    nohup "$0" bg > loglaunch.txt 2>&1 &
12    exit 1
13fi
14
15# A few parameters that might need be changed depending on your setup:
16# Path to the arch.env to source:
17source ../trunk/LMDZ.COMMON/arch.env
18
19# Save the current value of LC_NUMERIC and set it to a locale that uses a dot as the decimal separator
20OLD_LC_NUMERIC=$LC_NUMERIC
21LC_NUMERIC=en_US.UTF-8
22
23
24################################################################
25#---------- Modify here the number of years to be simulated ------------
26## set the number of Martian years:
27n_myears=1000
28
29#------------------ Modify here the name of PCM exe --------------------
30## fill in the name of executable for PCM:
31exePCM="testphys1d_29_phymars_seq.e"
32################################################################
33
34
35#------ Check if files/directories necessary for the script exist ------
36dir=`pwd`
37machine=`hostname`
38address=`whoami`
39if [ ! -f "$exePCM" ]; then
40    echo "Error: file \"$exePCM\" does not exist in $dir!"
41    exit 1
42fi
43if [ ! -d "out_PCM" ]; then
44    mkdir out_PCM
45fi
46if [ ! -d "starts" ]; then
47    mkdir starts
48fi
49if [ ! -d "diags" ]; then
50    mkdir diags
51fi
52
53#---------------------------- Initialization ---------------------------
54dir=`pwd`
55machine=`hostname`
56address=`whoami`
57echo "This is a chained simulation for PCM runs in $dir on $machine."
58echo "Number of years to be simulated: $n_myears Martian years."
59myear=686.9725      # Number of Earth days in Martian year
60eyear=365.256363004 # Number of days in Earth year
61convert_years=$(echo "$myear/$eyear" | bc -l)
62convert_years=$(printf "%.4f" $convert_years) # Rounding to the 4th decimal to respect the precision of Martian year
63i_myear=0
64iPCM=1
65cp startfi.nc starts/
66if [ -f "star1D.nc" ]; then
67    cp star1D.txt starts/
68fi
69
70#---------------- Main loop to to run PCM year by year -----------------
71while [ $i_myear -lt $n_myears ]; do
72    # Run the PCM
73    echo "Run PCM $iPCM: year $iPCM/$n_myears..."
74    ./$exePCM > out_runPCM${iPCM} 2>&1
75    if [ ! -f "restartfi.nc" ]; then # Check if run ended abnormally
[3213]76        echo "Error: the run PCM $iPCM crashed!"
[3209]77        exit 1
78    fi
79    # Copy data files and prepare the next run
80    mv out_runPCM${iPCM} out_PCM/run${iPCM}
81    mv diagfi.nc diags/diagfi${iPCM}.nc
82    if [ -f "diagsoil.nc" ]; then
83        mv diagsoil.nc diags/diagsoil${iPCM}.nc
84    fi
85    if [ -f "stats.nc" ]; then
86        mv stats.nc diags/stats${iPCM}.nc
87    fi
88    if [ -f "Xdiurnalave.nc" ]; then
89        mv Xdiurnalave.nc diags/Xdiurnalave${iPCM}.nc
90    fi
91    cp restartfi.nc starts/startfi${iPCM}.nc
92    mv restartfi.nc startfi.nc
93    if [ -f "restart1D.txt" ]; then
94        cp restart1D.txt starts/restart1D${iPCM}.txt
95        mv restart1D.txt start1D.txt
96    fi
97    ((iPCM++))
98    ((i_myear++))
99    echo "Done!"
100done
101
102# Restore the previous value of LC_NUMERIC
103LC_NUMERIC=$OLD_LC_NUMERIC
104
105date
[3213]106echo "The launching script ended."
Note: See TracBrowser for help on using the repository browser.