source: CONFIG/IPSL_ESM/IPSLCM5CHEM_uni/GENERAL/DRIVER/oasis.driver @ 1663

Last change on this file since 1663 was 1650, checked in by jgipsl, 13 years ago

IPSLCM5_v4 :
Now lmdz.driver tests which components are set in ListOfComponents? in config.card and lmdz.driver activates corresponding parameters in run.def file.
This configuration can no longer run with libIGCM_v1_12. libIGCM/trunk from rev 541 or later is needed.

File size: 3.6 KB
Line 
1#!/bin/ksh
2#-----------------------------------
3CPL_Initialize ()
4{
5    IGCM_debug_PushStack "CPL_Initialize"
6 
7    echo INITIALIZE CPL !!!
8
9    RESOL_CPL=$( echo $RESOL | awk "-F-" '{print $1}' )
10
11    #D- MPI context used to launch the coupled model
12    LIBMPI=$(cat ${SUBMIT_DIR}/../.libmpi)
13    echo LIBMPI=${LIBMPI}
14
15    #D- MPISUSPEND=ON required for MPMD mode used by oasis
16    export MPISUSPEND=ON
17
18    IGCM_sys_build_run_file ${LIBMPI}
19
20    CPL_OkDay="n"
21    CPL_OkMonth="n"
22
23    for CPL_Frequency in ${config_CPL_WriteFrequency} ; do
24        case ${CPL_Frequency} in
25            *D|*d) CPL_OkDay="y"   ;;
26            *M)    CPL_OkMonth="y" ;;
27        esac
28    done
29
30    IGCM_debug_PopStack "CPL_Initialize"
31
32}
33
34#-----------------------------------
35CPL_Update ()
36{
37    IGCM_debug_PushStack "CPL_Update"
38
39    # Local function to find parameters in LMDZ .def files
40    lmdzgrep () {
41        grep $1 $2 |grep -v "#" | awk "-F=" '{print $2}'
42    }
43
44    ############ Update Time and Counters ##############
45    ##-- Calcul de la duree du job (en secondes)
46    (( D_JOB_SEC = 3600 * 24 * PeriodLengthInDays ))
47
48    # nleapy configuration
49    case ${config_UserChoices_CalendarType} in
50        leap|gregorian)
51            CPL_calendar=1;;
52        noleap)
53            CPL_calendar=0;;
54        360d)
55            CPL_calendar=30;;
56        *)
57            CPL_calendar=30
58    esac
59
60    ############ Update Other Parameters  ##############
61    ## Read Output_mode option in oasis.card --> Put "y" to have coupling variables in ouptut files
62    CPL_OutputMode="n"
63    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/oasis.card UserChoices OutputMode
64    eval CPL_OutputMode=\${oasis_UserChoices_OutputMode} > /dev/null 2>&1
65    echo CPL_OutputMode = ${CPL_OutputMode}
66    CPL_OutputVar='EXPORTED'
67    if [ ${CPL_OutputMode} = y ] ; then
68        CPL_OutputVar='EXPOUT'
69    fi
70
71    ## Calculate lag for transfer of fields from atmosphere -> ocean.
72    ## LAG_ATM="1day in sec"/day_step * iphysiq/nsplit_phys
73    ## First get day_step, iphyisq and nsplit_phys from LMDZ parameter files
74    day_step=$( lmdzgrep day_step gcm.def )
75    iphysiq=$( lmdzgrep iphysiq gcm.def )
76    nsplit_phys=$( lmdzgrep nsplit_phys physiq.def )
77
78    (( LAG_ATM = 86400 / day_step * iphysiq / nsplit_phys ))
79
80    ############ Update Parameter Files   ##############
81    sed -e "s/<initial_date>/${PeriodDateBegin}/" \
82        -e "s/<calendar_type>/${CPL_calendar}/" \
83        -e "s/<total_time>/${D_JOB_SEC}/" \
84        -e "s/<lib_mpi>/${LIBMPI}/" \
85        -e "s/<nproc_atm>/${NUM_PROC_ATM}/g" \
86        -e "s/<nproc_oce>/${NUM_PROC_OCE}/g" \
87        -e "s/<output_mode>/${CPL_OutputVar}/g" \
88        -e "s/<lag_atm>/${LAG_ATM}/g" \
89        namcouple > namcouple.tmp
90    IGCM_sys_Mv namcouple.tmp namcouple
91
92    # Unused files we want to remove
93    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=trace
94    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=gweights
95    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=mweights
96    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=anaisout
97
98    IGCM_debug_PopStack "CPL_Update"
99}
100
101#-----------------------------------
102CPL_Finalize ()
103{
104    IGCM_debug_PushStack "CPL_Finalize"
105
106    DATE_CPL=$(echo ${PeriodDateBegin} | sed -e "{ s/^\(.\{4\}\)/\1-/;s/\(-.\{2\}\)/\1-/; }");
107    DATE_CPL=${DATE_CPL}"T00:00:00"
108   
109    echo ${DATE_CPL} ${CPL_OutputMode} ${CPL_OkDay} ${CPL_OkMonth}
110
111    if [ "${CPL_OutputMode}" = "y" ] ; then
112
113        [[ ${CPL_OkDay}   = "y" ]] && date >TEMPO_1D_cpl_atm.nc
114        [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_atm.nc
115        [[ ${CPL_OkDay}   = "y" ]] && date >TEMPO_1D_cpl_oce.nc
116        [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_oce.nc
117
118    fi
119
120    echo FINALIZE CPL !!!
121
122    IGCM_debug_PopStack "CPL_Finalize"
123}
Note: See TracBrowser for help on using the repository browser.