[396] | 1 | #!/bin/ksh |
---|
| 2 | #----------------------------------- |
---|
| 3 | CPL_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 | #----------------------------------- |
---|
| 33 | CPL_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} |
---|
[2117] | 53 | |
---|
[1548] | 54 | ## Calculate lag for transfer of fields from atmosphere -> ocean. |
---|
[2117] | 55 | ## LagAtm="1day in sec"/day_step * iphysiq/nsplit_phys |
---|
[1548] | 56 | ## First get day_step, iphyisq and nsplit_phys from LMDZ parameter files |
---|
[2117] | 57 | day_step=$( lmdzgrep day_step gcm.def ) |
---|
| 58 | iphysiq=$( lmdzgrep iphysiq gcm.def ) |
---|
[1548] | 59 | nsplit_phys=$( lmdzgrep nsplit_phys physiq.def ) |
---|
| 60 | |
---|
[2282] | 61 | IGCM_debug_Print 3 "Parametre de calcul Lag LMDZ recuperes " ${day_step} ${iphysiq} ${nsplit_phys} |
---|
| 62 | |
---|
| 63 | [[ ${nsplit_phys} -eq 0 || "X${nsplit_phys}" = "X" ]] && nsplit_phys=1 |
---|
| 64 | |
---|
| 65 | IGCM_debug_Print 3 "Parametre de calcul Lag LMDZ mis a jour " ${day_step} ${iphysiq} ${nsplit_phys} |
---|
| 66 | |
---|
[2117] | 67 | (( LagAtm = 86400 / day_step * iphysiq / nsplit_phys )) |
---|
[1548] | 68 | |
---|
[2540] | 69 | (( LagOce = 86400 / OPA_NPDT_JOUR )) |
---|
[2117] | 70 | |
---|
[2540] | 71 | IGCM_debug_Print 1 "OPA_NPDT_JOUR : ${OPA_NPDT_JOUR}" |
---|
| 72 | IGCM_debug_Print 1 "LagAtm : ${LagAtm}" |
---|
| 73 | IGCM_debug_Print 1 "LagOce : ${LagOce}" |
---|
[2534] | 74 | |
---|
[2362] | 75 | ## Use of Lucia ## |
---|
| 76 | lucia_ok="" |
---|
| 77 | if [ ${oasis_UserChoices_Lucia} = y ] ; then |
---|
| 78 | lucia_ok="-1" |
---|
| 79 | fi |
---|
| 80 | |
---|
[653] | 81 | ############ Update Parameter Files ############## |
---|
[2198] | 82 | sed -e "s/<total_time>/${D_JOB_SEC}/" \ |
---|
[2362] | 83 | -e "s/<lucia_ok>/${lucia_ok}/" \ |
---|
[808] | 84 | -e "s/<output_mode>/${CPL_OutputVar}/g" \ |
---|
[2117] | 85 | -e "s/<freq_coupling>/${FreqCoupling}/g" \ |
---|
| 86 | -e "s/<lag_atm>/${LagAtm}/g" \ |
---|
| 87 | -e "s/<lag_oce>/${LagOce}/g" \ |
---|
[396] | 88 | namcouple > namcouple.tmp |
---|
[808] | 89 | IGCM_sys_Mv namcouple.tmp namcouple |
---|
[2206] | 90 | # For IPSLCM6 and use of OASIS-MCT |
---|
| 91 | if [ ${CumulPeriod} -eq 1 ]; then |
---|
| 92 | ncrename -v OIceFrac,OIceFrc sstoc.nc > /dev/null 2>&1 |
---|
| 93 | fi |
---|
[2343] | 94 | # For use of XIOS |
---|
| 95 | IGCM_comp_modifyXmlFile force iodef.xml using_oasis NONE true |
---|
[396] | 96 | |
---|
| 97 | IGCM_debug_PopStack "CPL_Update" |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | #----------------------------------- |
---|
| 101 | CPL_Finalize () |
---|
| 102 | { |
---|
| 103 | IGCM_debug_PushStack "CPL_Finalize" |
---|
| 104 | |
---|
[808] | 105 | if [ "${CPL_OutputMode}" = "y" ] ; then |
---|
| 106 | |
---|
| 107 | [[ ${CPL_OkDay} = "y" ]] && date >TEMPO_1D_cpl_atm.nc |
---|
| 108 | [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_atm.nc |
---|
| 109 | [[ ${CPL_OkDay} = "y" ]] && date >TEMPO_1D_cpl_oce.nc |
---|
| 110 | [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_oce.nc |
---|
| 111 | |
---|
| 112 | fi |
---|
| 113 | |
---|
[2362] | 114 | ## Use of Lucia ## |
---|
| 115 | if [ ${oasis_UserChoices_Lucia} = y ] ; then |
---|
| 116 | echo "Use of LUCIA" |
---|
| 117 | # To be changed |
---|
| 118 | # On Curie |
---|
| 119 | # /ccc/scratch/cont003/dsm/p86caub/LUCIA/lucia |
---|
| 120 | # On Ada |
---|
| 121 | # /linkhome/rech/psl/rpsl035/LUCIA/lucia |
---|
| 122 | fi |
---|
[2267] | 123 | |
---|
[396] | 124 | echo FINALIZE CPL !!! |
---|
| 125 | |
---|
| 126 | IGCM_debug_PopStack "CPL_Finalize" |
---|
| 127 | } |
---|