source: CONFIG_DEVT/IPSLCM6.2.2_ENSEMBLES/config/IPSLCM6/LMDZOR622-ENSEMBLES.01/DRIVER/oasis.driver @ 6246

Last change on this file since 6246 was 6246, checked in by aclsce, 20 months ago

Added LMDZOR experiment within XIOS ensembles infrastructure.

File size: 5.9 KB
Line 
1#!/bin/ksh
2#-----------------------------------
3CPL_Initialize ()
4{
5    IGCM_debug_PushStack "CPL_Initialize"
6 
7    echo INITIALIZE CPL !!!
8
9# Local function to find parameters in LMDZ .def files
10    lmdzgrep () {
11        grep $1 $2 |grep -v "#" | awk "-F=" '{print $2}' | awk "-F " '{print $1}'
12    }
13
14    #RESOL_CPL=$( echo $RESOL | awk "-F-" '{print $1}' )
15    RESOL_CPL=${RESOL_OCE}x${RESOL_ATM}
16    IGCM_debug_Print 1 "RESOL_CPL      : ${RESOL_CPL}"
17
18    CPL_OkDay="n"
19    CPL_OkMonth="n"
20
21    for CPL_Frequency in ${config_CPL_WriteFrequency} ; do
22        case ${CPL_Frequency} in
23            *D|*d) CPL_OkDay="y"   ;;
24            *M)    CPL_OkMonth="y" ;;
25        esac
26    done
27
28    # Initialisation required for AddNoise done during one Period
29    Test_AddNoise_First_Only=y
30
31    IGCM_debug_PopStack "CPL_Initialize"
32
33}
34
35#-----------------------------------
36CPL_Update ()
37{
38    IGCM_debug_PushStack "CPL_Update"
39
40    ############ Update Time and Counters ##############
41    ##-- Calcul de la duree du job (en secondes)
42    (( D_JOB_SEC = 3600 * 24 * PeriodLengthInDays ))
43
44    ############ Update Other Parameters  ##############
45    ## Read Output_mode option in oasis.card --> Put "y" to have coupling variables in ouptut files
46    CPL_OutputMode="n"
47    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/oasis.card UserChoices OutputMode
48    eval CPL_OutputMode=\${oasis_UserChoices_OutputMode} > /dev/null 2>&1
49    echo CPL_OutputMode = ${CPL_OutputMode}
50    CPL_OutputVar='EXPORTED'
51    if [ ${CPL_OutputMode} = y ] ; then
52        CPL_OutputVar='EXPOUT'
53    fi
54
55    FreqCoupling=${oasis_UserChoices_FreqCoupling:-86400}
56    FreqCouplingRoffCalv=${oasis_UserChoices_FreqCouplingRoffCalv:-86400}
57
58    ## Calculate lag for transfer of fields from atmosphere -> ocean.
59    ## LagAtm="1day in sec"/day_step * iphysiq/nsplit_phys
60    ## First get day_step, iphyisq and nsplit_phys from LMDZ parameter files
61    day_step=$(    lmdzgrep day_step gcm.def )
62    iphysiq=$(     lmdzgrep iphysiq gcm.def )
63    nsplit_phys=$( lmdzgrep nsplit_phys physiq.def )
64
65    IGCM_debug_Print 3 "Parametre de calcul Lag LMDZ recuperes " ${day_step} ${iphysiq} ${nsplit_phys}
66
67    [[ ${nsplit_phys} -eq 0 || "X${nsplit_phys}" = "X" ]] && nsplit_phys=1
68
69    IGCM_debug_Print 3 "Parametre de calcul Lag LMDZ mis a jour " ${day_step} ${iphysiq} ${nsplit_phys}
70                                                             
71    (( LagAtm = 86400 * iphysiq / day_step / nsplit_phys ))
72    (( LagAtmRoffCalv = $FreqCoupling + $LagAtm ))
73    (( LagOce = 86400 / OPA_NPDT_DAY ))
74
75    IGCM_debug_Print 1 "OPA_NPDT_DAY : ${OPA_NPDT_DAY}"
76    IGCM_debug_Print 1 "LagAtm        : ${LagAtm}"
77    IGCM_debug_Print 1 "LagAtmRoffCalv : ${LagAtmRoffCalv}"
78    IGCM_debug_Print 1 "LagOce        : ${LagOce}"
79
80    ## Use of Lucia ##
81    lucia_ok=""
82    if [ ${oasis_UserChoices_Lucia} = y ] ; then
83        lucia_ok="-1"
84    fi
85   
86    ############ Update Parameter Files   ##############
87    sed -e "s/<total_time>/${D_JOB_SEC}/" \
88        -e "s/<lucia_ok>/${lucia_ok}/" \
89        -e "s/<output_mode>/${CPL_OutputVar}/g" \
90        -e "s/<freq_coupling>/${FreqCoupling}/g" \
91        -e "s/<freq_coupling_roff_calv>/${FreqCouplingRoffCalv}/g" \
92        -e "s/<lag_atm>/${LagAtm}/g" \
93        -e "s/<lag_atm_roff_calv>/${LagAtmRoffCalv}/g" \
94        -e "s/<lag_oce>/${LagOce}/g" \
95        namcouple > namcouple.tmp
96    IGCM_sys_Mv namcouple.tmp namcouple
97
98    # Ensemble case
99    if [ ${config_Ensemble_EnsembleXIOS} = TRUE ] ; then
100      sed -e "s/<total_time>/${D_JOB_SEC}/" oasis_namcouple_header > oasis_namcouple_header.tmp
101      IGCM_sys_Mv oasis_namcouple_header.tmp oasis_namcouple_header
102    fi
103
104    # For IPSLCM6 and use of OASIS-MCT
105    if [ ${CumulPeriod} -eq 1 ]; then
106        ncrename -v OIceFrac,OIceFrc sstoc.nc > /dev/null 2>&1
107    fi
108    # For use of XIOS
109    IGCM_comp_modifyXmlFile force iodef.xml using_oasis NONE true
110
111    if [ X"${Test_AddNoise_First_Only}" = X"y" ]; then
112
113    Test_AddNoise_First_Only=n
114
115    # AddNoise if required but only for one Period
116
117    # Read ByPass_addnoise_sst option in oasis.card --> apply addnoise for sst in CPL restart file if [ $ByPass_addnoise_sst = y ]
118    ByPass_addnoise_sst=${oasis_UserChoices_ByPass_addnoise_sst}
119    if [ X"${ByPass_addnoise_sst}" = X"y" ] ; then
120     
121      ByPass_PerturbExe=${oasis_UserChoices_ByPass_PerturbExe}
122      ByPass_FileOut=${oasis_UserChoices_ByPass_FileOut}
123      ByPass_PerturbVar=${oasis_UserChoices_ByPass_PerturbVar}
124      ByPass_PerturbAmp=${oasis_UserChoices_ByPass_PerturbAmp}
125
126      IGCM_sys_Chmod 644 ${RUN_DIR}/${ByPass_FileOut}.nc
127      IGCM_debug_Print 1 "${ByPass_PerturbExe} ${RUN_DIR}/${ByPass_FileOut}.nc ${ByPass_PerturbVar} ${ByPass_PerturbAmp}"
128
129      ${ByPass_PerturbExe} ${RUN_DIR}/${ByPass_FileOut}.nc ${ByPass_PerturbVar} ${ByPass_PerturbAmp} 
130      if [ $? -ne 0 ] ; then
131        IGCM_debug_Exit "Error with $( basename ${ByPass_PerturbExe} )"
132        IGCM_debug_Verif_Exit
133      fi
134
135      echo
136      IGCM_debug_Print 1 "ByPass_addnoise_sst : applied addnoise for sst in CPL restart file"
137      echo
138      ByPass_addnoise_sst=n
139      # necessary to reset ByPass in next Period during the same Job (PeriodNb<>1)
140      export oasis_UserChoicesByPass_addnoise_sst=n
141      IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/oasis.card UserChoices ByPass_addnoise_sst "${ByPass_addnoise_sst}"
142    fi
143
144    fi
145
146    IGCM_debug_PopStack "CPL_Update"
147}
148
149#-----------------------------------
150CPL_Finalize ()
151{
152    IGCM_debug_PushStack "CPL_Finalize"
153
154    if [ "${CPL_OutputMode}" = "y" ] ; then
155
156        [[ ${CPL_OkDay}   = "y" ]] && date >TEMPO_1D_cpl_atm.nc
157        [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_atm.nc
158        [[ ${CPL_OkDay}   = "y" ]] && date >TEMPO_1D_cpl_oce.nc
159        [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_oce.nc
160
161    fi
162
163    ## Use of Lucia ##
164    if [ ${oasis_UserChoices_Lucia} = y ] ; then
165        echo "Use of LUCIA"
166    #   To be changed
167    #   On Curie
168    #   /ccc/scratch/cont003/dsm/p86caub/LUCIA/lucia
169    #   On Ada
170    #   /linkhome/rech/psl/rpsl035/LUCIA/lucia
171    fi
172
173    echo FINALIZE CPL !!!
174
175    IGCM_debug_PopStack "CPL_Finalize"
176}
Note: See TracBrowser for help on using the repository browser.