New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 9369 – NEMO

Changeset 9369


Ignore:
Timestamp:
2018-03-01T12:44:33+01:00 (6 years ago)
Author:
jpalmier
Message:

JPALM -- branch corrections from review

Location:
branches/NERC/dev_r5518_GO6_CO2_cmip/NEMOGCM/NEMO/TOP_SRC/MEDUSA
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/NERC/dev_r5518_GO6_CO2_cmip/NEMOGCM/NEMO/TOP_SRC/MEDUSA/sms_medusa.F90

    r9310 r9369  
    288288   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)   ::   hist_pco2 !: pCO2 
    289289   INTEGER  :: co2_rec 
    290    REAL(wp) :: co2_yinit, co2_yend 
     290   REAL(wp) :: co2_yinit, co2_yend    !: First and Last year read in the xCO2.atm file 
    291291#endif 
    292292 
  • branches/NERC/dev_r5518_GO6_CO2_cmip/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcini_medusa.F90

    r9309 r9369  
    498498      !! ** Method  : - Read the xco2 file 
    499499      !!---------------------------------------------------------------------- 
    500       INTEGER  ::  jn, jm, io, ierr, inum 
    501       INTEGER  ::  iskip = 4   ! number of 1st descriptor lines 
     500      INTEGER                       ::  jn, jm, io, ierr, inum, iostatus 
     501      INTEGER, PARAMETER            ::  iskip = 4   ! number of 1st descriptor lines 
    502502      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:)   ::   zyy !: xCO2 record years 
    503       CHARACTER (len=10) ::   clname = 'xco2.atm'  !! atm CO2 record file 
     503      CHARACTER (len=10), PARAMETER ::  clname = 'xco2.atm'  !! atm CO2 record file 
    504504      !!---------------------------------------------------------------------- 
    505505 
     
    512512 
    513513      CALL ctl_opn( inum, clname, 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. ) 
    514       REWIND(inum) 
    515  
    516       ! compute the number of year in the file 
    517       ! file starts in 1849 do jn represent the record number in the file. 
    518       ! the year is jn + yinit - 1 
     514      !REWIND(inum) 
     515      !!! 
     516      ! -Compute the number of year in the file 
     517      ! -File starts in co2_yinit, jn represents the record number in the file. 
     518      ! -Remove the file head (iskip lines) to jn 
     519      ! -The year is jn + yinit - 1  
     520      !! Determine the number of lines in xCO2 input file 
     521      iostatus = 0 
    519522      jn = 1 
    520       DO 
    521         READ(inum,'(1x)',END=100) 
     523      DO WHILE ( iostatus == 0 ) 
     524        READ(inum,'(1x)', IOSTAT=iostatus, END=100) 
    522525        jn = jn + 1 
    523       END DO 
     526      ENDDO 
     527      IF( iostatus .NE. 0 ) THEN 
     528        !! Error while reading xCO2 input file  
     529        CALL ctl_stop('trc_ini_medusa_co2atm: & 
     530                      & Error on the 1st reading of xco2.atm') 
     531        RETURN 
     532      ENDIF 
    524533 100  co2_rec = jn - 1 - iskip 
    525534      IF ( lwp) WRITE(numout,*) '    ', co2_rec ,' years read in the file' 
     
    528537      ALLOCATE( hist_pco2(co2_rec),zyy(co2_rec), STAT=ierr ) 
    529538      IF( ierr > 0 ) THEN 
    530          CALL ctl_stop( 'trc_ini_medusa_co2atm: unable to allocate  array' )   ; RETURN 
     539         CALL ctl_stop( 'trc_ini_medusa_co2atm: unable to allocate  array' )   
     540         RETURN 
    531541      ENDIF 
    532542 
     
    539549      ! Read file till the end 
    540550      ! allocate start and end year of the file 
    541       jn = 1 
    542       DO 
    543         READ(inum,*, IOSTAT=io) zyy(jn), hist_pco2(jn) 
    544         IF( io < 0 ) exit 
     551      DO jn = 1, co2_rec 
     552        READ(inum,'(F6.1,F12.7)', IOSTAT=io) zyy(jn), hist_pco2(jn) 
     553        IF( io .NE. 0 ) THEN 
     554          !! Error while reading xCO2 input file  
     555          CALL ctl_stop('trc_ini_medusa_co2atm: & 
     556                        & Error on the 2nd reading of xco2.atm') 
     557          RETURN 
     558        ENDIF 
     559 
    545560        IF(jn==1) co2_yinit = zyy(jn) 
    546         jn = jn + 1 
    547561      END DO 
    548562      co2_yend = co2_yinit + real(co2_rec) - 1. 
     
    554568         WRITE(numout,*) ' Year   xCO2 atm ' 
    555569         DO jn = 1, co2_rec 
    556             WRITE(numout, '( 5F7.1, 6F9.2)') zyy(jn), hist_pco2(jn) 
     570            WRITE(numout, '(F6.1,F12.7)') zyy(jn), hist_pco2(jn) 
    557571         END DO 
    558572      ENDIF 
Note: See TracChangeset for help on using the changeset viewer.