source: CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/oasis.driver @ 3891

Last change on this file since 3891 was 3891, checked in by mafoipsl, 6 years ago

DRIVER/oasis.driver : correction to detect the first passage for AddNoise

File size: 5.7 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    # For IPSLCM6 and use of OASIS-MCT
98    if [ ${CumulPeriod} -eq 1 ]; then
99        ncrename -v OIceFrac,OIceFrc sstoc.nc > /dev/null 2>&1
100    fi
101    # For use of XIOS
102    IGCM_comp_modifyXmlFile force iodef.xml using_oasis NONE true
103
104    if [ X"${Test_AddNoise_First_Only}" = X"y" ]; then
105
106    Test_AddNoise_First_Only=n
107
108    # AddNoise if required but only for one Period
109
110    # Read ByPass_addnoise_sst option in oasis.card --> apply addnoise for sst in CPL restart file if [ $ByPass_addnoise_sst = y ]
111    ByPass_addnoise_sst=${oasis_UserChoices_ByPass_addnoise_sst}
112    if [ X"${ByPass_addnoise_sst}" = X"y" ] ; then
113     
114      ByPass_PerturbExe=${oasis_UserChoices_ByPass_PerturbExe}
115      ByPass_FileOut=${oasis_UserChoices_ByPass_FileOut}
116      ByPass_PerturbVar=${oasis_UserChoices_ByPass_PerturbVar}
117      ByPass_PerturbAmp=${oasis_UserChoices_ByPass_PerturbAmp}
118
119      IGCM_sys_Chmod 644 ${RUN_DIR}/${ByPass_FileOut}.nc
120      IGCM_debug_Print 1 "${ByPass_PerturbExe} ${RUN_DIR}/${ByPass_FileOut}.nc ${ByPass_PerturbVar} ${ByPass_PerturbAmp}"
121
122      ${ByPass_PerturbExe} ${RUN_DIR}/${ByPass_FileOut}.nc ${ByPass_PerturbVar} ${ByPass_PerturbAmp} 
123      if [ $? -ne 0 ] ; then
124        IGCM_debug_Exit "Error with $( basename ${ByPass_PerturbExe} )"
125        IGCM_debug_Verif_Exit
126      fi
127
128      echo
129      IGCM_debug_Print 1 "ByPass_addnoise_sst : applied addnoise for sst in CPL restart file"
130      echo
131      ByPass_addnoise_sst=n
132      # necessary to reset ByPass in next Period during the same Job (PeriodNb<>1)
133      export oasis_UserChoicesByPass_addnoise_sst=n
134      IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/oasis.card UserChoices ByPass_addnoise_sst "${ByPass_addnoise_sst}"
135    fi
136
137    fi
138
139    IGCM_debug_PopStack "CPL_Update"
140}
141
142#-----------------------------------
143CPL_Finalize ()
144{
145    IGCM_debug_PushStack "CPL_Finalize"
146
147    if [ "${CPL_OutputMode}" = "y" ] ; then
148
149        [[ ${CPL_OkDay}   = "y" ]] && date >TEMPO_1D_cpl_atm.nc
150        [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_atm.nc
151        [[ ${CPL_OkDay}   = "y" ]] && date >TEMPO_1D_cpl_oce.nc
152        [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_oce.nc
153
154    fi
155
156    ## Use of Lucia ##
157    if [ ${oasis_UserChoices_Lucia} = y ] ; then
158        echo "Use of LUCIA"
159    #   To be changed
160    #   On Curie
161    #   /ccc/scratch/cont003/dsm/p86caub/LUCIA/lucia
162    #   On Ada
163    #   /linkhome/rech/psl/rpsl035/LUCIA/lucia
164    fi
165
166    echo FINALIZE CPL !!!
167
168    IGCM_debug_PopStack "CPL_Finalize"
169}
Note: See TracBrowser for help on using the repository browser.