c_ --------------------------------------------------------------------- c_ RCS lines preceded by "c_ " c_ --------------------------------------------------------------------- c_ c_ $Source: /home/orr/ocmip/web/OCMIP/phase2/simulations/CFC/boundcond/RCS/rgasx_ocmip2.f,v $ c_ $Revision: 1.1 $ c_ $Date: 1998/07/07 15:22:00 $ ; $State: Exp $ c_ $Author: orr $ ; $Locker: $ c_ c_ --------------------------------------------------------------------- c_ $Log: rgasx_ocmip2.f,v $ c_ Revision 1.1 1998/07/07 15:22:00 orr c_ Initial revision c_ c_ --------------------------------------------------------------------- c_ PROGRAM rgasx_ocmip2 c Program to demonstrate reading 2-D gas exchange fields, c written in netCDF format. These fields are those necessary c to make simulations according to standard OCMIP-2 protocols, c as is required by all participants. C To compile: c ----------- c f77 -L/usr/local/lib -lnetcdf -I/usr/local/include -o rgasx_ocmip2 rgasx_ocmip2.f C Patrick Brockmann, 9 june 1998, LSCE/CEA-CNRS, Saclay C - modified by J. Orr (9 june 1998) IMPLICIT NONE INTEGER*4 imt,jmt,nmonths PARAMETER (imt=360, jmt=180, nmonths=12) REAL*4 lon(imt), lat(jmt) REAL*4 tmask(imt,jmt) REAL*4 fice(imt, jmt, nmonths) REAL*4 xkw (imt, jmt, nmonths) REAL*4 p (imt, jmt, nmonths) C Get standard OCMIP-2 gas exchange boundary conditions CALL gasx_ocmip2(lon, lat, tmask, fice, xkw, p) C PRINT results to screen (for verification) C -> PRINT all values for lon & lat WRITE(*,*) 'lon = ', lon PRINT *, "******************" WRITE(*,*) 'lat = ', lat PRINT *, "******************" C -> PRINT row 25 for tmask WRITE(*,*) 'tmask = ', tmask(:,25) PRINT *, "******************" C -> PRINT row 25 (in january) for fice, xkw, and p WRITE(*,*) 'fice = ', fice(:,25,1) PRINT *, "******************" WRITE(*,*) 'xkw = ', xkw(:,25,1) PRINT *, "******************" WRITE(*,*) 'p = ', p(:,25,1) PRINT *, "******************" END C****************************************************************** SUBROUTINE gasx_ocmip2(lon, lat, tmask, fice, xkw, p) IMPLICIT NONE INCLUDE 'netcdf.inc' INTEGER*4 ncid INTEGER*4 STATUS INTEGER*4 idlon, idlat INTEGER*4 idtmask, idfice, idxkw, idp INTEGER*4 imt, jmt, nmonths PARAMETER (imt=360, jmt=180, nmonths=12) REAL*4 lon(imt), lat(jmt) REAL*4 tmask(imt,jmt) REAL*4 fice(imt, jmt, nmonths) REAL*4 xkw (imt, jmt, nmonths) REAL*4 p (imt, jmt, nmonths) c OPEN the netCDF file STATUS=nf_open("gasx_ocmip2.nc", nf_nowrite, ncid) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) c Get the netCDF variable id's STATUS=nf_inq_varid(ncid, "LON", idlon) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) STATUS=nf_inq_varid(ncid, "LAT", idlat) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) STATUS=nf_inq_varid(ncid, "TMASK", idtmask) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) STATUS=nf_inq_varid(ncid, "FICE", idfice) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) STATUS=nf_inq_varid(ncid, "XKW", idxkw) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) STATUS=nf_inq_varid(ncid, "P", idp) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) c READ the netCDF DATA using the variable id's and names above STATUS=nf_get_var_real(ncid, idlon, lon) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) STATUS=nf_get_var_real(ncid, idlat, lat) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) STATUS=nf_get_var_real(ncid, idtmask, tmask) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) STATUS=nf_get_var_real(ncid, idfice, fice) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) STATUS=nf_get_var_real(ncid, idxkw, xkw) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) STATUS=nf_get_var_real(ncid, idp, p) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) STATUS=nf_close(ncid) IF (STATUS .NE. nf_noerr) CALL handle_err(STATUS) END C****************************************************************** C****************************************************************** SUBROUTINE handle_err(STATUS) INCLUDE 'netcdf.inc' INTEGER*4 STATUS IF (STATUS .NE. nf_noerr) THEN PRINT *, nf_strerror(STATUS) STOP 'stopped' ENDIF END C******************************************************************