Changeset 9369
- Timestamp:
- 2018-03-01T12:44:33+01:00 (7 years ago)
- 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 288 288 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) :: hist_pco2 !: pCO2 289 289 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 291 291 #endif 292 292 -
branches/NERC/dev_r5518_GO6_CO2_cmip/NEMOGCM/NEMO/TOP_SRC/MEDUSA/trcini_medusa.F90
r9309 r9369 498 498 !! ** Method : - Read the xco2 file 499 499 !!---------------------------------------------------------------------- 500 INTEGER :: jn, jm, io, ierr, inum501 INTEGER :: iskip = 4 ! number of 1st descriptor lines500 INTEGER :: jn, jm, io, ierr, inum, iostatus 501 INTEGER, PARAMETER :: iskip = 4 ! number of 1st descriptor lines 502 502 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) :: zyy !: xCO2 record years 503 CHARACTER (len=10) ::clname = 'xco2.atm' !! atm CO2 record file503 CHARACTER (len=10), PARAMETER :: clname = 'xco2.atm' !! atm CO2 record file 504 504 !!---------------------------------------------------------------------- 505 505 … … 512 512 513 513 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 519 522 jn = 1 520 DO 521 READ(inum,'(1x)', END=100)523 DO WHILE ( iostatus == 0 ) 524 READ(inum,'(1x)', IOSTAT=iostatus, END=100) 522 525 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 524 533 100 co2_rec = jn - 1 - iskip 525 534 IF ( lwp) WRITE(numout,*) ' ', co2_rec ,' years read in the file' … … 528 537 ALLOCATE( hist_pco2(co2_rec),zyy(co2_rec), STAT=ierr ) 529 538 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 531 541 ENDIF 532 542 … … 539 549 ! Read file till the end 540 550 ! 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 545 560 IF(jn==1) co2_yinit = zyy(jn) 546 jn = jn + 1547 561 END DO 548 562 co2_yend = co2_yinit + real(co2_rec) - 1. … … 554 568 WRITE(numout,*) ' Year xCO2 atm ' 555 569 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) 557 571 END DO 558 572 ENDIF
Note: See TracChangeset
for help on using the changeset viewer.