source: CONFIG/UNIFORM/v7/IPSLCM7/GENERAL/DRIVER/oasis.driver @ 6662

Last change on this file since 6662 was 6662, checked in by cetlod, 8 months ago

CM7_work : finalisation, update drivers and monitoring files

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