source: CONFIG/UNIFORM/v5/IPSLCM5_v5/GENERAL/DRIVER/oasis.driver @ 1785

Last change on this file since 1785 was 1785, checked in by aclsce, 10 years ago

Moved lmdzgrep function from *_update function to *_initialize function
for oasis and pisces component (because of bad behaviour on SX9).

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# 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
16    #D- MPI context used to launch the coupled model
17    LIBMPI=$(cat ${SUBMIT_DIR}/../.libmpi)
18    echo LIBMPI=${LIBMPI}
19
20    #D- MPISUSPEND=ON required for MPMD mode used by oasis
21    export MPISUSPEND=ON
22
23    IGCM_sys_build_run_file ${LIBMPI}
24
25    CPL_OkDay="n"
26    CPL_OkMonth="n"
27
28    for CPL_Frequency in ${config_CPL_WriteFrequency} ; do
29        case ${CPL_Frequency} in
30            *D|*d) CPL_OkDay="y"   ;;
31            *M)    CPL_OkMonth="y" ;;
32        esac
33    done
34
35    IGCM_debug_PopStack "CPL_Initialize"
36
37}
38
39#-----------------------------------
40CPL_Update ()
41{
42    IGCM_debug_PushStack "CPL_Update"
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.