Ignore:
Timestamp:
09/24/14 13:10:00 (10 years ago)
Author:
jgipsl
Message:

Update to use IGCM_comp_modifyDefFile instead of local functions LMDZ_sed/LMDZ_sed_default/ORCHIDEE_sed.

Now this configuration must be used with libIGCM trunk rev 1073 or more recent.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CONFIG/UNIFORM/v6/LMDZOR_v6/GENERAL/DRIVER/lmdz.driver

    r2332 r2333  
    11#!/bin/ksh 
    22#----------------------------------------------------------------- 
    3 function LMDZ_sed 
    4 { 
    5 # Usage : LMDZ_sed filedef var_name myvalue 
    6 #         In file filedef modify the line containing var_name=xxx into var_name=myvalue 
    7     IGCM_debug_PushStack "LMDZ_sed" 
    8      
    9     # Test if the fichier exist 
    10     if [ ! -f ${1} ] ; then 
    11         echo "WARNING : ${1} file does not exist. Following will not be done : LMDZ_sed : ${1} ${2} ${3}" 
    12         IGCM_debug_PopStack "LMDZ_sed" 
    13         return 
    14     fi 
    15  
    16     sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp 
    17     RET=$? 
    18     echo "LMDZ_sed : ${1} ${2} ${3}" 
    19     \mv ${1}.tmp ${1} 
    20  
    21     IGCM_debug_PopStack "LMDZ_sed" 
    22     return $RET 
    23 } 
    24  
    25 function LMDZ_sed_default 
    26 { 
    27 # Usage : LMDZ_sed_default filedef var_name 
    28 #         In file filedef modify the line  "var_name=xxx DEFAULT= myvalue" 
    29 #         into "var_name=myvalue" 
    30     IGCM_debug_PushStack "LMDZ_sed_default" 
    31  
    32     DefValue=$( grep ${2} ${1}  | awk -F"DEFAULT.=*" '{print $2}') 
    33  
    34     LMDZ_sed  ${1} ${2} $DefValue 
    35     IGCM_debug_PopStack "LMDZ_sed_default" 
    36     return $RET 
    37 } 
    38  
    393function LMDZ_sed_xml 
    404{ 
     
    459    # Test if the fichier exist 
    4610    if [ ! -f ${1} ] ; then 
    47       echo "WARNING : ${1} file does not exist. Following will not be done : LMDZ_sed : ${1} ${2} ${3} ${4}" 
     11      echo "WARNING : ${1} file does not exist. Following will not be done : LMDZ_sed_xml : ${1} ${2} ${3} ${4}" 
    4812      IGCM_debug_PopStack "LMDZ_sed_xml" 
    4913      return 
     
    5115    sed -e "/id=\"${2}\"/s/\(${3}=\"\)[^\"]*\(\"\)/\1${4}\2/" ${1} > ${1}.tmp 
    5216    RET=$? 
    53     echo "LMDZ_sed : ${1} ${2} ${3} ${4}" 
     17    echo "LMDZ_sed_xml : ${1} ${2} ${3} ${4}" 
    5418    \mv ${1}.tmp ${1} 
    5519    IGCM_debug_PopStack "LMDZ_sed_xml" 
     
    281245    ##   If forcing file exist in run directory, read values for the current year  
    282246    ##   and set in config.def. If not use the default value set in config.def 
     247 
     248    # Read value for solaire from file SOLARANDVOLCANOES.txt. If file not existing, take DEFAULT value from file.  
    283249    if [ -f SOLARANDVOLCANOES.txt ] ; then 
    284         IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'` 
    285         if [ X"${IPCC_SOLAR}" = X ] ; then 
     250        value=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'` 
     251        if [ X"${value}" = X ] ; then 
    286252            # The grep returned empty variable, stop execution 
    287253            IGCM_debug_Exit "The file SOLARANDVOLCANOES.txt do not contain the current year." 
    288254            IGCM_debug_Verif_Exit 
    289         else 
    290             # Set new variable in config.def file 
    291             LMDZ_sed config.def solaire     ${IPCC_SOLAR} 
    292         fi 
    293     else 
    294         LMDZ_sed_default config.def solaire 
    295     fi 
    296  
     255        fi 
     256    else 
     257        value=DEFAULT 
     258    fi 
     259    IGCM_comp_modifyDefFile nonblocker config.def solaire $value 
     260 
     261 
     262    # Read value for co2_ppm from file CO2.txt. If file not existing, take DEFAULT value from file.  
    297263    if [ -f CO2.txt ] ; then 
    298         IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'` 
    299         if [ X"${IPCC_CO2}" = X ] ; then 
     264        value=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'` 
     265        if [ X"${value}" = X ] ; then 
    300266            # The grep returned empty variable, stop execution 
    301267            IGCM_debug_Exit "The file CO2.txt do not contain the current year." 
    302268            IGCM_debug_Verif_Exit 
    303         else 
    304             # Set new variable in config.def file 
    305             LMDZ_sed config.def co2_ppm     ${IPCC_CO2} 
    306         fi 
    307     else 
    308         LMDZ_sed_default config.def co2_ppm 
    309     fi 
    310  
     269        fi 
     270    else 
     271        value=DEFAULT 
     272    fi 
     273    IGCM_comp_modifyDefFile nonblocker config.def co2_ppm $value 
     274 
     275 
     276    # Read value for CH4_ppb from file CH4.txt. If file not existing, take DEFAULT value from file.  
    311277    if [ -f CH4.txt ] ; then 
    312         IPCC_CH4=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'` 
    313         if [ X"${IPCC_CH4}" = X ] ; then 
     278        value=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'` 
     279        if [ X"${value}" = X ] ; then 
    314280            # The grep returned empty variable, stop execution 
    315281            IGCM_debug_Exit "The file CH4.txt do not contain the current year." 
    316282            IGCM_debug_Verif_Exit 
    317         else 
    318             # Set new variable in config.def file 
    319             LMDZ_sed config.def CH4_ppb     ${IPCC_CH4} 
    320         fi 
    321      else 
    322         LMDZ_sed_default config.def CH4_ppb 
    323     fi 
    324  
     283        fi 
     284    else 
     285        value=DEFAULT 
     286    fi 
     287    IGCM_comp_modifyDefFile nonblocker config.def CH4_ppb $value 
     288 
     289 
     290    # Read value for N2O_ppb from file N2O.txt. If file not existing, take DEFAULT value from file.  
    325291    if [ -f N2O.txt ] ; then 
    326         IPCC_N2O=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'` 
    327         if [ X"${IPCC_N2O}" = X ] ; then 
     292        value=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'` 
     293        if [ X"${value}" = X ] ; then 
    328294            # The grep returned empty variable, stop execution 
    329295            IGCM_debug_Exit "The file N2O.txt do not contain the current year." 
    330296            IGCM_debug_Verif_Exit 
    331         else 
    332             # Set new variable in config.def file 
    333             LMDZ_sed config.def N2O_ppb     ${IPCC_N2O} 
    334         fi 
    335     else 
    336         LMDZ_sed_default config.def N2O_ppb 
    337     fi 
    338  
     297        fi 
     298    else 
     299        value=DEFAULT 
     300    fi 
     301    IGCM_comp_modifyDefFile nonblocker config.def N2O_ppb $value 
     302 
     303    # Read value for CFC11_ppt from file CFC11.txt. If file not existing, take DEFAULT value from file.  
    339304    if [ -f CFC11.txt ] ; then 
    340         IPCC_CFC11=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'` 
    341         if [ X"${IPCC_CFC11}" = X ] ; then 
     305        value=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'` 
     306        if [ X"${value}" = X ] ; then 
    342307            # The grep returned empty variable, stop execution 
    343308            IGCM_debug_Exit "The file CFC11.txt do not contain the current year." 
    344309            IGCM_debug_Verif_Exit 
    345         else 
    346             # Set new variable in config.def file 
    347             LMDZ_sed config.def CFC11_ppt   ${IPCC_CFC11} 
    348         fi 
    349     else 
    350         LMDZ_sed_default config.def CFC11_ppt 
    351     fi 
    352  
     310        fi 
     311    else 
     312        value=DEFAULT 
     313    fi 
     314    IGCM_comp_modifyDefFile nonblocker config.def CFC11_ppt $value 
     315 
     316 
     317    # Read value for CFC12_ppt from file CFC12.txt. If file not existing, take DEFAULT value from file.  
    353318    if [ -f CFC12.txt ] ; then 
    354         IPCC_CFC12=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'` 
    355         if [ X"${IPCC_CFC12}" = X ] ; then 
     319        value=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'` 
     320        if [ X"${value}" = X ] ; then 
    356321            # The grep returned empty variable, stop execution 
    357322            IGCM_debug_Exit "The file CFC12.txt do not contain the current year." 
    358323            IGCM_debug_Verif_Exit 
    359         else 
    360             # Set new variable in config.def file 
    361             LMDZ_sed config.def CFC12_ppt   ${IPCC_CFC12} 
    362         fi 
    363     else 
    364         LMDZ_sed_default config.def CFC12_ppt 
    365     fi 
     324        fi 
     325    else 
     326        value=DEFAULT 
     327    fi 
     328    IGCM_comp_modifyDefFile nonblocker config.def CFC12_ppt $value 
    366329 
    367330 
     
    369332    LMDZ_t_coupl=${oasis_UserChoices_FreqCoupling:-${lmdz_UserChoices_t_coupl}} 
    370333    IGCM_debug_Print 3 "LMDZ_t_coupl "   ${LMDZ_t_coupl} 
    371     LMDZ_sed config.def t_coupl   ${LMDZ_t_coupl} 
     334    IGCM_comp_modifyDefFile nonblocker config.def t_coupl   ${LMDZ_t_coupl}  
    372335 
    373336    ##-- Add special treatement for CARBON CYCLE 
     
    387350    #  columns in phys_output_filekeys refer to the filenames given in phys_out_filenames in output.def :   
    388351    #                                            histmth       histday        histhf    histfh3h   histhf3hm   histstn 
    389     LMDZ_sed output.def phys_out_filekeys      "${ok_mensuel} ${ok_journe}   ${ok_hf}  ${ok_hf3h} ${ok_hf3hm} ${ok_stn}" 
    390     LMDZ_sed output.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} 
    391     LMDZ_sed output.def ok_cosp     ${LMDZ_COSP_OK} 
    392     LMDZ_sed output.def ok_mensuelCOSP  ${LMDZ_COSP_monthly} 
    393     LMDZ_sed output.def ok_journeCOSP   ${LMDZ_COSP_daily} 
    394     LMDZ_sed output.def ok_hfCOSP   ${LMDZ_COSP_hf} 
    395     LMDZ_sed output.def ok_histNMC  "${LMDZ_NMC_monthly} ${LMDZ_NMC_daily} ${LMDZ_NMC_hf}" 
     352    IGCM_comp_modifyDefFile nonblocker output.def phys_out_filekeys "${ok_mensuel} ${ok_journe}   ${ok_hf}  ${ok_hf3h} ${ok_hf3hm} ${ok_stn}" 
     353    IGCM_comp_modifyDefFile nonblocker output.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP} 
     354    IGCM_comp_modifyDefFile nonblocker output.def ok_cosp     ${LMDZ_COSP_OK} 
     355    IGCM_comp_modifyDefFile nonblocker output.def ok_mensuelCOSP  ${LMDZ_COSP_monthly} 
     356    IGCM_comp_modifyDefFile nonblocker output.def ok_journeCOSP   ${LMDZ_COSP_daily} 
     357    IGCM_comp_modifyDefFile nonblocker output.def ok_hfCOSP   ${LMDZ_COSP_hf} 
     358    IGCM_comp_modifyDefFile nonblocker output.def ok_histNMC  "${LMDZ_NMC_monthly} ${LMDZ_NMC_daily} ${LMDZ_NMC_hf}" 
    396359 
    397360    # XIOS XML definition 
     
    472435 
    473436    ## gcm.def parameters :  
    474     # Modification only for new physics 
     437    # Modification of variable iphysiq depending on the physics 
    475438    if [ X${LMDZ_Physics} = X"AP" ] ; then 
    476         LMDZ_sed gcm.def iphysiq     10 
    477     else 
    478         LMDZ_sed_default gcm.def iphysiq 
    479     fi 
     439        value=10 
     440    else 
     441        value=DEFAULT 
     442    fi 
     443    IGCM_comp_modifyDefFile nonblocker gcm.def iphysiq $value 
    480444 
    481445 
    482446    ## run.def parameters 
    483     LMDZ_sed run.def dayref   ${InitDay} 
    484     LMDZ_sed run.def nday     ${PeriodLengthInDays} 
    485     LMDZ_sed run.def raz_date ${RAZ_DATE} 
    486     LMDZ_sed run.def periodav ${LMDZ_periodav} 
    487     LMDZ_sed run.def adjust   ${LMDZ_adjust} 
     447    IGCM_comp_modifyDefFile blocker run.def dayref   ${InitDay} 
     448    IGCM_comp_modifyDefFile blocker run.def nday     ${PeriodLengthInDays} 
     449    IGCM_comp_modifyDefFile blocker run.def raz_date ${RAZ_DATE} 
     450    IGCM_comp_modifyDefFile blocker run.def periodav ${LMDZ_periodav} 
     451    IGCM_comp_modifyDefFile nonblocker run.def adjust   ${LMDZ_adjust} 
    488452 
    489453    # Set anneeref different for gcm and ce0l 
     
    492456    if [ -f create_etat0_limit* ] || [ -f ce0l* ] && [ ! -f lmdz.x ] ; then 
    493457        # for case ce0l : always take current year 
    494         LMDZ_sed run.def anneeref ${year} 
    495         LMDZ_sed run.def calend   ${CalendarTypeForCreate} 
     458        IGCM_comp_modifyDefFile blocker run.def anneeref ${year} 
     459        IGCM_comp_modifyDefFile blocker run.def calend   ${CalendarTypeForCreate} 
    496460    else 
    497461        # for case gcm : take first year of simulation 
    498         LMDZ_sed run.def anneeref ${InitYear} 
    499         LMDZ_sed run.def calend   ${CalendarTypeForLmdz} 
     462        IGCM_comp_modifyDefFile blocker run.def anneeref ${InitYear} 
     463        IGCM_comp_modifyDefFile blocker run.def calend   ${CalendarTypeForLmdz} 
    500464    fi 
    501465 
    502466    # Activate creation of file grilles_gcm.nc only at first period 
    503467    if [ ${CumulPeriod} -eq 1 ] ; then 
    504         LMDZ_sed run.def grilles_gcm_netcdf y 
    505     else 
    506         LMDZ_sed run.def grilles_gcm_netcdf n 
     468        IGCM_comp_modifyDefFile nonblocker run.def grilles_gcm_netcdf y 
     469    else 
     470        IGCM_comp_modifyDefFile nonblocker run.def grilles_gcm_netcdf n 
    507471    fi 
    508472 
     
    513477    if [ X${config_ListOfComponents_SRF} = Xorchidee ] ; then 
    514478        echo "Activate ORCHIDEE, set VEGET=y in run.def" 
    515         LMDZ_sed run.def VEGET y 
     479        IGCM_comp_modifyDefFile blocker run.def VEGET y 
    516480    else 
    517481        echo "No ORCHIDEE, set VEGET=n in run.def" 
    518         LMDZ_sed run.def VEGET n 
     482        IGCM_comp_modifyDefFile blocker run.def VEGET n 
    519483    fi 
    520484 
    521485    if [ X${config_ListOfComponents_CPL} = Xoasis ] ; then 
    522486        echo "Activate coupling to ocean, set type_ocean=couple in run.def" 
    523         LMDZ_sed run.def type_ocean couple 
     487        IGCM_comp_modifyDefFile blocker run.def type_ocean couple 
    524488    else 
    525489        echo "LMDZ is running in forced mode without ocean model, set type_ocean=force in run.def" 
    526         LMDZ_sed run.def type_ocean force 
     490        IGCM_comp_modifyDefFile blocker run.def type_ocean force 
    527491    fi 
    528492 
    529493    if [ X${config_ListOfComponents_CHM} = Xinca ] ; then 
    530494        echo "Activate coupling to INCA, set type_trac=inca in run.def" 
    531         LMDZ_sed run.def type_trac inca 
     495        IGCM_comp_modifyDefFile blocker run.def type_trac inca 
    532496    elif [ X${config_ListOfComponents_CHM} = Xreprobus ] ; then 
    533497        echo "Activate coupling to REPROBUS, set type_trac=repr in run.def" 
    534         LMDZ_sed run.def type_trac repr 
    535         LMDZ_sed run.def config_inca none 
     498        IGCM_comp_modifyDefFile blocker run.def type_trac repr 
     499        IGCM_comp_modifyDefFile blocker run.def config_inca none 
    536500    else 
    537501        echo "No coupling to chemistry model, set type_trac=lmdz in run.def" 
    538         LMDZ_sed run.def type_trac lmdz 
    539         LMDZ_sed run.def config_inca none 
     502        IGCM_comp_modifyDefFile blocker run.def type_trac lmdz 
     503        IGCM_comp_modifyDefFile blocker run.def config_inca none 
    540504    fi 
    541505 
     
    543507    # config.def : Activate direct radiative effect if ok_ade=y 
    544508    if [ ! X${lmdz_UserChoices_ok_ade} = X ]; then  
    545         LMDZ_sed config.def ok_ade ${lmdz_UserChoices_ok_ade} 
    546     else 
    547         LMDZ_sed config.def ok_ade n 
     509        IGCM_comp_modifyDefFile nonblocker config.def ok_ade ${lmdz_UserChoices_ok_ade} 
     510    else 
     511        IGCM_comp_modifyDefFile nonblocker config.def ok_ade n 
    548512    fi  
    549513 
    550514    # config.def : Activate indirect radiative effect if ok_aie=y 
    551515    if [ ! X${lmdz_UserChoices_ok_aie} = X ]; then  
    552         LMDZ_sed config.def ok_aie ${lmdz_UserChoices_ok_aie} 
    553     else 
    554         LMDZ_sed config.def ok_aie n 
     516        IGCM_comp_modifyDefFile nonblocker config.def ok_aie ${lmdz_UserChoices_ok_aie} 
     517    else 
     518        IGCM_comp_modifyDefFile nonblocker config.def ok_aie n 
    555519    fi  
    556520 
    557521    # config.def : Activate online aerosol coupled model if aerosol_couple=y 
    558522    if [ ! X${lmdz_UserChoices_aerosol_couple} = X ]; then  
    559         LMDZ_sed config.def aerosol_couple ${lmdz_UserChoices_aerosol_couple} 
    560     else 
    561         LMDZ_sed config.def aerosol_couple n 
     523        IGCM_comp_modifyDefFile nonblocker config.def aerosol_couple ${lmdz_UserChoices_aerosol_couple} 
     524    else 
     525        IGCM_comp_modifyDefFile nonblocker config.def aerosol_couple n 
    562526    fi  
    563527 
    564528    # config.def : Activate reading of ozone in climatology if read_climoz=2 
    565529    if [ ! X${lmdz_UserChoices_read_climoz} = X ]; then  
    566         LMDZ_sed config.def read_climoz ${lmdz_UserChoices_read_climoz} 
    567     else 
    568         LMDZ_sed config.def read_climoz 0        
     530        IGCM_comp_modifyDefFile nonblocker config.def read_climoz ${lmdz_UserChoices_read_climoz} 
     531    else 
     532        IGCM_comp_modifyDefFile nonblocker config.def read_climoz 0      
    569533    fi  
    570534 
     
    573537    # =5 => dust only =6 => all aerosol     
    574538    if [ ! X${lmdz_UserChoices_flag_aerosol} = X ]; then  
    575         LMDZ_sed config.def flag_aerosol ${lmdz_UserChoices_flag_aerosol} 
    576     else 
    577         LMDZ_sed config.def flag_aerosol 0 
     539        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol ${lmdz_UserChoices_flag_aerosol} 
     540    else 
     541        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol 0 
    578542    fi  
    579543 
    580544    # config.def : Activate calcul of Cloud droplet number concentration if ok_cdnc=y 
    581545    if [ ! X${lmdz_UserChoices_ok_cdnc} = X ]; then  
    582         LMDZ_sed config.def ok_cdnc ${lmdz_UserChoices_ok_cdnc} 
    583     else 
    584         LMDZ_sed config.def ok_cdnc n    
     546        IGCM_comp_modifyDefFile nonblocker config.def ok_cdnc ${lmdz_UserChoices_ok_cdnc} 
     547    else 
     548        IGCM_comp_modifyDefFile nonblocker config.def ok_cdnc n  
    585549    fi  
    586550 
    587551    # guide.def : Activate nudging if ok_guide=y set in lmdz.card 
    588552    if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then 
    589         LMDZ_sed guide.def ok_guide  ${lmdz_UserChoices_ok_guide} 
    590     else 
    591         LMDZ_sed guide.def ok_guide n 
     553        IGCM_comp_modifyDefFile nonblocker guide.def ok_guide  ${lmdz_UserChoices_ok_guide} 
     554    else 
     555        IGCM_comp_modifyDefFile nonblocker guide.def ok_guide n 
    592556    fi 
    593557 
     
    741705    if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
    742706            # Modify co2_ppm in config.def only for historical run 
    743             # If not historical run, keep co2_ppm value set earlier by LMDZ_sed 
    744         LMDZ_sed config.def co2_ppm     ${CO2_ppm} 
     707            # If not historical run, keep co2_ppm value set earlier by IGCM_comp_modifyDefFile 
     708        IGCM_comp_modifyDefFile nonblocker config.def co2_ppm     ${CO2_ppm} 
    745709    fi 
    746710    IGCM_debug_PopStack "ATM_Carbon_Update" 
Note: See TracChangeset for help on using the changeset viewer.