[1356] | 1 | SUBROUTINE get_field_npp_dyn(filename) |
---|
| 2 | !-------------------------------------------------------------- |
---|
| 3 | ! get the emissions and interpolate on the final grid |
---|
| 4 | !-------------------------------------------------------------- |
---|
| 5 | USE final_grid_lmdz |
---|
| 6 | USE grid |
---|
| 7 | USE sflx |
---|
| 8 | |
---|
| 9 | IMPLICIT NONE |
---|
| 10 | |
---|
| 11 | INCLUDE 'netcdf.inc' |
---|
| 12 | |
---|
| 13 | !-------------------------------------------------------------- |
---|
| 14 | ! ... Dummy arguments |
---|
| 15 | !-------------------------------------------------------------- |
---|
| 16 | CHARACTER(LEN=*), INTENT(in) :: filename |
---|
| 17 | |
---|
| 18 | !-------------------------------------------------------------- |
---|
| 19 | ! ... Local variables |
---|
| 20 | !-------------------------------------------------------------- |
---|
| 21 | INTEGER :: iret |
---|
| 22 | INTEGER :: error |
---|
| 23 | INTEGER :: ncid |
---|
| 24 | INTEGER :: varid |
---|
| 25 | ! REAL :: workin (klon_init,nlev_len, nrecs) |
---|
| 26 | |
---|
| 27 | !! filename="npp_dyn_1x1.nc" |
---|
| 28 | PRINT *,'Read field from file' , filename(:LEN_TRIM(filename)) |
---|
| 29 | |
---|
| 30 | ! ... Open the file |
---|
| 31 | iret = nf_open(filename, 0, ncid) |
---|
| 32 | CALL check_err(iret) |
---|
| 33 | |
---|
| 34 | iret = nf_inq_dimid(ncid, 'time', varid) |
---|
| 35 | CALL check_err(iret) |
---|
| 36 | iret = nf_inq_dimlen(ncid, varid, nrecs) |
---|
| 37 | CALL check_err(iret) |
---|
| 38 | print*,'nrecs',nrecs |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | iret = nf_inq_dimid(ncid, 'lat', varid) |
---|
| 42 | CALL check_err(iret) |
---|
| 43 | iret = nf_inq_dimlen(ncid, varid, nlat_len) |
---|
| 44 | CALL check_err(iret) |
---|
| 45 | print*,'nlat_len',nlat_len |
---|
| 46 | iret = nf_inq_dimid(ncid, 'lon', varid) |
---|
| 47 | CALL check_err(iret) |
---|
| 48 | iret = nf_inq_dimlen(ncid, varid, nlon_len) |
---|
| 49 | CALL check_err(iret) |
---|
| 50 | print*,'nlon_len',nlon_len |
---|
| 51 | |
---|
| 52 | ALLOCATE(npp_dyn(nlon_len, nlat_len, nrecs), STAT=error) |
---|
| 53 | |
---|
| 54 | iret = nf_inq_varid(ncid, 'NPP', varid) |
---|
| 55 | CALL check_err(iret) |
---|
| 56 | iret = nf_get_var_real(ncid, varid, npp_dyn) |
---|
| 57 | CALL check_err(iret) |
---|
| 58 | |
---|
| 59 | print*,npp_dyn(1,1,1) |
---|
| 60 | |
---|
| 61 | ! ... Close the file |
---|
| 62 | iret = nf_close(ncid) |
---|
| 63 | CALL check_err(iret) |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | END SUBROUTINE get_field_npp_dyn |
---|
| 67 | |
---|