Index: flexpart_code/fpmetbinary_mod.F90
===================================================================
--- flexpart_code/fpmetbinary_mod.F90	(revision 515b21c06ac454a3edcdd8f8fcbbaafcaa3d2291)
+++ flexpart_code/fpmetbinary_mod.F90	(revision b398fb67a4f4baa29fc8752c3bd278a6e469486e)
@@ -112,17 +112,6 @@
 
 
-#ifdef RAWBIN
-        OPEN(IOUNIT_DUMP, file=filename, action='WRITE', status='REPLACE', form="unformatted", access="stream")
-#endif
-
-
-
-
-
-        CALL fpio(IOUNIT_DUMP, ncid, 'DUMP', cm_index)
-
-#ifdef RAWBIN
-        CLOSE(IOUNIT_DUMP)
-#endif
+
+        CALL fpio(ncid, 'DUMP', cm_index)
 
         PRINT *, 'Closing NC4 file...'
@@ -153,15 +142,5 @@
 
 
-
-#ifdef RAWBIN
-        OPEN(IOUNIT_LOAD, file=filename, action='READ', status='OLD', form="unformatted", access="stream")
-#endif
-
-        CALL fpio(IOUNIT_LOAD, ncid, 'LOAD', cm_index)
-
-#ifdef RAWBIN
-        CLOSE(IOUNIT_LOAD)
-#endif
-
+        CALL fpio(ncid, 'LOAD', cm_index)
 
         CALL SYSTEM_CLOCK(millisecs_stop, count_rate, count_max)
@@ -169,157 +148,10 @@
     END SUBROUTINE fpmetbinary_load
 
-    SUBROUTINE fpmetbinary_zero(cm_index)
-        INTEGER, INTENT(IN) :: cm_index           ! Index of last dimension in
-                                                  ! most com_mod variables.
-                                                  ! Should be 1 or 2 
-
-
-        ! Zeroes out, in local datastructures, the values dumped/loaded
-        ! This was written primarily as a testing mechanism.
-        ! DJM -- 17 February 2017 -- I don't think this routine has been used
-        ! for anything in recent past.  Might want to consider 86'ing it.
-        ! The lines here correspond to READ and WRITE in the dump/load routines
-
-        ! Scalar values
-        nx=0.0; ny=0.0; nxmin1=0.0; nymin1=0.0; nxfield=0.0
-        nuvz=0.0; nwz=0.0; nz=0.0; nmixz=0.0; nlev_ec=0.0
-        dx=0.0; dy=0.0; xlon0=0.0; ylat0=0.0; dxconst=0.0; dyconst=0.0
-
-        ! Fixed fields, static in time
-        oro=0.0; excessoro=0.0; lsm=0.0; xlanduse=0.0; height=0.0
-
-        ! 3d fields
-        uu(:,:,:,cm_index) = 0.0
-        vv(:,:,:,cm_index) = 0.0
-        uupol(:,:,:,cm_index) = 0.0
-        vvpol(:,:,:,cm_index) = 0.0
-        ww(:,:,:,cm_index) = 0.0
-        tt(:,:,:,cm_index) = 0.0
-        qv(:,:,:,cm_index) = 0.0
-        pv(:,:,:,cm_index) = 0.0
-        rho(:,:,:,cm_index) = 0.0
-        drhodz(:,:,:,cm_index) = 0.0
-        tth(:,:,:,cm_index) = 0.0
-        qvh(:,:,:,cm_index) = 0.0
-        pplev(:,:,:,cm_index) = 0.0
-        clouds(:,:,:,cm_index) = 0.0
-        cloudsh(:,:,cm_index) = 0.0
-
-        ! 2d fields
-        ps(:,:,:,cm_index) = 0.0
-        sd(:,:,:,cm_index) = 0.0
-        msl(:,:,:,cm_index) = 0.0
-        tcc(:,:,:,cm_index) = 0.0
-        u10(:,:,:,cm_index) = 0.0
-        v10(:,:,:,cm_index) = 0.0
-        tt2(:,:,:,cm_index) = 0.0
-        td2(:,:,:,cm_index) = 0.0
-        lsprec(:,:,:,cm_index) = 0.0
-        convprec(:,:,:,cm_index) = 0.0
-        sshf(:,:,:,cm_index) = 0.0
-        ssr(:,:,:,cm_index) = 0.0
-        surfstr(:,:,:,cm_index) = 0.0
-        ustar(:,:,:,cm_index) = 0.0
-        wstar(:,:,:,cm_index) = 0.0
-        hmix(:,:,:,cm_index) = 0.0
-        tropopause(:,:,:,cm_index) = 0.0
-        oli(:,:,:,cm_index) = 0.0
-        diffk(:,:,:,cm_index) = 0.0
-        vdep(:,:,:,cm_index) = 0.0
-
-        ! 1d fields
-        z0(:) = 0.0
-        akm(:) = 0.0
-        bkm(:) = 0.0
-        akz(:) = 0.0
-        bkz(:) = 0.0
-        aknew(:) = 0.0
-        bknew(:) = 0.0
-
-        ! Nested, scalar values (for each nest)
-        nxn(:) = 0.0
-        nyn(:) = 0.0
-        dxn(:) = 0.0
-        dyn(:) = 0.0
-        xlon0n(:) = 0.0
-        ylat0n(:) = 0.0
-
-        ! Nested fields, static in time
-        oron=0.0; excessoron=0.0; lsmn=0.0; xlandusen=0.0
-
-        ! 3d nested fields
-        uun(:,:,:,cm_index,:) = 0.0
-        wwn(:,:,:,cm_index,:) = 0.0
-        ttn(:,:,:,cm_index,:) = 0.0
-        qvn(:,:,:,cm_index,:) = 0.0
-        pvn(:,:,:,cm_index,:) = 0.0
-        cloudsn(:,:,:,cm_index,:) = 0.0
-        cloudsnh(:,:,cm_index,:) = 0.0
-        rhon(:,:,:,cm_index,:) = 0.0
-        drhodzn(:,:,:,cm_index,:) = 0.0
-        tthn(:,:,:,cm_index,:) = 0.0
-        qvhn(:,:,:,cm_index,:) = 0.0
-
-        ! 2d nested fields
-        psn(:,:,:,cm_index,:) = 0.0
-        sdn(:,:,:,cm_index,:) = 0.0
-        msln(:,:,:,cm_index,:) = 0.0
-        tccn(:,:,:,cm_index,:) = 0.0
-        u10n(:,:,:,cm_index,:) = 0.0
-        v10n(:,:,:,cm_index,:) = 0.0
-        tt2n(:,:,:,cm_index,:) = 0.0
-        td2n(:,:,:,cm_index,:) = 0.0
-        lsprecn(:,:,:,cm_index,:) = 0.0
-        convprecn(:,:,:,cm_index,:) = 0.0
-        sshfn(:,:,:,cm_index,:) = 0.0
-        ssrn(:,:,:,cm_index,:) = 0.0
-        surfstrn(:,:,:,cm_index,:) = 0.0
-        ustarn(:,:,:,cm_index,:) = 0.0
-        wstarn(:,:,:,cm_index,:) = 0.0
-        hmixn(:,:,:,cm_index,:) = 0.0
-        tropopausen(:,:,:,cm_index,:) = 0.0
-        olin(:,:,:,cm_index,:) = 0.0
-        diffkn(:,:,:,cm_index,:) = 0.0
-        vdepn(:,:,:,cm_index,:) = 0.0
-
-        ! Auxiliary variables for nests
-        xresoln(:) = 0.0
-        yresoln(:) = 0.0
-        xln(:) = 0.0
-        yln(:) = 0.0
-        xrn(:) = 0.0
-        yrn(:) = 0.0
-
-        ! Variables for polar stereographic projection
-        xglobal=.FALSE.; sglobal=.FALSE.; nglobal=.FALSE.
-        switchnorthg=0.0; switchsouthg=0.0
-        southpolemap(:) = 0.0
-        northpolemap(:) = 0.0
-
-        ! Variables declared in conv_mod (convection)
-        pconv(:) = 0.0
-        phconv(:) = 0.0
-        dpr(:) = 0.0
-        pconv_hpa(:) = 0.0
-        phconv_hpa(:) = 0.0
-        ft(:) = 0.0
-        fq(:) = 0.0
-        fmass(:,:) = 0.0
-        sub(:) = 0.0
-        fmassfrac(:,:) = 0.0
-        cbaseflux(:,:) = 0.0
-        cbasefluxn(:,:,:) = 0.0
-        tconv(:) = 0.0
-        qconv(:) = 0.0
-        qsconv(:) = 0.0
-        psconv=0.0; tt2conv=0.0; td2conv=0.0
-        nconvlev=0.0; nconvtop=0.0
-
-    END SUBROUTINE fpmetbinary_zero
-
-    SUBROUTINE fpio(iounit, ncid, op, cm_index)
+
+
+
+    SUBROUTINE fpio(ncid, op, cm_index)
         IMPLICIT NONE
         INTEGER, INTENT(IN) :: ncid               ! NetCDF file id
-        INTEGER, INTENT(IN) :: iounit
         CHARACTER(LEN=4), INTENT(IN) :: op        ! Operation - DUMP or LOAD
         INTEGER, INTENT(IN) :: cm_index           ! Index of last dimension in
@@ -380,8 +212,5 @@
 
 
-#ifdef RAWBIN
-            WRITE (iounit) PREPROC_FORMAT_VERSION_STR
-
-#endif
+
 
             ! Write the compiled max dimensions from par_mod - these are
@@ -389,7 +218,4 @@
             ! information to provide the structure of arrays
 
-#ifdef RAWBIN
-            WRITE (iounit) nxmax, nymax, nzmax, nuvzmax, nwzmax
-#endif
 
 
@@ -449,11 +275,4 @@
 
 
-
-#ifdef RAWBIN
-            WRITE(iounit) nx, ny, nxmin1, nymin1, nxfield
-            WRITE(iounit) nuvz, nwz, nz, nmixz, nlev_ec
-            WRITE(iounit) dx, dy, xlon0, ylat0, dxconst, dyconst
-#endif
-
             ncret = nf90_def_var(ncid, 'nx', NF90_INT, ncvarid)
             call handle_nf90_err(ncret)
@@ -539,10 +358,4 @@
 
             ! Fixed fields, static in time
-
-
-#ifdef RAWBIN
-            WRITE(iounit) oro, excessoro, lsm, xlanduse, height
-#endif
-
             dim2dids = (/nxmax_dimid, nymax_dimid/)
 
@@ -614,26 +427,4 @@
 
             ! 3d fields
-
-
-
-#ifdef RAWBIN
-            WRITE(iounit) uu(:,:,:,cm_index)
-            WRITE(iounit) vv(:,:,:,cm_index)
-            WRITE(iounit) uupol(:,:,:,cm_index)
-            WRITE(iounit) vvpol(:,:,:,cm_index)
-            WRITE(iounit) ww(:,:,:,cm_index)
-            WRITE(iounit) tt(:,:,:,cm_index)
-            WRITE(iounit) qv(:,:,:,cm_index)
-            WRITE(iounit) pv(:,:,:,cm_index)
-            WRITE(iounit) rho(:,:,:,cm_index)
-            WRITE(iounit) drhodz(:,:,:,cm_index)
-            WRITE(iounit) tth(:,:,:,cm_index)
-            WRITE(iounit) qvh(:,:,:,cm_index)
-            WRITE(iounit) pplev(:,:,:,cm_index)
-            WRITE(iounit) clouds(:,:,:,cm_index)
-            WRITE(iounit) cloudsh(:,:,cm_index)
-#endif
-
-
             dim3dids = (/nxmax_dimid, nymax_dimid, nzmax_dimid/)
 
@@ -836,30 +627,4 @@
 
             ! 2d fields
-
-
-#ifdef RAWBIN
-            WRITE(iounit) ps(:,:,:,cm_index)
-            WRITE(iounit) sd(:,:,:,cm_index)
-            WRITE(iounit) msl(:,:,:,cm_index)
-            WRITE(iounit) tcc(:,:,:,cm_index)
-            WRITE(iounit) u10(:,:,:,cm_index)
-            WRITE(iounit) v10(:,:,:,cm_index)
-            WRITE(iounit) tt2(:,:,:,cm_index)
-            WRITE(iounit) td2(:,:,:,cm_index)
-            WRITE(iounit) lsprec(:,:,:,cm_index)
-            WRITE(iounit) convprec(:,:,:,cm_index)
-            WRITE(iounit) sshf(:,:,:,cm_index)
-            WRITE(iounit) ssr(:,:,:,cm_index)
-            WRITE(iounit) surfstr(:,:,:,cm_index)
-            WRITE(iounit) ustar(:,:,:,cm_index)
-            WRITE(iounit) wstar(:,:,:,cm_index)
-            WRITE(iounit) hmix(:,:,:,cm_index)
-            WRITE(iounit) tropopause(:,:,:,cm_index)
-            WRITE(iounit) oli(:,:,:,cm_index)
-            WRITE(iounit) diffk(:,:,:,cm_index)
-            WRITE(iounit) vdep(:,:,:,cm_index)
-#endif
-
-
             dim2dids = (/nxmax_dimid, nymax_dimid/)
 
@@ -1118,17 +883,4 @@
 
             ! 1d fields
-
-
-
-#ifdef RAWBIN
-            WRITE(iounit) z0(:)
-            WRITE(iounit) akm(:)
-            WRITE(iounit) bkm(:)
-            WRITE(iounit) akz(:)
-            WRITE(iounit) bkz(:)
-            WRITE(iounit) aknew(:)
-            WRITE(iounit) bknew(:)
-#endif
-
             dim1dids = (/numclass_dimid/)
 
@@ -1242,15 +994,5 @@
 
 
-#ifdef RAWBIN
-            WRITE(iounit) nxn(:)
-            WRITE(iounit) nyn(:)
-            WRITE(iounit) dxn(:)
-            WRITE(iounit) dyn(:)
-            WRITE(iounit) xlon0n(:)
-            WRITE(iounit) ylat0n(:)
-#endif
-
             ! Nested, scalar values (for each nest)
-
             dim1dids = (/maxnests_dimid/)
 
@@ -1331,6 +1073,4 @@
 
             ! Nested fields, static over time
-            WRITE(iounit) oron, excessoron, lsmn, xlandusen 
-
             dim3dids = (/nxmaxn_dimid, nymaxn_dimid, maxnests_dimid/)
 
@@ -1390,22 +1130,4 @@
 
             ! 3d nested fields
-
-
-
-#ifdef RAWBIN
-            WRITE(iounit) uun(:,:,:,cm_index,:)
-            WRITE(iounit) vvn(:,:,:,cm_index,:)
-            WRITE(iounit) wwn(:,:,:,cm_index,:)
-            WRITE(iounit) ttn(:,:,:,cm_index,:)
-            WRITE(iounit) qvn(:,:,:,cm_index,:)
-            WRITE(iounit) pvn(:,:,:,cm_index,:)
-            WRITE(iounit) cloudsn(:,:,:,cm_index,:)
-            WRITE(iounit) cloudsnh(:,:,cm_index,:)
-            WRITE(iounit) rhon(:,:,:,cm_index,:)
-            WRITE(iounit) drhodzn(:,:,:,cm_index,:)
-            WRITE(iounit) tthn(:,:,:,cm_index,:)
-            WRITE(iounit) qvhn(:,:,:,cm_index,:)
-#endif
-
             dim4dids = (/nxmaxn_dimid, nymaxn_dimid, nzmax_dimid, maxnests_dimid/)
 
@@ -1563,11 +1285,4 @@
 &                                cloudsnh(0:nxmaxn-1, 0:nymaxn-1, cm_index, 1:maxnests))
             call handle_nf90_err(ncret)
-
-
-
-
-
-
-
 
 
@@ -1579,30 +1294,4 @@
 
             ! 2d nested fields
-
-
-#ifdef RAWBIN
-            WRITE(iounit) psn(:,:,:,cm_index,:)
-            WRITE(iounit) sdn(:,:,:,cm_index,:)
-            WRITE(iounit) msln(:,:,:,cm_index,:)
-            WRITE(iounit) tccn(:,:,:,cm_index,:)
-            WRITE(iounit) u10n(:,:,:,cm_index,:)
-            WRITE(iounit) v10n(:,:,:,cm_index,:)
-            WRITE(iounit) tt2n(:,:,:,cm_index,:)
-            WRITE(iounit) td2n(:,:,:,cm_index,:)
-            WRITE(iounit) lsprecn(:,:,:,cm_index,:)
-            WRITE(iounit) convprecn(:,:,:,cm_index,:)
-            WRITE(iounit) sshfn(:,:,:,cm_index,:)
-            WRITE(iounit) ssrn(:,:,:,cm_index,:)
-            WRITE(iounit) surfstrn(:,:,:,cm_index,:)
-            WRITE(iounit) ustarn(:,:,:,cm_index,:)
-            WRITE(iounit) wstarn(:,:,:,cm_index,:)
-            WRITE(iounit) hmixn(:,:,:,cm_index,:)
-            WRITE(iounit) tropopausen(:,:,:,cm_index,:)
-            WRITE(iounit) olin(:,:,:,cm_index,:)
-            WRITE(iounit) diffkn(:,:,:,cm_index,:)
-            WRITE(iounit) vdepn(:,:,:,cm_index,:)
-#endif
-
-
             dim3dids = (/nxmaxn_dimid, nymaxn_dimid, maxnests_dimid/)
 
@@ -1850,6 +1539,4 @@
 &                                vdepn(0:nxmaxn-1, 0:nymaxn-1, 1:maxspec, cm_index, 1:maxnests))
             call handle_nf90_err(ncret)
-
-
 
 
@@ -1860,18 +1547,5 @@
 
 
-
-
             ! Auxiliary variables for nests
-
-#ifdef RAWBIN
-            WRITE(iounit) xresoln(:)
-            WRITE(iounit) yresoln(:)
-            WRITE(iounit) xln(:)
-            WRITE(iounit) yln(:)
-            WRITE(iounit) xrn(:)
-            WRITE(iounit) yrn(:)
-#endif
-
-
             dim1dids = (/zero_to_maxnests_dimid/)
 
@@ -1956,15 +1630,4 @@
 
             ! Variables for polar stereographic projection
-
-
-
-#ifdef RAWBIN
-            WRITE(iounit) xglobal, sglobal, nglobal
-            WRITE(iounit) switchnorthg, switchsouthg
-            WRITE(iounit) southpolemap(:)
-            WRITE(iounit) northpolemap(:)
-#endif
-
-
             dim1dids = (/polemap_dimid/)
 
@@ -2025,27 +1688,4 @@
 
             ! Variables declared in conv_mod (convection)
-
-
-#ifdef RAWBIN
-            WRITE(iounit) pconv(:)
-            WRITE(iounit) phconv(:)
-            WRITE(iounit) dpr(:)
-            WRITE(iounit) pconv_hpa(:)
-            WRITE(iounit) phconv_hpa(:)
-            WRITE(iounit) ft(:)
-            WRITE(iounit) fq(:)
-            WRITE(iounit) fmass(:,:)
-            WRITE(iounit) sub(:)
-            WRITE(iounit) fmassfrac(:,:)
-            WRITE(iounit) cbaseflux(:,:)
-            WRITE(iounit) cbasefluxn(:,:,:)
-            WRITE(iounit) tconv(:)
-            WRITE(iounit) qconv(:)
-            WRITE(iounit) qsconv(:)
-            WRITE(iounit) psconv, tt2conv, td2conv
-            WRITE(iounit) nconvlev, nconvtop
-#endif
-
-
             dim1dids = (/nconvlevmax_dimid/)
 
@@ -2237,16 +1877,4 @@
             ! Read the preprocessed format version string and insure it
             ! matches this version
-
-
-
-
-
-
-
-#ifdef RAWBIN
-            READ (iounit) temp_preproc_format_version_str
-#endif
-
-
             ncret = nf90_inq_dimid(ncid, 'preproc_fmt_str_dim', preproc_fmt_str_dimid)
             call handle_nf90_err(ncret)            
@@ -2285,20 +1913,5 @@
             ! we abort.
 
-
-
-#ifdef RAWBIN
-            READ (iounit) temp_nxmax, temp_nymax, temp_nzmax, &
-&                         temp_nuvzmax, temp_nwzmax
-#endif
-
-
-
-
-
             ! Get dimensions
-            
-            
-
-
             ncret = nf90_inq_dimid(ncid, 'nxmax', nxmax_dimid)
             call handle_nf90_err(ncret)            
@@ -2381,137 +1994,1203 @@
 
 
-#ifdef RAWBIN
+            ! Get the varid , then read into scalar variable
+            ncret = nf90_inq_varid(ncid, 'nx', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nx)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'ny', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, ny)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'nxmin1', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nxmin1)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'nymin1', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nymin1)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'nxfield', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nxfield)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'nuvz', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nuvz)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'nwz', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nwz)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'nz', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nz)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'nmixz', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nmixz)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'nlev_ec', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nlev_ec)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'dx', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, dx)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'dy', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, dy)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'xlon0', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, xlon0)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'ylat0', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, ylat0)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'dxconst', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, dxconst)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'dyconst', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, dyconst)
+            call handle_nf90_err(ncret)
+
+
+
+
+
+
+            ! Fixed fields, static in time
+            ncret = nf90_inq_varid(ncid, 'oro', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, oro(0:nxmax-1,0:nymax-1))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'excessoro', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, excessoro(0:nxmax-1,0:nymax-1))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'lsm', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, lsm(0:nxmax-1,0:nymax-1))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'xlanduse', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, xlanduse(0:nxmax-1,0:nymax-1, 1:numclass))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'height', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, height(1:nzmax))
+            call handle_nf90_err(ncret)
+
+
+
+
+            ! 3d fields
+
+            ! Get the varid and read the variable into the array
+            ncret = nf90_inq_varid(ncid, 'uu', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, uu(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'vv', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, vv(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'uupol', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, uupol(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'vvpol', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, vvpol(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'ww', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, ww(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'tt', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, tt(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'qv', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, qv(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'pv', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, pv(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'rho', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, rho(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'drhodz', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, drhodz(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'clouds', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, clouds(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'tth', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, tth(0:nxmax-1,0:nymax-1,1:nuvzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'qvh', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, qvh(0:nxmax-1,0:nymax-1,1:nuvzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'pplev', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, pplev(0:nxmax-1,0:nymax-1,1:nuvzmax,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'cloudsh', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, cloudsh(0:nxmax-1,0:nymax-1,cm_index))
+            call handle_nf90_err(ncret)
+
+
+
+
+            PRINT *, 'SUM(tt(0:nxmax-1, 0:nymax-1, 1:nzmax, cm_index)): ', &
+&                                        SUM(tt(0:nxmax-1,0:nymax-1,1:nzmax, cm_index))
+
+
+            PRINT *, 'SUM(clouds(0:nxmax-1, 0:nymax-1, 1:nzmax, cm_index)): ', &
+&                                        SUM(clouds(0:nxmax-1,0:nymax-1,1:nzmax, cm_index))
+
+
+
+            ! 2d fields
+
+            ! Get the varid and read the variable into the array
+            ncret = nf90_inq_varid(ncid, 'ps', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, ps(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'sd', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, sd(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'msl', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, msl(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'tcc', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, tcc(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'u10', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, u10(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'v10', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, v10(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'tt2', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, tt2(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'td2', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, td2(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'lsprec', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, lsprec(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'convprec', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, convprec(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'sshf', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, sshf(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'ssr', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, ssr(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'surfstr', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, surfstr(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'ustar', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, ustar(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'wstar', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, wstar(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'hmix', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, hmix(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'tropopause', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, tropopause(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'oli', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, oli(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'diffk', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, diffk(0:nxmax-1,0:nymax-1,1,cm_index))
+            call handle_nf90_err(ncret)
+
+
+
+
+            PRINT *, 'SUM(ps(0:nxmax-1, 0:nymax-1, 1, cm_index)): ', &
+&                                        SUM(ps(0:nxmax-1,0:nymax-1,1, cm_index))
+
+            PRINT *, 'SUM(wstar(0:nxmax-1, 0:nymax-1, 1, cm_index)): ', &
+&                                        SUM(wstar(0:nxmax-1,0:nymax-1,1, cm_index))
+
+
+            ncret = nf90_inq_varid(ncid, 'vdep', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, vdep(0:nxmax-1,0:nymax-1,1:maxspec, cm_index))
+            call handle_nf90_err(ncret)
+
+
+
+
+
+            ! 1d fields
+
+            ncret = nf90_inq_varid(ncid, 'z0', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, z0(1:numclass))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'akm', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, akm(1:nwzmax))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'bkm', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, bkm(1:nwzmax))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'akz', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, akz(1:nuvzmax))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'bkz', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, bkz(1:nuvzmax))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'aknew', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, aknew(1:nzmax))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'bknew', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, bknew(1:nzmax))
+            call handle_nf90_err(ncret)
+
+
+
+            PRINT *, 'SUM(bknew(1:nzmax)): ', &
+&                                        SUM(bknew(1:nzmax))
+
+
+
+
+            ! Now the nested input grid variables
+            ! Get the compiled values that were written into the FP file, and
+            ! make sure they are equal to the current compiled values, to make
+            ! sure we are working with consistent arrays
+            ncret = nf90_inq_dimid(ncid, 'maxnests', maxnests_dimid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_inquire_dimension(ncid, maxnests_dimid, maxnests_dimname, &
+&                                                temp_maxnests)
+            call handle_nf90_err(ncret)
+            PRINT *, 'temp_maxnests: ', temp_maxnests
+
+            ncret = nf90_inq_dimid(ncid, 'nxmaxn', nxmaxn_dimid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_inquire_dimension(ncid, nxmaxn_dimid, nxmaxn_dimname, &
+&                                                temp_nxmaxn)
+            call handle_nf90_err(ncret)
+            PRINT *, 'temp_nxmaxn: ', temp_nxmaxn
+
+            ncret = nf90_inq_dimid(ncid, 'nymaxn', nymaxn_dimid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_inquire_dimension(ncid, nymaxn_dimid, nymaxn_dimname, &
+&                                                temp_nymaxn)
+            call handle_nf90_err(ncret)
+            PRINT *, 'temp_nymaxn: ', temp_nymaxn
+
+            ! Note that maxspec_dimid and numclass_dimid were checked above
+
+
+
+
+            IF ( (temp_nxmaxn == nxmaxn) .AND. (temp_nymaxn == nymaxn) .AND. &
+&                   (temp_maxnests == maxnests) ) THEN
+                CONTINUE
+            ELSE
+                PRINT *, 'Incompatible dimensions between fp file and current FLEXPART!'
+                ! PRINT *, ''
+                PRINT *, '                  FP file     Compiled FP'
+                PRINT *, 'nxmaxn:     ', temp_nxmaxn, '    ', nxmaxn
+                PRINT *, 'nymaxn:     ', temp_nymaxn, '    ', nymaxn
+                PRINT *, 'maxnests:     ', temp_maxnests, '    ', maxnests
+                STOP
+            END IF
+
+
+
+            ! Nested, scalar values (for each nest)
+            ncret = nf90_inq_varid(ncid, 'nxn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nxn(1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'nyn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nyn(1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'dxn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, dxn(1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'dyn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, dyn(1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'xlon0n', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, xlon0n(1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'ylat0n', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, ylat0n(1:maxnests))
+            call handle_nf90_err(ncret)
+
+
+
+            ! Nested fields, static over time
+            ncret = nf90_inq_varid(ncid, 'oron', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, oron(0:nxmaxn-1,0:nymaxn-1,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'excessoron', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, excessoron(0:nxmaxn-1,0:nymaxn-1,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'lsmn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, lsmn(0:nxmaxn-1,0:nymaxn-1,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'xlandusen', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, xlandusen(0:nxmaxn-1,0:nymaxn-1,1:numclass,1:maxnests))
+            call handle_nf90_err(ncret)
+
+
+            PRINT *, 'SUM(oron): ', SUM(oron)
+
+
+
+
+            ! 3d nested fields
+
+            ncret = nf90_inq_varid(ncid, 'uun', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, uun(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'vvn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, vvn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'wwn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, wwn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'ttn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, ttn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'qvn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, qvn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'pvn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, pvn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'rhon', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, rhon(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'drhodzn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, drhodzn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'tthn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, tthn(0:nxmaxn-1,0:nymaxn-1,1:nuvzmax,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'qvhn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, qvhn(0:nxmaxn-1,0:nymaxn-1,1:nuvzmax,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'cloudsn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, cloudsn(0:nxmaxn-1,0:nymaxn-1,0:nzmax,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'cloudsnh', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, cloudsnh(0:nxmaxn-1,0:nymaxn-1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+
+
+
+            PRINT *, 'SUM(uun): ', SUM(uun(:,:,:,cm_index,:))
+            PRINT *, 'SUM(qvhn): ', SUM(qvhn(:,:,:,cm_index,:))
+            PRINT *, 'SUM(cloudsn): ', SUM(cloudsn(:,:,:,cm_index,:))
+
+
+
+
+            ! 2d nested fields
+            ncret = nf90_inq_varid(ncid, 'psn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, psn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'sdn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, sdn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'msln', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, msln(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'tccn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, tccn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'u10n', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, u10n(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'v10n', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, v10n(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'tt2n', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, tt2n(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'td2n', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, td2n(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'lsprecn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, lsprecn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'convprecn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, convprecn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'sshfn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, sshfn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'ssrn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, ssrn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'surfstrn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, surfstrn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'ustarn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, ustarn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'wstarn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, wstarn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'hmixn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, hmixn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'tropopausen', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, tropopausen(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'olin', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, olin(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'diffkn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, diffkn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'vdepn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, vdepn(0:nxmaxn-1,0:nymaxn-1,1:maxspec,cm_index,1:maxnests))
+            call handle_nf90_err(ncret)
+
+
+
+
+            PRINT *, 'SUM(psn): ', SUM(psn(:,:,:,cm_index,:))
+            PRINT *, 'SUM(surfstrn): ', SUM(surfstrn(:,:,:,cm_index,:))
+            PRINT *, 'SUM(vdepn): ', SUM(vdepn(:,:,:,cm_index,:))
+
+
+
+            ! Auxiliary variables for nests
+            ncret = nf90_inq_varid(ncid, 'xresoln', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, xresoln(0:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'yresoln', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, yresoln(0:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'xln', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, xln(1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'yln', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, yln(1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'xrn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, xrn(1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'yrn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, yrn(1:maxnests))
+            call handle_nf90_err(ncret)
+
+
+
+            PRINT *, 'SUM(yresoln): ', SUM(yresoln)
+            PRINT *, 'SUM(xrn): ', SUM(xrn)
+
+
+
+            ! Variables for polar stereographic projection
+            ncret = nf90_inq_varid(ncid, 'southpolemap', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, southpolemap(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'northpolemap', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, northpolemap(:))
+            call handle_nf90_err(ncret)
+
+            ! xglobal, sglobal, nglobal are LOGICAL vars, and need to be converted
+            ! to INTEGER for NetCDF storage
+            ncret = nf90_inq_varid(ncid, 'xglobal', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, temp_integer)
+            call handle_nf90_err(ncret)
+            xglobal = integer2logical(temp_integer)
+
+            ncret = nf90_inq_varid(ncid, 'sglobal', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, temp_integer)
+            call handle_nf90_err(ncret)
+            sglobal = integer2logical(temp_integer)
+
+            ncret = nf90_inq_varid(ncid, 'nglobal', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, temp_integer)
+            call handle_nf90_err(ncret)
+            nglobal = integer2logical(temp_integer)
+
+            ncret = nf90_inq_varid(ncid, 'switchnorthg', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, switchnorthg)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'switchsouthg', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, switchsouthg)
+            call handle_nf90_err(ncret)
+
+
+            PRINT *, 'SUM(northpolemap): ', SUM(northpolemap)
+            PRINT *, 'xglobal: ', xglobal
+            PRINT *, 'sglobal: ', sglobal
+            PRINT *, 'nglobal: ', nglobal
+            PRINT *, 'switchsouthg: ', switchsouthg
+
+
+
+
+            ! Variables declared in conv_mod (convection)
+            ncret = nf90_inq_varid(ncid, 'pconv', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, pconv(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'dpr', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, dpr(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'pconv_hpa', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, pconv_hpa(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'ft', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, ft(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'fq', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, fq(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'sub', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, sub(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'phconv', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, phconv(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'phconv_hpa', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, phconv_hpa(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'tconv', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, tconv(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'qconv', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, qconv(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'qsconv', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, qsconv(:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'fmass', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, fmass(:,:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'fmassfrac', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, fmassfrac(:,:))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'cbaseflux', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, cbaseflux(0:nxmax-1,0:nymax-1))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'cbasefluxn', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, cbasefluxn(0:nxmaxn-1,0:nymaxn-1,1:maxnests))
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'psconv', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, psconv)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'tt2conv', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, tt2conv)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'td2conv', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, td2conv)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'nconvlev', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nconvlev)
+            call handle_nf90_err(ncret)
+
+            ncret = nf90_inq_varid(ncid, 'nconvtop', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, nconvtop)
+            call handle_nf90_err(ncret)
+
+
+
+
+            PRINT *, 'SUM(pconv): ', SUM(pconv)
+            PRINT *, 'SUM(qconv): ', SUM(qconv)
+            PRINT *, 'SUM(fmassfrac): ', SUM(fmassfrac)
+            PRINT *, 'SUM(cbasefluxn): ', SUM(cbasefluxn)
+            PRINT *, 'tt2conv: ', tt2conv
+            PRINT *, 'nconvlev: ', nconvlev
+
+
+
+        ELSE
+            STOP 'fpio(): Illegal operation' 
+            
+        ENDIF
+    END SUBROUTINE fpio
+
+
+
+
+
+    SUBROUTINE fpio_rawbin(iounit, op, cm_index)
+        IMPLICIT NONE
+        INTEGER, INTENT(IN) :: iounit
+        CHARACTER(LEN=4), INTENT(IN) :: op        ! Operation - DUMP or LOAD
+        INTEGER, INTENT(IN) :: cm_index           ! Index of last dimension in
+                                                  ! most com_mod variables.
+                                                  ! Should be 1 or 2 
+
+
+        INTEGER :: temp_integer   ! temporary value
+
+
+        ! These are temporary variables, used in the LOAD option, for 
+        ! comparing against the current values in FLEXPART of nxmax, nymax, ...
+        INTEGER :: temp_nxmax, temp_nymax, temp_nzmax, &
+&                  temp_nuvzmax, temp_nwzmax, &
+&                  temp_maxspec, temp_numclass,&
+&                  temp_maxnests, temp_nxmaxn, temp_nymaxn, temp_preproc_fmt_str_dim
+
+        CHARACTER(LEN=PREPROC_FMT_STR_DIM) :: temp_preproc_format_version_str
+
+        CHARACTER(LEN=128) :: errmesg
+
+        INTEGER, PARAMETER :: DEF_LEVEL = 3
+
+        if (op == 'DUMP') THEN
+
+
+            ! Write the preprocessing format version string
+            !  NEED TO FILL THIS IN FOR NC4
+
+
+
+            WRITE (iounit) PREPROC_FORMAT_VERSION_STR
+
+
+            ! Write the compiled max dimensions from par_mod - these are
+            ! not meant to be reassigned during a LOAD, but used as "header"
+            ! information to provide the structure of arrays
+
+
+            WRITE (iounit) nxmax, nymax, nzmax, nuvzmax, nwzmax
+
+
+
+
+            ! Scalar values
+
+            ! Fixed fields, static in time
+
+
+
+            WRITE(iounit) oro, excessoro, lsm, xlanduse, height
+
+
+ 
+
+            ! 3d fields
+            WRITE(iounit) uu(:,:,:,cm_index)
+            WRITE(iounit) vv(:,:,:,cm_index)
+            WRITE(iounit) uupol(:,:,:,cm_index)
+            WRITE(iounit) vvpol(:,:,:,cm_index)
+            WRITE(iounit) ww(:,:,:,cm_index)
+            WRITE(iounit) tt(:,:,:,cm_index)
+            WRITE(iounit) qv(:,:,:,cm_index)
+            WRITE(iounit) pv(:,:,:,cm_index)
+            WRITE(iounit) rho(:,:,:,cm_index)
+            WRITE(iounit) drhodz(:,:,:,cm_index)
+            WRITE(iounit) tth(:,:,:,cm_index)
+            WRITE(iounit) qvh(:,:,:,cm_index)
+            WRITE(iounit) pplev(:,:,:,cm_index)
+            WRITE(iounit) clouds(:,:,:,cm_index)
+            WRITE(iounit) cloudsh(:,:,cm_index)
+
+
+
+!            PRINT *, 'SUM(tt(0:nxmax-1, 0:nymax-1, 1:nzmax, cm_index)): ', &
+!&                                        SUM(tt(0:nxmax-1,0:nymax-1,1:nzmax, cm_index))
+
+!            PRINT *, 'SUM(clouds(0:nxmax-1, 0:nymax-1, 1:nzmax, cm_index)): ', &
+!&                                        SUM(clouds(0:nxmax-1,0:nymax-1,1:nzmax, cm_index))
+
+
+
+            ! 2d fields
+            WRITE(iounit) ps(:,:,:,cm_index)
+            WRITE(iounit) sd(:,:,:,cm_index)
+            WRITE(iounit) msl(:,:,:,cm_index)
+            WRITE(iounit) tcc(:,:,:,cm_index)
+            WRITE(iounit) u10(:,:,:,cm_index)
+            WRITE(iounit) v10(:,:,:,cm_index)
+            WRITE(iounit) tt2(:,:,:,cm_index)
+            WRITE(iounit) td2(:,:,:,cm_index)
+            WRITE(iounit) lsprec(:,:,:,cm_index)
+            WRITE(iounit) convprec(:,:,:,cm_index)
+            WRITE(iounit) sshf(:,:,:,cm_index)
+            WRITE(iounit) ssr(:,:,:,cm_index)
+            WRITE(iounit) surfstr(:,:,:,cm_index)
+            WRITE(iounit) ustar(:,:,:,cm_index)
+            WRITE(iounit) wstar(:,:,:,cm_index)
+            WRITE(iounit) hmix(:,:,:,cm_index)
+            WRITE(iounit) tropopause(:,:,:,cm_index)
+            WRITE(iounit) oli(:,:,:,cm_index)
+            WRITE(iounit) diffk(:,:,:,cm_index)
+            WRITE(iounit) vdep(:,:,:,cm_index)
+
+
+
+
+            ! 1d fields
+            WRITE(iounit) z0(:)
+            WRITE(iounit) akm(:)
+            WRITE(iounit) bkm(:)
+            WRITE(iounit) akz(:)
+            WRITE(iounit) bkz(:)
+            WRITE(iounit) aknew(:)
+            WRITE(iounit) bknew(:)
+
+
+
+
+
+!            PRINT *, 'SUM(bknew(1:nzmax)): ', &
+!&                                        SUM(bknew(1:nzmax))
+
+
+
+            ! Getting ready to add in nested code
+
+            ! These are compiled max dimensions from par_mod - these are
+            ! not meant to be reassigned during a LOAD, but used as "header"
+            ! information to provide the structure of arrays
+            WRITE(iounit) nxn(:)
+            WRITE(iounit) nyn(:)
+            WRITE(iounit) dxn(:)
+            WRITE(iounit) dyn(:)
+            WRITE(iounit) xlon0n(:)
+            WRITE(iounit) ylat0n(:)
+
+            ! Nested, scalar values (for each nest)
+
+
+            ! Nested fields, static over time
+            WRITE(iounit) oron, excessoron, lsmn, xlandusen 
+
+
+!           PRINT *, 'SUM(oron): ', SUM(oron)
+
+
+
+            ! 3d nested fields
+            WRITE(iounit) uun(:,:,:,cm_index,:)
+            WRITE(iounit) vvn(:,:,:,cm_index,:)
+            WRITE(iounit) wwn(:,:,:,cm_index,:)
+            WRITE(iounit) ttn(:,:,:,cm_index,:)
+            WRITE(iounit) qvn(:,:,:,cm_index,:)
+            WRITE(iounit) pvn(:,:,:,cm_index,:)
+            WRITE(iounit) cloudsn(:,:,:,cm_index,:)
+            WRITE(iounit) cloudsnh(:,:,cm_index,:)
+            WRITE(iounit) rhon(:,:,:,cm_index,:)
+            WRITE(iounit) drhodzn(:,:,:,cm_index,:)
+            WRITE(iounit) tthn(:,:,:,cm_index,:)
+            WRITE(iounit) qvhn(:,:,:,cm_index,:)
+
+
+
+!            PRINT *, 'SUM(uun): ', SUM(uun(:,:,:,cm_index,:))
+!            PRINT *, 'SUM(qvhn): ', SUM(qvhn(:,:,:,cm_index,:))
+!            PRINT *, 'SUM(cloudsn): ', SUM(cloudsn(:,:,:,cm_index,:))
+
+
+
+            ! 2d nested fields
+            WRITE(iounit) psn(:,:,:,cm_index,:)
+            WRITE(iounit) sdn(:,:,:,cm_index,:)
+            WRITE(iounit) msln(:,:,:,cm_index,:)
+            WRITE(iounit) tccn(:,:,:,cm_index,:)
+            WRITE(iounit) u10n(:,:,:,cm_index,:)
+            WRITE(iounit) v10n(:,:,:,cm_index,:)
+            WRITE(iounit) tt2n(:,:,:,cm_index,:)
+            WRITE(iounit) td2n(:,:,:,cm_index,:)
+            WRITE(iounit) lsprecn(:,:,:,cm_index,:)
+            WRITE(iounit) convprecn(:,:,:,cm_index,:)
+            WRITE(iounit) sshfn(:,:,:,cm_index,:)
+            WRITE(iounit) ssrn(:,:,:,cm_index,:)
+            WRITE(iounit) surfstrn(:,:,:,cm_index,:)
+            WRITE(iounit) ustarn(:,:,:,cm_index,:)
+            WRITE(iounit) wstarn(:,:,:,cm_index,:)
+            WRITE(iounit) hmixn(:,:,:,cm_index,:)
+            WRITE(iounit) tropopausen(:,:,:,cm_index,:)
+            WRITE(iounit) olin(:,:,:,cm_index,:)
+            WRITE(iounit) diffkn(:,:,:,cm_index,:)
+            WRITE(iounit) vdepn(:,:,:,cm_index,:)
+
+
+
+!            PRINT *, 'SUM(psn): ', SUM(psn(:,:,:,cm_index,:))
+!            PRINT *, 'SUM(surfstrn): ', SUM(surfstrn(:,:,:,cm_index,:))
+!            PRINT *, 'SUM(vdepn): ', SUM(vdepn(:,:,:,cm_index,:))
+
+
+
+
+
+            ! Auxiliary variables for nests
+            WRITE(iounit) xresoln(:)
+            WRITE(iounit) yresoln(:)
+            WRITE(iounit) xln(:)
+            WRITE(iounit) yln(:)
+            WRITE(iounit) xrn(:)
+            WRITE(iounit) yrn(:)
+
+
+
+!            PRINT *, 'SUM(yresoln): ', SUM(yresoln)
+!            PRINT *, 'SUM(xrn): ', SUM(xrn)
+
+
+
+            ! Variables for polar stereographic projection
+            WRITE(iounit) xglobal, sglobal, nglobal
+            WRITE(iounit) switchnorthg, switchsouthg
+            WRITE(iounit) southpolemap(:)
+            WRITE(iounit) northpolemap(:)
+
+
+
+
+
+!            PRINT *, 'SUM(northpolemap): ', SUM(northpolemap)
+!            PRINT *, 'xglobal: ', xglobal
+!            PRINT *, 'sglobal: ', sglobal
+!            PRINT *, 'nglobal: ', nglobal
+!            PRINT *, 'switchsouthg: ', switchsouthg
+
+            ! Variables declared in conv_mod (convection)
+            WRITE(iounit) pconv(:)
+            WRITE(iounit) phconv(:)
+            WRITE(iounit) dpr(:)
+            WRITE(iounit) pconv_hpa(:)
+            WRITE(iounit) phconv_hpa(:)
+            WRITE(iounit) ft(:)
+            WRITE(iounit) fq(:)
+            WRITE(iounit) fmass(:,:)
+            WRITE(iounit) sub(:)
+            WRITE(iounit) fmassfrac(:,:)
+            WRITE(iounit) cbaseflux(:,:)
+            WRITE(iounit) cbasefluxn(:,:,:)
+            WRITE(iounit) tconv(:)
+            WRITE(iounit) qconv(:)
+            WRITE(iounit) qsconv(:)
+            WRITE(iounit) psconv, tt2conv, td2conv
+            WRITE(iounit) nconvlev, nconvtop
+
+
+
+
+!            PRINT *, 'SUM(pconv): ', SUM(pconv)
+!            PRINT *, 'SUM(qconv): ', SUM(qconv)
+!            PRINT *, 'SUM(fmassfrac): ', SUM(fmassfrac)
+!            PRINT *, 'SUM(cbasefluxn): ', SUM(cbasefluxn)
+!            PRINT *, 'tt2conv: ', tt2conv
+!            PRINT *, 'nconvlev: ', nconvlev
+
+
+
+        ELSE IF (op == 'LOAD') THEN 
+
+            ! Read the preprocessed format version string and insure it
+            ! matches this version
+            READ (iounit) temp_preproc_format_version_str
+
+            PRINT *, 'Reading preprocessed file format version: ', &
+&                    temp_preproc_format_version_str
+            IF (TRIM(temp_preproc_format_version_str) == &
+&                                        TRIM(PREPROC_FORMAT_VERSION_STR)) THEN
+                CONTINUE
+            ELSE
+                ! PRINT *, ''  GK: causes relocation truncated to fit: R_X86_64_32
+                PRINT *, 'Inconsistent preprocessing format version'
+                PRINT *, 'Expected Version: ', PREPROC_FORMAT_VERSION_STR
+                PRINT *, 'Detected Version: ', temp_preproc_format_version_str
+                ! PRINT *, ''
+                STOP
+            END IF
+
+
+            ! Read the compiled max dimensions that were dumped from par_mod 
+            ! when creating the fp file, so that we can compare against
+            ! current FLEXPART dimensions - they need to be the same, or else
+            ! we abort.
+            READ (iounit) temp_nxmax, temp_nymax, temp_nzmax, &
+&                         temp_nuvzmax, temp_nwzmax
+
+
+
+
+
+            ! Get dimensions
+            IF ( (temp_nxmax == nxmax) .AND. (temp_nymax == nymax) .AND. &
+&                   (temp_nzmax == nzmax) .AND. &
+&                   (temp_nuvzmax == nuvzmax) .AND. &
+&                   (temp_nwzmax == nwzmax) ) THEN
+                CONTINUE
+            ELSE
+                PRINT *, 'Incompatible dimensions between fp file and current FLEXPART!'
+                PRINT *, '                  FP file     Compiled FP'
+                PRINT *, 'nxmax:     ', temp_nxmax, '    ', nxmax 
+                PRINT *, 'nymax:     ', temp_nymax, '    ', nymax 
+                PRINT *, 'nzmax:     ', temp_nzmax, '    ', nzmax 
+                PRINT *, 'nuvzmax:     ', temp_nuvzmax, '    ', nuvzmax 
+                PRINT *, 'nwzmax:     ', temp_nwzmax, '    ', nwzmax
+                STOP
+            END IF
+
+
+
+
+            ! Scalar values
             READ(iounit) nx, ny, nxmin1, nymin1, nxfield
             READ(iounit) nuvz, nwz, nz, nmixz, nlev_ec
             READ(iounit) dx, dy, xlon0, ylat0, dxconst, dyconst
-#endif
-
-
-
-            ! Get the varid , then read into scalar variable
-            ncret = nf90_inq_varid(ncid, 'nx', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nx)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'ny', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, ny)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'nxmin1', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nxmin1)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'nymin1', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nymin1)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'nxfield', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nxfield)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'nuvz', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nuvz)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'nwz', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nwz)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'nz', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nz)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'nmixz', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nmixz)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'nlev_ec', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nlev_ec)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'dx', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, dx)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'dy', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, dy)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'xlon0', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, xlon0)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'ylat0', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, ylat0)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'dxconst', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, dxconst)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'dyconst', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, dyconst)
-            call handle_nf90_err(ncret)
-
-
-
-
-
-
-            ! Fixed fields, static in time
-            
-#ifdef RAWBIN            
+
+
+
+
+
+            ! Fixed fields, static in time           
             READ(iounit) oro, excessoro, lsm, xlanduse, height
-#endif
-
-            ncret = nf90_inq_varid(ncid, 'oro', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, oro(0:nxmax-1,0:nymax-1))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'excessoro', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, excessoro(0:nxmax-1,0:nymax-1))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'lsm', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, lsm(0:nxmax-1,0:nymax-1))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'xlanduse', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, xlanduse(0:nxmax-1,0:nymax-1, 1:numclass))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'height', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, height(1:nzmax))
-            call handle_nf90_err(ncret)
-
 
 
 
             ! 3d fields
-
-
-
-#ifdef RAWBIN
             READ(iounit) uu(:,:,:,cm_index)
             READ(iounit) vv(:,:,:,cm_index)
@@ -2529,100 +3208,16 @@
             READ(iounit) clouds(:,:,:,cm_index)
             READ(iounit) cloudsh(:,:,cm_index)
-#endif
-
-
-
-            ! Get the varid and read the variable into the array
-            ncret = nf90_inq_varid(ncid, 'uu', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, uu(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'vv', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, vv(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'uupol', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, uupol(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'vvpol', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, vvpol(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'ww', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, ww(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'tt', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, tt(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'qv', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, qv(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'pv', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, pv(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'rho', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, rho(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'drhodz', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, drhodz(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'clouds', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, clouds(0:nxmax-1,0:nymax-1,1:nzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'tth', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, tth(0:nxmax-1,0:nymax-1,1:nuvzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'qvh', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, qvh(0:nxmax-1,0:nymax-1,1:nuvzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'pplev', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, pplev(0:nxmax-1,0:nymax-1,1:nuvzmax,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'cloudsh', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, cloudsh(0:nxmax-1,0:nymax-1,cm_index))
-            call handle_nf90_err(ncret)
-
-
-
-
-            PRINT *, 'SUM(tt(0:nxmax-1, 0:nymax-1, 1:nzmax, cm_index)): ', &
-&                                        SUM(tt(0:nxmax-1,0:nymax-1,1:nzmax, cm_index))
-
-
-            PRINT *, 'SUM(clouds(0:nxmax-1, 0:nymax-1, 1:nzmax, cm_index)): ', &
-&                                        SUM(clouds(0:nxmax-1,0:nymax-1,1:nzmax, cm_index))
+
+
+!            PRINT *, 'SUM(tt(0:nxmax-1, 0:nymax-1, 1:nzmax, cm_index)): ', &
+!&                                        SUM(tt(0:nxmax-1,0:nymax-1,1:nzmax, cm_index))
+
+
+!            PRINT *, 'SUM(clouds(0:nxmax-1, 0:nymax-1, 1:nzmax, cm_index)): ', &
+!&                                        SUM(clouds(0:nxmax-1,0:nymax-1,1:nzmax, cm_index))
 
 
 
             ! 2d fields
-
-
-#ifdef RAWBIN
             READ(iounit) ps(:,:,:,cm_index)
             READ(iounit) sd(:,:,:,cm_index)
@@ -2645,119 +3240,14 @@
             READ(iounit) diffk(:,:,:,cm_index)
             READ(iounit) vdep(:,:,:,cm_index)
-#endif
-
-
-
-            ! Get the varid and read the variable into the array
-            ncret = nf90_inq_varid(ncid, 'ps', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, ps(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'sd', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, sd(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'msl', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, msl(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'tcc', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, tcc(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'u10', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, u10(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'v10', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, v10(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'tt2', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, tt2(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'td2', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, td2(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'lsprec', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, lsprec(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'convprec', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, convprec(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'sshf', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, sshf(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'ssr', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, ssr(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'surfstr', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, surfstr(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'ustar', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, ustar(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'wstar', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, wstar(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'hmix', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, hmix(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'tropopause', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, tropopause(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'oli', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, oli(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'diffk', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, diffk(0:nxmax-1,0:nymax-1,1,cm_index))
-            call handle_nf90_err(ncret)
-
-
-
-
-            PRINT *, 'SUM(ps(0:nxmax-1, 0:nymax-1, 1, cm_index)): ', &
-&                                        SUM(ps(0:nxmax-1,0:nymax-1,1, cm_index))
-
-            PRINT *, 'SUM(wstar(0:nxmax-1, 0:nymax-1, 1, cm_index)): ', &
-&                                        SUM(wstar(0:nxmax-1,0:nymax-1,1, cm_index))
-
-
-            ncret = nf90_inq_varid(ncid, 'vdep', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, vdep(0:nxmax-1,0:nymax-1,1:maxspec, cm_index))
-            call handle_nf90_err(ncret)
-
+
+
+
+
+
+!            PRINT *, 'SUM(ps(0:nxmax-1, 0:nymax-1, 1, cm_index)): ', &
+!&                                        SUM(ps(0:nxmax-1,0:nymax-1,1, cm_index))
+
+!            PRINT *, 'SUM(wstar(0:nxmax-1, 0:nymax-1, 1, cm_index)): ', &
+!&                                        SUM(wstar(0:nxmax-1,0:nymax-1,1, cm_index))
 
 
@@ -2765,6 +3255,4 @@
 
             ! 1d fields
-
-#ifdef RAWBIN
             READ(iounit) z0(:)
             READ(iounit) akm(:)
@@ -2774,100 +3262,15 @@
             READ(iounit) aknew(:)
             READ(iounit) bknew(:)
-#endif
-
-            ncret = nf90_inq_varid(ncid, 'z0', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, z0(1:numclass))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'akm', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, akm(1:nwzmax))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'bkm', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, bkm(1:nwzmax))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'akz', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, akz(1:nuvzmax))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'bkz', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, bkz(1:nuvzmax))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'aknew', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, aknew(1:nzmax))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'bknew', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, bknew(1:nzmax))
-            call handle_nf90_err(ncret)
-
-
-
-            PRINT *, 'SUM(bknew(1:nzmax)): ', &
-&                                        SUM(bknew(1:nzmax))
-
-
-
-
-            ! Now the nested input grid variables
-            ! Get the compiled values that were written into the FP file, and
-            ! make sure they are equal to the current compiled values, to make
-            ! sure we are working with consistent arrays
-            ncret = nf90_inq_dimid(ncid, 'maxnests', maxnests_dimid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_inquire_dimension(ncid, maxnests_dimid, maxnests_dimname, &
-&                                                temp_maxnests)
-            call handle_nf90_err(ncret)
-            PRINT *, 'temp_maxnests: ', temp_maxnests
-
-            ncret = nf90_inq_dimid(ncid, 'nxmaxn', nxmaxn_dimid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_inquire_dimension(ncid, nxmaxn_dimid, nxmaxn_dimname, &
-&                                                temp_nxmaxn)
-            call handle_nf90_err(ncret)
-            PRINT *, 'temp_nxmaxn: ', temp_nxmaxn
-
-            ncret = nf90_inq_dimid(ncid, 'nymaxn', nymaxn_dimid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_inquire_dimension(ncid, nymaxn_dimid, nymaxn_dimname, &
-&                                                temp_nymaxn)
-            call handle_nf90_err(ncret)
-            PRINT *, 'temp_nymaxn: ', temp_nymaxn
-
-            ! Note that maxspec_dimid and numclass_dimid were checked above
-
-
-
-
-            IF ( (temp_nxmaxn == nxmaxn) .AND. (temp_nymaxn == nymaxn) .AND. &
-&                   (temp_maxnests == maxnests) ) THEN
-                CONTINUE
-            ELSE
-                PRINT *, 'Incompatible dimensions between fp file and current FLEXPART!'
-                ! PRINT *, ''
-                PRINT *, '                  FP file     Compiled FP'
-                PRINT *, 'nxmaxn:     ', temp_nxmaxn, '    ', nxmaxn
-                PRINT *, 'nymaxn:     ', temp_nymaxn, '    ', nymaxn
-                PRINT *, 'maxnests:     ', temp_maxnests, '    ', maxnests
-                STOP
-            END IF
+
+
+
+!            PRINT *, 'SUM(bknew(1:nzmax)): ', &
+!&                                        SUM(bknew(1:nzmax))
+
+
 
 
 
             ! Nested, scalar values (for each nest)
-
-
-
-
-#ifdef RAWBIN
             READ(iounit) nxn(:)
             READ(iounit) nyn(:)
@@ -2876,67 +3279,13 @@
             READ(iounit) xlon0n(:)
             READ(iounit) ylat0n(:)
-#endif
-
-
-            ncret = nf90_inq_varid(ncid, 'nxn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nxn(1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'nyn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nyn(1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'dxn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, dxn(1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'dyn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, dyn(1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'xlon0n', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, xlon0n(1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'ylat0n', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, ylat0n(1:maxnests))
-            call handle_nf90_err(ncret)
 
 
 
             ! Nested fields, static over time
-
-#ifdef RAWBIN
             READ(iounit) oron, excessoron, lsmn, xlandusen 
-#endif
-
-            ncret = nf90_inq_varid(ncid, 'oron', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, oron(0:nxmaxn-1,0:nymaxn-1,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'excessoron', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, excessoron(0:nxmaxn-1,0:nymaxn-1,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'lsmn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, lsmn(0:nxmaxn-1,0:nymaxn-1,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'xlandusen', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, xlandusen(0:nxmaxn-1,0:nymaxn-1,1:numclass,1:maxnests))
-            call handle_nf90_err(ncret)
-
-
-            PRINT *, 'SUM(oron): ', SUM(oron)
+
+
+
+!            PRINT *, 'SUM(oron): ', SUM(oron)
 
 
@@ -2944,6 +3293,4 @@
 
             ! 3d nested fields
-
-#ifdef RAWBIN
             READ(iounit) uun(:,:,:,cm_index,:)
             READ(iounit) vvn(:,:,:,cm_index,:)
@@ -2958,72 +3305,8 @@
             READ(iounit) tthn(:,:,:,cm_index,:)
             READ(iounit) qvhn(:,:,:,cm_index,:)
-#endif
-
-            ncret = nf90_inq_varid(ncid, 'uun', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, uun(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'vvn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, vvn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'wwn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, wwn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'ttn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, ttn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'qvn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, qvn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'pvn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, pvn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'rhon', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, rhon(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'drhodzn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, drhodzn(0:nxmaxn-1,0:nymaxn-1,1:nzmax,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'tthn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, tthn(0:nxmaxn-1,0:nymaxn-1,1:nuvzmax,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'qvhn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, qvhn(0:nxmaxn-1,0:nymaxn-1,1:nuvzmax,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'cloudsn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, cloudsn(0:nxmaxn-1,0:nymaxn-1,0:nzmax,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'cloudsnh', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, cloudsnh(0:nxmaxn-1,0:nymaxn-1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-
-
-
-            PRINT *, 'SUM(uun): ', SUM(uun(:,:,:,cm_index,:))
-            PRINT *, 'SUM(qvhn): ', SUM(qvhn(:,:,:,cm_index,:))
-            PRINT *, 'SUM(cloudsn): ', SUM(cloudsn(:,:,:,cm_index,:))
+
+!            PRINT *, 'SUM(uun): ', SUM(uun(:,:,:,cm_index,:))
+!            PRINT *, 'SUM(qvhn): ', SUM(qvhn(:,:,:,cm_index,:))
+!            PRINT *, 'SUM(cloudsn): ', SUM(cloudsn(:,:,:,cm_index,:))
 
 
@@ -3031,7 +3314,4 @@
 
             ! 2d nested fields
-
-
-#ifdef RAWBIN
             READ(iounit) psn(:,:,:,cm_index,:)
             READ(iounit) sdn(:,:,:,cm_index,:)
@@ -3054,120 +3334,12 @@
             READ(iounit) diffkn(:,:,:,cm_index,:)
             READ(iounit) vdepn(:,:,:,cm_index,:)
-#endif
-
-
-            ncret = nf90_inq_varid(ncid, 'psn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, psn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'sdn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, sdn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'msln', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, msln(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'tccn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, tccn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'u10n', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, u10n(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'v10n', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, v10n(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'tt2n', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, tt2n(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'td2n', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, td2n(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'lsprecn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, lsprecn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'convprecn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, convprecn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'sshfn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, sshfn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'ssrn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, ssrn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'surfstrn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, surfstrn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'ustarn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, ustarn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'wstarn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, wstarn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'hmixn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, hmixn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'tropopausen', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, tropopausen(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'olin', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, olin(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'diffkn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, diffkn(0:nxmaxn-1,0:nymaxn-1,1,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'vdepn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, vdepn(0:nxmaxn-1,0:nymaxn-1,1:maxspec,cm_index,1:maxnests))
-            call handle_nf90_err(ncret)
-
-
-
-
-            PRINT *, 'SUM(psn): ', SUM(psn(:,:,:,cm_index,:))
-            PRINT *, 'SUM(surfstrn): ', SUM(surfstrn(:,:,:,cm_index,:))
-            PRINT *, 'SUM(vdepn): ', SUM(vdepn(:,:,:,cm_index,:))
+
+!            PRINT *, 'SUM(psn): ', SUM(psn(:,:,:,cm_index,:))
+!            PRINT *, 'SUM(surfstrn): ', SUM(surfstrn(:,:,:,cm_index,:))
+!            PRINT *, 'SUM(vdepn): ', SUM(vdepn(:,:,:,cm_index,:))
 
 
 
             ! Auxiliary variables for nests
-
-
-#ifdef RAWBIN
             READ(iounit) xresoln(:)
             READ(iounit) yresoln(:)
@@ -3175,101 +3347,23 @@
             READ(iounit) yln(:)
             READ(iounit) xrn(:)
-            READ(iounit) yrn(:)
-#endif
-
-
-            ncret = nf90_inq_varid(ncid, 'xresoln', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, xresoln(0:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'yresoln', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, yresoln(0:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'xln', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, xln(1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'yln', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, yln(1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'xrn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, xrn(1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'yrn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, yrn(1:maxnests))
-            call handle_nf90_err(ncret)
-
-
-
-            PRINT *, 'SUM(yresoln): ', SUM(yresoln)
-            PRINT *, 'SUM(xrn): ', SUM(xrn)
+
+
+!            PRINT *, 'SUM(yresoln): ', SUM(yresoln)
+!            PRINT *, 'SUM(xrn): ', SUM(xrn)
 
 
 
             ! Variables for polar stereographic projection
-
-
-#ifdef RAWBIN
             READ(iounit) xglobal, sglobal, nglobal
             READ(iounit) switchnorthg, switchsouthg
             READ(iounit) southpolemap(:)
             READ(iounit) northpolemap(:)
-#endif
-
-            ncret = nf90_inq_varid(ncid, 'southpolemap', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, southpolemap(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'northpolemap', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, northpolemap(:))
-            call handle_nf90_err(ncret)
-
-            ! xglobal, sglobal, nglobal are LOGICAL vars, and need to be converted
-            ! to INTEGER for NetCDF storage
-            ncret = nf90_inq_varid(ncid, 'xglobal', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, temp_integer)
-            call handle_nf90_err(ncret)
-            xglobal = integer2logical(temp_integer)
-
-            ncret = nf90_inq_varid(ncid, 'sglobal', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, temp_integer)
-            call handle_nf90_err(ncret)
-            sglobal = integer2logical(temp_integer)
-
-            ncret = nf90_inq_varid(ncid, 'nglobal', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, temp_integer)
-            call handle_nf90_err(ncret)
-            nglobal = integer2logical(temp_integer)
-
-            ncret = nf90_inq_varid(ncid, 'switchnorthg', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, switchnorthg)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'switchsouthg', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, switchsouthg)
-            call handle_nf90_err(ncret)
-
-
-            PRINT *, 'SUM(northpolemap): ', SUM(northpolemap)
-            PRINT *, 'xglobal: ', xglobal
-            PRINT *, 'sglobal: ', sglobal
-            PRINT *, 'nglobal: ', nglobal
-            PRINT *, 'switchsouthg: ', switchsouthg
+
+
+!            PRINT *, 'SUM(northpolemap): ', SUM(northpolemap)
+!            PRINT *, 'xglobal: ', xglobal
+!            PRINT *, 'sglobal: ', sglobal
+!            PRINT *, 'nglobal: ', nglobal
+!            PRINT *, 'switchsouthg: ', switchsouthg
 
 
@@ -3277,7 +3371,4 @@
 
             ! Variables declared in conv_mod (convection)
-
-
-#ifdef RAWBIN
             READ(iounit) pconv(:)
             READ(iounit) phconv(:)
@@ -3297,171 +3388,26 @@
             READ(iounit) psconv, tt2conv, td2conv
             READ(iounit) nconvlev, nconvtop
-#endif
-
-
-
-            ncret = nf90_inq_varid(ncid, 'pconv', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, pconv(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'dpr', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, dpr(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'pconv_hpa', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, pconv_hpa(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'ft', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, ft(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'fq', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, fq(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'sub', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, sub(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'phconv', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, phconv(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'phconv_hpa', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, phconv_hpa(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'tconv', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, tconv(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'qconv', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, qconv(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'qsconv', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, qsconv(:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'fmass', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, fmass(:,:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'fmassfrac', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, fmassfrac(:,:))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'cbaseflux', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, cbaseflux(0:nxmax-1,0:nymax-1))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'cbasefluxn', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, cbasefluxn(0:nxmaxn-1,0:nymaxn-1,1:maxnests))
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'psconv', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, psconv)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'tt2conv', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, tt2conv)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'td2conv', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, td2conv)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'nconvlev', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nconvlev)
-            call handle_nf90_err(ncret)
-
-            ncret = nf90_inq_varid(ncid, 'nconvtop', ncvarid)
-            call handle_nf90_err(ncret)
-            ncret = nf90_get_var(ncid, ncvarid, nconvtop)
-            call handle_nf90_err(ncret)
-
-
-
-
-            PRINT *, 'SUM(pconv): ', SUM(pconv)
-            PRINT *, 'SUM(qconv): ', SUM(qconv)
-            PRINT *, 'SUM(fmassfrac): ', SUM(fmassfrac)
-            PRINT *, 'SUM(cbasefluxn): ', SUM(cbasefluxn)
-            PRINT *, 'tt2conv: ', tt2conv
-            PRINT *, 'nconvlev: ', nconvlev
+
+
+
+
+
+!            PRINT *, 'SUM(pconv): ', SUM(pconv)
+!            PRINT *, 'SUM(qconv): ', SUM(qconv)
+!            PRINT *, 'SUM(fmassfrac): ', SUM(fmassfrac)
+!            PRINT *, 'SUM(cbasefluxn): ', SUM(cbasefluxn)
+!            PRINT *, 'tt2conv: ', tt2conv
+!            PRINT *, 'nconvlev: ', nconvlev
 
 
 
         ELSE
-            STOP 'fpio(): Illegal operation' 
+            STOP 'fpio_rawbin(): Illegal operation' 
             
         ENDIF
-    END SUBROUTINE fpio
-
-    SUBROUTINE fpmetbinary_filetext(filename, cm_index)
-
-        ! This is a utility subroutine meant to be used for testing purposes.
-        ! It facilitates the text output of variables read in from the 
-        ! specified .fp file.  This routine will easily cause the program
-        ! to crash due memory allocation issues, particularly when you are
-        ! trying to text print 3d arrays in a single formatted statetment.
-        
-        CHARACTER(LEN=*), INTENT(IN) :: filename
-        INTEGER, INTENT(IN) :: cm_index           ! Index of last dimension in
-                                                  ! most com_mod variables.
-                                                  ! Should be 1 or 2 
-
-        !OPEN(IOUNIT_TEXTOUT, file=filename, action='WRITE', status='REPLACE', &
-        !    form="formatted", access="stream")
-        OPEN(IOUNIT_TEXTOUT, file=filename, action='WRITE', &
-             form="formatted", access="APPEND")
-
-        WRITE(IOUNIT_TEXTOUT, *) 'oro: ', oro
-        WRITE(IOUNIT_TEXTOUT, *) 'excessoro: ', excessoro
-        WRITE(IOUNIT_TEXTOUT, *) 'lsm: ', lsm
-        WRITE(IOUNIT_TEXTOUT, *) 'xlanduse: ', xlanduse
-        WRITE(IOUNIT_TEXTOUT, *) 'height: ', height
-
-        WRITE(IOUNIT_TEXTOUT, *) 'uu: ', uu(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'vv: ', vv(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'uupol: ', uupol(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'vvpol: ', vvpol(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'ww: ', ww(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'tt: ', tt(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'qv: ', qv(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'pv: ', pv(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'rho: ', rho(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'drhodz: ', drhodz(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'tth: ', tth(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'qvh: ', qvh(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'pplev: ', pplev(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'clouds: ', clouds(:,:,:,cm_index)
-        WRITE(IOUNIT_TEXTOUT, *) 'cloudsh: ', cloudsh(:,:,cm_index)
-
-
-
-
-        CLOSE(IOUNIT_TEXTOUT)
-    END SUBROUTINE fpmetbinary_filetext
+    END SUBROUTINE fpio_rawbin
+
+
+
 
     subroutine handle_nf90_err(status)
