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

Last change on this file since 2109 was 2109, checked in by omamce, 9 years ago

O.M. : detection of sea ice model use.

File size: 3.7 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    ## Calculate lag for transfer of fields from atmosphere -> ocean.
74    ## LAG_ATM="1day in sec"/day_step * iphysiq/nsplit_phys
75    ## First get day_step, iphyisq and nsplit_phys from LMDZ parameter files
76    day_step=$( lmdzgrep day_step gcm.def )
77    iphysiq=$( lmdzgrep iphysiq gcm.def )
78    nsplit_phys=$( lmdzgrep nsplit_phys physiq.def )
79
80    (( LAG_ATM = 86400 / day_step * iphysiq / nsplit_phys ))
81
82    ############ Update Parameter Files   ##############
83    sed -e "s/<initial_date>/${PeriodDateBegin}/" \
84        -e "s/<calendar_type>/${CPL_calendar}/" \
85        -e "s/<total_time>/${D_JOB_SEC}/" \
86        -e "s/<lib_mpi>/${LIBMPI}/" \
87        -e "s/<nproc_atm>/${NUM_PROC_ATM}/g" \
88        -e "s/<nproc_oce>/${NUM_PROC_OCE}/g" \
89        -e "s/<output_mode>/${CPL_OutputVar}/g" \
90        -e "s/<lag_atm>/${LAG_ATM}/g" \
91        namcouple > namcouple.tmp
92    IGCM_sys_Mv namcouple.tmp namcouple
93
94    # Unused files we want to remove
95    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=trace
96    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=gweights
97    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=mweights
98    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=anaisout
99
100    IGCM_debug_PopStack "CPL_Update"
101}
102
103#-----------------------------------
104CPL_Finalize ()
105{
106    IGCM_debug_PushStack "CPL_Finalize"
107
108    DATE_CPL=$(echo ${PeriodDateBegin} | sed -e "{ s/^\(.\{4\}\)/\1-/;s/\(-.\{2\}\)/\1-/; }");
109    DATE_CPL=${DATE_CPL}"T00:00:00"
110   
111    echo ${DATE_CPL} ${CPL_OutputMode} ${CPL_OkDay} ${CPL_OkMonth}
112
113    if [ "${CPL_OutputMode}" = "y" ] ; then
114
115        [[ ${CPL_OkDay}   = "y" ]] && date >TEMPO_1D_cpl_atm.nc
116        [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_atm.nc
117        [[ ${CPL_OkDay}   = "y" ]] && date >TEMPO_1D_cpl_oce.nc
118        [[ ${CPL_OkMonth} = "y" ]] && date >TEMPO_1M_cpl_oce.nc
119
120    fi
121
122    echo FINALIZE CPL !!!
123
124    IGCM_debug_PopStack "CPL_Finalize"
125}
Note: See TracBrowser for help on using the repository browser.