source: CONFIG/UNIFORM/v6/IPSLCM6/GENERAL/DRIVER/oasis.driver @ 2186

Last change on this file since 2186 was 2126, checked in by omamce, 11 years ago

O.M.

Set a default coupling frequency

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