source: CONFIG/IPSLCM/IPSLCM5_v4/GENERAL/DRIVER/oasis.driver @ 1649

Last change on this file since 1649 was 1622, checked in by jgipsl, 13 years ago

Changed default values for type_ocean and VEGET in run.def. Now the default is LMDZ forced without ORCHIDEE and without ocean. Theses values are changed automatically if oasis.driver and/or orchidee.driver is used.

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