source: CONFIG/UNIFORM/v6/IPSLCM5A2/GENERAL/DRIVER/oasis.driver @ 5106

Last change on this file since 5106 was 5106, checked in by aclsce, 4 years ago
  • Added Addnoise functionality in IPSLCM5A2 configuration.
File size: 5.4 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
57    ## Calculate lag for transfer of fields from atmosphere -> ocean.
58    ## LagAtm="1day in sec"/day_step * iphysiq/nsplit_phys
59    ## First get day_step, iphyisq and nsplit_phys from LMDZ parameter files
60    day_step=$(    lmdzgrep day_step gcm.def )
61    iphysiq=$(     lmdzgrep iphysiq gcm.def )
62    nsplit_phys=$( lmdzgrep nsplit_phys physiq.def )
63
64    IGCM_debug_Print 3 "Parametre de calcul Lag LMDZ recuperes " ${day_step} ${iphysiq} ${nsplit_phys}
65
66    [[ ${nsplit_phys} -eq 0 || "X${nsplit_phys}" = "X" ]] && nsplit_phys=1
67
68    IGCM_debug_Print 3 "Parametre de calcul Lag LMDZ mis a jour " ${day_step} ${iphysiq} ${nsplit_phys}
69                                                             
70    (( LagAtm = 86400 / day_step * iphysiq / nsplit_phys ))
71
72    (( LagOce = 86400 / OPA_NPDT_DAY ))
73
74    IGCM_debug_Print 1 "OPA_NPDT_DAY : ${OPA_NPDT_DAY}"
75    IGCM_debug_Print 1 "LagAtm        : ${LagAtm}"
76    IGCM_debug_Print 1 "LagOce        : ${LagOce}"
77
78    ## Use of Lucia ##
79    lucia_ok=""
80    if [ ${oasis_UserChoices_Lucia} = y ] ; then
81        lucia_ok="-1"
82    fi
83   
84    ############ Update Parameter Files   ##############
85    sed -e "s/<total_time>/${D_JOB_SEC}/" \
86        -e "s/<lucia_ok>/${lucia_ok}/" \
87        -e "s/<output_mode>/${CPL_OutputVar}/g" \
88        -e "s/<freq_coupling>/${FreqCoupling}/g" \
89        -e "s/<lag_atm>/${LagAtm}/g" \
90        -e "s/<lag_oce>/${LagOce}/g" \
91        namcouple > namcouple.tmp
92    IGCM_sys_Mv namcouple.tmp namcouple
93    # For IPSLCM6 and use of OASIS-MCT
94    if [ ${CumulPeriod} -eq 1 ]; then
95        ncrename -v OIceFrac,OIceFrc sstoc.nc > /dev/null 2>&1
96    fi
97    # For use of XIOS
98    IGCM_comp_modifyXmlFile force iodef.xml using_oasis NONE true
99
100    if [ X"${Test_AddNoise_First_Only}" = X"y" ]; then
101
102    Test_AddNoise_First_Only=n
103
104    # AddNoise if required but only for one Period
105
106    # Read ByPass_addnoise_sst option in oasis.card --> apply addnoise for sst in CPL restart file if [ $ByPass_addnoise_sst = y ]
107    ByPass_addnoise_sst=${oasis_UserChoices_ByPass_addnoise_sst}
108    if [ X"${ByPass_addnoise_sst}" = X"y" ] ; then
109
110      ByPass_PerturbExe=${oasis_UserChoices_ByPass_PerturbExe}
111      ByPass_FileOut=${oasis_UserChoices_ByPass_FileOut}
112      ByPass_PerturbVar=${oasis_UserChoices_ByPass_PerturbVar}
113      ByPass_PerturbAmp=${oasis_UserChoices_ByPass_PerturbAmp}
114
115      IGCM_sys_Chmod 644 ${RUN_DIR}/${ByPass_FileOut}.nc
116      IGCM_debug_Print 1 "${ByPass_PerturbExe} ${RUN_DIR}/${ByPass_FileOut}.nc ${ByPass_PerturbVar} ${ByPass_PerturbAmp}"
117
118      ${ByPass_PerturbExe} ${RUN_DIR}/${ByPass_FileOut}.nc ${ByPass_PerturbVar} ${ByPass_PerturbAmp}
119      if [ $? -ne 0 ] ; then
120        IGCM_debug_Exit "Error with $( basename ${ByPass_PerturbExe} )"
121        IGCM_debug_Verif_Exit
122      fi
123
124      echo
125      IGCM_debug_Print 1 "ByPass_addnoise_sst : applied addnoise for sst in CPL restart file"
126      echo
127      ByPass_addnoise_sst=n
128      # necessary to reset ByPass in next Period during the same Job (PeriodNb<>1)
129      export oasis_UserChoicesByPass_addnoise_sst=n
130      IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/oasis.card UserChoices ByPass_addnoise_sst "${ByPass_addnoise_sst}"
131    fi
132
133    fi
134
135    IGCM_debug_PopStack "CPL_Update"
136}
137
138#-----------------------------------
139CPL_Finalize ()
140{
141    IGCM_debug_PushStack "CPL_Finalize"
142
143    if [ "${CPL_OutputMode}" = "y" ] ; then
144
145        [[ ${CPL_OkDay}   = "y" ]] && date >TEMPO_1D_cpl_atm.nc
146        [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_atm.nc
147        [[ ${CPL_OkDay}   = "y" ]] && date >TEMPO_1D_cpl_oce.nc
148        [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_oce.nc
149
150    fi
151
152    ## Use of Lucia ##
153    if [ ${oasis_UserChoices_Lucia} = y ] ; then
154        echo "Use of LUCIA"
155    #   To be changed
156    #   On Curie
157    #   /ccc/scratch/cont003/dsm/p86caub/LUCIA/lucia
158    #   On Ada
159    #   /linkhome/rech/psl/rpsl035/LUCIA/lucia
160    fi
161
162    echo FINALIZE CPL !!!
163
164    IGCM_debug_PopStack "CPL_Finalize"
165}
Note: See TracBrowser for help on using the repository browser.