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 9285 for branches/NERC/dev_r5518_GO6_CO2_cmip/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcini_medusa.F90 – NEMO

Ignore:
Timestamp:
2018-01-26T13:27:36+01:00 (6 years ago)
Author:
jpalmier
Message:

JPALM --26-01-2018 -- change MEDUSA atm co2 input method. now reads a file a variable length

File:
1 edited

Legend:

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

    r9114 r9285  
    324324      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~' 
    325325      IF(lwp) CALL flush(numout) 
     326      !! 
     327      !!---------------------------------------------------------------------- 
     328      !! JPALM (23-01-2017): new way to initialize CO2-atm for cmip6  
     329      !!                     initially done in trcsms_medusa 
     330      !!---------------------------------------------------------------------- 
     331      !!      
     332      IF(lwp) WRITE(numout,*) ' trc_ini_medusa: initialisating atm CO2 record' 
     333      CALL trc_ini_medusa_co2atm 
     334 
    326335 
    327336   END SUBROUTINE trc_ini_medusa 
     
    480489   END SUBROUTINE trc_ini_medusa_river 
    481490    
     491   SUBROUTINE trc_ini_medusa_co2atm 
     492      !!---------------------------------------------------------------------- 
     493      !!                     ***  trc_ini_medusa_co2atm  ***   
     494      !! 
     495      !! ** Purpose :   initialization atmospheric co2 record 
     496      !! 
     497      !! ** Method  : - Read the xco2 file 
     498      !!---------------------------------------------------------------------- 
     499      INTEGER  ::  jn, jl, jm, io, ierr, inum 
     500      INTEGER  ::  iskip = 4   ! number of 1st descriptor lines 
     501      REAL(wp) ::  zyy 
     502      CHARACTER (len=10) ::   clname = 'xco2.atm'  !! atm CO2 record file 
     503      !!---------------------------------------------------------------------- 
     504 
     505      IF(lwp) WRITE(numout,*) 
     506      IF(lwp) WRITE(numout,*) ' trc_ini_medusa_co2atm: initialisation of atm CO2 historical record' 
     507      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~' 
     508 
     509 
     510      IF(lwp) WRITE(numout,*) 'read of formatted file xco2.atm' 
     511 
     512      CALL ctl_opn( inum, clname, 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. ) 
     513      REWIND(inum) 
     514 
     515      ! compute the number of year in the file 
     516      ! file starts in 1849 do jn represent the record number in the file. 
     517      ! the year is jn + yinit - 1 
     518      jn = 1 
     519      DO 
     520        READ(inum,'(1x)',END=100) 
     521        jn = jn + 1 
     522      END DO 
     523 100  co2_rec = jn - 1 - iskip 
     524      IF ( lwp) WRITE(numout,*) '    ', co2_rec ,' years read in the file' 
     525      !                                ! Allocate CO2 hist arrays 
     526      ierr = 0  
     527      ALLOCATE( hist_pco2(co2_rec), STAT=ierr ) 
     528      IF( ierr > 0 ) THEN 
     529         CALL ctl_stop( 'trc_ini_medusa_co2atm: unable to allocate  array' )   ; RETURN 
     530      ENDIF 
     531 
     532      REWIND(inum) 
     533 
     534      DO jm = 1, iskip        ! Skip over 1st six descriptor lines 
     535         READ(inum,'(1x)') 
     536      END DO 
     537      ! file starts in 1931 do jn represent the year in the century.jhh 
     538      ! Read file till the end 
     539      ! allocate start and end year of the file 
     540      jn = 1 
     541      DO 
     542        READ(inum,*, IOSTAT=io) zyy, hist_pco2(jn) 
     543        IF( io < 0 ) exit 
     544        IF(jn==1) co2_yinit = int(zyy) 
     545        jn = jn + 1 
     546      END DO 
     547      co2_yend = co2_yinit + co2_rec - 1 
     548 
     549      IF(lwp) THEN        ! Control print 
     550         WRITE(numout,*) 
     551         WRITE(numout,*) 'CO2 hist start year: ', co2_yinit 
     552         WRITE(numout,*) 'CO2 hist end   year: ', co2_yend 
     553         WRITE(numout,*) ' Year   xCO2 atm ' 
     554         DO jn = 1, co2_rec 
     555            jl = jn + co2_yinit - 1 
     556            WRITE(numout, '( 1I4, 6F9.2)') jl, hist_pco2(jn) 
     557         END DO 
     558      ENDIF 
     559 
     560   END SUBROUTINE trc_ini_medusa_co2atm 
     561 
     562 
    482563#else 
    483564   !!---------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.