Changeset 3023


Ignore:
Timestamp:
Aug 1, 2023, 4:32:24 PM (16 months ago)
Author:
jbclement
Message:

Mars Deftank:
Complete rewriting (much simpler) of script "run_pem1d_1" in deftank/pem/ to launch chained simulations of 1D PCM/PEM. To be adapted to 3D in the future.
JBC

Location:
trunk
Files:
3 edited

Legend:

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

    r3022 r3023  
    4141!--------------------------------------------------------
    4242
    43       real :: Year                      ! Year of the simulation
    44       real :: Lsp               ! time of peri in ls
    45       integer ilask                     ! Loop variable
    46       real :: halfaxe                   ! Million of km
     43      real :: Year     ! Year of the simulation
     44      real :: Lsp      ! time of peri in ls
     45      integer ilask    ! Loop variable
     46      real :: halfaxe  ! Million of km
    4747      real :: unitastr
    4848
  • trunk/LMDZ.MARS/changelog.txt

    r3022 r3023  
    41604160== 1/08/2023 == JBC
    41614161Rework and correction of computation of the maximum number of iterations for PEM according to orbital parameters.
     4162
     4163== 1/08/2023 == JBC
     4164Complete rewriting (much simpler) of script "run_pem1d_1" in deftank/pem/ to launch chained simulations of 1D PCM/PEM. To be adapted to 3D in the future.
  • trunk/LMDZ.MARS/deftank/pem/run_pem1d_1

    r2980 r3023  
    2525
    2626# A few parameters that might need be changed depending on your setup:
    27 # Path to the arch.env to source
     27# Path to the arch.env to source:
    2828source ../trunk/LMDZ.COMMON/arch.env
    29 # Number of threads to use (must be the same as "#MSUB -c" above)
    30 export OMP_NUM_THREADS=1
    31 export OMP_STACKSIZE=400M
    3229
    33 #------------------Modify here the number of PEM call----------------------
     30#------------------ Modify here the name of PEM exe --------------------
     31## fill in the name of executable for PEM:
     32exePEM=pem_29_phymars_seq.e
    3433
    35 ## set starting PEM first and last number call:
    36 num_PEM_now=1
    37 num_PEM_end=20
    38 (( num_PEM_previous = $num_PEM_now - 1 ))
     34#------------------ Modify here the name of GCM exe --------------------
     35## fill in the name of executable for GCM:
     36exeGCM=testphys1d_29_phymars_para.e
    3937
    40 #-----------------Modify here the number of GCM call between each PEM ---------
     38#-------------- Modify here the name of reshape XIOS exe ---------------
     39## fill in the name of executable for reshape XIOS:
     40exeReshape=reshape_XIOS_output_64x48x29_phymars_seq.e
    4141
    42 ## set number of GCM call between each PEM call:
    43 nb_GCM_call=2
     42#---------------- Modify here the number of PEM calls ------------------
     43## set the number of PEM calls:
     44nPEM=1000
    4445
    45 #----------------Here we launch GCM call year by year ---------
     46#---------------- Modify here the number of GCM calls ------------------
     47## set the number of GCM calls between each PEM call:
     48nGCM=2
    4649
    47 (( num_GCM_now = ($num_PEM_now - 1)* $nb_GCM_call + 1 ))
    48 (( num_GCM_previous = $num_GCM_now - 1 ))
    49 (( num_GCM_end = $num_GCM_previous + $nb_GCM_call ))
    5050
    51 echo "num_GCM_now $num_GCM_now"
    52 echo "num_GCM_previous $num_GCM_previous"
    53 echo "num_GCM_end $num_GCM_end"
    5451
    55 echo "$num_GCM_previous" > num_run
    56 
    57   \cp -f startfi$num_GCM_previous.nc startfi.nc
    58   ./testphys1d_29_phymars_seq.e > lrun$num_GCM_now 2>&1
    59   \cp -f diagfi.nc diagfi$num_GCM_now.nc
    60   \cp -f diagfi.nc data2reshape1.nc
    61   \cp -f restartfi.nc startfi${num_GCM_now}.nc
    62   \cp -f restartfi.nc startfi.nc
    63 
    64   ./testphys1d_29_phymars_seq.e > lrun$num_GCM_end 2>&1
    65   \cp -f diagfi.nc diagfi$num_GCM_end.nc
    66   \cp -f diagfi.nc data2reshape2.nc
    67   \cp -f restartfi.nc startfi${num_GCM_end}_GCM.nc
    68   \cp -f restartfi.nc startfi_evol.nc
    69 
    70 #--------------- We reshape the GCM data from XIOS-------------------
    71 
    72 rm -rf datareshaped1.nc
    73 rm -rf datareshaped2.nc
    74 
    75 ./reshape_XIOS_output_32x24x27_phymars_seq.e
    76 
    77 #---------------- We rename files for the PEM call----------------
    78 
    79 cp datareshaped1.nc data_GCM_Y1.nc
    80 echo "y"
    81 cp datareshaped2.nc data_GCM_Y2.nc
    82 echo "y"
    83 
    84 #--------------- We run the PEM ------------------
    85 
    86 if [[ -r run.def_PEM ]] ; then
    87   cp run.def_PEM run.def
    88   echo "y"
     52#--------- Check if files/directories exist to be able to run ----------
     53echo Starting script to call PEM with GCM!
     54if [ ! -d "profiles" ]; then
     55    mkdir profiles
     56else
     57    rm profiles/*
    8958fi
    90 if [[ -r diagfi.def_PEM ]] ; then
    91   cp diagfi.def_PEM diagfi.def
    92   echo "y"
     59if [ ! -d "diagfis" ]; then
     60    mkdir diagfis
     61else
     62    rm diagfis/*
     63fi
     64if [ ! -d "startfis" ]; then
     65    mkdir startfis
     66else
     67    rm startfis/*
     68fi
     69if [ ! -r "context_lmdz_physics.xml" ]; then
     70    echo File context_lmdz_physics.xml does not exist!
     71    exit 0
     72fi
     73if [ ! -r "field_def_physics_mars.xml" ]; then
     74    echo File field_def_physics_mars.xml does not exist!
     75    exit 0
     76fi
     77if [ ! -r "file_def_physics_mars.xml" ]; then
     78    echo File file_def_physics_mars.xml does not exist!
     79    exit 0
     80fi
     81if [ ! -r "iodef.xml" ]; then
     82    echo File iodef.xml does not exist!
     83    exit 0
     84fi
     85if [ ! -r "run_PEM.def" ]; then
     86    echo File diagfi_PEM.def does not exist!
     87    exit 0
     88fi
     89if [ ! -r "run_GCM.def" ]; then
     90    echo File diagfi_GCM.def does not exist!
     91    exit 0
     92fi
     93if [ ! -r "run_PEM.def" ]; then
     94    echo File diagfi_PEM.def does not exist!
     95    exit 0
     96fi
     97if [ ! -r "run_GCM.def" ]; then
     98    echo File diagfi_GCM.def does not exist!
     99    exit 0
    93100fi
    94101
    95 ./pem_29_phymars_seq.e > PEMrun${num_PEM_now} 2>&1
     102#---------------------------- Initialization ---------------------------
     103iPEM=1
     104((iGCM = ($iPEM - 1)*$nGCM + 1))
     105cp startfi.nc startfis/
     106cp startfi_PEM.nc startfis/
     107for file in profile_*; do
     108    cp $file profiles/${file}_0
     109done
    96110
    97 if [[ -r run.def_GCM ]] ; then
    98   cp run.def_GCM run.def
    99   echo "y"
    100 fi
    101 if [[ -r diagfi.def_GCM ]] ; then
    102   cp diagfi.def_GCM diagfi.def
    103   echo "y"
    104 fi
     111#---------------------- Main loop to call PEM/GCM ----------------------
     112while [ $iPEM -le $nPEM ]; do
     113    #--- Loop to run GCM year by year
     114    cp run_GCM.def run.def
     115    cp diagfi_GCM.def diagfi.def
     116    for ((i = 1; i <= $nGCM; i++)); do
     117        echo Run GCM $iGCM: call $i out of $nGCM...
     118        ./$exeGCM > lrun${iGCM} 2>&1
     119        mv diagfi.nc diagfis/diagfi${iGCM}.nc
     120        cp Xdiurnalave.nc diagfis/Xdiurnalave${iGCM}.nc
     121        mv Xdiurnalave.nc data2reshape${i}.nc
     122        cp restartfi.nc startfis/startfi${iGCM}.nc
     123        mv restartfi.nc startfi.nc
     124        for file in profile_out_*; do
     125            cp $file profiles/${file/_out/}_${iGCM}
     126            mv $file ${file/_out/}
     127        done
     128        ((iGCM++))
     129        echo Done!
     130    done
     131    #--- Reshaping GCM data with XIOS
     132    echo Reshaping GCM data with XIOS...
     133    for i in $(ls datareshaped*); do
     134        rm $i
     135    done
     136    ./$exeReshape
     137    for file in datareshaped*; do
     138        mv $file ${file/reshaped/_GCM_Y}
     139    done
     140    echo Done!
     141     #--- Running PEM
     142    echo Run PEM $iPEM...
     143    cp run_PEM.def run.def
     144    cp diagfi_PEM.def diagfi.def
     145    mv startfi.nc startfi_evol.nc
     146    ./$exePEM > mrun${iPEM} 2>&1
     147    mv diagfi.nc diagfis/diagfi_PEM${iPEM}.nc
     148    cp restartfi_evol.nc startfis/startfi_postPEM${iPEM}.nc
     149    mv restartfi_evol.nc startfi.nc
     150    cp restartfi_PEM.nc startfis/startfi_PEM${iPEM}.nc
     151    mv restartfi_PEM.nc startfi_PEM.nc
     152    for file in profile_out_*; do
     153        cp $file profiles/${file/_out/}PEM_${iPEM}
     154        mv $file ${file/_out/}
     155    done
     156    mv info_run_PEM.txt info_run_PEM${iPEM}.txt
     157    ((iPEM++))
     158    echo Done!
     159done
    105160
    106 #--------------- We rename PEM output ------------------
     161#---------------------- Preparation for relaunch  ----------------------
     162echo Reinitializing starting files...
     163cp startfis/startfi.nc .
     164for file in profiles/*_0; do
     165    cp $file ${file/_0/}
     166done
    107167
    108 cp restartfi_evol.nc startfi${num_GCM_end}_post_PEM.nc
    109 echo "y"
    110 cp restartfi_evol.nc startfi${num_GCM_end}.nc
    111 echo "y"
    112 
    113 (( num_PEM_next = $num_PEM_now + 1 ))
    114 
    115 if [[ -r diagfi.nc ]] ; then
    116   \mv -f diagfi.nc diagfi${num_PEM_now}_PEM.nc
    117 fi
    118 
    119 #------------------- Launch the next PEM call------------------
    120 
    121 # launch job for next month
    122 if (( $num_PEM_next <= $num_PEM_end )) ; then
    123   cp -f run_pem1d_$num_PEM_now tmp
    124   sed -e "s@run_pem1d_${num_PEM_now}@run_pem1d_${num_PEM_next}@" \
    125       -e "s@num_PEM_now=${num_PEM_now}@num_PEM_now=${num_PEM_next}@" tmp > run_pem1d_$num_PEM_next
    126   rm tmp
    127  
    128   ccc_msub run_pem1d_$num_PEM_next
    129 fi
     168echo Script finished.
Note: See TracChangeset for help on using the changeset viewer.