Ignore:
Timestamp:
Feb 11, 2016, 3:01:01 PM (9 years ago)
Author:
ymipsl
Message:

Compilation of IOIPSL is now made by FCM

YM

Location:
dynamico_lmdz/aquaplanet/IOIPSL
Files:
4 added
21 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • dynamico_lmdz/aquaplanet/IOIPSL/src/calendar.f90

    r3847 r3907  
    11MODULE calendar
    22!-
    3 !$Id: calendar.f90 1011 2010-05-07 13:05:34Z bellier $
     3!$Id: calendar.f90 1519 2011-08-01 09:34:10Z mmaipsl $
    44!-
    55! This software is governed by the CeCILL license
     
    4040!---------------------------------------------------------------------
    4141  USE stringop,ONLY  : strlowercase
    42   USE errioipsl,ONLY : ipslerr
     42  USE errioipsl,ONLY : ipslerr, ipsldbg, ipslout
    4343!-
    4444  PRIVATE
     
    354354    tmp_str = input_str
    355355    DO WHILE ( MAX(y_pos,m_pos,d_pos,s_pos) > 0)
    356 !---- WRITE(*,*) tmp_str
    357 !---- WRITE(*,*) y_pos,m_pos,d_pos,s_pos
     356!---- WRITE(ipslout,*) tmp_str
     357!---- WRITE(ipslout,*) y_pos,m_pos,d_pos,s_pos
    358358      IF (y_pos > 0) THEN
    359359        WRITE(fmt,'("(I",I10.10,")")') y_pos-1
     
    530530  INTEGER :: yearp,dayp
    531531  REAL :: sec,secp
    532   LOGICAL :: check = .FALSE.
    533 !---------------------------------------------------------------------
    534   IF (check) THEN
    535     WRITE(*,*) &
     532  LOGICAL :: l_dbg
     533!---------------------------------------------------------------------
     534  CALL ipsldbg (old_status=l_dbg)
     535!---------------------------------------------------------------------
     536  IF (l_dbg) THEN
     537    WRITE(ipslout,*) &
    536538 &    "isittime 1.0 ",itau,date0,dt,freq,last_action,last_check
    537539  ENDIF
     
    604606 &        <= ABS( next_check_itau-next_act_itau)) THEN
    605607        do_action = .TRUE.
    606         IF (check) THEN
    607           WRITE(*,*) &
     608        IF (l_dbg) THEN
     609          WRITE(ipslout,*) &
    608610 &         'ACT-TIME : itau, next_act_itau, next_check_itau : ', &
    609611 &         itau,next_act_itau,next_check_itau
    610612          CALL ju2ymds (date_now,year,month,day,sec)
    611           WRITE(*,*) 'ACT-TIME : y, m, d, s : ',year,month,day,sec
    612           WRITE(*,*) &
     613          WRITE(ipslout,*) 'ACT-TIME : y, m, d, s : ',year,month,day,sec
     614          WRITE(ipslout,*) &
    613615 &         'ACT-TIME : date_mp1, date_mpf : ',date_mp1,date_mpf
    614616        ENDIF
     
    618620    ENDIF
    619621!-
    620     IF (check) THEN
    621       WRITE(*,*) "isittime 2.0 ", &
     622    IF (l_dbg) THEN
     623      WRITE(ipslout,*) "isittime 2.0 ", &
    622624 &     date_next_check,date_next_act,ABS(dt_action-freq), &
    623625 &     ABS(dt_action+dt_check-freq),dt_action,dt_check, &
  • dynamico_lmdz/aquaplanet/IOIPSL/src/errioipsl.f90

    r3847 r3907  
    11MODULE errioipsl
    22!-
    3 !$Id: errioipsl.f90 759 2009-10-22 08:53:27Z bellier $
     3!$Id: errioipsl.f90 2079 2013-06-03 09:14:13Z jgipsl $
    44!-
    55! This software is governed by the CeCILL license
     
    1010PRIVATE
    1111!-
    12 PUBLIC :: ipslnlf, ipslerr, ipslerr_act, ipslerr_inq, histerr, ipsldbg
    13 !-
    14   INTEGER :: n_l=6, ilv_cur=0, ilv_max=0
     12PUBLIC :: ipslnlf, ipslerr, ipslerr_act, ipslerr_inq, histerr, ipsldbg, ipslout
     13!-
     14  INTEGER :: ipslout=6, ilv_cur=0, ilv_max=0
    1515  LOGICAL :: ioipsl_debug=.FALSE., lact_mode=.TRUE.
    1616!-
     
    3939!---------------------------------------------------------------------
    4040  IF (PRESENT(old_number)) THEN
    41     old_number = n_l
     41    old_number = ipslout
    4242  ENDIF
    4343  IF (PRESENT(new_number)) THEN
    44     n_l = new_number
     44    ipslout = new_number
    4545  ENDIF
    4646!---------------------
     
    7676     ilv_cur = plev
    7777     ilv_max = MAX(ilv_max,plev)
    78      WRITE(n_l,'(/,A," ",A)') TRIM(pemsg(plev)),TRIM(pcname)
    79      WRITE(n_l,'(3(" --> ",A,/))') TRIM(pstr1),TRIM(pstr2),TRIM(pstr3)
     78     WRITE(ipslout,'(/,A," ",A)') TRIM(pemsg(plev)),TRIM(pcname)
     79     WRITE(ipslout,'(3(" --> ",A,/))') TRIM(pstr1),TRIM(pstr2),TRIM(pstr3)
    8080   ENDIF
    8181   IF ( (plev == 3).AND.lact_mode) THEN
    82      WRITE(n_l,'("Fatal error from IOIPSL. STOP in ipslerr with code")')
     82     WRITE(ipslout,'("Fatal error from IOIPSL. STOP in ipslerr with code")')
    8383     STOP 1
    8484   ENDIF
     
    177177   ENDIF
    178178   IF (plev == 3) THEN
    179      STOP 'Fatal error from IOIPSL. See stdout for more details'
     179     WRITE(ipslout,'("Fatal error from IOIPSL. See stdout for more details")')
     180     STOP 1
    180181   ENDIF
    181182!---------------------
  • dynamico_lmdz/aquaplanet/IOIPSL/src/flincom.f90

    r3847 r3907  
    11MODULE flincom
    22!-
    3 !$Id: flincom.f90 427 2008-10-16 07:55:13Z bellier $
     3!$Id: flincom.f90 1932 2012-11-28 09:56:17Z jgipsl $
    44!-
    55! This software is governed by the CeCILL license
     
    99!-
    1010  USE calendar,  ONLY : ju2ymds, ymds2ju, ioconf_calendar
    11   USE errioipsl, ONLY : histerr
     11  USE errioipsl, ONLY : histerr, ipslout,ipslerr,ipsldbg
    1212  USE stringop,  ONLY : strlowercase
    1313!-
     
    175175  CHARACTER(LEN=250):: name
    176176!-
    177   LOGICAL :: check = .FALSE.
    178 !---------------------------------------------------------------------
     177  LOGICAL :: l_dbg
     178!---------------------------------------------------------------------
     179  CALL ipsldbg (old_status=l_dbg)
     180
    179181  lll = LEN_TRIM(filename)
    180182  IF (filename(lll-2:lll) /= '.nc') THEN
     
    193195! Vertical axis
    194196!-
    195   IF (check) WRITE(*,*) 'flincre Vertical axis'
     197  IF (l_dbg) WRITE(ipslout,*) 'flincre Vertical axis'
    196198!-
    197199  iret = NF90_DEF_VAR (fid, 'lev', NF90_FLOAT, zdimid1, levid)
     
    202204! Time axis
    203205!-
    204   IF (check) WRITE(*,*) 'flincre time axis'
     206  IF (l_dbg) WRITE(ipslout,*) 'flincre time axis'
    205207!-
    206208  iret = NF90_DEF_VAR (fid, 'tstep', NF90_FLOAT, tdimid1, timeid)
     
    211213! The longitude
    212214!-
    213   IF (check) WRITE(*,*) 'flincre Longitude axis'
     215  IF (l_dbg) WRITE(ipslout,*) 'flincre Longitude axis'
    214216!-
    215217  iret = NF90_DEF_VAR (fid, "nav_lon", NF90_FLOAT, &
     
    226228! The Latitude
    227229!-
    228   IF (check) WRITE(*,*) 'flincre Latitude axis'
     230  IF (l_dbg) WRITE(ipslout,*) 'flincre Latitude axis'
    229231!-
    230232  iret = NF90_DEF_VAR (fid, "nav_lat", NF90_FLOAT, &
     
    253255  iret = NF90_ENDDEF (fid)
    254256!-
    255   IF (check) WRITE(*,*) 'flincre Variable'
     257  IF (l_dbg) WRITE(ipslout,*) 'flincre Variable'
    256258!-
    257259  iret = NF90_PUT_VAR (fid, levid, lev1(1:llm1))
    258260!-
    259   IF (check) WRITE(*,*) 'flincre Time Variable'
     261  IF (l_dbg) WRITE(ipslout,*) 'flincre Time Variable'
    260262!-
    261263  iret = NF90_PUT_VAR (fid, timeid, REAL(itaus(1:ttm1)))
    262264!-
    263   IF (check) WRITE(*,*) 'flincre Longitude'
     265  IF (l_dbg) WRITE(ipslout,*) 'flincre Longitude'
    264266!-
    265267  iret = NF90_PUT_VAR (fid, lonid, lon1(1:iim1,1:jjm1))
    266268!-
    267   IF (check) WRITE(*,*) 'flincre Latitude'
     269  IF (l_dbg) WRITE(ipslout,*) 'flincre Latitude'
    268270!-
    269271  iret = NF90_PUT_VAR (fid, latid, lat1(1:iim1,1:jjm1))
     
    311313  INTEGER :: fid_out
    312314!-
    313   LOGICAL :: check = .FALSE.
    314 !---------------------------------------------------------------------
    315   IF (check) WRITE (*,*) ' iideb, iilen, jjdeb, jjlen, iim, jjm ', &
     315  LOGICAL :: l_dbg
     316!---------------------------------------------------------------------
     317  CALL ipsldbg (old_status=l_dbg)
     318
     319  IF (l_dbg) WRITE (*,*) ' iideb, iilen, jjdeb, jjlen, iim, jjm ', &
    316320                           iideb, iilen, jjdeb, jjlen, iim, jjm
    317   IF (check) WRITE (*,*) ' lon ', lon(1,1), lon(iilen,jjlen)
    318   IF (check) WRITE (*,*) ' lat ', lat(1,1), lat(iilen,jjlen)
     321  IF (l_dbg) WRITE (*,*) ' lon ', lon(1,1), lon(iilen,jjlen)
     322  IF (l_dbg) WRITE (*,*) ' lat ', lat(1,1), lat(iilen,jjlen)
    319323!-
    320324  CALL flinopen_work &
     
    341345  REAL :: date0, dt
    342346  INTEGER :: fid_out
    343 !---------------------------------------------------------------------
     347  INTEGER :: iimc, jjmc
     348!---------------------------------------------------------------------
     349  iimc=iim
     350  jjmc=jjm
    344351  CALL flinopen_work &
    345     (filename, 1, iim, 1, jjm, do_test, &
     352    (filename, 1, iimc, 1, jjmc, do_test, &
    346353     iim, jjm, llm, lon, lat, lev, ttm, itaus, date0, dt, fid_out)
    347354!-------------------------
     
    385392!-
    386393  LOGICAL :: open_file
    387   LOGICAL :: check = .FALSE.
    388 !---------------------------------------------------------------------
     394  LOGICAL :: l_dbg
     395!---------------------------------------------------------------------
     396  CALL ipsldbg (old_status=l_dbg)
     397
    389398  iilast = iideb+iilen-1
    390399  jjlast = jjdeb+jjlen-1
    391   IF (check) WRITE (*,*) &
     400  IF (l_dbg) WRITE (*,*) &
    392401    ' flinopen_work zoom 2D information '// &
    393402    ' iideb, iilen, iilast, jjdeb, jjlen, jjlast ', &
     
    419428  ENDIF
    420429!-
    421   IF (check) &
    422     WRITE(*,*) 'OUT OF flininfo :',tmp_iim,tmp_jjm,tmp_llm,tmp_ttm
     430  IF (l_dbg) &
     431    WRITE(ipslout,*) 'OUT OF flininfo :',tmp_iim,tmp_jjm,tmp_llm,tmp_ttm
    423432!-
    424433  fid = ncids(fid_out)
     
    429438! 2.2 We test the axis if we have to.
    430439!-
    431   IF (check) &
    432     WRITE(*,*) 'flininfo 2.2 We test if we have to test : ',do_test
     440  IF (l_dbg) &
     441    WRITE(ipslout,*) 'flininfo 2.2 We test if we have to test : ',do_test
    433442!-
    434443  IF (do_test) THEN
     
    450459!-- 2.3 Else the sizes of the axes are returned to the user
    451460!---
    452     IF (check) WRITE(*,*) 'flinopen 2.3 Else sizes are returned'
     461    IF (l_dbg) WRITE(ipslout,*) 'flinopen 2.3 Else sizes are returned'
    453462!---
    454463    iim = tmp_iim
     
    462471!     if not then we get the lon, lat and lev variables from the file
    463472!-
    464   IF (check) WRITE(*,*) 'flinopen 3.0 we are realy talking'
     473  IF (l_dbg) WRITE(ipslout,*) 'flinopen 3.0 we are realy talking'
    465474!-
    466475  IF (do_test) THEN
     
    470479    iret = NF90_GET_VAR (fid, vid, x_last, start=(/ iilast, jjlast /))
    471480!---
    472     IF (check) &
    473       WRITE(*,*) 'from file lon first and last, modulo 360. ', &
     481    IF (l_dbg) &
     482      WRITE(ipslout,*) 'from file lon first and last, modulo 360. ', &
    474483        x_first, x_last, MODULO(x_first,360.), MODULO(x_last,360.)
    475     IF (check) &
    476       WRITE(*,*) 'from model lon first and last, modulo 360. ', &
     484    IF (l_dbg) &
     485      WRITE(ipslout,*) 'from model lon first and last, modulo 360. ', &
    477486        lon(1,1),lon(iilen,jjlen), &
    478487        MODULO(lon(1,1),360.), MODULO(lon(iilen,jjlen),360.)
     
    491500    iret = NF90_GET_VAR (fid, vid, x_last, start=(/ iilast, jjlast /))
    492501!---
    493     IF (check) WRITE(*,*) &
     502    IF (l_dbg) WRITE(ipslout,*) &
    494503      'from file lat first and last ',x_first,x_last
    495     IF (check) WRITE(*,*) &
     504    IF (l_dbg) WRITE(ipslout,*) &
    496505      'from model lat first and last ',lat(1,1),lat(iilen,jjlen)
    497506!---
     
    509518      iret = NF90_GET_VAR (fid, vid, x_last, start=(/ llm /))
    510519!-----
    511       IF (check) WRITE(*,*) &
     520      IF (l_dbg) WRITE(ipslout,*) &
    512521        'from file lev first and last ',x_first ,x_last
    513       IF (check) WRITE(*,*) &
     522      IF (l_dbg) WRITE(ipslout,*) &
    514523        'from model lev first and last ',lev(1),lev(llm)
    515524!-----
     
    527536!-- 4.0 extracting the coordinates if we do not check
    528537!---
    529     IF (check) WRITE(*,*) 'flinopen 4.0 extracting the coordinates'
     538    IF (l_dbg) WRITE(ipslout,*) 'flinopen 4.0 extracting the coordinates'
    530539!---
    531540    CALL flinfindcood (fid_out, 'lon', vid, nbdim)
     
    572581! 5.0 Get all the details for the time if possible needed
    573582!-
    574   IF (check) WRITE(*,*) 'flinopen 5.0 Get time'
     583  IF (l_dbg) WRITE(ipslout,*) 'flinopen 5.0 Get time'
    575584!-
    576585  IF (ttm > 0) THEN
     
    588597      IF (INDEX(units,'seconds since') > 0) gdtmaf_id = iv
    589598      IF (INDEX(units,'timesteps since') > 0) gdtt_id = iv
    590       IF (INDEX(name, 'tstep') > 0) old_id = iv
     599      IF (INDEX(name, 'tstep') > 0 .OR. INDEX(name,'time') > 0 ) old_id = iv
    591600    ENDDO
    592601!---
     
    606615    DEALLOCATE(vec_tmp)
    607616!---
    608     IF (check) WRITE(*,*) 'flinopen 5.1 Times ',itaus
     617    IF (l_dbg) WRITE(ipslout,*) 'flinopen 5.1 Times ',itaus
    609618!---
    610619!-- Getting all the details for the time axis
     
    626635      sec0 = hours0*3600. + minutes0*60. + seci
    627636      CALL ymds2ju (year0, month0, day0, sec0, date0)
    628       IF (check) &
    629         WRITE(*,*) 'flinopen 5.1 gdtt_id year0 ... date0 ', &
     637      IF (l_dbg) &
     638        WRITE(ipslout,*) 'flinopen 5.1 gdtt_id year0 ... date0 ', &
    630639                   year0, month0, day0, sec0, date0
    631640!-----
     
    639648      CALL ymds2ju (year0, month0, day0, sec0, date0)
    640649!-----
    641       IF (check) &
    642         WRITE(*,*) 'flinopen 5.1 gdtmaf_id year0 ... date0 ', &
     650      IF (l_dbg) &
     651        WRITE(ipslout,*) 'flinopen 5.1 gdtmaf_id year0 ... date0 ', &
    643652                   year0, month0, day0, sec0, date0
    644653    ELSE IF (old_id > 0) THEN
     
    657666  ENDIF
    658667!-
    659   IF (check) WRITE(*,*) 'flinopen 6.0 File opened', date0, dt
     668  IF (l_dbg) WRITE(ipslout,*) 'flinopen 6.0 File opened', date0, dt
    660669!---------------------------
    661670END SUBROUTINE flinopen_work
     
    685694  CHARACTER(LEN=30) :: axname
    686695!-
    687   LOGICAL :: check = .FALSE.
    688 !---------------------------------------------------------------------
     696  LOGICAL :: l_dbg
     697!---------------------------------------------------------------------
     698  CALL ipsldbg (old_status=l_dbg)
     699
    689700  lll = LEN_TRIM(filename)
    690701  IF (filename(lll-2:lll) /= '.nc') THEN
     
    713724    axname = ADJUSTL(axname)
    714725!---
    715     IF (check) WRITE(*,*) &
     726    IF (l_dbg) WRITE(ipslout,*) &
    716727      'flininfo - getting axname',iv,axname,lll
    717728!---
     
    728739      zid = iv; llm = lll;
    729740    ELSE IF (    (INDEX(axname,'tstep') == 1) &
     741             .OR.(INDEX(axname,'time') == 1) &
    730742             .OR.(INDEX(axname,'time_counter') == 1) ) THEN
    731743!---- For the time we certainly need to allow for other names
     
    775787!-
    776788  INTEGER :: fid, ncvarid, ndim, iret
    777   LOGICAL :: check = .FALSE.
    778 !---------------------------------------------------------------------
    779   IF (check) WRITE(*,*) &
     789  LOGICAL :: l_dbg
     790!---------------------------------------------------------------------
     791  CALL ipsldbg (old_status=l_dbg)
     792
     793  IF (l_dbg) WRITE(ipslout,*) &
    780794     "flinput_r1d : SIZE(var) = ",SIZE(var)
    781795!-
     
    802816!-
    803817  INTEGER :: fid, ncvarid, ndim, iret
    804   LOGICAL :: check = .FALSE.
    805 !---------------------------------------------------------------------
    806   IF (check) WRITE(*,*) &
     818  LOGICAL :: l_dbg
     819!---------------------------------------------------------------------
     820  CALL ipsldbg (old_status=l_dbg)
     821
     822  IF (l_dbg) WRITE(ipslout,*) &
    807823     "flinput_r2d : SIZE(var) = ",SIZE(var)
    808824!-
     
    829845!-
    830846  INTEGER :: fid, ncvarid, ndim, iret
    831   LOGICAL :: check = .FALSE.
    832 !---------------------------------------------------------------------
    833   IF (check) WRITE(*,*) &
     847  LOGICAL :: l_dbg
     848!---------------------------------------------------------------------
     849  CALL ipsldbg (old_status=l_dbg)
     850
     851  IF (l_dbg) WRITE(ipslout,*) &
    834852     "flinput_r3d : SIZE(var) = ",SIZE(var)
    835853!-
     
    856874!-
    857875  INTEGER :: fid, ncvarid, ndim, iret
    858   LOGICAL :: check = .FALSE.
    859 !---------------------------------------------------------------------
    860   IF (check) WRITE(*,*) &
     876  LOGICAL :: l_dbg
     877!---------------------------------------------------------------------
     878  CALL ipsldbg (old_status=l_dbg)
     879
     880  IF (l_dbg) WRITE(ipslout,*) &
    861881     "flinput_r4d : SIZE(var) = ",SIZE(var)
    862882!-
     
    955975  INTEGER :: jl, ji
    956976  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
    957   LOGICAL :: check = .FALSE.
    958 !---------------------------------------------------------------------
     977  LOGICAL :: l_dbg
     978!---------------------------------------------------------------------
     979  CALL ipsldbg (old_status=l_dbg)
     980
    959981  IF (.NOT.ALLOCATED(buff_tmp)) THEN
    960     IF (check) WRITE(*,*) &
     982    IF (l_dbg) WRITE(ipslout,*) &
    961983      "flinget_r1d : allocate buff_tmp for buff_sz = ",SIZE(var)
    962984    ALLOCATE (buff_tmp(SIZE(var)))
    963985  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
    964     IF (check) WRITE(*,*) &
     986    IF (l_dbg) WRITE(ipslout,*) &
    965987      "flinget_r1d : re-allocate buff_tmp for buff_sz = ",SIZE(var)
    966988    DEALLOCATE (buff_tmp)
     
    9931015  INTEGER :: jl, jj, ji
    9941016  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
    995   LOGICAL :: check = .FALSE.
    996 !---------------------------------------------------------------------
     1017  LOGICAL :: l_dbg
     1018!---------------------------------------------------------------------
     1019  CALL ipsldbg (old_status=l_dbg)
     1020
    9971021  IF (.NOT.ALLOCATED(buff_tmp)) THEN
    998     IF (check) WRITE(*,*) &
     1022    IF (l_dbg) WRITE(ipslout,*) &
    9991023      "flinget_r2d : allocate buff_tmp for buff_sz = ",SIZE(var)
    10001024    ALLOCATE (buff_tmp(SIZE(var)))
    10011025  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
    1002     IF (check) WRITE(*,*) &
     1026    IF (l_dbg) WRITE(ipslout,*) &
    10031027      "flinget_r2d : re-allocate buff_tmp for buff_sz = ",SIZE(var)
    10041028    DEALLOCATE (buff_tmp)
     
    10341058  INTEGER :: jl, jj, ji
    10351059  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
    1036   LOGICAL :: check = .FALSE.
    1037 !---------------------------------------------------------------------
     1060  LOGICAL :: l_dbg
     1061!---------------------------------------------------------------------
     1062  CALL ipsldbg (old_status=l_dbg)
     1063
    10381064  IF (.NOT.ALLOCATED(buff_tmp)) THEN
    1039     IF (check) WRITE(*,*) &
     1065    IF (l_dbg) WRITE(ipslout,*) &
    10401066      "flinget_r2d_zoom : allocate buff_tmp for buff_sz = ",SIZE(var)
    10411067    ALLOCATE (buff_tmp(SIZE(var)))
    10421068  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
    1043     IF (check) WRITE(*,*) &
     1069    IF (l_dbg) WRITE(ipslout,*) &
    10441070      "flinget_r2d_zoom : re-allocate buff_tmp for buff_sz = ",SIZE(var)
    10451071    DEALLOCATE (buff_tmp)
     
    10741100  INTEGER :: jl, jk, jj, ji
    10751101  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
    1076   LOGICAL :: check = .FALSE.
    1077 !---------------------------------------------------------------------
     1102  LOGICAL :: l_dbg
     1103!---------------------------------------------------------------------
     1104  CALL ipsldbg (old_status=l_dbg)
     1105
    10781106  IF (.NOT.ALLOCATED(buff_tmp)) THEN
    1079     IF (check) WRITE(*,*) &
     1107    IF (l_dbg) WRITE(ipslout,*) &
    10801108      "flinget_r3d : allocate buff_tmp for buff_sz = ",SIZE(var)
    10811109    ALLOCATE (buff_tmp(SIZE(var)))
    10821110  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
    1083     IF (check) WRITE(*,*) &
     1111    IF (l_dbg) WRITE(ipslout,*) &
    10841112      "flinget_r3d : re-allocate buff_tmp for buff_sz = ",SIZE(var)
    10851113    DEALLOCATE (buff_tmp)
     
    11171145  INTEGER :: jl, jk, jj, ji
    11181146  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
    1119   LOGICAL :: check = .FALSE.
    1120 !---------------------------------------------------------------------
     1147  LOGICAL :: l_dbg
     1148!---------------------------------------------------------------------
     1149  CALL ipsldbg (old_status=l_dbg)
     1150
    11211151  IF (.NOT.ALLOCATED(buff_tmp)) THEN
    1122     IF (check) WRITE(*,*) &
     1152    IF (l_dbg) WRITE(ipslout,*) &
    11231153      "flinget_r3d_zoom : allocate buff_tmp for buff_sz = ",SIZE(var)
    11241154    ALLOCATE (buff_tmp(SIZE(var)))
    11251155  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
    1126     IF (check) WRITE(*,*) &
     1156    IF (l_dbg) WRITE(ipslout,*) &
    11271157      "flinget_r3d_zoom : re-allocate buff_tmp for buff_sz = ",SIZE(var)
    11281158    DEALLOCATE (buff_tmp)
     
    11591189  INTEGER :: jl, jk, jj, ji, jm
    11601190  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
    1161   LOGICAL :: check = .FALSE.
    1162 !---------------------------------------------------------------------
     1191  LOGICAL :: l_dbg
     1192!---------------------------------------------------------------------
     1193  CALL ipsldbg (old_status=l_dbg)
     1194
    11631195  IF (.NOT.ALLOCATED(buff_tmp)) THEN
    1164     IF (check) WRITE(*,*) &
     1196    IF (l_dbg) WRITE(ipslout,*) &
    11651197      "flinget_r4d : allocate buff_tmp for buff_sz = ",SIZE(var)
    11661198    ALLOCATE (buff_tmp(SIZE(var)))
    11671199  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
    1168     IF (check) WRITE(*,*) &
     1200    IF (l_dbg) WRITE(ipslout,*) &
    11691201      "flinget_r4d : re-allocate buff_tmp for buff_sz = ",SIZE(var)
    11701202    DEALLOCATE (buff_tmp)
     
    12041236  INTEGER :: jl, jk, jj, ji, jm
    12051237  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: buff_tmp
    1206   LOGICAL :: check = .FALSE.
    1207 !---------------------------------------------------------------------
     1238  LOGICAL :: l_dbg
     1239!---------------------------------------------------------------------
     1240  CALL ipsldbg (old_status=l_dbg)
     1241
    12081242  IF (.NOT.ALLOCATED(buff_tmp)) THEN
    1209     IF (check) WRITE(*,*) &
     1243    IF (l_dbg) WRITE(ipslout,*) &
    12101244      "flinget_r4d_zoom : allocate buff_tmp for buff_sz = ",SIZE(var)
    12111245    ALLOCATE (buff_tmp(SIZE(var)))
    12121246  ELSE IF (SIZE(var) > SIZE(buff_tmp)) THEN
    1213     IF (check) WRITE(*,*) &
     1247    IF (l_dbg) WRITE(ipslout,*) &
    12141248      "flinget_r4d_zoom : re-allocate buff_tmp for buff_sz = ",SIZE(var)
    12151249    DEALLOCATE (buff_tmp)
     
    12801314! ARGUMENTS
    12811315!-
    1282   INTEGER :: fid_in
    1283   CHARACTER(LEN=*) :: varname
    1284   INTEGER :: iim, jjm, llm, ttm
    1285   INTEGER :: itau_dep, itau_fin, iideb, iilen, jjdeb, jjlen
    1286   REAL :: var(:)
     1316  INTEGER, INTENT(IN) :: fid_in
     1317  CHARACTER(LEN=*), INTENT(IN) :: varname
     1318  INTEGER, INTENT(IN) :: iim, jjm, llm, ttm
     1319  INTEGER, INTENT(IN) :: itau_dep, itau_fin, iideb, iilen, jjdeb, jjlen
     1320  REAL, INTENT(OUT) :: var(:)
    12871321!-
    12881322! LOCAL
     
    13001334  INTEGER :: i, nvars, i2d, cnd
    13011335  REAL,DIMENSION(:),ALLOCATABLE,SAVE :: var_tmp
     1336  INTEGER :: itau_len
    13021337  LOGICAL :: uncompress = .FALSE.
    1303   LOGICAL :: check = .FALSE.
    1304 !---------------------------------------------------------------------
     1338  INTEGER :: il, ip, i2p, it
     1339  !-
     1340  LOGICAL :: l_dbg
     1341!---------------------------------------------------------------------
     1342  CALL ipsldbg (old_status=l_dbg)
     1343  !-
    13051344  fid = ncids(fid_in)
    13061345!-
    1307   IF (check) THEN
    1308     WRITE(*,*) &
     1346  IF (l_dbg) THEN
     1347    WRITE(ipslout,*) &
    13091348    'flinget_mat : fid_in, fid, varname :', fid_in, fid, TRIM(varname)
    1310     WRITE(*,*) &
     1349    WRITE(ipslout,*) &
    13111350    'flinget_mat : iim, jjm, llm, ttm, itau_dep, itau_fin :', &
    13121351    iim, jjm, llm, ttm, itau_dep, itau_fin
    1313     WRITE(*,*) &
     1352    WRITE(ipslout,*) &
    13141353    'flinget_mat : iideb, iilen, jjdeb, jjlen :', &
    13151354    iideb, iilen, jjdeb, jjlen
     
    13321371  iret = NF90_INQUIRE_VARIABLE (fid, vid, &
    13331372           ndims=ndims, dimids=dimids, nAtts=nb_atts)
    1334   IF (check) THEN
    1335     WRITE(*,*) &
     1373  IF (l_dbg) THEN
     1374    WRITE(ipslout,*) &
    13361375    'flinget_mat : fid, vid :', fid, vid
    1337     WRITE(*,*) &
     1376    WRITE(ipslout,*) &
    13381377    'flinget_mat : ndims, dimids(1:ndims), nb_atts :', &
    13391378    ndims, dimids(1:ndims), nb_atts
     
    13441383    iret  = NF90_INQUIRE_DIMENSION (fid, dimids(i), len=w_dim(i))
    13451384  ENDDO
    1346   IF (check) WRITE(*,*) &
     1385  IF (l_dbg) WRITE(ipslout,*) &
    13471386    'flinget_mat : w_dim :', w_dim(1:ndims)
    13481387!-
     
    13501389!-
    13511390  IF (nb_atts > 0) THEN
    1352     IF (check) THEN
    1353       WRITE(*,*) 'flinget_mat : attributes for variable :'
     1391     IF (l_dbg) THEN
     1392      WRITE(ipslout,*) 'flinget_mat : attributes for variable :'
    13541393    ENDIF
    13551394  ENDIF
     
    13611400             .OR.(x_typ == NF90_BYTE) ) THEN
    13621401      iret = NF90_GET_ATT (fid, vid, att_n, tmp_i)
    1363       IF (check) THEN
    1364         WRITE(*,*) '   ',TRIM(att_n),' : ',tmp_i
     1402        IF (l_dbg) THEN
     1403        WRITE(ipslout,*) '   ',TRIM(att_n),' : ',tmp_i
    13651404      ENDIF
    13661405    ELSE IF ( (x_typ == NF90_FLOAT).OR.(x_typ == NF90_DOUBLE) ) THEN
    13671406      iret = NF90_GET_ATT (fid, vid, att_n, tmp_r)
    1368       IF (check) THEN
    1369         WRITE(*,*) '   ',TRIM(att_n),' : ',tmp_r
     1407        IF (l_dbg) THEN
     1408        WRITE(ipslout,*) '   ',TRIM(att_n),' : ',tmp_r
    13701409      ENDIF
    13711410      IF (index(att_n,'missing_value') > 0) THEN
     
    13751414      tmp_n = ''
    13761415      iret = NF90_GET_ATT (fid, vid, att_n, tmp_n)
    1377       IF (check) THEN
    1378         WRITE(*,*) '   ',TRIM(att_n),' : ',TRIM(tmp_n)
     1416        IF (l_dbg) THEN
     1417        WRITE(ipslout,*) '   ',TRIM(att_n),' : ',TRIM(tmp_n)
    13791418      ENDIF
    13801419      IF (index(att_n,'axis') > 0) THEN
     
    13991438    iret = NF90_INQ_VARID (fid, tmp_n, cvid)
    14001439!---
    1401     IF (check) WRITE(*,*) &
     1440    IF (l_dbg) WRITE(ipslout,*) &
    14021441      'Dimname, iret , NF90_NOERR : ',TRIM(tmp_n),iret,NF90_NOERR
    14031442!---
     
    15561595! 3.0 Reading the data
    15571596!-
    1558   IF (check) WRITE(*,*) &
     1597  IF (l_dbg) WRITE(ipslout,*) &
    15591598    'flinget_mat 3.0 : ', uncompress, w_sta, w_len
    15601599!---
     1600  var(:) = mis_v
    15611601  IF (uncompress) THEN
    15621602!---
    15631603    IF (ALLOCATED(var_tmp)) THEN
    1564       IF (SIZE(var_tmp) < clen) THEN
    1565         DEALLOCATE(var_tmp)
    1566         ALLOCATE(var_tmp(clen))
     1604      IF (SIZE(var_tmp) < PRODUCT(w_len(:),mask=(w_len>1))) THEN
     1605         DEALLOCATE(var_tmp)
     1606         ALLOCATE(var_tmp(PRODUCT(w_len(:),mask=(w_len>1))))
    15671607      ENDIF
    15681608    ELSE
    1569       ALLOCATE(var_tmp(clen))
     1609      ALLOCATE(var_tmp(PRODUCT(w_len(:),mask=(w_len>1))))
    15701610    ENDIF
    15711611!---
     
    15731613             start=w_sta(:), count=w_len(:))
    15741614!---
     1615    itau_len=itau_fin-itau_dep+1
     1616    IF (l_dbg) WRITE(ipslout,*) 'flinget_mat 3.0 : clen, itau_len ',clen,itau_len
    15751617    var(:) = mis_v
    1576     var(cindex(:)) = var_tmp(:)
     1618    IF (itau_len > 0) THEN
     1619       DO it=1,itau_len
     1620          DO il=1,clen
     1621             ip = il + (it-1)*clen
     1622             i2p = cindex(il)+(it-1)*iim*jjm
     1623             var(i2p) = var_tmp(ip)
     1624          ENDDO
     1625       ENDDO
     1626    ELSE
     1627       var(cindex(:)) = var_tmp(:)
     1628    ENDIF
    15771629!---
    15781630  ELSE
     
    15811633  ENDIF
    15821634!-
    1583   IF (check) WRITE(*,*) 'flinget_mat 3.1 : ',NF90_STRERROR (iret)
     1635  IF (l_dbg) WRITE(ipslout,*) 'flinget_mat 3.1 : ',NF90_STRERROR (iret)
    15841636!--------------------------
    15851637END  SUBROUTINE flinget_mat
     
    16271679! LOCAL
    16281680!-
    1629   INTEGER :: iret, fid
    1630 !-
    1631   LOGICAL :: check = .FALSE.
    1632 !---------------------------------------------------------------------
    1633   IF (check) THEN
    1634     WRITE (*,*) 'flinget_scal in file with id ',fid_in
     1681  INTEGER :: iret, fid, vid
     1682  INTEGER :: attlen, attnum
     1683  INTEGER :: ndims, nb_atts
     1684  INTEGER,DIMENSION(NF90_MAX_VAR_DIMS) :: dimids
     1685  LOGICAL :: var_exists
     1686!-
     1687  LOGICAL :: l_dbg
     1688  INTEGER :: lll
     1689!---------------------------------------------------------------------
     1690  CALL ipsldbg (old_status=l_dbg)
     1691
     1692  IF (l_dbg) THEN
     1693    WRITE (ipslout,*) 'flinget_scal in file with id ',fid_in
    16351694  ENDIF
    16361695!-
    16371696  fid = ncids(fid_in)
     1697  iret = NF90_INQUIRE_ATTRIBUTE(fid, NF90_GLOBAL, varname, len=attlen, attnum=attnum)
    16381698!-
    16391699! 1.0 Reading a global attribute
    16401700!-
    1641   iret = NF90_GET_ATT (fid, NF90_GLOBAL, varname, var)
     1701  IF ( iret == nf90_noerr ) THEN
     1702     !
     1703     ! This seems to be a Global attribute
     1704     !
     1705     iret = NF90_GET_ATT (fid, NF90_GLOBAL, varname, var)
     1706  ELSE
     1707     !
     1708     ! If there was an error on the test for a global attribute it
     1709     ! is perhaps a scalar variable.
     1710     !
     1711     vid = -1
     1712     iret = NF90_INQ_VARID (fid, varname, vid)
     1713     !
     1714     IF ( (vid >= 0).AND.(iret == NF90_NOERR) ) THEN
     1715        iret = NF90_INQUIRE_VARIABLE (fid, vid, &
     1716             ndims=ndims, dimids=dimids, nAtts=nb_atts)
     1717        IF (ndims == 1) THEN
     1718           iret = NF90_INQUIRE_DIMENSION (fid, dimids(1), len=lll)
     1719        ENDIF
     1720
     1721        IF ( ((ndims == 0) .OR. ((ndims == 1).AND.(lll == 1))) .AND. (nb_atts >= 0) ) THEN
     1722           iret = NF90_GET_VAR(fid, vid, var)
     1723        ELSE
     1724           CALL histerr (3,'flinget_scal', &
     1725                'The variable has coordinates and thus is probably not a scalar.', &
     1726                'Check your netCDF file.', " ")
     1727        ENDIF
     1728     ENDIF
     1729     IF (l_dbg) THEN
     1730        WRITE(ipslout,*) "Reading a Scalar value for varibale ", varname," It has value ", var
     1731     ENDIF
     1732  ENDIF
     1733!-
    16421734!---------------------------
    16431735END  SUBROUTINE flinget_scal
     
    18911983      WRITE (*,*) 'Dimension Z size   : ',llm
    18921984    ELSE IF (    (INDEX(axname,'tstep') == 1) &
     1985             .OR.(INDEX(axname,'time') == 1) &
    18931986             .OR.(INDEX(axname,'time_counter') == 1)) THEN
    18941987!---- For the time we certainly need to allow for other names
  • dynamico_lmdz/aquaplanet/IOIPSL/src/fliocom.f90

    r3847 r3907  
    11MODULE fliocom
    22!-
    3 !$Id: fliocom.f90 965 2010-04-07 08:38:54Z bellier $
     3!$Id: fliocom.f90 2311 2014-08-04 13:52:44Z mafoipsl $
    44!-
    55! This software is governed by the CeCILL license
     
    1111USE calendar,  ONLY : lock_calendar,ioget_calendar, &
    1212 &                    ioconf_calendar,ju2ymds,ymds2ju
    13 USE errioipsl, ONLY : ipslerr,ipsldbg
     13USE errioipsl, ONLY : ipslerr,ipsldbg, ipslout
    1414USE stringop,  ONLY : strlowercase,str_xfw
    1515!-
     
    4949!!--------------------------------------------------------------------
    5050  INTEGER,PARAMETER,PUBLIC :: &
    51  &  flio_max_files=100, flio_max_dims=10, flio_max_var_dims=5
     51 &  flio_max_files=100, flio_max_dims=15, flio_max_var_dims=5
    5252  INTEGER,PARAMETER,PUBLIC :: &
    5353 &  flio_i = -1,        flio_r = -2,        flio_c =nf90_char, &
     
    867867!-
    868868  IF (l_dbg) THEN
    869     WRITE(*,*) "->fliocrfd - file name : ",TRIM(f_n)
     869    WRITE(ipslout,*) "->fliocrfd - file name : ",TRIM(f_n)
    870870  ENDIF
    871871!-
     
    990990!-
    991991  IF (l_dbg) THEN
    992     WRITE(*,*) '  fliocrfd, external model file-id : ',f_e
     992    WRITE(ipslout,*) '  fliocrfd, external model file-id : ',f_e
    993993  ENDIF
    994994!-
     
    10401040!-
    10411041  IF (l_dbg) THEN
    1042     WRITE(*,*) '<-fliocrfd'
     1042    WRITE(ipslout,*) '<-fliocrfd'
    10431043  ENDIF
    10441044!----------------------
     
    10741074!-
    10751075  IF (l_dbg) THEN
    1076     WRITE(*,*) "->fliopstc"
     1076    WRITE(ipslout,*) "->fliopstc"
    10771077  ENDIF
    10781078!-
     
    11001100!---
    11011101    IF (l_dbg) THEN
    1102       WRITE(*,*) '  fliopstc : Define the Longitude axis'
     1102      WRITE(ipslout,*) '  fliopstc : Define the Longitude axis'
    11031103    ENDIF
    11041104!---
     
    11441144!---
    11451145    IF (l_dbg) THEN
    1146       WRITE(*,*) '  fliopstc : Define the Latitude axis'
     1146      WRITE(ipslout,*) '  fliopstc : Define the Latitude axis'
    11471147    ENDIF
    11481148!---
     
    11881188!---
    11891189    IF (l_dbg) THEN
    1190       WRITE(*,*) '  fliopstc : Define the Vertical axis'
     1190      WRITE(ipslout,*) '  fliopstc : Define the Vertical axis'
    11911191    ENDIF
    11921192!---
     
    12191219!---
    12201220    IF (l_dbg) THEN
    1221       WRITE(*,*) '  fliopstc : Define the Time axis'
     1221      WRITE(ipslout,*) '  fliopstc : Define the Time axis'
    12221222    ENDIF
    12231223!---
     
    13171317  IF (PRESENT(x_axis).OR.PRESENT(x_axis_2d)) THEN
    13181318    IF (l_dbg) THEN
    1319       WRITE(*,*) '  fliopstc : Create the Longitude axis'
     1319      WRITE(ipslout,*) '  fliopstc : Create the Longitude axis'
    13201320    ENDIF
    13211321    IF (PRESENT(x_axis)) THEN
     
    13301330  IF (PRESENT(y_axis).OR.PRESENT(y_axis_2d)) THEN
    13311331    IF (l_dbg) THEN
    1332       WRITE(*,*) '  fliopstc : Create the Latitude axis'
     1332      WRITE(ipslout,*) '  fliopstc : Create the Latitude axis'
    13331333    ENDIF
    13341334    IF (PRESENT(y_axis)) THEN
     
    13431343  IF (PRESENT(z_axis)) THEN
    13441344    IF (l_dbg) THEN
    1345       WRITE(*,*) '  fliopstc : Create the Vertical axis'
     1345      WRITE(ipslout,*) '  fliopstc : Create the Vertical axis'
    13461346    ENDIF
    13471347    i_rc = NF90_PUT_VAR(f_e,levid,z_axis(:))
     
    13521352  IF (PRESENT(t_axis)) THEN
    13531353    IF (l_dbg) THEN
    1354       WRITE(*,*) '  fliopstc : Create the Time axis'
     1354      WRITE(ipslout,*) '  fliopstc : Create the Time axis'
    13551355    ENDIF
    13561356    i_rc = NF90_PUT_VAR(f_e,timeid,REAL(t_axis(:)))
     
    13621362!-
    13631363  IF (l_dbg) THEN
    1364     WRITE(*,*) "<-fliopstc"
     1364    WRITE(ipslout,*) "<-fliopstc"
    13651365  ENDIF
    13661366!----------------------
     
    14281428!-
    14291429  IF (l_dbg) THEN
    1430     WRITE(*,*) "->fliodefv ",TRIM(v_n)," ",n_d,"D"
     1430    WRITE(ipslout,*) "->fliodefv ",TRIM(v_n)," ",n_d,"D"
    14311431  ENDIF
    14321432!-
     
    15671567!-
    15681568  IF (l_dbg) THEN
    1569     WRITE(*,*) "<-fliodefv"
     1569    WRITE(ipslout,*) "<-fliodefv"
    15701570  ENDIF
    15711571!----------------------
     
    20482048    ELSE IF (PRESENT(r_85)) THEN; cvr_d = "R8 5D";
    20492049    ENDIF
    2050     WRITE(*,*) "->flioputv ",TRIM(v_n)," ",TRIM(cvr_d)
     2050    WRITE(ipslout,*) "->flioputv ",TRIM(v_n)," ",TRIM(cvr_d)
    20512051  ENDIF
    20522052!-
     
    21312131!-
    21322132  IF (l_dbg) THEN
    2133     WRITE(*,*) "<-flioputv"
     2133    WRITE(ipslout,*) "<-flioputv"
    21342134  ENDIF
    21352135!----------------------
     
    22382238!-
    22392239  IF (l_dbg) THEN
    2240     WRITE(*,*) "->flioputa ",TRIM(v_n)," ",TRIM(a_n)
     2240    WRITE(ipslout,*) "->flioputa ",TRIM(v_n)," ",TRIM(a_n)
    22412241  ENDIF
    22422242!-
     
    22702270!-
    22712271  IF (l_dbg) THEN
    2272     WRITE(*,*) "<-flioputa"
     2272    WRITE(ipslout,*) "<-flioputa"
    22732273  ENDIF
    22742274!----------------------
     
    22912291!-
    22922292  IF (l_dbg) THEN
    2293     WRITE(*,*) '->flioopfd, file name : ',TRIM(f_n)
     2293    WRITE(ipslout,*) '->flioopfd, file name : ',TRIM(f_n)
    22942294  ENDIF
    22952295!-
     
    23252325!-
    23262326  IF (l_dbg) THEN
    2327     WRITE(*,*) '  flioopfd, model file-id : ',f_e
     2327    WRITE(ipslout,*) '  flioopfd, model file-id : ',f_e
    23282328  ENDIF
    23292329!-
     
    23502350!-
    23512351  IF (l_dbg) THEN
    2352     WRITE(*,'("   flioopfd - dimensions :",/,(5(1X,I10),:))') &
     2352    WRITE(ipslout,'("   flioopfd - dimensions :",/,(5(1X,I10),:))') &
    23532353 &    nw_dl(:,f_i)
    2354     WRITE(*,*) "<-flioopfd"
     2354    WRITE(ipslout,*) "<-flioopfd"
    23552355  ENDIF
    23562356!----------------------
     
    23732373!-
    23742374  IF (l_dbg) THEN
    2375     WRITE(*,*) "->flioinqf"
     2375    WRITE(ipslout,*) "->flioinqf"
    23762376  ENDIF
    23772377!-
     
    24182418!-
    24192419  IF (l_dbg) THEN
    2420     WRITE(*,*) "<-flioinqf"
     2420    WRITE(ipslout,*) "<-flioinqf"
    24212421  ENDIF
    24222422!----------------------
     
    24452445!-
    24462446  IF (l_dbg) THEN
    2447     WRITE(*,*) "->flioinqn"
     2447    WRITE(ipslout,*) "->flioinqn"
    24482448  ENDIF
    24492449!-
     
    26222622!-
    26232623  IF (l_dbg) THEN
    2624     WRITE(*,*) "<-flioinqn"
     2624    WRITE(ipslout,*) "<-flioinqn"
    26252625  ENDIF
    26262626!----------------------
     
    26622662!-
    26632663  IF (l_dbg) THEN
    2664     WRITE(*,*) "->fliogstc"
     2664    WRITE(ipslout,*) "->fliogstc"
    26652665  ENDIF
    26662666!-
     
    27022702!-
    27032703  IF (l_dbg) THEN
    2704     WRITE(*,'("   fliogstc - dimensions :",/,(5(1X,I10),:))') &
     2704    WRITE(ipslout,'("   fliogstc - dimensions :",/,(5(1X,I10),:))') &
    27052705 &    m_x,m_y,m_z,m_t
    27062706  ENDIF
     
    29322932!---
    29332933    IF (l_dbg) THEN
    2934       WRITE(*,*) '  fliogstc - get time details'
     2934      WRITE(ipslout,*) '  fliogstc - get time details'
    29352935    ENDIF
    29362936!---
     
    29772977!---
    29782978    IF (l_dbg) THEN
    2979       WRITE(*,*) '  fliogstc - first time : ',t_axis(1:1)
     2979      WRITE(ipslout,*) '  fliogstc - first time : ',t_axis(1:1)
    29802980    ENDIF
    29812981  ENDIF
     
    30153015    CALL lock_calendar (new_status=l_tmp)
    30163016    IF (l_dbg) THEN
    3017       WRITE(*,*) '  fliogstc - time_type : '
    3018       WRITE(*,*) it_t
    3019       WRITE(*,*) '  fliogstc - year month day second t_init : '
    3020       WRITE(*,*) j_yy,j_mo,j_dd,r_ss,t_init
     3017      WRITE(ipslout,*) '  fliogstc - time_type : '
     3018      WRITE(ipslout,*) it_t
     3019      WRITE(ipslout,*) '  fliogstc - year month day second t_init : '
     3020      WRITE(ipslout,*) j_yy,j_mo,j_dd,r_ss,t_init
    30213021    ENDIF
    30223022  ENDIF
     
    30803080!-
    30813081  IF (l_dbg) THEN
    3082     WRITE(*,*) "<-fliogstc"
     3082    WRITE(ipslout,*) "<-fliogstc"
    30833083  ENDIF
    30843084!----------------------
     
    31083108!-
    31093109  IF (l_dbg) THEN
    3110     WRITE(*,*) "->flioinqv ",TRIM(v_n)
     3110    WRITE(ipslout,*) "->flioinqv ",TRIM(v_n)
    31113111  ENDIF
    31123112!-
     
    32213221!-
    32223222  IF (l_dbg) THEN
    3223     WRITE(*,*) "<-flioinqv"
     3223    WRITE(ipslout,*) "<-flioinqv"
    32243224  ENDIF
    32253225!----------------------
     
    37023702    ELSE IF (PRESENT(r_85)) THEN; cvr_d = "R8 5D";
    37033703    ENDIF
    3704     WRITE(*,*) "->fliogetv ",TRIM(v_n)," ",TRIM(cvr_d)
     3704    WRITE(ipslout,*) "->fliogetv ",TRIM(v_n)," ",TRIM(cvr_d)
    37053705  ENDIF
    37063706!-
     
    37853785!-
    37863786  IF (l_dbg) THEN
    3787     WRITE(*,*) "<-fliogetv"
     3787    WRITE(ipslout,*) "<-fliogetv"
    37883788  ENDIF
    37893789!----------------------
     
    38063806!-
    38073807  IF (l_dbg) THEN
    3808     WRITE(*,*) "->flioinqa ",TRIM(v_n),"-",TRIM(a_n)
     3808    WRITE(ipslout,*) "->flioinqa ",TRIM(v_n),"-",TRIM(a_n)
    38093809  ENDIF
    38103810!-
     
    38363836!-
    38373837  IF (l_dbg) THEN
    3838     WRITE(*,*) "<-flioinqa"
     3838    WRITE(ipslout,*) "<-flioinqa"
    38393839  ENDIF
    38403840!----------------------
     
    39483948!-
    39493949  IF (l_dbg) THEN
    3950     WRITE(*,*) "->fliogeta ",TRIM(v_n)," ",TRIM(a_n)
     3950    WRITE(ipslout,*) "->fliogeta ",TRIM(v_n)," ",TRIM(a_n)
    39513951  ENDIF
    39523952!-
     
    40124012!-
    40134013  IF (l_dbg) THEN
    4014     WRITE(*,*) "<-fliogeta"
     4014    WRITE(ipslout,*) "<-fliogeta"
    40154015  ENDIF
    40164016!----------------------
     
    40314031!-
    40324032  IF (l_dbg) THEN
    4033     WRITE(*,*) &
     4033    WRITE(ipslout,*) &
    40344034 &    "->fliorenv ",TRIM(v_o_n),"->",TRIM(v_n_n)
    40354035  ENDIF
     
    40524052!-
    40534053  IF (l_dbg) THEN
    4054     WRITE(*,*) "<-fliorenv"
     4054    WRITE(ipslout,*) "<-fliorenv"
    40554055  ENDIF
    40564056!----------------------
     
    40714071!-
    40724072  IF (l_dbg) THEN
    4073     WRITE(*,*) &
     4073    WRITE(ipslout,*) &
    40744074 &    "->fliorena ",TRIM(v_n),"-",TRIM(a_o_n),"->",TRIM(a_n_n)
    40754075  ENDIF
     
    41024102!-
    41034103  IF (l_dbg) THEN
    4104     WRITE(*,*) "<-fliorena"
     4104    WRITE(ipslout,*) "<-fliorena"
    41054105  ENDIF
    41064106!----------------------
     
    41214121!-
    41224122  IF (l_dbg) THEN
    4123     WRITE(*,*) "->fliodela ",TRIM(v_n),"-",TRIM(a_n)
     4123    WRITE(ipslout,*) "->fliodela ",TRIM(v_n),"-",TRIM(a_n)
    41244124  ENDIF
    41254125!-
     
    41504150!-
    41514151  IF (l_dbg) THEN
    4152     WRITE(*,*) "<-fliodela"
     4152    WRITE(ipslout,*) "<-fliodela"
    41534153  ENDIF
    41544154!----------------------
     
    41694169!-
    41704170  IF (l_dbg) THEN
    4171     WRITE(*,*) "->fliocpya - file",f_i_i,"-",TRIM(v_n_i),"-",TRIM(a_n)
    4172     WRITE(*,*) "  copied to file ",f_i_o,"-",TRIM(v_n_o)
     4171    WRITE(ipslout,*) "->fliocpya - file",f_i_i,"-",TRIM(v_n_i),"-",TRIM(a_n)
     4172    WRITE(ipslout,*) "  copied to file ",f_i_o,"-",TRIM(v_n_o)
    41734173  ENDIF
    41744174!-
     
    42164216!-
    42174217  IF (l_dbg) THEN
    4218     WRITE(*,*) "<-fliocpya"
     4218    WRITE(ipslout,*) "<-fliocpya"
    42194219  ENDIF
    42204220!----------------------
     
    42384238!-
    42394239  IF (l_dbg) THEN
    4240     WRITE(*,*) "->flioqstc ",TRIM(c_type)
     4240    WRITE(ipslout,*) "->flioqstc ",TRIM(c_type)
    42414241  ENDIF
    42424242!-
     
    42604260!-
    42614261  IF (l_dbg) THEN
    4262     WRITE(*,*) "<-flioqstc"
     4262    WRITE(ipslout,*) "<-flioqstc"
    42634263  ENDIF
    42644264!----------------------
     
    42764276!-
    42774277  IF (l_dbg) THEN
    4278     WRITE(*,*) "->fliosync"
     4278    WRITE(ipslout,*) "->fliosync"
    42794279  ENDIF
    42804280!-
     
    43024302    IF (f_e > 0) THEN
    43034303      IF (l_dbg) THEN
    4304         WRITE(*,*) '  fliosync - synchronising file number ',i_f
     4304        WRITE(ipslout,*) '  fliosync - synchronising file number ',i_f
    43054305      ENDIF
    43064306      i_rc = NF90_SYNC(f_e)
     
    43124312!-
    43134313  IF (l_dbg) THEN
    4314     WRITE(*,*) "<-fliosync"
     4314    WRITE(ipslout,*) "<-fliosync"
    43154315  ENDIF
    43164316!----------------------
     
    43284328!-
    43294329  IF (l_dbg) THEN
    4330     WRITE(*,*) "->flioclo"
     4330    WRITE(ipslout,*) "->flioclo"
    43314331  ENDIF
    43324332!-
     
    43504350    IF (f_e > 0) THEN
    43514351      IF (l_dbg) THEN
    4352         WRITE(*,*) '  flioclo - closing file number ',i_f
     4352        WRITE(ipslout,*) '  flioclo - closing file number ',i_f
    43534353      ENDIF
    43544354      i_rc = NF90_CLOSE(f_e)
     4355!- error case added : explicit the message and stop with a fatal error
     4356      IF (i_rc /= NF90_NOERR) THEN
     4357        CALL ipslerr (3,'flioclo', &
     4358 &       'Could not close file','Try again and contact your local administrator ', &
     4359 &       TRIM(NF90_STRERROR(i_rc))//' (Netcdf)')
     4360      ENDIF
    43554361      nw_id(i_f) = -1
    43564362    ELSE IF (PRESENT(f_i)) THEN
     
    43614367!-
    43624368  IF (l_dbg) THEN
    4363     WRITE(*,*) "<-flioclo"
     4369    WRITE(ipslout,*) "<-flioclo"
    43644370  ENDIF
    43654371!---------------------
     
    43924398  ENDIF
    43934399!-
    4394   WRITE (*,*) "---"
    4395   WRITE (*,*) "--- File '",TRIM(f_n),"'"
    4396   WRITE (*,*) "---"
     4400  WRITE (ipslout,*) "---"
     4401  WRITE (ipslout,*) "--- File '",TRIM(f_n),"'"
     4402  WRITE (ipslout,*) "---"
    43974403!-
    43984404  CALL flio_inf &
     
    44014407 &       nn_idm=n_idim,nn_ldm=n_ldim,cc_ndm=c_ndim,nn_aid=n_ai)
    44024408!-
    4403   WRITE (*,*) 'External model identifier   : ',f_e
    4404   WRITE (*,*) 'Number of dimensions        : ',n_dims
    4405   WRITE (*,*) 'Number of variables         : ',n_vars
    4406   WRITE (*,*) 'ID unlimited                : ',i_unlm
    4407 !-
    4408   WRITE (*,*) "---"
    4409   WRITE (*,*) 'Presumed axis dimensions identifiers :'
     4409  WRITE (ipslout,*) 'External model identifier   : ',f_e
     4410  WRITE (ipslout,*) 'Number of dimensions        : ',n_dims
     4411  WRITE (ipslout,*) 'Number of variables         : ',n_vars
     4412  WRITE (ipslout,*) 'ID unlimited                : ',i_unlm
     4413!-
     4414  WRITE (ipslout,*) "---"
     4415  WRITE (ipslout,*) 'Presumed axis dimensions identifiers :'
    44104416  IF (n_ai(k_lon) > 0) THEN
    4411     WRITE (*,*) 'x axis : ',n_ai(k_lon)
     4417    WRITE (ipslout,*) 'x axis : ',n_ai(k_lon)
    44124418  ELSE
    4413     WRITE (*,*) 'x axis : NONE'
     4419    WRITE (ipslout,*) 'x axis : NONE'
    44144420  ENDIF
    44154421  IF (n_ai(k_lat) > 0) THEN
    4416     WRITE (*,*) 'y axis : ',n_ai(k_lat)
     4422    WRITE (ipslout,*) 'y axis : ',n_ai(k_lat)
    44174423  ELSE
    4418     WRITE (*,*) 'y axis : NONE'
     4424    WRITE (ipslout,*) 'y axis : NONE'
    44194425  ENDIF
    44204426  IF (n_ai(k_lev) > 0) THEN
    4421     WRITE (*,*) 'z axis : ',n_ai(k_lev)
     4427    WRITE (ipslout,*) 'z axis : ',n_ai(k_lev)
    44224428  ELSE
    4423     WRITE (*,*) 'z axis : NONE'
     4429    WRITE (ipslout,*) 'z axis : NONE'
    44244430  ENDIF
    44254431  IF (n_ai(k_tim) > 0) THEN
    4426     WRITE (*,*) 't axis : ',n_ai(k_tim)
     4432    WRITE (ipslout,*) 't axis : ',n_ai(k_tim)
    44274433  ELSE
    4428     WRITE (*,*) 't axis : NONE'
    4429   ENDIF
    4430 !-
    4431   WRITE (*,*) "---"
    4432   WRITE (*,*) 'Number of global attributes : ',n_atts
     4434    WRITE (ipslout,*) 't axis : NONE'
     4435  ENDIF
     4436!-
     4437  WRITE (ipslout,*) "---"
     4438  WRITE (ipslout,*) 'Number of global attributes : ',n_atts
    44334439  DO k_n=1,n_atts
    44344440    i_rc = NF90_INQ_ATTNAME(f_e,NF90_GLOBAL,k_n,c_name)
     
    44404446        ALLOCATE(tma_i(l_ea))
    44414447        i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,c_name,tma_i)
    4442         WRITE (*,'("    ",A," :",/,(5(1X,I10),:))') &
     4448        WRITE (ipslout,'("    ",A," :",/,(5(1X,I10),:))') &
    44434449 &        TRIM(c_name),tma_i(1:l_ea)
    44444450        DEALLOCATE(tma_i)
    44454451      ELSE
    44464452        i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,c_name,tmp_i)
    4447         WRITE(*,*) '   ',TRIM(c_name),' : ',tmp_i
     4453        WRITE(ipslout,*) '   ',TRIM(c_name),' : ',tmp_i
    44484454      ENDIF
    44494455    ELSE IF ( (t_ea == NF90_REAL4).OR.(t_ea == NF90_REAL8) ) THEN
     
    44514457        ALLOCATE(tma_r(l_ea))
    44524458        i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,c_name,tma_r)
    4453         WRITE (*,'("    ",A," :",/,(5(1X,1PE11.3),:))') &
     4459        WRITE (ipslout,'("    ",A," :",/,(5(1X,1PE11.3),:))') &
    44544460 &        TRIM(c_name),tma_r(1:l_ea)
    44554461        DEALLOCATE(tma_r)
    44564462      ELSE
    44574463        i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,c_name,tmp_r)
    4458         WRITE(*,*) '   ',TRIM(c_name),' : ',tmp_r
     4464        WRITE(ipslout,*) '   ',TRIM(c_name),' : ',tmp_r
    44594465      ENDIF
    44604466    ELSE
    44614467      tmp_c = ''
    44624468      i_rc = NF90_GET_ATT(f_e,NF90_GLOBAL,c_name,tmp_c)
    4463       WRITE(*,*) '   ',TRIM(c_name),' : "',TRIM(tmp_c),'"'
     4469      WRITE(ipslout,*) '   ',TRIM(c_name),' : "',TRIM(tmp_c),'"'
    44644470    ENDIF
    44654471  ENDDO
     
    44674473  DO i_n=1,nb_fd_mx
    44684474    IF (n_idim(i_n) > 0) THEN
    4469       WRITE (*,*) "---"
    4470       WRITE (*,*) 'Dimension id   : ',n_idim(i_n)
    4471       WRITE (*,*) 'Dimension name : ',TRIM(c_ndim(i_n))
    4472       WRITE (*,*) 'Dimension size : ',n_ldim(i_n)
     4475      WRITE (ipslout,*) "---"
     4476      WRITE (ipslout,*) 'Dimension id   : ',n_idim(i_n)
     4477      WRITE (ipslout,*) 'Dimension name : ',TRIM(c_ndim(i_n))
     4478      WRITE (ipslout,*) 'Dimension size : ',n_ldim(i_n)
    44734479    ENDIF
    44744480  ENDDO
     
    44774483    i_rc = NF90_INQUIRE_VARIABLE(f_e,i_n, &
    44784484 &           name=c_name,ndims=n_dims,dimids=idimid,nAtts=n_atts)
    4479     WRITE (*,*) "---"
    4480     WRITE (*,*) "Variable name        : ",TRIM(c_name)
    4481     WRITE (*,*) "Variable identifier  : ",i_n
    4482     WRITE (*,*) "Number of dimensions : ",n_dims
     4485    WRITE (ipslout,*) "---"
     4486    WRITE (ipslout,*) "Variable name        : ",TRIM(c_name)
     4487    WRITE (ipslout,*) "Variable identifier  : ",i_n
     4488    WRITE (ipslout,*) "Number of dimensions : ",n_dims
    44834489    IF (n_dims > 0) THEN
    4484       WRITE (*,*) "Dimensions ID's      : ",idimid(1:n_dims)
    4485     ENDIF
    4486     WRITE (*,*) "Number of attributes : ",n_atts
     4490      WRITE (ipslout,*) "Dimensions ID's      : ",idimid(1:n_dims)
     4491    ENDIF
     4492    WRITE (ipslout,*) "Number of attributes : ",n_atts
    44874493    DO k_n=1,n_atts
    44884494      i_rc = NF90_INQ_ATTNAME(f_e,i_n,k_n,c_name)
     
    44944500          ALLOCATE(tma_i(l_ea))
    44954501          i_rc = NF90_GET_ATT(f_e,i_n,c_name,tma_i)
    4496           WRITE (*,'("    ",A," :",/,(5(1X,I10),:))') &
     4502          WRITE (ipslout,'("    ",A," :",/,(5(1X,I10),:))') &
    44974503 &              TRIM(c_name),tma_i(1:l_ea)
    44984504          DEALLOCATE(tma_i)
    44994505        ELSE
    45004506          i_rc = NF90_GET_ATT(f_e,i_n,c_name,tmp_i)
    4501           WRITE(*,*) '   ',TRIM(c_name),' : ',tmp_i
     4507          WRITE(ipslout,*) '   ',TRIM(c_name),' : ',tmp_i
    45024508        ENDIF
    45034509      ELSE IF ( (t_ea == NF90_REAL4).OR.(t_ea == NF90_REAL8) ) THEN
     
    45054511          ALLOCATE(tma_r(l_ea))
    45064512          i_rc = NF90_GET_ATT(f_e,i_n,c_name,tma_r)
    4507           WRITE (*,'("    ",A," :",/,(5(1X,1PE11.3),:))') &
     4513          WRITE (ipslout,'("    ",A," :",/,(5(1X,1PE11.3),:))') &
    45084514 &          TRIM(c_name),tma_r(1:l_ea)
    45094515          DEALLOCATE(tma_r)
    45104516        ELSE
    45114517          i_rc = NF90_GET_ATT(f_e,i_n,c_name,tmp_r)
    4512           WRITE(*,*) '   ',TRIM(c_name),' : ',tmp_r
     4518          WRITE(ipslout,*) '   ',TRIM(c_name),' : ',tmp_r
    45134519        ENDIF
    45144520      ELSE
    45154521        tmp_c = ''
    45164522        i_rc = NF90_GET_ATT(f_e,i_n,c_name,tmp_c)
    4517         WRITE(*,*) '   ',TRIM(c_name),' : "',TRIM(tmp_c),'"'
     4523        WRITE(ipslout,*) '   ',TRIM(c_name),' : "',TRIM(tmp_c),'"'
    45184524      ENDIF
    45194525    ENDDO
    45204526  ENDDO
    4521   WRITE (*,*) "---"
     4527  WRITE (ipslout,*) "---"
    45224528!-
    45234529  i_rc = NF90_CLOSE(f_e)
     
    49374943!-
    49384944  IF (l_dbg) THEN
    4939     WRITE(*,*) "->flio_inf"
     4945    WRITE(ipslout,*) "->flio_inf"
    49404946  ENDIF
    49414947!-
     
    49604966!---
    49614967    IF (l_dbg) THEN
    4962       WRITE(*,*) "  flio_inf ",kv,ml," ",TRIM(f_d_n)
     4968      WRITE(ipslout,*) "  flio_inf ",kv,ml," ",TRIM(f_d_n)
    49634969    ENDIF
    49644970!---
     
    50055011!-
    50065012  IF (l_dbg) THEN
    5007     WRITE(*,*) "<-flio_inf"
     5013    WRITE(ipslout,*) "<-flio_inf"
    50085014  ENDIF
    50095015!----------------------
  • dynamico_lmdz/aquaplanet/IOIPSL/src/getincom.f90

    r3847 r3907  
    11MODULE getincom
    22!-
    3 !$Id: getincom.f90 963 2010-03-31 15:26:11Z bellier $
     3!$Id: getincom.f90 1574 2011-11-10 08:21:23Z mmaipsl $
    44!-
    55! This software is governed by the CeCILL license
    66! See IOIPSL/IOIPSL_License_CeCILL.txt
    77!---------------------------------------------------------------------
    8 USE errioipsl, ONLY : ipslerr
     8USE errioipsl, ONLY : ipslerr,ipsldbg,ipslout
    99USE stringop, &
    1010 &   ONLY : nocomma,cmpblank,strlowercase
     
    1313!-
    1414PRIVATE
    15 PUBLIC :: getin_name, getin, getin_dump
     15PUBLIC :: getin_name, getin, getin_dump, getin_dump_para
    1616!-
    1717!!--------------------------------------------------------------------
     
    3535!! and if not we get it from the definition file.
    3636!!
    37 !! SUBROUTINE getin (target,ret_val)
     37!! SUBROUTINE getin (targetname,ret_val)
    3838!!
    3939!! INPUT
    4040!!
    41 !! (C) target : Name of the variable
     41!! (C) targetname : Name of the variable
    4242!!
    4343!! OUTPUT
     
    6767!!--------------------------------------------------------------------
    6868!-
     69!!------------------------------------------------------------------------
     70!! Parallel version of getin_dump : user must give a fileprefix and a rank.
     71!! It may be usefull to verify that only the root proc is reading the input
     72!! def files.
     73!!
     74!!  SUBROUTINE getin_dump_para (fileprefix,rank)
     75!!
     76!! INPUT argument
     77!!
     78!! (C) fileprefix : allows the user to change the name of the file
     79!!                  in which the data will be archived
     80!! (I) rank : the rank of the parallel process (only 0-999 files will be created)
     81!!--------------------------------------------------------------------
     82!-
    6983  INTEGER,PARAMETER :: max_files=100
    7084  CHARACTER(LEN=100),DIMENSION(max_files),SAVE :: filelist
     
    98112! keystatus = 2 : Default value is used
    99113! keystatus = 3 : Some vector elements were taken from default
     114  INTEGER,PARAMETER :: nondefault=1, default=2, vectornondefault=3
    100115!-
    101116! keytype definition
     
    150165!=== INTEGER INTERFACE
    151166!-
    152 SUBROUTINE getinis (target,ret_val)
    153 !---------------------------------------------------------------------
    154   IMPLICIT NONE
    155 !-
    156   CHARACTER(LEN=*) :: target
     167SUBROUTINE getinis (targetname,ret_val)
     168!---------------------------------------------------------------------
     169  IMPLICIT NONE
     170!-
     171  CHARACTER(LEN=*) :: targetname
    157172  INTEGER :: ret_val
    158173!-
    159174  INTEGER,DIMENSION(1) :: tmp_ret_val
    160   INTEGER :: pos,status=0,fileorig
    161 !---------------------------------------------------------------------
    162 !-
    163 ! Do we have this target in our database ?
    164 !-
    165   CALL get_findkey (1,target,pos)
     175  INTEGER :: pos,status=0,fileorig, size_of_in
     176!---------------------------------------------------------------------
     177!-
     178! Do we have this targetname in our database ?
     179!-
     180  CALL get_findkey (1,targetname,pos)
    166181!-
    167182  tmp_ret_val(1) = ret_val
     183  size_of_in = SIZE(tmp_ret_val)
     184 
    168185!-
    169186  IF (pos < 0) THEN
    170187!-- Get the information out of the file
    171     CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
     188    CALL get_fil (targetname,status,fileorig,size_of_in,i_val=tmp_ret_val)
    172189!-- Put the data into the database
    173190    CALL get_wdb &
    174  &   (target,status,fileorig,1,i_val=tmp_ret_val)
     191 &   (targetname,status,fileorig,1,i_val=tmp_ret_val)
    175192  ELSE
    176193!-- Get the value out of the database
    177     CALL get_rdb (pos,1,target,i_val=tmp_ret_val)
     194    CALL get_rdb (pos,1,targetname,i_val=tmp_ret_val)
    178195  ENDIF
    179196  ret_val = tmp_ret_val(1)
     
    181198END SUBROUTINE getinis
    182199!===
    183 SUBROUTINE getini1d (target,ret_val)
    184 !---------------------------------------------------------------------
    185   IMPLICIT NONE
    186 !-
    187   CHARACTER(LEN=*) :: target
     200SUBROUTINE getini1d (targetname,ret_val)
     201!---------------------------------------------------------------------
     202  IMPLICIT NONE
     203!-
     204  CHARACTER(LEN=*) :: targetname
    188205  INTEGER,DIMENSION(:) :: ret_val
    189206!-
     
    193210!---------------------------------------------------------------------
    194211!-
    195 ! Do we have this target in our database ?
    196 !-
    197   CALL get_findkey (1,target,pos)
     212! Do we have this targetname in our database ?
     213!-
     214  CALL get_findkey (1,targetname,pos)
    198215!-
    199216  size_of_in = SIZE(ret_val)
     
    209226  IF (pos < 0) THEN
    210227!-- Get the information out of the file
    211     CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
     228    CALL get_fil (targetname,status,fileorig,size_of_in,i_val=tmp_ret_val)
    212229!-- Put the data into the database
    213230    CALL get_wdb &
    214  &   (target,status,fileorig,size_of_in,i_val=tmp_ret_val)
     231 &   (targetname,status,fileorig,size_of_in,i_val=tmp_ret_val)
    215232  ELSE
    216233!-- Get the value out of the database
    217     CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val)
     234    CALL get_rdb (pos,size_of_in,targetname,i_val=tmp_ret_val)
    218235  ENDIF
    219236  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
     
    221238END SUBROUTINE getini1d
    222239!===
    223 SUBROUTINE getini2d (target,ret_val)
    224 !---------------------------------------------------------------------
    225   IMPLICIT NONE
    226 !-
    227   CHARACTER(LEN=*) :: target
     240SUBROUTINE getini2d (targetname,ret_val)
     241!---------------------------------------------------------------------
     242  IMPLICIT NONE
     243!-
     244  CHARACTER(LEN=*) :: targetname
    228245  INTEGER,DIMENSION(:,:) :: ret_val
    229246!-
     
    234251!---------------------------------------------------------------------
    235252!-
    236 ! Do we have this target in our database ?
    237 !-
    238   CALL get_findkey (1,target,pos)
     253! Do we have this targetname in our database ?
     254!-
     255  CALL get_findkey (1,targetname,pos)
    239256!-
    240257  size_of_in = SIZE(ret_val)
     
    259276  IF (pos < 0) THEN
    260277!-- Get the information out of the file
    261     CALL get_fil (target,status,fileorig,i_val=tmp_ret_val)
     278    CALL get_fil (targetname,status,fileorig,size_of_in,i_val=tmp_ret_val)
    262279!-- Put the data into the database
    263280    CALL get_wdb &
    264  &   (target,status,fileorig,size_of_in,i_val=tmp_ret_val)
     281 &   (targetname,status,fileorig,size_of_in,i_val=tmp_ret_val)
    265282  ELSE
    266283!-- Get the value out of the database
    267     CALL get_rdb (pos,size_of_in,target,i_val=tmp_ret_val)
     284    CALL get_rdb (pos,size_of_in,targetname,i_val=tmp_ret_val)
    268285  ENDIF
    269286!-
     
    280297!=== REAL INTERFACE
    281298!-
    282 SUBROUTINE getinrs (target,ret_val)
    283 !---------------------------------------------------------------------
    284   IMPLICIT NONE
    285 !-
    286   CHARACTER(LEN=*) :: target
     299SUBROUTINE getinrs (targetname,ret_val)
     300!---------------------------------------------------------------------
     301  IMPLICIT NONE
     302!-
     303  CHARACTER(LEN=*) :: targetname
    287304  REAL :: ret_val
    288305!-
    289306  REAL,DIMENSION(1) :: tmp_ret_val
    290   INTEGER :: pos,status=0,fileorig
    291 !---------------------------------------------------------------------
    292 !-
    293 ! Do we have this target in our database ?
    294 !-
    295   CALL get_findkey (1,target,pos)
     307  INTEGER :: pos,status=0,fileorig, size_of_in
     308!---------------------------------------------------------------------
     309!-
     310! Do we have this targetname in our database ?
     311!-
     312  CALL get_findkey (1,targetname,pos)
    296313!-
    297314  tmp_ret_val(1) = ret_val
     315  size_of_in = SIZE(tmp_ret_val)
    298316!-
    299317  IF (pos < 0) THEN
    300318!-- Get the information out of the file
    301     CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
     319    CALL get_fil (targetname,status,fileorig,size_of_in,r_val=tmp_ret_val)
    302320!-- Put the data into the database
    303321    CALL get_wdb &
    304  &   (target,status,fileorig,1,r_val=tmp_ret_val)
     322 &   (targetname,status,fileorig,1,r_val=tmp_ret_val)
    305323  ELSE
    306324!-- Get the value out of the database
    307     CALL get_rdb (pos,1,target,r_val=tmp_ret_val)
     325    CALL get_rdb (pos,1,targetname,r_val=tmp_ret_val)
    308326  ENDIF
    309327  ret_val = tmp_ret_val(1)
     
    311329END SUBROUTINE getinrs
    312330!===
    313 SUBROUTINE getinr1d (target,ret_val)
    314 !---------------------------------------------------------------------
    315   IMPLICIT NONE
    316 !-
    317   CHARACTER(LEN=*) :: target
     331SUBROUTINE getinr1d (targetname,ret_val)
     332!---------------------------------------------------------------------
     333  IMPLICIT NONE
     334!-
     335  CHARACTER(LEN=*) :: targetname
    318336  REAL,DIMENSION(:) :: ret_val
    319337!-
     
    323341!---------------------------------------------------------------------
    324342!-
    325 ! Do we have this target in our database ?
    326 !-
    327   CALL get_findkey (1,target,pos)
     343! Do we have this targetname in our database ?
     344!-
     345  CALL get_findkey (1,targetname,pos)
    328346!-
    329347  size_of_in = SIZE(ret_val)
     
    339357  IF (pos < 0) THEN
    340358!-- Get the information out of the file
    341     CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
     359    CALL get_fil (targetname,status,fileorig,size_of_in,r_val=tmp_ret_val)
    342360!-- Put the data into the database
    343361    CALL get_wdb &
    344  &   (target,status,fileorig,size_of_in,r_val=tmp_ret_val)
     362 &   (targetname,status,fileorig,size_of_in,r_val=tmp_ret_val)
    345363  ELSE
    346364!-- Get the value out of the database
    347     CALL get_rdb (pos,size_of_in,target,r_val=tmp_ret_val)
     365    CALL get_rdb (pos,size_of_in,targetname,r_val=tmp_ret_val)
    348366  ENDIF
    349367  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
     
    351369END SUBROUTINE getinr1d
    352370!===
    353 SUBROUTINE getinr2d (target,ret_val)
    354 !---------------------------------------------------------------------
    355   IMPLICIT NONE
    356 !-
    357   CHARACTER(LEN=*) :: target
     371SUBROUTINE getinr2d (targetname,ret_val)
     372!---------------------------------------------------------------------
     373  IMPLICIT NONE
     374!-
     375  CHARACTER(LEN=*) :: targetname
    358376  REAL,DIMENSION(:,:) :: ret_val
    359377!-
     
    364382!---------------------------------------------------------------------
    365383!-
    366 ! Do we have this target in our database ?
    367 !-
    368   CALL get_findkey (1,target,pos)
     384! Do we have this targetname in our database ?
     385!-
     386  CALL get_findkey (1,targetname,pos)
    369387!-
    370388  size_of_in = SIZE(ret_val)
     
    389407  IF (pos < 0) THEN
    390408!-- Get the information out of the file
    391     CALL get_fil (target,status,fileorig,r_val=tmp_ret_val)
     409    CALL get_fil (targetname,status,fileorig,size_of_in,r_val=tmp_ret_val)
    392410!-- Put the data into the database
    393411    CALL get_wdb &
    394  &   (target,status,fileorig,size_of_in,r_val=tmp_ret_val)
     412 &   (targetname,status,fileorig,size_of_in,r_val=tmp_ret_val)
    395413  ELSE
    396414!-- Get the value out of the database
    397     CALL get_rdb (pos,size_of_in,target,r_val=tmp_ret_val)
     415    CALL get_rdb (pos,size_of_in,targetname,r_val=tmp_ret_val)
    398416  ENDIF
    399417!-
     
    410428!=== CHARACTER INTERFACE
    411429!-
    412 SUBROUTINE getincs (target,ret_val)
    413 !---------------------------------------------------------------------
    414   IMPLICIT NONE
    415 !-
    416   CHARACTER(LEN=*) :: target
     430SUBROUTINE getincs (targetname,ret_val)
     431!---------------------------------------------------------------------
     432  IMPLICIT NONE
     433!-
     434  CHARACTER(LEN=*) :: targetname
    417435  CHARACTER(LEN=*) :: ret_val
    418436!-
    419437  CHARACTER(LEN=100),DIMENSION(1) :: tmp_ret_val
    420   INTEGER :: pos,status=0,fileorig
    421 !---------------------------------------------------------------------
    422 !-
    423 ! Do we have this target in our database ?
    424 !-
    425   CALL get_findkey (1,target,pos)
     438  INTEGER :: pos,status=0,fileorig,size_of_in
     439!---------------------------------------------------------------------
     440!-
     441! Do we have this targetname in our database ?
     442!-
     443  CALL get_findkey (1,targetname,pos)
    426444!-
    427445  tmp_ret_val(1) = ret_val
     446  size_of_in = SIZE(tmp_ret_val)
    428447!-
    429448  IF (pos < 0) THEN
    430449!-- Get the information out of the file
    431     CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
     450    CALL get_fil (targetname,status,fileorig,size_of_in,c_val=tmp_ret_val)
    432451!-- Put the data into the database
    433452    CALL get_wdb &
    434  &   (target,status,fileorig,1,c_val=tmp_ret_val)
     453 &   (targetname,status,fileorig,1,c_val=tmp_ret_val)
    435454  ELSE
    436455!-- Get the value out of the database
    437     CALL get_rdb (pos,1,target,c_val=tmp_ret_val)
     456    CALL get_rdb (pos,1,targetname,c_val=tmp_ret_val)
    438457  ENDIF
    439458  ret_val = tmp_ret_val(1)
     
    441460END SUBROUTINE getincs
    442461!===
    443 SUBROUTINE getinc1d (target,ret_val)
    444 !---------------------------------------------------------------------
    445   IMPLICIT NONE
    446 !-
    447   CHARACTER(LEN=*) :: target
     462SUBROUTINE getinc1d (targetname,ret_val)
     463!---------------------------------------------------------------------
     464  IMPLICIT NONE
     465!-
     466  CHARACTER(LEN=*) :: targetname
    448467  CHARACTER(LEN=*),DIMENSION(:) :: ret_val
    449468!-
     
    453472!---------------------------------------------------------------------
    454473!-
    455 ! Do we have this target in our database ?
    456 !-
    457   CALL get_findkey (1,target,pos)
     474! Do we have this targetname in our database ?
     475!-
     476  CALL get_findkey (1,targetname,pos)
    458477!-
    459478  size_of_in = SIZE(ret_val)
     
    469488  IF (pos < 0) THEN
    470489!-- Get the information out of the file
    471     CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
     490    CALL get_fil (targetname,status,fileorig,size_of_in,c_val=tmp_ret_val)
    472491!-- Put the data into the database
    473492    CALL get_wdb &
    474  &   (target,status,fileorig,size_of_in,c_val=tmp_ret_val)
     493 &   (targetname,status,fileorig,size_of_in,c_val=tmp_ret_val)
    475494  ELSE
    476495!-- Get the value out of the database
    477     CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val)
     496    CALL get_rdb (pos,size_of_in,targetname,c_val=tmp_ret_val)
    478497  ENDIF
    479498  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
     
    481500END SUBROUTINE getinc1d
    482501!===
    483 SUBROUTINE getinc2d (target,ret_val)
    484 !---------------------------------------------------------------------
    485   IMPLICIT NONE
    486 !-
    487   CHARACTER(LEN=*) :: target
     502SUBROUTINE getinc2d (targetname,ret_val)
     503!---------------------------------------------------------------------
     504  IMPLICIT NONE
     505!-
     506  CHARACTER(LEN=*) :: targetname
    488507  CHARACTER(LEN=*),DIMENSION(:,:) :: ret_val
    489508!-
     
    494513!---------------------------------------------------------------------
    495514!-
    496 ! Do we have this target in our database ?
    497 !-
    498   CALL get_findkey (1,target,pos)
     515! Do we have this targetname in our database ?
     516!-
     517  CALL get_findkey (1,targetname,pos)
    499518!-
    500519  size_of_in = SIZE(ret_val)
     
    519538  IF (pos < 0) THEN
    520539!-- Get the information out of the file
    521     CALL get_fil (target,status,fileorig,c_val=tmp_ret_val)
     540    CALL get_fil (targetname,status,fileorig,size_of_in,c_val=tmp_ret_val)
    522541!-- Put the data into the database
    523542    CALL get_wdb &
    524  &   (target,status,fileorig,size_of_in,c_val=tmp_ret_val)
     543 &   (targetname,status,fileorig,size_of_in,c_val=tmp_ret_val)
    525544  ELSE
    526545!-- Get the value out of the database
    527     CALL get_rdb (pos,size_of_in,target,c_val=tmp_ret_val)
     546    CALL get_rdb (pos,size_of_in,targetname,c_val=tmp_ret_val)
    528547  ENDIF
    529548!-
     
    540559!=== LOGICAL INTERFACE
    541560!-
    542 SUBROUTINE getinls (target,ret_val)
    543 !---------------------------------------------------------------------
    544   IMPLICIT NONE
    545 !-
    546   CHARACTER(LEN=*) :: target
     561SUBROUTINE getinls (targetname,ret_val)
     562!---------------------------------------------------------------------
     563  IMPLICIT NONE
     564!-
     565  CHARACTER(LEN=*) :: targetname
    547566  LOGICAL :: ret_val
    548567!-
    549568  LOGICAL,DIMENSION(1) :: tmp_ret_val
    550   INTEGER :: pos,status=0,fileorig
    551 !---------------------------------------------------------------------
    552 !-
    553 ! Do we have this target in our database ?
    554 !-
    555   CALL get_findkey (1,target,pos)
     569  INTEGER :: pos,status=0,fileorig,size_of_in
     570!---------------------------------------------------------------------
     571!-
     572! Do we have this targetname in our database ?
     573!-
     574  CALL get_findkey (1,targetname,pos)
    556575!-
    557576  tmp_ret_val(1) = ret_val
     577  size_of_in = SIZE(tmp_ret_val)
    558578!-
    559579  IF (pos < 0) THEN
    560580!-- Get the information out of the file
    561     CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
     581    CALL get_fil (targetname,status,fileorig,size_of_in,l_val=tmp_ret_val)
    562582!-- Put the data into the database
    563583    CALL get_wdb &
    564  &   (target,status,fileorig,1,l_val=tmp_ret_val)
     584 &   (targetname,status,fileorig,1,l_val=tmp_ret_val)
    565585  ELSE
    566586!-- Get the value out of the database
    567     CALL get_rdb (pos,1,target,l_val=tmp_ret_val)
     587    CALL get_rdb (pos,1,targetname,l_val=tmp_ret_val)
    568588  ENDIF
    569589  ret_val = tmp_ret_val(1)
     
    571591END SUBROUTINE getinls
    572592!===
    573 SUBROUTINE getinl1d (target,ret_val)
    574 !---------------------------------------------------------------------
    575   IMPLICIT NONE
    576 !-
    577   CHARACTER(LEN=*) :: target
     593SUBROUTINE getinl1d (targetname,ret_val)
     594!---------------------------------------------------------------------
     595  IMPLICIT NONE
     596!-
     597  CHARACTER(LEN=*) :: targetname
    578598  LOGICAL,DIMENSION(:) :: ret_val
    579599!-
     
    583603!---------------------------------------------------------------------
    584604!-
    585 ! Do we have this target in our database ?
    586 !-
    587   CALL get_findkey (1,target,pos)
     605! Do we have this targetname in our database ?
     606!-
     607  CALL get_findkey (1,targetname,pos)
    588608!-
    589609  size_of_in = SIZE(ret_val)
     
    599619  IF (pos < 0) THEN
    600620!-- Get the information out of the file
    601     CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
     621    CALL get_fil (targetname,status,fileorig,size_of_in,l_val=tmp_ret_val)
    602622!-- Put the data into the database
    603623    CALL get_wdb &
    604  &   (target,status,fileorig,size_of_in,l_val=tmp_ret_val)
     624 &   (targetname,status,fileorig,size_of_in,l_val=tmp_ret_val)
    605625  ELSE
    606626!-- Get the value out of the database
    607     CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val)
     627    CALL get_rdb (pos,size_of_in,targetname,l_val=tmp_ret_val)
    608628  ENDIF
    609629  ret_val(1:size_of_in) = tmp_ret_val(1:size_of_in)
     
    611631END SUBROUTINE getinl1d
    612632!===
    613 SUBROUTINE getinl2d (target,ret_val)
    614 !---------------------------------------------------------------------
    615   IMPLICIT NONE
    616 !-
    617   CHARACTER(LEN=*) :: target
     633SUBROUTINE getinl2d (targetname,ret_val)
     634!---------------------------------------------------------------------
     635  IMPLICIT NONE
     636!-
     637  CHARACTER(LEN=*) :: targetname
    618638  LOGICAL,DIMENSION(:,:) :: ret_val
    619639!-
     
    624644!---------------------------------------------------------------------
    625645!-
    626 ! Do we have this target in our database ?
    627 !-
    628   CALL get_findkey (1,target,pos)
     646! Do we have this targetname in our database ?
     647!-
     648  CALL get_findkey (1,targetname,pos)
    629649!-
    630650  size_of_in = SIZE(ret_val)
     
    649669  IF (pos < 0) THEN
    650670!-- Get the information out of the file
    651     CALL get_fil (target,status,fileorig,l_val=tmp_ret_val)
     671    CALL get_fil (targetname,status,fileorig,size_of_in,l_val=tmp_ret_val)
    652672!-- Put the data into the database
    653673    CALL get_wdb &
    654  &   (target,status,fileorig,size_of_in,l_val=tmp_ret_val)
     674 &   (targetname,status,fileorig,size_of_in,l_val=tmp_ret_val)
    655675  ELSE
    656676!-- Get the value out of the database
    657     CALL get_rdb (pos,size_of_in,target,l_val=tmp_ret_val)
     677    CALL get_rdb (pos,size_of_in,targetname,l_val=tmp_ret_val)
    658678  ENDIF
    659679!-
     
    670690!=== Generic file/database INTERFACE
    671691!-
    672 SUBROUTINE get_fil (target,status,fileorig,i_val,r_val,c_val,l_val)
     692SUBROUTINE get_fil (targetname,status,fileorig,nb_to_ret,i_val,r_val,c_val,l_val)
    673693!---------------------------------------------------------------------
    674694!- Subroutine that will extract from the file the values
    675 !- attributed to the keyword target
    676 !-
    677 !- (C) target    : target for which we will look in the file
     695!- attributed to the keyword targetname
     696!-
     697!- (C) targetname    : target for which we will look in the file
    678698!- (I) status    : tells us from where we obtained the data
    679699!- (I) fileorig  : index of the file from which the key comes
     700!- (I) nb_to_ret : size of output vector
    680701!- (I) i_val(:)  : INTEGER(nb_to_ret)   values
    681702!- (R) r_val(:)  : REAL(nb_to_ret)      values
     
    685706  IMPLICIT NONE
    686707!-
    687   CHARACTER(LEN=*) :: target
     708  CHARACTER(LEN=*) :: targetname
     709  INTEGER,INTENT(IN) :: nb_to_ret
    688710  INTEGER,INTENT(OUT) :: status,fileorig
    689711  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
     
    692714  CHARACTER(LEN=*),DIMENSION(:),OPTIONAL :: c_val
    693715!-
    694   INTEGER :: k_typ,nb_to_ret,it,pos,len_str,status_cnt,io_err
     716  INTEGER :: k_typ,it,pos,len_str,status_cnt,io_err
    695717  CHARACTER(LEN=n_d_fmt)  :: cnt
    696718  CHARACTER(LEN=80) :: str_READ,str_READ_lower
     
    702724  REAL    :: r_cmpval
    703725  INTEGER :: ipos_tr,ipos_fl
     726  LOGICAL :: l_dbg
     727!---------------------------------------------------------------------
     728  CALL ipsldbg (old_status=l_dbg)
    704729!---------------------------------------------------------------------
    705730!-
    706731! Get the type of the argument
    707732  CALL get_qtyp (k_typ,c_vtyp,i_val,r_val,c_val,l_val)
    708   SELECT CASE (k_typ)
    709   CASE(k_i)
    710     nb_to_ret = SIZE(i_val)
    711   CASE(k_r)
    712     nb_to_ret = SIZE(r_val)
    713   CASE(k_c)
    714     nb_to_ret = SIZE(c_val)
    715   CASE(k_l)
    716     nb_to_ret = SIZE(l_val)
    717   CASE DEFAULT
     733  IF ( (k_typ.NE.k_i) .AND. (k_typ.NE.k_r) .AND. (k_typ.NE.k_c) .AND. (k_typ.NE.k_l) ) THEN
    718734    CALL ipslerr (3,'get_fil', &
    719735 &   'Internal error','Unknown type of data',' ')
    720   END SELECT
     736  ENDIF
    721737!-
    722738! Read the file(s)
     
    728744!-
    729745! See what we find in the files read
     746!---
     747!-- We dont know from which file the target could come.
     748!-- Thus by default we attribute it to the first file :
     749  fileorig = 1
     750!-
    730751  DO it=1,nb_to_ret
    731752!---
    732753!-- First try the target as it is
    733     CALL get_findkey (2,target,pos)
     754    CALL get_findkey (2,targetname,pos)
    734755!---
    735756!-- Another try
     
    737758    IF (pos < 0) THEN
    738759      WRITE(UNIT=cnt,FMT=c_i_fmt) it
    739       CALL get_findkey (2,TRIM(target)//'__'//cnt,pos)
    740     ENDIF
    741 !---
    742 !-- We dont know from which file the target could come.
    743 !-- Thus by default we attribute it to the first file :
    744     fileorig = 1
     760      CALL get_findkey (2,TRIM(targetname)//'__'//cnt,pos)
     761    ENDIF
    745762!---
    746763    IF (pos > 0) THEN
     
    748765      found(it) = .TRUE.
    749766      fileorig = fromfile(pos)
     767      !
     768      IF (l_dbg) THEN
     769         WRITE(*,*) &
     770              &      'getin_fil : read key ',targetname,' from file ',fileorig,' has type ',k_typ
     771      ENDIF
    750772!-----
    751773!---- DECODE
     
    754776      str_READ_lower = str_READ
    755777      CALL strlowercase (str_READ_lower)
     778      IF (l_dbg) THEN
     779         WRITE(*,*) &
     780              &      '            value    ',str_READ_lower
     781      ENDIF
    756782!-----
    757783      IF (    (TRIM(str_READ_lower) == 'def')     &
     
    789815        IF (io_err /= 0) THEN
    790816          CALL ipslerr (3,'get_fil', &
    791  &         'Target '//TRIM(target), &
     817 &         'Target '//TRIM(targetname), &
    792818 &         'is not of '//TRIM(c_vtyp)//' type',' ')
    793819        ENDIF
     
    801827          IF (compline(pos) /= nb_to_ret) THEN
    802828            CALL ipslerr (2,'get_fil', &
    803  &           'For key '//TRIM(target)//' we have a compressed field', &
     829 &           'For key '//TRIM(targetname)//' we have a compressed field', &
    804830 &           'which does not have the right size.', &
    805831 &           'We will try to fix that.')
     
    828854            i_val(it) = i_cmpval
    829855          ELSE IF (k_typ == k_r) THEN
     856            r_val(it) = r_cmpval
    830857          ENDIF
    831858          found(it) = .TRUE.
     
    837864! Now we set the status for what we found
    838865  IF (def_beha) THEN
    839     status = 2
    840     WRITE(*,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(target)
     866    status = default
     867    CALL ipslerr (1,'USING DEFAULT BEHAVIOUR FOR', &
     868 &   TRIM(targetname),' ',' ')
     869    WRITE(ipslout,*) 'USING DEFAULT BEHAVIOUR FOR ',TRIM(targetname)
    841870  ELSE
    842871    status_cnt = 0
     
    845874        status_cnt = status_cnt+1
    846875        IF      (status_cnt <= max_msgs) THEN
    847           WRITE (UNIT=*,FMT='(" USING DEFAULTS : ",A)', &
    848  &               ADVANCE='NO') TRIM(target)
     876          WRITE (UNIT=ipslout,FMT='(" USING DEFAULTS : ",A)', &
     877 &               ADVANCE='NO') TRIM(targetname)
    849878          IF (nb_to_ret > 1) THEN
    850             WRITE (UNIT=*,FMT='("__")',ADVANCE='NO')
    851             WRITE (UNIT=*,FMT=c_i_fmt,ADVANCE='NO') it
     879            WRITE (UNIT=ipslout,FMT='("__")',ADVANCE='NO')
     880            WRITE (UNIT=ipslout,FMT=c_i_fmt,ADVANCE='NO') it
    852881          ENDIF
    853882          SELECT CASE (k_typ)
    854883          CASE(k_i)
    855             WRITE (UNIT=*,FMT=*) "=",i_val(it)
     884            WRITE (UNIT=ipslout,FMT=*) "=",i_val(it)
    856885          CASE(k_r)
    857             WRITE (UNIT=*,FMT=*) "=",r_val(it)
     886            WRITE (UNIT=ipslout,FMT=*) "=",r_val(it)
    858887          CASE(k_c)
    859             WRITE (UNIT=*,FMT=*) "=",c_val(it)
     888            WRITE (UNIT=ipslout,FMT=*) "=",c_val(it)
    860889          CASE(k_l)
    861             WRITE (UNIT=*,FMT=*) "=",l_val(it)
     890            WRITE (UNIT=ipslout,FMT=*) "=",l_val(it)
    862891          END SELECT
    863892        ELSE IF (status_cnt == max_msgs+1) THEN
    864           WRITE (UNIT=*,FMT='(" USING DEFAULTS ... ",A)')
     893          WRITE (UNIT=ipslout,FMT='(" USING DEFAULTS ... ",A)')
    865894        ENDIF
    866895      ENDIF
     
    868897!---
    869898    IF (status_cnt == 0) THEN
    870       status = 1
     899      status = nondefault
    871900    ELSE IF (status_cnt == nb_to_ret) THEN
    872       status = 2
     901      status = default
    873902    ELSE
    874       status = 3
     903      status = vectornondefault
    875904    ENDIF
    876905  ENDIF
     
    880909END SUBROUTINE get_fil
    881910!===
    882 SUBROUTINE get_rdb (pos,size_of_in,target,i_val,r_val,c_val,l_val)
     911SUBROUTINE get_rdb (pos,size_of_in,targetname,i_val,r_val,c_val,l_val)
    883912!---------------------------------------------------------------------
    884913!- Read the required variable in the database
     
    887916!-
    888917  INTEGER :: pos,size_of_in
    889   CHARACTER(LEN=*) :: target
     918  CHARACTER(LEN=*) :: targetname
    890919  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
    891920  REAL,DIMENSION(:),OPTIONAL             :: r_val
     
    907936  IF (key_tab(pos)%keytype /= k_typ) THEN
    908937    CALL ipslerr (3,'get_rdb', &
    909  &   'Wrong data type for keyword '//TRIM(target), &
     938 &   'Wrong data type for keyword '//TRIM(targetname), &
    910939 &   '(NOT '//TRIM(c_vtyp)//')',' ')
    911940  ENDIF
     
    915944 &      .OR.(key_tab(pos)%keymemlen /= 1) ) THEN
    916945      CALL ipslerr (3,'get_rdb', &
    917  &     'Wrong compression length','for keyword '//TRIM(target),' ')
     946 &     'Wrong compression length','for keyword '//TRIM(targetname),' ')
    918947    ELSE
    919948      SELECT CASE (k_typ)
     
    927956    IF (key_tab(pos)%keymemlen /= size_of_in) THEN
    928957      CALL ipslerr (3,'get_rdb', &
    929  &     'Wrong array length','for keyword '//TRIM(target),' ')
     958 &     'Wrong array length','for keyword '//TRIM(targetname),' ')
    930959    ELSE
    931960      k_beg = key_tab(pos)%keymemstart
     
    947976!===
    948977SUBROUTINE get_wdb &
    949  &  (target,status,fileorig,size_of_in, &
     978 &  (targetname,status,fileorig,size_of_in, &
    950979 &   i_val,r_val,c_val,l_val)
    951980!---------------------------------------------------------------------
     
    954983  IMPLICIT NONE
    955984!-
    956   CHARACTER(LEN=*) :: target
     985  CHARACTER(LEN=*) :: targetname
    957986  INTEGER :: status,fileorig,size_of_in
    958987  INTEGER,DIMENSION(:),OPTIONAL          :: i_val
     
    965994  INTEGER :: k_mempos,k_memsize,k_beg,k_end
    966995  LOGICAL :: l_cmp
     996  LOGICAL :: l_dbg
     997!---------------------------------------------------------------------
     998  CALL ipsldbg (old_status=l_dbg)
    967999!---------------------------------------------------------------------
    9681000!-
     
    9991031! Fill out the items of the data base
    10001032  nb_keys = nb_keys+1
    1001   key_tab(nb_keys)%keystr = target(1:MIN(LEN_TRIM(target),l_n))
     1033  key_tab(nb_keys)%keystr = targetname(1:MIN(LEN_TRIM(targetname),l_n))
    10021034  key_tab(nb_keys)%keystatus = status
    10031035  key_tab(nb_keys)%keytype = k_typ
     
    10111043    key_tab(nb_keys)%keymemlen = size_of_in
    10121044  ENDIF
     1045  IF (l_dbg) THEN
     1046     WRITE(*,*) &
     1047 &     "get_wdb : nb_keys ",nb_keys," key_tab keystr   ",key_tab(nb_keys)%keystr,&
     1048 &                                       ",keystatus   ",key_tab(nb_keys)%keystatus,&
     1049 &                                       ",keytype     ",key_tab(nb_keys)%keytype,&
     1050 &                                       ",keycompress ",key_tab(nb_keys)%keycompress,&
     1051 &                                       ",keyfromfile ",key_tab(nb_keys)%keyfromfile,&
     1052 &                                       ",keymemstart ",key_tab(nb_keys)%keymemstart
     1053  ENDIF
     1054
    10131055!-
    10141056! Before writing the actual size lets see if we have the space
     
    10861128!-
    10871129  INTEGER :: eof,ptn,len_str,i,it,iund,io_err
    1088   LOGICAL :: check = .FALSE.
     1130  LOGICAL :: l_dbg
     1131!---------------------------------------------------------------------
     1132  CALL ipsldbg (old_status=l_dbg)
    10891133!---------------------------------------------------------------------
    10901134  eof = 0
     
    10921136  nb_lastkey = 0
    10931137!-
    1094   IF (check) THEN
    1095     WRITE(*,*) 'getin_readdef : Open file ',TRIM(filelist(current))
     1138  IF (l_dbg) THEN
     1139    WRITE(ipslout,*) 'getin_readdef : Open file ',TRIM(filelist(current))
    10961140  ENDIF
    10971141!-
     
    11331177      CALL cmpblank (NEW_str)
    11341178      NEW_str  = TRIM(ADJUSTL(NEW_str))
    1135       IF (check) THEN
    1136         WRITE(*,*) &
     1179      IF (l_dbg) THEN
     1180        WRITE(ipslout,*) &
    11371181 &        '--> getin_readdef : ',TRIM(key_str),' :: ',TRIM(NEW_str)
    11381182      ENDIF
     
    11711215!---- If we have an empty line then the keyword finishes
    11721216      nb_lastkey = 0
    1173       IF (check) THEN
    1174         WRITE(*,*) 'getin_readdef : Have found an emtpy line '
     1217      IF (l_dbg) THEN
     1218        WRITE(ipslout,*) 'getin_readdef : Have found an emtpy line '
    11751219      ENDIF
    11761220    ENDIF
     
    11791223  CLOSE(UNIT=22)
    11801224!-
    1181   IF (check) THEN
     1225  IF (l_dbg) THEN
    11821226    OPEN (UNIT=22,file=TRIM(def_file)//'.test')
    11831227    DO i=1,nb_lines
     
    11861230    CLOSE(UNIT=22)
    11871231  ENDIF
     1232!-
     1233  IF (l_dbg) THEN
     1234     WRITE(ipslout,*) "nb_lines ",nb_lines,"nb_keys ",nb_keys
     1235     WRITE(ipslout,*) "fichier ",fichier(1:nb_lines)
     1236     WRITE(ipslout,*) "targetlist ",targetlist(1:nb_lines)
     1237     WRITE(ipslout,*) "fromfile ",fromfile(1:nb_lines)
     1238     WRITE(ipslout,*) "compline ",compline(1:nb_lines)
     1239     WRITE(ipslout,*) '<-getin_readdef'
     1240  ENDIF
    11881241!---------------------------
    11891242END SUBROUTINE getin_readdef
     
    12021255!-
    12031256  INTEGER :: current,nb_lastkey
    1204   CHARACTER(LEN=*) :: key_str,NEW_str,last_key
     1257  CHARACTER(LEN=*) :: key_str,NEW_str
     1258  CHARACTER(LEN=*),INTENT(out) :: last_key
    12051259!-
    12061260! LOCAL
     
    12101264  CHARACTER(LEN=n_d_fmt) :: cnt
    12111265  CHARACTER(LEN=10) :: c_fmt
     1266  LOGICAL :: l_dbg
     1267!---------------------------------------------------------------------
     1268  CALL ipsldbg (old_status=l_dbg)
    12121269!---------------------------------------------------------------------
    12131270  len_str = LEN_TRIM(NEW_str)
     
    13471404        nbve = nbve+1
    13481405        WRITE(UNIT=cnt,FMT=c_i_fmt) nbve
     1406        compline(nb_lines)=compline(nb_lines-1)
    13491407!-
    13501408      ENDDO
     
    13651423!-
    13661424  ENDIF
     1425
     1426  IF (l_dbg) THEN
     1427     WRITE(ipslout,*) "getin_decrypt ->",TRIM(NEW_str), " : "
     1428     WRITE(ipslout,*) "getin_decrypt ->", nb_lines,&
     1429          & SIZE(fichier), &
     1430          & SIZE(fromfile), &
     1431          & SIZE(filelist)
     1432     IF (nb_lines > 0) THEN
     1433        WRITE(ipslout,*) "getin_decrypt ->", &
     1434          & TRIM(fichier(nb_lines)), &
     1435          & fromfile(nb_lines), &
     1436          & TRIM(filelist(fromfile(nb_lines)))
     1437        WRITE(ipslout,*) "                compline : ",compline(nb_lines)
     1438        WRITE(ipslout,*) "                targetlist : ",TRIM(targetlist(nb_lines))
     1439     ENDIF
     1440     WRITE(ipslout,*) "                last_key : ",last_key
     1441  ENDIF
    13671442!---------------------------
    13681443END SUBROUTINE getin_decrypt
     
    13911466!---
    13921467    IF (n_k > 0) THEN
    1393       WRITE(*,*) 'COUNT : ',n_k
    1394       WRITE(*,*) &
     1468      WRITE(ipslout,*) 'COUNT : ',n_k
     1469      WRITE(ipslout,*) &
    13951470 &  'getin_checkcohe : Found a problem on key ',TRIM(targetlist(line))
    1396       WRITE(*,*) &
     1471      WRITE(ipslout,*) &
    13971472 &  'getin_checkcohe : The following values were encoutered :'
    1398       WRITE(*,*) &
     1473      WRITE(ipslout,*) &
    13991474 &  '                ',TRIM(targetlist(line)),' == ',fichier(line)
    1400       WRITE(*,*) &
     1475      WRITE(ipslout,*) &
    14011476 &  '                ',TRIM(targetlist(k)),' == ',fichier(k)
    1402       WRITE(*,*) &
     1477      WRITE(ipslout,*) &
    14031478 &  'getin_checkcohe : We will keep only the last value'
     1479       CALL ipslerr (2,'getin_checkcohe','Found a problem on key ', &
     1480 &                     TRIM(targetlist(line)), fichier(line)//" "//fichier(k))
    14041481      targetlist(line) = ' '
    14051482    ENDIF
     
    14161493  INTEGER :: unit,eof,nb_lastkey
    14171494  CHARACTER(LEN=100) :: dummy
    1418   CHARACTER(LEN=100) :: out_string
     1495  CHARACTER(LEN=100),INTENT(out) :: out_string
    14191496  CHARACTER(LEN=1) :: first
    14201497!---------------------------------------------------------------------
     
    17801857  CHARACTER(LEN=20) :: c_tmp
    17811858  CHARACTER(LEN=100) :: tmp_str,used_filename
    1782   LOGICAL :: check = .FALSE.
     1859  INTEGER :: io_err
     1860  LOGICAL :: l_dbg
     1861!---------------------------------------------------------------------
     1862  CALL ipsldbg (old_status=l_dbg)
    17831863!---------------------------------------------------------------------
    17841864  IF (PRESENT(fileprefix)) THEN
     
    17911871!---
    17921872    used_filename = TRIM(usedfileprefix)//'_'//TRIM(filelist(if))
    1793     IF (check) THEN
    1794       WRITE(*,*) &
    1795  &      'GETIN_DUMP : opens file : ',TRIM(used_filename),' if = ',if
    1796       WRITE(*,*) 'GETIN_DUMP : NUMBER OF KEYS : ',nb_keys
    1797     ENDIF
    1798     OPEN (UNIT=22,FILE=used_filename)
     1873    IF (l_dbg) THEN
     1874      WRITE(ipslout,*) &
     1875 &      'getin_dump : opens file : ',TRIM(used_filename),' if = ',if
     1876      WRITE(ipslout,*) 'GETIN_DUMP : NUMBER OF KEYS : ',nb_keys
     1877    ENDIF
     1878    OPEN (UNIT=22,FILE=used_filename,iostat=io_err)
     1879    IF (io_err /= 0) THEN
     1880       CALL ipslerr (3,'getin_dump', &
     1881            &   'Could not open file :',TRIM(used_filename), &
     1882            &   '')
     1883    ENDIF
    17991884!---
    18001885!-- If this is the first file we need to add the list
     
    18081893      ENDDO
    18091894      WRITE(22,*) '# '
     1895      IF (l_dbg) THEN
     1896         WRITE(ipslout,*) '# '
     1897         WRITE(ipslout,*) '# This file is linked to the following files :'
     1898         WRITE(ipslout,*) '# '
     1899         DO iff=2,nbfiles
     1900            WRITE(ipslout,*) 'INCLUDEDEF = ',TRIM(filelist(iff))
     1901         ENDDO
     1902         WRITE(ipslout,*) '# '
     1903      ENDIF
    18101904    ENDIF
    18111905!---
     
    18181912        WRITE(22,*) '#'
    18191913        SELECT CASE (key_tab(ikey)%keystatus)
    1820         CASE(1)
     1914        CASE(nondefault)
    18211915          WRITE(22,*) '# Values of ', &
    18221916 &          TRIM(key_tab(ikey)%keystr),' comes from ',TRIM(def_file)
    1823         CASE(2)
     1917        CASE(default)
    18241918          WRITE(22,*) '# Values of ', &
    18251919 &          TRIM(key_tab(ikey)%keystr),' are all defaults.'
    1826         CASE(3)
     1920        CASE(vectornondefault)
    18271921          WRITE(22,*) '# Values of ', &
    18281922 &          TRIM(key_tab(ikey)%keystr), &
     
    18331927        END SELECT
    18341928        WRITE(22,*) '#'
     1929        !-
     1930        IF (l_dbg) THEN
     1931           WRITE(ipslout,*) '#'
     1932           WRITE(ipslout,*) '# Status of key ', ikey, ' : ',&
     1933 &          TRIM(key_tab(ikey)%keystr),key_tab(ikey)%keystatus
     1934        ENDIF
    18351935!-------
    18361936!------ Write the values
     
    19252025END SUBROUTINE getin_dump
    19262026!===
     2027SUBROUTINE getin_dump_para (fileprefix,rank)
     2028!---------------------------------------------------------------------
     2029  IMPLICIT NONE
     2030!-
     2031  CHARACTER(*) :: fileprefix
     2032  INTEGER,INTENT(IN) :: rank
     2033!-
     2034  CHARACTER(LEN=80) :: usedfileprefix
     2035  LOGICAL :: l_dbg
     2036  INTEGER :: isize
     2037!---------------------------------------------------------------------
     2038  CALL ipsldbg (old_status=l_dbg)
     2039!---------------------------------------------------------------------
     2040  IF ( rank < 1000 ) THEN
     2041     isize=MIN(LEN_TRIM(fileprefix),75)
     2042     usedfileprefix = fileprefix(1:isize)
     2043     usedfileprefix((isize+1):(isize+1))='_'
     2044     WRITE(usedfileprefix((isize+2):(isize+5)),'(I4.4)') rank
     2045     IF (l_dbg) &
     2046          WRITE(ipslout,*) 'Dump getin to file ',usedfileprefix
     2047     CALL getin_dump(usedfileprefix)
     2048  ENDIF
     2049!------------------------
     2050END SUBROUTINE getin_dump_para
     2051
     2052!===
    19272053SUBROUTINE get_qtyp (k_typ,c_vtyp,i_v,r_v,c_v,l_v)
    19282054!---------------------------------------------------------------------
  • dynamico_lmdz/aquaplanet/IOIPSL/src/histcom.f90

    r3847 r3907  
    11MODULE histcom
    22!-
    3 !$Id: histcom.f90 1028 2010-05-20 15:17:30Z bellier $
     3!$Id: histcom.f90 2350 2014-10-08 12:21:30Z acosce $
    44!-
    55! This software is governed by the CeCILL license
     
    99!-
    1010  USE stringop, ONLY : nocomma,cmpblank,findpos,find_str,strlowercase
    11   USE mathelp,  ONLY : mathop,moycum,buildop
     11  USE mathelp,  ONLY : mathop,moycum,moycum_index,buildop
    1212  USE fliocom,  ONLY : flio_dom_file,flio_dom_att
    1313  USE calendar
    14   USE errioipsl, ONLY : ipslerr,ipsldbg
     14  USE errioipsl, ONLY : ipslerr,ipsldbg,ipslout
    1515!-
    1616  IMPLICIT NONE
     
    1818  PRIVATE
    1919  PUBLIC :: histbeg,histdef,histhori,histvert,histend, &
    20  &          histwrite,histclo,histsync,ioconf_modname
     20 &          histwrite,histclo,histsync,ioconf_modname, histglobal_attr
    2121!---------------------------------------------------------------------
    2222!- Some confusing vocabulary in this code !
     
    7474! Fixed parameter
    7575!-
    76   INTEGER,PARAMETER :: nb_files_max=20,nb_var_max=2000, &
     76  INTEGER,PARAMETER :: nb_files_max=20,nb_var_max=1000, &
    7777 &                     nb_hax_max=5,nb_zax_max=10,nbopp_max=10
    7878  REAL,PARAMETER :: missing_val=nf90_fill_real
     
    123123!-NETCDF IDs for file
    124124  INTEGER :: ncfid=-1
     125!-Name of the file
     126  CHARACTER(LEN=120) :: name
    125127!-Time variables
    126128  INTEGER :: itau0=0
     
    340342  ENDIF
    341343!-
    342   IF (l_dbg) WRITE(*,*) c_nam//" 0.0"
     344  IF (l_dbg) WRITE(ipslout,*) c_nam//" 0.0"
    343345!-
    344346! Search for a free index
     
    358360! 1.0 Transfering into the common for future use
    359361!-
    360   IF (l_dbg) WRITE(*,*) c_nam//" 1.0"
     362  IF (l_dbg) WRITE(ipslout,*) c_nam//" 1.0"
    361363!-
    362364  W_F(idf)%itau0  = pitau0
     
    366368! 2.0 Initializes all variables for this file
    367369!-
    368   IF (l_dbg) WRITE(*,*) c_nam//" 2.0"
     370  IF (l_dbg) WRITE(ipslout,*) c_nam//" 2.0"
    369371!-
    370372  W_F(idf)%n_var = 0
     
    383385! 3.0 Opening netcdf file and defining dimensions
    384386!-
    385   IF (l_dbg) WRITE(*,*) c_nam//" 3.0"
     387  IF (l_dbg) WRITE(ipslout,*) c_nam//" 3.0"
    386388!-
    387389! Add DOMAIN number and ".nc" suffix in file name if needed
     
    425427! 4.0 Declaring the geographical coordinates and other attributes
    426428!-
    427   IF (l_dbg) WRITE(*,*) c_nam//" 4.0"
     429  IF (l_dbg) WRITE(ipslout,*) c_nam//" 4.0"
    428430!-
    429431  iret = NF90_PUT_ATT(nfid,NF90_GLOBAL,'Conventions','CF-1.1')
     
    436438! 5.0 Saving some important information on this file in the common
    437439!-
    438   IF (l_dbg) WRITE(*,*) c_nam//" 5.0"
     440  IF (l_dbg) WRITE(ipslout,*) c_nam//" 5.0"
    439441!-
    440442  IF (PRESENT(domain_id)) THEN
    441443    W_F(idf)%dom_id_svg = domain_id
    442444  ENDIF
     445  W_F(idf)%name = TRIM(nc_name)
    443446  W_F(idf)%ncfid = nfid
    444447  IF ( (k_typ == 1).OR.(k_typ == 2) ) THEN
     
    467470!-----------------------
    468471END SUBROUTINE histb_all
     472!===
     473SUBROUTINE histglobal_attr &
     474 & (idf,string_attr,glob_attr)
     475!---------------------------------------------------------------------
     476!- Definition of GLOBAL attribute for history files.
     477!-
     478!- INPUT
     479!-
     480!- idf     : The id of the file to which the grid should be added
     481!- string_attr : name of the global attribute to be added
     482!- glob_attr : global_attribute to be added
     483!---------------------------------------------------------------------
     484  IMPLICIT NONE
     485!-
     486  INTEGER,INTENT(IN) :: idf
     487  CHARACTER(len=*),INTENT(IN) :: string_attr
     488  CHARACTER(len=*),INTENT(IN) :: glob_attr
     489
     490  INTEGER :: iret,nfid
     491  LOGICAL :: l_dbg
     492!---------------------------------------------------------------------
     493  CALL ipsldbg (old_status=l_dbg)
     494
     495  nfid = W_F(idf)%ncfid
     496  IF (l_dbg) WRITE(ipslout,*) "New global attribute : ",glob_attr
     497  iret = NF90_PUT_ATT(nfid,NF90_GLOBAL,string_attr,glob_attr)
     498!-----------------------
     499END SUBROUTINE histglobal_attr
    469500!===
    470501SUBROUTINE histh_reg1d &
     
    612643! 1.1 Create all the variables needed
    613644!-
    614   IF (l_dbg) WRITE(*,*) c_nam//" 1.0"
     645  IF (l_dbg) WRITE(ipslout,*) c_nam//" 1.0"
    615646!-
    616647  nfid = W_F(idf)%ncfid
     
    671702! 2.0 Longitude
    672703!-
    673   IF (l_dbg) WRITE(*,*) c_nam//" 2.0"
     704  IF (l_dbg) WRITE(ipslout,*) c_nam//" 2.0"
    674705!-
    675706  i_s = 1;
     
    702733! 3.0 Latitude
    703734!-
    704   IF (l_dbg) WRITE(*,*) c_nam//" 3.0"
     735  IF (l_dbg) WRITE(ipslout,*) c_nam//" 3.0"
    705736!-
    706737  i_e = 2;
     
    736767! 4.0 storing the geographical coordinates
    737768!-
    738   IF (l_dbg) WRITE(*,*) c_nam//" 4.0"
     769  IF (l_dbg) WRITE(ipslout,*) c_nam//" 4.0"
    739770!-
    740771  IF ( (k_typ == 1).OR.(k_typ == 2) ) THEN
     
    833864!    Is the name already in use ?
    834865!-
    835   IF (l_dbg) WRITE(*,*) "histvert : 1.0 Verifications", &
     866  IF (l_dbg) WRITE(ipslout,*) "histvert : 1.0 Verifications", &
    836867 &                      pzaxname,'---',pzaxunit,'---',pzaxtitle
    837868!-
     
    883914!-
    884915  IF (l_dbg) &
    885  &  WRITE(*,*) "histvert : 2.0 Add the information to the file"
     916 &  WRITE(ipslout,*) "histvert : 2.0 Add the information to the file"
    886917!-
    887918  nfid = W_F(idf)%ncfid
     
    918949!-
    919950  IF (l_dbg) &
    920   &  WRITE(*,*) "histvert : 3.0 add the information to the common"
     951  &  WRITE(ipslout,*) "histvert : 3.0 add the information to the common"
    921952!-
    922953  W_F(idf)%n_zax = iv
     
    10161047!     and verify that it does not already exist
    10171048!-
    1018   IF (l_dbg) WRITE(*,*) "histdef : 1.0"
     1049  IF (l_dbg) WRITE(ipslout,*) "histdef : 1.0"
    10191050!-
    10201051  IF (iv > 1) THEN
     
    10701101!-
    10711102  IF (l_dbg) THEN
    1072     WRITE(*,*) "histdef : 2.0",idf,iv,W_F(idf)%W_V(iv)%nbopp, &
     1103    WRITE(ipslout,*) "histdef : 2.0",idf,iv,W_F(idf)%W_V(iv)%nbopp, &
    10731104 &    W_F(idf)%W_V(iv)%sopp(1:W_F(idf)%W_V(iv)%nbopp), &
    10741105 &    W_F(idf)%W_V(iv)%scal(1:W_F(idf)%W_V(iv)%nbopp)
     
    11641195!-
    11651196  IF (l_dbg) THEN
    1166     WRITE(*,*) "histdef : 3.0"
     1197    WRITE(ipslout,*) "histdef : 3.0"
    11671198  ENDIF
    11681199!-
     
    11751206 &    .AND.(TRIM(W_F(idf)%W_V(iv)%topp) /= "never") )THEN
    11761207    ALLOCATE(W_F(idf)%W_V(iv)%t_bf(buff_sz))
    1177     W_F(idf)%W_V(iv)%t_bf(:) = 0.
     1208    W_F(idf)%W_V(iv)%t_bf(:) = missing_val
    11781209    IF (l_dbg) THEN
    1179       WRITE(*,*) "histdef : 3.0 allocating time_buffer for", &
     1210      WRITE(ipslout,*) "histdef : 3.0 allocating time_buffer for", &
    11801211 &      " idf = ",idf," iv = ",iv," size = ",buff_sz
    11811212    ENDIF
     
    11871218!     The strategy is to bring it back to seconds for the tests
    11881219!-
    1189   IF (l_dbg) WRITE(*,*) "histdef : 4.0"
     1220  IF (l_dbg) WRITE(ipslout,*) "histdef : 4.0"
    11901221!-
    11911222  W_F(idf)%W_V(iv)%freq_opp = pfreq_opp
     
    12721303! 5.0 Initialize other variables of the common
    12731304!-
    1274   IF (l_dbg) WRITE(*,*) "histdef : 5.0"
     1305  IF (l_dbg) WRITE(ipslout,*) "histdef : 5.0"
    12751306!-
    12761307  W_F(idf)%W_V(iv)%hist_wrt_rng = (PRESENT(var_range))
     
    12981329! 6.0 Get the time axis for this variable
    12991330!-
    1300   IF (l_dbg) WRITE(*,*) "histdef : 6.0"
     1331  IF (l_dbg) WRITE(ipslout,*) "histdef : 6.0"
    13011332!-
    13021333! No time axis for once, l_max, l_min or never operation
     
    13311362  ELSE
    13321363    IF (l_dbg) THEN
    1333       WRITE(*,*) "histdef : 7.0 ",TRIM(W_F(idf)%W_V(iv)%topp),'----'
     1364      WRITE(ipslout,*) "histdef : 7.0 ",TRIM(W_F(idf)%W_V(iv)%topp),'----'
    13341365    ENDIF
    13351366    W_F(idf)%W_V(iv)%t_axid = -99
     
    13851416! 1.0 Create the time axes
    13861417!-
    1387   IF (l_dbg) WRITE(*,*) "histend : 1.0"
     1418  IF (l_dbg) WRITE(ipslout,*) "histend : 1.0"
    13881419!-
    13891420! 1.1 Define the time dimensions needed for this file
     
    14731504! 2.0 declare the variables
    14741505!-
    1475   IF (l_dbg) WRITE(*,*) "histend : 2.0"
     1506  IF (l_dbg) WRITE(ipslout,*) "histend : 2.0"
    14761507!-
    14771508  DO iv=1,W_F(idf)%n_var
     
    15751606!-
    15761607        IF (l_dbg) THEN
    1577           WRITE(*,*) "histend : 2.0.n, freq_opp, freq_wrt", &
     1608          WRITE(ipslout,*) "histend : 2.0.n, freq_opp, freq_wrt", &
    15781609 &          W_F(idf)%W_V(iv)%freq_opp,W_F(idf)%W_V(iv)%freq_wrt
    15791610        ENDIF
     
    15961627! 3.0 Put the netcdf file into write mode
    15971628!-
    1598   IF (l_dbg) WRITE(*,*) "histend : 3.0"
     1629  IF (l_dbg) WRITE(ipslout,*) "histend : 3.0"
    15991630!-
    16001631  iret = NF90_ENDDEF (nfid)
     
    16021633! 4.0 Give some informations to the user
    16031634!-
    1604   IF (l_dbg) WRITE(*,*) "histend : 4.0"
     1635  IF (l_dbg) WRITE(ipslout,*) "histend : 4.0"
    16051636!-
    16061637  WRITE(str70,'("All variables have been initialized on file :",I3)') idf
     
    16821713!-
    16831714  IF (l_dbg) THEN
    1684     WRITE(*,*) "histwrite : ",c_nam
     1715    WRITE(ipslout,*) "histwrite : ",c_nam
    16851716  ENDIF
    16861717!-
     
    17911822    IF (.NOT.ALLOCATED(tbf_1)) THEN
    17921823      IF (l_dbg) THEN
    1793         WRITE(*,*) &
     1824        WRITE(ipslout,*) &
    17941825 &       c_nam//" : allocate tbf_1 for size = ", &
    17951826 &       W_F(idf)%W_V(iv)%datasz_max
     
    17981829    ELSE IF (W_F(idf)%W_V(iv)%datasz_max > SIZE(tbf_1)) THEN
    17991830      IF (l_dbg) THEN
    1800         WRITE(*,*) &
     1831        WRITE(ipslout,*) &
    18011832 &       c_nam//" : re-allocate tbf_1 for size = ", &
    18021833 &       W_F(idf)%W_V(iv)%datasz_max
     
    18611892  INTEGER,DIMENSION(4) :: corner,edges
    18621893  INTEGER :: itime
     1894  LOGICAL :: flag
    18631895!-
    18641896  REAL :: rtime
     
    18711903!-
    18721904  IF (l_dbg) THEN
    1873     WRITE(*,*) "histwrite 0.0 : VAR : ",W_F(idf)%W_V(iv)%v_name
    1874     WRITE(*,*) "histwrite 0.0 : nbindex :",nbindex
    1875     WRITE(*,*) "histwrite 0.0 : nindex  :",nindex(1:MIN(3,nbindex)),'...'
     1905    WRITE(ipslout,*) "histwrite 0.0 : VAR : ",W_F(idf)%W_V(iv)%v_name
     1906    WRITE(ipslout,*) "histwrite 0.0 : nbindex :",nbindex
     1907    WRITE(ipslout,*) "histwrite 0.0 : nindex  :",nindex(1:MIN(3,nbindex)),'...'
    18761908  ENDIF
    18771909!-
     
    18881920  IF (.NOT.ALLOCATED(tbf_2)) THEN
    18891921    IF (l_dbg) THEN
    1890       WRITE(*,*) "histwrite_real 1.1 allocate tbf_2 ",SIZE(tbf_1)
     1922      WRITE(ipslout,*) "histwrite_real 1.1 allocate tbf_2 ",SIZE(tbf_1)
    18911923    ENDIF
    18921924    ALLOCATE(tbf_2(W_F(idf)%W_V(iv)%datasz_max))
    18931925  ELSE IF (W_F(idf)%W_V(iv)%datasz_max > SIZE(tbf_2)) THEN
    18941926    IF (l_dbg) THEN
    1895       WRITE(*,*) "histwrite_real 1.2 re-allocate tbf_2 : ", &
     1927      WRITE(ipslout,*) "histwrite_real 1.2 re-allocate tbf_2 : ", &
    18961928     & SIZE(tbf_1)," instead of ",SIZE(tbf_2)
    18971929    ENDIF
     
    19061938!-
    19071939  IF (l_dbg) THEN
    1908     WRITE(*,*) "histwrite: 3.0",idf
     1940    WRITE(ipslout,*) "histwrite: 3.0",idf
    19091941  ENDIF
    19101942!-
     
    19241956 &      nbout,tbf_2)
    19251957      IF (l_dbg) THEN
    1926         WRITE(*,*) &
     1958        WRITE(ipslout,*) &
    19271959 &       "histwrite: 3.4a nbout : ",nbin,nbout,W_F(idf)%W_V(iv)%sopp(io)
    19281960      ENDIF
     
    19341966 &      nbout,tbf_1)
    19351967      IF (l_dbg) THEN
    1936         WRITE(*,*) &
     1968        WRITE(ipslout,*) &
    19371969 &     "histwrite: 3.4b nbout : ",nbin,nbout,W_F(idf)%W_V(iv)%sopp(io+1)
    19381970      ENDIF
     
    19421974!-
    19431975    IF (l_dbg) THEN
    1944       WRITE(*,*) &
     1976      WRITE(ipslout,*) &
    19451977 &     "histwrite: 3.5 size(tbf_1) : ",SIZE(tbf_1)
    1946       WRITE(*,*) &
     1978      WRITE(ipslout,*) &
    19471979 &     "histwrite: 3.5 slab in X :", &
    19481980 &     W_F(idf)%W_V(iv)%zorig(1),W_F(idf)%W_V(iv)%zsize(1)
    1949       WRITE(*,*) &
     1981      WRITE(ipslout,*) &
    19501982 &     "histwrite: 3.5 slab in Y :", &
    19511983 &     W_F(idf)%W_V(iv)%zorig(2),W_F(idf)%W_V(iv)%zsize(2)
    1952       WRITE(*,*) &
     1984      WRITE(ipslout,*) &
    19531985 &     "histwrite: 3.5 slab in Z :", &
    19541986 &     W_F(idf)%W_V(iv)%zorig(3),W_F(idf)%W_V(iv)%zsize(3)
    1955       WRITE(*,*) &
     1987      WRITE(ipslout,*) &
    19561988 &     "histwrite: 3.5 slab of input:", &
    19571989 &     W_F(idf)%W_V(iv)%scsize(1), &
     
    19992031!-
    20002032    IF (l_dbg) THEN
    2001       WRITE(*,*) "histwrite: 4.0 tbf_1",idf,iv, &
     2033      WRITE(ipslout,*) "histwrite: 4.0 tbf_1",idf,iv, &
    20022034 &      TRIM(tmp_opp),' ---- ',LEN_TRIM(tmp_opp),nbindex
    20032035    ENDIF
     
    20162048!-
    20172049    IF (l_dbg) THEN
    2018       WRITE(*,*) "histwrite: 5.0 idf : ",idf," iv : ",iv," tsz : ",tsz
     2050      WRITE(ipslout,*) "histwrite: 5.0 idf : ",idf," iv : ",iv," tsz : ",tsz
    20192051    ENDIF
    20202052!-
    20212053    IF (     (TRIM(tmp_opp) /= "inst") &
    20222054 &      .AND.(TRIM(tmp_opp) /= "once") ) THEN
    2023       CALL moycum(tmp_opp,tsz,W_F(idf)%W_V(iv)%t_bf, &
    2024  &           tbf_2,W_F(idf)%W_V(iv)%nb_opp)
     2055
     2056!-
     2057!------ 5.1 Check if scatter operation is performed
     2058!-     
     2059       flag = .FALSE.
     2060       DO io = 1, nbopp_max
     2061          IF ( INDEX(TRIM(W_F(idf)%W_V(iv)%sopp(io)),'scatter') > 0 ) THEN
     2062             flag = .TRUE.
     2063          END IF
     2064       END DO
     2065
     2066       IF ( flag ) THEN
     2067!-
     2068!------ 5.2  Enter moycum_index only if a scatter operation is performed
     2069!-         
     2070          IF (l_dbg) &
     2071               & WRITE(ipslout,*) "histwrite: 5.2 moycum_index",nbindex,nx,ny,nz
     2072          CALL moycum_index(tmp_opp, W_F(idf)%W_V(iv)%t_bf, &
     2073 &             tbf_2, W_F(idf)%W_V(iv)%nb_opp, nbindex, nindex)
     2074       ELSE
     2075!-
     2076!------ 5.3  Enter moycum otherwise
     2077!-
     2078          IF (l_dbg) &
     2079               & WRITE(ipslout,*) "histwrite: 5.3 moycum",nbindex,nx,ny
     2080          CALL moycum(tmp_opp,tsz,W_F(idf)%W_V(iv)%t_bf, &
     2081               &           tbf_2,W_F(idf)%W_V(iv)%nb_opp)
     2082       END IF
     2083
    20252084    ENDIF
    20262085!-
     
    20322091! 6.0 Write to file if needed
    20332092!-
    2034   IF (l_dbg) WRITE(*,*) "histwrite: 6.0",idf
     2093  IF (l_dbg) WRITE(ipslout,*) "histwrite: 6.0",idf
    20352094!-
    20362095  IF (do_write) THEN
     
    20412100!-- 6.1 Do the operations that are needed before writting
    20422101!-
    2043     IF (l_dbg) WRITE(*,*) "histwrite: 6.1",idf
     2102    IF (l_dbg) WRITE(ipslout,*) "histwrite: 6.1",idf
    20442103!-
    20452104    IF (     (TRIM(tmp_opp) /= "inst") &
     
    20552114 &      .AND.(TRIM(tmp_opp) /= "once") ) THEN
    20562115!-
    2057       IF (l_dbg) WRITE(*,*) "histwrite: 6.2",idf
     2116      IF (l_dbg) WRITE(ipslout,*) "histwrite: 6.2",idf
    20582117!-
    20592118      itax  = W_F(idf)%W_V(iv)%t_axid
     
    20772136!-
    20782137    IF (l_dbg) THEN
    2079       WRITE(*,*) "histwrite: 6.3",idf,nfid,nvid,iv,itime
     2138      WRITE(ipslout,*) "histwrite: 6.3",idf,nfid,nvid,iv,itime
    20802139    ENDIF
    20812140!-
     
    21592218!-
    21602219  IF (l_dbg) THEN
    2161     WRITE(*,*) 'histvar_seq, start of the subroutine :',learning(idf)
     2220    WRITE(ipslout,*) 'histvar_seq, start of the subroutine :',learning(idf)
    21622221  ENDIF
    21632222!-
     
    22032262 &       'of your code. Thus if you wish to save time'// &
    22042263 &       ' contact the IOIPSL team. ')
    2205         WRITE(*,*) 'The sequence we have found up to now :'
    2206         WRITE(*,*) varseq(idf,1:sp-1)
     2264        WRITE(ipslout,*) 'The sequence we have found up to now :'
     2265        WRITE(ipslout,*) varseq(idf,1:sp-1)
    22072266        varseq_err(idf) = -1
    22082267      ENDIF
     
    22492308      ENDIF
    22502309      varseq_err(idf) = varseq_err(idf)+1
     2310      IF (l_dbg) &
     2311           WRITE(ipslout,*) "Error history file ",W_F(idf)%name," names : ", &
     2312 &           TRIM(W_F(idf)%W_V(idv)%v_name),TRIM(pvarname)," id : ",idv
    22512313    ELSE
    22522314!-
     
    22682330!-
    22692331  IF (l_dbg) THEN
    2270     WRITE(*,*) &
     2332    WRITE(ipslout,*) &
    22712333 &   'histvar_seq, end of the subroutine :',TRIM(pvarname),idv
    22722334  ENDIF
     
    22942356!-
    22952357  IF (l_dbg) THEN
    2296     WRITE(*,*) "->histsync"
     2358    WRITE(ipslout,*) "->histsync"
    22972359  ENDIF
    22982360!-
     
    23192381    IF (W_F(ifile)%ncfid > 0) THEN
    23202382      IF (l_dbg) THEN
    2321         WRITE(*,*) '  histsync - synchronising file number ',ifile
     2383        WRITE(ipslout,*) '  histsync - synchronising file number ',ifile
    23222384      ENDIF
    23232385      iret = NF90_SYNC(W_F(ifile)%ncfid)
     
    23262388!-
    23272389  IF (l_dbg) THEN
    2328     WRITE(*,*) "<-histsync"
     2390    WRITE(ipslout,*) "<-histsync"
    23292391  ENDIF
    23302392!----------------------
     
    23492411!-
    23502412  IF (l_dbg) THEN
    2351     WRITE(*,*) "->histclo"
     2413    WRITE(ipslout,*) "->histclo"
    23522414  ENDIF
    23532415!-
     
    23742436    IF (W_F(ifile)%ncfid > 0) THEN
    23752437      IF (l_dbg) THEN
    2376         WRITE(*,*) '  histclo - closing specified file number :',ifile
     2438        WRITE(ipslout,*) '  histclo - closing specified file number :',ifile
    23772439      ENDIF
    23782440      nfid = W_F(ifile)%ncfid
     
    23822444!-----
    23832445      IF (l_dbg) THEN
    2384         WRITE(*,*) '  Entering loop on vars : ',W_F(ifile)%n_var
     2446        WRITE(ipslout,*) '  Entering loop on vars : ',W_F(ifile)%n_var
    23852447      ENDIF
    23862448      DO iv=1,W_F(ifile)%n_var
     
    23882450        IF (W_F(ifile)%W_V(iv)%hist_wrt_rng) THEN
    23892451          IF (l_dbg) THEN
    2390             WRITE(*,*) 'min value for file :',ifile,' var n. :',iv, &
     2452            WRITE(ipslout,*) 'min value for file :',ifile,' var n. :',iv, &
    23912453 &                     ' is : ',W_F(ifile)%W_V(iv)%hist_minmax(1)
    2392             WRITE(*,*) 'max value for file :',ifile,' var n. :',iv, &
     2454            WRITE(ipslout,*) 'max value for file :',ifile,' var n. :',iv, &
    23932455 &                     ' is : ',W_F(ifile)%W_V(iv)%hist_minmax(2)
    23942456          ENDIF
     
    24202482!---- 2. Close the file
    24212483!-----
    2422       IF (l_dbg) WRITE(*,*) '  close file :',nfid
     2484      IF (l_dbg) WRITE(ipslout,*) '  close file :',nfid
    24232485      iret = NF90_CLOSE(nfid)
    24242486      W_F(ifile)%ncfid = -1
     
    24282490!-
    24292491  IF (l_dbg) THEN
    2430     WRITE(*,*) "<-histclo"
     2492    WRITE(ipslout,*) "<-histclo"
    24312493  ENDIF
    24322494!---------------------
  • dynamico_lmdz/aquaplanet/IOIPSL/src/mathelp.f90

    r3847 r3907  
    11MODULE mathelp
    22!-
    3 !$Id: mathelp.f90 845 2009-12-10 16:26:03Z bellier $
     3!$Id: mathelp.f90 1927 2012-11-22 13:54:21Z dsolyga $
    44!-
    55! This software is governed by the CeCILL license
     
    1010!-
    1111  PRIVATE
    12   PUBLIC :: mathop,moycum,buildop
     12  PUBLIC :: mathop,moycum,moycum_index,buildop
    1313!-
    1414  INTERFACE mathop
     
    31193119END SUBROUTINE moycum
    31203120!===
     3121SUBROUTINE moycum_index( opp, px, py, pwx, nbi, ind )
     3122!---------------------------------------------------------------------
     3123!- Does time operations on index points
     3124!---------------------------------------------------------------------
     3125  IMPLICIT NONE
     3126!-
     3127
     3128  !! 0. Parameters and variables declaration
     3129
     3130  !! 0.1 Input variables
     3131
     3132  CHARACTER(LEN=7), INTENT(in)        :: opp  !! Operation performed
     3133  INTEGER, INTENT(in)                 :: nbi  !! Size of index vector
     3134  INTEGER, DIMENSION(nbi), INTENT(in) :: ind  !! Index vector
     3135  REAL, DIMENSION(:), INTENT(in)      :: py   !! Vector containing the
     3136                                              !! previous values of px
     3137                                              !! Warning : due to memory
     3138                                              !! optimization, we have
     3139                                              !! generally SIZE(px) /= SIZE(py) 
     3140  INTEGER, INTENT(in)                 :: pwx  !! Used to calculate average value                             
     3141
     3142  !! 0.3 Modified variables
     3143
     3144  REAL, DIMENSION(:), INTENT(inout)   :: px   !! Result
     3145
     3146  !! 0.4 Local variables
     3147
     3148  INTEGER :: ig                               !! Index
     3149
     3150!---------------------------------------------------------------------
     3151
     3152  !! Perform operations only if the values of ind don't exceed the size of px
     3153
     3154  IF ( MAXVAL(ind) > SIZE(px) ) THEN
     3155     CALL ipslerr(3,"moycum_index", &
     3156          & "the index vector is out of range for px", &
     3157          & "Indexation vector problem. We stop", " " )
     3158  END IF
     3159
     3160  IF (pwx /= 0) THEN
     3161     IF      (opp == 'ave') THEN
     3162        DO ig = 1,nbi
     3163           px(ind(ig)) = (px(ind(ig))*pwx + py(ind(ig)))/REAL(pwx+1)
     3164        END DO
     3165     ELSE IF (opp == 't_sum') THEN
     3166        DO ig = 1,nbi
     3167           px(ind(ig)) = px(ind(ig)) + py(ind(ig))
     3168        END DO
     3169     ELSE IF ( (opp == 'l_min').OR.(opp == 't_min') ) THEN
     3170        DO ig = 1,nbi
     3171           px(ind(ig)) = MIN(px(ind(ig)),py(ind(ig)))
     3172        END DO
     3173     ELSE IF ( (opp == 'l_max').OR.(opp == 't_max') ) THEN
     3174        DO ig = 1,nbi
     3175           px(ind(ig)) = MAX(px(ind(ig)),py(ind(ig)))
     3176        END DO
     3177     ELSE
     3178        CALL ipslerr(3,"moycum_index",'Unknown time operation',opp,' ')
     3179     END IF
     3180  ELSE
     3181    IF      (opp == 'l_min') THEN
     3182       DO ig = 1,nbi
     3183          px(ind(ig)) = MIN(px(ind(ig)),py(ind(ig)))
     3184       END DO
     3185    ELSE IF (opp == 'l_max') THEN
     3186       DO ig = 1,nbi
     3187          px(ind(ig)) = MAX(px(ind(ig)),py(ind(ig)))
     3188       END DO
     3189    ELSE
     3190       DO ig = 1,nbi
     3191          px(ind(ig)) = py(ind(ig))
     3192       END DO
     3193    ENDIF
     3194 END IF
     3195
     3196END SUBROUTINE moycum_index
     3197
     3198
    31213199!-----------------
    31223200END MODULE mathelp
  • dynamico_lmdz/aquaplanet/IOIPSL/src/restcom.f90

    r3847 r3907  
    11MODULE restcom
    22!-
    3 !$Id: restcom.f90 430 2008-10-23 14:33:11Z bellier $
     3!$Id: restcom.f90 2020 2013-03-07 09:22:15Z jgipsl $
    44!-
    55! This software is governed by the CeCILL license
     
    88USE netcdf
    99!-
    10 USE errioipsl, ONLY : ipslerr,ipsldbg
     10USE errioipsl, ONLY : ipslerr,ipsldbg, ipslout
    1111USE stringop
    1212USE calendar
     
    4949  INTEGER,SAVE :: nb_fi = 0
    5050  INTEGER,DIMENSION(max_file,2),SAVE :: netcdf_id = -1
     51  CHARACTER(LEN=120),DIMENSION(max_file,2),SAVE :: netcdf_name='NONE'
    5152!-
    5253! Description of the content of the 'in' files and the 'out' files.
     
    230231!-
    231232  IF (l_dbg) THEN
    232     WRITE(*,*) 'restini 0.0 : ',TRIM(fnamein),' , ',TRIM(fnameout)
     233    WRITE(ipslout,*) 'restini 0.0 : ',TRIM(fnamein),' , ',TRIM(fnameout)
    233234  ENDIF
    234235!-
     
    254255!-
    255256  IF (l_dbg) THEN
    256     WRITE(*,*) 'restini 0.1 l_fi, l_fo, l_rw : ',l_fi,l_fo,l_rw
     257    WRITE(ipslout,*) 'restini 0.1 l_fi, l_fo, l_rw : ',l_fi,l_fo,l_rw
    257258  ENDIF
    258259!-
     
    261262  IF (l_fi) THEN
    262263!---
    263     IF (l_dbg) WRITE(*,*) 'restini 1.0 : Open input file'
     264    IF (l_dbg) WRITE(ipslout,*) 'restini 1.0 : Open input file'
    264265!-- Add DOMAIN number and ".nc" suffix in file names if needed
    265266    fname = fnamein
     
    268269    CALL restopenin (nb_fi,fname,l_rw,iim,jjm,lon,lat,llm,lev,ncfid)
    269270    netcdf_id(nb_fi,1) = ncfid
     271    netcdf_name(nb_fi,1) = TRIM(fnamein)
    270272!---
    271273!-- 1.3 Extract the time information
     
    284286!-- 2.0 The case of a missing restart file is dealt with
    285287!---
    286     IF (l_dbg) WRITE(*,*) 'restini 2.0'
     288    IF (l_dbg) WRITE(ipslout,*) 'restini 2.0'
    287289!---
    288290    IF (     (ALL(MINLOC(lon(:iim,:jjm)) == MAXLOC(lon(:iim,:jjm)))) &
     
    324326      (nb_fi,fname,iim,jjm,lon,lat,llm,lev,dt,date0,ncfid,domain_id)
    325327    netcdf_id(nb_fi,2) = ncfid
     328    netcdf_name(nb_fi,2) = TRIM(fnameout)
    326329  ELSE IF (l_fi.AND.l_fo) THEN
    327330    netcdf_id(nb_fi,2) = netcdf_id(nb_fi,1)
     331    netcdf_name(nb_fi,2) = netcdf_name(nb_fi,1)
    328332    varname_out(nb_fi,:) = varname_in(nb_fi,:)
    329333    nbvar_out(nb_fi) = nbvar_in(nb_fi)
     
    340344!-
    341345  IF (l_dbg) THEN
    342     WRITE(*,*) 'restini 2.3 : Configure calendar if needed : ', &
     346    WRITE(ipslout,*) 'restini 2.3 : Configure calendar if needed : ', &
    343347                calend_str
    344348  ENDIF
     
    347351    CALL ioconf_calendar (calend_str)
    348352    IF (l_dbg) THEN
    349       WRITE(*,*) 'restini 2.3b : new calendar : ',calend_str
     353      WRITE(ipslout,*) 'restini 2.3b : new calendar : ',calend_str
    350354    ENDIF
    351355  ENDIF
     
    359363  fid = nb_fi
    360364  IF (l_dbg) THEN
    361     WRITE(*,*) 'SIZE of t_index :',SIZE(t_index), &
     365    WRITE(ipslout,*) 'SIZE of t_index :',SIZE(t_index), &
    362366               SIZE(t_index,dim=1),SIZE(t_index,dim=2)
    363     WRITE(*,*) 't_index = ',t_index(fid,:)
     367    WRITE(ipslout,*) 't_index = ',t_index(fid,:)
    364368  ENDIF
    365369  itau = t_index(fid,1)
    366370!-
    367   IF (l_dbg) WRITE(*,*) 'restini END'
     371  IF (l_dbg) WRITE(ipslout,*) 'restini END'
    368372!---------------------
    369373END SUBROUTINE restini
     
    502506! 2.0 Get the list of variables
    503507!-
    504   IF (l_dbg) WRITE(*,*) 'restopenin 1.2'
     508  IF (l_dbg) WRITE(ipslout,*) 'restopenin 1.2'
    505509!-
    506510  lat_vid = -1
     
    663667      CALL ioconf_calendar (calendar)
    664668      IF (l_dbg) THEN
    665         WRITE(*,*) 'restsett : calendar of the restart ',calendar
     669        WRITE(ipslout,*) 'restsett : calendar of the restart ',calendar
    666670      ENDIF
    667671    ENDIF
     
    669673  CALL ioget_calendar (one_year,one_day)
    670674  IF (l_dbg) THEN
    671     WRITE(*,*) 'one_year,one_day = ',one_year,one_day
     675    WRITE(ipslout,*) 'one_year,one_day = ',one_year,one_day
    672676  ENDIF
    673677!-
     
    681685      t_index(nb_fi,:) = itau
    682686      IF (l_dbg) THEN
    683         WRITE(*,*) "nb_fi,t_index",nb_fi,t_index(nb_fi,:)
     687        WRITE(ipslout,*) "nb_fi,t_index",nb_fi,t_index(nb_fi,:)
    684688      ENDIF
    685689      CALL ju2ymds (date0,year0,month0,day0,sec0)
     
    691695      strc=':'
    692696      IF (l_dbg) THEN
    693         WRITE(*,*) date0
     697        WRITE(ipslout,*) date0
    694698        WRITE (UNIT=itau_orig,FMT='(I4.4,5(A,I2.2))') &
    695699 &       year0,'-',month0,'-',day0,' ',hours0,':',minutes0,':',seci
    696         WRITE(*,*) "itau_orig : ",itau_orig
     700        WRITE(ipslout,*) "itau_orig : ",itau_orig
    697701      ENDIF
    698702    ELSE
    699703      iret = NF90_GET_VAR(ncfid,tind_varid_in(nb_fi),t_index(nb_fi,:))
    700704      IF (l_dbg) THEN
    701         WRITE(*,*) "restsett, time axis : ",t_index(nb_fi,:)
     705        WRITE(ipslout,*) "restsett, time axis : ",t_index(nb_fi,:)
    702706      ENDIF
    703707      iret = NF90_GET_ATT(ncfid,tind_varid_in(nb_fi),'units',itau_orig)
     
    727731    iret = NF90_GET_ATT(ncfid,tax_varid_in(nb_fi),'calendar',tmp_cal)
    728732    IF (l_dbg) THEN
    729       WRITE(*,*) 'restsett : tmp_calendar of the restart ',tmp_cal
     733      WRITE(ipslout,*) 'restsett : tmp_calendar of the restart ',tmp_cal
    730734    ENDIF
    731735!---
     
    744748!-- to get ride of the intial date.
    745749!---
    746     IF (l_dbg) WRITE(*,*) 'tax_orig : ',TRIM(tax_orig)
     750    IF (l_dbg) WRITE(ipslout,*) 'tax_orig : ',TRIM(tax_orig)
    747751    READ (UNIT=tax_orig,FMT='(I4.4,5(a,I2.2))') &
    748752      year0,strc,month0,strc,day0,strc, &
     
    831835  CALL ipsldbg (old_status=l_dbg)
    832836!-
    833   IF (l_dbg) WRITE(*,*) "restopenout 0.0 ",TRIM(fname)
     837  IF (l_dbg) WRITE(ipslout,*) "restopenout 0.0 ",TRIM(fname)
    834838!-
    835839!  If we use the same file for input and output
    836840!- we will not even call restopenout
    837841!-
    838   iret = NF90_CREATE(fname,NF90_NOCLOBBER,ncfid)
     842  iret = NF90_CREATE(fname,cmode=or(NF90_NOCLOBBER,NF90_64BIT_OFFSET),ncid=ncfid)
    839843  IF (iret == -35) THEN
    840844    CALL ipslerr (3,'restopenout',&
     
    863867! 1.0 Longitude
    864868!-
    865   IF (l_dbg) WRITE(*,*) "restopenout 1.0"
     869  IF (l_dbg) WRITE(ipslout,*) "restopenout 1.0"
    866870!-
    867871  iret = NF90_DEF_VAR(ncfid,"nav_lon",NF90_FLOAT,(/x_id,y_id/),nlonid)
     
    873877! 2.0 Latitude
    874878!-
    875   IF (l_dbg) WRITE(*,*) "restopenout 2.0"
     879  IF (l_dbg) WRITE(ipslout,*) "restopenout 2.0"
    876880!-
    877881  iret = NF90_DEF_VAR(ncfid,"nav_lat",NF90_FLOAT,(/x_id,y_id/),nlatid)
     
    883887! 3.0 Levels
    884888!-
    885   IF (l_dbg) WRITE(*,*) "restopenout 3.0"
     889  IF (l_dbg) WRITE(ipslout,*) "restopenout 3.0"
    886890!-
    887891  iret = NF90_DEF_VAR(ncfid,"nav_lev",NF90_FLOAT,z_id,nlevid)
     
    895899! 4.0 Time axis, this is the seconds since axis
    896900!-
    897   IF (l_dbg) WRITE(*,*) "restopenout 4.0"
     901  IF (l_dbg) WRITE(ipslout,*) "restopenout 4.0"
    898902!-
    899903  iret = NF90_DEF_VAR(ncfid,"time",NF90_FLOAT, &
     
    923927! 5.0 Time axis, this is the time steps since axis
    924928!-
    925   IF (l_dbg) WRITE(*,*) "restopenout 5.0"
     929  IF (l_dbg) WRITE(ipslout,*) "restopenout 5.0"
    926930!-
    927931  iret = NF90_DEF_VAR(ncfid,"time_steps",NF90_INT, &
     
    984988  iret = NF90_REDEF(ncfid)
    985989!-
    986   IF (l_dbg) WRITE(*,*) "restopenout END"
     990  IF (l_dbg) WRITE(ipslout,*) "restopenout END"
    987991!-------------------------
    988992END SUBROUTINE restopenout
     
    13721376  CHARACTER(LEN=80) attname
    13731377  INTEGER,DIMENSION(4) :: corner,edge
    1374 !---------------------------------------------------------------------
     1378  LOGICAL :: l_dbg
     1379!---------------------------------------------------------------------
     1380  CALL ipsldbg (old_status=l_dbg)
     1381!---------------------------------------------------------------------
     1382  IF (l_dbg) WRITE(ipslout,*) 'RESTGET 0.0 : ',netcdf_name(fid,2),vname_q,iim,jjm,llm,itau,def_beha
     1383!-
    13751384  ncfid = netcdf_id(fid,1)
    13761385!-
     
    13791388! 1.0 If the variable is not present then ERROR or filled up
    13801389!     by default values if allowed
     1390!-
     1391  IF (l_dbg) WRITE(ipslout,*) 'RESTGET 1.0 : ',vnb
    13811392!-
    13821393  IF (vnb < 0) THEN
     
    14021413!-----
    14031414      CALL restdefv (fid,vname_q,iim,jjm,llm,.TRUE.)
     1415      IF (l_dbg) WRITE(ipslout,*) 'RESTGET 1.1 : ',vnb
    14041416!-----
    14051417    ELSE
     
    14161428!---
    14171429    vid = varid_in(fid,vnb)
     1430    IF (l_dbg) WRITE(ipslout,*) 'RESTGET 2.0 : ',vid
    14181431!---
    14191432    nbvar_read(fid) = nbvar_read(fid)+1
     
    14371450 &      str,'is not available in the current file',' ')
    14381451    ENDIF
     1452    IF (l_dbg) WRITE(ipslout,*) 'RESTGET 3.0 : ',index
    14391453!---
    14401454!-- 4.0 Read the data. Note that the variables in the restart files
     
    14881502    iret = NF90_GET_VAR(ncfid,vid,var, &
    14891503 &                      start=corner(1:ndim),count=edge(1:ndim))
     1504    IF (l_dbg) WRITE(ipslout,*) 'RESTGET 4.0 : ',iret
    14901505!---
    14911506!-- 5.0 The variable we have just read is created
     
    19001915  CALL ioget_calendar (one_year,one_day)
    19011916!-
     1917! 0.0 show arguments
     1918  IF (l_dbg) WRITE(ipslout,*) 'RESTPUT 0.0 : ',netcdf_name(fid,2),vname_q,iim,jjm,llm,itau
     1919!-
    19021920! 1.0 Check if the variable is already present
    19031921!-
    1904   IF (l_dbg) WRITE(*,*) 'RESTPUT 1.0 : ',TRIM(vname_q)
     1922  IF (l_dbg) WRITE(ipslout,*) 'RESTPUT 1.0 : ',TRIM(vname_q)
    19051923!-
    19061924  CALL find_str (varname_out(fid,1:nbvar_out(fid)),vname_q,vnb)
    19071925!-
    19081926  IF (l_dbg) THEN
    1909     WRITE(*,*) 'RESTPUT 1.1 : ',varname_out(fid,1:nbvar_out(fid)),vnb
     1927    WRITE(ipslout,*) 'RESTPUT 1.1 : ',varname_out(fid,1:nbvar_out(fid)),vnb
    19101928  ENDIF
    19111929!-
     
    19191937  vid = varid_out(fid,vnb)
    19201938!-
    1921   IF (l_dbg) WRITE(*,*) 'RESTPUT 2.0 : ',vnb,vid
     1939  IF (l_dbg) WRITE(ipslout,*) 'RESTPUT 2.0 : ',vnb,vid
    19221940!-
    19231941! 2.1 Is this file already in write mode ?
     
    19321950!     If not then check that all variables of previous time is OK.
    19331951!-
    1934   IF (l_dbg) WRITE(*,*) 'RESTPUT 3.0 : ',itau,itau_out(fid)
     1952  IF (l_dbg) WRITE(ipslout,*) 'RESTPUT 3.0 : ',itau,itau_out(fid)
    19351953!-
    19361954  IF (itau /= itau_out(fid)) THEN
     
    19421960    IF (tstp_out(fid) == 0) THEN
    19431961      IF (nbvar_out(fid) < nbvar_read(fid)) THEN
    1944         WRITE(*,*) "ERROR :",tstp_out(fid), &
     1962        WRITE(ipslout,*) "ERROR :",tstp_out(fid), &
    19451963                   nbvar_out(fid),nbvar_read(fid)
    19461964        CALL ipslerr (1,'restput', &
     
    19551973      ENDDO
    19561974      IF (ierr > 0) THEN
    1957         WRITE(*,*) "ERROR :",nbvar_out(fid)
     1975        WRITE(ipslout,*) "ERROR :",nbvar_out(fid)
    19581976        CALL ipslerr (1,'restput', &
    19591977 &        'There are fewer variables in the output file for this', &
     
    19711989!---
    19721990    IF (l_dbg) THEN
    1973       WRITE(*,*) 'RESTPUT 3.1 : ',itau,secsince,corner(1),edge(1)
     1991      WRITE(ipslout,*) 'RESTPUT 3.1 : ',itau,secsince,corner(1),edge(1)
    19741992    ENDIF
    19751993!---
     
    20532071  IF (itau_out(fid) >= 0) THEN
    20542072    iret = NF90_REDEF(ncfid)
     2073    IF (l_dbg) THEN
     2074       WRITE(ipslout,*) 'restdefv 0.0 : REDEF',itau_out(fid)
     2075    ENDIF
    20552076  ENDIF
    20562077!-
     
    20582079!-
    20592080  IF (l_dbg) THEN
    2060     WRITE(*,*) 'restdefv 1.0 :',TRIM(varname),nbvar_out(fid)
     2081    WRITE(ipslout,*) 'restdefv 1.0 :',TRIM(varname),nbvar_out(fid)
    20612082  ENDIF
    20622083!-
     
    21342155!-
    21352156  IF (l_dbg) THEN
    2136     WRITE(*,*) 'restdefv 2.0 :',ndim,' :: ',dims(1:ndim),tdimid_out(fid)
     2157    WRITE(ipslout,*) 'restdefv 2.0 :',ndim,' :: ',dims(1:ndim),tdimid_out(fid)
    21372158  ENDIF
    21382159!-
     
    21692190!-
    21702191  IF (l_dbg) THEN
    2171     WRITE(*,*) &
     2192    WRITE(ipslout,*) &
    21722193 &    'restdefv 3.0 : LIST OF VARS ',varname_out(fid,1:nbvar_out(fid))
    21732194  ENDIF
     
    21932214  IF (.NOT.ALLOCATED(t_index) .AND. .NOT.ALLOCATED(t_julian)) THEN
    21942215    IF (l_msg) THEN
    2195       WRITE(*,*) TRIM(c_p)//' : Allocate times axes at :', &
     2216      WRITE(ipslout,*) TRIM(c_p)//' : Allocate times axes at :', &
    21962217 &               max_file,tax_size_in(nb_fi)
    21972218    ENDIF
     
    21992220    ALLOCATE(t_index(max_file,tax_size_in(nb_fi)),STAT=i_err)
    22002221    IF (i_err/=0) THEN
    2201       WRITE(*,*) "ERROR IN ALLOCATION of t_index : ",i_err
     2222      WRITE(ipslout,*) "ERROR IN ALLOCATION of t_index : ",i_err
    22022223      CALL ipslerr (3,TRIM(c_p), &
    22032224 &      'Problem in allocation of t_index','', &
     
    22082229    ALLOCATE(t_julian(max_file,tax_size_in(nb_fi)),STAT=i_err)
    22092230    IF (i_err/=0) THEN
    2210       WRITE(*,*) "ERROR IN ALLOCATION of t_julian : ",i_err
     2231      WRITE(ipslout,*) "ERROR IN ALLOCATION of t_julian : ",i_err
    22112232      CALL ipslerr (3,TRIM(c_p), &
    22122233 &      'Problem in allocation of max_file,tax_size_in','', &
     
    22172238 &         .OR.(SIZE(t_julian,DIM=2) < tax_size_in(nb_fi)) ) THEN
    22182239    IF (l_msg) THEN
    2219       WRITE(*,*) TRIM(c_p)//' : Reallocate times axes at :', &
     2240      WRITE(ipslout,*) TRIM(c_p)//' : Reallocate times axes at :', &
    22202241 &               max_file,tax_size_in(nb_fi)
    22212242    ENDIF
     
    22232244    ALLOCATE (tmp_index(max_file,tax_size_in(nb_fi)),STAT=i_err)
    22242245    IF (i_err/=0) THEN
    2225       WRITE(*,*) "ERROR IN ALLOCATION of tmp_index : ",i_err
     2246      WRITE(ipslout,*) "ERROR IN ALLOCATION of tmp_index : ",i_err
    22262247      CALL ipslerr (3,TRIM(c_p), &
    22272248 &      'Problem in allocation of tmp_index','', &
     
    22332254    ALLOCATE (t_index(max_file,tax_size_in(nb_fi)),STAT=i_err)
    22342255    IF (i_err/=0) THEN
    2235       WRITE(*,*) "ERROR IN ALLOCATION of t_index : ",i_err
     2256      WRITE(ipslout,*) "ERROR IN ALLOCATION of t_index : ",i_err
    22362257      CALL ipslerr (3,TRIM(c_p), &
    22372258 &     'Problem in reallocation of t_index','', &
     
    22422263    ALLOCATE (tmp_julian(max_file,tax_size_in(nb_fi)),STAT=i_err)
    22432264    IF (i_err/=0) THEN
    2244       WRITE(*,*) "ERROR IN ALLOCATION of tmp_julian : ",i_err
     2265      WRITE(ipslout,*) "ERROR IN ALLOCATION of tmp_julian : ",i_err
    22452266      CALL ipslerr (3,TRIM(c_p), &
    22462267 &     'Problem in allocation of tmp_julian','', &
     
    22522273    ALLOCATE (t_julian(max_file,tax_size_in(nb_fi)),STAT=i_err)
    22532274    IF (i_err/=0) THEN
    2254       WRITE(*,*) "ERROR IN ALLOCATION of t_julian : ",i_err
     2275      WRITE(ipslout,*) "ERROR IN ALLOCATION of t_julian : ",i_err
    22552276      CALL ipslerr (3,TRIM(c_p), &
    22562277 &      'Problem in reallocation of t_julian','', &
     
    23082329      IF (    (l_alloc1.AND.ALLOCATED(buff_tmp1)) &
    23092330 &        .OR.(l_alloc2.AND.ALLOCATED(buff_tmp2)) ) THEN
    2310         WRITE(*,*) TRIM(c_p)//" : re_allocate "//TRIM(cbn)//"=",i_qsz
     2331        WRITE(ipslout,*) TRIM(c_p)//" : re_allocate "//TRIM(cbn)//"=",i_qsz
    23112332      ELSE
    2312         WRITE(*,*) TRIM(c_p)//" : allocate "//TRIM(cbn)//"=",i_qsz
     2333        WRITE(ipslout,*) TRIM(c_p)//" : allocate "//TRIM(cbn)//"=",i_qsz
    23132334      ENDIF
    23142335    ENDIF
     
    24792500!---
    24802501    IF (l_dbg) THEN
    2481       WRITE(*,*) &
     2502      WRITE(ipslout,*) &
    24822503        'restclo : Closing specified restart file number :', &
    2483         fid,netcdf_id(fid,1:2)
     2504        fid,netcdf_id(fid,1:2),netcdf_name(fid,1:2)
    24842505    ENDIF
    24852506!---
     
    24902511        WRITE (n_f,'(I3)') netcdf_id(fid,1)
    24912512        CALL ipslerr (2,'restclo', &
    2492           "Error "//n_e//" in closing file : "//n_f,'',' ')
     2513          "Error "//n_e//" in closing file : "//n_f,netcdf_name(fid,1),' ')
    24932514      ENDIF
    24942515      IF (netcdf_id(fid,1) == netcdf_id(fid,2)) THEN
    24952516        netcdf_id(fid,2) = -1
     2517        netcdf_name(fid,2) = 'NONE'
    24962518      ENDIF
    24972519      netcdf_id(fid,1) = -1
     2520      netcdf_name(fid,1) = 'NONE'
    24982521    ENDIF
    24992522!---
     
    25042527        WRITE (n_f,'(I3)') netcdf_id(fid,2)
    25052528        CALL ipslerr (2,'restclo', &
    2506           "Error "//n_e//" in closing file : "//n_f,'',' ')
     2529          "Error "//n_e//" in closing file : "//n_f,netcdf_name(fid,2),' ')
    25072530      ENDIF
    25082531      netcdf_id(fid,2) = -1
     2532      netcdf_name(fid,2) = 'NONE'
    25092533    ENDIF
    25102534!---
    25112535  ELSE
    25122536!---
    2513     IF (l_dbg) WRITE(*,*) 'restclo : Closing all files'
     2537    IF (l_dbg) WRITE(ipslout,*) 'restclo : Closing all files'
    25142538!---
    25152539    DO ifnc=1,nb_fi
     
    25202544          WRITE (n_f,'(I3)') netcdf_id(ifnc,1)
    25212545          CALL ipslerr (2,'restclo', &
    2522             "Error "//n_e//" in closing file : "//n_f,'',' ')
     2546            "Error "//n_e//" in closing file : "//n_f,netcdf_name(ifnc,1),' ')
     2547        ENDIF
     2548        IF (l_dbg) THEN
     2549           WRITE(ipslout,*) &
     2550                'restclo : Closing specified restart file number :', &
     2551                ifnc,netcdf_id(ifnc,1:2),netcdf_name(ifnc,1:2)
    25232552        ENDIF
    25242553        IF (netcdf_id(ifnc,1) == netcdf_id(ifnc,2)) THEN
    25252554          netcdf_id(ifnc,2) = -1
     2555          netcdf_name(ifnc,2) = 'NONE'
    25262556        ENDIF
    25272557        netcdf_id(ifnc,1) = -1
     2558        netcdf_name(ifnc,1) = 'NONE'
    25282559      ENDIF
    25292560!-----
     
    25342565          WRITE (n_f,'(I3)') netcdf_id(ifnc,2)
    25352566          CALL ipslerr (2,'restclo', &
    2536             "Error "//n_e//" in closing file : "//n_f,'',' ')
     2567            "Error "//n_e//" in closing file : "//n_f,netcdf_name(ifnc,2),' ')
     2568        END IF
     2569        IF (l_dbg) THEN
     2570           WRITE(ipslout,*) &
     2571                'restclo : Closing specified restart file number :', &
     2572                ifnc,netcdf_id(ifnc,1:2),netcdf_name(ifnc,1:2)
    25372573        END IF
    25382574        netcdf_id(ifnc,2) = -1
     2575        netcdf_name(ifnc,2) = 'NONE'
    25392576      ENDIF
    25402577    ENDDO
Note: See TracChangeset for help on using the changeset viewer.