[2456] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #----------------------------------- |
---|
| 4 | function MBG_Initialize |
---|
| 5 | { |
---|
| 6 | IGCM_debug_PushStack "MBG_Initialize" |
---|
| 7 | |
---|
[3688] | 8 | # Local function to find parameters in LMDZ .def files |
---|
[2456] | 9 | |
---|
[3688] | 10 | lmdzgrep2 () { |
---|
| 11 | grep -w ${1} ${2} | grep -v "#" | sed -e 's/=//g' -e 's/://g' -e 's/_AUTO_//' -e 's/DEFAULT//' | sed -e "s/${1}//" |
---|
[2456] | 12 | } |
---|
| 13 | |
---|
| 14 | ##--Variables used by MBG -- |
---|
| 15 | |
---|
| 16 | # ln_rsttr boolean term for tracer model restart (true or false) |
---|
| 17 | # nrsttr control of the time step (0, 1 or 2) |
---|
| 18 | |
---|
| 19 | IGCM_debug_PopStack "MBG_Initialize" |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | #----------------------------------- |
---|
| 23 | function MBG_Update |
---|
| 24 | { |
---|
| 25 | IGCM_debug_PushStack "MBG_Update" |
---|
| 26 | |
---|
[3688] | 27 | ##--Write Frequency for iomput |
---|
| 28 | ## Differents frequencies are allowed for MBG files |
---|
| 29 | |
---|
| 30 | VT1D_ENABLE=".FALSE." |
---|
| 31 | VT5D_ENABLE=".FALSE." |
---|
| 32 | VT1M_ENABLE=".FALSE." |
---|
| 33 | VT1Y_ENABLE=".FALSE." |
---|
| 34 | |
---|
| 35 | for frequency in ${config_MBG_WriteFrequency} ; do |
---|
| 36 | case ${frequency} in |
---|
| 37 | ( 1D|1d ) VT1D_ENABLE=".TRUE." ;; |
---|
| 38 | ( 5D|5d ) VT5D_ENABLE=".TRUE." ;; |
---|
| 39 | ( 1M|1m ) VT1M_ENABLE=".TRUE." ;; |
---|
| 40 | ( *[yY] ) VT1Y_ENABLE=".TRUE." ;; |
---|
| 41 | esac |
---|
| 42 | done |
---|
| 43 | |
---|
[2456] | 44 | ##-- Restart configuration |
---|
| 45 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then |
---|
| 46 | |
---|
| 47 | #echo "NO RESTART FOR TOP" |
---|
[3688] | 48 | TOP_LN_RSTR=.FALSE. |
---|
| 49 | TOP_NN_RSTR=0 |
---|
[2456] | 50 | |
---|
| 51 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then |
---|
| 52 | |
---|
| 53 | #echo "RESTART TOP" |
---|
[3688] | 54 | TOP_LN_RSTR=.TRUE. |
---|
| 55 | TOP_NN_RSTR=0 |
---|
[2456] | 56 | |
---|
| 57 | # If we start from IPSLCM5* restart files. |
---|
| 58 | for file in restart_trc*.nc ; do |
---|
| 59 | ncrename -v TRBDSi,TRBGSi -v TRNDSi,TRNGSi -v TRNBSi,TRNDSi -v TRBBSi,TRBDSi ${file} > /dev/null 2>&1 |
---|
| 60 | done |
---|
| 61 | |
---|
| 62 | else |
---|
| 63 | |
---|
| 64 | #echo "RESTART TOP" |
---|
[3688] | 65 | TOP_LN_RSTR=.TRUE. |
---|
| 66 | TOP_NN_RSTR=2 |
---|
[2456] | 67 | |
---|
| 68 | fi |
---|
| 69 | |
---|
| 70 | ##-- Enable dbio output file |
---|
| 71 | DBIO_ENABLE=".FALSE." |
---|
| 72 | eval pisces_DBIO_ENABLE=\${pisces_UserChoices_DBIO_ENABLE} > /dev/null 2>&1 |
---|
| 73 | if [ "${pisces_DBIO_ENABLE}" = "y" ]; then |
---|
| 74 | DBIO_ENABLE=".TRUE." |
---|
| 75 | fi |
---|
| 76 | |
---|
| 77 | # update iodef.xml |
---|
| 78 | |
---|
[3688] | 79 | IGCM_debug_Print 1 " 'Informations into iodef.xml : DBIO_ENABLE : ${DBIO_ENABLE}" |
---|
[2456] | 80 | |
---|
| 81 | sed -e "s/<DBIO_ENABLE>/${DBIO_ENABLE}/" \ |
---|
| 82 | iodef.xml > iodef.xml.tmp |
---|
| 83 | |
---|
| 84 | IGCM_sys_Mv iodef.xml.tmp iodef.xml |
---|
| 85 | |
---|
| 86 | ##-- CO2 forcing : update atcco2 value in namelist_pisces_cfg |
---|
| 87 | if [ "${pisces_UserChoices_CARBON_CYCLE}" = "y" ]; then |
---|
[3688] | 88 | IGCM_debug_Print 1 "Special case for carbon cycle" |
---|
[2456] | 89 | # Activate this case by putting CARBON_CYCLE=y in pisces.card section UserChoices |
---|
[3688] | 90 | IGCM_debug_Print 1 'Update atcco2 in namelist_pisces_cfg with value from file co2.log' |
---|
[2456] | 91 | PathCO2log=${SUBMIT_DIR} |
---|
| 92 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 93 | IPCC_PIS_CO2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
[3688] | 94 | IGCM_debug_Print 1 "IPCC_PIS_CO2 : ${IPCC_PIS_CO2} " |
---|
| 95 | IGCM_comp_modifyNamelist force namelist_pisces_cfg atcco2 ${IPCC_PIS_CO2} |
---|
[2456] | 96 | else |
---|
[3688] | 97 | IGCM_debug_Print 1 "Take same CO2 as for LMDZ, in parameter file config.def." |
---|
| 98 | # ATM_Update is done before MBG_Update and therefore config.def file contains the correct value for CO2. |
---|
| 99 | IGCM_debug_Print 1 'Update atcco2 in namelist_pisces_cfg with same value as for LMDZ' |
---|
| 100 | LMDZ_CO2=$( lmdzgrep2 co2_ppm config.def ) |
---|
| 101 | IGCM_debug_Print 1 "LMDZ_CO2 : ${LMDZ_CO2} " |
---|
| 102 | IGCM_comp_modifyNamelist force namelist_pisces_cfg atcco2 ${LMDZ_CO2} |
---|
[2456] | 103 | fi |
---|
| 104 | |
---|
| 105 | ##-- Update namelist_top_cfg and namelist_pisces_cfg |
---|
[3688] | 106 | IGCM_comp_modifyNamelist blocker namelist_top_cfg ln_rsttr ${TOP_LN_RSTR} |
---|
| 107 | IGCM_comp_modifyNamelist blocker namelist_top_cfg nn_rsttr ${TOP_NN_RSTR} |
---|
| 108 | IGCM_comp_modifyNamelist blocker namelist_pisces_cfg nn_pisdmp ${OPA_NPDT_YEAR} |
---|
| 109 | |
---|
| 110 | # Update iodef.xml |
---|
[2456] | 111 | |
---|
[3688] | 112 | if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then |
---|
| 113 | VT1D_ENABLE=".FALSE." |
---|
| 114 | VT5D_ENABLE=".FALSE." |
---|
| 115 | VT1M_ENABLE=".FALSE." |
---|
| 116 | VT1Y_ENABLE=".FALSE." |
---|
| 117 | fi |
---|
[2456] | 118 | |
---|
[3688] | 119 | IGCM_debug_Print 1 'Informations into iodef.xml : VT1D_ENABLE VT5D_ENABLE VT1M_ENABLE VT1Y_ENABLE ' |
---|
| 120 | IGCM_debug_Print 1 ${VT1D_ENABLE} ${VT5D_ENABLE} ${VT1M_ENABLE} ${VT1Y_ENABLE} |
---|
[2456] | 121 | |
---|
[3688] | 122 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1d_pis enabled ${VT1D_ENABLE} |
---|
| 123 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 5d_pis enabled ${VT5D_ENABLE} |
---|
| 124 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1m_pis enabled ${VT1M_ENABLE} |
---|
| 125 | IGCM_comp_modifyXmlFile nonblocker file_def_nemo-pisces.xml 1y_pis enabled ${VT1Y_ENABLE} |
---|
| 126 | |
---|
[2456] | 127 | IGCM_debug_PopStack "MBG_Update" |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | #----------------------------------- |
---|
| 131 | function MBG_Finalize |
---|
| 132 | { |
---|
| 133 | IGCM_debug_PushStack "MBG_Finalize" |
---|
| 134 | |
---|
| 135 | echo FINALIZE MBG !!! |
---|
| 136 | |
---|
| 137 | IGCM_debug_PopStack "MBG_Finalize" |
---|
| 138 | } |
---|
| 139 | |
---|