Ignore:
Timestamp:
Sep 19, 2025, 2:53:16 PM (2 months ago)
Author:
jbclement
Message:

Mars PCM 1D:

  • "profile.F" is transformed into a module "profile_temp_mod.F90" with F90 format. The file "profile" where the temperature is read is renamed into "profile_temp" to avoid any confusion.
  • Small corrections and improvements throughout the code and scripts in the deftank.

JBC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/deftank/launch_1Dchained.sh

    r3580 r3918  
    77
    88
    9 echo "The launching script is starting!"
    10 echo "The output file is \"loglaunch.txt\"."
    11 if [ "$1" = "bg" ]; then
    12     date
    13 else
    14     nohup "$0" bg > loglaunch.txt 2>&1 &
    15     exit 1
    16 fi
    17 
    18 # Save the current value of LC_NUMERIC and set it to a locale that uses a dot as the decimal separator
    19 OLD_LC_NUMERIC=$LC_NUMERIC
    20 LC_NUMERIC=en_US.UTF-8
    21 
    229################################################################
    2310# Modify here the parameters for the simulation
     
    2714
    2815# Set the number of Martian years to be simulated:
    29 n_myears=1000
     16n_myear=100
    3017
    3118# Name of executable for the PCM:
    32 exePCM="testphys1d_29_phymars_seq.e"
     19exePCM="testphys1d_32_phymars_seq.e"
    3320################################################################
    3421
    3522
    36 # Check if files/directories necessary for the script exist
     23echo "The launching script is starting!"
     24echo "The output file is \"launch.log\"."
     25exec > launch.log 2>&1
     26
     27# Save the current value of LC_NUMERIC and set it to a locale that uses a dot as the decimal separator
     28OLD_LC_NUMERIC=$LC_NUMERIC
     29LC_NUMERIC=en_US.UTF-8
     30
     31# To end the launching script with error
     32errlaunch() {
     33    # Restore the previous value of LC_NUMERIC
     34    LC_NUMERIC=$OLD_LC_NUMERIC
     35
     36    date
     37    echo "Error: an issue occured in the launching script!"
     38    exit 1
     39}
     40
     41
     42# Check if the set-up is correct
    3743dir=`pwd`
    3844machine=`hostname`
    3945address=`whoami`
     46if [ -v n_myear ]; then
     47    if [ $(echo "$n_myear <= 0." | bc -l) -eq 1 ]; then
     48        echo "Error: 'n_myear' must be > 0!"
     49        errlaunch
     50    fi
     51else
     52    echo "Error: the number of years to be simulated is not set!"
     53    errlaunch
     54fi
    4055if [ ! -f "$exePCM" ]; then
    4156    echo "Error: file \"$exePCM\" does not exist in $dir!"
    42     exit 1
     57    errlaunch
    4358fi
    44 if [ ! -d "out_PCM" ]; then
    45     mkdir out_PCM
     59if [ ! -d "logs" ]; then
     60    mkdir logs
    4661fi
    4762if [ ! -d "starts" ]; then
     
    5671machine=`hostname`
    5772address=`whoami`
    58 echo "This is a chained simulation for PCM runs in $dir on $machine."
    59 echo "Number of years to be simulated: $n_myears Martian years."
    60 myear=686.9725      # Number of Earth days in Martian year
    61 eyear=365.256363004 # Number of days in Earth year
    62 convert_years=$(echo "$myear/$eyear" | bc -l)
    63 convert_years=$(printf "%.4f" $convert_years) # Rounding to the 4th decimal to respect the precision of Martian year
     73echo "This is a chained simulation for PCM 1D runs in $dir on $machine."
     74echo "Number of years to be simulated: $n_myear Martian years."
    6475i_myear=0
    6576iPCM=1
    66 cp startfi.nc starts/
    67 if [ -f "star1D.nc" ]; then
    68     cp star1D.txt starts/
     77if [ -f "startfi.nc" ]; then
     78    cp startfi.nc starts/
     79fi
     80if [ -f "start1D.txt" ]; then
     81    cp start1D.txt starts/
    6982fi
    7083
    7184# Main loop to to run PCM year by year
    72 while [ $i_myear -lt $n_myears ]; do
     85while [ $i_myear -lt $n_myear ]; do
    7386    # Run the PCM
    74     echo "Run PCM $iPCM: year $iPCM/$n_myears..."
    75     ./$exePCM > out_runPCM${iPCM} 2>&1
    76     if [ ! -f "restartfi.nc" ]; then # Check if run ended abnormally
    77         echo "Error: the run PCM $iPCM crashed!"
    78         exit 1
     87    echo "Run $iPCM: year $iPCM/$n_myear..."
     88    ./$exePCM > run.log 2>&1
     89    if [ ! -f "restartfi.nc" ] || ! (tail -n 100 run.log | grep -iq "everything is cool!"); then # Check if it ended abnormally
     90        echo "Error: the run $iPCM crashed!"
     91        errlaunch
    7992    fi
    8093    # Copy data files and prepare the next run
    81     mv out_runPCM${iPCM} out_PCM/run${iPCM}
    82     mv diagfi.nc diags/diagfi${iPCM}.nc
     94    mv run.log logs/run${iPCM}.log
     95    if [ -f "diagfi.nc" ]; then
     96        mv diagfi.nc diags/diagfi${iPCM}.nc
     97    fi
    8398    if [ -f "diagsoil.nc" ]; then
    8499        mv diagsoil.nc diags/diagsoil${iPCM}.nc
     
    105120
    106121date
    107 echo "The launching script ended."
     122echo "Success: the launching script completed normally!"
     123exit 0
Note: See TracChangeset for help on using the changeset viewer.