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

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

DRIVER/oasis.driver : an other way to test the first passage to use AddNoise because Period is not available.

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