[3919] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #----------------------------------- |
---|
| 4 | function MBG_Initialize |
---|
| 5 | { |
---|
| 6 | IGCM_debug_PushStack "MBG_Initialize" |
---|
| 7 | |
---|
| 8 | # Local function to find parameters in LMDZ .def files |
---|
| 9 | |
---|
| 10 | lmdzgrep2 () { |
---|
| 11 | grep ${1} ${2} | grep -v "#" | sed -e 's/=//g' -e 's/://g' -e 's/_AUTO_//' -e 's/DEFAULT//' | sed -e "s/${1}//" |
---|
| 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 | |
---|
| 27 | ##-- Restart configuration |
---|
| 28 | if ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "n" ] ) ; then |
---|
| 29 | |
---|
| 30 | #echo "NO RESTART FOR TOP" |
---|
| 31 | TOP_LN_RSTR=.FALSE. |
---|
| 32 | TOP_NN_RSTR=0 |
---|
| 33 | |
---|
| 34 | elif ( [ "${CumulPeriod}" -eq 1 ] && [ "${config_MBG_Restart}" = "y" ] ) ; then |
---|
| 35 | |
---|
| 36 | #echo "RESTART TOP" |
---|
| 37 | TOP_LN_RSTR=.TRUE. |
---|
| 38 | TOP_NN_RSTR=0 |
---|
| 39 | |
---|
| 40 | # If we start from IPSLCM5* restart files. |
---|
| 41 | for file in restart_trc*.nc ; do |
---|
| 42 | ncrename -v TRBDSi,TRBGSi -v TRNDSi,TRNGSi -v TRNBSi,TRNDSi -v TRBBSi,TRBDSi ${file} > /dev/null 2>&1 |
---|
| 43 | done |
---|
| 44 | |
---|
| 45 | else |
---|
| 46 | |
---|
| 47 | #echo "RESTART TOP" |
---|
| 48 | TOP_LN_RSTR=.TRUE. |
---|
| 49 | TOP_NN_RSTR=2 |
---|
| 50 | |
---|
| 51 | fi |
---|
| 52 | |
---|
| 53 | ##-- Enable dbio output file |
---|
| 54 | DBIO_ENABLE=".FALSE." |
---|
| 55 | eval pisces_DBIO_ENABLE=\${pisces_UserChoices_DBIO_ENABLE} > /dev/null 2>&1 |
---|
| 56 | if [ "${pisces_DBIO_ENABLE}" = "y" ]; then |
---|
| 57 | DBIO_ENABLE=".TRUE." |
---|
| 58 | fi |
---|
| 59 | |
---|
| 60 | # update iodef.xml |
---|
| 61 | |
---|
| 62 | IGCM_debug_Print 1 " 'Informations into iodef.xml : DBIO_ENABLE : ${DBIO_ENABLE}" |
---|
| 63 | |
---|
| 64 | sed -e "s/<DBIO_ENABLE>/${DBIO_ENABLE}/" \ |
---|
| 65 | iodef.xml > iodef.xml.tmp |
---|
| 66 | |
---|
| 67 | IGCM_sys_Mv iodef.xml.tmp iodef.xml |
---|
| 68 | |
---|
| 69 | ##-- CO2 forcing : update atcco2 value in namelist_pisces_cfg |
---|
| 70 | if [ "${pisces_UserChoices_CARBON_CYCLE}" = "y" ]; then |
---|
| 71 | IGCM_debug_Print 1 "Special case for carbon cycle" |
---|
| 72 | # Activate this case by putting CARBON_CYCLE=y in pisces.card section UserChoices |
---|
| 73 | IGCM_debug_Print 1 'Update atcco2 in namelist_pisces_cfg with value from file co2.log' |
---|
| 74 | PathCO2log=${SUBMIT_DIR} |
---|
| 75 | PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) |
---|
| 76 | IPCC_PIS_CO2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) |
---|
| 77 | IGCM_debug_Print 1 "IPCC_PIS_CO2 : ${IPCC_PIS_CO2} " |
---|
| 78 | IGCM_comp_modifyNamelist force namelist_pisces_cfg atcco2 ${IPCC_PIS_CO2} |
---|
| 79 | else |
---|
| 80 | IGCM_debug_Print 1 "Take same CO2 as for LMDZ, in parameter file config.def." |
---|
| 81 | # ATM_Update is done before MBG_Update and therefore config.def file contains the correct value for CO2. |
---|
| 82 | IGCM_debug_Print 1 'Update atcco2 in namelist_pisces_cfg with same value as for LMDZ' |
---|
| 83 | LMDZ_CO2=$( lmdzgrep2 co2_ppm config.def ) |
---|
| 84 | IGCM_debug_Print 1 "LMDZ_CO2 : ${LMDZ_CO2} " |
---|
| 85 | IGCM_comp_modifyNamelist force namelist_pisces_cfg atcco2 ${LMDZ_CO2} |
---|
| 86 | fi |
---|
| 87 | |
---|
| 88 | ##-- Update namelist_top_cfg and namelist_pisces_cfg |
---|
| 89 | IGCM_comp_modifyNamelist blocker namelist_top_cfg ln_rsttr ${TOP_LN_RSTR} |
---|
| 90 | IGCM_comp_modifyNamelist blocker namelist_top_cfg nn_rsttr ${TOP_NN_RSTR} |
---|
| 91 | IGCM_comp_modifyNamelist blocker namelist_pisces_cfg nn_pisdmp ${OPA_NPDT_YEAR} |
---|
| 92 | |
---|
| 93 | IGCM_debug_PopStack "MBG_Update" |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | #----------------------------------- |
---|
| 97 | function MBG_Finalize |
---|
| 98 | { |
---|
| 99 | IGCM_debug_PushStack "MBG_Finalize" |
---|
| 100 | |
---|
| 101 | echo FINALIZE MBG !!! |
---|
| 102 | |
---|
| 103 | IGCM_debug_PopStack "MBG_Finalize" |
---|
| 104 | } |
---|
| 105 | |
---|