LOCK statement

Standard: F77 F90 F95 F2003 F2008 Example program


LOCK ( lock-variable [ , lock-stat ]... )

lock-stat ::= ACQUIRED_LOCK = scalar-logical-variable
| ERRMSG = errmsg-variable
| STAT = stat-variable

The lock-variable must be a scalar variable of type LOCK_TYPE from the intrinsic module ISO_FORTRAN_ENV. The errmsg-variable must be a scalar Character variable with default kind, and the stat-variable must be a scalar Integer variable; these are further described in the STAT= and ERRMSG= specifier pages.


This statement locks a lock variable. If the lock is already locked by another image, it will wait until it becomes unlocked unless the ACQUIRED_LOCK= specifier appears. If the lock is already locked by this image, an error occurs; the stat-variable will be assigned the value of STAT_LOCKED from the intrinsic module ISO_FORTRAN_ENV.

Note that if any error occurs and STAT= does not appear, the program will be terminated.


ERRMSG= specifier, STAT= specifier, LOCK_TYPE from ISO_FORTRAN_ENV, UNLOCK statement